mirror of
https://github.com/PolarisSS13/Polaris.git
synced 2026-08-25 06:06:34 +01:00
Archery Tweaks (#8670)
* Add proper custom arrows. (cross)Bows "render" proper arrows over themselves in inventory and on ground. Hardlight bow no longer deletes other arrows on removal. * Fix subtyping issue. Add Chitin arrow type. * Remember to hit save, kids. * Fixfix. Add true Unga arrow utilizing the Ancient Art of Sharp Rocks.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// Stacked resources. They use a material datum for a lot of inherited values.
|
||||
// If you're adding something here, make sure to add it to fifty_spawner_mats.dm as well
|
||||
/obj/item/stack/material
|
||||
name = "material sheet"
|
||||
force = 5.0
|
||||
throwforce = 5
|
||||
w_class = ITEMSIZE_NORMAL
|
||||
@@ -86,4 +87,4 @@
|
||||
else if(istype(W, /obj/item/stack/rods))
|
||||
material.build_rod_product(user, W, src)
|
||||
return
|
||||
return ..()
|
||||
return ..()
|
||||
|
||||
@@ -11,6 +11,12 @@
|
||||
drop_sound = 'sound/items/drop/woodweapon.ogg'
|
||||
pickup_sound = 'sound/items/pickup/woodweapon.ogg'
|
||||
|
||||
knock_point = list(9,8)
|
||||
|
||||
/obj/item/arrow/wood/chitin
|
||||
name = "chitin arrow"
|
||||
desc = "A wooden arrow with a hard chitin tip. Simple, but gets the job done."
|
||||
color = "#a66008"
|
||||
|
||||
/obj/item/arrow/energy
|
||||
name = "hardlight arrow"
|
||||
@@ -48,10 +54,12 @@
|
||||
release_speed = 15
|
||||
release_force = 20
|
||||
tension = 3
|
||||
var/drawn = FALSE
|
||||
drop_sound = 'sound/items/drop/woodweapon.ogg'
|
||||
pickup_sound = 'sound/items/pickup/woodweapon.ogg'
|
||||
|
||||
bolt_rotation_transform = 0 // Bows do not rotate their arrows like crossbows, as they face north-east on the ground.
|
||||
drawn_knock = list(8,7)
|
||||
ready_knock = list(15,14)
|
||||
|
||||
/obj/item/gun/launcher/crossbow/bow/update_release_force(obj/item/projectile)
|
||||
return 0
|
||||
@@ -59,34 +67,34 @@
|
||||
/obj/item/gun/launcher/crossbow/bow/proc/unload(mob/user)
|
||||
var/obj/item/arrow/A = bolt
|
||||
bolt = null
|
||||
drawn = FALSE
|
||||
tension = FALSE
|
||||
A.forceMove(get_turf(user))
|
||||
user.put_in_hands(A)
|
||||
update_icon()
|
||||
|
||||
/obj/item/gun/launcher/crossbow/bow/consume_next_projectile(mob/user)
|
||||
if(!drawn)
|
||||
if(!tension)
|
||||
to_chat(user, "<span class='warning'>\The [src] is not drawn back!</span>")
|
||||
return null
|
||||
return bolt
|
||||
|
||||
/obj/item/gun/launcher/crossbow/bow/handle_post_fire(mob/user, atom/target)
|
||||
bolt = null
|
||||
drawn = FALSE
|
||||
tension = FALSE
|
||||
update_icon()
|
||||
..()
|
||||
|
||||
/obj/item/gun/launcher/crossbow/bow/attack_hand(mob/living/user)
|
||||
if(loc == user && bolt && !drawn)
|
||||
if(loc == user && bolt && !tension)
|
||||
user.visible_message("<b>[user]</b> removes [bolt] from [src].","You remove [bolt] from [src].")
|
||||
unload(user)
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/item/gun/launcher/crossbow/bow/attack_self(mob/living/user)
|
||||
if(drawn)
|
||||
if(tension)
|
||||
user.visible_message("<b>[user]</b> relaxes the tension on [src]'s string.","You relax the tension on [src]'s string.")
|
||||
drawn = FALSE
|
||||
tension = FALSE
|
||||
update_icon()
|
||||
else
|
||||
draw(user)
|
||||
@@ -102,7 +110,7 @@
|
||||
current_user = user
|
||||
user.visible_message("<b>[user]</b> begins to draw back the string of [src].","<span class='notice'>You begin to draw back the string of [src].</span>")
|
||||
if(do_after(user, 25))
|
||||
drawn = TRUE
|
||||
tension = TRUE
|
||||
user.visible_message("<b>[user]</b> draws the string on [src] back fully!", "You draw the string on [src] back fully!")
|
||||
update_icon()
|
||||
|
||||
@@ -110,24 +118,27 @@
|
||||
return
|
||||
|
||||
/obj/item/gun/launcher/crossbow/bow/attackby(obj/item/W as obj, mob/user)
|
||||
if(!bolt && istype(W,/obj/item/arrow/wood))
|
||||
if(!bolt && (istype(W,/obj/item/arrow) || istype(W,/obj/item/material/arrow)))
|
||||
user.drop_from_inventory(W, src)
|
||||
bolt = W
|
||||
user.visible_message("[user] nocks [bolt] in [src].","You nock [bolt] in [src].")
|
||||
update_icon()
|
||||
|
||||
/obj/item/gun/launcher/crossbow/bow/update_icon()
|
||||
if(drawn)
|
||||
cut_overlays()
|
||||
if(tension)
|
||||
icon_state = "[initial(icon_state)]_firing"
|
||||
else if(bolt)
|
||||
icon_state = "[initial(icon_state)]_loaded"
|
||||
else
|
||||
icon_state = "[initial(icon_state)]"
|
||||
|
||||
add_overlay(update_bolt_transform())
|
||||
|
||||
/obj/item/gun/launcher/crossbow/bow/dropped(mob/user)
|
||||
if(drawn)
|
||||
if(tension)
|
||||
to_chat(user, "<span class='warning'>\The [src]'s tension is relaxed as you let go of it!</span>")
|
||||
drawn = FALSE
|
||||
tension = FALSE
|
||||
update_icon()
|
||||
|
||||
|
||||
@@ -139,18 +150,23 @@
|
||||
drop_sound = 'sound/items/drop/gun.ogg'
|
||||
pickup_sound = 'sound/items/pickup/gun.ogg'
|
||||
|
||||
var/arrow_type = /obj/item/arrow/energy
|
||||
|
||||
/obj/item/gun/launcher/crossbow/bow/hardlight/unload(mob/user)
|
||||
qdel_null(bolt)
|
||||
update_icon()
|
||||
if(istype(bolt, /obj/item/arrow/energy)) // Let's not delete a Real Arrow^tm
|
||||
qdel_null(bolt)
|
||||
update_icon()
|
||||
else
|
||||
. = ..()
|
||||
|
||||
/obj/item/gun/launcher/crossbow/bow/hardlight/attack_self(mob/living/user)
|
||||
if(drawn)
|
||||
if(tension)
|
||||
user.visible_message("<b>[user]</b> relaxes the tension on [src]'s string.","You relax the tension on [src]'s string.")
|
||||
drawn = FALSE
|
||||
tension = FALSE
|
||||
update_icon()
|
||||
else if(!bolt)
|
||||
user.visible_message("<b>[user]</b> fabricates a new hardlight projectile with [src].","You fabricate a new hardlight projectile with [src].")
|
||||
bolt = new /obj/item/arrow/energy(src)
|
||||
bolt = new arrow_type(src)
|
||||
update_icon()
|
||||
else
|
||||
draw(user)
|
||||
draw(user)
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
sharp = 1
|
||||
edge = 0
|
||||
|
||||
var/list/knock_point = list(6,6)
|
||||
|
||||
/obj/item/arrow/proc/removed() //Helper for metal rods falling apart.
|
||||
return
|
||||
|
||||
@@ -37,6 +39,8 @@
|
||||
item_state = "quill"
|
||||
throwforce = 5
|
||||
|
||||
knock_point = list(10,11)
|
||||
|
||||
/obj/item/arrow/rod
|
||||
name = "metal rod"
|
||||
desc = "Don't cry for me, Orithena."
|
||||
@@ -60,6 +64,11 @@
|
||||
fire_delay = 25
|
||||
slot_flags = SLOT_BACK
|
||||
|
||||
// Pixel location the arrow should rest on.
|
||||
var/list/drawn_knock = list(10,9)
|
||||
var/list/ready_knock = list(4,3)
|
||||
var/bolt_rotation_transform = 180 // Crossbows point 'southwest' in their ground icon, so the arrows have to be flipped around.
|
||||
|
||||
var/obj/item/bolt
|
||||
var/tension = 0 // Current draw on the bow.
|
||||
var/max_tension = 5 // Highest possible tension.
|
||||
@@ -139,7 +148,7 @@
|
||||
|
||||
/obj/item/gun/launcher/crossbow/attackby(obj/item/W as obj, mob/user as mob)
|
||||
if(!bolt)
|
||||
if (istype(W,/obj/item/arrow))
|
||||
if (istype(W,/obj/item/arrow) || istype(W, /obj/item/material/arrow))
|
||||
user.drop_from_inventory(W, src)
|
||||
bolt = W
|
||||
user.visible_message("[user] slides [bolt] into [src].","You slide [bolt] into [src].")
|
||||
@@ -179,6 +188,14 @@
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/gun/launcher/crossbow/attack_hand(mob/living/user)
|
||||
. = ..()
|
||||
update_icon()
|
||||
|
||||
/obj/item/gun/launcher/crossbow/dropped(mob/user)
|
||||
. = ..()
|
||||
update_icon()
|
||||
|
||||
/obj/item/gun/launcher/crossbow/proc/superheat_rod(var/mob/user)
|
||||
if(!user || !cell || !bolt) return
|
||||
if(cell.charge < 500) return
|
||||
@@ -190,7 +207,29 @@
|
||||
bolt.icon_state = "metal-rod-superheated"
|
||||
cell.use(500)
|
||||
|
||||
/obj/item/gun/launcher/crossbow/proc/update_bolt_transform()
|
||||
if(!(istype(bolt,/obj/item/arrow) || istype(bolt, /obj/item/material/arrow)))
|
||||
return
|
||||
|
||||
var/obj/item/arrow/dart = bolt
|
||||
|
||||
if(LAZYLEN(drawn_knock) && LAZYLEN(ready_knock) && LAZYLEN(dart.knock_point))
|
||||
dart.SetTransform(rotation = bolt_rotation_transform)
|
||||
|
||||
if(!tension)
|
||||
dart.SetTransform(offset_x = ready_knock[1] - dart?.knock_point[1], offset_y = ready_knock[2] - dart?.knock_point[2])
|
||||
|
||||
else
|
||||
dart.SetTransform(offset_x = drawn_knock[1] - dart?.knock_point[1], offset_y = drawn_knock[2] - dart?.knock_point[2])
|
||||
|
||||
var/image/dart_image = image(dart)
|
||||
dart_image.plane = plane // Make sure it's the same plane as the parent, otherwise we get phantom bolts.
|
||||
dart.ClearTransform()
|
||||
|
||||
return dart_image
|
||||
|
||||
/obj/item/gun/launcher/crossbow/update_icon()
|
||||
cut_overlays()
|
||||
if(tension > 1)
|
||||
icon_state = "crossbow-drawn"
|
||||
else if(bolt)
|
||||
@@ -198,6 +237,8 @@
|
||||
else
|
||||
icon_state = "crossbow"
|
||||
|
||||
if((istype(bolt,/obj/item/arrow) || istype(bolt, /obj/item/material/arrow)))
|
||||
add_overlay(update_bolt_transform())
|
||||
|
||||
// Crossbow construction.
|
||||
/obj/item/crossbowframe
|
||||
|
||||
Reference in New Issue
Block a user