Delayed objective (#2140)
Delayed objective [Latejoiners can now be selected as traitor targets]
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
#define MIN_LATE_TARGET_TIME 600 //lower bound of re-rolled timer, 1 min
|
||||
#define MAX_LATE_TARGET_TIME 6000 //upper bound of re-rolled timer, 10 min
|
||||
#define LATE_TARGET_HIT_CHANCE 70 //How often would the find_target succeed, otherwise it re-rolls later and tries again.
|
||||
//Hit chance is here to avoid people checking github and then hovering around new arrivals within the max minute range every round.
|
||||
|
||||
/datum/objective/assassinate/late
|
||||
martyr_compatible = 0
|
||||
|
||||
|
||||
/datum/objective/assassinate/late/find_target()
|
||||
var/list/possible_targets = list()
|
||||
for(var/mob/M in GLOB.latejoiners)
|
||||
var/datum/mind/possible_target = M.mind
|
||||
if(possible_target != owner && ishuman(possible_target.current) && (possible_target.current.stat != 2) && is_unique_objective(possible_target))
|
||||
possible_targets += possible_target
|
||||
if(possible_targets.len > 0 && prob(LATE_TARGET_HIT_CHANCE))
|
||||
target = pick(possible_targets)
|
||||
martyr_compatible = 1 //Might never matter, but I guess if an admin gives another random objective, this should now be compatible
|
||||
update_explanation_text()
|
||||
|
||||
message_admins("[target] has been selected as the assassination target of [owner].")
|
||||
log_game("[target] has been selected as the assassination target of [owner].")
|
||||
|
||||
to_chat(owner, "<span class='italics'>You hear a crackling noise in your ears, as a one-way syndicate message plays:</span>")
|
||||
to_chat(owner, "<span class='userdanger'><font size=5>You target has been located. To succeed, find and eliminate [target], the [!target_role_type ? target.assigned_role : target.special_role].</font></span>")
|
||||
return target
|
||||
else
|
||||
update_explanation_text()
|
||||
addtimer(CALLBACK(src, .proc/find_target),rand(MIN_LATE_TARGET_TIME, MAX_LATE_TARGET_TIME))
|
||||
return null
|
||||
|
||||
/datum/objective/assassinate/late/find_target_by_role(role, role_type=0, invert=0)
|
||||
var/list/possible_targets = list()
|
||||
for(var/mob/M in GLOB.latejoiners)
|
||||
var/datum/mind/possible_target = M.mind
|
||||
if((possible_target != owner) && ishuman(possible_target.current))
|
||||
var/is_role = 0
|
||||
if(role_type)
|
||||
if(possible_target.special_role == role)
|
||||
is_role++
|
||||
else
|
||||
if(possible_target.assigned_role == role)
|
||||
is_role++
|
||||
|
||||
if(invert)
|
||||
if(is_role)
|
||||
continue
|
||||
possible_targets += possible_target
|
||||
//break
|
||||
else if(is_role)
|
||||
possible_targets += possible_target
|
||||
//break
|
||||
if(possible_targets && prob(LATE_TARGET_HIT_CHANCE))
|
||||
target = pick(possible_targets)
|
||||
update_explanation_text()
|
||||
|
||||
message_admins("[target] has been selected as the assassination target of [owner].")
|
||||
log_game("[target] has been selected as the assassination target of [owner].")
|
||||
|
||||
to_chat(owner, "<span class='italics'>You hear a crackling noise in your ears, as a one-way syndicate message plays:</span>")
|
||||
to_chat(owner, "<span class='userdanger'><font size=5>You target has been located. To succeed, find and eliminate [target], the [!target_role_type ? target.assigned_role : target.special_role].</font></span>")
|
||||
else
|
||||
update_explanation_text()
|
||||
addtimer(CALLBACK(src, .proc/find_target_by_role, role, role_type, invert),rand(MIN_LATE_TARGET_TIME, MAX_LATE_TARGET_TIME))
|
||||
|
||||
|
||||
|
||||
/datum/objective/assassinate/late/check_completion()
|
||||
if(target && target.current) //If target WAS assigned
|
||||
if(target.current.stat == DEAD || issilicon(target.current) || isbrain(target.current) || target.current.z > 6 || !target.current.ckey) //Borgs/brains/AIs count as dead for traitor objectives. --NeoFite
|
||||
return 1
|
||||
return 0
|
||||
else //If no target was ever given
|
||||
if(!owner.current || owner.current.stat == DEAD || isbrain(owner.current))
|
||||
return 0
|
||||
if(!is_special_character(owner.current))
|
||||
return 0
|
||||
return 1
|
||||
|
||||
/datum/objective/assassinate/late/update_explanation_text()
|
||||
//..()
|
||||
if(target && target.current)
|
||||
explanation_text = "Assassinate [target.name], the [!target_role_type ? target.assigned_role : target.special_role]."
|
||||
else
|
||||
explanation_text = "Stay alive until your target arrives on the station, you will be notified when the target has been identified."
|
||||
@@ -43,6 +43,7 @@
|
||||
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"
|
||||
var/list/candidates = list() //Let's compile a list and THEN pick one randomly, not just first come first serve...
|
||||
for(var/datum/mind/possible_target in get_crewmember_minds())
|
||||
if((possible_target != owner) && ishuman(possible_target.current))
|
||||
var/is_role = 0
|
||||
@@ -56,12 +57,11 @@
|
||||
if(invert)
|
||||
if(is_role)
|
||||
continue
|
||||
target = possible_target
|
||||
break
|
||||
candidates += possible_target
|
||||
else if(is_role)
|
||||
target = possible_target
|
||||
break
|
||||
|
||||
candidates += possible_target
|
||||
if(candidates)
|
||||
target = pick(candidates)
|
||||
update_explanation_text()
|
||||
|
||||
/datum/objective/proc/update_explanation_text()
|
||||
|
||||
Reference in New Issue
Block a user