From 959658a970775d93f56a5ceedf2256509e30cfcf Mon Sep 17 00:00:00 2001 From: MistakeNot4892 Date: Wed, 1 Mar 2023 17:40:11 +1100 Subject: [PATCH] Implementing tranquilizer rifle and pistols. --- code/modules/mob/living/simple_mob/defense.dm | 5 +-- code/modules/mob/living/simple_mob/life.dm | 45 ++++++++++--------- .../mob/living/simple_mob/simple_mob.dm | 19 ++++++++ code/modules/projectiles/guns/energy/phase.dm | 27 ++++++++++- code/modules/projectiles/projectile.dm | 6 +++ code/modules/projectiles/projectile/energy.dm | 31 ++++++++++++- maps/cynosure/structures/closets/misc.dm | 6 ++- 7 files changed, 110 insertions(+), 29 deletions(-) diff --git a/code/modules/mob/living/simple_mob/defense.dm b/code/modules/mob/living/simple_mob/defense.dm index 371ddc6192..120075cf33 100644 --- a/code/modules/mob/living/simple_mob/defense.dm +++ b/code/modules/mob/living/simple_mob/defense.dm @@ -1,10 +1,7 @@ // Hit by a projectile. /mob/living/simple_mob/bullet_act(var/obj/item/projectile/P) //Projectiles with bonus SA damage - if(!P.nodamage) - // if(!P.SA_vulnerability || P.SA_vulnerability == intelligence_level) - if(P.SA_vulnerability & mob_class) - P.damage += P.SA_bonus_damage + P.damage += P.apply_SA_vulnerability(src) . = ..() diff --git a/code/modules/mob/living/simple_mob/life.dm b/code/modules/mob/living/simple_mob/life.dm index 43ec32d64b..98c89ac670 100644 --- a/code/modules/mob/living/simple_mob/life.dm +++ b/code/modules/mob/living/simple_mob/life.dm @@ -22,6 +22,7 @@ //Should we be dead? /mob/living/simple_mob/updatehealth() + var/lasthealth = health health = getMaxHealth() - getFireLoss() - getBruteLoss() - getToxLoss() - getOxyLoss() - getCloneLoss() //Alive, becoming dead @@ -33,26 +34,30 @@ health = getMaxHealth() //Update our hud if we have one - if(healths) - if(stat != DEAD) - var/heal_per = (health / getMaxHealth()) * 100 - switch(heal_per) - if(100 to INFINITY) - healths.icon_state = "health0" - if(80 to 100) - healths.icon_state = "health1" - if(60 to 80) - healths.icon_state = "health2" - if(40 to 60) - healths.icon_state = "health3" - if(20 to 40) - healths.icon_state = "health4" - if(0 to 20) - healths.icon_state = "health5" - else - healths.icon_state = "health6" - else - healths.icon_state = "health7" + if(lasthealth != health) + if(lasthealth > health && sleeping) // Damage wakes us up. + tranq_countdown = 0 + SetSleeping(0) + if(healths) + if(stat != DEAD) + var/heal_per = (health / getMaxHealth()) * 100 + switch(heal_per) + if(100 to INFINITY) + healths.icon_state = "health0" + if(80 to 100) + healths.icon_state = "health1" + if(60 to 80) + healths.icon_state = "health2" + if(40 to 60) + healths.icon_state = "health3" + if(20 to 40) + healths.icon_state = "health4" + if(0 to 20) + healths.icon_state = "health5" + else + healths.icon_state = "health6" + else + healths.icon_state = "health7" //Updates the nutrition while we're here var/food_per = (nutrition / max_nutrition) * 100 diff --git a/code/modules/mob/living/simple_mob/simple_mob.dm b/code/modules/mob/living/simple_mob/simple_mob.dm index 61a95a99bb..e858ab7151 100644 --- a/code/modules/mob/living/simple_mob/simple_mob.dm +++ b/code/modules/mob/living/simple_mob/simple_mob.dm @@ -163,6 +163,11 @@ // Used for if the mob can drop limbs. Overrides the icon cache key, so it doesn't keep remaking the icon needlessly. var/limb_icon_key + /// If above zero, decrement in Life(); on zero, put the mob to sleep for thirty seconds. + var/tranq_countdown = 0 + /// A temporary storage value for the duration of any tranquilizer effect. + var/tranq_duration + /mob/living/simple_mob/Initialize() verbs -= /mob/verb/observe health = maxHealth @@ -288,3 +293,17 @@ /decl/mob_organ_names var/list/hit_zones = list("body") //When in doubt, it's probably got a body. + +/mob/living/simple_mob/handle_sleeping() + if(sleeping || stat != CONSCIOUS) + tranq_countdown = null + tranq_duration = null + else if(tranq_countdown > 0) + tranq_countdown-- + if(tranq_countdown <= 0) + if(client) + to_chat(src, SPAN_DANGER("You fall asleep!")) + SetSleeping(max(1, round(tranq_duration / SSmobs.wait))) + else if(prob(5) && client) + to_chat(src, SPAN_WARNING("You feel [pick("dizzy", "woozy", "sleepy")]...")) + return ..() diff --git a/code/modules/projectiles/guns/energy/phase.dm b/code/modules/projectiles/guns/energy/phase.dm index bb99cac1d7..e954c2ec0d 100644 --- a/code/modules/projectiles/guns/energy/phase.dm +++ b/code/modules/projectiles/guns/energy/phase.dm @@ -1,5 +1,4 @@ // Phase weapons go here - /obj/item/gun/energy/phasegun name = "phase carbine" desc = "The RayZar EW26 Artemis is a downsized energy weapon, specifically designed for use against wildlife." @@ -12,6 +11,30 @@ projectile_type = /obj/item/projectile/energy/phase one_handed_penalty = 15 +/obj/item/gun/energy/phasegun/tranq_rifle + name = "tranquilizer rifle" + desc = "A niche RayZar product designed for nonlethal animal control. A specialized emitter disrupts the nervous system of the target, eventually inducing sleep. Only rated for use on wildlife." + icon_state = "phaserifle" + item_state = "phaserifle" + wielded_item_state = "phaserifle-wielded" + w_class = ITEMSIZE_LARGE + slot_flags = SLOT_BACK + charge_cost = 140 + projectile_type = /obj/item/projectile/energy/phase/tranq + accuracy = 15 + one_handed_penalty = 30 + +/obj/item/gun/energy/phasegun/tranq_pistol + name = "tranquilizer pistol" + desc = "A niche RayZar product designed for nonlethal animal control. A specialized emitter disrupts the nervous system of the target, eventually inducing sleep. Only rated for use on wildlife." + icon_state = "phase" + item_state = "taser" + w_class = ITEMSIZE_NORMAL + slot_flags = SLOT_BELT|SLOT_HOLSTER + charge_cost = 200 + projectile_type = /obj/item/projectile/energy/phase/tranq/weak + one_handed_penalty = 0 + /obj/item/gun/energy/phasegun/mounted self_recharge = 1 use_external_power = 1 @@ -65,4 +88,4 @@ charge_cost = 100 projectile_type = /obj/item/projectile/energy/phase/heavy/cannon accuracy = 15 - one_handed_penalty = 65 \ No newline at end of file + one_handed_penalty = 65 diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 89e5118be7..1ebb1d287c 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -820,3 +820,9 @@ if(silenced) volume = 5 playsound(A, hitsound_wall, volume, 1, -1) + + +/obj/item/projectile/proc/apply_SA_vulnerability(var/mob/living/simple_mob/victim) + if(!nodamage && SA_bonus_damage && istype(victim) && (SA_vulnerability & victim.mob_class)) + return SA_bonus_damage + return 0 diff --git a/code/modules/projectiles/projectile/energy.dm b/code/modules/projectiles/projectile/energy.dm index de52c5d4e5..2bec4ddf69 100644 --- a/code/modules/projectiles/projectile/energy.dm +++ b/code/modules/projectiles/projectile/energy.dm @@ -292,4 +292,33 @@ range = 10 damage = 15 SA_bonus_damage = 60 // 75 total on animals - hud_state = "laser_heat" \ No newline at end of file + hud_state = "laser_heat" + +/obj/item/projectile/energy/phase/tranq + name = "tranquilizer wave" + range = 10 + damage = 0 + nodamage = TRUE + SA_bonus_damage = 0 + hud_state = "laser_heat" + var/tranq_duration = 30 SECONDS + var/tranq_delay = 10 SECONDS + var/tranq_delay_modifier = 0.7 + +/obj/item/projectile/energy/phase/tranq/weak + range = 6 + tranq_duration = 20 SECONDS + tranq_delay = 15 SECONDS + tranq_delay_modifier = 0.9 + +// Being hit with a tranq shot either shaves a percentage off the remaining delay, or starts the timer. +/obj/item/projectile/energy/phase/tranq/apply_SA_vulnerability(var/mob/living/simple_mob/victim) + ..() + if(!istype(victim) || victim.stat != CONSCIOUS || !(SA_vulnerability & victim.mob_class)) + return + if(victim.tranq_countdown <= 0) + victim.tranq_countdown = tranq_duration / SSmobs.wait + else + victim.tranq_countdown *= tranq_delay_modifier + victim.tranq_duration = (victim.tranq_duration > 0) ? min(tranq_duration, victim.tranq_duration) : tranq_duration + victim.tranq_countdown = max(1, round(victim.tranq_countdown)) diff --git a/maps/cynosure/structures/closets/misc.dm b/maps/cynosure/structures/closets/misc.dm index fdeb93e013..6eed4e191b 100644 --- a/maps/cynosure/structures/closets/misc.dm +++ b/maps/cynosure/structures/closets/misc.dm @@ -34,10 +34,12 @@ /obj/item/clothing/accessory/permit/gun/planetside) /obj/structure/closet/secure_closet/guncabinet/tranq - name = "phase pistol cabinet" //"tranquilizer rifle cabinet" + name = "tranquilizer rifle cabinet" req_one_access = list(access_xenofauna,access_medical) starts_with = list( - /obj/item/gun/energy/phasegun/pistol = 2, + /obj/item/gun/energy/phasegun/tranq_rifle = 2, + /obj/item/gun/energy/phasegun/tranq_pistol, + /obj/item/gun/energy/phasegun/pistol, /obj/item/cell/device/weapon = 2, /obj/item/clothing/accessory/permit/gun/planetside )