mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-25 06:00:16 +01:00
[MIRROR] Refactors the Charge wizard spell [MDB IGNORE] (#13424)
* Refactors the Charge wizard spell (#66599) This PR refactors the "charge" spell to be signal based instead of looping over held items + istype checks. This was atomized out of my proc holder removal PR. Figured it was small enough to handle on its own. * Refactors the Charge wizard spell Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
var/charges = 0
|
||||
var/recharge_rate = 8
|
||||
var/charge_timer = 0
|
||||
/// Whether this wand/staff recharges on its own over time.
|
||||
/// (This is not related to the spell "Charge" whatsoever!)
|
||||
var/can_charge = TRUE
|
||||
var/ammo_type
|
||||
var/no_den_usage
|
||||
@@ -23,6 +25,34 @@
|
||||
trigger_guard = TRIGGER_GUARD_ALLOW_ALL // Has no trigger at all, uses magic instead
|
||||
pin = /obj/item/firing_pin/magic
|
||||
|
||||
/obj/item/gun/magic/Initialize(mapload)
|
||||
. = ..()
|
||||
RegisterSignal(src, COMSIG_ITEM_MAGICALLY_CHARGED, .proc/on_magic_charge)
|
||||
|
||||
/**
|
||||
* Signal proc for [COMSIG_ITEM_MAGICALLY_CHARGED]
|
||||
*
|
||||
* Adds uses to wands or staffs.
|
||||
*/
|
||||
/obj/item/gun/magic/proc/on_magic_charge(datum/source, obj/effect/proc_holder/spell/targeted/charge/spell, mob/living/caster)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
. = COMPONENT_ITEM_CHARGED
|
||||
|
||||
// Non-self charging staves and wands can potentially expire
|
||||
if(!can_charge && max_charges && prob(80))
|
||||
max_charges--
|
||||
|
||||
if(max_charges <= 0)
|
||||
max_charges = 0
|
||||
. |= COMPONENT_ITEM_BURNT_OUT
|
||||
|
||||
charges = max_charges
|
||||
update_appearance(UPDATE_ICON_STATE)
|
||||
recharge_newshot()
|
||||
|
||||
return .
|
||||
|
||||
/obj/item/gun/magic/process_fire(atom/target, mob/living/user, message, params, zone_override, bonus_spread)
|
||||
if(no_den_usage)
|
||||
var/area/A = get_area(user)
|
||||
|
||||
Reference in New Issue
Block a user