Skip to content

Commit

Permalink
https://github.com/tgstation/tgstation/pull/59629
Browse files Browse the repository at this point in the history
  • Loading branch information
Tsar-Salat committed Dec 16, 2023
1 parent 90e3f55 commit fb1eda0
Show file tree
Hide file tree
Showing 20 changed files with 985 additions and 460 deletions.
8 changes: 6 additions & 2 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
#include "code\__DEFINES\dcs\signals\signals_obj\signals_projectile.dm"
#include "code\__DEFINES\dcs\signals\signals_obj\signals_item\signals_clothing.dm"
#include "code\__DEFINES\dcs\signals\signals_obj\signals_item\signals_food.dm"
#include "code\__DEFINES\dcs\signals\signals_obj\signals_item\signals_gun.dm"
#include "code\__DEFINES\dcs\signals\signals_obj\signals_item\signals_grenade.dm"
#include "code\__DEFINES\dcs\signals\signals_obj\signals_item\signals_implant.dm"
#include "code\__DEFINES\dcs\signals\signals_obj\signals_item\signals_item.dm"
Expand Down Expand Up @@ -781,6 +782,7 @@
#include "code\datums\elements\death_drops.dm"
#include "code\datums\elements\decal.dm"
#include "code\datums\elements\deferred_aquarium_content.dm"
#include "code\datums\elements\delete_on_drop.dm"
#include "code\datums\elements\digital_camo.dm"
#include "code\datums\elements\earhealing.dm"
#include "code\datums\elements\embed.dm"
Expand Down Expand Up @@ -2223,8 +2225,10 @@
#include "code\modules\buildmode\submodes\smite.dm"
#include "code\modules\buildmode\submodes\throwing.dm"
#include "code\modules\buildmode\submodes\variable_edit.dm"
#include "code\modules\capture_the_flag\capture_the_flag.dm"
#include "code\modules\capture_the_flag\map_loading.dm"
#include "code\modules\capture_the_flag\ctf_classes.dm"
#include "code\modules\capture_the_flag\ctf_equipment.dm"
#include "code\modules\capture_the_flag\ctf_game.dm"
#include "code\modules\capture_the_flag\ctf_map_loading.dm"
#include "code\modules\cargo\bounty.dm"
#include "code\modules\cargo\bounty_console.dm"
#include "code\modules\cargo\centcom_podlauncher.dm"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// /obj/item/gun signals

///called in /obj/item/gun/ballistic/process_chamber (casing)
#define COMSIG_CASING_EJECTED "casing_ejected"
1 change: 1 addition & 0 deletions code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ world

//Dummy mob reserve slots
#define DUMMY_HUMAN_SLOT_ADMIN "admintools"
#define DUMMY_HUMAN_SLOT_CTF "dummy_ctf_preview_generation"

// Multiply all alpha values by this float
/icon/proc/ChangeOpacity(opacity = 1)
Expand Down
25 changes: 20 additions & 5 deletions code/datums/components/shielded.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,32 @@
var/recharge_start_delay = 20 SECONDS
/// Once we go unhit long enough to recharge, we replenish charges this often. The floor is effectively 1 second, AKA how often SSdcs processes
var/charge_increment_delay = 1 SECONDS
/// How many charges we recover on each charge increment
var/charge_recovery = 1
/// What .dmi we're pulling the shield icon from
var/shield_icon_file = 'icons/effects/effects.dmi'
/// What icon is used when someone has a functional shield up
var/shield_icon = "shield-old"
/// Do we still shield if we're being held in-hand? If FALSE, it needs to be equipped to a slot to work
var/shield_inhand = FALSE
/// Should the shield lose charges equal to the damage dealt by a hit?
var/lose_multiple_charges = FALSE
/// The cooldown tracking when we were last hit
COOLDOWN_DECLARE(recently_hit_cd)
/// The cooldown tracking when we last replenished a charge
COOLDOWN_DECLARE(charge_add_cd)
/// A callback for the sparks/message that play when a charge is used, see [/datum/component/shielded/proc/default_run_hit_callback]
var/datum/callback/on_hit_effects

/datum/component/shielded/Initialize(max_charges = 3, recharge_start_delay = 20 SECONDS, charge_increment_delay = 1 SECONDS, shield_icon_file = 'icons/effects/effects.dmi', shield_icon = "shield-old", shield_inhand = FALSE, run_hit_callback)
/datum/component/shielded/Initialize(max_charges = 3, recharge_start_delay = 20 SECONDS, charge_increment_delay = 1 SECONDS, charge_recovery = 1, lose_multiple_charges = FALSE, shield_icon_file = 'icons/effects/effects.dmi', shield_icon = "shield-old", shield_inhand = FALSE, run_hit_callback)
if(!isitem(parent) || max_charges <= 0)
return COMPONENT_INCOMPATIBLE

src.max_charges = max_charges
src.recharge_start_delay = recharge_start_delay
src.charge_increment_delay = charge_increment_delay
src.charge_recovery = charge_recovery
src.lose_multiple_charges = lose_multiple_charges
src.shield_icon_file = shield_icon_file
src.shield_icon = shield_icon
src.shield_inhand = shield_inhand
Expand Down Expand Up @@ -73,13 +79,18 @@

var/obj/item/item_parent = parent
COOLDOWN_START(src, charge_add_cd, charge_increment_delay)
current_charges++
adjust_charge(charge_recovery) // set the number of charges to current + recovery per increment, clamped from zero to max_charges
if(wearer && current_charges == 1)
wearer.update_icon()
playsound(item_parent, 'sound/magic/charge.ogg', 50, TRUE)
if(current_charges == max_charges)
playsound(item_parent, 'sound/machines/ding.ogg', 50, TRUE)

/datum/component/shielded/proc/adjust_charge(change)
current_charges = clamp(current_charges + change, 0, max_charges)
if(wearer)
wearer.update_appearance(UPDATE_ICON)

/// Check if we've been equipped to a valid slot to shield
/datum/component/shielded/proc/on_equipped(datum/source, mob/user, slot)
SIGNAL_HANDLER
Expand Down Expand Up @@ -121,7 +132,13 @@
if(current_charges <= 0)
return
. = COMPONENT_HIT_REACTION_BLOCK
current_charges = max(current_charges - 1, 0)

var/charge_loss = 1 // how many charges do we lose

if(lose_multiple_charges) // if the shield has health like damage we'll lose charges equal to the damage of the hit
charge_loss = damage

adjust_charge(-charge_loss)

INVOKE_ASYNC(src, PROC_REF(actually_run_hit_callback), owner, attack_text, current_charges)

Expand All @@ -130,8 +147,6 @@
qdel(src)
return

if(!current_charges)
wearer.update_icon()
START_PROCESSING(SSdcs, src) // if we DO recharge, start processing so we can do that

/// The wrapper to invoke the on_hit callback, so we don't have to worry about blocking in the signal handler
Expand Down
21 changes: 21 additions & 0 deletions code/datums/elements/delete_on_drop.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Attaches to an item, if that item is dropped on the floor delete it
*/
/datum/element/delete_on_drop
element_flags = ELEMENT_DETACH
var/list/myvar = list()

/datum/element/delete_on_drop/Attach(datum/target)
. = ..()
if(!isitem(target))
return COMPONENT_INCOMPATIBLE
RegisterSignal(target, list(COMSIG_ITEM_DROPPED, COMSIG_CASING_EJECTED), .proc/del_on_drop)

/datum/element/delete_on_drop/Detach(datum/source)
. = ..()
UnregisterSignal(source, list(COMSIG_ITEM_DROPPED, COMSIG_CASING_EJECTED))

/datum/element/delete_on_drop/proc/del_on_drop(atom/source)
SIGNAL_HANDLER
if(isturf(source.loc))
qdel(source)
10 changes: 7 additions & 3 deletions code/game/objects/effects/powerup.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
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/Crossed(atom/movable/movable_atom)
. = ..()
/obj/effect/powerup/proc/on_entered(datum/source, atom/movable/movable_atom)
SIGNAL_HANDLER
trigger(movable_atom)

/obj/effect/powerup/Bump(atom/bumped_atom)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@

/obj/effect/projectile/impact/wormhole
icon_state = "wormhole_g"

/obj/effect/projectile/impact/solar
name = "solar impact"
icon_state = "impact_solar"
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
name = "heavy laser"
icon_state = "beam_heavy"

/obj/effect/projectile/tracer/solar
name = "solar beam"
icon_state = "solar"

//BEAM RIFLE
/obj/effect/projectile/tracer/tracer/beam_rifle
icon_state = "tracer_beam"
Expand Down
Loading

0 comments on commit fb1eda0

Please sign in to comment.