diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 2f69b63ae9..05ea9e0c47 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -1239,19 +1239,21 @@ GLOBAL_REAL_VAR(list/stack_trace_storage) pixel_x = initialpixelx pixel_y = initialpixely -/atom/proc/do_jiggle(targetangle = 45) +/atom/proc/do_jiggle(targetangle = 45, timer = 20) var/matrix/OM = matrix(transform) var/matrix/M = matrix(transform) + var/halftime = timer * 0.5 M.Turn(pick(-targetangle, targetangle)) - animate(src, transform = M, time = 10, easing = ELASTIC_EASING) - animate(src, transform = OM, time = 10, easing = ELASTIC_EASING) + animate(src, transform = M, time = halftime, easing = ELASTIC_EASING) + animate(src, transform = OM, time = halftime, easing = ELASTIC_EASING) -/atom/proc/do_squish(squishx = 1.2, squishy = 0.6) +/atom/proc/do_squish(squishx = 1.2, squishy = 0.6, timer = 20) var/matrix/OM = matrix(transform) var/matrix/M = matrix(transform) + var/halftime = timer * 0.5 M.Scale(squishx, squishy) - animate(src, transform = M, time = 10, easing = BOUNCE_EASING) - animate(src, transform = OM, time = 10, easing = BOUNCE_EASING) + animate(src, transform = M, time = halftime, easing = BOUNCE_EASING) + animate(src, transform = OM, time = halftime, easing = BOUNCE_EASING) /proc/weightclass2text(var/w_class) switch(w_class) diff --git a/code/datums/components/bouncy.dm b/code/datums/components/bouncy.dm new file mode 100644 index 0000000000..2584e46121 --- /dev/null +++ b/code/datums/components/bouncy.dm @@ -0,0 +1,36 @@ +/datum/component/bouncy + dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS + var/bouncy_mod = 1 + var/list/bounce_signals = list(COMSIG_MOVABLE_IMPACT, COMSIG_ITEM_HIT_REACT, COMSIG_ITEM_ATTACK) + +/datum/component/bouncy/Initialize(_bouncy_mod, list/_bounce_signals) + if(!ismovableatom(parent)) + return COMPONENT_INCOMPATIBLE + bouncy_mod = _bouncy_mod + bounce_signals = _bounce_signals + +/datum/component/bouncy/InheritComponent(datum/component/bouncy/B, original, _bouncy_mod, list/_bounce_signals) + bouncy_mod = max(bouncy_mod, _bouncy_mod) + var/list/diff_bounces = difflist(bounce_signals, _bounce_signals, TRUE) + for(var/bounce in diff_bounces) + bounce_signals += bounce + RegisterSignal(parent, bounce, .proc/bounce_up) + +/datum/component/bouncy/RegisterWithParent() + RegisterSignal(parent, bounce_signals, .proc/bounce_up) + +/datum/component/bouncy/UnregisterFromParent() + UnregisterSignal(parent, bounce_signals) + +/datum/component/bouncy/proc/bounce_up(datum/source) + var/atom/movable/A = parent + switch(rand(1, 3)) + if(1) + A.do_jiggle(45 + rand(-10, 10) * bouncy_mod, 14) + if(2) + var/min_b = 0.6/bouncy_mod + var/max_b = 1.2 * bouncy_mod + A.do_squish(rand(min_b, max_b), rand(min_b, max_b), 14) + if(3) + var/pixelshift = 8 * bouncy_mod + A.Shake(pixelshift, pixelshift, duration = 15) diff --git a/code/game/objects/items/his_grace.dm b/code/game/objects/items/his_grace.dm index 49a5cfaf35..f9d00b6213 100644 --- a/code/game/objects/items/his_grace.dm +++ b/code/game/objects/items/his_grace.dm @@ -8,7 +8,7 @@ name = "artistic toolbox" desc = "A toolbox painted bright green. Looking at it makes you feel uneasy." icon_state = "his_grace" - item_state = "artistic_toolbox" + item_state = "toolbox_green" lefthand_file = 'icons/mob/inhands/equipment/toolbox_lefthand.dmi' righthand_file = 'icons/mob/inhands/equipment/toolbox_righthand.dmi' icon = 'icons/obj/items_and_weapons.dmi' diff --git a/code/game/objects/items/storage/toolbox.dm b/code/game/objects/items/storage/toolbox.dm index b2313969f0..b6c45bc7ab 100644 --- a/code/game/objects/items/storage/toolbox.dm +++ b/code/game/objects/items/storage/toolbox.dm @@ -1,3 +1,5 @@ +GLOBAL_LIST_EMPTY(rubber_toolbox_icons) + /obj/item/storage/toolbox name = "toolbox" desc = "Danger. Very robust." @@ -16,21 +18,25 @@ hitsound = 'sound/weapons/smash.ogg' var/latches = "single_latch" var/has_latches = TRUE + var/can_rubberify = TRUE -/obj/item/storage/toolbox/Initialize() +/obj/item/storage/toolbox/Initialize(mapload) . = ..() if(has_latches) if(prob(10)) latches = "double_latch" if(prob(1)) latches = "triple_latch" + if(mapload && can_rubberify && prob(5)) + rubberify() update_icon() /obj/item/storage/toolbox/update_icon() ..() cut_overlays() if(has_latches) - add_overlay(latches) + var/icon/I = icon('icons/obj/storage.dmi', latches) + add_overlay(I) /obj/item/storage/toolbox/suicide_act(mob/user) @@ -39,8 +45,6 @@ /obj/item/storage/toolbox/emergency name = "emergency toolbox" - icon_state = "red" - item_state = "toolbox_red" /obj/item/storage/toolbox/emergency/PopulateContents() new /obj/item/crowbar/red(src) @@ -59,6 +63,7 @@ name = "rusty red toolbox" icon_state = "toolbox_red_old" has_latches = FALSE + can_rubberify = FALSE /obj/item/storage/toolbox/mechanical name = "mechanical toolbox" @@ -77,6 +82,7 @@ name = "rusty blue toolbox" icon_state = "toolbox_blue_old" has_latches = FALSE + can_rubberify = FALSE /obj/item/storage/toolbox/mechanical/old/heirloom name = "old, robust toolbox" //this will be named "X family toolbox" @@ -151,6 +157,7 @@ resistance_flags = FIRE_PROOF | ACID_PROOF w_class = WEIGHT_CLASS_HUGE attack_verb = list("robusted", "crushed", "smashed") + can_rubberify = FALSE var/fabricator_type = /obj/item/clockwork/replica_fabricator/scarab /obj/item/storage/toolbox/brass/ComponentInitialize() @@ -191,6 +198,7 @@ item_state = "toolbox_blue" w_class = WEIGHT_CLASS_HUGE //heyo no bohing this! force = 18 //spear damage + can_rubberify = FALSE /obj/item/storage/toolbox/plastitanium/afterattack(atom/A, mob/user, proximity) . = ..() @@ -204,7 +212,7 @@ name = "artistic toolbox" desc = "A toolbox painted bright green. Why anyone would store art supplies in a toolbox is beyond you, but it has plenty of extra space." icon_state = "green" - item_state = "artistic_toolbox" + item_state = "toolbox_green" w_class = WEIGHT_CLASS_GIGANTIC //Holds more than a regular toolbox! /obj/item/storage/toolbox/artistic/ComponentInitialize() @@ -235,6 +243,7 @@ throwforce = 14 throw_speed = 5 throw_range = 10 + can_rubberify = FALSE /obj/item/storage/toolbox/gold_real/PopulateContents() new /obj/item/screwdriver/nuke(src) @@ -259,3 +268,48 @@ has_latches = FALSE force = 0 throwforce = 0 + can_rubberify = FALSE + +/obj/item/storage/toolbox/proc/rubberify() + name = "rubber [name]" + desc = replacetext(desc, "Danger", "Bouncy") + desc = replacetext(desc, "robust", "safe") + desc = replacetext(desc, "heavier", "bouncier") + flags_1 = null + materials = null + damtype = STAMINA + force += 5 //to compensate the higher stamina K.O. threshold compared to actual health. + throwforce += 5 + attack_verb += "bounced" + if(!GLOB.rubber_toolbox_icons[icon_state]) + generate_rubber_toolbox_icon() + icon = GLOB.rubber_toolbox_icons[icon_state] + AddComponent(/datum/component/bouncy) + . = ..() + +/obj/item/storage/toolbox/proc/generate_rubber_toolbox_icon() + var/icon/new_icon = icon(icon, icon_state) + var/icon/smooth = icon('icons/obj/storage.dmi', "rubber_toolbox_blend") + new_icon.Blend(smooth, ICON_MULTIPLY) + new_icon = fcopy_rsc(new_icon) + GLOB.rubber_toolbox_icons[icon_state] = new_icon + +/obj/item/storage/toolbox/rubber + name = "rubber toolbox" + desc = "Bouncy. Very safe." + flags_1 = null + materials = null + damtype = STAMINA + force = 17 + throwforce = 17 + attack_verb = list("robusted", "bounced") + can_rubberify = FALSE //we are already the future. + +/obj/item/storage/toolbox/rubber/Initialize() + icon_state = pick("blue", "red", "yellow", "green") + item_state = "toolbox_[icon_state]" + if(!GLOB.rubber_toolbox_icons[icon_state]) + generate_rubber_toolbox_icon() + icon = GLOB.rubber_toolbox_icons[icon_state] + . = ..() + AddComponent(/datum/component/bouncy) \ No newline at end of file diff --git a/code/game/objects/items/toys.dm b/code/game/objects/items/toys.dm index 274afe15e0..9239973247 100644 --- a/code/game/objects/items/toys.dm +++ b/code/game/objects/items/toys.dm @@ -294,7 +294,7 @@ name = "windup toolbox" desc = "A replica toolbox that rumbles when you turn the key." icon_state = "his_grace" - item_state = "artistic_toolbox" + item_state = "toolbox_green" lefthand_file = 'icons/mob/inhands/equipment/toolbox_lefthand.dmi' righthand_file = 'icons/mob/inhands/equipment/toolbox_righthand.dmi' var/active = FALSE diff --git a/icons/mob/inhands/equipment/toolbox_lefthand.dmi b/icons/mob/inhands/equipment/toolbox_lefthand.dmi index b2fa42ce5e..801df7abb8 100644 Binary files a/icons/mob/inhands/equipment/toolbox_lefthand.dmi and b/icons/mob/inhands/equipment/toolbox_lefthand.dmi differ diff --git a/icons/mob/inhands/equipment/toolbox_righthand.dmi b/icons/mob/inhands/equipment/toolbox_righthand.dmi index ccb15982dd..f38ddfc9a4 100644 Binary files a/icons/mob/inhands/equipment/toolbox_righthand.dmi and b/icons/mob/inhands/equipment/toolbox_righthand.dmi differ diff --git a/icons/obj/storage.dmi b/icons/obj/storage.dmi index 9037bfc0d0..2a6ec3955a 100644 Binary files a/icons/obj/storage.dmi and b/icons/obj/storage.dmi differ diff --git a/tgstation.dme b/tgstation.dme index 5a4f096f3a..3a14a0700b 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -336,6 +336,7 @@ #include "code\datums\components\_component.dm" #include "code\datums\components\anti_magic.dm" #include "code\datums\components\armor_plate.dm" +#include "code\datums\components\bouncy.dm" #include "code\datums\components\butchering.dm" #include "code\datums\components\caltrop.dm" #include "code\datums\components\chasm.dm"