diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index 55b6c0b9fa0..03f99e071d8 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -574,6 +574,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define LYING_DOWN_TRAIT "lying-down" /// Trait associated to lacking electrical power. #define POWER_LACK_TRAIT "power-lack" +/// Trait associated to lacking motor movement +#define MOTOR_LACK_TRAIT "motor-lack" /// Trait associated with mafia #define MAFIA_TRAIT "mafia" /// Trait associated with highlander diff --git a/code/datums/wires/mulebot.dm b/code/datums/wires/mulebot.dm index 395c0d52b05..f2296641388 100644 --- a/code/datums/wires/mulebot.dm +++ b/code/datums/wires/mulebot.dm @@ -1,3 +1,7 @@ +#define FAST_MOTOR_SPEED 1 +#define AVERAGE_MOTOR_SPEED 2 +#define SLOW_MOTOR_SPEED 3 + /datum/wires/mulebot holder_type = /mob/living/simple_animal/bot/mulebot proper_name = "Mulebot" @@ -15,23 +19,43 @@ /datum/wires/mulebot/interactable(mob/user) if(!..()) return FALSE - var/mob/living/simple_animal/bot/mulebot/M = holder - if(M.open) + var/mob/living/simple_animal/bot/mulebot/mule = holder + if(mule.open) return TRUE +/datum/wires/mulebot/on_cut(wire, mend) + var/mob/living/simple_animal/bot/mulebot/mule = holder + switch(wire) + if(WIRE_MOTOR1, WIRE_MOTOR2) + if(is_cut(WIRE_MOTOR1) && is_cut(WIRE_MOTOR2)) + ADD_TRAIT(mule, TRAIT_IMMOBILIZED, MOTOR_LACK_TRAIT) + else + REMOVE_TRAIT(mule, TRAIT_IMMOBILIZED, MOTOR_LACK_TRAIT) + + if(is_cut(WIRE_MOTOR1)) + mule.set_varspeed(FAST_MOTOR_SPEED) + else if(is_cut(WIRE_MOTOR2)) + mule.set_varspeed(AVERAGE_MOTOR_SPEED) + else + mule.set_varspeed(SLOW_MOTOR_SPEED) + /datum/wires/mulebot/on_pulse(wire) - var/mob/living/simple_animal/bot/mulebot/M = holder - if(!M.has_power(TRUE)) + var/mob/living/simple_animal/bot/mulebot/mule = holder + if(!mule.has_power(TRUE)) return //logically mulebots can't flash and beep if they don't have power. switch(wire) if(WIRE_POWER1, WIRE_POWER2) - holder.visible_message(span_notice("[icon2html(M, viewers(holder))] The charge light flickers.")) + holder.visible_message(span_notice("[icon2html(mule, viewers(holder))] The charge light flickers.")) if(WIRE_AVOIDANCE) - holder.visible_message(span_notice("[icon2html(M, viewers(holder))] The external warning lights flash briefly.")) - flick("[M.base_icon]1", M) + holder.visible_message(span_notice("[icon2html(mule, viewers(holder))] The external warning lights flash briefly.")) + flick("[mule.base_icon]1", mule) if(WIRE_LOADCHECK) - holder.visible_message(span_notice("[icon2html(M, viewers(holder))] The load platform clunks.")) + holder.visible_message(span_notice("[icon2html(mule, viewers(holder))] The load platform clunks.")) if(WIRE_MOTOR1, WIRE_MOTOR2) - holder.visible_message(span_notice("[icon2html(M, viewers(holder))] The drive motor whines briefly.")) + holder.visible_message(span_notice("[icon2html(mule, viewers(holder))] The drive motor whines briefly.")) else - holder.visible_message(span_notice("[icon2html(M, viewers(holder))] You hear a radio crackle.")) + holder.visible_message(span_notice("[icon2html(mule, viewers(holder))] You hear a radio crackle.")) + +#undef FAST_MOTOR_SPEED +#undef AVERAGE_MOTOR_SPEED +#undef SLOW_MOTOR_SPEED diff --git a/code/modules/mob/living/simple_animal/bot/mulebot.dm b/code/modules/mob/living/simple_animal/bot/mulebot.dm index a592cfa716e..4f9486976e4 100644 --- a/code/modules/mob/living/simple_animal/bot/mulebot.dm +++ b/code/modules/mob/living/simple_animal/bot/mulebot.dm @@ -18,6 +18,7 @@ animate_movement = FORWARD_STEPS health = 50 maxHealth = 50 + speed = 3 damage_coeff = list(BRUTE = 0.5, BURN = 0.7, TOX = 0, CLONE = 0, STAMINA = 0, OXY = 0) combat_mode = TRUE //No swapping buckle_lying = 0 @@ -128,8 +129,8 @@ return ..() /// returns true if the bot is fully powered. -/mob/living/simple_animal/bot/mulebot/proc/has_power(bypass_open_check) - return (!open || bypass_open_check) && cell && cell.charge > 0 && (!wires.is_cut(WIRE_POWER1) && !wires.is_cut(WIRE_POWER2)) +/mob/living/simple_animal/bot/mulebot/proc/has_power() + return cell && cell.charge > 0 && (!wires.is_cut(WIRE_POWER1) && !wires.is_cut(WIRE_POWER2)) /mob/living/simple_animal/bot/mulebot/proc/set_id(new_id) @@ -146,10 +147,7 @@ /mob/living/simple_animal/bot/mulebot/attackby(obj/item/I, mob/living/user, params) if(I.tool_behaviour == TOOL_SCREWDRIVER) . = ..() - if(open) - turn_off() - else - update_appearance() //this is also handled by turn_off(), so no need to call this twice. + update_appearance() else if(istype(I, /obj/item/stock_parts/cell) && open) if(cell) to_chat(user, span_warning("[src] already has a power cell!")) @@ -558,6 +556,8 @@ return if(mode == BOT_IDLE) return + if(HAS_TRAIT(src, TRAIT_IMMOBILIZED)) + return var/speed = (wires.is_cut(WIRE_MOTOR1) ? 0 : 1) + (wires.is_cut(WIRE_MOTOR2) ? 0 : 2) if(!speed)//Devide by zero man bad @@ -836,7 +836,7 @@ if(!on) return COMPONENT_MOB_BOT_BLOCK_PRE_STEP - if((cell && (cell.charge < cell_move_power_usage)) || !has_power((client || paicard))) + if((cell && (cell.charge < cell_move_power_usage)) || !has_power()) turn_off() return COMPONENT_MOB_BOT_BLOCK_PRE_STEP @@ -926,4 +926,3 @@ /obj/machinery/bot_core/mulebot req_access = list(ACCESS_CARGO) -