Skip to content

Commit

Permalink
Merge pull request #15 from RadiantFlash7/Towner-home-claims
Browse files Browse the repository at this point in the history
Towner home claims
  • Loading branch information
TheGreatKitsune authored Sep 17, 2024
2 parents 3b3623d + 55bc314 commit 21c4fcf
Show file tree
Hide file tree
Showing 7 changed files with 223 additions and 45 deletions.
72 changes: 34 additions & 38 deletions _maps/map_files/dun_manor/dun_manor.dmm

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/datum/class_register
var/id = null
var/list/registered_messages = list()
var/list/listening_mobs = list()

/datum/class_register/proc/add_listener(mob/listener)
for(var/msg in registered_messages)
to_chat(listener, span_notice(msg))
listening_mobs += listener

/datum/class_register/proc/remove_listener(mob/listener)
listening_mobs -= listener

/datum/class_register/proc/add_message(msg, mob/invoker)
for(var/mob/listener as anything in listening_mobs)
if(listener == invoker)
continue
to_chat(listener, span_notice(msg))
registered_messages += msg
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
var/PQ_boost_divider = 0

/*
/*
This list is organized like so
class_cat_alloc_attempts = list(CTAG_PILGRIM = 5, CTAG_ADVENTURER = 3, etc)
Wherein you will have this datum attempt to roll you up 5 pilgrim category classes, and 3 adventurer class categories
Expand All @@ -20,7 +20,7 @@
// Whether we bypass reqs on class cat alloc attempts
var/class_cat_alloc_bypass_reqs = FALSE

/*
/*
This list is organized exactly like the class_cat_alloc_attempts the numbers dictate how many plusboosts we give to the category
class_cat_alloc_attempts = list(CTAG_PILGRIM = 3, CTAG_ADVENTURER = 2, etc)
If you put a number in, it will attempt to allocate it to the cat
Expand Down Expand Up @@ -63,9 +63,13 @@

//classes we rolled, basically you get a datum followed by a number in here on how many times you rerolled it.
var/list/rolled_classes = list()
// The register id we use- CC EDIT
var/register_id = null //CC Edit

// The normal route for first use of this list.
/datum/class_select_handler/proc/initial_setup()
if(register_id)
SSrole_class_handler.add_class_register_listener(register_id, linked_client.mob)
assemble_the_CLASSES()
second_step()

Expand All @@ -77,9 +81,11 @@
browser_slop()

/datum/class_select_handler/Destroy()
if(register_id) //CC Edit
SSrole_class_handler.remove_class_register_listener(register_id, linked_client.mob) // CC Edit
ForceCloseMenus() // force menus closed
// Cleanup anything holding references, aka these lists holding refs to class datums and the other two
linked_client = null
linked_client = null
cur_picked_class = null
class_cat_alloc_attempts = null
forced_class_additions = null
Expand Down Expand Up @@ -197,7 +203,7 @@

if(possible_list.len)
rolled_classes[pick(possible_list)] = 0

if(cur_picked_class == filled_class)
if(special_session_queue && cur_picked_class in special_session_queue)
special_selected = FALSE
Expand Down Expand Up @@ -251,7 +257,7 @@

//Buttondiv Segment
data += "<div class='footer'>"
data += {"
data += {"
<a class='mo_bottom_buttons' href='?src=\ref[src];show_challenge_class=1'>[showing_challenge_classes ? "Hide Challenge Classes" : "Show Challenge Classes"]</a>
</div>
"}
Expand Down Expand Up @@ -309,7 +315,7 @@

// Safety check. Make sure the thing that got rammed into the href is actually in the rolled list
// Unless its a challenge class then everyone can jus see it via a click of the button anyways
if(locvar_check in rolled_classes)
if(locvar_check in rolled_classes)
plus_power = rolled_classes[locvar_check] // Get the plus power too
cur_picked_class = locvar_check
class_select_slop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ SUBSYSTEM_DEF(role_class_handler)
/// Whether bandits have been injected in the game
var/bandits_in_round = FALSE

/// Assoc list of class registers to keep track of what townies and migrant parties are and message listeners- CC Edit
var/list/class_registers = list()//CC Edit


/*
We init and build the retard azz listszz
Expand Down Expand Up @@ -70,7 +73,11 @@ SUBSYSTEM_DEF(role_class_handler)
We setup the class handler here, aka the menu
We will cache it per server session via an assc list with a ckey leading to the datum.
*/
/datum/controller/subsystem/role_class_handler/proc/setup_class_handler(mob/living/carbon/human/H, advclass_rolls_override = null)
/datum/controller/subsystem/role_class_handler/proc/setup_class_handler(mob/living/carbon/human/H, advclass_rolls_override = null, register_id = null)
// Bandaid to this extremely badly coded system
if(!register_id)
if(H.job == "Towner")
register_id = "towner"
// insure they somehow aren't closing the datum they got and opening a new one w rolls
var/datum/class_select_handler/GOT_IT = class_select_handlers[H.client.ckey]
if(GOT_IT)
Expand Down Expand Up @@ -101,6 +108,7 @@ SUBSYSTEM_DEF(role_class_handler)
if(XTRA_SPECIAL.maximum_possible_slots > XTRA_SPECIAL.total_slots_occupied)
XTRA_MEATY.special_session_queue += XTRA_SPECIAL

XTRA_MEATY.register_id = register_id
XTRA_MEATY.initial_setup()
class_select_handlers[H.client.ckey] = XTRA_MEATY

Expand Down Expand Up @@ -129,6 +137,8 @@ SUBSYSTEM_DEF(role_class_handler)
if(plus_factor)
picked_class.boost_by_plus_power(plus_factor, H)

if(related_handler.register_id)
add_class_register_msg(related_handler.register_id, "[H.real_name] is the [picked_class.name]", related_handler.linked_client.mob)

// In retrospect, If I don't just delete these Ill have to actually attempt to keep track of when a byond browser window is actually open lol
// soooo..... this will be the place where we take it out, as it means they finished class selection, and we can safely delete the handler.
Expand All @@ -155,4 +165,30 @@ SUBSYSTEM_DEF(role_class_handler)



/datum/controller/subsystem/role_class_handler/proc/get_advclass_by_name(advclass_name)
for(var/category in sorted_class_categories)
for(var/datum/advclass/class as anything in sorted_class_categories[category])
if(class.name != advclass_name)
continue
return class
return null


/datum/controller/subsystem/role_class_handler/proc/get_class_register(register_id)
if(!class_registers[register_id])
var/datum/class_register/register = new /datum/class_register()
register.id = register_id
class_registers[register_id] = register
return class_registers[register_id]

/datum/controller/subsystem/role_class_handler/proc/add_class_register_msg(register_id, msg, mob/invoker)
var/datum/class_register/register = get_class_register(register_id)
register.add_message(msg, invoker)

/datum/controller/subsystem/role_class_handler/proc/add_class_register_listener(register_id, mob/listener)
var/datum/class_register/register = get_class_register(register_id)
register.add_listener(listener)

/datum/controller/subsystem/role_class_handler/proc/remove_class_register_listener(register_id, mob/listener)
var/datum/class_register/register = get_class_register(register_id)
register.remove_listener(listener)
118 changes: 118 additions & 0 deletions code/game/objects/structures/mineral_doors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,69 @@
var/kickthresh = 15
var/swing_closed = TRUE

/// Whether to grant a resident_key- CC Edit Start
var/grant_resident_key = FALSE
var/resident_key_amount = 1
/// The type of a key the resident will get
var/resident_key_type
/// The required role of the resident
var/resident_role
/// The requied advclass of the resident
var/resident_advclass
//CC Edit Ends.
damage_deflection = 10

/obj/structure/mineral_door/proc/try_award_resident_key(mob/user)//CC Edit Starts
if(!grant_resident_key)
return FALSE
if(!lockid)
return FALSE
if(!ishuman(user))
return FALSE
var/mob/living/carbon/human/human = user
if(human.received_resident_key)
return FALSE
if(resident_role)
var/datum/job/job = SSjob.name_occupations[human.job]
if(job.type != resident_role)
return FALSE
if(resident_advclass)
if(!human.advjob)
return FALSE
var/datum/advclass/advclass = SSrole_class_handler.get_advclass_by_name(human.advjob)
if(!advclass)
return FALSE
if(advclass.type != resident_advclass)
return FALSE
var/alert = alert(user, "Is this my home?", "Home", "Yes", "No")
if(alert != "Yes")
return
if(!grant_resident_key)
return
var/spare_key = alert(user, "Have I got an extra spare key?", "Home", "Yes", "No")
if(!grant_resident_key)
return
if(spare_key == "Yes")
resident_key_amount = 2
else
resident_key_amount = 1
for(var/i in 1 to resident_key_amount)
var/obj/item/roguekey/key
if(resident_key_type)
key = new resident_key_type(get_turf(human))
else
key = new /obj/item/roguekey(get_turf(human))
key.lockid = lockid
key.lockhash = lockhash
human.put_in_hands(key)
human.received_resident_key = TRUE
grant_resident_key = FALSE
if(resident_key_amount > 1)
to_chat(human, span_notice("They're just where I left them..."))
else
to_chat(human, span_notice("It's just where I left it..."))
return TRUE //CC Edit ends

/obj/structure/mineral_door/onkick(mob/user)
if(isSwitchingStates)
return
Expand Down Expand Up @@ -109,6 +170,8 @@
if(!base_state)
base_state = icon_state
air_update_turf(TRUE)
if(grant_resident_key && !lockid) //CC edit
lockid = "random_lock_id_[rand(1,9999999)]" // I know, not foolproof- CC edit
if(lockhash)
GLOB.lockhashes += lockhash
else if(keylock)
Expand Down Expand Up @@ -180,6 +243,8 @@
return
if(isSwitchingStates)
return
if(try_award_resident_key(user))
return
if(locked)
if(isliving(user))
var/mob/living/L = user
Expand Down Expand Up @@ -798,3 +863,56 @@
closeSound = 'modular/Neu_Food/sound/blindsclose.ogg'
dir = NORTH
locked = TRUE

/obj/structure/mineral_door/wood/towner
locked = TRUE
keylock = TRUE
grant_resident_key = TRUE
resident_key_type = /obj/item/roguekey/townie
resident_role = /datum/job/roguetown/villager
lockid = null //Will be randomized

/obj/structure/mineral_door/wood/towner/generic

/obj/structure/mineral_door/wood/towner/generic/two_keys
resident_key_amount = 2

/obj/structure/mineral_door/wood/towner/blacksmith
resident_advclass = /datum/advclass/blacksmith
lockid = "towner_blacksmith"

/obj/structure/mineral_door/wood/towner/carpenter
resident_advclass = /datum/advclass/carpenter
lockid = "towner_carpenter"

/obj/structure/mineral_door/wood/towner/cheesemaker
resident_advclass = /datum/advclass/cheesemaker
lockid = "towner_cheesemaker"

/obj/structure/mineral_door/wood/towner/hunter
resident_advclass = /datum/advclass/hunter
lockid = "towner_hunter"

/obj/structure/mineral_door/wood/towner/miner
resident_advclass = /datum/advclass/miner
lockid = "towner_miner"

/obj/structure/mineral_door/wood/towner/farmer
resident_advclass = /datum/advclass/peasant
lockid = "towner_farmer"

/obj/structure/mineral_door/wood/towner/seamstress
resident_advclass = /datum/advclass/seamstress
lockid = "towner_seamstress"

/obj/structure/mineral_door/wood/towner/towndoctor
resident_advclass = /datum/advclass/towndoctor
lockid = "towner_towndoctor"

/obj/structure/mineral_door/wood/towner/woodcutter
resident_advclass = /datum/advclass/woodcutter
lockid = "towner_woodcutter"

/obj/structure/mineral_door/wood/towner/fisher
resident_advclass = /datum/advclass/fisher
lockid = "towner_fisher"
2 changes: 2 additions & 0 deletions code/modules/mob/living/carbon/human/human_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@
var/flavortext = null
var/ooc_notes = null

var/received_resident_key = FALSE

possible_rmb_intents = list(/datum/rmb_intent/feint,\
/datum/rmb_intent/aimed,\
/datum/rmb_intent/strong,\
Expand Down
1 change: 1 addition & 0 deletions roguetown.dme
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@
#include "code\controllers\subsystem\rogue\todchange.dm"
#include "code\controllers\subsystem\rogue\treasury.dm"
#include "code\controllers\subsystem\rogue\water_level.dm"
#include "code\controllers\subsystem\rogue\role_class_handler\class_register.dm"
#include "code\controllers\subsystem\rogue\role_class_handler\role_class_handler.dm"
#include "code\controllers\subsystem\rogue\role_class_handler\class_select_handler\class_select_handler.dm"
#include "code\controllers\subsystem\rogue\triumphs\triumph_adjust_procs.dm"
Expand Down

0 comments on commit 21c4fcf

Please sign in to comment.