Files
Paradise/code/modules/projectiles/guns/throw.dm
warriorstar-orion 525c68d617 Attack chain, initial setup. (pull *immediately* for *any* TM issues) (#26834)
* refactor: Attack chain, initial setup.

* migrate curtain to make dreamchecker happy

* update thurible

* don't call attacked_by separately for legacy attack chain

* remove duplicate proc

* condense similar code, put allowances for legacy code in new procs

* update docs, include diagram source

* add comment on how to update diagram

* fix admonition

* mindflayer updates

* remove commented out code

* clarify all steps

* after_attack should be overridable

* whoops

* retrofit recent changes

* duh, can't restrict this yet because of tool_acts

* i hate ore bags with the fire of a thousand suns

* return correct value for object attack logic

* Various cleanups.

We don't want to attempt to pull stuff out of `/obj/item/attackby`,
because those pieces are part of the related objects' migrations, not
`/obj/item` itself. Attempting to do this causes knockon effects where
things expected to call e.g. `/obj/item/storage/attackby` in the call
chain were not ferried over to the new item interaction code, because
the related objects hadn't actually been migrated over yet.

I've used refactoring /obj/vehicle as the example for migrating
`attackby` methods instead.

* simplify some argument names

* fuck it

* make it do the thing

* Rename CI module call

* Prove that CI works

* improve test output

* aaand fix it again

* fix curtain tool interactions

* fix compile error

* fix compile error

* Better docs, introduce migration plan tool.
2024-12-02 23:36:36 +00:00

94 lines
2.5 KiB
Plaintext

/obj/item/gun/throw
name = "abstract item thrower"
desc = "This shouldn't be here, yell at a coder."
fire_sound = 'sound/weapons/punchmiss.ogg'
fire_sound_text = "thwock"
var/obj/item/to_launch
var/list/valid_projectile_type
var/max_capacity = 1
var/list/loaded_projectiles = list()
var/projectile_speed = 1
var/projectile_range = 1
/obj/item/gun/throw/proc/notify_ammo_count()
return
/obj/item/gun/throw/proc/get_throwrange()
return projectile_range
/obj/item/gun/throw/proc/get_throwspeed()
return projectile_speed
/obj/item/gun/throw/proc/modify_projectile(obj/item/I, on_chamber = 0)
return
/obj/item/gun/throw/proc/get_ammocount(include_loaded = 1)
var/count = length(loaded_projectiles)
if(include_loaded && to_launch)
count++
return count
/obj/item/gun/throw/examine(mob/user)
. = ..()
. += "<span class='notice'>It is [to_launch ? "loaded with \a [to_launch]" : "not loaded"].</span>"
. += notify_ammo_count()
/obj/item/gun/throw/Destroy()
QDEL_NULL(to_launch)
QDEL_LIST_CONTENTS(loaded_projectiles)
loaded_projectiles = null
return ..()
/obj/item/gun/throw/update_icon_state()
return
/obj/item/gun/throw/update_overlays()
return list()
/obj/item/gun/throw/attackby__legacy__attackchain(obj/item/I, mob/user, params)
if(istype(I, valid_projectile_type) && !(I.flags & NODROP))
if(get_ammocount() < max_capacity)
user.drop_item()
I.forceMove(src)
loaded_projectiles += I
to_chat(user, "<span class='notice'>You load [I] into [src].</span>")
if(!to_launch)
process_chamber()
to_chat(user, notify_ammo_count())
else
to_chat(user, "<span class='warning'>[src] cannot hold any more projectiles.</span>")
else
to_chat(user, "<span class='warning'>You cannot load [I] into [src]!</span>")
/obj/item/gun/throw/process_chamber()
if(!to_launch && length(loaded_projectiles))
to_launch = loaded_projectiles[1]
loaded_projectiles -= to_launch
return
/obj/item/gun/throw/can_shoot()
if(to_launch)
return 1
return 0
/obj/item/gun/throw/process_fire(atom/target as mob|obj|turf, mob/living/user as mob|obj, message = 1, params, zone_override)
add_fingerprint(user)
if(semicd)
return
var/obj/item/I = to_launch
I.forceMove(get_turf(src))
to_launch = null
modify_projectile(I)
playsound(user, fire_sound, 50, 1)
I.throw_at(target, get_throwrange(), get_throwspeed(), user, FALSE)
message_admins("[key_name_admin(user)] fired \a [I] from a [src].")
log_game("[key_name_admin(user)] used \a [src].")
process_chamber()
semicd = 1
spawn(fire_delay)
semicd = 0