Skip to content

Commit

Permalink
Weed nodes now check density
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
Drulikar committed Jun 29, 2023
1 parent 71f0ab8 commit 3808550
Showing 1 changed file with 32 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,62 @@

// Plant weeds
/datum/action/xeno_action/onclick/plant_weeds/use_ability(atom/A)
var/mob/living/carbon/xenomorph/X = owner
var/mob/living/carbon/xenomorph/xeno = owner
if(!action_cooldown_check())
return
if(!X.check_state())
if(!xeno.check_state())
return
if(X.burrow)
if(xeno.burrow)
return

var/turf/T = X.loc
var/turf/turf = xeno.loc

if(!istype(T))
to_chat(X, SPAN_WARNING("You can't do that here."))
if(!istype(turf))
to_chat(xeno, SPAN_WARNING("You can't do that here."))
return

var/is_weedable = T.is_weedable()
if(turf.density)
to_chat(xeno, SPAN_WARNING("You can't do that here."))
return

var/is_weedable = turf.is_weedable()
if(!is_weedable)
to_chat(X, SPAN_WARNING("Bad place for a garden!"))
to_chat(xeno, SPAN_WARNING("Bad place for a garden!"))
return
if(!plant_on_semiweedable && is_weedable < FULLY_WEEDABLE)
to_chat(X, SPAN_WARNING("Bad place for a garden!"))
to_chat(xeno, SPAN_WARNING("Bad place for a garden!"))
return

var/obj/effect/alien/weeds/node/N = locate() in T
if(N && N.weed_strength >= X.weed_level)
to_chat(X, SPAN_WARNING("There's a pod here already!"))
var/obj/effect/alien/weeds/node/node = locate() in turf
if(node && node.weed_strength >= xeno.weed_level)
to_chat(xeno, SPAN_WARNING("There's a pod here already!"))
return

var/obj/effect/alien/resin/trap/resin_trap = locate() in T
var/obj/effect/alien/resin/trap/resin_trap = locate() in turf
if(resin_trap)
to_chat(X, SPAN_WARNING("You can't weed on top of a trap!"))
to_chat(xeno, SPAN_WARNING("You can't weed on top of a trap!"))
return

var/list/to_convert
if(N)
to_convert = N.children.Copy()

var/obj/effect/alien/weeds/W = locate(/obj/effect/alien/weeds) in T
if (W && W.weed_strength >= WEED_LEVEL_HIVE)
to_chat(X, SPAN_WARNING("These weeds are too strong to plant a node on!"))
var/obj/effect/alien/weeds/weed = node || locate() in turf
if (weed && weed.weed_strength >= WEED_LEVEL_HIVE)
to_chat(xeno, SPAN_WARNING("These weeds are too strong to plant a node on!"))
return

var/area/AR = get_area(T)
if(isnull(AR) || !(AR.is_resin_allowed))
to_chat(X, SPAN_XENOWARNING("It's too early to spread the hive this far."))
var/area/area = get_area(turf)
if(isnull(area) || !(area.is_resin_allowed))
to_chat(xeno, SPAN_XENOWARNING("It's too early to spread the hive this far."))
return

if (!check_and_use_plasma_owner())
if(!check_and_use_plasma_owner())
return

X.visible_message(SPAN_XENONOTICE("\The [X] regurgitates a pulsating node and plants it on the ground!"), \
var/list/to_convert
if(node)
to_convert = node.children.Copy()

xeno.visible_message(SPAN_XENONOTICE("\The [xeno] regurgitates a pulsating node and plants it on the ground!"), \
SPAN_XENONOTICE("You regurgitate a pulsating node and plant it on the ground!"), null, 5)
var/obj/effect/alien/weeds/node/new_node = new node_type(X.loc, src, X)
var/obj/effect/alien/weeds/node/new_node = new node_type(xeno.loc, src, xeno)

if(to_convert)
for(var/weed in to_convert)
Expand All @@ -64,7 +68,7 @@
new /obj/effect/alien/weeds(target_turf, new_node)
qdel(weed)

playsound(X.loc, "alien_resin_build", 25)
playsound(xeno.loc, "alien_resin_build", 25)
apply_cooldown()
return ..()

Expand Down

0 comments on commit 3808550

Please sign in to comment.