Skip to content

Commit

Permalink
[MIRROR] Limit and update confusion updating logic
Browse files Browse the repository at this point in the history
  • Loading branch information
SierraKomodo authored and SuhEugene committed Oct 10, 2023
1 parent aada9d8 commit 9b58222
Show file tree
Hide file tree
Showing 41 changed files with 132 additions and 77 deletions.
3 changes: 3 additions & 0 deletions code/__defines/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,6 @@
#define PRONOUNS_SHE_THEY "she/they"

#define PRONOUNS_ALL list(PRONOUNS_THEY_THEM, PRONOUNS_HE_HIM, PRONOUNS_SHE_HER, PRONOUNS_HE_THEY, PRONOUNS_SHE_THEY, PRONOUNS_IT_ITS)

/// Integer (~ticks * SSMobs/wait fire rate). The default maximum value a mob's confused var can be set to.
#define CONFUSED_MAX 15
2 changes: 1 addition & 1 deletion code/datums/movement/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@

/mob/proc/AdjustMovementDirection(direction)
. = direction
if(!confused)
if(!is_confused())
return

var/stability = MOVING_DELIBERATELY(src) ? 75 : 25
Expand Down
3 changes: 1 addition & 2 deletions code/game/gamemodes/endgame/bluespace_jump/bluespace_jump.dm
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,14 @@
if(M.client)
to_chat(M,SPAN_NOTICE("You feel oddly light, and somewhat disoriented as everything around you shimmers and warps ever so slightly."))
M.overlay_fullscreen("bluespace", /obj/screen/fullscreen/bluespace_overlay)
M.confused = 20
M.set_confused(20)
bluegoasts += new/obj/effect/bluegoast/(get_turf(M),M)


/datum/universal_state/bluespace_jump/proc/clear_bluespaced(mob/living/M)
if(M.client)
to_chat(M,SPAN_NOTICE("You feel rooted in material world again."))
M.clear_fullscreen("bluespace")
M.confused = 0
for(var/mob/goast in GLOB.ghost_mobs)
goast.mouse_opacity = initial(goast.mouse_opacity)
goast.set_invisibility(initial(goast.invisibility))
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/bluespace_drive.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
to_chat(living, SPAN_DANGER(FONT_LARGE("The Drive's field cracks open briefly, emitting a blinding flash of blue light and a deafenening screech!")))
living.flash_eyes(FLASH_PROTECTION_MAJOR)
living.Stun(3)
living.confused += 15
living.mod_confused(15)
living.ear_damage += rand(0, 5)
living.ear_deaf = max(living.ear_deaf, 15)
if (!change_turf)
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/flasher.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
/obj/machinery/flasher/proc/do_flash(mob/living/victim, flash_time)
victim.flash_eyes()
victim.eye_blurry += flash_time
victim.confused += (flash_time + 2)
victim.mod_confused(flash_time + 2)
victim.Stun(flash_time / 2)
victim.Weaken(3)

Expand Down
6 changes: 3 additions & 3 deletions code/game/objects/items/devices/flash.dm
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
M.flash_eyes(FLASH_PROTECTION_MODERATE - safety)
M.Stun(flash_strength / 2)
M.eye_blurry = max(M.eye_blurry, flash_strength)
M.confused = max(M.confused, (flash_strength + 2))
M.set_confused(flash_strength + 2)
if(flash_strength > 3)
M.drop_l_hand()
M.drop_r_hand()
Expand All @@ -130,11 +130,11 @@
var/mob/living/simple_animal/SA = M
var/safety = SA.eyecheck()
if(safety < FLASH_PROTECTION_MAJOR)
SA.confused = max(SA.confused, (flash_strength * 0.5))
SA.set_confused(flash_strength * 0.5)
if(safety < FLASH_PROTECTION_MODERATE)
SA.flash_eyes(2)
SA.eye_blurry = max(SA.eye_blurry, flash_strength)
SA.confused = max(SA.confused, (flash_strength))
SA.set_confused(flash_strength)
else
return TRUE

Expand Down
10 changes: 5 additions & 5 deletions code/game/objects/items/weapons/grenades/flashbang.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@
M.flash_eyes(FLASH_PROTECTION_MODERATE)
if(eye_safety < FLASH_PROTECTION_MODERATE)
M.Stun(2)
M.confused += 5
M.mod_confused(5)

//Now applying sound
if(ear_safety)
if(ear_safety < 2 && get_dist(M, T) <= 2)
M.Stun(1)
M.confused += 3
M.mod_confused(3)

else if(get_dist(M, T) <= 2)
M.Stun(3)
M.confused += 8
M.mod_confused(8)
M.ear_damage += rand(0, 5)
M.ear_deaf = max(M.ear_deaf,15)

else if(get_dist(M, T) <= 5)
M.Stun(2)
M.confused += 5
M.mod_confused(5)
M.ear_damage += rand(0, 3)
M.ear_deaf = max(M.ear_deaf,10)

else
M.Stun(1)
M.confused += 3
M.mod_confused(3)
M.ear_damage += rand(0, 1)
M.ear_deaf = max(M.ear_deaf,5)

Expand Down
2 changes: 1 addition & 1 deletion code/game/sound.dm
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ var/global/const/FALLOFF_SOUNDS = 0.5
S.environment = DRUGGED
else if (M.drowsyness)
S.environment = DIZZY
else if (M.confused)
else if (M.is_confused())
S.environment = DIZZY
else if (M.stat == UNCONSCIOUS)
S.environment = UNDERWATER
Expand Down
2 changes: 1 addition & 1 deletion code/modules/ai/ai_holder_disabled.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
return FALSE

/datum/ai_holder/proc/is_confused()
return holder.confused > 0 && respect_confusion
return holder.is_confused() && respect_confusion

// Called by the main loop.
/datum/ai_holder/proc/handle_disabled()
Expand Down
4 changes: 2 additions & 2 deletions code/modules/augment/active/nerve_dampeners.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
if (!ticks_remaining) // ...but comes at a price. Brief short term benefit for a long-term comedown
to_chat(owner, SPAN_WARNING("You abruptly feel intensely exhausted as sensation returns."))
owner.drowsyness = max(owner.drowsyness, 15)
owner.confused = max(owner.confused, 15)
owner.set_confused(15)
owner.slurring = max(owner.slurring, 30)
owner.chem_effects[CE_PAINKILLER] = 0
owner.stamina = 0
if(MOVING_QUICKLY(owner))
owner.set_moving_slowly()

/obj/item/organ/internal/augment/active/nerve_dampeners/hidden
augment_flags = AUGMENT_BIOLOGICAL
augment_flags = AUGMENT_BIOLOGICAL
2 changes: 1 addition & 1 deletion code/modules/events/ion_storm.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
continue
to_chat(S, SPAN_WARNING("Your integrated sensors detect an ionospheric anomaly. Your systems will be impacted as you begin a partial restart."))
var/ionbug = rand(5, 15)
S.confused += ionbug
S.mod_confused(ionbug)
S.eye_blurry += ionbug-1
for(var/mob/living/silicon/S in SSmobs.mob_list)
if(isdrone(S) || !(isAI(S) || isrobot(S)))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/genetics/side_effects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@

/datum/genetics/side_effect/confuse/finish(mob/living/carbon/human/H)
if(!H.reagents.has_reagent(/datum/reagent/dylovene))
H.confused += 100
H.set_confused(CONFUSED_MAX)
4 changes: 2 additions & 2 deletions code/modules/mechs/equipment/combat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@
if(!O.blinded)
O.flash_eyes(FLASH_PROTECTION_MODERATE - protection)
O.eye_blurry += flash_time
O.confused += (flash_time + 2)
O.mod_confused(flash_time + 2)

/obj/item/mech_equipment/flash/attack_self(mob/user)
. = ..()
Expand Down Expand Up @@ -519,7 +519,7 @@
if(!O.blinded)
O.flash_eyes(FLASH_PROTECTION_MAJOR - protection)
O.eye_blurry += flash_time
O.confused += (flash_time + 2)
O.mod_confused(flash_time + 2)

if(isanimal(O)) //Hit animals a bit harder
O.Stun(flash_time)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/grab/grab_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@

if(affecting.incapacitated(INCAPACITATION_ALL))
break_strength--
if(affecting.confused)
if(affecting.is_confused())
break_strength--
if(affecting.eye_blind)
break_strength--
Expand All @@ -303,7 +303,7 @@
if(shock >= 50)
break_strength--

if(assailant.confused)
if(assailant.is_confused())
break_strength++
if(assailant.eye_blind)
break_strength++
Expand Down
8 changes: 4 additions & 4 deletions code/modules/mob/living/carbon/xenobiological/slime_AI.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
attacked = 50 // Let's not get into absurdly long periods of rage
--attacked

if(confused > 0)
--confused
handle_confused()
if (is_confused())
return

if(nutrition < get_starve_nutrition()) // If a slime is starving, it starts losing its friends
Expand Down Expand Up @@ -113,7 +113,7 @@
AIproc = 0
return // If we're dead or have a client, we don't need AI, if we're feeding, we continue feeding

if(confused)
if(is_confused())
AIproc = 0
return

Expand Down Expand Up @@ -185,7 +185,7 @@
/mob/living/carbon/slime/proc/UpdateFace()
var/newmood = ""
a_intent = I_HELP
if(confused)
if(is_confused())
newmood = "pout"
else if(rabid || attacked)
newmood = "angry"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
visible_message(SPAN_WARNING("\The [M] manages to wrestle \the [src] off!"))
playsound(loc, 'sound/weapons/thudswoosh.ogg', 50, 1, -1)

confused = max(confused, 2)
set_confused(2)
Feedstop()
UpdateFace()
step_away(src, M)
Expand All @@ -250,7 +250,7 @@
visible_message(SPAN_WARNING("\The [M] manages to wrestle \the [src] off \the [Victim]!"))
playsound(loc, 'sound/weapons/thudswoosh.ogg', 50, 1, -1)

confused = max(confused, 2)
set_confused(2)
Feedstop()
UpdateFace()
step_away(src, M)
Expand All @@ -265,7 +265,7 @@
var/success = prob(40)
visible_message(SPAN_WARNING("\The [M] pushes \the [src]![success ? " \The [src] looks momentarily disoriented!" : ""]"))
if(success)
confused = max(confused, 2)
set_confused(2)
UpdateFace()
playsound(loc, 'sound/weapons/thudswoosh.ogg', 50, 1, -1)
else
Expand Down
3 changes: 1 addition & 2 deletions code/modules/mob/living/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@
handle_impaired_hearing()

/mob/living/proc/handle_confused()
if(confused)
confused = max(0, confused - 1)
confused--
return confused

/mob/living/proc/handle_impaired_vision()
Expand Down
8 changes: 4 additions & 4 deletions code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ default behaviour is:
spawn(0)
..()
var/saved_dir = AM.dir
if ((confused || (MUTATION_CLUMSY in mutations)) && !MOVING_DELIBERATELY(src))
if ((is_confused() || (MUTATION_CLUMSY in mutations)) && !MOVING_DELIBERATELY(src))
AM.slam_into(src)
if (!istype(AM, /atom/movable) || AM.anchored)
return
Expand Down Expand Up @@ -455,7 +455,7 @@ default behaviour is:
drowsyness = 0
druggy = 0
jitteriness = 0
confused = 0
clear_confused()

heal_overall_damage(getBruteLoss(), getFireLoss())

Expand Down Expand Up @@ -845,7 +845,7 @@ default behaviour is:
. = 0
if(incapacitated(INCAPACITATION_UNRESISTING))
. += 100
if(confused)
if(is_confused())
. += 10
if(weakened)
. += 15
Expand All @@ -860,7 +860,7 @@ default behaviour is:
. = 0
if(jitteriness)
. -= 2
if(confused)
if(is_confused())
. -= 2
if(eye_blind)
. -= 5
Expand Down
5 changes: 3 additions & 2 deletions code/modules/mob/living/silicon/silicon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@
if(EMP_ACT_HEAVY)
take_organ_damage(0, 16, ORGAN_DAMAGE_SILICON_EMP)
if(prob(50)) Stun(rand(5,10))
else confused = (min(confused + 2, 40))
else
mod_confused(2, 40)
if(EMP_ACT_LIGHT)
take_organ_damage(0, 7, ORGAN_DAMAGE_SILICON_EMP)
confused = (min(confused + 2, 30))
mod_confused(2, 30)
flash_eyes(affect_silicon = 1)
to_chat(src, SPAN_DANGER("<B>*BZZZT*</B>"))
to_chat(src, SPAN_DANGER("Warning: Electromagnetic pulse detected."))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
var/mob/living/L = target
if(prob(G.stun_chance))
L.Weaken(0.5)
L.confused += 1
L.mod_confused(1)
G.visible_message(SPAN_WARNING("\The [L] is bowled over by the impact of [G]'s attack!"))

/datum/ai_holder/simple_animal/goat/king/react_to_attack(atom/movable/attacker)
Expand Down
53 changes: 53 additions & 0 deletions code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,59 @@
sleeping = max(sleeping + amount,0)
return


/**
* Sets a mob's confused value.
*
* Parameters:
* - `amount` (Positive Int) - The confused value to set. Decimal values are rounded.
* - `limit` (Positive Int, default `CONFUSED_MAX`) - The maximum value `confused` can be set to. Decimal values are rounded.
*
* Returns integer. The new value of `confused`.
*/
/mob/proc/set_confused(amount, limit = CONFUSED_MAX)
confused = clamp(round(amount), 0, round(limit))
return confused


/**
* Modifies a mob's confused value by `mod_amount`.
*
* Parameters:
* - `mod_amount` (Integer) - The amount to modify `confused` by. Allows negative values for subtraction. Decimal values are rounded.
* - `floor` (Positive Integer, default `0`) - The minimum value to set `confused` to. Decimal values are rounded.
* - `ceiling` (Positive Integer, default `CONFUSED_MAX`) - The maximum value to set `confused` to. Decimal values are rounded.
*
* Returns integer. The new value of `confused`.
*/
/mob/proc/mod_confused(mod_amount, floor = 0, ceiling = CONFUSED_MAX)
confused += round(mod_amount)
confused = clamp(confused, round(floor), round(ceiling))
return confused


/**
* Sets a mob's confused value to `0`.
*
* Returns integer. The new value of `confused`.
*/
/mob/proc/clear_confused()
confused = 0
return confused


/**
* Whether or not the mob's confusion level is at the threshhold.
*
* Parameters:
* - `threshhold` (Positive Integer, default `1`) - The threshhold at which the mob should be considered confused.
*
* Returns boolean.
*/
/mob/proc/is_confused(threshhold = 1)
return confused >= threshhold


/mob/proc/get_species()
return ""

Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@
var/bhunger = 0 //Carbon

var/druggy = 0 //Carbon
var/confused = 0 //Carbon
/// Positive Integer. The mob's current confusion level. Ticks down every `Fire()` in SSMobs. See `set_confused()`, `mod_confused()`, `clear_confused()`, and `is_confused()`.
VAR_PRIVATE/confused = 0
var/sleeping = 0 //Carbon
var/resting = FALSE //Carbon
var/lying = 0
Expand Down
2 changes: 1 addition & 1 deletion code/modules/organs/external/_external.dm
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@

if(owner && BP_IS_CRYSTAL(src)) // Crystalline robotics == piezoelectrics.
owner.Weaken(4 - severity)
owner.confused = max(owner.confused, 6 - (severity * 2))
owner.set_confused(6 - (severity * 2))
return

var/burn_damage = 0
Expand Down
Loading

0 comments on commit 9b58222

Please sign in to comment.