mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-14 17:45:02 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
179 lines
5.9 KiB
Plaintext
179 lines
5.9 KiB
Plaintext
/datum/component/throwbonus_on_windup
|
|
///the maximum windup bonus
|
|
var/maximum_bonus = 20
|
|
///additional behavior if we exceed the maximum bonus
|
|
var/datum/callback/pass_maximum_callback
|
|
///the player currently winding up their throw
|
|
var/datum/weakref/holder
|
|
///the current bonus we are at
|
|
var/throwforce_bonus = 0
|
|
///the bar relaying feedback to the player
|
|
var/obj/effect/overlay/windup_bar/our_bar
|
|
///any additional behavior we should look for before applying the bonus
|
|
var/datum/callback/apply_bonus_callback
|
|
///sound we play after successfully damaging the enemy with a bonus
|
|
var/sound_on_success
|
|
///effect we play after successfully damaging the enemy with a bonus
|
|
var/effect_on_success
|
|
///how fast we increase the wind up counter on process
|
|
var/windup_increment_speed
|
|
///text we display when we start winding up
|
|
var/throw_text
|
|
|
|
/datum/component/throwbonus_on_windup/Initialize(maximum_bonus = 20, windup_increment_speed = 1, pass_maximum_callback, apply_bonus_callback, sound_on_success, effect_on_success, throw_text)
|
|
. = ..()
|
|
if(!isitem(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
|
|
src.maximum_bonus = maximum_bonus
|
|
src.pass_maximum_callback = pass_maximum_callback
|
|
src.apply_bonus_callback = apply_bonus_callback
|
|
src.sound_on_success = sound_on_success
|
|
src.effect_on_success = effect_on_success
|
|
src.windup_increment_speed = windup_increment_speed
|
|
src.throw_text = throw_text
|
|
|
|
/datum/component/throwbonus_on_windup/proc/on_equip(datum/source, mob/living/equipper, slot)
|
|
SIGNAL_HANDLER
|
|
|
|
if(!(slot & ITEM_SLOT_HANDS) || holder?.resolve())
|
|
return
|
|
holder = WEAKREF(equipper)
|
|
RegisterSignal(equipper, COMSIG_LIVING_THROW_MODE_TOGGLE, PROC_REF(throw_change))
|
|
RegisterSignal(equipper, COMSIG_MOB_SWAP_HANDS, PROC_REF(on_hands_swap))
|
|
if(equipper.throw_mode)
|
|
start_windup()
|
|
|
|
/datum/component/throwbonus_on_windup/proc/start_windup()
|
|
if(!QDELETED(our_bar))
|
|
CRASH("throwbonus_on_windup component attempted to start windup while already winding up a throw!")
|
|
|
|
throwforce_bonus = initial(throwforce_bonus)
|
|
var/mob/living/our_holder = holder?.resolve()
|
|
if(isnull(holder))
|
|
return
|
|
|
|
if(throw_text)
|
|
to_chat(our_holder, span_warning(throw_text))
|
|
|
|
var/x_position = CEILING(our_holder.get_visual_width() * 0.5, 1)
|
|
our_bar = new()
|
|
our_bar.maximum_count = maximum_bonus
|
|
our_bar.pixel_x = x_position
|
|
our_holder.vis_contents += our_bar
|
|
START_PROCESSING(SSfastprocess, src)
|
|
|
|
/datum/component/throwbonus_on_windup/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, PROC_REF(on_equip))
|
|
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(on_move))
|
|
RegisterSignal(parent, COMSIG_MOVABLE_PRE_IMPACT, PROC_REF(on_thrown))
|
|
|
|
/datum/component/throwbonus_on_windup/UnregisterFromParent()
|
|
UnregisterSignal(parent, list(COMSIG_ITEM_EQUIPPED, COMSIG_MOVABLE_MOVED, COMSIG_MOVABLE_PRE_IMPACT))
|
|
var/atom/our_holder = holder?.resolve()
|
|
if(!isnull(our_holder))
|
|
UnregisterSignal(our_holder, list(COMSIG_LIVING_THROW_MODE_TOGGLE, COMSIG_MOB_SWAP_HANDS))
|
|
|
|
/datum/component/throwbonus_on_windup/Destroy()
|
|
STOP_PROCESSING(SSfastprocess, src)
|
|
QDEL_NULL(our_bar)
|
|
holder = null
|
|
return ..()
|
|
|
|
/datum/component/throwbonus_on_windup/proc/throw_change(mob/living/source, throw_mode)
|
|
SIGNAL_HANDLER
|
|
|
|
if (source.get_active_held_item() != parent)
|
|
return
|
|
|
|
if(throw_mode)
|
|
start_windup()
|
|
else
|
|
end_windup()
|
|
|
|
/datum/component/throwbonus_on_windup/proc/on_hands_swap(mob/living/source, obj/item/swapped_to, obj/item/swapped_from)
|
|
SIGNAL_HANDLER
|
|
|
|
if(source.get_active_held_item() != parent)
|
|
end_windup()
|
|
return
|
|
|
|
if(source.throw_mode)
|
|
start_windup()
|
|
|
|
/datum/component/throwbonus_on_windup/process(seconds_per_tick)
|
|
if(throwforce_bonus > maximum_bonus)
|
|
var/mob/living/our_holder = holder?.resolve()
|
|
pass_maximum_callback?.Invoke(our_holder)
|
|
end_windup()
|
|
return PROCESS_KILL
|
|
|
|
our_bar.recalculate_position(min(throwforce_bonus, maximum_bonus))
|
|
throwforce_bonus += windup_increment_speed
|
|
|
|
/datum/component/throwbonus_on_windup/proc/on_move(obj/item/source, atom/entering_loc)
|
|
SIGNAL_HANDLER
|
|
end_windup()
|
|
var/mob/living/our_holder = holder?.resolve()
|
|
if(isnull(our_holder))
|
|
return
|
|
holder = null
|
|
UnregisterSignal(our_holder, list(COMSIG_LIVING_THROW_MODE_TOGGLE, COMSIG_MOB_SWAP_HANDS))
|
|
|
|
/datum/component/throwbonus_on_windup/proc/end_windup()
|
|
QDEL_NULL(our_bar)
|
|
STOP_PROCESSING(SSfastprocess, src)
|
|
|
|
/datum/component/throwbonus_on_windup/proc/on_thrown(datum/source, atom/hit_atom, datum/thrownthing/throwingdatum)
|
|
SIGNAL_HANDLER
|
|
|
|
var/damage_to_apply = throwforce_bonus
|
|
throwforce_bonus = initial(throwforce_bonus)
|
|
if(!isliving(hit_atom))
|
|
return
|
|
|
|
if(apply_bonus_callback && !apply_bonus_callback.Invoke(hit_atom, damage_to_apply))
|
|
return
|
|
|
|
if(effect_on_success)
|
|
new effect_on_success(get_turf(hit_atom))
|
|
if(sound_on_success)
|
|
playsound(hit_atom, sound_on_success, 50, TRUE)
|
|
|
|
var/mob/living/living_target = hit_atom
|
|
living_target.apply_damage(damage_to_apply)
|
|
|
|
/obj/effect/overlay/windup_bar
|
|
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
|
|
anchored = TRUE
|
|
vis_flags = VIS_INHERIT_DIR | VIS_INHERIT_PLANE
|
|
icon = 'icons/effects/effects.dmi'
|
|
icon_state = "windup_bar"
|
|
layer = ABOVE_ALL_MOB_LAYER
|
|
///the maximum windup bonus
|
|
var/maximum_count = INFINITY
|
|
///the current count we are at
|
|
var/current_count = 0
|
|
|
|
/obj/effect/overlay/windup_bar/proc/recalculate_position(input_count)
|
|
current_count = input_count
|
|
update_appearance(UPDATE_OVERLAYS)
|
|
|
|
/obj/effect/overlay/windup_bar/update_overlays()
|
|
. = ..()
|
|
var/static/list/bar_positions = list(0, 2, 4, 6, 8)
|
|
var/current_percentage = current_count / maximum_count
|
|
var/bars_to_add = ceil(length(bar_positions) * current_percentage)
|
|
for(var/curr_number in 1 to bars_to_add)
|
|
var/bar_color
|
|
switch(curr_number)
|
|
if(1 to 2)
|
|
bar_color = "windup_red"
|
|
if(2 to 4)
|
|
bar_color = "windup_green"
|
|
if(4 to 5)
|
|
bar_color = "windup_purple"
|
|
var/mutable_appearance/bar_overlay = mutable_appearance(icon = icon, icon_state = bar_color, layer = ABOVE_HUD_PLANE)
|
|
bar_overlay.pixel_z = bar_positions[curr_number]
|
|
. += bar_overlay
|