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.
This commit is contained in:
PsiOmegaDelta
2016-09-01 15:25:01 +02:00
committed by Yoshax
parent 843c48a9ee
commit 41129ab0d8
2 changed files with 63 additions and 91 deletions

View File

@@ -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, "<span class='warning'>You don't possess the ability to ventcrawl!</span>")
return FALSE
if(incapacitated())
to_chat(src, "<span class='warning'>You cannot ventcrawl in your current state!</span>")
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 << "<span class='warning'>You cannot ventcrawl while feeding.</span>"
return 0
return 1
to_chat(src, "<span class='warning'>You cannot ventcrawl while feeding.</span>")
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 << "<span class='warning'>You can't be carrying that when vent crawling! - [A.name]</span>"
return 0
return 1
to_chat(src, "<span class='warning'>You can't carry \the [A] while ventcrawling!</span>")
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,36 +93,16 @@ 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(!stat)
if(!lying)
if(!can_ventcrawl())
return
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())
@@ -162,11 +147,7 @@ var/list/ventcrawl_machinery = list(
if(!do_after(src, 45, vent_found, 1, 1))
return
if(!client)
return
if(!ventcrawl_carry())
if(!can_ventcrawl())
return
visible_message("<B>[src] scrambles into the ventilation ducts!</B>", "You climb into the ventilation system.")
@@ -180,13 +161,6 @@ var/list/ventcrawl_machinery = list(
else
to_chat(src, "You must be standing on or beside an air vent to enter it.")
else
to_chat(src, "You can't vent crawl while you're stunned!")
else
to_chat(src, "You must be conscious to do this!")
return
/mob/living/proc/add_ventcrawl(obj/machinery/atmospherics/starting_machine)
is_ventcrawling = 1
//candrop = 0

View File

@@ -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()