Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

//Initializes Jumping on the player
AddComponent(/datum/component/jumper)
AddComponent(/datum/component/violation_observer, violation_aoe)
if(CONFIG_GET(flag/swing_combat))
AddElement(/datum/element/swing_attack)
else if(CONFIG_GET(flag/directional_combat))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
storyteller_stats = create_new_stat_prefs(storyteller_stats)
become_area_sensitive(ZONE_TRAIT)
update_zone_hud(src, get_area(src)) // AREAS - (Zone hud)
RegisterSignal(src, COMSIG_MASQUERADE_VIOLATION, TYPE_PROC_REF(/atom/movable, on_masquerade_violation))

/mob/living/Destroy(force)
storyteller_stats = null
beastmaster_minions = null
minion_command_components = null
QDEL_LAZYLIST(splats)
UnregisterSignal(src, COMSIG_MASQUERADE_VIOLATION)
Comment on lines +6 to +13

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ehh... should probably register this on splat level if 'humans cant breach' as per on_observed_violation.

return ..()

/mob/living/set_pull_offsets(mob/living/mob_to_set, grab_state = GRAB_PASSIVE, animate = TRUE)
Expand Down
17 changes: 8 additions & 9 deletions modular_darkpack/modules/bodycameras/code/bodycamera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
///The camera itself, made when we need it and deleted on Destroy. Installed into the clothing item directly.
var/obj/machinery/camera/bodycamera/builtin_bodycamera
var/static/mutable_appearance/equipped_overlay = mutable_appearance('modular_darkpack/modules/bodycameras/icons/bodycamera_overlay.dmi', "bodycamera")

/obj/item/bodycam_upgrade/Initialize(mapload)
. = ..()
AddComponent(/datum/component/violation_observer, FALSE)
// the guy wearing it , temporary var until i figure out something better
var/mob/living/carbon/wearer

/obj/item/bodycam_upgrade/examine_more(mob/user)
. = ..()
Expand Down Expand Up @@ -107,10 +105,11 @@
playsound(loc, 'sound/machines/beep/beep.ogg', get_clamped_volume(), TRUE, -1)
builtin_bodycamera.network = network //sync the network of the camera to us, the upgrade.
builtin_bodycamera.camera_enabled = TRUE
var/datum/component/violation_observer/violation_component = src.GetComponent(/datum/component/violation_observer)
var/obj/item/clothing = loc
var/mob/living/carbon/wearer = iscarbon(clothing.loc) // interacting_with_atom forces us to be on an /obj/item/clothing on a mob
violation_component.toggle_area_of_effect(wearer)
if(!iscarbon(clothing.loc))
return
wearer = clothing.loc // interacting_with_atom forces us to be on an /obj/item/clothing on a mob
wearer.toggle_masquerade_sensitivity(TRUE)
log_game("BODYCAM TOGGLE: [(user ? key_name(user) : "SYSTEM")] turned ON [src] ([builtin_bodycamera.c_tag]) at [loc_name(src)].")

///Turns the camera off. Will be silent if 'user' is null.
Expand All @@ -120,8 +119,8 @@
playsound(loc, 'sound/machines/beep/beep.ogg', get_clamped_volume(), TRUE, -1)
if(builtin_bodycamera)
builtin_bodycamera.camera_enabled = FALSE
var/datum/component/violation_observer/violation_component = src.GetComponent(/datum/component/violation_observer)
violation_component.toggle_area_of_effect()
wearer.toggle_masquerade_sensitivity(FALSE)
wearer = null
log_game("BODYCAM TOGGLE: [(user ? key_name(user) : "SYSTEM")] turned OFF [src] at [loc_name(src)].")

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
. = ..()
REGISTER_REQUIRED_MAP_ITEM(1, 1)
GLOB.blood_hunt_announcers += src
AddComponent(/datum/component/violation_observer, FALSE)

/obj/item/blood_hunt/Destroy(force)
GLOB.blood_hunt_announcers -= src
Expand Down
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
// Used for things that detect masquerade violations.
// Usually NPCs or cameras.
/datum/component/violation_observer
dupe_mode = COMPONENT_DUPE_UNIQUE
var/datum/proximity_monitor/advanced/violation_check_aoe/area_of_effect
/// Time between us checking for violations
COOLDOWN_DECLARE(scan_cooldown)
var/list/breached_players

/datum/component/violation_observer/Initialize(add_area_of_effect) //Only add the AOE checker for NPCs and camera objects.
if(add_area_of_effect)
area_of_effect = new(parent, 7, TRUE, src)
breached_players = new()

/datum/component/violation_observer/RegisterWithParent()
RegisterSignal(parent, COMSIG_SEEN_MASQUERADE_VIOLATION, PROC_REF(on_observed_violation))
RegisterSignal(parent, COMSIG_MASQUERADE_REINFORCE, PROC_REF(on_masquerade_violation_reinforced))
RegisterSignals(parent, list(COMSIG_LIVING_DEATH, COMSIG_ALL_MASQUERADE_REINFORCE), PROC_REF(on_death))

/datum/component/violation_observer/UnregisterFromParent(force, silent)
QDEL_NULL(area_of_effect)
breached_players = null
UnregisterSignal(parent, list(COMSIG_SEEN_MASQUERADE_VIOLATION, COMSIG_MASQUERADE_REINFORCE, COMSIG_LIVING_DEATH, COMSIG_ALL_MASQUERADE_REINFORCE))

/datum/component/violation_observer/proc/toggle_area_of_effect(origin = parent)
if(area_of_effect)
QDEL_NULL(area_of_effect)
/atom/movable
var/violation_observer = FALSE
COOLDOWN_DECLARE(masquerade_violation_cooldown)

/atom/movable/proc/toggle_masquerade_sensitivity(new_listening_state)
// don't proceed if we're toggling to TRUE on something already listening
if(!isnull(new_listening_state) && new_listening_state == violation_observer)
return

// if we don't pass an arg just flip the switch
if(isnull(new_listening_state))
violation_observer = !violation_observer
else
violation_observer = new_listening_state

if(violation_observer)
RegisterSignal(src, COMSIG_SEEN_MASQUERADE_VIOLATION, PROC_REF(on_observed_violation))
RegisterSignal(src, COMSIG_MASQUERADE_REINFORCE, PROC_REF(on_masquerade_violation_reinforced))
RegisterSignals(src, list(COMSIG_LIVING_DEATH, COMSIG_ALL_MASQUERADE_REINFORCE), PROC_REF(on_masquerade_witness_death))
else
area_of_effect = new(origin, 7, TRUE, src)
UnregisterSignal(src, list(COMSIG_SEEN_MASQUERADE_VIOLATION, COMSIG_MASQUERADE_REINFORCE, COMSIG_LIVING_DEATH, COMSIG_ALL_MASQUERADE_REINFORCE))

/datum/component/violation_observer/proc/on_observed_violation(atom/source, mob/living/player_breacher)
/atom/movable/proc/on_masquerade_violation()
if(!COOLDOWN_FINISHED(src, masquerade_violation_cooldown))
return
var/area/vtm/breacher_area = get_area(src)
if(!istype(breacher_area, /area/vtm))
return
if(breacher_area.zone_type != ZONE_MASQUERADE)
return
for(var/atom/movable/moving_atom in view(7, loc))
if(!moving_atom.violation_observer)
continue
SEND_SIGNAL(moving_atom, COMSIG_SEEN_MASQUERADE_VIOLATION, src)
COOLDOWN_START(src, masquerade_violation_cooldown, 1 TURNS)

/atom/movable/proc/on_observed_violation(atom/source, atom/movable/player_breacher)
SIGNAL_HANDLER

if(!source || !player_breacher || ismundane(player_breacher)) //Humans cant break the masquerade. Because reasons.
return

if(isliving(source))
var/mob/living/mob_parent = source
if(mob_parent.stat == DEAD)
return
if(!INCAPACITATED_IGNORING(mob_parent, INCAPABLE_RESTRAINTS))
mob_parent.face_atom(player_breacher)
source.observe_masquerade_violation(player_breacher)
Expand All @@ -48,43 +56,48 @@
animate(exclamation, pixel_z = 32, alpha = 255, time = 0.5 SECONDS, easing = ELASTIC_EASING)

source.AddComponent(/datum/component/masquerade_hud, player_breacher)
breached_players += player_breacher
SSmasquerade.masquerade_breach(source, player_breacher, (isliving(source) ? MASQUERADE_REASON_NPC : MASQUERADE_REASON_OBJECT))
RegisterSignal(player_breacher, COMSIG_LIVING_DEATH, PROC_REF(on_breacher_death))
RegisterSignal(player_breacher, COMSIG_LIVING_DEATH, PROC_REF(on_breacher_death), override = TRUE) // override is for breaching multiple times on the same violation observer - on_breacher_death handles all violations, not just the breach created here, so we only need one register

return TRUE

/datum/component/violation_observer/proc/on_masquerade_violation_reinforced(atom/source, mob/living/player_breacher)
/atom/movable/proc/on_masquerade_violation_reinforced(atom/source, atom/movable/player_breacher)
SIGNAL_HANDLER

if(player_breacher in breached_players)
SEND_SIGNAL(source, COMSIG_MASQUERADE_HUD_DELETE, player_breacher)
SSmasquerade.masquerade_reinforce(source, player_breacher)
source.observe_masquerade_reinforce(player_breacher)
breached_players -= player_breacher
for(var/breach in SSmasquerade.masquerade_breachers)
if(breach[1] != player_breacher)
continue
if(breach[2] != src)
continue
SEND_SIGNAL(src, COMSIG_MASQUERADE_HUD_DELETE, player_breacher)
SSmasquerade.masquerade_reinforce(src, player_breacher)
src.observe_masquerade_reinforce(player_breacher)
UnregisterSignal(player_breacher, COMSIG_LIVING_DEATH)

return TRUE

/datum/component/violation_observer/proc/on_death(atom/source)
/atom/movable/proc/on_masquerade_witness_death()
SIGNAL_HANDLER

for(var/mob/player_breacher in breached_players)
if(!QDELETED(player_breacher))
SEND_SIGNAL(source, COMSIG_MASQUERADE_HUD_DELETE, player_breacher)
SSmasquerade.masquerade_reinforce(source, player_breacher)
source.observe_masquerade_reinforce(player_breacher)
breached_players -= player_breacher
for(var/breach in SSmasquerade.masquerade_breachers)
var/mob/living/player_breacher = breach[1]
var/atom/breach_witness = breach[2]
if(breach_witness != src)
continue
SEND_SIGNAL(src, COMSIG_MASQUERADE_HUD_DELETE, player_breacher)
SSmasquerade.masquerade_reinforce(src, player_breacher)
observe_masquerade_reinforce(player_breacher)
UnregisterSignal(player_breacher, COMSIG_LIVING_DEATH)

/datum/component/violation_observer/proc/on_breacher_death(mob/living/dead_breacher, gibbed)
/atom/movable/proc/on_breacher_death(mob/living/dead_breacher, gibbed)
SIGNAL_HANDLER

if(dead_breacher in breached_players)
var/atom/parent_atom = parent
SEND_SIGNAL(parent, COMSIG_MASQUERADE_HUD_DELETE, dead_breacher)
SSmasquerade.masquerade_reinforce(parent, dead_breacher)
parent_atom.observe_masquerade_reinforce(dead_breacher)
breached_players -= dead_breacher
for(var/breach in SSmasquerade.masquerade_breachers)
if(breach[1] != dead_breacher)
continue
SEND_SIGNAL(src, COMSIG_MASQUERADE_HUD_DELETE, dead_breacher)
SSmasquerade.masquerade_reinforce(src, dead_breacher)
observe_masquerade_reinforce(dead_breacher)
UnregisterSignal(dead_breacher, COMSIG_LIVING_DEATH)

/atom/proc/observe_masquerade_violation(player_breacher)
Expand Down

This file was deleted.

30 changes: 12 additions & 18 deletions modular_darkpack/modules/masquerade/code/subsystem/masquerade.dm
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ SUBSYSTEM_DEF(masquerade)
* player_breacher - The player which caused the masquerade breach.
* reason - Optional, the reason for the breach. For example,
*/
/datum/controller/subsystem/masquerade/proc/masquerade_reinforce(atom/source, mob/living/player_breacher, reason)
/datum/controller/subsystem/masquerade/proc/masquerade_reinforce(atom/source, mob/living/player_breacher)
. = FALSE
for(var/masquerade_breach in masquerade_breachers)
var/breach_sources = masquerade_breach[2]
var/breach_reasons = masquerade_breach[3]

var/source_matches = FALSE
// breach_sources can be a list if there is more than one blood skull, handle for that
Expand All @@ -58,17 +57,12 @@ SUBSYSTEM_DEF(masquerade)
else
source_matches = (source == breach_sources)

if(source_matches || reason == "debug")
if(!reason || (reason in masquerade_breach) || (reason == MASQUERADE_REASON_PREFERENCES) || (reason == "debug"))
// Only require blood hunt skull for "Preferences" (round-persistent) breaches
if(breach_reasons == MASQUERADE_REASON_PREFERENCES && !istype(source, /obj/item/blood_hunt))
continue

masquerade_breachers -= list(masquerade_breach)
masquerade_level = min(MASQUERADE_MAX_LEVEL, masquerade_level + 1)
player_breacher.masquerade_score = min(5, player_breacher.masquerade_score + 1)
. = TRUE
break
if(source_matches)
masquerade_breachers -= list(masquerade_breach)
masquerade_level = min(MASQUERADE_MAX_LEVEL, masquerade_level + 1)
player_breacher.masquerade_score = min(5, player_breacher.masquerade_score + 1)
. = TRUE
break
if(player_breacher.masquerade_score == 5) //Doesn't matter if they weren't in one of these lists.
GLOB.veil_breakers_list -= player_breacher
GLOB.masquerade_breakers_list -= player_breacher
Expand All @@ -90,13 +84,13 @@ SUBSYSTEM_DEF(masquerade)
* player_breacher - The player which caused the masquerade breach.
* reason - The reason for the breach. For example,
*/
/datum/controller/subsystem/masquerade/proc/masquerade_breach(atom/source, mob/living/player_breacher, reason)
log_game("[player_breacher] has caused a masquerade breach in front of [source] by [reason]")
/datum/controller/subsystem/masquerade/proc/masquerade_breach(atom/source, mob/living/player_breacher)
log_game("[player_breacher] has caused a masquerade breach in front of [source]")
var/pre_breach_score = player_breacher.masquerade_score
if(pre_breach_score == 0)
return
player_breacher.masquerade_score = max(0, player_breacher.masquerade_score - 1)
masquerade_breachers += list(list(player_breacher, source, reason))
masquerade_breachers += list(list(player_breacher, source))
if(get_vampire_splat(player_breacher))
GLOB.masquerade_breakers_list |= player_breacher
GLOB.supernatural_breakers_list |= player_breacher
Expand Down Expand Up @@ -161,7 +155,7 @@ SUBSYSTEM_DEF(masquerade)
var/list/masquerade_breach_list = masquerade_breach
if(islist(masquerade_breach_list[2])) //If its the skull list, then its a long term masq breach. Clear it.
for(var/atom/list_object as anything in masquerade_breach_list[2])
SSmasquerade.masquerade_reinforce(list_object, masquerade_breach_list[1], MASQUERADE_REASON_PREFERENCES)
SSmasquerade.masquerade_reinforce(list_object, masquerade_breach_list[1])
return
else
var/atom/object = masquerade_breach_list[2]
Expand All @@ -183,7 +177,7 @@ SUBSYSTEM_DEF(masquerade)
var/list/masquerade_breach_list = masquerade_breach
if(islist(masquerade_breach_list[2])) //If its the skull list, then its a long term masq breach. Clear it.
for(var/atom/list_object as anything in masquerade_breach_list[2])
SSmasquerade.masquerade_reinforce(list_object, masquerade_breach_list[1], MASQUERADE_REASON_PREFERENCES)
SSmasquerade.masquerade_reinforce(list_object, masquerade_breach_list[1])
else
var/atom/object = masquerade_breach_list[2]
SEND_SIGNAL(object, COMSIG_ALL_MASQUERADE_REINFORCE)
Expand Down
2 changes: 2 additions & 0 deletions modular_darkpack/modules/npc/code/human/__npc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
RegisterSignal(src, COMSIG_LIVING_MOB_BUMPED, PROC_REF(handle_bumped))
// Be annoyed if helped
RegisterSignal(src, COMSIG_CARBON_HELP_ACT, PROC_REF(handle_helped))
// all npcs are masquerade violators by default so flip it to true
toggle_masquerade_sensitivity(TRUE)
return INITIALIZE_HINT_LATELOAD

/mob/living/carbon/human/npc/LateInitialize(mapload)
Expand Down
1 change: 0 additions & 1 deletion modular_darkpack/modules/phones/code/_phone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
wiki_book = new()
become_hearing_sensitive(ROUNDSTART_TRAIT)
RegisterSignal(src, COMSIG_MOVABLE_HEAR, PROC_REF(handle_hearing))
AddComponent(/datum/component/violation_observer, FALSE)
phone_background = "BG_[rand(1,18)]" // pick a random phone background when spawned

/obj/item/smartphone/proc/update_initialized_contacts()
Expand Down
Loading
Loading