Skip to content

Commit

Permalink
add static vars
Browse files Browse the repository at this point in the history
  • Loading branch information
LiquidPotroh committed Dec 6, 2023
1 parent 319e342 commit 98d7460
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
21 changes: 10 additions & 11 deletions code/datums/spells/alien_spells/evolve.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
return

if(queen_check)
if(GLOB.alien_queens_count >= GLOB.alien_queens_maximum)
to_chat(user, "<span class='notice'>We already have a queen.</span>")
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, "<span class='noticealien'>You begin to evolve!</span>")
user.visible_message("<span class='alertalien'>[user] begins to twist and contort!</span>")
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
Expand All @@ -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."))
Expand Down
13 changes: 12 additions & 1 deletion code/modules/events/alien_infestation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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

Expand All @@ -53,13 +58,19 @@ 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)
if(C)
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

Expand Down
3 changes: 3 additions & 0 deletions code/modules/mob/living/carbon/alien/alien.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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

Expand Down

0 comments on commit 98d7460

Please sign in to comment.