-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds crappy system for delayed/looping spawns #111
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
code/modules/admin/game_master/game_master_xeno_spawner.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
GLOBAL_LIST_EMPTY(gm_xeno_spawners) | ||
|
||
/datum/game_master_xeno_spawner | ||
/// The actual image holder that is added to game masters' clients | ||
var/image/gm_image | ||
|
||
/// The location the xenomorphs will spawn at. | ||
var/turf/spawn_loc | ||
|
||
/// The type of xeno to be spawned. | ||
var/mob/living/carbon/xenomorph/spawn_type | ||
|
||
/// The number of xenos to be spawned. | ||
var/spawn_count | ||
|
||
/// The delay until xenos are spawned (may be 0, in which case xenos spawn instantaneously). | ||
var/spawn_delay | ||
|
||
/// If TRUE, the spawner will not delete itself after firing. | ||
var/looping | ||
|
||
/// The hive the spawned xenos will belong to. | ||
var/spawn_hive | ||
|
||
/// Whether or not to spawn xenos with AI: if TRUE, the spawned xenos will have AI. | ||
var/spawn_ai | ||
|
||
/// If TRUE, the spawn will fail if any humans are within "fail_range" tiles. | ||
/// This will cause the spawner to either delete itself or reset its spawn timer, depending on whether it loops. | ||
var/fail_if_human_near | ||
|
||
var/fail_range = 9 | ||
|
||
/datum/game_master_xeno_spawner/New(turf/s_loc, mob/living/carbon/xenomorph/s_type, s_count, s_delay, loop, s_hive, s_ai, fail_human) | ||
GLOB.gm_xeno_spawners += src | ||
|
||
spawn_loc = s_loc | ||
spawn_type = s_type | ||
spawn_count = s_count | ||
spawn_delay = s_delay | ||
looping = loop | ||
spawn_hive = s_hive | ||
spawn_ai = s_ai | ||
fail_if_human_near = fail_human | ||
|
||
// we can return early if we aren't waiting for anything | ||
if(spawn_delay <= 0) | ||
spawn_xenos() | ||
return | ||
|
||
addtimer(CALLBACK(src, PROC_REF(spawn_xenos)), spawn_delay) | ||
|
||
// get the icon state for the xeno type we're trying to spawn | ||
var/derived_icon_state = initial(spawn_type.mutation_type) + " " + initial(spawn_type.icon_state) | ||
gm_image = new( | ||
initial(spawn_type.icon), | ||
spawn_loc, | ||
derived_icon_state, | ||
layer = ABOVE_FLY_LAYER, | ||
) | ||
// centers the xeno | ||
gm_image.pixel_x = -(initial(spawn_type.icon_size) - 32)/2 | ||
// slightly more visible than observers | ||
gm_image.alpha = 150 | ||
// color matrix. this makes them look sorta overexposed. janky, but it's more important that it looks distinguishable than good | ||
gm_image.color = list( | ||
1.5, 0, 0, | ||
0, 1.5, 0, | ||
0, 0, 1.5, | ||
0.25, 0.25, 0.25 | ||
) | ||
|
||
for(var/client/game_master in GLOB.game_masters) | ||
game_master.images |= gm_image | ||
|
||
/datum/game_master_xeno_spawner/Destroy(force, silent, ...) | ||
. = ..() | ||
|
||
GLOB.gm_xeno_spawners -= src | ||
|
||
// cleans up the image | ||
if(gm_image) | ||
for(var/client/game_master in GLOB.game_masters) | ||
game_master.images -= gm_image | ||
QDEL_NULL(gm_image) | ||
|
||
/datum/game_master_xeno_spawner/proc/spawn_xenos() | ||
var/failure = FALSE | ||
|
||
if(fail_if_human_near) | ||
for(var/mob/living/carbon/human as anything in GLOB.alive_human_list) | ||
if(human.client && human.z == spawn_loc.z && (get_dist(human, spawn_loc) <= fail_range)) | ||
failure = TRUE | ||
break | ||
|
||
if(!failure) | ||
for(var/i = 1 to spawn_count) | ||
new spawn_type(spawn_loc, null, spawn_hive, !spawn_ai) | ||
|
||
if(spawn_delay && looping) | ||
addtimer(CALLBACK(src, PROC_REF(spawn_xenos)), spawn_delay) | ||
else | ||
qdel(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
fail_range
exists and is not a null,fail_if_human_near
may not be needed as the range already signals that it should do something within that range. Could maybe change the range instead of toggling the function, though in practice you probably would rarely want it to work like that.