diff --git a/code/game/objects/items/devices/PDA/cart.dm b/code/game/objects/items/devices/PDA/cart.dm index 24a2db67d7..5d576959fb 100644 --- a/code/game/objects/items/devices/PDA/cart.dm +++ b/code/game/objects/items/devices/PDA/cart.dm @@ -354,12 +354,12 @@ var/muleData[0] muleData["name"] = M.suffix muleData["location"] = get_area(M) - muleData["mode"] = M.mode + muleData["paused"] = M.paused muleData["home"] = M.homeName muleData["target"] = M.targetName muleData["ref"] = "\ref[M]" muleData["load"] = M.load ? M.load.name : "Nothing" - + mulebotsData[++mulebotsData.len] = muleData.Copy() values["mulebotcount"] = count diff --git a/code/modules/mob/living/bot/bot.dm b/code/modules/mob/living/bot/bot.dm index 9f7a42f9fc..5679cc1a46 100644 --- a/code/modules/mob/living/bot/bot.dm +++ b/code/modules/mob/living/bot/bot.dm @@ -24,6 +24,7 @@ var/list/ignore_list = list() var/list/patrol_path = list() var/list/target_path = list() + var/turf/obstacle = null var/wait_if_pulled = 0 // Only applies to moving to the target var/will_patrol = 0 // Not a setting - whether or no this type of bots patrols at all @@ -35,6 +36,7 @@ var/target_patience = 5 var/frustration = 0 + var/max_frustration = 0 /mob/living/bot/New() ..() @@ -133,7 +135,7 @@ /mob/living/bot/proc/handleAI() if(ignore_list.len) for(var/atom/A in ignore_list) - if(!A.loc || prob(1)) + if(!A || !A.loc || prob(1)) ignore_list -= A handleRegular() if(target && confirmTarget(target)) @@ -141,19 +143,24 @@ handleAdjacentTarget() else handleRangedTarget() - if(get_dist(src, target) > min_target_dist && (!wait_if_pulled || !pulledby)) + if(!wait_if_pulled || !pulledby) for(var/i = 1 to target_speed) stepToTarget() - sleep(20 / target_speed) + if(i < target_speed) + sleep(20 / target_speed) + if(max_frustration && frustration > max_frustration * target_speed) + handleFrustrated(1) else - target = null + resetTarget() lookForTargets() if(will_patrol && !pulledby && !target) if(patrol_path.len) for(var/i = 1 to patrol_speed) handlePatrol() if(i < patrol_speed) - sleep(20 / target_speed) + sleep(20 / patrol_speed) + if(max_frustration && frustration > max_frustration * patrol_speed) + handleFrustrated(0) else startPatrol() else @@ -171,9 +178,19 @@ /mob/living/bot/proc/stepToTarget() if(!target || !target.loc) return - if(!target_path.len || get_turf(target) != target_path[target_path.len]) - calcTargetPath() - makeStep(target_path) + if(get_dist(src, target) > min_target_dist) + if(!target_path.len || get_turf(target) != target_path[target_path.len]) + calcTargetPath() + if(makeStep(target_path)) + frustration = 0 + else if(max_frustration) + ++frustration + return + +/mob/living/bot/proc/handleFrustrated(var/targ) + obstacle = targ ? target_path[1] : patrol_path[1] + target_path = list() + patrol_path = list() return /mob/living/bot/proc/lookForTargets() @@ -195,9 +212,10 @@ /mob/living/bot/proc/startPatrol() var/turf/T = getPatrolTurf() if(T) - patrol_path = AStar(get_turf(loc), T, /turf/proc/CardinalTurfsWithAccess, /turf/proc/Distance, 0, max_patrol_dist, id = botcard) + patrol_path = AStar(get_turf(loc), T, /turf/proc/CardinalTurfsWithAccess, /turf/proc/Distance, 0, max_patrol_dist, id = botcard, exclude = obstacle) if(!patrol_path) patrol_path = list() + obstacle = null return /mob/living/bot/proc/getPatrolTurf() @@ -207,24 +225,29 @@ return /mob/living/bot/proc/calcTargetPath() - target_path = AStar(get_turf(loc), get_turf(target), /turf/proc/CardinalTurfsWithAccess, /turf/proc/Distance, 0, max_target_dist, id = botcard) + target_path = AStar(get_turf(loc), get_turf(target), /turf/proc/CardinalTurfsWithAccess, /turf/proc/Distance, 0, max_target_dist, id = botcard, exclude = obstacle) if(!target_path) if(target && target.loc) ignore_list |= target - target = null - target_path = list() + resetTarget() + obstacle = null return /mob/living/bot/proc/makeStep(var/list/path) if(!path.len) - return + return 0 var/turf/T = path[1] if(get_turf(src) == T) path -= T - makeStep(path) - return + return makeStep(path) - step_towards(src, T) + return step_towards(src, T) + +/mob/living/bot/proc/resetTarget() + target = null + target_path = list() + frustration = 0 + obstacle = null /mob/living/bot/proc/turn_on() if(stat) @@ -238,8 +261,7 @@ on = 0 set_light(0) update_icons() - target = null - target_path = list() + resetTarget() patrol_path = list() ignore_list = list() diff --git a/code/modules/mob/living/bot/mulebot.dm b/code/modules/mob/living/bot/mulebot.dm index dbc42f8282..c330e0efc0 100644 --- a/code/modules/mob/living/bot/mulebot.dm +++ b/code/modules/mob/living/bot/mulebot.dm @@ -17,11 +17,15 @@ maxHealth = 150 mob_bump_flag = HEAVY - botcard_access = list(access_maint_tunnels, access_mailsorting, access_cargo, access_cargo_bot, access_qm, access_mining, access_mining_station) + min_target_dist = 0 max_target_dist = 250 + target_speed = 3 + max_frustration = 5 + botcard_access = list(access_maint_tunnels, access_mailsorting, access_cargo, access_cargo_bot, access_qm, access_mining, access_mining_station) var/atom/movable/load + var/paused = 0 var/crates_only = 1 var/auto_return = 1 var/safety = 1 @@ -29,7 +33,6 @@ var/targetName var/turf/home var/homeName - var/turf/obstacle var/global/amount = 0 @@ -160,6 +163,7 @@ /mob/living/bot/mulebot/proc/obeyCommand(var/command) switch(command) if("Home") + resetTarget() target = home targetName = "Home" if("SetD") @@ -173,12 +177,13 @@ else alert("No destination beacons available.") if(new_dest) + resetTarget() target = get_turf(beaconlist[new_dest]) targetName = new_dest if("GoTD") - + paused = 0 if("Stop") - + paused = 1 /mob/living/bot/mulebot/emag_act(var/remaining_charges, var/user) locked = !locked @@ -191,7 +196,7 @@ if(open) icon_state = "mulebot-hatch" return - if(mode == MULE_MOVING || mode == MULE_UNLOAD) + if(target_path.len && !paused) icon_state = "mulebot1" return icon_state = "mulebot0" @@ -199,68 +204,41 @@ /mob/living/bot/mulebot/handleRegular() if(!safety && prob(1)) flick("mulebot-emagged", src) + update_icons() -/mob/living/bot/mulebot/handleAdjacentTarget() - if(get_turf(target) == src.loc) - UnarmedAttack(target) - -/mob/living/bot/mulebot/UnarmedAttack(var/turf/T) - unload(dir) - -/mob/living/bot/mulebot/Life() +/mob/living/bot/mulebot/handleFrustrated() + custom_emote(2, "makes a sighing buzz.") + playsound(loc, 'sound/machines/buzz-sigh.ogg', 50, 0) ..() - switch(mode) - if(MULE_MOVING) // Moving to target - if(!target) // Return home - if(auto_return && home) - target = home - targetName = "Home" - mode = MULE_LOST - else - mode = MULE_IDLE - update_icons() - return - if(loc == target) // Unload or stop - custom_emote(2, "makes a chiming sound.") - playsound(loc, 'sound/machines/chime.ogg', 50, 0) - mode = MULE_UNLOAD - update_icons() - return - if(path.len) // Move - makeStep() - sleep(10) - if(path.len) - makeStep() - else - mode = MULE_LOST +/mob/living/bot/mulebot/handleAdjacentTarget() + if(target == src.loc) + custom_emote(2, "makes a chiming sound.") + playsound(loc, 'sound/machines/chime.ogg', 50, 0) + UnarmedAttack(target) + resetTarget() + if(auto_return && home && (loc != home)) + target = home + targetName = "Home" - update_icons() - return - if(MULE_UNLOAD) - +/mob/living/bot/mulebot/confirmTarget() + return 1 - if(auto_return && home && (loc != home)) - target = home - targetName = "Home" - mode = MULE_LOST - else - mode = MULE_IDLE - update_icons() - return - if(MULE_PATH_DONE) // Done with path - obstacle = null - if(path.len) - frustration = 0 - mode = MULE_MOVING - else - if(home) - target = home - targetName = "Home" - mode = MULE_LOST - else - mode = MULE_IDLE - update_icons() +/mob/living/bot/mulebot/calcTargetPath() + ..() + if(!target_path.len && target != home) // I presume that target is not null + resetTarget() + target = home + targetName = "Home" + +/mob/living/bot/mulebot/stepToTarget() + if(paused) + return + ..() + +/mob/living/bot/mulebot/UnarmedAttack(var/turf/T) + if(T == src.loc) + unload(dir) /mob/living/bot/mulebot/Bump(var/mob/living/M) if(!safety && istype(M)) @@ -269,30 +247,6 @@ M.Weaken(5) ..() - /* -/mob/living/bot/mulebot/proc/makeStep() - var/turf/next = path[1] - if(next == loc) - path -= next - return - - var/moved = step_towards(src, next) - if(moved) - frustration = 0 - path -= next - else if(frustration < 6) - if(frustration == 3) - custom_emote(2, "makes an annoyed buzzing sound") - playsound(loc, 'sound/machines/buzz-two.ogg', 50, 0) - ++frustration - else - custom_emote(2, "makes a sighing buzz.") - playsound(loc, 'sound/machines/buzz-sigh.ogg', 50, 0) - obstacle = next - - mode = MULE_LOST - */ - /mob/living/bot/mulebot/proc/runOver(var/mob/living/carbon/human/H) if(istype(H)) // No safety checks - WILL run over lying humans. Stop ERPing in the maint! visible_message("[src] drives over [H]!") @@ -331,11 +285,6 @@ new /obj/effect/decal/cleanable/blood/oil(Tsec) ..() -/mob/living/bot/mulebot/proc/calc_path(var/turf/avoid = null) - path = AStar(loc, target, /turf/proc/CardinalTurfsWithAccess, /turf/proc/Distance, 0, 250, id = botcard, exclude = avoid) - if(!path) - path = list() - /mob/living/bot/mulebot/proc/load(var/atom/movable/C) if(busy || load || get_dist(C, src) > 1 || !isturf(C.loc)) return @@ -353,10 +302,6 @@ if(istype(crate)) crate.close() - //I'm sure someone will come along and ask why this is here... well people were dragging screen items onto the mule, and that was not cool. - //So this is a simple fix that only allows a selection of item types to be considered. Further narrowing-down is below. - //if(!istype(C,/obj/item) && !istype(C,/obj/machinery) && !istype(C,/obj/structure) && !ismob(C)) - // return busy = 1 C.loc = loc @@ -397,11 +342,3 @@ AM.layer = initial(AM.layer) AM.pixel_y = initial(AM.pixel_y) busy = 0 - -#undef MULE_IDLE -#undef MULE_MOVING -#undef MULE_UNLOAD -#undef MULE_LOST -#undef MULE_CALC_MIN -#undef MULE_CALC_MAX -#undef MULE_PATH_DONE diff --git a/nano/templates/pda.tmpl b/nano/templates/pda.tmpl index 756f6edce0..396cf8e34f 100644 --- a/nano/templates/pda.tmpl +++ b/nano/templates/pda.tmpl @@ -775,14 +775,10 @@ Used In File(s): \code\game\objects\items\devices\PDA\PDA.dm
Status:
- {{if value.mode == 0}} - Idle - {{else value.mode == 1}} - Moving - {{else value.mode == 2}} - Unloading - {{else}} - Calculating path + {{if value.paused == 0}} + Nominal + {{else value.paused == 1}} + Paused {{/if}}