[MIRROR] Sticker resprite and rewrite (#26853)

* Sticker resprite and rewrite (#81893)

Stealing from Goon is bad, but stickers are actually a good feature, and
loosing those will be a disappointment. This project aims to recreate
'em from scratch without using Jimmyl's and Goon's code. Also,
suspicious icons were resprited and renamed.

* Sticker resprite and rewrite

---------

Co-authored-by: Interception&? <137328283+intercepti0n@users.noreply.github.com>
This commit is contained in:
SkyratBot
2024-03-13 19:35:59 -04:00
committed by GitHub
co-authored by Interception&?
parent 24cd444494
commit 0e217eab7b
11 changed files with 327 additions and 277 deletions
@@ -1,78 +0,0 @@
// The attached sticker
/datum/component/attached_sticker
dupe_mode = COMPONENT_DUPE_ALLOWED
///The overlay we apply to things we stick to
var/mutable_appearance/sticker_overlay
///The turf our COMSIG_TURF_EXPOSE is registered to, so we can unregister it later.
var/turf/signal_turf
///Our physical sticker to drop
var/obj/item/sticker
///Can we be washed off?
var/washable = TRUE
/datum/component/attached_sticker/Initialize(px, py, obj/stick, mob/living/user, cleanable=TRUE)
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE
washable = cleanable
var/atom/atom_parent = parent
sticker = stick
sticker_overlay = mutable_appearance(stick.icon, stick.icon_state , layer = atom_parent.layer + 1, appearance_flags = RESET_COLOR | PIXEL_SCALE)
sticker_overlay.pixel_x = px
sticker_overlay.pixel_y = py
atom_parent.add_overlay(sticker_overlay)
if(isliving(parent) && user)
var/mob/living/victim = parent
if(victim.client)
user.log_message("stuck [sticker] to [key_name(victim)]", LOG_ATTACK)
victim.log_message("had [sticker] stuck to them by [key_name(user)]", LOG_ATTACK)
else if(isturf(parent) && (sticker.resistance_flags & FLAMMABLE))
//register signals on the users turf instead because we can assume they are on flooring sticking it to a wall so it should burn (otherwise it would fruitlessly check wall temperature)
signal_turf = (user && isclosedturf(parent)) ? get_turf(user) : parent
RegisterSignal(signal_turf, COMSIG_TURF_EXPOSE, PROC_REF(on_turf_expose))
sticker.moveToNullspace()
RegisterSignal(sticker, COMSIG_QDELETING, PROC_REF(peel))
/datum/component/attached_sticker/Destroy()
var/atom/as_atom = parent
as_atom.cut_overlay(sticker_overlay)
sticker_overlay = null
if(sticker)
QDEL_NULL(sticker)
return ..()
///Move sticker item from nullspace, delete this component, cut overlay
/datum/component/attached_sticker/proc/peel(atom/source)
SIGNAL_HANDLER
if(!QDELETED(sticker))
var/atom/as_atom = parent
sticker.forceMove(isturf(as_atom) ? as_atom : as_atom.drop_location())
sticker.pixel_y = rand(-4,1)
sticker.pixel_x = rand(-3,3)
sticker = null
if(!QDELETED(src))
qdel(src)
/datum/component/attached_sticker/RegisterWithParent()
if(sticker.resistance_flags & FLAMMABLE)
RegisterSignal(parent, COMSIG_LIVING_IGNITED, PROC_REF(peel))
if(washable)
RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, PROC_REF(peel))
RegisterSignal(parent, COMSIG_QDELETING, PROC_REF(peel))
ADD_TRAIT(parent, TRAIT_STICKERED, REF(sticker))
/datum/component/attached_sticker/UnregisterFromParent()
UnregisterSignal(parent, list(COMSIG_LIVING_IGNITED, COMSIG_QDELETING))
if(signal_turf)
UnregisterSignal(signal_turf, COMSIG_TURF_EXPOSE)
signal_turf = null
if(washable)
UnregisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT)
REMOVE_TRAIT(parent, TRAIT_STICKERED, REF(sticker))
///Signal handler for COMSIG_TURF_EXPOSE, deletes this sticker if the temperature is above 100C and it is flammable
/datum/component/attached_sticker/proc/on_turf_expose(datum/source, datum/gas_mixture/air, exposed_temperature)
SIGNAL_HANDLER
if(exposed_temperature <= FIRE_MINIMUM_TEMPERATURE_TO_EXIST)
return
peel()
+111
View File
@@ -0,0 +1,111 @@
/**
* ### Sticker component
*
* Component that draws supplied atom's icon over parent object with specified offset,
* icon centering is handled inside.
*/
/datum/component/sticker
dupe_mode = COMPONENT_DUPE_ALLOWED
/// Either `turf` or `null`, used to connect to `COMSIG_TURF_EXPOSE` signal when parent is a turf.
var/turf/listening_turf
/// Refernce to a "stickered" atom.
var/atom/movable/our_sticker
/// Reference to the created overlay, used during component deletion.
var/mutable_appearance/sticker_overlay
/datum/component/sticker/Initialize(atom/stickering_atom, mob/user, dir = NORTH, px = 0, py = 0)
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE
src.our_sticker = our_sticker
if(isliving(parent) && !isnull(user))
var/mob/living/victim = parent
if(!isnull(victim.client))
user.log_message("stuck [stickering_atom] to [key_name(victim)]", LOG_ATTACK)
victim.log_message("had [stickering_atom] stuck to them by [key_name(user)]", LOG_ATTACK)
stick(stickering_atom, px, py)
register_turf_signals(dir)
/datum/component/sticker/Destroy(force)
var/atom/parent_atom = parent
parent_atom.cut_overlay(sticker_overlay)
unregister_turf_signals()
REMOVE_TRAIT(parent, TRAIT_STICKERED, REF(src))
QDEL_NULL(our_sticker)
QDEL_NULL(sticker_overlay)
return ..()
/datum/component/sticker/RegisterWithParent()
if(isliving(parent))
RegisterSignal(parent, COMSIG_LIVING_IGNITED, PROC_REF(on_ignite))
RegisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT, PROC_REF(on_clean))
/datum/component/sticker/UnregisterFromParent()
if(isliving(parent))
UnregisterSignal(parent, COMSIG_LIVING_IGNITED)
UnregisterSignal(parent, COMSIG_COMPONENT_CLEAN_ACT)
/// Subscribes to `COMSIG_TURF_EXPOSE` if parent atom is a turf. If turf is closed - subscribes to signal
/datum/component/sticker/proc/register_turf_signals(dir)
if(!isturf(parent))
return
listening_turf = isclosedturf(parent) ? get_step(parent, dir) : parent
RegisterSignal(listening_turf, COMSIG_TURF_EXPOSE, PROC_REF(on_turf_expose))
/// Unsubscribes from `COMSIG_TURF_EXPOSE` if `listening_turf` is not `null`.
/datum/component/sticker/proc/unregister_turf_signals()
if(isnull(listening_turf))
return
UnregisterSignal(listening_turf, COMSIG_TURF_EXPOSE)
/// Handles overlay creation from supplied atom, adds created icon to the parent object, moves source atom to the nullspace.
/datum/component/sticker/proc/stick(atom/movable/stickering_atom, px, py)
our_sticker = stickering_atom
our_sticker.moveToNullspace()
var/atom/parent_atom = parent
sticker_overlay = mutable_appearance(icon = our_sticker.icon, icon_state = our_sticker.icon_state, layer = parent_atom.layer + 0.01, appearance_flags = RESET_COLOR)
sticker_overlay.pixel_w = px - world.icon_size / 2
sticker_overlay.pixel_z = py - world.icon_size / 2
parent_atom.add_overlay(sticker_overlay)
ADD_TRAIT(parent, TRAIT_STICKERED, REF(src))
/// Moves stickered atom from the nullspace, deletes component.
/datum/component/sticker/proc/peel()
var/atom/parent_atom = parent
var/turf/drop_location = isnull(listening_turf) ? parent_atom.drop_location() : listening_turf
our_sticker.forceMove(drop_location)
our_sticker = null
qdel(src)
/datum/component/sticker/proc/on_ignite(datum/source)
SIGNAL_HANDLER
qdel(src)
/datum/component/sticker/proc/on_clean(datum/source, clean_types)
SIGNAL_HANDLER
peel()
return COMPONENT_CLEANED
/datum/component/sticker/proc/on_turf_expose(datum/source, datum/gas_mixture/air, exposed_temperature)
SIGNAL_HANDLER
if(exposed_temperature >= FIRE_MINIMUM_TEMPERATURE_TO_EXIST)
qdel(src)
-53
View File
@@ -1,53 +0,0 @@
#define MAX_ALLOWED_STICKERS 12
/datum/element/sticker
///The typepath for our attached sticker component
var/stick_type = /datum/component/attached_sticker
///If TRUE, our attached_sticker can be washed off
var/washable = TRUE
/datum/element/sticker/Attach(datum/target, sticker_type, cleanable=TRUE)
. = ..()
if(!isitem(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, COMSIG_ITEM_AFTERATTACK, PROC_REF(on_afterattack))
RegisterSignal(target, COMSIG_MOVABLE_IMPACT, PROC_REF(on_throw_impact))
if(sticker_type)
stick_type = sticker_type
washable = cleanable
/datum/element/sticker/Detach(datum/source)
. = ..()
UnregisterSignal(source, list(COMSIG_ITEM_AFTERATTACK, COMSIG_MOVABLE_IMPACT))
/datum/element/sticker/proc/on_afterattack(obj/item/source, atom/target, mob/living/user, prox, params)
SIGNAL_HANDLER
if(!prox)
return
if(!isatom(target))
return
var/list/parameters = params2list(params)
if(!LAZYACCESS(parameters, ICON_X) || !LAZYACCESS(parameters, ICON_Y))
return
var/divided_size = world.icon_size / 2
var/px = text2num(LAZYACCESS(parameters, ICON_X)) - divided_size
var/py = text2num(LAZYACCESS(parameters, ICON_Y)) - divided_size
user.do_attack_animation(target)
if(do_stick(source, target, user, px, py))
target.balloon_alert_to_viewers("sticker sticked")
///Add our stick_type to the target with px and py as pixel x and pixel y respectively
/datum/element/sticker/proc/do_stick(obj/item/source, atom/target, mob/living/user, px, py)
if(COUNT_TRAIT_SOURCES(target, TRAIT_STICKERED) >= MAX_ALLOWED_STICKERS)
source.balloon_alert_to_viewers("sticker won't stick!")
return FALSE
target.AddComponent(stick_type, px, py, source, user, washable)
return TRUE
/datum/element/sticker/proc/on_throw_impact(obj/item/source, atom/hit_atom, datum/thrownthing/throwingdatum)
SIGNAL_HANDLER
if(prob(50) && do_stick(source, hit_atom, null, rand(-7,7), rand(-7,7)))
hit_atom.balloon_alert_to_viewers("sticker landed on sticky side!")
#undef MAX_ALLOWED_STICKERS
+5 -5
View File
@@ -25,8 +25,8 @@
return early_sig_return
var/interact_return = is_left_clicking \
? tool.interact_with_atom(src, user) \
: tool.interact_with_atom_secondary(src, user)
? tool.interact_with_atom(src, user, modifiers) \
: tool.interact_with_atom_secondary(src, user, modifiers)
if(interact_return)
return interact_return
@@ -92,7 +92,7 @@
* Return an ITEM_INTERACT_ flag in the event the interaction was handled, to cancel further interaction code.
* Return NONE to allow default interaction / tool handling.
*/
/obj/item/proc/interact_with_atom(atom/interacting_with, mob/living/user)
/obj/item/proc/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
return NONE
/**
@@ -104,8 +104,8 @@
* Return an ITEM_INTERACT_ flag in the event the interaction was handled, to cancel further interaction code.
* Return NONE to allow default interaction / tool handling.
*/
/obj/item/proc/interact_with_atom_secondary(atom/interacting_with, mob/living/user)
return interact_with_atom(interacting_with, user)
/obj/item/proc/interact_with_atom_secondary(atom/interacting_with, mob/living/user, list/modifiers)
return interact_with_atom(interacting_with, user, modifiers)
/*
* Tool-specific behavior procs.
-131
View File
@@ -1,131 +0,0 @@
/// parent type for all other stickers. do not spawn directly
/obj/item/sticker
name = "sticker"
desc = "A sticker with some strong adhesive on the back, sticks to stuff!"
item_flags = NOBLUDGEON | XENOMORPH_HOLDABLE //funny
resistance_flags = FLAMMABLE
icon = 'icons/obj/toys/stickers.dmi'
w_class = WEIGHT_CLASS_TINY
throw_range = 3
vis_flags = VIS_INHERIT_DIR | VIS_INHERIT_PLANE | VIS_INHERIT_LAYER
///If not null, pick an icon_state from this list
var/icon_states
/// If the sticker should be disincluded from normal sticker boxes.
var/contraband = FALSE
/obj/item/sticker/Initialize(mapload)
. = ..()
if(icon_states)
icon_state = pick(icon_states)
pixel_y = rand(-3,3)
pixel_x = rand(-3,3)
AddElement(/datum/element/sticker)
/obj/item/sticker/smile
name = "smiley sticker"
icon_state = "smile"
/obj/item/sticker/frown
name = "frowny sticker"
icon_state = "frown"
/obj/item/sticker/left_arrow
name = "left arrow sticker"
icon_state = "larrow"
/obj/item/sticker/right_arrow
name = "right arrow sticker"
icon_state = "rarrow"
/obj/item/sticker/star
name = "star sticker"
icon_state = "star1"
icon_states = list("star1","star2")
/obj/item/sticker/heart
name = "heart sticker"
icon_state = "heart"
/obj/item/sticker/googly
name = "googly eye sticker"
icon_state = "googly1"
icon_states = list("googly1","googly2")
/obj/item/sticker/rev
name = "blue R sticker"
desc = "A sticker of FUCK THE SYSTEM, the galaxy's premiere hardcore punk band."
icon_state = "revhead"
/obj/item/sticker/pslime
name = "slime plushie sticker"
icon_state = "pslime"
/obj/item/sticker/pliz
name = "lizard plushie sticker"
icon_state = "plizard"
/obj/item/sticker/pbee
name = "bee plushie sticker"
icon_state = "pbee"
/obj/item/sticker/psnake
name = "snake plushie sticker"
icon_state = "psnake"
/obj/item/sticker/robot
name = "bot sticker"
icon_state = "tile"
icon_states = list("tile","medbot","clean")
/obj/item/sticker/toolbox
name = "toolbox sticker"
icon_state = "toolbox"
/obj/item/sticker/clown
name = "clown sticker"
icon_state = "honkman"
/obj/item/sticker/mime
name = "mime sticker"
icon_state = "silentman"
/obj/item/sticker/assistant
name = "assistant sticker"
icon_state = "tider"
/obj/item/sticker/syndicate
name = "syndicate sticker"
icon_state = "synd"
contraband = TRUE
/obj/item/sticker/syndicate/c4
name = "C-4 sticker"
icon_state = "c4"
/obj/item/sticker/syndicate/bomb
name = "syndicate bomb sticker"
icon_state = "sbomb"
/obj/item/sticker/syndicate/apc
name = "broken APC sticker"
icon_state = "milf"
/obj/item/sticker/syndicate/larva
name = "larva sticker"
icon_state = "larva"
/obj/item/sticker/syndicate/cult
name = "bloody paper sticker"
icon_state = "cult"
/obj/item/sticker/syndicate/flash
name = "flash sticker"
icon_state = "flash"
/obj/item/sticker/syndicate/op
name = "operative sticker"
icon_state = "newcop"
/obj/item/sticker/syndicate/trap
name = "bear trap sticker"
icon_state = "trap"
+195
View File
@@ -0,0 +1,195 @@
#define MAX_STICKER_COUNT 15
/**
* What stickers can do?
*
* - They can be attached to any object.
* - They inherit cursor position when attached.
* - They are unclickable by mouse, I suppose?
* - They can be washed off.
* - They can be burnt off.
* - They can be attached to the object they collided with.
* - They play "attack" animation when attached.
*
*/
/obj/item/sticker
name = "sticker"
desc = "A sticker with some strong adhesive on the back, sticks to stuff!"
icon = 'icons/obj/toys/stickers.dmi'
max_integrity = 50
resistance_flags = FLAMMABLE
throw_range = 3
pressure_resistance = 0
item_flags = NOBLUDGEON | XENOMORPH_HOLDABLE //funny ~Jimmyl
w_class = WEIGHT_CLASS_TINY
/// `list` or `null`, contains possible alternate `icon_states`.
var/list/icon_states
/// Whether sticker is legal and allowed to generate inside non-syndicate boxes.
var/contraband = FALSE
/obj/item/sticker/Initialize(mapload)
. = ..()
if(length(icon_states))
icon_state = pick(icon_states)
/obj/item/sticker/Bump(atom/bumped_atom)
if(prob(50) && attempt_attach(bumped_atom))
bumped_atom.balloon_alert_to_viewers("sticker landed on sticky side!")
/obj/item/sticker/interact_with_atom(atom/interacting_with, mob/living/user, list/modifiers)
if(!isatom(interacting_with))
return NONE
var/cursor_x = text2num(LAZYACCESS(modifiers, ICON_X))
var/cursor_y = text2num(LAZYACCESS(modifiers, ICON_Y))
if(isnull(cursor_x) || isnull(cursor_y))
return NONE
if(attempt_attach(interacting_with, user, cursor_x, cursor_y))
return ITEM_INTERACT_SUCCESS
return NONE
/**
* Attempts to attach sticker to an object. Returns `FALSE` if atom has more than
* `MAX_STICKER_COUNT` stickers, `TRUE` otherwise. If no `px` or `py` were passed
* picks random coordinates based on a `target`'s icon.
*/
/obj/item/sticker/proc/attempt_attach(atom/target, mob/user, px, py)
if(COUNT_TRAIT_SOURCES(target, TRAIT_STICKERED) >= MAX_STICKER_COUNT)
balloon_alert_to_viewers("sticker won't stick!")
return FALSE
if(isnull(px) || isnull(py))
var/icon/target_mask = icon(target.icon, target.icon_state)
if(isnull(px))
px = rand(1, target_mask.Width())
if(isnull(py))
py = rand(1, target_mask.Height())
if(!isnull(user))
user.do_attack_animation(target, used_item = src)
target.balloon_alert(user, "sticker sticked")
target.AddComponent(/datum/component/sticker, src, user, get_dir(target, src), px, py)
return TRUE
#undef MAX_STICKER_COUNT
/obj/item/sticker/smile
name = "smiley sticker"
icon_state = "smile"
/obj/item/sticker/frown
name = "frowny sticker"
icon_state = "frown"
/obj/item/sticker/left_arrow
name = "left arrow sticker"
icon_state = "arrow-left"
/obj/item/sticker/right_arrow
name = "right arrow sticker"
icon_state = "arrow-right"
/obj/item/sticker/star
name = "star sticker"
icon_state = "star"
/obj/item/sticker/heart
name = "heart sticker"
icon_state = "heart"
/obj/item/sticker/googly
name = "googly eye sticker"
icon_state = "googly"
icon_states = list("googly", "googly-alt")
/obj/item/sticker/rev
name = "blue R sticker"
desc = "A sticker of FUCK THE SYSTEM, the galaxy's premiere hardcore punk band."
icon_state = "revhead"
/obj/item/sticker/pslime
name = "slime plushie sticker"
icon_state = "pslime"
/obj/item/sticker/pliz
name = "lizard plushie sticker"
icon_state = "plizard"
/obj/item/sticker/pbee
name = "bee plushie sticker"
icon_state = "pbee"
/obj/item/sticker/psnake
name = "snake plushie sticker"
icon_state = "psnake"
/obj/item/sticker/robot
name = "bot sticker"
icon_state = "tile"
icon_states = list("tile", "medbot", "clean")
/obj/item/sticker/toolbox
name = "toolbox sticker"
icon_state = "soul"
/obj/item/sticker/clown
name = "clown sticker"
icon_state = "honkman"
/obj/item/sticker/mime
name = "mime sticker"
icon_state = "silentman"
/obj/item/sticker/assistant
name = "assistant sticker"
icon_state = "tider"
/obj/item/sticker/syndicate
name = "syndicate sticker"
icon_state = "synd"
contraband = TRUE
/obj/item/sticker/syndicate/c4
name = "C-4 sticker"
icon_state = "c4"
/obj/item/sticker/syndicate/bomb
name = "syndicate bomb sticker"
icon_state = "sbomb"
/obj/item/sticker/syndicate/apc
name = "broken APC sticker"
icon_state = "milf"
/obj/item/sticker/syndicate/larva
name = "larva sticker"
icon_state = "larva"
/obj/item/sticker/syndicate/cult
name = "bloody paper sticker"
icon_state = "cult"
/obj/item/sticker/syndicate/flash
name = "flash sticker"
icon_state = "flash"
/obj/item/sticker/syndicate/op
name = "operative sticker"
icon_state = "newcop"
/obj/item/sticker/syndicate/trap
name = "bear trap sticker"
icon_state = "trap"
@@ -209,16 +209,21 @@
desc = "A box full of random stickers. Do give to the clown."
/obj/item/storage/box/stickers/proc/generate_non_contraband_stickers_list()
. = list()
var/list/allowed_stickers = list()
for(var/obj/item/sticker/sticker_type as anything in subtypesof(/obj/item/sticker))
if(!initial(sticker_type.contraband))
. += sticker_type
return .
if(!sticker_type::contraband)
allowed_stickers += sticker_type
return allowed_stickers
/obj/item/storage/box/stickers/PopulateContents()
var/static/list/non_contraband
if(!non_contraband)
if(isnull(non_contraband))
non_contraband = generate_non_contraband_stickers_list()
for(var/i in 1 to rand(4,8))
for(var/i in 1 to rand(4, 8))
var/type = pick(non_contraband)
new type(src)
@@ -674,6 +674,7 @@
/obj/item/storage/box/syndie_kit/stickers/PopulateContents()
var/list/types = subtypesof(/obj/item/sticker/syndicate)
for(var/i in 1 to atom_storage.max_slots)
var/type = pick(types)
new type(src)
+2 -1
View File
@@ -250,8 +250,9 @@
discountable = SUPPLY_PACK_STD_DISCOUNTABLE
/datum/supply_pack/costumes_toys/stickers/fill(obj/structure/closet/crate/crate)
for(var/i in 1 to rand(1,2))
for(var/i in 1 to rand(1, 2))
new /obj/item/storage/box/stickers(crate)
if(prob(30)) // a pair of googly eyes because funny
new /obj/item/storage/box/stickers/googly(crate)
Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 7.1 KiB

+2 -3
View File
@@ -1100,7 +1100,6 @@
#include "code\datums\components\areabound.dm"
#include "code\datums\components\armor_plate.dm"
#include "code\datums\components\atmos_reaction_recorder.dm"
#include "code\datums\components\attached_sticker.dm"
#include "code\datums\components\aura_healing.dm"
#include "code\datums\components\bakeable.dm"
#include "code\datums\components\basic_inhands.dm"
@@ -1283,6 +1282,7 @@
#include "code\datums\components\squeak.dm"
#include "code\datums\components\stationloving.dm"
#include "code\datums\components\stationstuck.dm"
#include "code\datums\components\sticker.dm"
#include "code\datums\components\storm_hating.dm"
#include "code\datums\components\strong_pull.dm"
#include "code\datums\components\subtype_picker.dm"
@@ -1565,7 +1565,6 @@
#include "code\datums\elements\spooky.dm"
#include "code\datums\elements\squish.dm"
#include "code\datums\elements\squish_sound.dm"
#include "code\datums\elements\sticker.dm"
#include "code\datums\elements\strippable.dm"
#include "code\datums\elements\structure_repair.dm"
#include "code\datums\elements\swabbable.dm"
@@ -2383,7 +2382,7 @@
#include "code\game\objects\items\signs.dm"
#include "code\game\objects\items\skub.dm"
#include "code\game\objects\items\spear.dm"
#include "code\game\objects\items\sticker.dm"
#include "code\game\objects\items\stickers.dm"
#include "code\game\objects\items\surgery_tray.dm"
#include "code\game\objects\items\syndie_spraycan.dm"
#include "code\game\objects\items\tail_pin.dm"