From e33e6581781666c574cb66064c96830518ec6682 Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Sat, 9 May 2015 05:43:47 -0700 Subject: [PATCH 1/2] Water_act system - for all your watery needs This is the first commit of the Water_act system for monkey cubes, showers, and mobs. The idea of the system is to outsource the effects of water to the object/mob being affected instead of a bunch of snowflake code. --- code/game/atoms_movable.dm | 2 ++ code/game/objects/structures/watercloset.dm | 24 +++++++++++++++---- code/modules/mob/living/carbon/carbon.dm | 1 - .../mob/living/carbon/human/human_defense.dm | 5 ++++ code/modules/mob/living/living_defense.dm | 4 ++++ .../reagent_containers/food/snacks.dm | 3 +++ 6 files changed, 34 insertions(+), 5 deletions(-) diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index dcbe4e4462e..b34f3412a5d 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -282,3 +282,5 @@ /atom/movable/proc/canSingulothPull(var/obj/machinery/singularity/singulo) return 1 +/atom/movable/proc/water_act(var/volume, var/temperature, var/source) //amount of water acting : temperature of water in kelvin : object that called it (for shennagins) + return 1 \ No newline at end of file diff --git a/code/game/objects/structures/watercloset.dm b/code/game/objects/structures/watercloset.dm index 2fdd133801b..2081f911325 100644 --- a/code/game/objects/structures/watercloset.dm +++ b/code/game/objects/structures/watercloset.dm @@ -146,8 +146,10 @@ if (M.loc == loc) wash(M) check_heat(M) + M.water_act(100, convertHeat(), src) for (var/atom/movable/G in src.loc) G.clean_blood() + G.water_act(100, convertHeat(), src) /obj/machinery/shower/attackby(obj/item/I as obj, mob/user as mob, params) if(I.type == /obj/item/device/analyzer) @@ -163,6 +165,8 @@ if("boiling") watertemp = "normal" user.visible_message("[user] adjusts the shower with the [I].", "You adjust the shower with the [I].") + if(on) + I.water_act(100, convertHeat(), src) /obj/machinery/shower/update_icon() //this is terribly unreadable, but basically it makes the shower mist up overlays.Cut() //once it's been on for a while, in addition to handling the water overlay. @@ -201,10 +205,21 @@ mobpresent -= 1 ..() +/obj/machinery/shower/proc/convertHeat() + switch(watertemp) + if("boiling") + return 340.15 + if("normal") + return 310.15 + if("freezing") + return 230.15 + //Yes, showers are super powerful as far as washing goes. /obj/machinery/shower/proc/wash(atom/movable/O as obj|mob) if(!on) return + O.water_act(100, convertHeat(), src) + if(isliving(O)) var/mob/living/L = O L.ExtinguishMob() @@ -298,17 +313,16 @@ var/mob/living/carbon/C = M if(watertemp == "freezing") - C.bodytemperature = max(80, C.bodytemperature - 80) + //C.bodytemperature = max(80, C.bodytemperature - 80) C << "The water is freezing!" return if(watertemp == "boiling") - C.bodytemperature = min(500, C.bodytemperature + 35) + //C.bodytemperature = min(500, C.bodytemperature + 35) C.adjustFireLoss(5) C << "The water is searing!" return - /obj/item/weapon/bikehorn/rubberducky name = "rubber ducky" desc = "Rubber ducky you're so fine, you make bathtime lots of fuuun. Rubber ducky I'm awfully fooooond of yooooouuuu~" //thanks doohl @@ -372,7 +386,9 @@ user.visible_message("\blue [user] fills the [RG] using \the [src].","\blue You fill the [RG] using \the [src].") return - else if (istype(O, /obj/item/weapon/melee/baton)) + O.water_act(20,310.15,src) + + if (istype(O, /obj/item/weapon/melee/baton)) var/obj/item/weapon/melee/baton/B = O if (B.bcell.charge > 0 && B.status == 1) flick("baton_active", src) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 683228e97e8..5da86e83455 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -92,7 +92,6 @@ mob/living return return - /mob/living/carbon/electrocute_act(var/shock_damage, var/obj/source, var/siemens_coeff = 1.0, var/def_zone = null) if(status_flags & GODMODE) //godmode return 0 diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 3ff64431933..d8d12108b20 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -488,3 +488,8 @@ emp_act ..() return + +/mob/living/carbon/human/water_act(volume, temperature) + ..() + if(temperature >= 330) bodytemperature = bodytemperature + (temperature - bodytemperature) + if(temperature <= 280) bodytemperature = bodytemperature - (bodytemperature - temperature) \ No newline at end of file diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index b61d58223c6..aff6a6d415e 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -238,6 +238,10 @@ //Mobs on Fire end +/mob/living/water_act(volume, temperature) + if(volume >= 20) fire_stacks -= 0.5 + if(volume >= 50) fire_stacks -= 1 + //This is called when the mob is thrown into a dense turf /mob/living/proc/turf_collision(var/turf/T, var/speed) src.take_organ_damage(speed*5) diff --git a/code/modules/reagents/reagent_containers/food/snacks.dm b/code/modules/reagents/reagent_containers/food/snacks.dm index 8cc0229c548..6d332a5cbc1 100644 --- a/code/modules/reagents/reagent_containers/food/snacks.dm +++ b/code/modules/reagents/reagent_containers/food/snacks.dm @@ -1722,6 +1722,9 @@ M.gib() ..() + water_act(volume, temperature) + if(volume >= 5) return Expand() + proc/Expand() for(var/mob/M in viewers(src,7)) M << "\red \The [src] expands!" From 27442f95392e6e4900a1cfec793f6f3fbb190974 Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Sun, 10 May 2015 05:39:26 -0700 Subject: [PATCH 2/2] Water_act: Wetlevel for carbon mobs All carbon mobs have a new variable called wetness, which is increased upon water_act's that have a volume over 10, and is decreased every 22~ cycles of mob_master. This variable currently does absolutely nothing but change their examine text. --- code/game/objects/effects/effect_system.dm | 3 +++ code/game/objects/structures/watercloset.dm | 1 + code/modules/mob/living/carbon/alien/alien.dm | 4 ++++ .../mob/living/carbon/alien/humanoid/life.dm | 3 +++ code/modules/mob/living/carbon/carbon_defenses.dm | 5 +++++ code/modules/mob/living/carbon/carbon_defines.dm | 3 ++- code/modules/mob/living/carbon/human/examine.dm | 12 ++++++++++++ .../mob/living/carbon/human/human_defense.dm | 2 +- code/modules/mob/living/carbon/human/life.dm | 7 +++++++ code/modules/mob/living/carbon/metroid/examine.dm | 14 ++++++++++++++ code/modules/mob/living/carbon/metroid/life.dm | 7 +++++++ code/modules/mob/living/carbon/monkey/examine.dm | 14 ++++++++++++++ code/modules/mob/living/carbon/monkey/life.dm | 10 +++++++++- 13 files changed, 82 insertions(+), 3 deletions(-) diff --git a/code/game/objects/effects/effect_system.dm b/code/game/objects/effects/effect_system.dm index d5d3555e12d..26d669038ba 100644 --- a/code/game/objects/effects/effect_system.dm +++ b/code/game/objects/effects/effect_system.dm @@ -79,6 +79,9 @@ would spawn and follow the beaker, even if it is carried or thrown. /obj/effect/effect/water/Bump(atom/A) if(reagents) reagents.reaction(A) + if(istype(A,/atom/movable)) + var/atom/movable/AM = A + AM.water_act(life, 310.15, src) return ..() diff --git a/code/game/objects/structures/watercloset.dm b/code/game/objects/structures/watercloset.dm index 2081f911325..76c6715b0da 100644 --- a/code/game/objects/structures/watercloset.dm +++ b/code/game/objects/structures/watercloset.dm @@ -308,6 +308,7 @@ check_heat(C) /obj/machinery/shower/proc/check_heat(mob/M as mob) + M.water_act(100, convertHeat(), src) //convenience if(!on || watertemp == "normal") return if(iscarbon(M)) var/mob/living/carbon/C = M diff --git a/code/modules/mob/living/carbon/alien/alien.dm b/code/modules/mob/living/carbon/alien/alien.dm index 6e5dcdc3dea..a2e7be0928d 100644 --- a/code/modules/mob/living/carbon/alien/alien.dm +++ b/code/modules/mob/living/carbon/alien/alien.dm @@ -152,6 +152,10 @@ bodytemperature += BODYTEMP_HEATING_MAX //If you're on fire, you heat up! return +/mob/living/carbon/alien/proc/handle_wetness() + if(mob_master.current_cycle%20==2) //dry off a bit once every 20 ticks or so + wetlevel = max(wetlevel - 1,0) + return /mob/living/carbon/alien/IsAdvancedToolUser() return has_fine_manipulation diff --git a/code/modules/mob/living/carbon/alien/humanoid/life.dm b/code/modules/mob/living/carbon/alien/humanoid/life.dm index eda8df77ee7..9ecf410a4d3 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/life.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/life.dm @@ -53,6 +53,9 @@ //Handle being on fire handle_fire() + //Decrease wetness over time + handle_wetness() + //Status updates, death etc. handle_regular_status_updates() update_canmove() diff --git a/code/modules/mob/living/carbon/carbon_defenses.dm b/code/modules/mob/living/carbon/carbon_defenses.dm index fddbd0d3cda..ab1c27ca2ee 100644 --- a/code/modules/mob/living/carbon/carbon_defenses.dm +++ b/code/modules/mob/living/carbon/carbon_defenses.dm @@ -14,4 +14,9 @@ visible_message("[src] catches [I]!") throw_mode_off() return + ..() + +/mob/living/carbon/water_act(volume, temperature, source) + if(volume > 10) //anything over 10 volume will make the mob wetter. + wetlevel = min(wetlevel + 1,5) ..() \ No newline at end of file diff --git a/code/modules/mob/living/carbon/carbon_defines.dm b/code/modules/mob/living/carbon/carbon_defines.dm index f9b61a3bd10..b6852c8a8dc 100644 --- a/code/modules/mob/living/carbon/carbon_defines.dm +++ b/code/modules/mob/living/carbon/carbon_defines.dm @@ -20,4 +20,5 @@ var/pulse = PULSE_NORM //current pulse level - var/heart_attack = 0 \ No newline at end of file + var/heart_attack = 0 + var/wetlevel = 0 //how wet the mob is \ No newline at end of file diff --git a/code/modules/mob/living/carbon/human/examine.dm b/code/modules/mob/living/carbon/human/examine.dm index fac498d9219..00ec9e67181 100644 --- a/code/modules/mob/living/carbon/human/examine.dm +++ b/code/modules/mob/living/carbon/human/examine.dm @@ -231,6 +231,18 @@ if(fire_stacks < 0) msg += "[t_He] looks a little soaked.\n" + switch(wetlevel) + if(1) + msg += "[t_He] looks a bit damp.\n" + if(2) + msg += "[t_He] looks a little bit wet.\n" + if(3) + msg += "[t_He] looks wet.\n" + if(4) + msg += "[t_He] looks very wet.\n" + if(5) + msg += "[t_He] looks absolutely soaked.\n" + if(nutrition < 100) msg += "[t_He] [t_is] severely malnourished.\n" else if(nutrition >= 500) diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index d8d12108b20..c2498a5a740 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -489,7 +489,7 @@ emp_act return -/mob/living/carbon/human/water_act(volume, temperature) +/mob/living/carbon/human/water_act(volume, temperature, source) ..() if(temperature >= 330) bodytemperature = bodytemperature + (temperature - bodytemperature) if(temperature <= 280) bodytemperature = bodytemperature - (bodytemperature - temperature) \ No newline at end of file diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 71226aa8bfb..ec2e253e100 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -108,6 +108,9 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc //Check if we're on fire handle_fire() + //Decrease wetness over time + handle_wetness() + //stuff in the stomach handle_stomach() @@ -547,6 +550,10 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc return //END FIRE CODE + proc/handle_wetness() + if(mob_master.current_cycle%20==2) //dry off a bit once every 20 ticks or so + wetlevel = max(wetlevel - 1,0) + return /* proc/adjust_body_temperature(current, loc_temp, boost) diff --git a/code/modules/mob/living/carbon/metroid/examine.dm b/code/modules/mob/living/carbon/metroid/examine.dm index f8fc23ad2e9..38087b35795 100644 --- a/code/modules/mob/living/carbon/metroid/examine.dm +++ b/code/modules/mob/living/carbon/metroid/examine.dm @@ -32,6 +32,20 @@ if(10) msg += "It is radiating with massive levels of electrical activity!\n" + msg += "" + switch(wetlevel) + if(1) + msg += "It looks a bit damp.\n" + if(2) + msg += "It looks a little bit wet.\n" + if(3) + msg += "It looks wet.\n" + if(4) + msg += "It looks very wet.\n" + if(5) + msg += "It looks absolutely soaked.\n" + msg += "" + msg += "*---------*" usr << msg return \ No newline at end of file diff --git a/code/modules/mob/living/carbon/metroid/life.dm b/code/modules/mob/living/carbon/metroid/life.dm index 8b11c8a1b2f..afcb48726bd 100644 --- a/code/modules/mob/living/carbon/metroid/life.dm +++ b/code/modules/mob/living/carbon/metroid/life.dm @@ -42,6 +42,8 @@ handle_regular_status_updates() // Status updates, death etc. + handle_wetness() + /mob/living/carbon/slime/proc/AIprocess() // the master AI process if(AIproc || stat == DEAD || client) return @@ -285,6 +287,11 @@ else Evolve() +/mob/living/carbon/slime/proc/handle_wetness() + if(mob_master.current_cycle%20==2) //dry off a bit once every 20 ticks or so + wetlevel = max(wetlevel - 1,0) + return + /mob/living/carbon/slime/proc/handle_targets() if(Tempstun) if(!Victim) // not while they're eating! diff --git a/code/modules/mob/living/carbon/monkey/examine.dm b/code/modules/mob/living/carbon/monkey/examine.dm index 5cbb5c6c7ce..9c9d0ef5082 100644 --- a/code/modules/mob/living/carbon/monkey/examine.dm +++ b/code/modules/mob/living/carbon/monkey/examine.dm @@ -40,6 +40,20 @@ msg += "It isn't responding to anything around it; it seems to be asleep.\n" msg += "" + msg += "" + switch(wetlevel) + if(1) + msg += "It looks a bit damp.\n" + if(2) + msg += "It looks a little bit wet.\n" + if(3) + msg += "It looks wet.\n" + if(4) + msg += "It looks very wet.\n" + if(5) + msg += "It looks absolutely soaked.\n" + msg += "" + if (src.digitalcamo) msg += "It is repulsively uncanny!\n" diff --git a/code/modules/mob/living/carbon/monkey/life.dm b/code/modules/mob/living/carbon/monkey/life.dm index 1a3bfc3f05a..cc1808ff6c5 100644 --- a/code/modules/mob/living/carbon/monkey/life.dm +++ b/code/modules/mob/living/carbon/monkey/life.dm @@ -62,6 +62,9 @@ //Check if we're on fire handle_fire() + //Decrease wetness over time + handle_wetness() + //Status updates, death etc. handle_regular_status_updates() update_canmove() @@ -660,4 +663,9 @@ return adjustFireLoss(6) return - //END FIRE CODE \ No newline at end of file + //END FIRE CODE + + proc/handle_wetness() + if(mob_master.current_cycle%20==2) //dry off a bit once every 20 ticks or so + wetlevel = max(wetlevel - 1,0) + return \ No newline at end of file