Skip to content

Commit

Permalink
Adds procs for applying root (immobilise) (#5551)
Browse files Browse the repository at this point in the history
# About the pull request

Adds procs for applying a root
(datum/status_effect/incapacitating/immobilized)

# Explain why it's good for the game

No need to keep applying and removing `TRAIT_IMMOBILIZED` directly.

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
code: Added procs for applying a root (immobilise)
/:cl:
  • Loading branch information
Birdtalon authored Jan 30, 2024
1 parent 5c16846 commit 0a17439
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 10 deletions.
5 changes: 4 additions & 1 deletion code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@
#define DAZE "daze"
#define SLOW "slow"
#define SUPERSLOW "superslow"
#define ROOT "root"

//=================================================

//I hate adding defines like this but I'd much rather deal with bitflags than lists and string searches
Expand All @@ -100,14 +102,15 @@

//Bitflags defining which status effects could be or are inflicted on a mob

#define STATUS_FLAGS_DEBILITATE (CANSTUN|CANKNOCKOUT|CANDAZE|CANSLOW)
#define STATUS_FLAGS_DEBILITATE (CANSTUN|CANKNOCKOUT|CANDAZE|CANSLOW|CANROOT)

#define CANSTUN (1<<0)
#define CANKNOCKDOWN (1<<1)
#define CANKNOCKOUT (1<<2)
#define CANPUSH (1<<3)
#define LEAPING (1<<4)
#define PASSEMOTES (1<<5) //holders inside of mob that need to see emotes.
#define CANROOT (1<<6)
#define GODMODE (1<<12)
#define FAKEDEATH (1<<13) //Replaces stuff like changeling.changeling_fakedeath
#define DISFIGURED (1<<14) //I'll probably move this elsewhere if I ever get wround to writing a bitflag mob-damage system
Expand Down
2 changes: 1 addition & 1 deletion code/__HELPERS/#maths.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ GLOBAL_LIST_INIT(sqrtTable, list(1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4,
#define Lcm(a, b) (abs(a) / Gcd(a, b) * abs(b))

// Returns the nth root of x.
#define Root(n, x) (x ** (1 / n))
#define NRoot(n, x) (x ** (1 / n))

// secant
#define Sec(x) (1 / cos(x))
Expand Down
31 changes: 23 additions & 8 deletions code/modules/mob/living/damage_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
EyeBlur(effect)
if(DROWSY)
drowsyness = max(drowsyness, effect)
if(ROOT)
Root(effect)
updatehealth()
return TRUE

Expand Down Expand Up @@ -130,6 +132,8 @@
AdjustEyeBlur(effect)
if(DROWSY)
drowsyness = POSITIVE(drowsyness + effect)
if(ROOT)
AdjustRoot(effect)
updatehealth()
return TRUE

Expand Down Expand Up @@ -160,15 +164,26 @@
SetEyeBlur(effect)
if(DROWSY)
drowsyness = POSITIVE(effect)
if(ROOT)
SetRoot(effect)
updatehealth()
return TRUE

/mob/living/proc/apply_effects(stun = 0, weaken = 0, paralyze = 0, irradiate = 0, stutter = 0, eyeblur = 0, drowsy = 0, agony = 0)
if(stun) apply_effect(stun, STUN)
if(weaken) apply_effect(weaken, WEAKEN)
if(paralyze) apply_effect(paralyze, PARALYZE)
if(stutter) apply_effect(stutter, STUTTER)
if(eyeblur) apply_effect(eyeblur, EYE_BLUR)
if(drowsy) apply_effect(drowsy, DROWSY)
if(agony) apply_effect(agony, AGONY)
/mob/living/proc/apply_effects(stun = 0, weaken = 0, paralyze = 0, irradiate = 0, stutter = 0, eyeblur = 0, drowsy = 0, agony = 0, root = 0)
if(stun)
apply_effect(stun, STUN)
if(weaken)
apply_effect(weaken, WEAKEN)
if(paralyze)
apply_effect(paralyze, PARALYZE)
if(stutter)
apply_effect(stutter, STUTTER)
if(eyeblur)
apply_effect(eyeblur, EYE_BLUR)
if(drowsy)
apply_effect(drowsy, DROWSY)
if(agony)
apply_effect(agony, AGONY)
if(root)
apply_effect(root, ROOT)
return 1
51 changes: 51 additions & 0 deletions code/modules/mob/living/living_health_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,57 @@
S = apply_status_effect(/datum/status_effect/incapacitating/stun, amount)
return S

/* ROOT (Immobilisation) */
/// Overridable handler to adjust the numerical value of status effects. Expand as needed
/mob/living/proc/GetRootDuration(amount)
return amount * GLOBAL_STATUS_MULTIPLIER

/mob/living/proc/IsRoot() //If we're stunned
return has_status_effect(/datum/status_effect/incapacitating/immobilized)

/mob/living/proc/AmountRoot() //How much time remain in our stun - scaled by GLOBAL_STATUS_MULTIPLIER (normally in multiples of legacy 2 seconds)
var/datum/status_effect/incapacitating/immobilized/root = IsRoot()
if(root)
return root.get_duration_left() / GLOBAL_STATUS_MULTIPLIER
return FALSE

/mob/living/proc/Root(amount)
if(!(status_flags & CANROOT))
return
amount = GetRootDuration(amount)
var/datum/status_effect/incapacitating/immobilized/root = IsRoot()
if(root)
root.update_duration(amount, increment = TRUE)
else if(amount > 0)
root = apply_status_effect(/datum/status_effect/incapacitating/immobilized, amount)
return root

/mob/living/proc/SetRoot(amount) //Sets remaining duration
if(!(status_flags & CANROOT))
return
amount = GetRootDuration(amount)
var/datum/status_effect/incapacitating/immobilized/root = IsRoot()
if(amount <= 0)
if(root)
qdel(root)
else
if(root)
root.update_duration(amount)
else
root = apply_status_effect(/datum/status_effect/incapacitating/immobilized, amount)
return root

/mob/living/proc/AdjustRoot(amount) //Adds to remaining duration
if(!(status_flags & CANROOT))
return
amount = GetRootDuration(amount)
var/datum/status_effect/incapacitating/immobilized/root = IsRoot()
if(root)
root.adjust_duration(amount)
else if(amount > 0)
root = apply_status_effect(/datum/status_effect/incapacitating/immobilized, amount)
return root

/* DAZE (Light incapacitation) */
/// Overridable handler to adjust the numerical value of status effects. Expand as needed
/mob/living/proc/GetDazeDuration(amount)
Expand Down

0 comments on commit 0a17439

Please sign in to comment.