Files
Bubberstation/code/game/objects/effects/powerup.dm
SkyratBot 5326760cb3 [MIRROR] Makes turfs persist their signals, uses this to optimize connect_loc (#6465)
* Makes turfs persist their signals, uses this to optimize connect_loc  (#59608)

* Makes turfs persist signals

* Splits connect_loc up into two elements, one for stuff that wishes to connect on behalf of something, and one for stuff that just wants to connect normally. Connecting on behalf of someone has a significant amount of overhead, so let's do this to keep things clear

* Converts all uses of connect_loc over to the new patterns

* Adds some comments, actually makes turfs persist signals

* There's no need to detach connect loc anymore, since all it does is unregister signals. Unregisters a signal from formorly decal'd turfs, and makes the changeturf signal persistance stuff actually work

* bro fuck documentation

* Changes from a var to a proc, prevents admemems and idiots

* Extra detail on why we do the copy post qdel

* Makes turfs persist their signals, uses this to optimize connect_loc

Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com>
2021-06-23 04:23:48 +01:00

131 lines
3.7 KiB
Plaintext

/obj/effect/powerup
name = "power-up"
icon = 'icons/effects/effects.dmi'
density = FALSE
anchored = TRUE
resistance_flags = INDESTRUCTIBLE
/// How long in deciseconds it will take for the powerup to respawn, if no value it won't respawn
var/respawn_time
/// How long the powerup stays on the ground, if no value it will stay forever
var/lifetime
/// Message given when powerup is picked up
var/pickup_message
/// Sound played when powerup is picked up
var/pickup_sound
/// Cooldown for the powerup to respawn after it's been used
COOLDOWN_DECLARE(respawn_cooldown)
/obj/effect/powerup/Initialize()
. = ..()
if(lifetime)
QDEL_IN(src, lifetime)
var/static/list/loc_connections = list(
COMSIG_ATOM_ENTERED = .proc/on_entered,
)
AddElement(/datum/element/connect_loc, loc_connections)
/obj/effect/powerup/proc/on_entered(datum/source, atom/movable/movable_atom)
SIGNAL_HANDLER
trigger(movable_atom)
/obj/effect/powerup/Bump(atom/bumped_atom)
trigger(bumped_atom)
/obj/effect/powerup/Bumped(atom/movable/movable_atom)
trigger(movable_atom)
/// Triggers the effect of the powerup on the target, returns FALSE if the target is not /mob/living, is dead or the cooldown hasn't finished, returns TRUE otherwise
/obj/effect/powerup/proc/trigger(mob/living/target)
if(!istype(target) || target.stat == DEAD)
return FALSE
if(respawn_time)
if(!COOLDOWN_FINISHED(src, respawn_cooldown))
return FALSE
COOLDOWN_START(src, respawn_cooldown, respawn_time)
alpha = 100
addtimer(VARSET_CALLBACK(src, alpha, initial(alpha)), respawn_time)
else
qdel(src)
if(pickup_message)
to_chat(target, span_notice("[pickup_message]"))
if(pickup_sound)
playsound(get_turf(target), pickup_sound, 50, TRUE, -1)
return TRUE
/obj/effect/powerup/health
name = "health pickup"
desc = "Blessing from the havens."
icon = 'icons/obj/storage.dmi'
icon_state = "medicalpack"
respawn_time = 30 SECONDS
pickup_message = "Health restored!"
pickup_sound = 'sound/magic/staff_healing.ogg'
/// How much the pickup heals when picked up
var/heal_amount = 50
/// Does this pickup fully heal when picked up
var/full_heal = FALSE
/// If full heal, does this do an admin level heal?
var/admin_heal = FALSE
/obj/effect/powerup/health/trigger(mob/living/target)
. = ..()
if(!.)
return
if(full_heal)
target.fully_heal(admin_heal)
else if(heal_amount)
target.heal_ordered_damage(heal_amount, list(BRUTE, BURN))
/obj/effect/powerup/health/full
name = "mega health pickup"
desc = "Now this is what I'm talking about."
icon_state = "duffel-med"
full_heal = TRUE
/obj/effect/powerup/ammo
name = "ammo pickup"
desc = "You like revenge, right? Everybody likes revenge! Well, let's go get some!"
icon = 'icons/obj/storage.dmi'
icon_state = "ammobox"
respawn_time = 30 SECONDS
pickup_message = "Ammunition reloaded!"
pickup_sound = 'sound/weapons/gun/shotgun/rack.ogg'
/obj/effect/powerup/ammo/trigger(mob/living/target)
. = ..()
if(!.)
return
for(var/obj/item/gun in target.GetAllContents())
if(!isgun(gun) && !istype(gun, /obj/item/flamethrower))
continue
SEND_SIGNAL(gun, COMSIG_ITEM_RECHARGED)
/obj/effect/powerup/ammo/ctf
icon = 'icons/effects/effects.dmi'
icon_state = "at_shield1"
respawn_time = FALSE
lifetime = 30 SECONDS
/obj/effect/powerup/speed
name = "Lightning Orb"
desc = "You feel faster just looking at it."
icon_state = "speed"
pickup_sound = 'sound/magic/lightningshock.ogg'
/obj/effect/powerup/speed/trigger(mob/living/target)
. = ..()
if(!.)
return
target.apply_status_effect(STATUS_EFFECT_LIGHTNINGORB)
/obj/effect/powerup/mayhem
name = "Orb of Mayhem"
desc = "You feel angry just looking at it."
icon_state = "impact_laser"
/obj/effect/powerup/mayhem/trigger(mob/living/target)
. = ..()
if(!.)
return
target.apply_status_effect(STATUS_EFFECT_MAYHEM)