Skip to content

Commit

Permalink
changes spawner logic, merges regular and vet spawners
Browse files Browse the repository at this point in the history
  • Loading branch information
silencer-pl committed Sep 18, 2024
1 parent a3ca621 commit f9fa2be
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 355 deletions.
23 changes: 14 additions & 9 deletions code/_globalvars/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,32 @@ GLOBAL_VAR(obfs_y)
GLOBAL_VAR_INIT(ai_xeno_weeding, FALSE)

GLOBAL_VAR_INIT(xenosurge_spawner_limit, 30)

GLOBAL_VAR_INIT(xenosurge_surge_started, 0)
GLOBAL_VAR_INIT(xenosurge_wave_xenos_max, 100)
GLOBAL_VAR_INIT(xenosurge_wave_xenos_current, 0)
GLOBAL_VAR_INIT(xenosurge_wave_veteran_xenos_current, 0)
GLOBAL_VAR_INIT(xenosurge_veteran_xenos_max, 6)

GLOBAL_VAR_INIT(xenosurge_wave_xenos_hp_factor, 1)
GLOBAL_VAR_INIT(xenosurge_wave_xenos_dam_factor, 1)

GLOBAL_LIST_EMPTY(xenosurge_configured_spawners)
GLOBAL_VAR_INIT(xenosurge_wave_xenos_hp, 50)
GLOBAL_VAR_INIT(xenosurge_wave_xenos_armor, 0)
GLOBAL_VAR_INIT(xenosurge_wave_xenos_dam_min, 5)
GLOBAL_VAR_INIT(xenosurge_wave_xenos_dam_max, 7)

GLOBAL_VAR_INIT(xenosurge_spawner_xenos, 5)
GLOBAL_VAR_INIT(xenosurge_spawner_delay, 100)
GLOBAL_VAR_INIT(xenosurge_spawner_variance, 10)

GLOBAL_LIST_EMPTY(xenosurge_configured_veteran_spawners)
GLOBAL_VAR_INIT(xenosurge_veteran_spawner_xenos, 2)
GLOBAL_VAR_INIT(xenosurge_veteran_spawner_xenos_max, 2)
GLOBAL_VAR_INIT(xenosurge_veteran_spawner_delay, 200)
GLOBAL_VAR_INIT(xenosurge_veteran_spawner_variance, 100)
GLOBAL_VAR_INIT(xenosurge_veteran_xenos_hp_factor, 2)
GLOBAL_VAR_INIT(xenosurge_veteran_xenos_dam_factor, 0.5)

GLOBAL_LIST_EMPTY(xenosurge_configured_spawners)

GLOBAL_VAR_INIT(spawner_number, 1)
GLOBAL_VAR_INIT(veteran_spawner_number, 1)

GLOBAL_VAR_INIT(quest_items_number, 1)
GLOBAL_VAR_INIT(quest_items_number, 0)
GLOBAL_VAR_INIT(quest_items_found, 0)

GLOBAL_VAR_INIT(ammo_restock_next, 0)
Expand Down
297 changes: 105 additions & 192 deletions code/modules/admin/PvE/spawner_control.dm

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,11 @@ var/list/admin_verbs_minor_event = list(
/client/proc/admin_biohazard_alert,
/client/proc/toggle_hardcore_perma,
/client/proc/toggle_bypass_joe_restriction,
/client/proc/create_spawner_setup,
/client/proc/remove_spawners,
/client/proc/reinitialize_spawners,
/client/proc/setup_surge,
/client/proc/start_surge,
/client/proc/stop_surge,
/client/proc/surge_preset_hp,
/client/proc/surge_preset_waves,
/client/proc/set_narration_preset,
/client/proc/speak_to_comms,
/client/proc/call_tgui_play_directly,
Expand All @@ -157,6 +154,8 @@ var/list/admin_verbs_minor_event = list(
/client/proc/change_objective,
/client/proc/enable_full_restock,
/client/proc/admin_shutter_control,
/client/proc/surge_status,
/client/proc/setup_surge_globals,
)

var/list/admin_verbs_major_event = list(
Expand All @@ -179,9 +178,6 @@ var/list/admin_verbs_major_event = list(
/client/proc/change_weather,
/client/proc/admin_blurb,
/client/proc/create_surge_spawner,
/client/proc/create_veteran_spawner_setup,
/client/proc/veteran_setup,
/client/proc/create_veteran_surge_spawner,
)

var/list/admin_verbs_spawn = list(
Expand Down
9 changes: 5 additions & 4 deletions code/modules/admin/game_master/game_master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -352,10 +352,11 @@ GLOBAL_VAR_INIT(radio_communication_clarity, 100)

for(var/i = 1 to xeno_spawn_count)
var/mob/living/carbon/xenomorph/spawned_xeno = new spawning_xeno_type(spawn_turf, null, selected_hive, !spawn_ai)
spawned_xeno.health = ceil(spawned_xeno.health * GLOB.xenosurge_wave_xenos_hp_factor)
spawned_xeno.maxHealth = ceil(spawned_xeno.maxHealth * GLOB.xenosurge_wave_xenos_hp_factor)
spawned_xeno.melee_damage_lower = ceil(spawned_xeno.melee_damage_lower * GLOB.xenosurge_wave_xenos_dam_factor)
spawned_xeno.melee_damage_upper = ceil(spawned_xeno.melee_damage_upper * GLOB.xenosurge_wave_xenos_dam_factor)
spawned_xeno.health = GLOB.xenosurge_wave_xenos_hp
spawned_xeno.maxHealth = GLOB.xenosurge_wave_xenos_hp
spawned_xeno.melee_damage_lower = GLOB.xenosurge_wave_xenos_dam_min
spawned_xeno.melee_damage_upper = GLOB.xenosurge_wave_xenos_dam_max
spawned_xeno.armor_deflection = GLOB.xenosurge_wave_xenos_armor
return TRUE

if(BEHAVIOR_CLICK_INTERCEPT_ACTION)
Expand Down
9 changes: 5 additions & 4 deletions code/modules/admin/game_master/game_master_submenu/ambush.dm
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,11 @@
playsound(referenced_atom, pick(ambush_sounds), 25, 1)

var/mob/living/carbon/xenomorph/spawned_xeno = new xeno_type(spawn_turf, null, selected_hive)
spawned_xeno.health *= GLOB.xenosurge_wave_xenos_hp_factor
spawned_xeno.maxHealth *= GLOB.xenosurge_wave_xenos_hp_factor
spawned_xeno.melee_damage_lower = ceil(spawned_xeno.melee_damage_lower * GLOB.xenosurge_wave_xenos_dam_factor)
spawned_xeno.melee_damage_upper = ceil(spawned_xeno.melee_damage_upper * GLOB.xenosurge_wave_xenos_dam_factor)
spawned_xeno.health = GLOB.xenosurge_wave_xenos_hp
spawned_xeno.maxHealth = GLOB.xenosurge_wave_xenos_hp
spawned_xeno.melee_damage_lower = GLOB.xenosurge_wave_xenos_dam_min
spawned_xeno.melee_damage_upper = GLOB.xenosurge_wave_xenos_dam_max
spawned_xeno.armor_deflection = GLOB.xenosurge_wave_xenos_armor

/// Shakes the spawner via animation and returns a callback to reset the animation
/datum/game_master_submenu/ambush/proc/shake_spawner()
Expand Down
2 changes: 0 additions & 2 deletions code/modules/mob/living/carbon/xenomorph/Xenomorph.dm
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,6 @@

var/atom/movable/vis_obj/xeno_wounds/wound_icon_holder
var/atom/movable/vis_obj/xeno_pack/backpack_icon_holder
//ai spawner fun
var/spawner_id

/mob/living/carbon/xenomorph/Initialize(mapload, mob/living/carbon/xenomorph/oldXeno, h_number, ai_hard_off = FALSE)
var/area/A = get_area(src)
Expand Down
189 changes: 51 additions & 138 deletions code/modules/pve/spawner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,91 +10,87 @@
indestructible = TRUE
unacidable = TRUE
unslashable = TRUE
var/xenos_to_spawn_max = 5
var/list/spawn_list = list(1 = XENO_CASTE_DRONE, 2 = null,)
var/xenos_to_spawn_delay = 100
var/spawner_initiated = FALSE
var/veterans_spawned = 0
var/spawner_id
var/extra_delay = 0

/obj/structure/xenosurge_spawner/Initialize(mapload, ...)
. = ..()
if(!spawner_id)
spawner_id = GLOB.spawner_number
GLOB.spawner_number += 1
spawner_initiated = TRUE
to_chat(usr, SPAN_INFO("Spawner number [spawner_id] set."))
GLOB.xenosurge_configured_spawners.Add(src)
if(GLOB.xenosurge_surge_started == 1)
to_chat(usr, SPAN_INFO("In-Progress Xenosurge detected. Starting spawn loop for spawner [spawner_id]."))
INVOKE_ASYNC(src, TYPE_PROC_REF(/obj/structure/xenosurge_spawner/, spawner_spawn))
return 1

/obj/structure/xenosurge_spawner/proc/spawner_limit_reached()
message_admins("Wave limit of [GLOB.xenosurge_wave_xenos_max] reached. Disabling spawners.")
for (var/obj/structure/xenosurge_spawner/spawner in GLOB.xenosurge_configured_spawners)
spawner.spawner_initiated = FALSE
GLOB.xenosurge_surge_started = 0
GLOB.xenosurge_wave_xenos_current = 0
GLOB.xenosurge_wave_veteran_xenos_current = 0

/obj/structure/xenosurge_spawner/proc/spawner_loop()
sleep(xenos_to_spawn_delay + extra_delay)
if(spawner_initiated == FALSE)
sleep(GLOB.xenosurge_spawner_delay)
if(GLOB.xenosurge_surge_started == FALSE)
return
else
spawner_spawn()

/obj/structure/xenosurge_spawner/proc/veteran_spawn_loop()
if(GLOB.xenosurge_wave_veteran_xenos_current >= GLOB.xenosurge_veteran_xenos_max) return
var/veterans_to_spawn = GLOB.xenosurge_veteran_spawner_xenos_max
while(veterans_to_spawn > 0)
if(GLOB.xenosurge_surge_started == 0)
veterans_to_spawn = 0
break
sleep(GLOB.xenosurge_veteran_spawner_delay + (rand(1,GLOB.xenosurge_spawner_variance)))
var/veteran_xenos_to_spawn_type = XENO_CASTE_DRONE
var/turf/veteran_spawner_xeno_turf = get_random_turf_in_range(src, 2, 0)
var/veteran_spawner_xeno_typepath = RoleAuthority.get_caste_by_text(veteran_xenos_to_spawn_type)
var/mob/living/carbon/xenomorph/drone/spawned_veteran = new veteran_spawner_xeno_typepath(veteran_spawner_xeno_turf, null, "xeno_hive_normal")
spawned_veteran.health = 1000
spawned_veteran.maxHealth = 1000
spawned_veteran.melee_damage_lower = 15
spawned_veteran.melee_damage_upper = 25
spawned_veteran.armor_deflection = 20
veterans_to_spawn -= 1
GLOB.xenosurge_wave_veteran_xenos_current += 1

/obj/structure/xenosurge_spawner/proc/spawner_spawn()
var/global_xeno_count = 0
var/ai_count = 0
for (var/mob/living/carbon/xenomorph/xeno in world)
if(xeno.loc != null)
global_xeno_count += 1
if(xeno.spawner_id == spawner_id)
ai_count += 1
if(global_xeno_count > GLOB.xenosurge_spawner_limit)
if(extra_delay != 0) extra_delay += 50
INVOKE_ASYNC(src, TYPE_PROC_REF(/obj/structure/xenosurge_spawner/, spawner_loop))
return
if(ai_count >= xenos_to_spawn_max)
INVOKE_ASYNC(src, TYPE_PROC_REF(/obj/structure/xenosurge_spawner/, spawner_loop))
return
else
var/xenos_to_spawn = xenos_to_spawn_max - ai_count
var/current_spawnlistpos = 1
while(xenos_to_spawn > 0)
var/xenos_to_spawn_type = spawn_list[current_spawnlistpos]
var/surge_to_spawn = GLOB.xenosurge_spawner_xenos
if(veterans_spawned == 0)
veterans_spawned = 1
INVOKE_ASYNC(src, TYPE_PROC_REF(/obj/structure/xenosurge_spawner/, veteran_spawn_loop))
while(surge_to_spawn > 0)
var/xenos_to_spawn_type = XENO_CASTE_DRONE
var/turf/spawner_xeno_turf = get_random_turf_in_range(src, 2, 0)
var/spawner_xeno_typepath = RoleAuthority.get_caste_by_text(xenos_to_spawn_type)
var/mob/living/carbon/xenomorph/drone/spawned_xeno = new spawner_xeno_typepath(spawner_xeno_turf, null, "xeno_hive_normal")
spawned_xeno.spawner_id = spawner_id
spawned_xeno.health *= GLOB.xenosurge_wave_xenos_hp_factor
spawned_xeno.maxHealth *= GLOB.xenosurge_wave_xenos_hp_factor
spawned_xeno.melee_damage_lower = ceil(spawned_xeno.melee_damage_lower * GLOB.xenosurge_wave_xenos_dam_factor)
spawned_xeno.melee_damage_upper = ceil(spawned_xeno.melee_damage_upper * GLOB.xenosurge_wave_xenos_dam_factor)
if(spawn_list[current_spawnlistpos + 1] != null)
current_spawnlistpos += 1
else
current_spawnlistpos = 1
xenos_to_spawn -= 1
global_xeno_count += 1
spawned_xeno.health = GLOB.xenosurge_wave_xenos_hp
spawned_xeno.maxHealth = GLOB.xenosurge_wave_xenos_hp
spawned_xeno.melee_damage_lower = GLOB.xenosurge_wave_xenos_dam_min
spawned_xeno.melee_damage_upper = GLOB.xenosurge_wave_xenos_dam_max
spawned_xeno.armor_deflection = GLOB.xenosurge_wave_xenos_armor
surge_to_spawn -= 1
GLOB.xenosurge_wave_xenos_current += 1
if(global_xeno_count >= GLOB.xenosurge_spawner_limit)
xenos_to_spawn = 0
extra_delay += 150
break
sleep(rand(1,GLOB.xenosurge_spawner_variance))
if(GLOB.xenosurge_wave_xenos_current >= GLOB.xenosurge_wave_xenos_max)
spawner_limit_reached()
else
INVOKE_ASYNC(src, TYPE_PROC_REF(/obj/structure/xenosurge_spawner/, spawner_loop))

/obj/structure/xenosurge_spawner/proc/setup_spawner(max = null, delay = null)
if(max == null)
xenos_to_spawn_max = tgui_input_number(usr, "How many xenos total from this spawner","Spawner Setup",xenos_to_spawn_max, timeout = 0)
if(xenos_to_spawn_max == null) return 0
else
xenos_to_spawn_max = max
if(delay == null)
xenos_to_spawn_delay = tgui_input_number(usr, "Dealy, in ticks (~10 a second) between spawn checks.","Spawner Setup",xenos_to_spawn_delay, timeout = 0)
if(xenos_to_spawn_delay == null) return 0
else
xenos_to_spawn_delay = delay
if(!spawner_id)
spawner_id = GLOB.spawner_number
GLOB.spawner_number += 1
spawner_initiated = TRUE
to_chat(usr, SPAN_INFO("Spawner number [spawner_id] set."))
GLOB.xenosurge_configured_spawners.Add(src)
if(GLOB.xenosurge_wave_xenos_current > 0)
to_chat(usr, SPAN_INFO("In-Progress Xenosurge detected. Starting spawn loop for spawner [spawner_id]."))
spawner_spawn()
return 1

/obj/structure/xenosurge_spawner/proc/start_spawning()
if(spawner_initiated == FALSE)
Expand All @@ -105,88 +101,5 @@
spawner_spawn()
return

/obj/structure/xenosurge_veteran_spawner
name = "veteran AI spawner"
desc = "just spawnin' veteran shit"
opacity = FALSE
density = FALSE
invisibility = INVISIBILITY_OBSERVER
icon_state = "campfire_on"
indestructible = TRUE
unacidable = TRUE
unslashable = TRUE
var/xenos_to_spawn_max = 5
var/list/spawn_list = list(1 = XENO_CASTE_DRONE, 2 = null,)
var/xenos_to_spawn_delay = 200
var/spawner_variance = 100
var/spawner_initiated = FALSE
var/spawner_id
var/extra_delay = 0

/obj/structure/xenosurge_veteran_spawner/proc/spawner_loop()
sleep(xenos_to_spawn_delay + extra_delay + rand(1,spawner_variance))
if(spawner_initiated == FALSE)
return
else
spawner_spawn()

/obj/structure/xenosurge_veteran_spawner/proc/spawner_spawn()
var/xenos_to_spawn = xenos_to_spawn_max
var/current_spawnlistpos = 1
while(xenos_to_spawn > 0)
var/xenos_to_spawn_type = spawn_list[current_spawnlistpos]
var/turf/spawner_xeno_turf = get_random_turf_in_range(src, 2, 0)
var/spawner_xeno_typepath = RoleAuthority.get_caste_by_text(xenos_to_spawn_type)
var/mob/living/carbon/xenomorph/drone/spawned_xeno = new spawner_xeno_typepath(spawner_xeno_turf, null, "xeno_hive_normal")
spawned_xeno.spawner_id = spawner_id
spawned_xeno.health *= GLOB.xenosurge_veteran_xenos_hp_factor
spawned_xeno.maxHealth *= GLOB.xenosurge_veteran_xenos_hp_factor
spawned_xeno.melee_damage_lower = ceil(spawned_xeno.melee_damage_lower * GLOB.xenosurge_veteran_xenos_dam_factor)
spawned_xeno.melee_damage_upper = ceil(spawned_xeno.melee_damage_upper * GLOB.xenosurge_veteran_xenos_dam_factor)
if(spawn_list[current_spawnlistpos + 1] != null)
current_spawnlistpos += 1
else
current_spawnlistpos = 1
xenos_to_spawn -= 1
sleep(rand(1,spawner_variance))
spawner_initiated = FALSE


/obj/structure/xenosurge_veteran_spawner/proc/setup_spawner(max = null, delay = null, variance = null)
if(max == null)
xenos_to_spawn_max = tgui_input_number(usr, "How many veteran xenos to spawn","Spawner Setup",xenos_to_spawn_max, timeout = 0)
if(xenos_to_spawn_max == null) return 0
else
xenos_to_spawn_max = max
if(delay == null)
xenos_to_spawn_delay = tgui_input_number(usr, "Base dealy until spawner starts spawning.","Spawner Setup",xenos_to_spawn_delay, timeout = 0)
if(xenos_to_spawn_delay == null) return 0
else
xenos_to_spawn_delay = delay
if(variance == null)
spawner_variance = tgui_input_number(usr, "Variance in pause (in ticks) to dealy and individual spawns.","Spawner Setup",spawner_variance, timeout = 0)
if(spawner_variance == null) return 0
else
spawner_variance = variance

if(!spawner_id)
spawner_id = GLOB.veteran_spawner_number
GLOB.veteran_spawner_number += 1
spawner_initiated = TRUE
to_chat(usr, SPAN_INFO("Veteran spawner number [spawner_id] set."))
GLOB.xenosurge_configured_veteran_spawners.Add(src)
if(GLOB.xenosurge_wave_xenos_current > 0)
to_chat(usr, SPAN_INFO("In-Progress Xenosurge detected. Starting spawn loop for veteran spawner [spawner_id]."))
spawner_spawn()
return 1

/obj/structure/xenosurge_veteran_spawner/proc/start_spawning()
if(spawner_initiated == FALSE)
to_chat(usr, SPAN_WARNING("Failed. Spawner not initiated."))
return
else
message_admins("Veteran Spawner [spawner_id] starting.")
spawner_loop()
return

#undef AI_XENOS

0 comments on commit f9fa2be

Please sign in to comment.