From 41129ab0d8bad5018f2f5a6ded90a49097a40df1 Mon Sep 17 00:00:00 2001 From: PsiOmegaDelta Date: Thu, 1 Sep 2016 15:25:01 +0200 Subject: [PATCH] Tweaks vent crawling. The ability to ventcrawl is now checked by the /handle_ventcrawl() proc, making it possible to properly check before and after the do_after() call. Moves various checks into the base can_ventcrawl proc. Now lists the first object that prevents a mob from ventcrawling, making it easier to correct the exception list. Removes the issmall() check, instead checks if the crawling mob has the relevant verb. Fixes #14081. --- code/modules/ventcrawl/ventcrawl.dm | 152 ++++++++++------------- code/modules/ventcrawl/ventcrawl_verb.dm | 2 - 2 files changed, 63 insertions(+), 91 deletions(-) diff --git a/code/modules/ventcrawl/ventcrawl.dm b/code/modules/ventcrawl/ventcrawl.dm index cc9cd50359..9b2b83d3e7 100644 --- a/code/modules/ventcrawl/ventcrawl.dm +++ b/code/modules/ventcrawl/ventcrawl.dm @@ -18,7 +18,15 @@ var/list/ventcrawl_machinery = list( /mob/var/next_play_vent = 0 /mob/living/proc/can_ventcrawl() - return 0 + if(!client) + return FALSE + if(!(/mob/living/proc/ventcrawl in verbs)) + to_chat(src, "You don't possess the ability to ventcrawl!") + return FALSE + if(incapacitated()) + to_chat(src, "You cannot ventcrawl in your current state!") + return FALSE + return ventcrawl_carry() /mob/living/Login() . = ..() @@ -29,9 +37,9 @@ var/list/ventcrawl_machinery = list( /mob/living/carbon/slime/can_ventcrawl() if(Victim) - src << "You cannot ventcrawl while feeding." - return 0 - return 1 + to_chat(src, "You cannot ventcrawl while feeding.") + return FALSE + . = ..() /mob/living/proc/is_allowed_vent_crawl_item(var/obj/item/carried_item) if(carried_item == ability_master) @@ -57,21 +65,18 @@ var/list/ventcrawl_machinery = list( return ..() /mob/living/proc/ventcrawl_carry() - for(var/atom/A in src.contents) + for(var/atom/A in contents) if(!is_allowed_vent_crawl_item(A)) - src << "You can't be carrying that when vent crawling! - [A.name]" - return 0 - return 1 + to_chat(src, "You can't carry \the [A] while ventcrawling!") + return FALSE + return TRUE /mob/living/AltClickOn(var/atom/A) - if(is_type_in_list(A,ventcrawl_machinery) && src.can_ventcrawl()) - src.handle_ventcrawl(A) + if(is_type_in_list(A,ventcrawl_machinery)) + handle_ventcrawl(A) return 1 return ..() -/mob/living/carbon/human/can_ventcrawl() - return issmall(src) - /mob/proc/start_ventcrawl() var/atom/pipe var/list/pipes = list() @@ -88,104 +93,73 @@ var/list/ventcrawl_machinery = list( if(canmove && pipe) return pipe -/mob/living/carbon/slime/can_ventcrawl() - return 1 - -/mob/living/simple_animal/borer/can_ventcrawl() - return 1 - -/mob/living/simple_animal/borer/ventcrawl_carry() - return 1 - -/mob/living/simple_animal/mouse/can_ventcrawl() - return 1 - -/mob/living/simple_animal/spiderbot/can_ventcrawl() - return 1 - -/mob/living/carbon/alien/can_ventcrawl() - return 1 - /mob/living/carbon/alien/ventcrawl_carry() return 1 /mob/living/var/ventcrawl_layer = 3 /mob/living/proc/handle_ventcrawl(var/atom/clicked_on) + if(!can_ventcrawl()) + return - if(!stat) - if(!lying) + var/obj/machinery/atmospherics/unary/vent_found + if(clicked_on && Adjacent(clicked_on)) + vent_found = clicked_on + if(!istype(vent_found) || !vent_found.can_crawl_through()) + vent_found = null - var/obj/machinery/atmospherics/unary/vent_found + if(!vent_found) + for(var/obj/machinery/atmospherics/machine in range(1,src)) + if(is_type_in_list(machine, ventcrawl_machinery)) + vent_found = machine - if(clicked_on && Adjacent(clicked_on)) - vent_found = clicked_on - if(!istype(vent_found) || !vent_found.can_crawl_through()) - vent_found = null - - if(!vent_found) - for(var/obj/machinery/atmospherics/machine in range(1,src)) - if(is_type_in_list(machine, ventcrawl_machinery)) - vent_found = machine - - if(!vent_found || !vent_found.can_crawl_through()) - vent_found = null - - if(vent_found) - break + if(!vent_found || !vent_found.can_crawl_through()) + vent_found = null if(vent_found) - if(vent_found.network && (vent_found.network.normal_members.len || vent_found.network.line_members.len)) + break - to_chat(src, "You begin climbing into the ventilation system...") - if(vent_found.air_contents && !issilicon(src)) + if(vent_found) + if(vent_found.network && (vent_found.network.normal_members.len || vent_found.network.line_members.len)) - switch(vent_found.air_contents.temperature) - if(0 to BODYTEMP_COLD_DAMAGE_LIMIT) - to_chat(src, "You feel a painful freeze coming from the vent!") - if(BODYTEMP_COLD_DAMAGE_LIMIT to T0C) - to_chat(src, "You feel an icy chill coming from the vent.") - if(T0C + 40 to BODYTEMP_HEAT_DAMAGE_LIMIT) - to_chat(src, "You feel a hot wash coming from the vent.") - if(BODYTEMP_HEAT_DAMAGE_LIMIT to INFINITY) - to_chat(src, "You feel a searing heat coming from the vent!") + to_chat(src, "You begin climbing into the ventilation system...") + if(vent_found.air_contents && !issilicon(src)) - switch(vent_found.air_contents.return_pressure()) - if(0 to HAZARD_LOW_PRESSURE) - to_chat(src, "You feel a rushing draw pulling you into the vent!") - if(HAZARD_LOW_PRESSURE to WARNING_LOW_PRESSURE) - to_chat(src, "You feel a strong drag pulling you into the vent.") - if(WARNING_HIGH_PRESSURE to HAZARD_HIGH_PRESSURE) - to_chat(src, "You feel a strong current pushing you away from the vent.") - if(HAZARD_HIGH_PRESSURE to INFINITY) - to_chat(src, "You feel a roaring wind pushing you away from the vent!") + switch(vent_found.air_contents.temperature) + if(0 to BODYTEMP_COLD_DAMAGE_LIMIT) + to_chat(src, "You feel a painful freeze coming from the vent!") + if(BODYTEMP_COLD_DAMAGE_LIMIT to T0C) + to_chat(src, "You feel an icy chill coming from the vent.") + if(T0C + 40 to BODYTEMP_HEAT_DAMAGE_LIMIT) + to_chat(src, "You feel a hot wash coming from the vent.") + if(BODYTEMP_HEAT_DAMAGE_LIMIT to INFINITY) + to_chat(src, "You feel a searing heat coming from the vent!") - if(!do_after(src, 45, vent_found, 1, 1)) - return + switch(vent_found.air_contents.return_pressure()) + if(0 to HAZARD_LOW_PRESSURE) + to_chat(src, "You feel a rushing draw pulling you into the vent!") + if(HAZARD_LOW_PRESSURE to WARNING_LOW_PRESSURE) + to_chat(src, "You feel a strong drag pulling you into the vent.") + if(WARNING_HIGH_PRESSURE to HAZARD_HIGH_PRESSURE) + to_chat(src, "You feel a strong current pushing you away from the vent.") + if(HAZARD_HIGH_PRESSURE to INFINITY) + to_chat(src, "You feel a roaring wind pushing you away from the vent!") - if(!client) - return + if(!do_after(src, 45, vent_found, 1, 1)) + return + if(!can_ventcrawl()) + return - if(!ventcrawl_carry()) - return + visible_message("[src] scrambles into the ventilation ducts!", "You climb into the ventilation system.") - visible_message("[src] scrambles into the ventilation ducts!", "You climb into the ventilation system.") - - forceMove(vent_found) - add_ventcrawl(vent_found) - - else - to_chat(src, "This vent is not connected to anything.") - - else - to_chat(src, "You must be standing on or beside an air vent to enter it.") + forceMove(vent_found) + add_ventcrawl(vent_found) else - to_chat(src, "You can't vent crawl while you're stunned!") + to_chat(src, "This vent is not connected to anything.") else - to_chat(src, "You must be conscious to do this!") - return + to_chat(src, "You must be standing on or beside an air vent to enter it.") /mob/living/proc/add_ventcrawl(obj/machinery/atmospherics/starting_machine) is_ventcrawling = 1 diff --git a/code/modules/ventcrawl/ventcrawl_verb.dm b/code/modules/ventcrawl/ventcrawl_verb.dm index 44bcab4a5c..b49f22836d 100644 --- a/code/modules/ventcrawl/ventcrawl_verb.dm +++ b/code/modules/ventcrawl/ventcrawl_verb.dm @@ -2,8 +2,6 @@ set name = "Crawl through Vent" set desc = "Enter an air vent and crawl through the pipe system." set category = "Abilities" - if(incapacitated() || restrained()) - return var/pipe = start_ventcrawl() if(pipe) handle_ventcrawl()