Merge branch 'master' of https://github.com/Citadel-Station-13/Citadel-Station-13 into Ghommie-cit655
This commit is contained in:
@@ -1,66 +1,48 @@
|
||||
GLOBAL_LIST_EMPTY(ghost_eligible_mobs)
|
||||
|
||||
GLOBAL_LIST_EMPTY(client_ghost_timeouts)
|
||||
|
||||
/datum/element/ghost_role_eligibility
|
||||
element_flags = ELEMENT_DETACH | ELEMENT_BESPOKE
|
||||
id_arg_index = 3
|
||||
var/list/timeouts = list()
|
||||
var/list/mob/eligible_mobs = list()
|
||||
id_arg_index = 2
|
||||
var/penalizing = FALSE
|
||||
var/free_ghost = FALSE
|
||||
|
||||
/datum/element/ghost_role_eligibility/Attach(datum/target,penalize = FALSE,free_ghosting = FALSE, penalize_on_ghost = FALSE)
|
||||
/datum/element/ghost_role_eligibility/Attach(datum/target,free_ghosting = FALSE, penalize_on_ghost = FALSE)
|
||||
. = ..()
|
||||
if(!ismob(target))
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
penalizing = penalize_on_ghost
|
||||
free_ghost = free_ghosting
|
||||
var/mob/M = target
|
||||
if(!(M in eligible_mobs))
|
||||
eligible_mobs += M
|
||||
if(penalize) //penalizing them from making a ghost role / midround antag comeback right away.
|
||||
var/penalty = CONFIG_GET(number/suicide_reenter_round_timer) MINUTES
|
||||
var/roundstart_quit_limit = CONFIG_GET(number/roundstart_suicide_time_limit) MINUTES
|
||||
if(world.time < roundstart_quit_limit) //add up the time difference to their antag rolling penalty if they quit before half a (ingame) hour even passed.
|
||||
penalty += roundstart_quit_limit - world.time
|
||||
if(penalty)
|
||||
penalty += world.realtime
|
||||
if(SSautotransfer.can_fire && SSautotransfer.maxvotes)
|
||||
var/maximumRoundEnd = SSautotransfer.starttime + SSautotransfer.voteinterval * SSautotransfer.maxvotes
|
||||
if(penalty - SSshuttle.realtimeofstart > maximumRoundEnd + SSshuttle.emergencyCallTime + SSshuttle.emergencyDockTime + SSshuttle.emergencyEscapeTime)
|
||||
penalty = CANT_REENTER_ROUND
|
||||
if(!(M.ckey in timeouts))
|
||||
timeouts += M.ckey
|
||||
timeouts[M.ckey] = 0
|
||||
else if(timeouts[M.ckey] == CANT_REENTER_ROUND)
|
||||
return
|
||||
timeouts[M.ckey] = max(timeouts[M.ckey],penalty)
|
||||
RegisterSignal(M,COMSIG_MOB_GHOSTIZE,.proc/get_ghost_flags)
|
||||
if(!(M in GLOB.ghost_eligible_mobs))
|
||||
GLOB.ghost_eligible_mobs += M
|
||||
RegisterSignal(M, COMSIG_MOB_GHOSTIZE, .proc/get_ghost_flags)
|
||||
|
||||
/datum/element/ghost_role_eligibility/Detach(mob/M)
|
||||
. = ..()
|
||||
if(M in eligible_mobs)
|
||||
eligible_mobs -= M
|
||||
if(M in GLOB.ghost_eligible_mobs)
|
||||
GLOB.ghost_eligible_mobs -= M
|
||||
UnregisterSignal(M, COMSIG_MOB_GHOSTIZE)
|
||||
|
||||
/datum/element/ghost_role_eligibility/proc/get_all_ghost_role_eligible(silent = FALSE)
|
||||
/proc/get_all_ghost_role_eligible(silent = FALSE)
|
||||
var/list/candidates = list()
|
||||
for(var/m in eligible_mobs)
|
||||
for(var/m in GLOB.ghost_eligible_mobs)
|
||||
var/mob/M = m
|
||||
if(M.can_reenter_round(TRUE))
|
||||
candidates += M
|
||||
return candidates
|
||||
|
||||
/mob/proc/can_reenter_round(silent = FALSE)
|
||||
var/datum/element/ghost_role_eligibility/eli = SSdcs.GetElement(list(/datum/element/ghost_role_eligibility))
|
||||
return eli.can_reenter_round(src,silent)
|
||||
|
||||
/datum/element/ghost_role_eligibility/proc/can_reenter_round(var/mob/M,silent = FALSE)
|
||||
if(!(M in eligible_mobs))
|
||||
if(!(src in GLOB.ghost_eligible_mobs))
|
||||
return FALSE
|
||||
if(!(M.ckey in timeouts))
|
||||
if(!(ckey in GLOB.client_ghost_timeouts))
|
||||
return TRUE
|
||||
var/timeout = timeouts[M.ckey]
|
||||
var/timeout = GLOB.client_ghost_timeouts[ckey]
|
||||
if(timeout != CANT_REENTER_ROUND && timeout <= world.realtime)
|
||||
return TRUE
|
||||
if(!silent && M.client)
|
||||
to_chat(M, "<span class='warning'>You are unable to reenter the round[timeout != CANT_REENTER_ROUND ? " yet. Your ghost role blacklist will expire in [DisplayTimeText(timeout - world.realtime)]" : ""].</span>")
|
||||
if(!silent && client)
|
||||
to_chat(src, "<span class='warning'>You are unable to reenter the round[timeout != CANT_REENTER_ROUND ? " yet. Your ghost role blacklist will expire in [DisplayTimeText(timeout - world.realtime)]" : ""].</span>")
|
||||
return FALSE
|
||||
|
||||
/datum/element/ghost_role_eligibility/proc/get_ghost_flags()
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
lefthand_file = 'icons/mob/animals_held_lh.dmi'
|
||||
icon_state = ""
|
||||
w_class = WEIGHT_CLASS_BULKY
|
||||
dynamic_hair_suffix = ""
|
||||
var/mob/living/held_mob
|
||||
|
||||
/obj/item/clothing/head/mob_holder/Initialize(mapload, mob/living/target, worn_state, alt_worn, right_hand, left_hand, slots = NONE)
|
||||
@@ -162,6 +163,11 @@
|
||||
L.visible_message("<span class='warning'>[held_mob] escapes from [L]!</span>", "<span class='warning'>[held_mob] escapes your grip!</span>")
|
||||
release()
|
||||
|
||||
/obj/item/clothing/head/mob_holder/mob_can_equip(mob/living/M, mob/living/equipper, slot, disable_warning = FALSE, bypass_equip_delay_self = FALSE)
|
||||
if(!ishuman(M)) //monkeys holding monkeys holding monkeys...
|
||||
return FALSE
|
||||
return ..()
|
||||
|
||||
/obj/item/clothing/head/mob_holder/assume_air(datum/gas_mixture/env)
|
||||
var/atom/location = loc
|
||||
if(!loc)
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/datum/element/spellcasting //allows to cast certain spells or skip requirements.
|
||||
element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH
|
||||
id_arg_index = 2
|
||||
var/cast_flags
|
||||
var/cast_slots
|
||||
var/list/users_by_item = list()
|
||||
var/list/stacked_spellcasting_by_user = list()
|
||||
|
||||
/datum/element/spellcasting/Attach(datum/target, _flags, _slots)
|
||||
. = ..()
|
||||
if(isitem(target))
|
||||
RegisterSignal(target, COMSIG_ITEM_EQUIPPED, .proc/on_equip)
|
||||
RegisterSignal(target, COMSIG_ITEM_DROPPED, .proc/on_drop)
|
||||
else if(ismob(target))
|
||||
RegisterSignal(target, COMSIG_MOB_SPELL_CAST_CHECK, .proc/on_cast)
|
||||
stacked_spellcasting_by_user[target]++
|
||||
else
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
cast_flags = _flags
|
||||
cast_slots = _slots
|
||||
|
||||
/datum/element/spellcasting/Detach(datum/target)
|
||||
. = ..()
|
||||
UnregisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED, COMSIG_MOB_SPELL_CAST_CHECK))
|
||||
if(users_by_item[target])
|
||||
var/mob/user = users_by_item[target]
|
||||
stacked_spellcasting_by_user[user]--
|
||||
if(!stacked_spellcasting_by_user[user])
|
||||
stacked_spellcasting_by_user -= user
|
||||
UnregisterSignal(user, COMSIG_MOB_SPELL_CAST_CHECK)
|
||||
else if(ismob(target))
|
||||
stacked_spellcasting_by_user[target]--
|
||||
if(!stacked_spellcasting_by_user[target])
|
||||
stacked_spellcasting_by_user -= target
|
||||
|
||||
/datum/element/spellcasting/proc/on_equip(datum/source, mob/equipper, slot)
|
||||
if(!(slot in cast_slots))
|
||||
return
|
||||
users_by_item[source] = equipper
|
||||
if(!stacked_spellcasting_by_user[equipper])
|
||||
RegisterSignal(equipper, COMSIG_MOB_SPELL_CAST_CHECK, .proc/on_cast)
|
||||
stacked_spellcasting_by_user[equipper]++
|
||||
|
||||
/datum/element/spellcasting/proc/on_drop(datum/source, mob/user)
|
||||
if(!users_by_item[source])
|
||||
return
|
||||
users_by_item -= source
|
||||
stacked_spellcasting_by_user[user]--
|
||||
if(!stacked_spellcasting_by_user[user])
|
||||
stacked_spellcasting_by_user -= user
|
||||
UnregisterSignal(user, COMSIG_MOB_SPELL_CAST_CHECK)
|
||||
|
||||
/datum/element/spellcasting/proc/on_cast(mob/caster, obj/effect/proc_holder/spell)
|
||||
return cast_flags
|
||||
Reference in New Issue
Block a user