Files
Wildkins 290032afc7 Turn hydroponics get and set_trait into defines (#21404)
Hydroponics tray processing is a massive chunk of machinery processing
for no good reason, I have a sneaking suspicion that this is due to proc
overhead on get_trait, as process can call it upwards of 30 times per
tick per tray.

Realistically most of the things that are traits should instead be
variables, but that's a refactor for someone with more time.
2025-09-28 12:09:49 +00:00

88 lines
3.0 KiB
Plaintext

/obj/effect/plant/HasProximity(var/atom/movable/AM)
if(!is_mature() || (GET_SEED_TRAIT(seed, TRAIT_SPREAD) != 2 && GET_SEED_TRAIT(seed, TRAIT_CARNIVOROUS) == 0))
return
var/mob/living/M = AM
if(!istype(M))
return
if(!issmall(M) && GET_SEED_TRAIT(seed, TRAIT_SPREAD) != 2 && GET_SEED_TRAIT(seed, TRAIT_CARNIVOROUS) != 2)
// let TRAIT_CARNIVOROUS = 1 plants eat small creatures without murdering every hydroponicist
return
if(!buckled && !M.buckled_to && !M.anchored && (issmall(M) || prob(round(GET_SEED_TRAIT(seed, TRAIT_POTENCY)/6))))
//wait a tick for the Entered() proc that called HasProximity() to finish (and thus the moving animation),
//so we don't appear to teleport from two tiles away when moving into a turf adjacent to vines.
addtimer(CALLBACK(src, PROC_REF(entangle), M), 1)
/obj/effect/plant/attack_generic(mob/user, damage, attack_message, environment_smash, armor_penetration, attack_flags, damage_type)
manual_unbuckle(user)
/obj/effect/plant/proc/trodden_on(var/mob/living/victim)
if(!is_mature())
return
var/mob/living/carbon/human/H = victim
if(istype(H) && H.shoes)
return
seed.do_thorns(victim,src)
seed.do_sting(victim,src,pick(BP_R_FOOT,BP_L_FOOT,BP_R_LEG,BP_L_LEG))
/obj/effect/plant/unbuckle()
if(istype(buckled, /mob/living))
var/mob/living/M = buckled
if(M.buckled_to == src)
M.buckled_to = null
M.anchored = initial(buckled.anchored)
M.update_canmove()
buckled = null
return
/obj/effect/plant/proc/manual_unbuckle(mob/user as mob)
if(buckled)
if(prob(seed ? min(max(0,100 - GET_SEED_TRAIT(seed, TRAIT_POTENCY)/2),100) : 50))
if(buckled.buckled_to == src)
if(buckled != user)
buckled.visible_message(\
SPAN_NOTICE("[user.name] frees [buckled.name] from \the [src]."),\
SPAN_NOTICE("[user.name] frees you from \the [src]."),\
SPAN_WARNING("You hear shredding and ripping."))
else
buckled.visible_message(\
SPAN_NOTICE("[buckled.name] struggles free of \the [src]."),\
SPAN_NOTICE("You untangle \the [src] from around yourself."),\
SPAN_WARNING("You hear shredding and ripping."))
unbuckle()
else
var/text = pick("rip","tear","pull")
user.visible_message(\
SPAN_NOTICE("[user.name] [text]s at \the [src]."),\
SPAN_NOTICE("You [text] at \the [src]."),\
SPAN_WARNING("You hear shredding and ripping."))
return
/obj/effect/plant/proc/entangle(var/mob/living/victim)
if(buckled)
return
if(victim.buckled_to)
return
//grabbing people
if(!victim.anchored && Adjacent(victim) && victim.loc != get_turf(src))
var/can_grab = 1
if(istype(victim, /mob/living/carbon/human))
var/mob/living/carbon/human/H = victim
if(H.Check_Shoegrip(FALSE))
can_grab = 0
if(can_grab)
src.visible_message(SPAN_DANGER("Tendrils lash out from \the [src] and drag \the [victim] in!"))
victim.forceMove(src.loc)
//entangling people
if(victim.loc == src.loc)
buckle(victim)
victim.set_dir(pick(GLOB.cardinals))
to_chat(victim, SPAN_DANGER("Tendrils tighten around you!"))