Skip to content

Commit

Permalink
refactor: Upgrade vomit from life cycle to debuff (#5931)
Browse files Browse the repository at this point in the history
* mrrow meow meow

* del useless coms

* dme

* wrong file again

* inconsistent

* again defines

* попытка передислокации nr1

* ok relocate all defines

* that needs mor improve

* logics

* smol upd

* op op fix fix fix

* normal process

* рубрика эксперименты

* рубрика эксперименты подходит к концу

* ladno

* fix it. Again

* improve.

* some improve

* final

* oczepyatka

* now this is final

* improve

* final

* false to seconds

* merge conflict

* fix inconsistent after merge roflcat

* ladno

* Better logic + "unvomitable nutriment".

* ahem

* A-a-a-a-a-and Done.

---------

Co-authored-by: Daeberdir <[email protected]>
  • Loading branch information
Antoonij and Daeberdir authored Oct 8, 2024
1 parent 44e06a1 commit bde24da
Show file tree
Hide file tree
Showing 17 changed files with 143 additions and 73 deletions.
11 changes: 11 additions & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,14 @@
/// Makes the weaken into a knockdown
#define SHOCK_KNOCKDOWN (1<<7)

/// Vomit defines
#define VOMIT_NUTRITION_LOSS 10
#define VOMIT_STUN_TIME (8 SECONDS)
#define VOMIT_DISTANCE 1
#define VOMIT_SAFE_NUTRITION 90
/// Vomit modes
#define VOMIT_BLOOD (1<<0)

/// When reached - we'll apply status effect which will force carbon to vomit
#define TOX_VOMIT_THRESHOLD_REACHED(mob, toxloss) (mob.getToxLoss() >= toxloss)
#define TOX_VOMIT_REQUIRED_TOXLOSS 45
2 changes: 2 additions & 0 deletions code/__DEFINES/status_effects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@

#define STATUS_EFFECT_DASH /datum/status_effect/dash // Grants the ability to dash, expiring after a few seconds

#define STATUS_EFFECT_VOMIT /datum/status_effect/tox_vomit // When carbon got enough tox damage - he will vomit.

//#define STATUS_EFFECT_NECROPOLIS_CURSE /datum/status_effect/necropolis_curse
//#define CURSE_BLINDING 1 //makes the edges of the target's screen obscured
//#define CURSE_SPAWNING 2 //spawns creatures that attack the target only
Expand Down
12 changes: 6 additions & 6 deletions code/datums/components/eatable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// integrity spend after bite
var/integrity_bite // integrity spend after bite
/// How much nutrition add
var/nutritional_value
var/nutritional_value
/// Grab if help_intent was used
var/is_only_grab_intent
/// If true - your item can be eaten without special diet check.
Expand All @@ -29,7 +29,7 @@
)
if(!isitem(parent))
return COMPONENT_INCOMPATIBLE

src.current_bites = current_bites
src.material_type = material_type
src.max_bites = max_bites
Expand All @@ -38,7 +38,7 @@
src.is_only_grab_intent = is_only_grab_intent
src.is_always_eatable = is_always_eatable
src.stack_use = stack_use

/datum/component/eatable/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_PRE_ATTACKBY, PROC_REF(pre_try_eat_item))
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, PROC_REF(on_examine))
Expand All @@ -53,7 +53,7 @@

if(!istype(human))
return

if(material_type & human.dna.species.special_diet)
examine_list += "Вкуснятина! [is_only_grab_intent ? "\nНужно аккуратно есть." : ""]"

Expand Down Expand Up @@ -134,7 +134,7 @@

to_chat(target, span_notice("[chat_message_to_target]"))
add_attack_logs(user, item, "Force Fed [target], item [item]")

if(!isstack(item))
to_chat(user, span_notice("[chat_message_to_user]"))

Expand Down Expand Up @@ -170,7 +170,7 @@
item.visible_message(span_warning("[user] пытается накормить [target], запихивая в рот [item.name]."))
if(!do_after(user, target, 2 SECONDS, NONE))
return FALSE

return TRUE

/datum/component/eatable/proc/get_colour()
Expand Down
4 changes: 2 additions & 2 deletions code/datums/diseases/viruses/advance/symptoms/vomit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Bonus
severity = 5

/datum/symptom/vomit/blood/Vomit(mob/living/carbon/M)
M.vomit(0, 1)
M.vomit(0, VOMIT_BLOOD)


/*
Expand Down Expand Up @@ -106,4 +106,4 @@ Bonus
level = 4

/datum/symptom/vomit/projectile/Vomit(mob/living/carbon/M)
M.vomit(6,0,8 SECONDS,5,1)
M.vomit(6, distance = 5)
32 changes: 31 additions & 1 deletion code/datums/status_effects/debuffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@
if(prob(pukeprob))
carbon.AdjustConfused(9 SECONDS)
carbon.AdjustStuttering(3 SECONDS)
carbon.vomit(15, FALSE, 8 SECONDS, 0, FALSE)
carbon.vomit(15, message = FALSE)
carbon.Dizzy(15 SECONDS)
if(strength >= DISGUST_LEVEL_DISGUSTED)
if(prob(25))
Expand Down Expand Up @@ -1227,3 +1227,33 @@
if(new_filter)
animate(get_filter("ray"), offset = 10, time = 10 SECONDS, loop = -1)
animate(offset = 0, time = 10 SECONDS)

/datum/status_effect/tox_vomit
id = "vomitting_from_toxins"
alert_type = null
processing_speed = STATUS_EFFECT_NORMAL_PROCESS
tick_interval = 2 SECONDS
var/puke_counter = 0

/datum/status_effect/tox_vomit/on_apply()
if(!iscarbon(owner))
return FALSE

return TRUE

/datum/status_effect/tox_vomit/tick(seconds_between_ticks)
if(owner.stat == DEAD || !TOX_VOMIT_THRESHOLD_REACHED(owner, TOX_VOMIT_REQUIRED_TOXLOSS) || HAS_TRAIT(owner, TRAIT_GODMODE))
qdel(src)
return

puke_counter++
if(puke_counter < 25)
return

var/mob/living/carbon/carbon = owner
puke_counter = initial(puke_counter)

if(!carbon.vomit())
return

carbon.adjustToxLoss(-3)
2 changes: 1 addition & 1 deletion code/game/gamemodes/shadowling/shadowling_abilities.dm
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@

var/mob/living/carbon/human/target = targets[1]

target.vomit(lost_nutrition = 0, blood = TRUE, stun = 8 SECONDS, distance = 1, message = FALSE)
target.vomit(0, VOMIT_BLOOD, distance = 2, message = FALSE)
playsound(user.loc, 'sound/hallucinations/veryfar_noise.ogg', 50, TRUE)
to_chat(user, "<span class='shadowling'>You instantly rearrange <b>[target]</b>'s memories, hyptonitizing [target.p_them()] into a thrall.</span>")
to_chat(target, "<span class='userdanger'><font size=3>An agonizing spike of pain drives into your mind, and--</font></span>")
Expand Down
3 changes: 2 additions & 1 deletion code/modules/antagonists/changeling/powers/panacea.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
borer.leave_host()
if(iscarbon(user))
var/mob/living/carbon/c_user = user
c_user.vomit(FALSE)
c_user.fakevomit()
c_user.Stun(VOMIT_STUN_TIME)

if(iscarbon(user))
var/mob/living/carbon/c_user = user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@

var/obj/item/thing = organ_to_dissect.remove(target)
qdel(thing)
target.vomit(50, TRUE, FALSE)
target.vomit(50, VOMIT_BLOOD, 0 SECONDS)
if(target.has_pain())
target.emote("scream")

Expand Down Expand Up @@ -688,7 +688,7 @@

if(iscarbon(victim))
var/mob/living/carbon/c_victim = victim
c_victim.vomit(50, TRUE, FALSE)
c_victim.vomit(50, VOMIT_BLOOD, 0 SECONDS)

if(prob(10 + vampire.get_trophies(INTERNAL_ORGAN_LIVER) * 3))
new /obj/effect/temp_visual/cult/sparks(get_turf(victim))
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mining/equipment/regenerative_core.dm
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
if(prob(2))
SEND_SOUND(owner, sound(pick(spooky_sounds)))
if(prob(3))
owner.vomit(0, 1)
owner.vomit(0, VOMIT_BLOOD)
if(prob(50))
var/mob/living/simple_animal/hostile/asteroid/hivelordbrood/legion/child = new(owner.loc)
child.faction = owner.faction.Copy()
Expand Down
83 changes: 55 additions & 28 deletions code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,43 +74,70 @@
return FALSE


/mob/living/carbon/proc/vomit(lost_nutrition = 10, blood = 0, stun = 8 SECONDS, distance = 0, message = 1)
if(ismachineperson(src)) //IPCs do not vomit particulates
/mob/living/carbon/proc/vomit(
lost_nutrition = VOMIT_NUTRITION_LOSS,
mode = NONE,
stun = VOMIT_STUN_TIME,
distance = VOMIT_DISTANCE,
message = TRUE
)
if(ismachineperson(src)) // IPCs do not vomit particulates.
return FALSE

if(is_muzzled())
if(message)
to_chat(src, "<span class='warning'>Намордник препятствует рвоте!</span>")
to_chat(src, span_warning("Намордник препятствует рвоте!"))

return FALSE

if(stun)
Stun(stun)
if(nutrition < 100 && !blood)

if((nutrition - VOMIT_SAFE_NUTRITION) < lost_nutrition && (!(mode & VOMIT_BLOOD)))
if(message)
visible_message("<span class='warning'>[src.name] сухо кашля[pluralize_ru(src.gender,"ет","ют")]!</span>", \
"<span class='userdanger'>Вы пытаетесь проблеваться, но в вашем желудке пусто!</span>")
visible_message(span_warning("[name] сухо кашля[pluralize_ru(gender,"ет","ют")]!"), \
span_userdanger("Вы пытаетесь проблеваться, но в вашем желудке пусто!"))

if(stun)
Weaken(stun * 2.5)
else
if(message)
visible_message("<span class='danger'>[src.name] блю[pluralize_ru(src.gender,"ет","ют")]!</span>", \
"<span class='userdanger'>Вас вырвало!</span>")
playsound(get_turf(src), 'sound/effects/splat.ogg', 50, 1)
var/turf/T = get_turf(src)
for(var/i=0 to distance)
if(blood)
if(T)
add_splatter_floor(T)
if(stun)
adjustBruteLoss(3)
else
if(T)
T.add_vomit_floor()
adjust_nutrition(-lost_nutrition)
if(stun)
adjustToxLoss(-3)
T = get_step(T, dir)
if(T.is_blocked_turf())
break
return TRUE

return FALSE

if(message)
visible_message(span_danger("[name] блю[pluralize_ru(gender,"ет","ют")]!"), \
span_userdanger("Вас вырвало!"))

playsound(get_turf(src), 'sound/effects/splat.ogg', 50, TRUE)
var/turf/turf = get_turf(src)

if(!turf)
return FALSE

var/max_nutriment_vomit_dist = 0
if(lost_nutrition)
max_nutriment_vomit_dist = floor((nutrition - VOMIT_SAFE_NUTRITION) / lost_nutrition)

for(var/i = 1 to distance)
if(max_nutriment_vomit_dist >= i)
turf.add_vomit_floor()
adjust_nutrition(-lost_nutrition)

if(stun)
adjustToxLoss(-3)

if(mode & VOMIT_BLOOD)
add_splatter_floor(turf)

if(stun)
adjustBruteLoss(3)

turf = get_step(turf, dir)

if(turf.is_blocked_turf())
break

return FALSE


/mob/living/carbon/gib()
. = death(TRUE)
Expand Down
27 changes: 23 additions & 4 deletions code/modules/mob/living/carbon/human/human_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,30 @@
used_weapon = null,
)
. = ..()
if(. && amount > 0 && mind)
for(var/datum/objective/pain_hunter/objective in GLOB.all_objectives)
if(mind == objective.target)
objective.take_damage(amount, TOX)
if(. == STATUS_UPDATE_NONE)
return .

if(TOX_VOMIT_THRESHOLD_REACHED(src, TOX_VOMIT_REQUIRED_TOXLOSS))
apply_status_effect(STATUS_EFFECT_VOMIT)

if(!mind)
return .

for(var/datum/objective/pain_hunter/objective in GLOB.all_objectives)
if(mind == objective.target)
objective.take_damage(amount, TOX)

return .

/mob/living/carbon/human/setToxLoss(amount, updating_health = TRUE)
. = ..()
if(. == STATUS_UPDATE_NONE)
return .

if(TOX_VOMIT_THRESHOLD_REACHED(src, TOX_VOMIT_REQUIRED_TOXLOSS))
apply_status_effect(STATUS_EFFECT_VOMIT)

return .

////////////////////////////////////////////

Expand Down
12 changes: 0 additions & 12 deletions code/modules/mob/living/carbon/human/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -857,18 +857,6 @@
throw_alert(ALERT_NUTRITION, text2path("/atom/movable/screen/alert/hunger/[new_hunger]"), icon_override = dna.species.hunger_icon)
med_hud_set_status()


/mob/living/carbon/human/handle_random_events()
// Puke if toxloss is too high
if(!stat)
if(getToxLoss() >= 45 && nutrition > 20)
lastpuke ++
if(lastpuke >= 25) // about 25 second delay I guess
vomit(20, 0, 8 SECONDS, 0, 1)
adjustToxLoss(-3)
lastpuke = 0


/mob/living/carbon/human/proc/handle_embedded_objects()
for(var/obj/item/organ/external/bodypart as anything in bodyparts)
for(var/obj/item/thing in bodypart.embedded_objects)
Expand Down
7 changes: 0 additions & 7 deletions code/modules/mob/living/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
//Breathing, if applicable
handle_breathing(times_fired)

if(stat != DEAD)
//Random events (vomiting etc)
handle_random_events()

if(LAZYLEN(diseases))
handle_diseases()

Expand Down Expand Up @@ -116,9 +112,6 @@
var/datum/disease/D = thing
D.stage_act()

/mob/living/proc/handle_random_events()
return

/mob/living/proc/handle_environment(datum/gas_mixture/environment)
return

Expand Down
1 change: 0 additions & 1 deletion code/modules/mob/mob_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
var/sec_record = ""
var/gen_record = ""
var/exploit_record = ""
var/lastpuke = 0
/// For speaking/listening.
var/list/languages
/// For reagents that grant language knowlege.
Expand Down
8 changes: 4 additions & 4 deletions code/modules/reagents/chemistry/reagents/medicine.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1051,20 +1051,20 @@
var/update_flags = overdose_info[REAGENT_OVERDOSE_FLAGS]
if(severity == 1)
if(effect <= 2)
M.vomit(0, TRUE, FALSE)
M.vomit(0, VOMIT_BLOOD, 0 SECONDS)
M.blood_volume = max(M.blood_volume - rand(5, 10), 0)
else if(effect <= 4)
M.vomit(0, TRUE, FALSE)
M.vomit(0, VOMIT_BLOOD, 0 SECONDS)
M.blood_volume = max(M.blood_volume - rand(1, 2), 0)
else if(severity == 2)
if(effect <= 2)
M.visible_message("<span class='warning'>[M] is bleeding from [M.p_their()] very pores!</span>")
M.bleed(rand(10, 20))
else if(effect <= 4)
M.vomit(0, TRUE, FALSE)
M.vomit(0, VOMIT_BLOOD, 0 SECONDS)
M.blood_volume = max(M.blood_volume - rand(5, 10), 0)
else if(effect <= 8)
M.vomit(0, TRUE, FALSE)
M.vomit(0, VOMIT_BLOOD, 0 SECONDS)
M.blood_volume = max(M.blood_volume - rand(1, 2), 0)
return list(effect, update_flags)

Expand Down
Loading

0 comments on commit bde24da

Please sign in to comment.