From 98d74609ac2e08f30e33933de4263924ed27f91d Mon Sep 17 00:00:00 2001 From: LiquidPotroh Date: Thu, 7 Dec 2023 02:19:51 +0300 Subject: [PATCH] add static vars --- code/datums/spells/alien_spells/evolve.dm | 21 +++++++++---------- code/modules/events/alien_infestation.dm | 13 +++++++++++- code/modules/mob/living/carbon/alien/alien.dm | 3 +++ .../carbon/alien/humanoid/caste/sentinel.dm | 7 +++++++ 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/code/datums/spells/alien_spells/evolve.dm b/code/datums/spells/alien_spells/evolve.dm index 91d3ed56b1c..e1bb39e386c 100644 --- a/code/datums/spells/alien_spells/evolve.dm +++ b/code/datums/spells/alien_spells/evolve.dm @@ -42,14 +42,14 @@ return if(queen_check) - if(GLOB.alien_queens_count >= GLOB.alien_queens_maximum) - to_chat(user, "We already have a queen.") + if(user.queen_count >= user.queen_maximum) + to_chat(user, span_warning("We already have a queen.")) return else - GLOB.alien_queens_count++ + user.queen_count++ - to_chat(user, "You begin to evolve!") - user.visible_message("[user] begins to twist and contort!") + to_chat(user, span_noticealien("You begin to evolve!")) + user.visible_message(span_alertalien("[user] begins to twist and contort!")) var/mob/living/carbon/alien/new_xeno = new evolution_path(user.loc) user.mind.transfer_to(new_xeno) new_xeno.mind.name = new_xeno.name @@ -58,17 +58,16 @@ qdel(user) /obj/effect/proc_holder/spell/alien_spell/evolve/praetorian/cast(list/targets, mob/living/carbon/user) - var/living_praetorians_count = 0 - var/living_players_count = 0 - for(var/mob/living/carbon/alien/humanoid/praetorian/praetorian in GLOB.alive_mob_list) - if(praetorian.client && praetorian.stat != DEAD) - living_praetorians_count++ + var/mob/living/carbon/alien/spell_owner = user + if(!istype(spell_owner)) + return + var/living_players_count = 0 for(var/mob/living/player in GLOB.player_list) if(player.client && player.stat != DEAD) living_players_count++ - if(living_praetorians_count < (1 + living_players_count/LIVING_PLAYERS_COUNT_FOR_1_PRAETORIAN)) + if(spell_owner.praetorian_count < (living_players_count/LIVING_PLAYERS_COUNT_FOR_1_PRAETORIAN)) ..() else to_chat(user, span_warning("We have too many praetorians.")) diff --git a/code/modules/events/alien_infestation.dm b/code/modules/events/alien_infestation.dm index b3c69667032..c47d6a55576 100644 --- a/code/modules/events/alien_infestation.dm +++ b/code/modules/events/alien_infestation.dm @@ -25,7 +25,6 @@ GLOBAL_VAR_INIT(alien_queens_maximum, 0) // It is necessary to wrap this to avoid the event triggering repeatedly. /datum/event/alien_infestation/proc/wrappedstart() - GLOB.alien_queens_maximum++ var/list/vents = get_valid_vent_spawns(exclude_mobs_nearby = TRUE, exclude_visible_by_mobs = TRUE) playercount = length(GLOB.clients)//grab playercount when event starts not when game starts if(playercount <= ALIEN_MIDPOP_TRIGGER) @@ -34,6 +33,7 @@ GLOBAL_VAR_INIT(alien_queens_maximum, 0) if(playercount >= ALIEN_HIGHPOP_TRIGGER) //spawn with 4 if highpop spawncount = 4 var/list/candidates = SSghost_spawns.poll_candidates("Вы хотите сыграть за Чужого?", ROLE_ALIEN, TRUE, source = /mob/living/carbon/alien/larva) + var/first_spawn = TRUE while(spawncount && length(vents) && length(candidates)) var/obj/vent = pick_n_take(vents) var/mob/C = pick_n_take(candidates) @@ -42,6 +42,11 @@ GLOBAL_VAR_INIT(alien_queens_maximum, 0) var/mob/living/carbon/alien/larva/new_xeno = new(vent.loc) new_xeno.evolution_points += (0.75 * new_xeno.max_evolution_points) //event spawned larva start off almost ready to evolve. new_xeno.key = C.key + + if(first_spawn) + new_xeno.queen_maximum++ + first_spawn = FALSE + if(SSticker && SSticker.mode) SSticker.mode.xenos += new_xeno.mind @@ -53,6 +58,7 @@ GLOBAL_VAR_INIT(alien_queens_maximum, 0) /datum/event/alien_infestation/proc/spawn_vectors(list/vents, playercount) spawncount = 1 var/list/candidates = SSghost_spawns.poll_candidates("Вы хотите сыграть за Чужого Вектора?", ROLE_ALIEN, TRUE, source = /mob/living/carbon/alien/humanoid/hunter/vector) + var/first_spawn = TRUE while(spawncount && length(vents) && length(candidates)) var/obj/vent = pick_n_take(vents) var/mob/C = pick_n_take(candidates) @@ -60,6 +66,11 @@ GLOBAL_VAR_INIT(alien_queens_maximum, 0) GLOB.respawnable_list -= C.client var/mob/living/carbon/alien/humanoid/hunter/vector/new_xeno = new(vent.loc) new_xeno.key = C.key + + if(first_spawn) + new_xeno.queen_maximum++ + first_spawn = FALSE + if(SSticker && SSticker.mode) SSticker.mode.xenos += new_xeno.mind diff --git a/code/modules/mob/living/carbon/alien/alien.dm b/code/modules/mob/living/carbon/alien/alien.dm index ffc46119e8a..af632c6221c 100644 --- a/code/modules/mob/living/carbon/alien/alien.dm +++ b/code/modules/mob/living/carbon/alien/alien.dm @@ -45,6 +45,9 @@ var/death_sound = 'sound/voice/hiss6.ogg' var/datum/action/innate/alien_nightvision_toggle/night_vision_action + var/static/praetorian_count = 0 + var/static/queen_count = 0 + var/static/queen_maximum = 0 /mob/living/carbon/alien/New() diff --git a/code/modules/mob/living/carbon/alien/humanoid/caste/sentinel.dm b/code/modules/mob/living/carbon/alien/humanoid/caste/sentinel.dm index af6615bd536..5357a941fa9 100644 --- a/code/modules/mob/living/carbon/alien/humanoid/caste/sentinel.dm +++ b/code/modules/mob/living/carbon/alien/humanoid/caste/sentinel.dm @@ -55,6 +55,7 @@ action_sprite.Grant(src) ..() AddSpell(new /obj/effect/proc_holder/spell/alien_spell/break_vents) + praetorian_count++ /mob/living/carbon/alien/humanoid/praetorian/Destroy() @@ -63,6 +64,12 @@ action_sprite = null return ..() +/mob/living/carbon/alien/humanoid/praetorian/death(gibbed) + // Only execute the below if we successfully died + . = ..(gibbed) + if(.) + praetorian_count-- + /mob/living/carbon/alien/humanoid/praetorian/is_strong() return TRUE