From 9cff9cbabfa88382d95c303dec8c57c3be73ae12 Mon Sep 17 00:00:00 2001
From: GDN <96800819+GDNgit@users.noreply.github.com>
Date: Tue, 2 May 2023 14:19:18 -0500
Subject: [PATCH] cleans up some giant spider code, moves verbs to action
buttons (#20596)
* cleans up some giant spider code, moves verbs to action buttons
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
* Update code/modules/mob/living/simple_animal/hostile/giant_spider.dm
Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
---------
Co-authored-by: Henri215 <77684085+Henri215@users.noreply.github.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com>
---
.../simple_animal/hostile/giant_spider.dm | 212 ++++++++++--------
1 file changed, 118 insertions(+), 94 deletions(-)
diff --git a/code/modules/mob/living/simple_animal/hostile/giant_spider.dm b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm
index 2fb4f0271c0..b9035c60087 100644
--- a/code/modules/mob/living/simple_animal/hostile/giant_spider.dm
+++ b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm
@@ -38,7 +38,16 @@
attack_sound = 'sound/weapons/bite.ogg'
gold_core_spawnable = HOSTILE_SPAWN
var/venom_per_bite = 0 // While the /poison/ type path remains as-is for consistency reasons, we're really talking about venom, not poison.
- var/busy = 0
+
+/mob/living/simple_animal/hostile/poison/giant_spider/Initialize(mapload)
+ . = ..()
+ var/datum/action/innate/web_giant_spider/web_action = new()
+ web_action.Grant(src)
+
+/mob/living/simple_animal/hostile/poison/giant_spider/Destroy()
+ for(var/datum/action/innate/web_giant_spider/web_action in actions)
+ web_action.Remove(src)
+ return ..()
/mob/living/simple_animal/hostile/poison/giant_spider/AttackingTarget()
// This is placed here, NOT on /poison, because the other subtypes of /poison/ already override AttackingTarget() completely, and as such it would do nothing but confuse people there.
@@ -72,6 +81,20 @@
var/atom/cocoon_target
var/fed = 0
+/mob/living/simple_animal/hostile/poison/giant_spider/nurse/Initialize(mapload)
+ . = ..()
+ var/datum/action/innate/wrap_giant_spider/wrap_action = new()
+ wrap_action.Grant(src)
+ var/datum/action/innate/lay_eggs_giant_spider/egg_action = new()
+ egg_action.Grant(src)
+
+/mob/living/simple_animal/hostile/poison/giant_spider/nurse/Destroy()
+ for(var/datum/action/innate/wrap_giant_spider/wrap_action in actions)
+ wrap_action.Remove(src)
+ for(var/datum/action/innate/lay_eggs_giant_spider/egg_action in actions)
+ egg_action.Remove(src)
+ return ..()
+
//hunters have the most poison and move the fastest, so they can find prey
/mob/living/simple_animal/hostile/poison/giant_spider/hunter
desc = "Furry and black, it makes you shudder to look at it. This one has sparkling purple eyes."
@@ -89,7 +112,7 @@
. = ..()
if(AIStatus == AI_IDLE)
//1% chance to skitter madly away
- if(!busy && prob(1))
+ if(prob(1))
stop_automated_movement = TRUE
Goto(pick(urange(20, src, 1)), move_to_delay)
spawn(50)
@@ -99,21 +122,18 @@
/mob/living/simple_animal/hostile/poison/giant_spider/nurse/proc/GiveUp(C)
spawn(100)
- if(busy == MOVING_TO_TARGET)
- if(cocoon_target == C && get_dist(src,cocoon_target) > 1)
- cocoon_target = null
- busy = 0
- stop_automated_movement = FALSE
+ if(cocoon_target == C && get_dist(src, cocoon_target) > 1)
+ cocoon_target = null
+ stop_automated_movement = FALSE
/mob/living/simple_animal/hostile/poison/giant_spider/nurse/handle_automated_movement() //Hacky and ugly.
if(..())
var/list/can_see = view(src, 10)
- if(!busy && prob(30)) //30% chance to stop wandering and do something
+ if(prob(30)) //30% chance to stop wandering and do something
//first, check for potential food nearby to cocoon
for(var/mob/living/C in can_see)
if(C.stat && !istype(C, /mob/living/simple_animal/hostile/poison/giant_spider) && !C.anchored)
cocoon_target = C
- busy = MOVING_TO_TARGET
Goto(C, move_to_delay)
//give up if we can't reach them after 10 seconds
GiveUp(C)
@@ -121,11 +141,11 @@
//second, spin a sticky spiderweb on this tile
var/obj/structure/spider/stickyweb/W = locate() in get_turf(src)
if(!W)
- Web()
+ create_web()
else
//third, lay an egg cluster there
if(fed)
- LayEggs()
+ lay_spider_eggs()
else
//fourthly, cocoon any nearby items so those pesky pinkskins can't use them
for(var/obj/O in can_see)
@@ -134,43 +154,56 @@
if(isitem(O) || isstructure(O) || ismachinery(O))
cocoon_target = O
- busy = MOVING_TO_TARGET
stop_automated_movement = TRUE
Goto(O, move_to_delay)
//give up if we can't reach them after 10 seconds
GiveUp(O)
- else if(busy == MOVING_TO_TARGET && cocoon_target)
+ else if(cocoon_target)
if(get_dist(src, cocoon_target) <= 1)
- Wrap()
+ wrap_target()
else
- busy = 0
stop_automated_movement = FALSE
-/mob/living/simple_animal/hostile/poison/giant_spider/verb/Web()
- set name = "Lay Web"
- set category = "Spider"
- set desc = "Spread a sticky web to slow down prey."
+/datum/action/innate/web_giant_spider
+ name = "Lay Web"
+ icon_icon = 'icons/effects/effects.dmi'
+ button_icon_state = "stickyweb1"
- var/T = src.loc
+/datum/action/innate/web_giant_spider/Activate()
+ var/mob/living/simple_animal/hostile/poison/giant_spider/user = owner
+ user.create_web()
- if(busy != SPINNING_WEB)
- busy = SPINNING_WEB
- src.visible_message("\the [src] begins to secrete a sticky substance.")
- stop_automated_movement = TRUE
- spawn(40)
- if(busy == SPINNING_WEB && src.loc == T)
- new /obj/structure/spider/stickyweb(T)
- busy = 0
- stop_automated_movement = FALSE
+/datum/action/innate/wrap_giant_spider
+ name = "Wrap"
+ icon_icon = 'icons/effects/effects.dmi'
+ button_icon_state = "cocoon_large1"
+/datum/action/innate/wrap_giant_spider/Activate()
+ var/mob/living/simple_animal/hostile/poison/giant_spider/nurse/user = owner
+ user.wrap_target()
-/mob/living/simple_animal/hostile/poison/giant_spider/nurse/verb/Wrap()
- set name = "Wrap"
- set category = "Spider"
- set desc = "Wrap up prey to feast upon and objects for safe keeping."
+/datum/action/innate/lay_eggs_giant_spider
+ name = "Lay Eggs"
+ icon_icon = 'icons/effects/effects.dmi'
+ button_icon_state = "eggs"
+/datum/action/innate/lay_eggs_giant_spider/Activate()
+ var/mob/living/simple_animal/hostile/poison/giant_spider/nurse/user = owner
+ user.lay_spider_eggs()
+
+/mob/living/simple_animal/hostile/poison/giant_spider/proc/create_web()
+ var/T = loc
+
+ visible_message("[src] begins to secrete a sticky substance.")
+ stop_automated_movement = TRUE
+ if(!do_after_once(src, 4 SECONDS, target = loc, attempt_cancel_message = "You stop spinning a web."))
+ return
+ new /obj/structure/spider/stickyweb(T)
+ stop_automated_movement = FALSE
+
+/mob/living/simple_animal/hostile/poison/giant_spider/nurse/proc/wrap_target()
if(!cocoon_target)
var/list/choices = list()
for(var/mob/living/L in view(1, src))
@@ -195,74 +228,65 @@
to_chat(src, "No suitable dead prey or wrappable objects found nearby.")
return
- if(cocoon_target && busy != SPINNING_COCOON)
- busy = SPINNING_COCOON
- src.visible_message("\the [src] begins to secrete a sticky substance around \the [cocoon_target].")
+ if(cocoon_target)
+ visible_message("[src] begins to secrete a sticky substance around [cocoon_target].")
stop_automated_movement = TRUE
- walk(src,0)
- spawn(50)
- if(busy == SPINNING_COCOON)
- if(cocoon_target && isturf(cocoon_target.loc) && get_dist(src,cocoon_target) <= 1)
- var/obj/structure/spider/cocoon/C = new(cocoon_target.loc)
- var/large_cocoon = 0
- C.pixel_x = cocoon_target.pixel_x
- C.pixel_y = cocoon_target.pixel_y
- for(var/obj/item/I in C.loc)
- I.loc = C
- for(var/obj/structure/S in C.loc)
- if(!S.anchored)
- S.loc = C
- large_cocoon = 1
- for(var/obj/machinery/M in C.loc)
- if(!M.anchored)
- M.loc = C
- large_cocoon = 1
- for(var/mob/living/L in C.loc)
- if(istype(L, /mob/living/simple_animal/hostile/poison/giant_spider))
- continue
- if(L.stat != DEAD)
- continue
- large_cocoon = 1
- L.loc = C
- C.pixel_x = L.pixel_x
- C.pixel_y = L.pixel_y
- fed++
- visible_message("\the [src] sticks a proboscis into \the [L] and sucks a viscous substance out.")
+ walk(src, 0)
+ if(!do_after_once(src, 5 SECONDS, target = cocoon_target, attempt_cancel_message = "You stop wrapping [cocoon_target]."))
+ return
+ if(cocoon_target && isturf(cocoon_target.loc) && get_dist(src, cocoon_target) <= 1)
+ var/obj/structure/spider/cocoon/C = new(cocoon_target.loc)
+ var/large_cocoon = FALSE
+ C.pixel_x = cocoon_target.pixel_x
+ C.pixel_y = cocoon_target.pixel_y
+ for(var/obj/item/I in C.loc)
+ I.loc = C
+ for(var/obj/structure/S in C.loc)
+ if(!S.anchored)
+ S.loc = C
+ large_cocoon = TRUE
+ for(var/obj/machinery/M in C.loc)
+ if(!M.anchored)
+ M.loc = C
+ large_cocoon = TRUE
+ for(var/mob/living/L in C.loc)
+ if(istype(L, /mob/living/simple_animal/hostile/poison/giant_spider))
+ continue
+ if(L.stat != DEAD)
+ continue
+ large_cocoon = TRUE
+ L.loc = C
+ C.pixel_x = L.pixel_x
+ C.pixel_y = L.pixel_y
+ fed++
+ visible_message("[src] sticks a proboscis into [L] and sucks a viscous substance out.")
- break
- if(large_cocoon)
- C.icon_state = pick("cocoon_large1","cocoon_large2","cocoon_large3")
- cocoon_target = null
- busy = 0
- stop_automated_movement = FALSE
-
-/mob/living/simple_animal/hostile/poison/giant_spider/nurse/verb/LayEggs()
- set name = "Lay Eggs"
- set category = "Spider"
- set desc = "Lay a clutch of eggs, but you must wrap a creature for feeding first."
+ break
+ if(large_cocoon)
+ C.icon_state = pick("cocoon_large1", "cocoon_large2", "cocoon_large3")
+ cocoon_target = null
+ stop_automated_movement = FALSE
+/mob/living/simple_animal/hostile/poison/giant_spider/nurse/proc/lay_spider_eggs()
var/obj/structure/spider/eggcluster/E = locate() in get_turf(src)
if(E)
to_chat(src, "There is already a cluster of eggs here!")
- else if(!fed)
+ return
+ if(!fed)
to_chat(src, "You are too hungry to do this!")
- else if(busy != LAYING_EGGS)
- busy = LAYING_EGGS
- src.visible_message("\the [src] begins to lay a cluster of eggs.")
- stop_automated_movement = TRUE
- spawn(50)
- if(busy == LAYING_EGGS)
- E = locate() in get_turf(src)
- if(!E)
- var/obj/structure/spider/eggcluster/C = new /obj/structure/spider/eggcluster(src.loc)
- C.faction = faction.Copy()
- C.master_commander = master_commander
- C.xenobiology_spawned = xenobiology_spawned
- if(ckey)
- C.player_spiders = TRUE
- fed--
- busy = 0
- stop_automated_movement = FALSE
+ return
+ visible_message("[src] begins to lay a cluster of eggs.")
+ stop_automated_movement = TRUE
+ if(!do_after_once(src, 4 SECONDS, target = loc, attempt_cancel_message = "You stop laying eggs."))
+ return
+ var/obj/structure/spider/eggcluster/C = new /obj/structure/spider/eggcluster(loc)
+ C.faction = faction.Copy()
+ C.master_commander = master_commander
+ C.xenobiology_spawned = xenobiology_spawned
+ if(ckey)
+ C.player_spiders = TRUE
+ fed--
+ stop_automated_movement = FALSE
#undef SPINNING_WEB
#undef LAYING_EGGS