Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Traps #2478

Merged
merged 5 commits into from
Dec 9, 2023
Merged

Traps #2478

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@

/mob/living/attacked_by(obj/item/I, mob/living/user)
send_item_attack_message(I, user)
if(I.force)
apply_damage(I.force, I.damtype)
var/no_defended = damage_armor(I.force, MELEE, I.damtype)
if(no_defended)
apply_damage(no_defended, I.damtype)
if(I.damtype == BRUTE)
if(prob(33))
I.add_mob_blood(src)
Expand Down
31 changes: 24 additions & 7 deletions code/modules/mob/living/carbon/human/human_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@
return
var/brute_loss = 0
var/burn_loss = 0
var/bomb_armor = getarmor(null, BOMB)
var/bomb_armor = getallsubarmor(CUTTING)

//200 max knockdown for EXPLODE_HEAVY
//160 max knockdown for EXPLODE_LIGHT
Expand All @@ -459,7 +459,7 @@
brute_loss = 500
var/atom/throw_target = get_edge_target_turf(src, get_dir(src, get_step_away(src, src)))
throw_at(throw_target, 200, 4)
damage_clothes(400 - bomb_armor, BRUTE, BOMB)
damage_clothes(max(400 - bomb_armor, round(bomb_armor * 0.05, 1)), BRUTE, CUTTING)

if (EXPLODE_HEAVY)
throw_alert_text(/atom/movable/screen/alert/text/sad, "What the f-", override = FALSE) // MOJAVE SUN EDIT - FO text alert
Expand All @@ -468,21 +468,21 @@
if(bomb_armor)
brute_loss = 30*(2 - round(bomb_armor*0.01, 0.05))
burn_loss = brute_loss //damage gets reduced from 120 to up to 60 combined brute+burn
damage_clothes(200 - bomb_armor, BRUTE, BOMB)
damage_clothes(max(200 - bomb_armor, round(bomb_armor * 0.05, 1)), BRUTE, CUTTING)
if (ears && !HAS_TRAIT_FROM(src, TRAIT_DEAF, CLOTHING_TRAIT))
ears.adjustEarDamage(30, 120)
Unconscious(20) //short amount of time for follow up attacks against elusive enemies like wizards
Knockdown(200 - (bomb_armor * 1.6)) //between ~4 and ~20 seconds of knockdown depending on bomb armor
Knockdown(max(200 - (bomb_armor * 1.6), round(bomb_armor * 0.05, 1))) //between ~4 and ~20 seconds of knockdown depending on bomb armor

if(EXPLODE_LIGHT)
throw_alert_text(/atom/movable/screen/alert/text/nohappy, "That's not good!", override = FALSE) // MOJAVE SUN EDIT - FO text alert
brute_loss = 30
if(bomb_armor)
brute_loss = 15*(2 - round(bomb_armor*0.01, 0.05))
damage_clothes(max(50 - bomb_armor, 0), BRUTE, BOMB)
damage_clothes(max(50 - bomb_armor, 0), BRUTE, CUTTING)
if (ears && !HAS_TRAIT_FROM(src, TRAIT_DEAF, CLOTHING_TRAIT))
ears.adjustEarDamage(15,60)
Knockdown(160 - (bomb_armor * 1.6)) //100 bomb armor will prevent knockdown altogether
Knockdown(max(160 - (bomb_armor * 1.6), round(bomb_armor * 0.05, 1))) //100 bomb armor will prevent knockdown altogether

take_overall_damage(brute_loss,burn_loss)

Expand All @@ -505,7 +505,7 @@
probability = 50
for(var/X in bodyparts)
var/obj/item/bodypart/BP = X
if(prob(probability) && !prob(getarmor(BP, BOMB)) && BP.body_zone != BODY_ZONE_HEAD && BP.body_zone != BODY_ZONE_CHEST)
if(prob(probability) && !prob(getsubarmor(BP, CUTTING)) && BP.body_zone != BODY_ZONE_HEAD && BP.body_zone != BODY_ZONE_CHEST && !istype(BP.owner:wear_suit, /obj/item/clothing/suit/space/hardsuit/ms13/power_armor))
BP.brute_dam = BP.max_damage
BP.dismember()
max_limb_loss--
Expand Down Expand Up @@ -1002,5 +1002,22 @@
if(leg_clothes)
torn_items |= leg_clothes

var/power_armor_safe = FALSE
for(var/obj/item/I in torn_items)
if(istype(I, /obj/item/clothing/suit/space/hardsuit/ms13/power_armor))
var/obj/item/clothing/suit/space/hardsuit/ms13/power_armor/pa = I
I.take_damage(damage_amount, damage_type, damage_flag, 0)
for(var/part_zone as anything in pa.module_armor)
if(part_zone == BODY_ZONE_HEAD)
continue
var/obj/item/ms13/power_armor/PA_part = pa.module_armor[part_zone]
if(PA_part != null)
PA_part.take_damage(damage_amount, damage_type, damage_flag, 0)
power_armor_safe = TRUE

//POWER_ARMOR SAFE ITEMS ON YOUR SLOTS
if(power_armor_safe)
return

for(var/obj/item/I in torn_items)
I.take_damage(damage_amount, damage_type, damage_flag, 0)
78 changes: 78 additions & 0 deletions mojave/code/game/objects/traps/mine.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

/obj/effect/mine/ms13/explosive
name = "Frag"
icon_state = "frag_primed"
var/inactive_state = "frag_armed"
/// The devastation range of the resulting explosion.
var/range_devastation = 0
/// The heavy impact range of the resulting explosion.
var/range_heavy = 1
/// The light impact range of the resulting explosion.
var/range_light = 2
/// The flame range of the resulting explosion.
var/range_flame = 0
/// The flash range of the resulting explosion.
var/range_flash = 3

arm_delay = 5 SECONDS

/obj/effect/mine/ms13/explosive/Initialize(mapload)
. = ..()
if(arm_delay)
armed = FALSE
icon_state = inactive_state
addtimer(CALLBACK(src, .proc/now_armed), arm_delay)
var/static/list/loc_connections = list(
COMSIG_ATOM_ENTERED = .proc/on_entered,
)
AddElement(/datum/element/connect_loc, loc_connections)

/obj/effect/mine/ms13/explosive/examine(mob/user)
. = ..()
if(!armed)
. += "\t<span class='information'>It appears to be inactive...</span>"

/// The effect of the mine
/obj/effect/mine/ms13/explosive/mineEffect(mob/victim)
explosion(src, range_devastation, range_heavy, range_light, range_flame, range_flash)

/// If the landmine was previously inactive, this beeps and displays a message marking it active
/obj/effect/mine/ms13/explosive/now_armed()
armed = TRUE
icon_state = initial(icon_state)
playsound(src, 'mojave/sound/ms13machines/frag_mine_arm.ogg', 40, FALSE, -2)
visible_message(span_danger("\The [src] beeps softly, indicating it is now active."), vision_distance = COMBAT_MESSAGE_RANGE)

/obj/effect/mine/ms13/explosive/on_entered(datum/source, atom/movable/AM)
. = ..()

/obj/effect/mine/ms13/explosive/take_damage(damage_amount, damage_type, damage_flag, sound_effect, attack_dir)
. = ..()
triggermine()

/// When something sets off a mine
/obj/effect/mine/ms13/explosive/triggermine(atom/movable/triggerer)
if(iseffect(triggerer))
return
if(triggered) //too busy detonating to detonate again
return
if(triggerer)
visible_message(span_danger("[triggerer] sets off [icon2html(src, viewers(src))] [src]!"))
else
visible_message(span_danger("[icon2html(src, viewers(src))] [src] detonates!"))

var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
s.set_up(3, 1, src)
s.start()
if(ismob(triggerer))
mineEffect(triggerer)
triggered = TRUE
SEND_SIGNAL(src, COMSIG_MINE_TRIGGERED, triggerer)
qdel(src)

/obj/effect/spawner/random/ms13/explosive_mines
name = "Explosive mines"
spawn_loot_chance = 50
loot = list(
/obj/effect/mine/ms13/explosive
)
2 changes: 2 additions & 0 deletions mojave/code/game/objects/traps/ms13_traps.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/obj/effect/mine/ms13
icon = 'mojave/icons/objects/ms_traps.dmi'
21 changes: 21 additions & 0 deletions mojave/code/modules/mob/living/carbon/human/human_armor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@
return clothing.subarmor.getRating(SUBARMOR_FLAGS)
return physiology.subarmor.getRating(SUBARMOR_FLAGS)

/mob/living/carbon/human/proc/getallsubarmor(d_type)
if(!d_type)
return 0

var/static/list/converstion_table = list(MELEE, BULLET)
if(d_type in converstion_table)
d_type = CRUSHING
stack_trace("Called checksubarmor with invalid d_type ([d_type])!")

var/protection = 0
for(var/X in bodyparts)
var/obj/item/bodypart/BP = X
protection += checksubarmor(BP, d_type)

return protection

/mob/living/carbon/human/proc/checksubarmor(obj/item/bodypart/def_zone, d_type)
if(!d_type)
return 0
Expand All @@ -69,6 +85,11 @@
var/protection = 0
var/list/clothings = clothingonpart(affecting)
for(var/obj/item/clothing as anything in clothings)
if(istype(clothing, /obj/item/clothing/suit/space/hardsuit/ms13/power_armor))
var/obj/item/clothing/suit/space/hardsuit/ms13/power_armor/pa = clothing
var/obj/item/ms13/power_armor/PA_part = pa.module_armor[def_zone.body_zone]
if(PA_part != null)
protection += PA_part.subarmor.getRating(d_type)
protection += clothing.subarmor.getRating(d_type)
protection += physiology.subarmor.getRating(d_type)
return protection
Expand Down
Binary file added mojave/icons/objects/ms_traps.dmi
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

//STOLEN
/datum/particle_weather/radiation_storm/weather_act(mob/living/L)
var/resist = L.getarmor(null)
var/resist = L.getsubarmor()
if(prob(40))
if(ishuman(L))
var/mob/living/carbon/human/H = L
Expand Down
Binary file added mojave/sound/ms13machines/frag_mine_arm.ogg
Binary file not shown.
2 changes: 2 additions & 0 deletions tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -4415,6 +4415,8 @@
#include "mojave\code\game\objects\item_wield.dm"
#include "mojave\code\game\objects\effects\displacement_maps.dm"
#include "mojave\code\game\objects\effects\displacement\fat.dm"
#include "mojave\code\game\objects\traps\mine.dm"
#include "mojave\code\game\objects\traps\ms13_traps.dm"
#include "mojave\code\modules\ai\effect_node.dm"
#include "mojave\code\modules\asset_cache\assets\mouse.dm"
#include "mojave\code\modules\atmosphere\atmosphere.dm"
Expand Down
Loading