mirror of
https://github.com/yogstation13/Yogstation.git
synced 2025-02-26 09:04:50 +00:00
Finding an objective target by role now actually picks a random target (#41036)
* finally * length check
This commit is contained in:
committed by
yogstation13-bot
parent
5efa5c2678
commit
226e8b015e
@@ -69,7 +69,7 @@
|
||||
if(hosts.len >= 4 && prob(35)) //Create the versus objective here since we want a common target for all the antags
|
||||
var/datum/antagonist/hivemind/hive
|
||||
hive.common_assimilation_obj = new /datum/objective/hivemind/assimilate_common
|
||||
hive.common_assimilation_obj.find_target_by_role(role = ROLE_HIVE, role_type = 1, invert = 1)
|
||||
hive.common_assimilation_obj.find_target_by_role(role = ROLE_HIVE, role_type = TRUE, invert = TRUE)
|
||||
for(var/datum/mind/i in hosts)
|
||||
i.add_antag_datum(/datum/antagonist/hivemind)
|
||||
return ..()
|
||||
|
||||
@@ -108,28 +108,31 @@ GLOBAL_LIST(admin_objective_list) //Prefilled admin assignable objective list
|
||||
update_explanation_text()
|
||||
return target
|
||||
|
||||
/datum/objective/proc/find_target_by_role(role, role_type=0, invert=0)//Option sets either to check assigned role or special role. Default to assigned., invert inverts the check, eg: "Don't choose a Ling"
|
||||
/datum/objective/proc/find_target_by_role(role, role_type=FALSE,invert=FALSE)//Option sets either to check assigned role or special role. Default to assigned., invert inverts the check, eg: "Don't choose a Ling"
|
||||
var/list/datum/mind/owners = get_owners()
|
||||
var/list/possible_targets = list()
|
||||
for(var/datum/mind/possible_target in get_crewmember_minds())
|
||||
if(!(possible_target in owners) && ishuman(possible_target.current))
|
||||
var/is_role = 0
|
||||
var/is_role = FALSE
|
||||
if(role_type)
|
||||
if(possible_target.special_role == role)
|
||||
is_role++
|
||||
is_role = TRUE
|
||||
else
|
||||
if(possible_target.assigned_role == role)
|
||||
is_role++
|
||||
is_role = TRUE
|
||||
|
||||
if(invert)
|
||||
if(is_role)
|
||||
continue
|
||||
target = possible_target
|
||||
possible_targets += possible_target
|
||||
break
|
||||
else if(is_role)
|
||||
target = possible_target
|
||||
possible_targets += possible_target
|
||||
break
|
||||
|
||||
if(length(possible_targets))
|
||||
target = pick(possible_targets)
|
||||
update_explanation_text()
|
||||
return target
|
||||
|
||||
/datum/objective/proc/update_explanation_text()
|
||||
if(team_explanation_text && LAZYLEN(get_owners()) > 1)
|
||||
@@ -147,14 +150,13 @@ GLOBAL_LIST(admin_objective_list) //Prefilled admin assignable objective list
|
||||
|
||||
/datum/objective/assassinate
|
||||
name = "assasinate"
|
||||
var/target_role_type=0
|
||||
var/target_role_type=FALSE
|
||||
martyr_compatible = 1
|
||||
|
||||
/datum/objective/assassinate/find_target_by_role(role, role_type=0, invert=0)
|
||||
/datum/objective/assassinate/find_target_by_role(role, role_type=FALSE,invert=FALSE)
|
||||
if(!invert)
|
||||
target_role_type = role_type
|
||||
..()
|
||||
return target
|
||||
|
||||
/datum/objective/assassinate/check_completion()
|
||||
return completed || (!considered_alive(target) || considered_afk(target))
|
||||
@@ -179,14 +181,13 @@ GLOBAL_LIST(admin_objective_list) //Prefilled admin assignable objective list
|
||||
|
||||
/datum/objective/mutiny
|
||||
name = "mutiny"
|
||||
var/target_role_type=0
|
||||
var/target_role_type=FALSE
|
||||
martyr_compatible = 1
|
||||
|
||||
/datum/objective/mutiny/find_target_by_role(role, role_type=0,invert=0)
|
||||
/datum/objective/mutiny/find_target_by_role(role, role_type=FALSE,invert=FALSE)
|
||||
if(!invert)
|
||||
target_role_type = role_type
|
||||
..()
|
||||
return target
|
||||
|
||||
/datum/objective/mutiny/check_completion()
|
||||
if(!target || !considered_alive(target) || considered_afk(target))
|
||||
@@ -203,14 +204,13 @@ GLOBAL_LIST(admin_objective_list) //Prefilled admin assignable objective list
|
||||
|
||||
/datum/objective/maroon
|
||||
name = "maroon"
|
||||
var/target_role_type=0
|
||||
var/target_role_type=FALSE
|
||||
martyr_compatible = 1
|
||||
|
||||
/datum/objective/maroon/find_target_by_role(role, role_type=0, invert=0)
|
||||
/datum/objective/maroon/find_target_by_role(role, role_type=FALSE,invert=FALSE)
|
||||
if(!invert)
|
||||
target_role_type = role_type
|
||||
..()
|
||||
return target
|
||||
|
||||
/datum/objective/maroon/check_completion()
|
||||
return !target || !considered_alive(target) || (!target.current.onCentCom() && !target.current.onSyndieBase())
|
||||
@@ -228,11 +228,10 @@ GLOBAL_LIST(admin_objective_list) //Prefilled admin assignable objective list
|
||||
name = "debrain"
|
||||
var/target_role_type=0
|
||||
|
||||
/datum/objective/debrain/find_target_by_role(role, role_type=0, invert=0)
|
||||
/datum/objective/debrain/find_target_by_role(role, role_type=FALSE,invert=FALSE)
|
||||
if(!invert)
|
||||
target_role_type = role_type
|
||||
..()
|
||||
return target
|
||||
|
||||
/datum/objective/debrain/check_completion()
|
||||
if(!target)//If it's a free objective.
|
||||
@@ -262,10 +261,10 @@ GLOBAL_LIST(admin_objective_list) //Prefilled admin assignable objective list
|
||||
/datum/objective/protect//The opposite of killing a dude.
|
||||
name = "protect"
|
||||
martyr_compatible = 1
|
||||
var/target_role_type = 0
|
||||
var/target_role_type = FALSE
|
||||
var/human_check = TRUE
|
||||
|
||||
/datum/objective/protect/find_target_by_role(role, role_type=0, invert=0)
|
||||
/datum/objective/protect/find_target_by_role(role, role_type=FALSE,invert=FALSE)
|
||||
if(!invert)
|
||||
target_role_type = role_type
|
||||
..()
|
||||
|
||||
@@ -410,7 +410,7 @@
|
||||
var/datum/objective/assassinate/kill_objective = new
|
||||
kill_objective.owner = owner
|
||||
if(team_mode) //No backstabbing while in a team
|
||||
kill_objective.find_target_by_role(role = ROLE_CHANGELING, role_type = 1, invert = 1)
|
||||
kill_objective.find_target_by_role(role = ROLE_CHANGELING, role_type = TRUE, invert = TRUE)
|
||||
else
|
||||
kill_objective.find_target()
|
||||
objectives += kill_objective
|
||||
@@ -418,7 +418,7 @@
|
||||
var/datum/objective/maroon/maroon_objective = new
|
||||
maroon_objective.owner = owner
|
||||
if(team_mode)
|
||||
maroon_objective.find_target_by_role(role = ROLE_CHANGELING, role_type = 1, invert = 1)
|
||||
maroon_objective.find_target_by_role(role = ROLE_CHANGELING, role_type = TRUE, invert = TRUE)
|
||||
else
|
||||
maroon_objective.find_target()
|
||||
objectives += maroon_objective
|
||||
@@ -440,7 +440,7 @@
|
||||
var/datum/objective/escape/escape_with_identity/identity_theft = new
|
||||
identity_theft.owner = owner
|
||||
if(team_mode)
|
||||
identity_theft.find_target_by_role(role = ROLE_CHANGELING, role_type = 1, invert = 1)
|
||||
identity_theft.find_target_by_role(role = ROLE_CHANGELING, role_type = TRUE, invert = TRUE)
|
||||
else
|
||||
identity_theft.find_target()
|
||||
objectives += identity_theft
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
if(prob(25)) //Decently high chance to have to assimilate an implanted crew member
|
||||
assim_objective.find_target_by_role(pick("Captain","Head of Security","Security Officer","Detective","Warden"))
|
||||
if(!assim_objective.target) //If the prob doesn't happen or there are no implanted crew, find any target that isn't a hivemmind host
|
||||
assim_objective.find_target_by_role(role = ROLE_HIVE, role_type = 1, invert = 1)
|
||||
assim_objective.find_target_by_role(role = ROLE_HIVE, role_type = TRUE, invert = TRUE)
|
||||
assim_objective.update_explanation_text()
|
||||
objectives += assim_objective
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user