Split antagonist.dm up.

This commit is contained in:
Zuhayr
2015-03-18 01:57:56 +10:30
parent 3718245e45
commit 4d14722b2a
11 changed files with 569 additions and 183 deletions

View File

@@ -10,10 +10,8 @@ var/datum/antagonist/xenos/xenomorphs
flags = ANTAG_OVERRIDE_MOB | ANTAG_RANDSPAWN | ANTAG_OVERRIDE_JOB | ANTAG_VOTABLE
welcome_text = "Hiss! You are a larval alien. Hide and bide your time until you are ready to evolve."
spawn_upper = 5
spawn_lower = 3
max_antags = 200 // No upper limit.
max_antags_round = 200 // No upper limit.
max_antags = 5
max_antags_round = 8
spawn_announcement = "Unidentified lifesigns detected coming aboard the station. Secure any exterior access, including ducting and ventilation."
spawn_announcement_title = "Lifesign Alert"

View File

@@ -0,0 +1,117 @@
/datum/antagonist/proc/create_objectives(var/datum/mind/player)
if(config.objectives_disabled)
return 0
if(global_objectives && global_objectives.len)
player.objectives |= global_objectives
return 1
/datum/antagonist/proc/apply(var/datum/mind/player)
// Get the mob.
if((flags & ANTAG_OVERRIDE_MOB) && (!player.current || (mob_path && !istype(player.current, mob_path))))
var/mob/holder = player.current
player.current = new mob_path(get_turf(player.current))
player.transfer_to(player.current)
if(holder) del(holder)
player.original = player.current
return player.current
/datum/antagonist/proc/equip(var/mob/living/carbon/human/player)
if(!istype(player))
return 0
// This could use work.
if(flags & ANTAG_CLEAR_EQUIPMENT)
for(var/obj/item/thing in player.contents)
del(thing)
return 1
if(flags & ANTAG_SET_APPEARANCE)
player.change_appearance(APPEARANCE_ALL, player, player, valid_species)
/datum/antagonist/proc/unequip(var/mob/living/carbon/human/player)
if(!istype(player))
return 0
return 1
/datum/antagonist/proc/greet(var/datum/mind/player)
// Basic intro text.
player.current << "<span class='danger'><font size=3>You are a [role_text]!</font></span>"
if(leader_welcome_text && player.current == leader)
player.current << "<span class='notice'>[leader_welcome_text]</span>"
else
player.current << "<span class='notice'>[welcome_text]</span>"
show_objectives(player)
// Choose a name, if any.
if(flags & ANTAG_CHOOSE_NAME)
var/newname = sanitize(copytext(input(player.current, "You are a [role_text]. Would you like to change your name to something else?", "Name change") as null|text,1,MAX_NAME_LEN))
if (newname)
player.current.real_name = newname
player.current.name = player.current.real_name
player.name = player.current.name
// Update any ID cards.
update_access(player.current)
// Clown clumsiness check, I guess downstream might use it.
if (player.current.mind)
if (player.current.mind.assigned_role == "Clown")
player.current << "You have evolved beyond your clownish nature, allowing you to wield weapons without harming yourself."
player.current.mutations.Remove(CLUMSY)
return 1
/datum/antagonist/proc/update_access(var/mob/living/player)
for(var/obj/item/weapon/card/id/id in player.contents)
id.name = "[player.real_name]'s ID Card"
id.registered_name = player.real_name
/datum/antagonist/proc/random_spawn()
return attempt_spawn(null,null,(flags & (ANTAG_OVERRIDE_MOB|ANTAG_OVERRIDE_JOB)))
/datum/antagonist/proc/create_id(var/assignment, var/mob/living/carbon/human/player)
var/obj/item/weapon/card/id/W = new id_type(player)
W.name = "[player.real_name]'s ID Card"
W.access |= default_access
W.assignment = "[assignment]"
W.registered_name = player.real_name
player.equip_to_slot_or_del(W, slot_wear_id)
return W
/datum/antagonist/proc/create_radio(var/freq, var/mob/living/carbon/human/player)
var/obj/item/device/radio/R = new /obj/item/device/radio/headset(player)
R.set_frequency(freq)
player.equip_to_slot_or_del(R, slot_l_ear)
return R
/datum/antagonist/proc/make_nuke(var/atom/paper_spawn_loc, var/datum/mind/code_owner)
// Decide on a code.
var/obj/effect/landmark/nuke_spawn = locate(nuke_spawn_loc ? nuke_spawn_loc : "landmark*Nuclear-Bomb")
var/code
if(nuke_spawn)
var/obj/machinery/nuclearbomb/nuke = new(get_turf(nuke_spawn))
code = "[rand(10000, 99999)]"
nuke.r_code = code
if(code)
if(!paper_spawn_loc)
paper_spawn_loc = get_turf(locate("landmark*Nuclear-Code"))
if(paper_spawn_loc)
// Create and pass on the bomb code paper.
var/obj/item/weapon/paper/P = new(paper_spawn_loc)
P.info = "The nuclear authorization code is: <b>[code]</b>"
P.name = "nuclear bomb code"
if(code_owner)
code_owner.store_memory("<B>Nuclear Bomb Code</B>: [code]", 0, 0)
code_owner.current << "The nuclear authorization code is: <B>[code]</B>"
else
world << "<spam class='danger'>Could not spawn nuclear bomb. Contact a developer.</span>"
return
return code

View File

@@ -0,0 +1,41 @@
var/global/list/all_antag_types = list()
var/global/list/all_antag_spawnpoints = list()
var/global/list/antag_names_to_ids = list()
/proc/get_antag_data(var/antag_type)
if(all_antag_types[antag_type])
return all_antag_types[antag_type]
else
for(var/cur_antag_type in all_antag_types)
var/datum/antagonist/antag = all_antag_types[cur_antag_type]
if(antag && antag.is_type(antag_type))
return antag
/proc/clear_antag_roles(var/datum/mind/player, var/implanted)
for(var/antag_type in all_antag_types)
var/datum/antagonist/antag = all_antag_types[antag_type]
if(!implanted || !(antag.flags & ANTAG_IMPLANT_IMMUNE))
antag.remove_antagonist(player, 1, implanted)
/proc/update_antag_icons(var/datum/mind/player)
for(var/antag_type in all_antag_types)
var/datum/antagonist/antag = all_antag_types[antag_type]
if(player)
antag.update_icons_removed(player)
if(antag.is_antagonist(player))
antag.update_icons_added(player)
else
antag.update_all_icons()
/proc/populate_antag_type_list()
for(var/antag_type in typesof(/datum/antagonist)-/datum/antagonist)
var/datum/antagonist/A = new antag_type
all_antag_types[A.id] = A
all_antag_spawnpoints[A.landmark_id] = list()
antag_names_to_ids[A.role_text] = A.id
/proc/get_antags(var/atype)
var/datum/antagonist/antag = all_antag_types[atype]
if(antag && islist(antag.current_antagonists))
return antag.current_antagonists
return list()

View File

@@ -0,0 +1,41 @@
/datum/antagonist/proc/can_become_antag(var/datum/mind/player)
if(player.current && jobban_isbanned(player.current, bantype))
return 0
if(player.assigned_role in protected_jobs)
return 0
if(config.protect_roles_from_antagonist && (player.assigned_role in restricted_jobs))
return 0
return 1
/datum/antagonist/proc/antags_are_dead()
for(var/datum/mind/antag in current_antagonists)
if(mob_path && !istype(antag.current,mob_path))
continue
if(antag.current.stat==2)
continue
return 0
return 1
/datum/antagonist/proc/get_antag_count()
return current_antagonists ? current_antagonists.len : 0
/datum/antagonist/proc/is_antagonist(var/datum/mind/player)
if(player in current_antagonists)
return 1
/datum/antagonist/proc/is_type(var/antag_type)
if(antag_type == id || antag_type == role_text)
return 1
return 0
/datum/antagonist/proc/get_candidates(var/ghosts_only)
candidates = list() // Clear.
candidates = ticker.mode.get_players_for_role(role_type, id)
// Prune restricted jobs and status.
for(var/datum/mind/player in candidates)
if((ghosts_only && !istype(player.current, /mob/dead)) || (player.assigned_role in restricted_jobs))
candidates -= player
return candidates

View File

@@ -0,0 +1,27 @@
/datum/antagonist/proc/create_global_objectives()
return !((global_objectives && global_objectives.len) || config.objectives_disabled)
/datum/antagonist/proc/get_special_objective_text()
return ""
/datum/antagonist/proc/check_victory()
var/result
if(config.objectives_disabled)
return 1
if(!victory_text || !loss_text)
return 1
if(global_objectives && global_objectives.len)
for(var/datum/objective/O in global_objectives)
if(!O.completed && !O.check_completion())
result = 1 // Victory.
else
O.completed = 1 //Will this break anything?
if(result)
world << "<span class='danger'><font size = 3>[victory_text]</span>"
if(victory_feedback_tag) feedback_set_details("round_end_result","[victory_feedback_tag]")
else
world << "<span class='danger'><font size = 3>[loss_text]</span>"
if(loss_feedback_tag) feedback_set_details("round_end_result","[loss_feedback_tag]")

View File

@@ -0,0 +1,78 @@
/datum/antagonist/proc/attempt_late_spawn(var/datum/mind/player, var/move_to_spawn)
update_cur_max()
if(get_antag_count() >= cur_max)
return 0
player.current << "<span class='danger'><i>You have been selected this round as an antagonist!</i></span>"
add_antagonist(player)
equip(player.current)
finalize(player)
if(move_to_spawn)
place_mob(player.current)
return
/datum/antagonist/proc/update_cur_max(var/lower_count, var/upper_count)
candidates = list()
var/main_type
if(ticker && ticker.mode)
if(ticker.mode.antag_tag && ticker.mode.antag_tag == id)
main_type = 1
else
return list()
cur_max = (main_type ? max_antags_round : max_antags)
if(ticker.mode.antag_scaling_coeff)
cur_max = Clamp((ticker.mode.num_players()/ticker.mode.antag_scaling_coeff), 1, cur_max)
/datum/antagonist/proc/attempt_spawn(var/lower_count, var/upper_count, var/ghosts_only)
world << "Attempting to spawn."
// Get the raw list of potential players.
update_cur_max(lower_count, upper_count)
candidates = get_candidates(ghosts_only)
// Update our boundaries.
if(!candidates.len)
world << "No candidates."
return 0
//Grab candidates randomly until we have enough.
while(candidates.len)
var/datum/mind/player = pick(candidates)
current_antagonists |= player
// Update job and role.
player.special_role = role_text
if(flags & ANTAG_OVERRIDE_JOB)
player.assigned_role = "MODE"
candidates -= player
world << "Done."
return 1
/datum/antagonist/proc/place_mob(var/mob/living/mob)
if(!starting_locations || !starting_locations.len)
return
mob.loc = pick(starting_locations)
/datum/antagonist/proc/add_antagonist(var/datum/mind/player)
if(!istype(player))
return 0
if(player in current_antagonists)
return 0
if(!can_become_antag(player))
return 0
current_antagonists |= player
apply(player)
finalize(player)
return 1
/datum/antagonist/proc/remove_antagonist(var/datum/mind/player, var/show_message, var/implanted)
if(player in current_antagonists)
player.current << "<span class='danger'><font size = 3>You are no longer a [role_text]!</font></span>"
current_antagonists -= player
player.special_role = null
update_icons_removed(player)
BITSET(player.current.hud_updateflag, SPECIALROLE_HUD)
return 1
return 0

View File

@@ -8,8 +8,6 @@ var/datum/antagonist/ert/ert
role_text_plural = "Emergency Responders"
welcome_text = "As member of the Emergency Response Team, you answer only to your leader and CentComm officials."
leader_welcome_text = "As leader of the Emergency Response Team, you answer only to CentComm, and have authority to override the Captain where it is necessary to achieve your mission goals. It is recommended that you attempt to cooperate with the captain where possible, however."
spawn_lower = 1
spawn_upper = 5
max_antags = 5
max_antags_round = 5 // ERT mode?

View File

@@ -6,10 +6,8 @@ var/datum/antagonist/highlander/highlanders
welcome_text = "There can be only one."
id = MODE_HIGHLANDER
flags = ANTAG_SUSPICIOUS | ANTAG_IMPLANT_IMMUNE //| ANTAG_RANDSPAWN | ANTAG_VOTABLE // Someday...
spawn_lower = 1
spawn_upper = 5
max_antags = 200 // No upper limit.
max_antags_round = 200
max_antags = 5
max_antags_round = 7
/datum/antagonist/highlander/New()
..()

View File

@@ -6,10 +6,8 @@ var/datum/antagonist/renegade/renegades
welcome_text = "Your own safety matters above all else, trust no one and kill anyone who gets in your way. However, armed as you are, now would be the perfect time to settle that score or grab that pair of yellow gloves you've been eyeing..."
id = MODE_RENEGADE
flags = ANTAG_SUSPICIOUS | ANTAG_IMPLANT_IMMUNE | ANTAG_RANDSPAWN | ANTAG_VOTABLE
spawn_lower = 1
spawn_upper = 5
max_antags = 200 // No upper limit.
max_antags_round = 200
max_antags = 5
max_antags_round = 7
var/list/spawn_guns = list(
/obj/item/weapon/gun/energy/taser,

View File

@@ -10,8 +10,6 @@ var/datum/antagonist/rogue_ai/malf
victory_text = "The AI has taken control of all of the station's systems."
loss_text = "The AI has been shut down!"
flags = ANTAG_OVERRIDE_MOB | ANTAG_VOTABLE
spawn_lower = 1
spawn_upper = 1
max_antags = 1
max_antags_round = 3