Basic mulebots. last basic bot refactor (#95899)

my watch has ended

<img width="401" height="256" alt="ffffff"
src="https://github.com/user-attachments/assets/a539203c-020b-4ad8-b034-f69ec0eafa78"
/>



## Changelog
🆑 Profakos (originally pulled from their branch, did massive chunk of
this), Ben10omintrix
refactor: mulebots have been refactored. please report any bugs
/🆑
This commit is contained in:
Ben10Omintrix
2026-06-11 23:58:13 -07:00
committed by GitHub
parent 8d37abd0dd
commit 64baa1979d
49 changed files with 1069 additions and 2287 deletions
+1 -1
View File
@@ -196,7 +196,7 @@ GLOBAL_LIST_INIT(command_strings, list(
/mob/living/basic/bot/proc/get_emagged_message()
return get_policy(ROLE_EMAGGED_BOT) || "You are a malfunctioning bot! Disrupt everyone and cause chaos!"
/mob/living/basic/bot/proc/turn_on()
/mob/living/basic/bot/proc/turn_on(mob/user)
if(stat == DEAD)
return FALSE
set_mode_flags(bot_mode_flags | BOT_MODE_ON)
@@ -0,0 +1,193 @@
/mob/living/basic/bot/mulebot
name = "\improper MULEbot"
desc = "A Multiple Utility Load Effector bot."
icon = 'icons/mob/silicon/aibots.dmi'
icon_state = "mulebot0"
base_icon_state = "mulebot"
light_color = "#ffcc99"
light_power = 0.8
health = 50
maxHealth = 50
damage_coeff = list(BRUTE = 0.5, BURN = 0.7, TOX = 0, STAMINA = 0, OXY = 0)
density = TRUE
mob_size = MOB_SIZE_LARGE
move_resist = MOVE_FORCE_STRONG
animate_movement = SLIDE_STEPS
speed = 3
combat_mode = TRUE
buckle_lying = 0
buckle_prevents_pull = TRUE // No pulling loaded shit
bot_mode_flags = ~BOT_MODE_ROUNDSTART_POSSESSION
req_one_access = list(ACCESS_ROBOTICS, ACCESS_CARGO)
radio_key = /obj/item/encryptionkey/headset_cargo
radio_channel = RADIO_CHANNEL_SUPPLY
pass_flags = PASSFLAPS
bot_type = MULE_BOT
additional_access = /datum/id_trim/job/cargo_technician
path_image_color = "#7F5200"
hud_type = /datum/hud/living/mulebot
hackables = "obstacle detection circuits"
possessed_message = "You are a MULEbot! Do your best to make sure that packages get to their destination!"
ai_controller = /datum/ai_controller/basic_controller/bot/mulebot
/// unique identifier in case there are multiple mulebots.
var/id
/// what we're transporting
var/atom/movable/load
/// who's riding us
var/mob/living/passenger
///flags of mulebot mode
var/mulebot_delivery_flags = MULEBOT_RETURN_MODE | MULEBOT_AUTO_PICKUP_MODE | MULEBOT_REPORT_DELIVERY_MODE
///Internal Powercell
var/obj/item/stock_parts/power_store/cell
///How much power we use when we move.
var/cell_move_power_usage = 0.0005 * STANDARD_CELL_CHARGE
///The amount of steps we should take until we rest for a time.
var/num_steps = 0
///The chance to be deleted and replaced by a different mule
var/replacement_chance = 0.666
///home destination, only used by mappers.
var/home_destination = ""
/mob/living/basic/bot/mulebot/Initialize(mapload)
. = ..()
if(prob(replacement_chance) && mapload)
new /mob/living/basic/bot/mulebot/paranormal(loc)
return INITIALIZE_HINT_QDEL
set_wires(new /datum/wires/mulebot(src))
var/obj/item/stock_parts/power_store/cell/upgraded/new_cell = new(src)
assign_cell(new_cell)
ai_controller.set_blackboard_key(BB_MULEBOT_HOME_BEACON, "")
AddElement(/datum/element/ridable, /datum/component/riding/creature/mulebot)
ADD_TRAIT(src, TRAIT_NOMOBSWAP, INNATE_TRAIT)
add_traits(list(TRAIT_NOMOBSWAP, TRAIT_COMBAT_MODE_LOCK), INNATE_TRAIT)
RegisterSignal(src, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(on_pre_move))
set_id(suffix || assign_random_name())
suffix = null
if(name == "\improper MULEbot")
name = "\improper MULEbot [id]"
set_home(get_turf(src))
ai_controller.update_able_to_run()
update_appearance()
/mob/living/basic/bot/mulebot/Destroy()
UnregisterSignal(src, COMSIG_MOVABLE_PRE_MOVE)
unload()
QDEL_NULL(cell)
return ..()
/mob/living/basic/bot/mulebot/proc/assign_cell(atom/new_cell)
cell = new_cell
var/atom/movable/screen/mob_charge/charge_hud = hud_used?.screen_objects[HUD_MULEBOT_CHARGE]
charge_hud?.update_battery_overlay(new_cell)
charge_hud?.calculate_charge()
/mob/living/basic/bot/mulebot/attack_hand(mob/living/carbon/human/user, list/modifiers)
if(bot_access_flags & BOT_COVER_MAINTS_OPEN && !HAS_AI_ACCESS(user))
wires.interact(user)
return
if(wires.is_cut(WIRE_RX) && HAS_AI_ACCESS(user))
return
return ..()
/mob/living/basic/bot/mulebot/examine(mob/user)
. = ..()
if(bot_access_flags & BOT_COVER_MAINTS_OPEN)
if(cell)
. += span_notice("It has \a [cell] installed.")
. += span_info("You can use a <b>crowbar</b> to remove it.")
else
. += span_notice("It has an empty compartment where a <b>power cell</b> can be installed.")
if(load) //observer check is so we don't show the name of the ghost that's sitting on it to prevent metagaming who's ded.
. += span_notice("\A [isobserver(load) ? "ghostly figure" : load] is on its load platform.")
/mob/living/basic/bot/mulebot/get_cell()
return cell
/mob/living/basic/bot/mulebot/melee_attack(atom/target, list/modifiers, ignore_cooldown = FALSE)
if(!can_unarmed_attack())
return
if(isturf(target) && isturf(loc) && loc.Adjacent(target) && load)
unload(get_dir(loc, target))
else
return ..()
/mob/living/basic/bot/mulebot/turn_on(mob/user)
if(bot_access_flags & BOT_COVER_MAINTS_OPEN)
if(user)
to_chat(user, span_warning("[src]'s maintenance panel is open!"))
return FALSE
if(!has_power())
if(user)
to_chat(user, span_warning("[src] has no power!"))
return FALSE
return ..()
/mob/living/basic/bot/mulebot/update_icon_state() //if you change the icon_state names, please make sure to update /datum/wires/mulebot/on_pulse() as well. <3
. = ..()
icon_state = "[base_icon_state][(bot_mode_flags & BOT_MODE_ON) ? wires?.is_cut(WIRE_AVOIDANCE) : "0"]"
/mob/living/basic/bot/mulebot/update_overlays()
. = ..()
if(bot_access_flags & BOT_COVER_MAINTS_OPEN)
. += "[base_icon_state]-hatch"
if(isnull(load) || ismob(load)) //mob offsets and such are handled by the riding component / buckling
return
var/mutable_appearance/load_overlay = mutable_appearance(load.icon, load.icon_state, layer + 0.01)
load_overlay.pixel_y = initial(load.pixel_y) + 11
. += load_overlay
/mob/living/basic/bot/mulebot/proc/handle_buzzing(datum/move_loop/has_target/jps/frustrations/source, frustration_counter)
SIGNAL_HANDLER
update_bot_mode(new_mode = BOT_BLOCKED)
var/buzz_mode = frustration_counter >= source.maximum_frustrations ? MULEBOT_MOOD_ANNOYED : MULEBOT_MOOD_SIGH
buzz(buzz_mode)
/mob/living/basic/bot/mulebot/handle_loop_movement(atom/movable/source, atom/oldloc, dir, forced) //incase we start moving again after being previously blocked, update our mode
. = ..()
if(mode != BOT_BLOCKED)
return
var/obj/machinery/navbeacon/beacon = ai_controller.current_movement_target
if(!istype(beacon))
return
var/intended_mode = beacon.location == ai_controller.blackboard[BB_MULEBOT_HOME_BEACON] ? BOT_GO_HOME : BOT_DELIVER
update_bot_mode(new_mode = intended_mode)
///Noises that mulebots make
/mob/living/basic/bot/mulebot/proc/buzz(type)
switch(type)
if(MULEBOT_MOOD_SIGH)
audible_message(span_hear("[src] makes a sighing buzz."))
playsound(src, 'sound/machines/buzz/buzz-sigh.ogg', 50, FALSE)
if(MULEBOT_MOOD_ANNOYED)
audible_message(span_hear("[src] makes an annoyed buzzing sound."))
playsound(src, 'sound/machines/buzz/buzz-two.ogg', 50, FALSE)
if(MULEBOT_MOOD_DELIGHT)
audible_message(span_hear("[src] makes a delighted ping!"))
playsound(src, 'sound/machines/ping.ogg', 50, FALSE)
if(MULEBOT_MOOD_CHIME)
audible_message(span_hear("[src] makes a chiming sound!"))
playsound(src, 'sound/machines/chime.ogg', 50, FALSE)
flick("[base_icon_state]1", src)
/// returns true if the bot is fully powered.
/mob/living/basic/bot/mulebot/proc/has_power()
return cell && cell.charge > 0 && (!wires.is_cut(WIRE_POWER1) && !wires.is_cut(WIRE_POWER2))
@@ -0,0 +1,145 @@
/datum/ai_controller/basic_controller/bot/mulebot
blackboard = list(
BB_SALUTE_MESSAGES = list(
"blinks its light in appreciation towards",
)
)
ai_movement = /datum/ai_movement/jps/bot/mulebot
max_target_distance = AI_MULEBOT_PATH_LENGTH
planning_subtrees = list(
/datum/ai_planning_subtree/respond_to_summon,
/datum/ai_planning_subtree/salute_authority,
/datum/ai_planning_subtree/attempt_delivery,
/datum/ai_planning_subtree/find_delivery_beacon,
)
reset_keys = list(
BB_BOT_SUMMON_TARGET,
BB_MULEBOT_DESTINATION_BEACON,
BB_MULEBOT_TRAVEL_TARGET,
)
/datum/ai_controller/basic_controller/bot/mulebot/get_able_to_run()
var/mob/living/basic/bot/mulebot/bot_pawn = pawn
if(!bot_pawn.has_power())
return AI_UNABLE_TO_RUN
return ..()
/datum/ai_controller/basic_controller/bot/mulebot/setup_able_to_run()
. = ..()
var/mob/living/basic/bot/my_bot = pawn
var/static/list/wire_signals = list(
COMSIG_MEND_WIRE(WIRE_POWER1), //this framework is insane
COMSIG_MEND_WIRE(WIRE_POWER2),
COMSIG_CUT_WIRE(WIRE_POWER1),
COMSIG_CUT_WIRE(WIRE_POWER2),
)
RegisterSignals(my_bot.wires, wire_signals, PROC_REF(update_able_to_run))
var/static/list/content_signals = list(
COMSIG_ATOM_ENTERED,
COMSIG_ATOM_EXITED,
)
RegisterSignals(my_bot, content_signals, PROC_REF(update_able_to_run))
/datum/ai_planning_subtree/find_delivery_beacon
///what behavior do we use to seek beacons
var/find_beacon_behaviour = /datum/ai_behavior/find_delivery_beacon
/datum/ai_planning_subtree/find_delivery_beacon/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
var/mob/living/basic/bot/mulebot/bot_pawn = controller.pawn
if(bot_pawn.wires.is_cut(WIRE_BEACON))
return
if(!controller.blackboard_key_exists(BB_MULEBOT_TRAVEL_TARGET))
controller.queue_behavior(find_beacon_behaviour, BB_MULEBOT_TRAVEL_TARGET)
/datum/ai_behavior/find_delivery_beacon
behavior_flags = AI_BEHAVIOR_CAN_PLAN_DURING_EXECUTION
/datum/ai_behavior/find_delivery_beacon/perform(seconds_per_tick, datum/ai_controller/controller, target_key)
var/mob/living/basic/bot/mulebot/bot_pawn = controller.pawn
var/atom/delivery_beacon
var/beacon_tag = null
switch(bot_pawn.mode)
if(BOT_DELIVER)
beacon_tag = controller.blackboard[BB_MULEBOT_DESTINATION_BEACON]
if(BOT_GO_HOME)
beacon_tag = controller.blackboard[BB_MULEBOT_HOME_BEACON]
else
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED
for(var/obj/machinery/navbeacon/beacon as anything in GLOB.deliverybeacons)
if(beacon.location == beacon_tag)
delivery_beacon = beacon
break
if(isnull(delivery_beacon))
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_FAILED
controller.set_blackboard_key(BB_MULEBOT_TRAVEL_TARGET, delivery_beacon)
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED
/datum/ai_behavior/travel_towards/delivery_beacon
new_movement_type = /datum/ai_movement/jps/bot/mulebot
/datum/ai_planning_subtree/attempt_delivery
///behavior we use to unload crates
var/delivery_behaviour = /datum/ai_behavior/handle_delivery
/datum/ai_planning_subtree/attempt_delivery/SelectBehaviors(datum/ai_controller/controller, seconds_per_tick)
if(!controller.blackboard_key_exists(BB_MULEBOT_TRAVEL_TARGET))
return
controller.queue_behavior(delivery_behaviour, BB_MULEBOT_TRAVEL_TARGET)
return SUBTREE_RETURN_FINISH_PLANNING
/datum/ai_behavior/handle_delivery
behavior_flags = AI_BEHAVIOR_REQUIRE_MOVEMENT | AI_BEHAVIOR_REQUIRE_REACH
/datum/ai_behavior/handle_delivery/setup(datum/ai_controller/controller, target_key)
. = ..()
var/atom/target = controller.blackboard[target_key]
if(QDELETED(target))
return FALSE
set_movement_target(controller, target)
/datum/ai_behavior/handle_delivery/perform(seconds_per_tick, datum/ai_controller/controller, target_key)
var/obj/machinery/navbeacon/beacon = controller.blackboard[target_key]
var/mob/living/basic/bot/mulebot/bot_pawn = controller.pawn
var/load_direction = beacon.codes[NAVBEACON_DELIVERY_DIRECTION] // this will be the load/unload dir
if(!load_direction)
load_direction = beacon.dir // fallback
load_direction = text2num(load_direction)
if(bot_pawn.load)
if(bot_pawn.mulebot_delivery_flags & MULEBOT_REPORT_DELIVERY_MODE)
bot_pawn.radio_channel = RADIO_CHANNEL_SUPPLY //Supply channel
bot_pawn.buzz(MULEBOT_MOOD_CHIME)
bot_pawn.speak("Destination [RUNECHAT_BOLD("[beacon.location]")] reached. Unloading [bot_pawn.load].", bot_pawn.radio_channel)
bot_pawn.unload(load_direction)
else
if(bot_pawn.mulebot_delivery_flags & MULEBOT_AUTO_PICKUP_MODE) // find a crate
var/atom/movable/atom_to_pick_up
if(bot_pawn.wires.is_cut(WIRE_LOADCHECK)) // if hacked, load first unanchored thing we find
for(var/atom/movable/target_atom in get_step(bot_pawn.loc, load_direction))
if(!target_atom.anchored)
atom_to_pick_up = target_atom
break
else // otherwise, look for crates only
atom_to_pick_up = locate(/obj/structure/closet/crate) in get_step(bot_pawn.loc, load_direction)
if(atom_to_pick_up?.Adjacent(bot_pawn))
bot_pawn.load(atom_to_pick_up)
if(bot_pawn.mulebot_delivery_flags & MULEBOT_REPORT_DELIVERY_MODE)
bot_pawn.speak("Now loading [bot_pawn.load] at [RUNECHAT_BOLD("[get_area_name(bot_pawn)]")].", bot_pawn.radio_channel)
if((bot_pawn.mulebot_delivery_flags & MULEBOT_RETURN_MODE) && controller.blackboard[BB_MULEBOT_HOME_BEACON] && controller.blackboard[BB_MULEBOT_HOME_BEACON] != beacon.location)
bot_pawn.update_bot_mode(new_mode = BOT_GO_HOME)
controller.clear_blackboard_key(BB_MULEBOT_TRAVEL_TARGET)
else
bot_pawn.bot_reset() // otherwise go idle
return AI_BEHAVIOR_DELAY | AI_BEHAVIOR_SUCCEEDED
@@ -0,0 +1,116 @@
/mob/living/basic/bot/mulebot/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Mule", name)
ui.open()
/mob/living/basic/bot/mulebot/ui_data(mob/user)
var/list/data = list()
data["powerStatus"] = bot_mode_flags & BOT_MODE_ON
data["locked"] = bot_access_flags & BOT_COVER_LOCKED
data["siliconUser"] = HAS_SILICON_ACCESS(user)
data["mode"] = mode ? "[mode]" : "Ready"
data["modeStatus"] = ""
switch(mode)
if(BOT_IDLE, BOT_DELIVER, BOT_GO_HOME)
data["modeStatus"] = "good"
if(BOT_BLOCKED, BOT_NAV, BOT_WAIT_FOR_NAV)
data["modeStatus"] = "average"
if(BOT_NO_ROUTE)
data["modeStatus"] = "bad"
data["load"] = get_load_name()
data["destination"] = ai_controller.blackboard[BB_MULEBOT_DESTINATION_BEACON]
data["homeDestination"] = ai_controller.blackboard[BB_MULEBOT_HOME_BEACON]
data["destinationsList"] = GLOB.deliverybeacontags
data["cellPercent"] = cell?.percent()
data["autoReturn"] = mulebot_delivery_flags & MULEBOT_RETURN_MODE
data["autoPickup"] = mulebot_delivery_flags & MULEBOT_AUTO_PICKUP_MODE
data["reportDelivery"] = mulebot_delivery_flags & MULEBOT_REPORT_DELIVERY_MODE
data["botId"] = id
data["allowPossession"] = bot_mode_flags & BOT_MODE_CAN_BE_SAPIENT
data["possessionEnabled"] = can_be_possessed
data["paiInserted"] = !!paicard
return data
/mob/living/basic/bot/mulebot/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
var/mob/user = ui.user
if(. || (bot_access_flags & BOT_COVER_LOCKED && !HAS_SILICON_ACCESS(user)))
return
bot_control(action, user, params)
return TRUE
/mob/living/basic/bot/mulebot/bot_control(command, mob/user, list/params = list(), pda = FALSE)
if(pda && wires.is_cut(WIRE_RX)) // MULE wireless is controlled by wires.
return
switch(command)
if("stop")
if(mode != BOT_IDLE)
bot_reset()
if("go")
if(mode == BOT_IDLE)
start()
if("home")
if(mode == BOT_IDLE || mode == BOT_DELIVER)
start_home()
if("destination")
var/new_dest
if(pda)
new_dest = tgui_input_list(user, "Enter Destination", "Mulebot Settings", GLOB.deliverybeacontags, ai_controller.blackboard[BB_MULEBOT_DESTINATION_BEACON])
else
new_dest = params["value"]
if(new_dest)
set_destination(new_dest)
if("setid")
var/new_id = tgui_input_text(user, "Enter ID", "ID Assignment", id, max_length = MAX_NAME_LEN)
if(new_id)
set_id(new_id)
name = "\improper MULEbot [new_id]"
if("sethome")
var/new_home = tgui_input_list(user, "Enter Home", "Mulebot Settings", GLOB.deliverybeacontags, ai_controller.blackboard[BB_MULEBOT_HOME_BEACON])
if(new_home)
ai_controller.set_blackboard_key(BB_MULEBOT_HOME_BEACON, new_home)
if("unload")
if(load && mode != BOT_HUNT)
unload()
if("autoret")
mulebot_delivery_flags ^= MULEBOT_RETURN_MODE
if("autopick")
mulebot_delivery_flags ^= MULEBOT_AUTO_PICKUP_MODE
if("report")
mulebot_delivery_flags ^= MULEBOT_REPORT_DELIVERY_MODE
/mob/living/basic/bot/mulebot/proc/start()
if(!(bot_mode_flags & BOT_MODE_ON))
return
if(ai_controller.blackboard[BB_MULEBOT_DESTINATION_BEACON] == ai_controller.blackboard[BB_MULEBOT_HOME_BEACON])
update_bot_mode(new_mode = BOT_GO_HOME)
else
update_bot_mode(new_mode = BOT_DELIVER)
/mob/living/basic/bot/mulebot/proc/start_home()
set_destination(ai_controller.blackboard[BB_MULEBOT_HOME_BEACON])
update_bot_mode(new_mode = BOT_GO_HOME)
/mob/living/basic/bot/mulebot/proc/set_destination(new_destination)
ai_controller.set_blackboard_key(BB_MULEBOT_DESTINATION_BEACON, new_destination)
/mob/living/basic/bot/mulebot/proc/set_home(turf/home_loc)
if(home_destination)
ai_controller.set_blackboard_key(BB_MULEBOT_HOME_BEACON, home_destination)
home_destination = null
if(!istype(home_loc))
CRASH("MULEbot [id] was requested to set a home location to [home_loc ? "an invalid home loc ([home_loc.type])" : "null"]")
var/obj/machinery/navbeacon/home_beacon = locate() in home_loc
if(isnull(home_beacon))
ai_controller.set_blackboard_key(BB_MULEBOT_HOME_BEACON, "")
return
ai_controller.set_blackboard_key(BB_MULEBOT_HOME_BEACON, home_beacon.location)
log_transport("[id]: MULEbot successfuly set home location to ID [home_beacon.location] at [home_beacon.x], [home_beacon.y], [home_beacon.z]")
///Sets the new ID of the mulebot
/mob/living/basic/bot/mulebot/proc/set_id(new_id)
id = new_id
@@ -0,0 +1,117 @@
/mob/living/basic/bot/mulebot/execute_resist()
. = ..()
if(load)
unload()
/mob/living/basic/bot/mulebot/Exited(atom/movable/gone, direction)
. = ..()
if(gone == load)
unload()
if(gone == cell)
turn_off()
assign_cell()
cell = null
set_cell_hud()
/mob/living/basic/bot/mulebot/Entered(obj/item/stock_parts/power_store/cell/arrived, atom/old_loc, list/atom/old_locs)
. = ..()
if(istype(arrived) && isnull(cell))
assign_cell(arrived)
// mousedrop a crate to load the bot
// can load anything if hacked
/mob/living/basic/bot/mulebot/mouse_drop_receive(atom/movable/atom_to_load, mob/user, params)
if(!isliving(user))
return
if(!istype(atom_to_load) || isdead(atom_to_load) || iseyemob(atom_to_load) || istype(atom_to_load, /obj/effect/dummy/phased_mob))
return
load(atom_to_load)
/mob/living/basic/bot/mulebot/post_unbuckle_mob(mob/living/M)
load = null
return ..()
/mob/living/basic/bot/mulebot/relaymove(mob/living/user, direction)
if(user.incapacitated)
return
if(load == user)
unload()
/mob/living/basic/bot/mulebot/remove_air(amount) //To prevent riders suffocating
return loc ? loc.remove_air(amount) : null
/// Called to load an atom on the mulebot, which is usually a crate, unless if hacked
/mob/living/basic/bot/mulebot/proc/load(atom/movable/atom_to_load)
if(load || atom_to_load.anchored)
return
if(!isturf(atom_to_load.loc)) //To prevent the loading from stuff from someone's inventory or screen icons.
return
var/obj/structure/closet/crate/crate = atom_to_load
if(!istype(crate))
if(!wires.is_cut(WIRE_LOADCHECK))
buzz(MULEBOT_MOOD_SIGH)
return // if not hacked, only allow crates to be loaded
crate = null
if(crate || isobj(atom_to_load))
var/obj/object_to_load = atom_to_load
if(object_to_load.has_buckled_mobs() || (locate(/mob) in atom_to_load)) //can't load non crates objects with mobs buckled to it or inside it.
buzz(MULEBOT_MOOD_SIGH)
return
if(crate)
crate.close() //make sure the crate is closed
object_to_load.forceMove(src)
else if(isliving(atom_to_load))
if(!load_mob(atom_to_load)) //forceMove() is handled in buckling
return
load = atom_to_load
update_appearance()
///resolves the name to display for the loaded mob. primarily needed for the paranormal subtype since we don't want to show the name of ghosts riding it.
/mob/living/basic/bot/mulebot/proc/get_load_name()
return load ? load.name : null
///Loads a mob onto the mulebot
/mob/living/basic/bot/mulebot/proc/load_mob(mob/living/mob_to_load)
can_buckle = TRUE
if(buckle_mob(mob_to_load))
passenger = mob_to_load
load = mob_to_load
can_buckle = FALSE
return TRUE
// called to unload the bot
// argument is optional direction to unload
// if zero or null, unload at bot's location
/mob/living/basic/bot/mulebot/proc/unload(dirn)
if(QDELETED(load))
if(load) //if our thing was qdel'd, there's likely a leftover reference. just clear it and remove the overlay. we'll let the bot keep moving around to prevent it abruptly stopping somewhere.
load = null
update_appearance()
return
update_bot_mode(new_mode = BOT_IDLE)
var/atom/movable/cached_load = load //cache the load since unbuckling mobs clears the var.
unbuckle_all_mobs()
if(load) //don't have to do any of this for mobs.
cached_load.forceMove(loc)
cached_load.pixel_y = initial(cached_load.pixel_y)
cached_load.layer = initial(cached_load.layer)
SET_PLANE_EXPLICIT(cached_load, initial(cached_load.plane), src)
load = null
if(dirn) //move the thing to the delivery point.
cached_load.Move(get_step(loc,dirn), dirn)
update_appearance()
@@ -0,0 +1,74 @@
/mob/living/basic/bot/mulebot/proc/set_cell_hud()
if(!has_power())
set_hud_image_state(DIAG_BATT_HUD, "hudnobatt")
return
var/atom/movable/screen/mob_charge/charge_hud = hud_used?.screen_objects[HUD_MULEBOT_CHARGE]
charge_hud?.calculate_charge()
set_hud_image_state(DIAG_BATT_HUD, "hudbatt[RoundDiagBar(cell.charge/cell.maxcharge)]")
/atom/movable/screen/mob_charge
icon = 'icons/obj/machines/cell_charger.dmi'
icon_state = "ccharger"
screen_loc = ui_stamina
///used to find the overlay for charger icon
var/current_charge_level = 4
///dynamic, based on what cell our nulebot's using
var/image/battery_overlay
///maptext that displays charge in numbers
var/image/charge_overlay
///is there a mouse on us
var/hovering = FALSE
/atom/movable/screen/mob_charge/proc/update_battery_overlay(atom/target_battery)
var/obj/item/stock_parts/power_store/cell/my_cell = target_battery || (locate() in get_mob())
if(isnull(my_cell))
battery_overlay = null
else
battery_overlay = image(icon = my_cell.icon, icon_state = my_cell.icon_state, loc = src, layer = src.layer + 0.1)
update_appearance(UPDATE_ICON)
/atom/movable/screen/mob_charge/proc/calculate_charge()
var/obj/item/stock_parts/power_store/cell/my_battery = locate() in get_mob()
var/charge_value = isnull(my_battery) ? 0 : round(my_battery.charge/my_battery.maxcharge * 100 , 1)
current_charge_level = round(charge_value * 4 / 100)
charge_overlay.maptext = MAPTEXT("<div align='center' valign='middle' style='position:relative'>[charge_value]%</div>")
update_appearance(UPDATE_ICON)
/atom/movable/screen/mob_charge/New(loc, ...)
. = ..()
charge_overlay = image(loc = src, layer = src.layer+0.2, pixel_y = -5)
update_battery_overlay()
/atom/movable/screen/mob_charge/Destroy()
charge_overlay = null
battery_overlay = null
return ..()
/atom/movable/screen/mob_charge/update_overlays()
. = ..()
. += mutable_appearance(icon, "ccharger-o[current_charge_level]")
if(battery_overlay)
. |= battery_overlay
if(hovering)
. |= charge_overlay
/atom/movable/screen/mob_charge/MouseEntered(location,control,params)
if(usr != get_mob())
return
. = ..()
hovering = TRUE
calculate_charge()
/atom/movable/screen/mob_charge/MouseExited(location, control, params)
if(usr != get_mob())
return
. = ..()
hovering = FALSE
update_appearance(UPDATE_ICON)
/datum/hud/living/mulebot
/datum/hud/living/mulebot/initialize_screen_objects()
. = ..()
add_screen_object(/atom/movable/screen/mob_charge, HUD_MULEBOT_CHARGE, HUD_GROUP_INFO)
@@ -0,0 +1,72 @@
/mob/living/basic/bot/mulebot/MobBump(mob/bumped_mob) // called when the bot bumps into a mob
if(mind || !isliving(bumped_mob)) //if there's a sentience controlling the bot, they aren't allowed to harm folks.
return ..()
var/mob/living/bumped_living = bumped_mob
if(wires.is_cut(WIRE_AVOIDANCE)) // usually just bumps, but if the avoidance wire is cut, knocks them over.
if(iscyborg(bumped_living))
visible_message(span_danger("[src] bumps into [bumped_living]!"))
else if(bumped_living.Knockdown(8 SECONDS))
log_combat(src, bumped_living, "knocked down")
visible_message(span_danger("[src] knocks over [bumped_living]!"))
return ..()
/mob/living/basic/bot/mulebot/on_bot_movement(atom/movable/source, atom/oldloc, dir, forced)
cell?.use(cell_move_power_usage)
set_cell_hud()
if(has_gravity())
for(var/mob/living/carbon/human/future_pancake in loc)
if(future_pancake.body_position == LYING_DOWN)
run_over(future_pancake)
return ..()
///Checks if the bot is on or if it has charge
/mob/living/basic/bot/mulebot/proc/on_pre_move()
SIGNAL_HANDLER
if(!(bot_mode_flags & BOT_MODE_ON))
return COMPONENT_MOB_BOT_BLOCK_PRE_STEP
if((cell && (cell.charge < cell_move_power_usage)) || !has_power())
turn_off()
return COMPONENT_MOB_BOT_BLOCK_PRE_STEP
// when mulebot is in the same loc
/mob/living/basic/bot/mulebot/proc/run_over(mob/living/carbon/human/crushed)
if (!(bot_access_flags & BOT_COVER_EMAGGED) && !wires.is_cut(WIRE_AVOIDANCE))
if (!has_status_effect(/datum/status_effect/careful_driving))
crushed.visible_message(span_notice("[src] slows down to avoid crushing [crushed]."))
apply_status_effect(/datum/status_effect/careful_driving)
return // Player mules must be emagged before they can trample
log_combat(src, crushed, "run over", addition = "(DAMTYPE: [uppertext(BRUTE)])")
crushed.visible_message(
span_danger("[src] drives over [crushed]!"),
span_userdanger("[src] drives over you!"),
)
playsound(src, 'sound/effects/splat.ogg', 50, TRUE)
var/damage = rand(5, 15)
var/static/list/zone_damages = list(
BODY_ZONE_HEAD = 2,
BODY_ZONE_CHEST = 2,
BODY_ZONE_L_LEG = 0.5,
BODY_ZONE_R_LEG = 0.5,
BODY_ZONE_L_ARM = 0.5,
BODY_ZONE_R_ARM = 0.5,
)
for(var/body_zone in zone_damages)
crushed.apply_damage(zone_damages[body_zone] * damage, BRUTE, body_zone, run_armor_check(body_zone, MELEE))
add_mob_blood(crushed)
var/turf/below_us = get_turf(src)
below_us.add_mob_blood(crushed)
AddComponent(/datum/component/blood_walk, \
blood_type = /obj/effect/decal/cleanable/blood/tracks, \
target_dir_change = TRUE, \
transfer_blood_dna = TRUE, \
max_blood = 4)
@@ -0,0 +1,61 @@
/mob/living/basic/bot/mulebot/paranormal
name = "\improper GHOULbot"
desc = "A rather ghastly looking... Multiple Utility Load Effector bot? It only seems to accept paranormal forces, and for this reason is fucking useless."
icon_state = "paranormalmulebot0"
base_icon_state = "paranormalmulebot"
///avoid the utterly miniscule chance of infinite looping
replacement_chance = 0
/mob/living/basic/bot/mulebot/paranormal/update_overlays()
. = ..()
if(!isobserver(load))
return
var/mutable_appearance/ghost_overlay = mutable_appearance('icons/mob/simple/mob.dmi', "ghost", layer + 0.01) //use a generic ghost icon, otherwise you can metagame who's dead if they have a custom ghost set
ghost_overlay.pixel_y = 12
. += ghost_overlay
/mob/living/basic/bot/mulebot/paranormal/get_load_name() //Don't reveal the name of ghosts so we can't metagame who died and all that.
. = ..()
if(. && isobserver(load))
return "Unknown"
/mob/living/basic/bot/mulebot/paranormal/load(atom/movable/movable_atom)
if(load || movable_atom.anchored)
return
if(!isturf(movable_atom.loc)) //To prevent the loading from stuff from someone's inventory or screen icons.
return
if(isobserver(movable_atom))
visible_message(span_warning("A ghostly figure appears on [src]!"))
movable_atom.forceMove(src)
RegisterSignal(movable_atom, COMSIG_MOVABLE_MOVED, PROC_REF(ghost_moved))
else if(!wires.is_cut(WIRE_LOADCHECK))
buzz(MULEBOT_MOOD_SIGH)
return // if not hacked, only allow ghosts to be loaded
else if(isobj(movable_atom))
if(movable_atom.has_buckled_mobs() || (locate(/mob) in movable_atom)) //can't load non crates objects with mobs buckled to it or inside it.
buzz(MULEBOT_MOOD_SIGH)
return
if(istype(movable_atom, /obj/structure/closet/crate))
var/obj/structure/closet/crate/crate = movable_atom
crate.close() //make sure it's closed
movable_atom.forceMove(src)
else if(isliving(movable_atom) && !load_mob(movable_atom))
return
load = movable_atom
update_bot_mode(new_mode = BOT_IDLE)
update_appearance()
///Handles the ghosts moving out from the mule
/mob/living/basic/bot/mulebot/paranormal/proc/ghost_moved()
SIGNAL_HANDLER
visible_message(span_notice("The ghostly figure vanishes..."))
UnregisterSignal(load, COMSIG_MOVABLE_MOVED)
unload()
@@ -0,0 +1,46 @@
/mob/living/basic/bot/mulebot/screwdriver_act(mob/living/user, obj/item/tool)
. = ..()
update_appearance()
/mob/living/basic/bot/mulebot/crowbar_act(mob/living/user, obj/item/tool)
if(!(bot_access_flags & BOT_COVER_MAINTS_OPEN) || user.combat_mode)
return
if(!cell)
to_chat(user, span_warning("[src] doesn't have a power cell!"))
return ITEM_INTERACT_BLOCKING
cell.add_fingerprint(user)
user.visible_message(
span_notice("[user] crowbars [cell] out from [src]."),
span_notice("You pry [cell] out of [src]."),
)
if(Adjacent(user) && !issilicon(user))
user.put_in_hands(cell)
else
cell.forceMove(drop_location())
return ITEM_INTERACT_SUCCESS
/mob/living/basic/bot/mulebot/item_interaction(mob/living/user, obj/item/tool, list/modifiers)
if(istype(tool, /obj/item/stock_parts/power_store/cell) && (bot_access_flags & BOT_COVER_MAINTS_OPEN))
if(cell)
to_chat(user, span_warning("[src] already has a power cell!"))
return ITEM_INTERACT_BLOCKING
if(!user.transferItemToLoc(tool, src))
return ITEM_INTERACT_BLOCKING
user.visible_message(
span_notice("[user] inserts \a [cell] into [src]."),
span_notice("You insert [cell] into [src]."),
)
return ITEM_INTERACT_SUCCESS
if(is_wire_tool(tool) && (bot_access_flags & BOT_COVER_MAINTS_OPEN))
attack_hand(user)
return ITEM_INTERACT_SUCCESS
return ..()
/mob/living/basic/bot/mulebot/emag_act(mob/user, obj/item/card/emag/emag_card)
. = ..()
if(!(bot_access_flags & BOT_COVER_EMAGGED))
return
flick("[base_icon_state]-emagged", src)
playsound(src, SFX_SPARKS, 100, FALSE, SHORT_RANGE_SOUND_EXTRARANGE)
return TRUE
@@ -250,7 +250,7 @@
var/obj/item/stack/rods/new_rods = new()
new_rods.forceMove(src)
/mob/living/basic/bot/repairbot/turn_on()
/mob/living/basic/bot/repairbot/turn_on(mob/user)
. = ..()
if(!.)
return
@@ -175,12 +175,6 @@
// A note to future coders: do not replace this with an EMP because it will wreck malf AIs and everyone will hate you.
/datum/action/cooldown/spell/aoe/revenant/malfunction/cast_on_thing_in_aoe(turf/victim, mob/living/basic/revenant/caster)
for(var/mob/living/simple_animal/bot/bot in victim)
if(!(bot.bot_cover_flags & BOT_COVER_EMAGGED))
new /obj/effect/temp_visual/revenant(bot.loc)
bot.bot_cover_flags &= ~BOT_COVER_LOCKED
bot.bot_cover_flags |= BOT_COVER_MAINTS_OPEN
bot.emag_act(caster)
for(var/mob/living/basic/bot/bot in victim)
if(!(bot.bot_access_flags & BOT_COVER_EMAGGED))
new /obj/effect/temp_visual/revenant(bot.loc)