mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 06:29:23 +01:00
[READY]Updates knockoff component and adds it to prescription glasses (#59006)
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
//Items with these will have a chance to get knocked off when disarming
|
||||
///Items with these will have a chance to get knocked off when disarming or being knocked down
|
||||
/datum/component/knockoff
|
||||
var/knockoff_chance = 100 //Chance to knockoff
|
||||
var/list/target_zones //Aiming for these zones will cause the knockoff, null means all zones allowed
|
||||
var/list/slots_knockoffable //Can be only knocked off from these slots, null means all slots allowed
|
||||
///Chance to knockoff
|
||||
var/knockoff_chance = 100
|
||||
///Aiming for these zones will cause the knockoff, null means all zones allowed
|
||||
var/list/target_zones
|
||||
///Can be only knocked off from these slots, null means all slots allowed
|
||||
var/list/slots_knockoffable
|
||||
|
||||
/datum/component/knockoff/Initialize(knockoff_chance,zone_override,slots_knockoffable)
|
||||
if(!isitem(parent))
|
||||
@@ -11,40 +14,55 @@
|
||||
RegisterSignal(parent, COMSIG_ITEM_DROPPED,.proc/OnDropped)
|
||||
|
||||
src.knockoff_chance = knockoff_chance
|
||||
|
||||
|
||||
if(zone_override)
|
||||
target_zones = zone_override
|
||||
|
||||
if(slots_knockoffable)
|
||||
src.slots_knockoffable = slots_knockoffable
|
||||
|
||||
/datum/component/knockoff/proc/Knockoff(mob/living/attacker,zone)
|
||||
///Tries to knockoff the item when disarmed
|
||||
/datum/component/knockoff/proc/Knockoff(mob/living/carbon/human/wearer,mob/living/attacker,zone)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
var/obj/item/I = parent
|
||||
var/mob/living/carbon/human/wearer = I.loc
|
||||
var/obj/item/item = parent
|
||||
if(!istype(wearer))
|
||||
return
|
||||
if(target_zones && !(zone in target_zones))
|
||||
return
|
||||
if(!prob(knockoff_chance))
|
||||
return
|
||||
if(!wearer.dropItemToGround(I))
|
||||
if(!wearer.dropItemToGround(item))
|
||||
return
|
||||
wearer.visible_message("<span class='warning'>[attacker] knocks off [wearer]'s [item]!</span>","<span class='userdanger'>[attacker] knocks off your [item]!</span>")
|
||||
|
||||
///Tries to knockoff the item when user is knocked down
|
||||
/datum/component/knockoff/proc/Knockoff_knockdown(mob/living/carbon/human/wearer,amount)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
var/obj/item/item = parent
|
||||
if(!istype(wearer))
|
||||
return
|
||||
if(!prob(knockoff_chance))
|
||||
return
|
||||
if(!wearer.dropItemToGround(item))
|
||||
return
|
||||
wearer.visible_message("<span class='warning'>[wearer]'s [item] gets knocked off!</span>","<span class='userdanger'>Your [item] was knocked off!</span>")
|
||||
|
||||
wearer.visible_message("<span class='warning'>[attacker] knocks off [wearer]'s [I.name]!</span>","<span class='userdanger'>[attacker] knocks off your [I.name]!</span>")
|
||||
|
||||
/datum/component/knockoff/proc/OnEquipped(datum/source, mob/living/carbon/human/H,slot)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(!istype(H))
|
||||
return
|
||||
if(slots_knockoffable && !(slot in slots_knockoffable))
|
||||
UnregisterSignal(H, COMSIG_HUMAN_DISARM_HIT)
|
||||
UnregisterSignal(H, COMSIG_LIVING_STATUS_KNOCKDOWN)
|
||||
return
|
||||
RegisterSignal(H, COMSIG_HUMAN_DISARM_HIT, .proc/Knockoff, TRUE)
|
||||
RegisterSignal(H, COMSIG_LIVING_STATUS_KNOCKDOWN, .proc/Knockoff_knockdown, TRUE)
|
||||
|
||||
/datum/component/knockoff/proc/OnDropped(datum/source, mob/living/M)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
UnregisterSignal(M, COMSIG_HUMAN_DISARM_HIT)
|
||||
UnregisterSignal(M, COMSIG_LIVING_STATUS_KNOCKDOWN)
|
||||
|
||||
@@ -237,7 +237,7 @@
|
||||
/datum/quirk/nearsighted //t. errorage
|
||||
name = "Nearsighted"
|
||||
desc = "You are nearsighted without prescription glasses, but spawn with a pair."
|
||||
value = -1
|
||||
value = -4
|
||||
gain_text = "<span class='danger'>Things far away from you start looking blurry.</span>"
|
||||
lose_text = "<span class='notice'>You start seeing faraway things normally again.</span>"
|
||||
medical_record_text = "Patient requires prescription glasses in order to counteract nearsightedness."
|
||||
|
||||
@@ -202,6 +202,46 @@
|
||||
inhand_icon_state = "glasses"
|
||||
vision_correction = TRUE //corrects nearsightedness
|
||||
|
||||
/obj/item/clothing/glasses/regular/Initialize()
|
||||
. = ..()
|
||||
AddComponent(/datum/component/knockoff,25,list(BODY_ZONE_PRECISE_EYES),list(ITEM_SLOT_EYES))
|
||||
var/static/list/loc_connections = list(
|
||||
COMSIG_ATOM_ENTERED = .proc/on_entered,
|
||||
)
|
||||
AddElement(/datum/element/connect_loc, src, loc_connections)
|
||||
|
||||
|
||||
/obj/item/clothing/glasses/regular/proc/on_entered(datum/source, atom/movable/movable)
|
||||
SIGNAL_HANDLER
|
||||
if(damaged_clothes == CLOTHING_SHREDDED)
|
||||
return
|
||||
if(isliving(movable))
|
||||
var/mob/living/crusher = movable
|
||||
if(crusher.m_intent != MOVE_INTENT_WALK && (!(crusher.movement_type & (FLYING|FLOATING)) || crusher.buckled))
|
||||
playsound(src, 'sound/effects/glass_step.ogg', 30, TRUE)
|
||||
visible_message("<span class='warning'>[crusher] steps on [src], damaging it!</span>")
|
||||
take_damage(100, sound_effect = FALSE)
|
||||
|
||||
/obj/item/clothing/glasses/regular/obj_destruction(damage_flag)
|
||||
. = ..()
|
||||
vision_correction = FALSE
|
||||
|
||||
/obj/item/clothing/glasses/regular/welder_act(mob/living/user, obj/item/I)
|
||||
. = ..()
|
||||
if(damaged_clothes == CLOTHING_PRISTINE)
|
||||
return
|
||||
if(!I.tool_start_check(user, amount=1))
|
||||
return
|
||||
if(I.use_tool(src, user, 10, volume=30, amount=1))
|
||||
user.visible_message("<span class='notice'>[user] welds [src] back together.</span>",\
|
||||
"<span class='notice'>You weld [src] back together.</span>")
|
||||
repair()
|
||||
return TRUE
|
||||
|
||||
/obj/item/clothing/glasses/regular/repair()
|
||||
. = ..()
|
||||
vision_correction = TRUE
|
||||
|
||||
/obj/item/clothing/glasses/regular/jamjar
|
||||
name = "jamjar glasses"
|
||||
desc = "Also known as Virginity Protectors."
|
||||
|
||||
Reference in New Issue
Block a user