forked from ParadiseSS13/Paradise
-
Notifications
You must be signed in to change notification settings - Fork 130
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
Terror spider spawn refactor #957
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b1f8046
tweak: terror spiders spawn refactor
Fullonibus 8898c14
cleanup
Fullonibus 406dcec
pupu
Fullonibus f2e9771
now is modular
Fullonibus ba48b87
wrong code
Fullonibus 6698d03
fixed modular
Fullonibus 87d5e6c
Merge branch 'master' into spider_refactor
Fullonibus 2e0507c
Merge branch 'master' into spider_refactor
Fullonibus 0f5481e
Update modular_ss220/events/code/spider_terror.dm
Fullonibus 2dd048c
Update modular_ss220/events/code/spider_terror.dm
Fullonibus 49b2a22
Update modular_ss220/events/code/spider_terror.dm
Fullonibus 8d9d535
Update modular_ss220/events/code/spider_terror.dm
Fullonibus 4a0c2a4
Merge branch 'master' into spider_refactor
Fullonibus d17ff9b
de-defined type list
Fullonibus e23b161
Merge branch 'master' into spider_refactor
Fullonibus 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
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,101 @@ | ||
#define TS_POINTS_GREEN 9 | ||
#define TS_POINTS_WHITE 17 | ||
#define TS_POINTS_PRINCESS 19 | ||
#define TS_POINTS_PRINCE 30 | ||
#define TS_POINTS_QUEEN 42 | ||
|
||
#define TERROR_GREEN /mob/living/simple_animal/hostile/poison/terror_spider/green | ||
#define TERROR_WHITE /mob/living/simple_animal/hostile/poison/terror_spider/prince | ||
#define TERROR_PRINCESS /mob/living/simple_animal/hostile/poison/terror_spider/queen/princess | ||
#define TERROR_PRINCE /mob/living/simple_animal/hostile/poison/terror_spider/prince | ||
#define TERROR_QUEEN /mob/living/simple_animal/hostile/poison/terror_spider/queen | ||
|
||
/datum/event/spider_terror | ||
announceWhen = 240 | ||
var/population_factor = 0.7 // higher - more spawnpoints | ||
spawncount = 0 // amount of spawned spiders | ||
var/spawnpoints = TS_POINTS_GREEN // weight points | ||
/// lists for matching spiders and their weights | ||
var/list/spider_types = list("TERROR_GREEN" = TERROR_GREEN, "TERROR_WHITE" = TERROR_WHITE, "TERROR_PRINCESS" = TERROR_PRINCESS, "TERROR_PRINCE" = TERROR_PRINCE, "TERROR_QUEEN" = TERROR_QUEEN) | ||
var/list/spider_costs = list("TERROR_GREEN" = TS_POINTS_GREEN, "TERROR_WHITE" = TS_POINTS_WHITE, "TERROR_PRINCESS" = TS_POINTS_PRINCESS, "TERROR_PRINCE" = TS_POINTS_PRINCE, "TERROR_QUEEN" = TS_POINTS_QUEEN) | ||
var/list/spider_counts = list("TERROR_GREEN" = 0, "TERROR_WHITE" = 0, "TERROR_PRINCESS" = 0, "TERROR_PRINCE" = 0, "TERROR_QUEEN" = 0) | ||
|
||
/datum/event/spider_terror/start() | ||
spawncount = 0 // yeah, still not 0 | ||
// It is necessary to wrap this to avoid the event triggering repeatedly. | ||
INVOKE_ASYNC(src, PROC_REF(wrappedstart_new)) | ||
|
||
/datum/event/spider_terror/proc/wrappedstart_new() | ||
var/list/candidates = SSghost_spawns.poll_candidates("Do you want to play as a terror spider?", null, TRUE, source = /mob/living/simple_animal/hostile/poison/terror_spider) // questionable | ||
var/max_spiders = length(candidates) | ||
log_debug("where is [max_spiders] candidates") | ||
spawnpoints += round(population_factor * length(GLOB.clients)) // server population sensitivity | ||
log_debug("where is [spawnpoints] available spawnpoints") | ||
spawn_terror_spiders(count_spawn_spiders(max_spiders), candidates) | ||
SSevents.biohazards_this_round += 1 | ||
|
||
/datum/event/spider_terror/proc/count_spawn_spiders(max_spiders) | ||
while(spawnpoints >= TS_POINTS_GREEN && spawncount < max_spiders) | ||
var/chosen_spider_id = pick(spider_costs) // random spider type choose | ||
var/cost = spider_costs[chosen_spider_id] | ||
|
||
if(spawnpoints - cost >= 0) | ||
spider_counts[chosen_spider_id] += 1 | ||
spawnpoints -= cost | ||
spawncount += 1 | ||
log_debug("spider added into pool: [chosen_spider_id]") | ||
log_debug("where is [spawnpoints] available spawnpoints now") | ||
|
||
if(spawnpoints < TS_POINTS_GREEN || spawncount >= max_spiders) | ||
break | ||
|
||
log_debug("selected [spawncount] spider(s)") | ||
return spider_counts | ||
|
||
/datum/event/spider_terror/proc/spawn_terror_spiders(list/spider_counts, candidates) | ||
log_debug("begin spiders spawning") | ||
var/list/vents = get_valid_vent_spawns(exclude_mobs_nearby = TRUE) | ||
if(!length(vents)) | ||
message_admins("Warning: No suitable vents detected for spawning terrors. Force picking from station vents regardless of state!") | ||
vents = get_valid_vent_spawns(unwelded_only = FALSE, min_network_size = 0) | ||
|
||
log_debug("where is awailible [length(vents)] vents") | ||
log_debug("spawncount is: [spawncount] vents") | ||
while(spawncount && length(vents) && length(candidates)) | ||
for(var/spider_id in spider_counts) | ||
var/spider_type = spider_types[spider_id] | ||
var/spider_count = spider_counts[spider_id] | ||
log_debug("entering inner while cycle") | ||
while(spider_count > 0 && length(candidates)) | ||
var/obj/vent = pick_n_take(vents) | ||
var/mob/living/simple_animal/hostile/poison/terror_spider/S = new spider_type(vent.loc) | ||
var/mob/M = pick_n_take(candidates) | ||
S.key = M.key | ||
dust_if_respawnable(M) | ||
S.forceMove(vent) | ||
S.add_ventcrawl(vent) | ||
SEND_SOUND(S, sound('sound/ambience/antag/terrorspider.ogg')) | ||
S.give_intro_text() | ||
spawncount-- | ||
successSpawn = TRUE | ||
|
||
spider_count-- | ||
|
||
if(spawncount <= 0) | ||
break | ||
|
||
spider_counts[spider_type] = 0 | ||
|
||
log_and_message_admins("spiders spawned successfully") | ||
|
||
#undef TS_POINTS_GREEN | ||
#undef TS_POINTS_WHITE | ||
#undef TS_POINTS_PRINCESS | ||
#undef TS_POINTS_PRINCE | ||
#undef TS_POINTS_QUEEN | ||
|
||
#undef TERROR_GREEN | ||
#undef TERROR_WHITE | ||
#undef TERROR_PRINCESS | ||
#undef TERROR_PRINCE | ||
#undef TERROR_QUEEN |
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.
Убери дефайны и сделай список, каждое значение - с новой строки.