Skip to content

Commit

Permalink
Fixes Toy Sword Icon & Rewrites It to Use E-Sword Procs. (#6054)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request

1. **Fixes Toy Sword Icon and Rewrites Procs to use E-Sword.**

## Why It's Good For The Game

1. _The toy sword off icon was broken, so I looked into it and it's
using an outdated sprite name. So I changed it, but then I looked over
the proc, and I realized it would be more fun if the toy sword had some
of the real one's traits - like the rainbow thing if you multitool it,
and alt-click color change support. So I started adding those, but I
didn't like putting all of it in one attack_self proc, so I've instead
just cloned over the procs from the esword and adjusted them to suit the
toy instead!_

## Changelog

<!-- If your PR modifies aspects of the game that can be concretely
observed by players or admins you should add a changelog. If your change
does NOT meet this description, remove this section. Be sure to properly
mark your PRs to prevent unnecessary GBP loss. You can read up on GBP
and it's effects on PRs in the tgstation guides for contributors. Please
note that maintainers freely reserve the right to remove and add tags
should they deem it appropriate. You can attempt to finagle the system
all you want, but it's best to shoot for clear communication right off
the bat. -->

:cl:
fix: Fixes broken toy sword icon and changes its procs.
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
Captain277 authored Oct 9, 2023
1 parent 32cf4cf commit 36a3b1c
Showing 1 changed file with 76 additions and 14 deletions.
90 changes: 76 additions & 14 deletions code/game/objects/items/toys.dm
Original file line number Diff line number Diff line change
Expand Up @@ -254,41 +254,103 @@
*/
/obj/item/toy/sword
name = "toy sword"
desc = "A cheap, plastic replica of an energy sword. Realistic sounds! Ages 8 and up."
desc = "A cheap, plastic replica of an energy sword. Realistic sounds! Ages 8 and up. It can be recolored via Alt-Click."
icon = 'icons/obj/weapons.dmi'
icon_state = "sword0"
icon_state = "esword"
item_icons = list(
SLOT_ID_LEFT_HAND = 'icons/mob/items/lefthand_melee.dmi',
SLOT_ID_RIGHT_HAND = 'icons/mob/items/righthand_melee.dmi',
)
var/active = 0.0
var/active = 0
w_class = ITEMSIZE_SMALL
attack_verb = list("attacked", "struck", "hit")
color = "#0099FF"
var/colorable = TRUE
var/rainbow = FALSE

/obj/item/toy/sword/attack_self(mob/user)
. = ..()
if(.)
return
src.active = !( src.active )
if (src.active)
to_chat(user, SPAN_NOTICE("You extend the plastic blade with a quick flick of your wrist."))
playsound(user, 'sound/weapons/saberon.ogg', 50, TRUE)
src.icon_state = "swordblue"
src.w_class = ITEMSIZE_LARGE
if (active)
deactivate(user)
else
to_chat(user, SPAN_NOTICE("You push the plastic blade back down into the handle."))
playsound(user, 'sound/weapons/saberoff.ogg', 50, TRUE)
src.icon_state = "sword0"
src.w_class = ITEMSIZE_SMALL
activate(user)

if(istype(user,/mob/living/carbon/human))
var/mob/living/carbon/human/H = user
H.update_inv_l_hand()
H.update_inv_r_hand()

src.add_fingerprint(user)
add_fingerprint(user)
return

/obj/item/toy/sword/proc/activate(mob/living/user)
if(active)
return
active = 1
if(rainbow)
item_state = "[icon_state]_blade_rainbow"
else
item_state = "[icon_state]_blade"
w_class = ITEMSIZE_LARGE
playsound(user, 'sound/weapons/saberon.ogg', 50, 1)
update_icon()
to_chat(user, SPAN_NOTICE("You extend the plastic blade with a quick flick of your wrist."))

/obj/item/toy/sword/proc/deactivate(mob/living/user)
if(!active)
return
playsound(user, 'sound/weapons/saberoff.ogg', 50, 1)
to_chat(user, SPAN_NOTICE("You push the plastic blade back down into the handle."))
item_state = "[icon_state]"
active = 0
w_class = initial(w_class)
update_icon()

/obj/item/toy/sword/attackby(obj/item/W, mob/user)
if(istype(W, /obj/item/multitool) && colorable && !active)
if(!rainbow)
rainbow = TRUE
else
rainbow = FALSE
to_chat(user, "<span class='notice'>You manipulate the color controller in [src].</span>")
update_icon()
return ..()

/obj/item/toy/sword/update_icon()
. = ..()
var/mutable_appearance/blade_overlay = mutable_appearance(icon, "[icon_state]_blade")
blade_overlay.color = color
if(rainbow)
blade_overlay = mutable_appearance(icon, "[icon_state]_blade_rainbow")
blade_overlay.color = "FFFFFF"
color = "FFFFFF"
cut_overlays() //So that it doesn't keep stacking overlays non-stop on top of each other
if(active)
add_overlay(blade_overlay)
if(istype(usr,/mob/living/carbon/human))
var/mob/living/carbon/human/H = usr
H.update_inv_l_hand()
H.update_inv_r_hand()

/obj/item/toy/sword/AltClick(mob/living/user)
if(!colorable) //checks if is not colorable
return
if(!in_range(src, user)) //Basic checks to prevent abuse
return
if(user.incapacitated() || !istype(user))
to_chat(user, "<span class='warning'>You can't do that right now!</span>")
return

if(alert("Are you sure you want to recolor your blade?", "Confirm Recolor", "Yes", "No") == "Yes")
var/energy_color_input = input(usr,"","Choose Energy Color",color) as color|null
if(energy_color_input)
color = "#[sanitize_hexcolor(energy_color_input)]"
deactivate()
update_icon()
. = ..()

/obj/item/toy/katana
name = "replica katana"
desc = "Woefully underpowered in D20."
Expand Down

0 comments on commit 36a3b1c

Please sign in to comment.