Merge pull request #23432 from DamianX/CheckEnemyJobs

Allow dynamic rulesets to have custom enemy job requirement checks
This commit is contained in:
Kurfursten
2019-07-08 13:13:03 -05:00
committed by GitHub
3 changed files with 21 additions and 29 deletions

View File

@@ -80,6 +80,23 @@
return 0
return 1
// Returns TRUE if there are sufficient enemies to execute this ruleset
/datum/dynamic_ruleset/proc/check_enemy_jobs()
if (!enemy_jobs.len)
return TRUE
var/enemies_count = 0
for (var/mob/M in mode.living_players)
if (M.stat == DEAD)
continue//dead players cannot count as opponents
if (M.mind && M.mind.assigned_role && (M.mind.assigned_role in enemy_jobs) && (!(M in candidates) || (M.mind.assigned_role in restricted_from_jobs)))
enemies_count++//checking for "enemies" (such as sec officers). To be counters, they must either not be candidates to that rule, or have a job that restricts them from it
var/threat = round(mode.threat_level/10)
if (enemies_count >= required_enemies[threat])
return TRUE
return FALSE
/datum/dynamic_ruleset/proc/get_weight()
if(repeatable && weight > 1)
for(var/datum/dynamic_ruleset/DR in mode.executed_rules)
@@ -220,13 +237,6 @@
/datum/dynamic_ruleset/roundstart/ready(var/forced = 0)
if (!forced)
var/job_check = 0
if (enemy_jobs.len > 0)
for (var/mob/M in mode.candidates)
if (M.mind && M.mind.assigned_role && (M.mind.assigned_role in enemy_jobs) && (!(M in candidates) || (M.mind.assigned_role in restricted_from_jobs)))
job_check++//checking for "enemies" (such as sec officers). To be counters, they must either not be candidates to that rule, or have a job that restricts them from it
var/threat = round(mode.threat_level/10)
if (job_check < required_enemies[threat])
if(!check_enemy_jobs())
return 0
return ..()

View File

@@ -28,16 +28,7 @@
/datum/dynamic_ruleset/latejoin/ready(var/forced = 0)
if (!forced)
var/job_check = 0
if (enemy_jobs.len > 0)
for (var/mob/M in mode.living_players)
if (M.stat == DEAD)
continue//dead players cannot count as opponents
if (M.mind && M.mind.assigned_role && (M.mind.assigned_role in enemy_jobs) && (!(M in candidates) || (M.mind.assigned_role in restricted_from_jobs)))
job_check++//checking for "enemies" (such as sec officers). To be counters, they must either not be candidates to that rule, or have a job that restricts them from it
var/threat = round(mode.threat_level/10)
if (job_check < required_enemies[threat])
if(!check_enemy_jobs())
return 0
return ..()
@@ -143,7 +134,7 @@
spawn(5)
newninja.antag.current.ThrowAtStation()
return 1
//////////////////////////////////////////////

View File

@@ -60,16 +60,7 @@
// (see /datum/dynamic_ruleset/midround/autotraitor/ready(var/forced = 0) for example)
/datum/dynamic_ruleset/midround/ready(var/forced = 0)
if (!forced)
var/job_check = 0
if (enemy_jobs.len > 0)
for (var/mob/M in living_players)
if (M.stat == DEAD)
continue//dead players cannot count as opponents
if (M.mind && M.mind.assigned_role && (M.mind.assigned_role in enemy_jobs) && (!(M in candidates) || (M.mind.assigned_role in restricted_from_jobs)))
job_check++//checking for "enemies" (such as sec officers). To be counters, they must either not be candidates to that rule, or have a job that restricts them from it
var/threat = round(mode.threat_level/10)
if (job_check < required_enemies[threat])
if(!check_enemy_jobs())
return 0
return 1