Skip to content

Commit

Permalink
refactor: Datumized Thief (#3387)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottfrei authored Aug 25, 2023
1 parent 789b564 commit f2c61b0
Show file tree
Hide file tree
Showing 24 changed files with 718 additions and 686 deletions.
10 changes: 7 additions & 3 deletions code/__HELPERS/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@
* Proc that collects all atoms of passed `path` in our atom contents
* and returns it in a list()
*/
/atom/proc/collect_all_atoms_of_type(path)
/atom/proc/collect_all_atoms_of_type(path, list/blacklist)
var/list/atoms = list()
if(src in blacklist)
return atoms
for(var/atom/check in contents)
if(check in blacklist)
continue
if(istype(check, path))
atoms += check
atoms |= check
if(length(check.contents))
check.collect_all_atoms_of_type(path)
atoms |= check.collect_all_atoms_of_type(path, blacklist)
return atoms
8 changes: 8 additions & 0 deletions code/__HELPERS/lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -903,3 +903,11 @@ proc/dd_sortedObjectList(list/incoming)
. = list()
for(var/thing in flat_list)
.[thing] = TRUE


/proc/listclearduplicates(check, list/list)
if(!istype(list))
stack_trace("Wrong type of list passed.")
return
while(check in list)
list -= check
73 changes: 45 additions & 28 deletions code/datums/mind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -581,17 +581,22 @@
else
. += "mindslave|<b>NO</b>"


/datum/mind/proc/memory_edit_thief()
. = _memory_edit_header("thief", list("traitorthief", "traitorthiefvamp", "traitorthiefchan", "thiefchan", "thiefvamp", "changelingthief", "vampirethief"))
if(src in SSticker.mode.thieves)
. += "<b><font color='red'>THIEF</font></b>|<a href='?src=[UID()];thief=clear'>no</a>|<a href='?src=[UID()];thief=equip'>Equip</a>"
if(!length(objectives))
var/datum/antagonist/thief/thief_datum = has_antag_datum(/datum/antagonist/thief)
if(thief_datum)
. += "<b><font color='red'>THIEF</font></b>|<a href='?src=[UID()];thief=clear'>no</a>"
if(ishuman(current))
. += "|<a href='?src=[UID()];thief=equip'>Equip</a>"
if(!length(thief_datum.objectives))
. += "<br>Objectives are empty! <a href='?src=[UID()];thief=autoobjectives'>Randomize!</a>"
else
. += "<a href='?src=[UID()];thief=thief'>thief</a>|<b>NO</b>"

. += _memory_edit_role_enabled(ROLE_THIEF)


/datum/mind/proc/memory_edit_silicon()
. = "<i><b>Silicon</b></i>: "
var/mob/living/silicon/silicon = current
Expand Down Expand Up @@ -1105,34 +1110,34 @@
return

if("thief collect")
if(!istype(objective, /datum/objective/collect))
new_objective = new /datum/objective/collect
if(!istype(objective, /datum/objective/steal/collect))
new_objective = new /datum/objective/steal/collect
new_objective.owner = src
else
new_objective = objective
var/datum/objective/collect/steal = new_objective
var/datum/objective/steal/collect/steal = new_objective
if(!steal.select_target())
to_chat(usr, "<span class='warning'>Цель не обнаружена. Выберите другую или создайте её.</span>")
return

if("thief pet")
if(!istype(objective, /datum/objective/steal_pet))
new_objective = new /datum/objective/steal_pet
if(!istype(objective, /datum/objective/steal/animal))
new_objective = new /datum/objective/steal/animal
new_objective.owner = src
else
new_objective = objective
var/datum/objective/steal_pet/steal = new_objective
var/datum/objective/steal/animal/steal = new_objective
if(!steal.select_target())
to_chat(usr, "<span class='warning'>Цель не обнаружена. Выберите другую или создайте её.</span>")
return

if("thief structure")
if(!istype(objective, /datum/objective/steal_structure))
new_objective = new /datum/objective/steal_structure
if(!istype(objective, /datum/objective/steal/structure))
new_objective = new /datum/objective/steal/structure
new_objective.owner = src
else
new_objective = objective
var/datum/objective/steal_structure/steal = new_objective
var/datum/objective/steal/structure/steal = new_objective
if(!steal.select_target())
to_chat(usr, "<span class='warning'>Цель не обнаружена. Выберите другую или создайте её.</span>")
return
Expand Down Expand Up @@ -2086,24 +2091,37 @@
remove_thief_role()
log_admin("[key_name(usr)] has de-thiefed [key_name(current)]")
message_admins("[key_name_admin(usr)] has de-thiefed [key_name_admin(current)]")

if("thief")
SSticker.mode.thieves += src
special_role = SPECIAL_ROLE_THIEF
SSticker.mode.update_thief_icons_added(src)
if(has_antag_datum(/datum/antagonist/thief))
return

var/datum/antagonist/thief/thief_datum = new()
thief_datum.silent = TRUE
thief_datum.give_objectives = FALSE
thief_datum.give_kit = FALSE
add_antag_datum(thief_datum)
SEND_SOUND(current, 'sound/ambience/antag/thiefalert.ogg')
to_chat(current, "<B><font color='red'>Мои [ishuman(current) ? "руки" : "лапы"] так и чешутся чего-нибудь прикарманить!</font></B>")
log_admin("[key_name(usr)] has thiefed [key_name(current)]")
message_admins("[key_name_admin(usr)] has thiefed [key_name_admin(current)]")

if("autoobjectives")
SSticker.mode.forge_thief_objectives(src)
var/datum/antagonist/thief/thief_datum = has_antag_datum(/datum/antagonist/thief)
if(!thief_datum)
return

thief_datum.give_objectives()
to_chat(usr, "<span class='notice'>The objectives for thief [key] have been generated. You can edit them and announce manually.</span>")
log_admin("[key_name(usr)] has automatically forged objectives for [key_name(current)]")
message_admins("[key_name_admin(usr)] has automatically forged objectives for [key_name_admin(current)]")

if("equip")
if(!ishuman(current))
to_chat(usr, "<span class='warning'>Некуда поместить экипировку!</span>")
var/datum/antagonist/thief/thief_datum = has_antag_datum(/datum/antagonist/thief)
if(!thief_datum)
return
SSticker.mode.equip_thief(current)

thief_datum.equip_thief_kit()
log_admin("[key_name(usr)] give [key_name(current)] thief equipment")
message_admins("[key_name_admin(usr)] give [key_name_admin(current)] thief equipment")

Expand Down Expand Up @@ -2516,8 +2534,12 @@


/datum/mind/proc/remove_thief_role()
if(src in SSticker.mode.thieves)
SSticker.mode.remove_thief(src)
var/datum/antagonist/thief/thief_datum = has_antag_datum(/datum/antagonist/thief)
if(!thief_datum)
return

remove_antag_datum(thief_datum)


/datum/mind/proc/remove_shadow_role()
SSticker.mode.update_shadow_icons_removed(src)
Expand Down Expand Up @@ -2701,13 +2723,8 @@


/datum/mind/proc/make_Thief()
if(!(src in SSticker.mode.thieves))
SSticker.mode.thieves += src
special_role = SPECIAL_ROLE_THIEF
SSticker.mode.forge_thief_objectives(src)
SSticker.mode.equip_thief(current)
SSticker.mode.update_thief_icons_added(src)
SSticker.mode.greet_thief(src)
if(!has_antag_datum(/datum/antagonist/thief))
add_antag_datum(/datum/antagonist/thief)

/datum/mind/proc/make_Abductor()
var/role = alert("Abductor Role ?","Role","Agent","Scientist")
Expand Down
1 change: 0 additions & 1 deletion code/game/gamemodes/changeling/thief_chan.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/datum/game_mode/thief/changeling
name = "thief+changeling(less)"
config_tag = "thiefchan"
thieves_amount = 3 //hard limit if scaling is turned off
restricted_jobs = list("AI", "Cyborg")
required_players = 15
required_enemies = 1 // how many of each type are required
Expand Down
2 changes: 1 addition & 1 deletion code/game/gamemodes/game_mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
var/list/protected_jobs = list()
/// Species that can't be antags.
var/list/protected_species = list()
/// Species duplicate for antags.
/// Species duplicate for antags. Remember to clear the list you get with [get_players_for_role()] from duplicate minds. See thief game mode setup.
var/list/prefered_species = list()
/// If prefered_species list is not empty antagonist mind with that specie will be duplicated passed number of times in get_players_for_role().
var/prefered_species_mod = 0
Expand Down
Loading

0 comments on commit f2c61b0

Please sign in to comment.