diff --git a/code/__DEFINES/mecha.dm b/code/__DEFINES/mecha.dm new file mode 100644 index 00000000000..0b60cbc12aa --- /dev/null +++ b/code/__DEFINES/mecha.dm @@ -0,0 +1,18 @@ +#define MECHA_INT_FIRE (1<<0) +#define MECHA_INT_TEMP_CONTROL (1<<1) +#define MECHA_INT_SHORT_CIRCUIT (1<<2) +#define MECHA_INT_TANK_BREACH (1<<3) +#define MECHA_INT_CONTROL_LOST (1<<4) + +#define MECHA_MELEE (1 << 0) +#define MECHA_RANGED (1 << 1) + +#define MECHA_FRONT_ARMOUR 1 +#define MECHA_SIDE_ARMOUR 2 +#define MECHA_BACK_ARMOUR 3 + +#define MECHA_LOCKED 0 +#define MECHA_SECURE_BOLTS 1 +#define MECHA_LOOSE_BOLTS 2 +#define MECHA_OPEN_HATCH 3 +#define MECHA_UNSECURE_CELL 4 diff --git a/code/game/mecha/equipment/mecha_equipment.dm b/code/game/mecha/equipment/mecha_equipment.dm index c02b91cadb0..1ecaf62a0a7 100644 --- a/code/game/mecha/equipment/mecha_equipment.dm +++ b/code/game/mecha/equipment/mecha_equipment.dm @@ -11,7 +11,8 @@ var/equip_ready = 1 //whether the equipment is ready for use. (or deactivated/activated for static stuff) var/energy_drain = 0 var/obj/mecha/chassis = null - var/range = MELEE //bitFflags + ///Bitflag. Determines the range of the equipment. + var/range = MECHA_MELEE var/salvageable = 1 var/selectable = 1 // Set to 0 for passive equipment such as mining scanner or armor plates var/harmful = FALSE //Controls if equipment can be used to attack by a pacifist. @@ -67,10 +68,10 @@ return txt /obj/item/mecha_parts/mecha_equipment/proc/is_ranged()//add a distance restricted equipment. Why not? - return range&RANGED + return range&MECHA_RANGED /obj/item/mecha_parts/mecha_equipment/proc/is_melee() - return range&MELEE + return range&MECHA_MELEE /obj/item/mecha_parts/mecha_equipment/proc/action_checks(atom/target) diff --git a/code/game/mecha/equipment/tools/medical_tools.dm b/code/game/mecha/equipment/tools/medical_tools.dm index ef049a23560..5f56d7d665c 100644 --- a/code/game/mecha/equipment/tools/medical_tools.dm +++ b/code/game/mecha/equipment/tools/medical_tools.dm @@ -34,7 +34,7 @@ icon = 'icons/obj/machines/sleeper.dmi' icon_state = "sleeper" energy_drain = 20 - range = MELEE + range = MECHA_MELEE equip_cooldown = 20 var/mob/living/carbon/patient = null var/inject_amount = 10 @@ -256,7 +256,7 @@ var/synth_speed = 5 //[num] reagent units per cycle energy_drain = 10 var/mode = 0 //0 - fire syringe, 1 - analyze reagents. - range = MELEE|RANGED + range = MECHA_MELEE|MECHA_RANGED equip_cooldown = 10 /obj/item/mecha_parts/mecha_equipment/medical/syringe_gun/Initialize() @@ -524,7 +524,7 @@ desc = "Equipment for medical exosuits. Generates a focused beam of medical nanites." icon_state = "mecha_medigun" energy_drain = 10 - range = MELEE|RANGED + range = MECHA_MELEE|MECHA_RANGED equip_cooldown = 0 var/obj/item/gun/medbeam/mech/medigun materials = list(/datum/material/iron = 15000, /datum/material/glass = 8000, /datum/material/plasma = 3000, /datum/material/gold = 8000, /datum/material/diamond = 2000) diff --git a/code/game/mecha/equipment/tools/other_tools.dm b/code/game/mecha/equipment/tools/other_tools.dm index 75f71f3dbff..fa64dc0bcbf 100644 --- a/code/game/mecha/equipment/tools/other_tools.dm +++ b/code/game/mecha/equipment/tools/other_tools.dm @@ -10,7 +10,7 @@ icon_state = "mecha_teleport" equip_cooldown = 150 energy_drain = 1000 - range = RANGED + range = MECHA_RANGED /obj/item/mecha_parts/mecha_equipment/teleporter/action(atom/target) if(!action_checks(target) || is_centcom_level(loc.z)) @@ -30,7 +30,7 @@ icon_state = "mecha_wholegen" equip_cooldown = 50 energy_drain = 300 - range = RANGED + range = MECHA_RANGED /obj/item/mecha_parts/mecha_equipment/wormhole_generator/action(atom/target) @@ -73,7 +73,7 @@ icon_state = "mecha_teleport" equip_cooldown = 10 energy_drain = 100 - range = MELEE|RANGED + range = MECHA_MELEE|MECHA_RANGED var/atom/movable/locked var/mode = 1 //1 - gravsling 2 - gravpush @@ -361,7 +361,7 @@ name = "exosuit plasma converter" desc = "An exosuit module that generates power using solid plasma as fuel. Pollutes the environment." icon_state = "tesla" - range = MELEE + range = MECHA_MELEE var/coeff = 100 var/obj/item/stack/sheet/fuel var/max_fuel = 150000 diff --git a/code/game/mecha/equipment/tools/work_tools.dm b/code/game/mecha/equipment/tools/work_tools.dm index 686dac42eaf..01657c26b24 100644 --- a/code/game/mecha/equipment/tools/work_tools.dm +++ b/code/game/mecha/equipment/tools/work_tools.dm @@ -186,7 +186,7 @@ icon_state = "mecha_exting" equip_cooldown = 5 energy_drain = 0 - range = MELEE|RANGED + range = MECHA_MELEE|MECHA_RANGED /obj/item/mecha_parts/mecha_equipment/extinguisher/Initialize() . = ..() @@ -253,7 +253,7 @@ icon_state = "mecha_rcd" equip_cooldown = 10 energy_drain = 250 - range = MELEE|RANGED + range = MECHA_MELEE|MECHA_RANGED item_flags = NO_MAT_REDEMPTION var/mode = 0 //0 - deconstruct, 1 - wall or floor, 2 - airlock. diff --git a/code/game/mecha/equipment/weapons/weapons.dm b/code/game/mecha/equipment/weapons/weapons.dm index 748770c26d9..129de8f6fbe 100644 --- a/code/game/mecha/equipment/weapons/weapons.dm +++ b/code/game/mecha/equipment/weapons/weapons.dm @@ -1,6 +1,6 @@ /obj/item/mecha_parts/mecha_equipment/weapon name = "mecha weapon" - range = RANGED + range = MECHA_RANGED destroy_sound = 'sound/mecha/weapdestr.ogg' var/projectile var/fire_sound @@ -167,7 +167,7 @@ icon_state = "mecha_honker" energy_drain = 200 equip_cooldown = 150 - range = MELEE|RANGED + range = MECHA_MELEE|MECHA_RANGED kickback = FALSE /obj/item/mecha_parts/mecha_equipment/weapon/honker/can_attach(obj/mecha/combat/honker/M) @@ -454,7 +454,7 @@ icon_state = "mecha_punching_glove" energy_drain = 250 equip_cooldown = 20 - range = MELEE|RANGED + range = MECHA_MELEE|MECHA_RANGED missile_range = 5 projectile = /obj/item/punching_glove fire_sound = 'sound/items/bikehorn.ogg' diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index 9062d66982c..776ce11fca3 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -1,17 +1,3 @@ -#define MECHA_INT_FIRE (1<<0) -#define MECHA_INT_TEMP_CONTROL (1<<1) -#define MECHA_INT_SHORT_CIRCUIT (1<<2) -#define MECHA_INT_TANK_BREACH (1<<3) -#define MECHA_INT_CONTROL_LOST (1<<4) - -#define MELEE 1 -#define RANGED 2 - -#define FRONT_ARMOUR 1 -#define SIDE_ARMOUR 2 -#define BACK_ARMOUR 3 - - /obj/mecha name = "mecha" desc = "Exosuit" @@ -36,10 +22,10 @@ max_integrity = 300 //max_integrity is base health var/deflect_chance = 10 //chance to deflect the incoming projectiles, hits, or lesser the effect of ex_act. armor = list("melee" = 20, "bullet" = 10, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 100, "acid" = 100) - var/list/facing_modifiers = list(FRONT_ARMOUR = 1.5, SIDE_ARMOUR = 1, BACK_ARMOUR = 0.5) + var/list/facing_modifiers = list(MECHA_FRONT_ARMOUR = 1.5, MECHA_SIDE_ARMOUR = 1, MECHA_BACK_ARMOUR = 0.5) var/equipment_disabled = 0 //disabled due to EMP var/obj/item/stock_parts/cell/cell - var/state = 0 + var/construction_state = MECHA_LOCKED var/last_message = 0 var/add_req_access = 1 var/maint_access = 0 @@ -475,7 +461,7 @@ return if(user.incapacitated()) return - if(state) + if(construction_state) occupant_message("Maintenance protocols in effect.") return if(!get_charge()) @@ -558,7 +544,7 @@ occupant_message("Unable to move while connected to the air system port!") last_message = world.time return 0 - if(state) + if(construction_state) occupant_message("Maintenance protocols in effect.") return return domove(direction) @@ -722,7 +708,7 @@ //Transfer from core or card to mech. Proc is called by mech. switch(interaction) if(AI_TRANS_TO_CARD) //Upload AI from mech to AI card. - if(!state) //Mech must be in maint mode to allow carding. + if(!construction_state) //Mech must be in maint mode to allow carding. to_chat(user, "[name] must have maintenance protocols active in order to allow a transfer.") return AI = occupant diff --git a/code/game/mecha/mecha_defense.dm b/code/game/mecha/mecha_defense.dm index 92a27489358..3db0b3446d6 100644 --- a/code/game/mecha/mecha_defense.dm +++ b/code/game/mecha/mecha_defense.dm @@ -1,11 +1,11 @@ /obj/mecha/proc/get_armour_facing(relative_dir) switch(relative_dir) if(0) // BACKSTAB! - return facing_modifiers[BACK_ARMOUR] + return facing_modifiers[MECHA_BACK_ARMOUR] if(45, 90, 270, 315) - return facing_modifiers[SIDE_ARMOUR] + return facing_modifiers[MECHA_SIDE_ARMOUR] if(225, 180, 135) - return facing_modifiers[FRONT_ARMOUR] + return facing_modifiers[MECHA_FRONT_ARMOUR] return 1 //always return non-0 /obj/mecha/take_damage(damage_amount, damage_type = BRUTE, damage_flag = 0, sound_effect = 1, attack_dir) @@ -187,52 +187,13 @@ id_card = pda.id output_maintenance_dialog(id_card, user) return - else - to_chat(user, "Invalid ID: Access denied.") - else - to_chat(user, "Maintenance protocols disabled by operator.") - else if(W.tool_behaviour == TOOL_WRENCH) - if(state==1) - state = 2 - to_chat(user, "You undo the securing bolts.") - else if(state==2) - state = 1 - to_chat(user, "You tighten the securing bolts.") - return - else if(W.tool_behaviour == TOOL_CROWBAR) - if(state==2) - state = 3 - to_chat(user, "You open the hatch to the power unit.") - else if(state==3) - state=2 - to_chat(user, "You close the hatch to the power unit.") - return - else if(istype(W, /obj/item/stack/cable_coil)) - if(state == 3 && (internal_damage & MECHA_INT_SHORT_CIRCUIT)) - var/obj/item/stack/cable_coil/CC = W - if(CC.use(2)) - clearInternalDamage(MECHA_INT_SHORT_CIRCUIT) - to_chat(user, "You replace the fused wires.") - else - to_chat(user, "You need two lengths of cable to fix this mech!") - return - else if(W.tool_behaviour == TOOL_SCREWDRIVER && user.a_intent != INTENT_HARM) - if(internal_damage & MECHA_INT_TEMP_CONTROL) - clearInternalDamage(MECHA_INT_TEMP_CONTROL) - to_chat(user, "You repair the damaged temperature controller.") - else if(state==3 && cell) - cell.forceMove(loc) - cell = null - state = 4 - to_chat(user, "You unscrew and pry out the powercell.") - log_message("Powercell removed", LOG_MECHA) - else if(state==4 && cell) - state=3 - to_chat(user, "You screw the cell in place.") + to_chat(user, "Invalid ID: Access denied.") + return + to_chat(user, "Maintenance protocols disabled by operator.") return - else if(istype(W, /obj/item/stock_parts/cell)) - if(state==4) + if(istype(W, /obj/item/stock_parts/cell)) + if(construction_state == MECHA_UNSECURE_CELL) if(!cell) if(!user.transferItemToLoc(W, src)) return @@ -244,33 +205,86 @@ to_chat(user, "There's already a powercell installed.") return - else if(W.tool_behaviour == TOOL_WELDER && user.a_intent != INTENT_HARM) - user.changeNext_move(CLICK_CD_MELEE) - if(obj_integrity < max_integrity) - if(W.use_tool(src, user, 0, volume=50, amount=1)) - if (internal_damage & MECHA_INT_TANK_BREACH) - clearInternalDamage(MECHA_INT_TANK_BREACH) - to_chat(user, "You repair the damaged gas tank.") - else - user.visible_message("[user] repairs some damage to [name].", "You repair some damage to [src].") - obj_integrity += min(10, max_integrity-obj_integrity) - if(obj_integrity == max_integrity) - to_chat(user, "It looks to be fully repaired now.") - return 1 - else - to_chat(user, "The [name] is at full integrity!") - return 1 + if(istype(W, /obj/item/stack/cable_coil)) + if(construction_state == MECHA_OPEN_HATCH && (internal_damage & MECHA_INT_SHORT_CIRCUIT)) + var/obj/item/stack/cable_coil/CC = W + if(CC.use(2)) + clearInternalDamage(MECHA_INT_SHORT_CIRCUIT) + to_chat(user, "You replace the fused wires.") + else + to_chat(user, "You need two lengths of cable to fix this mech!") + return - else if(istype(W, /obj/item/mecha_parts)) + if(istype(W, /obj/item/mecha_parts)) var/obj/item/mecha_parts/P = W P.try_attach_part(user, src) return - else - return ..() + log_message("Attacked by [W]. Attacker - [user]", LOG_MECHA) + return ..() -/obj/mecha/attacked_by(obj/item/I, mob/living/user) - log_message("Attacked by [I]. Attacker - [user]", LOG_MECHA) +/obj/mecha/wrench_act(mob/living/user, obj/item/I) ..() + . = TRUE + if(construction_state == MECHA_SECURE_BOLTS) + construction_state = MECHA_LOOSE_BOLTS + to_chat(user, "You undo the securing bolts.") + return + if(construction_state == MECHA_LOOSE_BOLTS) + construction_state = MECHA_SECURE_BOLTS + to_chat(user, "You tighten the securing bolts.") + +/obj/mecha/crowbar_act(mob/living/user, obj/item/I) + ..() + . = TRUE + if(construction_state == MECHA_LOOSE_BOLTS) + construction_state = MECHA_OPEN_HATCH + to_chat(user, "You open the hatch to the power unit.") + return + if(construction_state == MECHA_OPEN_HATCH) + construction_state = MECHA_LOOSE_BOLTS + to_chat(user, "You close the hatch to the power unit.") + +/obj/mecha/screwdriver_act(mob/living/user, obj/item/I) + ..() + . = TRUE + if(internal_damage & MECHA_INT_TEMP_CONTROL) + clearInternalDamage(MECHA_INT_TEMP_CONTROL) + to_chat(user, "You repair the damaged temperature controller.") + return + if(!cell) + to_chat(user, "There is no cell in [src].") + return + if(construction_state == MECHA_OPEN_HATCH) + cell.forceMove(loc) + cell = null + construction_state = MECHA_UNSECURE_CELL + to_chat(user, "You unscrew and pry out the powercell.") + log_message("Powercell removed", LOG_MECHA) + return + if(construction_state == MECHA_UNSECURE_CELL) + construction_state = MECHA_OPEN_HATCH + to_chat(user, "You screw the cell in place.") + +/obj/mecha/welder_act(mob/living/user, obj/item/W) + . = ..() + if(user.a_intent == INTENT_HARM) + return + . = TRUE + if(internal_damage & MECHA_INT_TANK_BREACH) + if(!W.use_tool(src, user, 0, volume=50, amount=1)) + return + clearInternalDamage(MECHA_INT_TANK_BREACH) + to_chat(user, "You repair the damaged gas tank.") + return + if(obj_integrity < max_integrity) + if(!W.use_tool(src, user, 0, volume=50, amount=1)) + return + user.visible_message("[user] repairs some damage to [name].", "You repair some damage to [src].") + obj_integrity += min(10, max_integrity-obj_integrity) + if(obj_integrity == max_integrity) + to_chat(user, "It looks to be fully repaired now.") + return + to_chat(user, "The [name] is at full integrity!") /obj/mecha/proc/mech_toxin_damage(mob/living/target) playsound(src, 'sound/effects/spray2.ogg', 50, 1) diff --git a/code/game/mecha/mecha_topic.dm b/code/game/mecha/mecha_topic.dm index cb373d99a1a..cc9d3878e56 100644 --- a/code/game/mecha/mecha_topic.dm +++ b/code/game/mecha/mecha_topic.dm @@ -201,8 +201,8 @@
[add_req_access?"Edit operation keycodes":null] - [maint_access?"[(state>0) ? "Terminate" : "Initiate"] maintenance protocol":null] - [(state>0) ?"Set Cabin Air Pressure":null] + [maint_access?"[(construction_state > MECHA_LOCKED) ? "Terminate" : "Initiate"] maintenance protocol":null] + [(construction_state > MECHA_LOCKED) ?"Set Cabin Air Pressure":null]