From 88d7fb3dca0d33afe70f3c6a9d42a76ad875b028 Mon Sep 17 00:00:00 2001 From: DragonTrance Date: Sun, 9 May 2021 14:04:26 -0700 Subject: [PATCH] fixes borg pixel shift, and borg expander also gives client-side resize action --- code/__DEFINES/dcs/signals.dm | 5 ++ .../objects/items/robot/robot_upgrades.dm | 2 + .../modules/mob/living/silicon/robot/robot.dm | 13 ++-- .../mob/living/silicon/robot/robot_modules.dm | 4 ++ hyperstation/code/datums/actions.dm | 67 +++++++++++++++++++ .../modules/mob/living/silicon/robot/robot.dm | 3 + .../mob/living/silicon/robot/robot_modules.dm | 18 +++++ tgstation.dme | 9 ++- 8 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 hyperstation/code/datums/actions.dm create mode 100644 hyperstation/code/modules/mob/living/silicon/robot/robot.dm create mode 100644 hyperstation/code/modules/mob/living/silicon/robot/robot_modules.dm diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index 886ff744..be48f633 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -724,3 +724,8 @@ // twitch plays /// Returns direction: (wipe_votes) #define COMSIG_TWITCH_PLAYS_MOVEMENT_DATA "twitch_plays_movement_data" + +//Hyperstation Signals +// +///from datum/action/cyborg_small_sprite and sends when a cyborg changes modules +#define COMSIG_CYBORG_MODULE_CHANGE "cyborg_module_change" diff --git a/code/game/objects/items/robot/robot_upgrades.dm b/code/game/objects/items/robot/robot_upgrades.dm index 7323fbf9..56e2e3ee 100644 --- a/code/game/objects/items/robot/robot_upgrades.dm +++ b/code/game/objects/items/robot/robot_upgrades.dm @@ -587,11 +587,13 @@ R.anchored = FALSE R.notransform = FALSE R.hasExpanded = TRUE + R.module.handle_sprite_action(R, TRUE) //Hyperstation edit R.update_transform() /obj/item/borg/upgrade/expand/deactivate(mob/living/silicon/robot/R, user = usr) . = ..() if (.) + R.module.handle_sprite_action(R) R.hasExpanded = FALSE R.update_transform() diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index 7435cc60..32af8888 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -669,11 +669,12 @@ icon_state = "[module.cyborg_base_icon]-wreck" if(module.cyborg_pixel_offset) - pixel_x = module.cyborg_pixel_offset + pixel_w = module.cyborg_pixel_offset //End of citadel changes if(module.cyborg_base_icon == "robot") icon = 'icons/mob/robots.dmi' + pixel_w = initial(pixel_w) pixel_x = initial(pixel_x) if(stat != DEAD && !(IsUnconscious() || IsStun() || IsKnockdown() || low_power_mode)) //Not dead, not stunned. if(!eye_lights) @@ -1084,11 +1085,11 @@ /mob/living/silicon/robot/update_transform() . = ..() - if (hasExpanded) - var/matrix/ntransform = matrix(transform) - ntransform.Scale(2) //This seems a bit big - ntransform.Translate(0, 16) - transform = ntransform + if(hasExpanded) + var/matrix/ntransform = matrix() + ntransform.Scale(2) + ntransform.Translate(0, 16) //plop onto the tile you nerd + transform = ntransform //this will overwrite VV stuff probably /mob/living/silicon/robot/proc/place_on_head(obj/item/new_hat) if(hat) diff --git a/code/modules/mob/living/silicon/robot/robot_modules.dm b/code/modules/mob/living/silicon/robot/robot_modules.dm index b842ba42..1148d669 100644 --- a/code/modules/mob/living/silicon/robot/robot_modules.dm +++ b/code/modules/mob/living/silicon/robot/robot_modules.dm @@ -188,13 +188,17 @@ /obj/item/robot_module/proc/transform_to(new_module_type) var/mob/living/silicon/robot/R = loc var/obj/item/robot_module/RM = new new_module_type(R) + testing("Module Picked: \"[RM.name]\"") if(!RM.be_transformed_to(src)) + testing("\"[RM.name]\" [RM.type].be_transformed_to(src) returned false.") qdel(RM) return + RM.handle_sprite_action(R, R.hasExpanded) //hyperstation edit R.module = RM R.update_module_innate() RM.rebuild_modules() INVOKE_ASYNC(RM, .proc/do_transform_animation) + SEND_SIGNAL(R, COMSIG_CYBORG_MODULE_CHANGE) //hyperstation edit qdel(src) return RM diff --git a/hyperstation/code/datums/actions.dm b/hyperstation/code/datums/actions.dm new file mode 100644 index 00000000..822f76d6 --- /dev/null +++ b/hyperstation/code/datums/actions.dm @@ -0,0 +1,67 @@ +//Small Sprite for borgs --Cyanosis +//Basically the same as /small_sprite, but i'm screaming for modularization +/datum/action/cyborg_small_sprite + name = "Toggle Giant Sprite" + desc = "Others will continue to see you giant." + icon_icon = 'icons/obj/plushes.dmi' + button_icon_state = "securityk9" + background_icon_state = "bg_default_on" //looks techy enough + var/designated_module as text + var/small = FALSE + var/small_icon = null + var/small_icon_state = null + var/image/icon_image + var/i_am_wide = FALSE //transform stuff so we appear in the middle of a tile instead of between two WHEN PLUSHIE + +/datum/action/cyborg_small_sprite/k9 //turns you into a marketable plushie + designated_module = "Security K-9 Unit" + small_icon = 'icons/obj/plushes.dmi' + small_icon_state = "securityk9" + i_am_wide = TRUE + +/datum/action/cyborg_small_sprite/medihound + designated_module = "MediHound" + small_icon = 'icons/obj/plushes.dmi' + small_icon_state = "medihound" + i_am_wide = TRUE + +/datum/action/cyborg_small_sprite/scrubpup + designated_module = "Scrub Pup" + small_icon = 'icons/obj/plushes.dmi' + small_icon_state = "scrubpuppy" + i_am_wide = TRUE + +/datum/action/cyborg_small_sprite/Grant(mob/M) + ..() + if(!owner) + return + update_image() + RegisterSignal(owner, COMSIG_CYBORG_MODULE_CHANGE, .proc/update_image) + +/datum/action/cyborg_small_sprite/Remove(mob/M) + UnregisterSignal(owner, COMSIG_CYBORG_MODULE_CHANGE) + ..() + +/datum/action/cyborg_small_sprite/Trigger() + if(!icon_image) + update_image() + if(!small) + owner.add_alt_appearance(/datum/atom_hud/alternate_appearance/basic, "cyborg_smallsprite", icon_image) + else + owner.remove_alt_appearance("cyborg_smallsprite") + small = !small + return TRUE + +/datum/action/cyborg_small_sprite/proc/update_image() + var/image/I + if(small_icon && small_icon_state) + I = image(icon=small_icon,icon_state=small_icon_state,loc=owner,layer=owner.layer,pixel_x=owner.pixel_x,pixel_y=owner.pixel_y) + else + I = image(icon=owner.icon,icon_state=owner.icon_state,loc=owner,layer=owner.layer,pixel_x=owner.pixel_x,pixel_y=owner.pixel_y) + I.overlays = owner.overlays + var/matrix/M = matrix() //I don't understand why, I don't want to know why, but this matrix is needed + M.Scale(0.5) //If you ever change the borg's size, be sure to change this too + M.Translate(8*i_am_wide, -8) //x position is for WIDE borgs. If they're not wide, this doesn't matter + I.transform = M //also why do images have transforms + I.override = TRUE + icon_image = I diff --git a/hyperstation/code/modules/mob/living/silicon/robot/robot.dm b/hyperstation/code/modules/mob/living/silicon/robot/robot.dm new file mode 100644 index 00000000..4752f0c9 --- /dev/null +++ b/hyperstation/code/modules/mob/living/silicon/robot/robot.dm @@ -0,0 +1,3 @@ +//This file is empty right now, but leaves room for people to put shit here in the future for those who are lazy +/mob/living/silicon/robot + var/datum/action/cyborg_small_sprite/small_sprite_action //This gets replaced every time the cyborg changes modules --Cyanosis \ No newline at end of file diff --git a/hyperstation/code/modules/mob/living/silicon/robot/robot_modules.dm b/hyperstation/code/modules/mob/living/silicon/robot/robot_modules.dm new file mode 100644 index 00000000..dbef0ad9 --- /dev/null +++ b/hyperstation/code/modules/mob/living/silicon/robot/robot_modules.dm @@ -0,0 +1,18 @@ +//This file is empty right now, but leaves room for people to put shit here in the future for those who are lazy + +//This proc gets called whenever a new robot module is being applied --Cyanosis +/obj/item/robot_module/proc/handle_sprite_action(mob/living/silicon/robot/R, is_huge = FALSE) + ASSERT(istype(R)) + if(R.small_sprite_action) + QDEL_NULL(R.small_sprite_action) + if(!is_huge) //only from the expander upgrade. The borg won't have an action if they don't have the expander upgrade + return + for(var/P in typesof(/datum/action/cyborg_small_sprite)) + var/datum/action/cyborg_small_sprite/action = P + if(initial(action.designated_module) == name) + R.small_sprite_action = new action() + R.small_sprite_action.Grant(R) + break + if(!R.small_sprite_action) + R.small_sprite_action = new() + R.small_sprite_action.Grant(R) diff --git a/tgstation.dme b/tgstation.dme index 8cb367fb..124cedd0 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2268,16 +2268,16 @@ #include "code\modules\mob\living\simple_animal\friendly\dog.dm" #include "code\modules\mob\living\simple_animal\friendly\farm_animals.dm" #include "code\modules\mob\living\simple_animal\friendly\fox.dm" +#include "code\modules\mob\living\simple_animal\friendly\goliathbaby.dm" #include "code\modules\mob\living\simple_animal\friendly\gondola.dm" #include "code\modules\mob\living\simple_animal\friendly\lizard.dm" #include "code\modules\mob\living\simple_animal\friendly\mouse.dm" #include "code\modules\mob\living\simple_animal\friendly\panda.dm" #include "code\modules\mob\living\simple_animal\friendly\penguin.dm" #include "code\modules\mob\living\simple_animal\friendly\pet.dm" -#include "code\modules\mob\living\simple_animal\friendly\sloth.dm" -#include "code\modules\mob\living\simple_animal\friendly\skunk.dm" #include "code\modules\mob\living\simple_animal\friendly\possum.dm" -#include "code\modules\mob\living\simple_animal\friendly\goliathbaby.dm" +#include "code\modules\mob\living\simple_animal\friendly\skunk.dm" +#include "code\modules\mob\living\simple_animal\friendly\sloth.dm" #include "code\modules\mob\living\simple_animal\friendly\snake.dm" #include "code\modules\mob\living\simple_animal\friendly\drone\_drone.dm" #include "code\modules\mob\living\simple_animal\friendly\drone\drones_as_items.dm" @@ -3040,6 +3040,7 @@ #include "hyperstation\code\__DEFINES\economy.dm" #include "hyperstation\code\__DEFINES\wendigo.dm" #include "hyperstation\code\controllers\subsystem\economy.dm" +#include "hyperstation\code\datums\actions.dm" #include "hyperstation\code\datums\elements\holder_micro.dm" #include "hyperstation\code\datums\mood_events\events.dm" #include "hyperstation\code\datums\ruins\lavaland.dm" @@ -3094,6 +3095,8 @@ #include "hyperstation\code\modules\mining\equipment\survival_pod.dm" #include "hyperstation\code\modules\mob\mob_helpers.dm" #include "hyperstation\code\modules\mob\living\status_indicators.dm" +#include "hyperstation\code\modules\mob\living\silicon\robot\robot.dm" +#include "hyperstation\code\modules\mob\living\silicon\robot\robot_modules.dm" #include "hyperstation\code\modules\patreon\patreon.dm" #include "hyperstation\code\modules\power\reactor\fuel_rods.dm" #include "hyperstation\code\modules\power\reactor\rbmk.dm"