Files
Paradise/code/modules/projectiles/guns/throw/crossbow.dm
T
Vi3triceandGitHub f4b37b4177 Port TG updating appearances (#17943)
* Get pants that match or else you gonna look silly yo

* Posters

* Fix other hud elements

* Rereviewed

* Update shotglass.dm

* Fix for new merged PRs

* Typo

* Coming across other stuff

* Update theblob.dm

* No takebacksies

* smh i forget to leave a comment

* Updated for the detgun and cards

* Should have rerun langserver again

* No longer plastic, more in scope

* Damn you bluespace

* Reverting turret logic, out of scope at this point

* Tweak that part

* Went over energy guns again, and fixed UI White's sprite sheet

* Welding masks, glasses, and JUSTICE

* Update portable_atmospherics.dm

* Cleaning up, clearing things up

* Review and suggestions

* Update valve.dm

* More tweaks

* Missing character

* Not distinct lightmasks, so they can be overlays

* Update generator.dm

* Add parameter so holodeck doesn't try to make a perfect copy

* Update unsorted.dm

* Spiders

* Better fix for spiders, fix vamps too

* Ghosts

* Update telekinesis.dm

* Cleaning up old procs

* It's set up to not copy datums... Unless they're in a list

* Donuts, duct tape, and detgun. D3VR coming to Early Access

* Update procs that interact with doors so they call update_state instead

* Forgot one spot, and actually might as well just force lock

* Cleaning up other things... Sigh, and kitty ears

* oops

* Getting used to how it works

* blinds

* Going back to the suit obscuring thing, so it doesn't update all the time

* Missed that from merging master

* I made this PR and forgot about it

* Fix runtimes in cards

* Make things a bit more unified

* Update update_icons.dm

* yarn, really?

* Update library_equipment.dm

* Update shieldgen.dm

* Every time Charlie merges something, I go back and see if I can improve things further

* what's this? more?

* Update misc_special.dm

* wow, paper

* Review

* More reviews

* To be sure, seems like being broken messed something sometimes

* Brought airlocks closer to how TG works to iron out some stuff

* Pizza and morgue

* Doesn't seem to hurt, tried with holodeck

* Revert "Doesn't seem to hurt, tried with holodeck"

This reverts commit 158529302b.

* Icon conflict

* Fix organ damage

* Don't ask how. Why. It's like that on prod too.

* Cutting down on things and updating from TG.

* More flexible. Just in case the thing you stuck it on didn't destroy.

* Hydro was one the things I touched earlier on, better rework it

* Reviews

* Cleaning up further, also bri'ish

* Undo a change I did, and switch over to a more recent implementation

* Update biogenerator.dm

* Rolling back to old airlocks, but with new duct taped note

* Functionally the same. I'd just rather not have the smoothing happen there

* Went over APCs again

* Fix welding helmet names in species files

* Update airlock.dm

* Update persistent_overlay.dm

* Oh, topic
2022-07-21 08:11:59 +02:00

187 lines
5.8 KiB
Plaintext

#define XBOW_TENSION_20 "20%"
#define XBOW_TENSION_40 "40%"
#define XBOW_TENSION_60 "60%"
#define XBOW_TENSION_80 "80%"
#define XBOW_TENSION_FULL "100%"
/obj/item/gun/throw/crossbow
name = "powered crossbow"
desc = "A modern twist on an old classic. Pick up that can."
icon_state = "crossbow"
item_state = "crossbow-solid"
fire_sound_text = "a solid thunk"
fire_delay = 25
valid_projectile_type = /obj/item/arrow
var/tension = 0
var/drawtension = 5
var/maxtension = 5
var/speed_multiplier = 5
var/range_multiplier = 3
var/obj/item/stock_parts/cell/cell = null // Used for firing superheated rods.
var/list/possible_tensions = list(XBOW_TENSION_20, XBOW_TENSION_40, XBOW_TENSION_60, XBOW_TENSION_80, XBOW_TENSION_FULL)
/obj/item/gun/throw/crossbow/get_cell()
return cell
/obj/item/gun/throw/crossbow/emp_act(severity)
if(cell && severity)
emp_act(severity)
/obj/item/gun/throw/crossbow/update_icon_state()
if(!tension)
if(!to_launch)
icon_state = "[initial(icon_state)]"
else
icon_state = "[initial(icon_state)]-nocked"
else
icon_state = "[initial(icon_state)]-drawn"
/obj/item/gun/throw/crossbow/examine(mob/user)
. = ..()
if(cell)
. += "<span class='notice'>\A [cell] is mounted onto [src]. Battery cell charge: [cell.charge]/[cell.maxcharge]"
else
. += "<span class='notice'>It has an empty mount for a battery cell.</span>"
/obj/item/gun/throw/crossbow/modify_projectile(obj/item/I, on_chamber = 0)
if(cell && on_chamber && istype(I, /obj/item/arrow/rod))
var/obj/item/arrow/rod/R = I
visible_message("<span class='danger'>[R] plinks and crackles as it begins to glow red-hot.</span>")
R.throwforce = 15
R.superheated = 1
cell.use(500)
/obj/item/gun/throw/crossbow/get_throwspeed()
return tension * speed_multiplier
/obj/item/gun/throw/crossbow/get_throwrange()
return tension * range_multiplier
/obj/item/gun/throw/crossbow/process_chamber()
..()
if(to_launch)
modify_projectile(to_launch, 1)
update_icon(UPDATE_ICON_STATE)
/obj/item/gun/throw/crossbow/attack_self(mob/living/user)
if(tension)
if(to_launch)
user.visible_message("<span class='notice'>[user] relaxes the tension on [src]'s string and removes [to_launch].</span>","<span class='notice'>You relax the tension on [src]'s string and remove [to_launch].</span>")
to_launch.forceMove(get_turf(src))
var/obj/item/arrow/A = to_launch
to_launch = null
A.removed()
process_chamber()
else
user.visible_message("<span class='notice'>[user] relaxes the tension on [src]'s string.</span>","<span class='notice'>You relax the tension on [src]'s string.</span>")
tension = 0
update_icon(UPDATE_ICON_STATE)
else
draw(user)
/obj/item/gun/throw/crossbow/proc/draw(mob/living/user)
if(user.incapacitated())
return
if(!to_launch)
to_chat(user, "<span class='warning'>You can't draw [src] without a bolt nocked.</span>")
return
user.visible_message("[user] begins to draw back the string of [src].","You begin to draw back the string of [src].")
if(do_after(user, 25 * drawtension, target = user))
tension = drawtension
user.visible_message("[usr] draws back the string of [src]!","[src] clunks as you draw the string to its maximum tension!!")
update_icon(UPDATE_ICON_STATE)
/obj/item/gun/throw/crossbow/attackby(obj/item/I, mob/user, params)
if(!istype(I, /obj/item/stock_parts/cell))
return ..()
if(cell)
to_chat(user, "<span class='notice'>[src] already has a cell installed.</span>")
return
user.drop_item()
I.forceMove(src)
cell = I
to_chat(user, "<span class='notice'>You jam [cell] into [src] and wire it to the firing coil.</span>")
process_chamber()
/obj/item/gun/throw/crossbow/screwdriver_act(mob/user, obj/item/I)
. = ..()
if(!cell)
to_chat(user, "<span class='notice'>[src] doesn't have a cell installed.</span>")
return
cell.forceMove(get_turf(src))
to_chat(user, "<span class='notice'>You jimmy [cell] out of [src] with [I].</span>")
cell = null
/obj/item/gun/throw/crossbow/verb/set_tension()
set name = "Adjust Tension"
set category = "Object"
set src in range(0)
var/mob/user = usr
if(user.incapacitated())
return
var/choice = input("Select tension to draw to:", "[src]", XBOW_TENSION_FULL) as null|anything in possible_tensions
if(!choice)
return
switch(choice)
if(XBOW_TENSION_20)
drawtension = CEILING(0.2 * maxtension, 1)
if(XBOW_TENSION_40)
drawtension = CEILING(0.4 * maxtension, 1)
if(XBOW_TENSION_60)
drawtension = CEILING(0.6 * maxtension, 1)
if(XBOW_TENSION_80)
drawtension = CEILING(0.8 * maxtension, 1)
if(XBOW_TENSION_FULL)
drawtension = maxtension
/obj/item/gun/throw/crossbow/process_fire(atom/target as mob|obj|turf, mob/living/user as mob|obj, message = 1, params, zone_override)
..()
tension = 0
update_icon(UPDATE_ICON_STATE)
/obj/item/gun/throw/crossbow/french
name = "french powered crossbow"
icon_state = "fcrossbow"
valid_projectile_type = /obj/item/reagent_containers/food/snacks/baguette
/obj/item/gun/throw/crossbow/french/modify_projectile(obj/item/I, on_chamber = 0)
return
/obj/item/arrow
name = "bolt"
desc = "It's got a tip for you - get the point?"
icon_state = "bolt"
item_state = "bolt"
throwforce = 20
w_class = WEIGHT_CLASS_NORMAL
sharp = TRUE
/obj/item/arrow/proc/removed() //Helper for metal rods falling apart.
return
/obj/item/arrow/rod
name = "makeshift bolt"
desc = "A sharpened metal rod that can be fired out of a crossbow."
icon_state = "metal-rod"
throwforce = 10
var/superheated = 0
/obj/item/arrow/rod/removed()
if(superheated) // The rod has been superheated - we don't want it to be useable when removed from the bow.
visible_message("[src] shatters into a scattering of overstressed metal shards as it leaves the crossbow.")
qdel(src)
#undef XBOW_TENSION_20
#undef XBOW_TENSION_40
#undef XBOW_TENSION_60
#undef XBOW_TENSION_80
#undef XBOW_TENSION_FULL