ID:178263
 
i know it's been done, but i want to know if an arrow misses, lets say a guy at range 12, and my arrow has a range of 24, so how do i make it check to see if it hit the guy, and not interrupt it's flight pattern, and then make it keep flying out to it's full range, even hitting anyone else in it's path? On top of that lets say it encounters a object with a density of 1, lets say I want it to smack into that object and stop. Thanks!
Ter13 wrote:
i know it's been done, but i want to know if an arrow misses, lets say a guy at range 12, and my arrow has a range of 24, so how do i make it check to see if it hit the guy, and not interrupt it's flight pattern, and then make it keep flying out to it's full range, even hitting anyone else in it's path? On top of that lets say it encounters a object with a density of 1, lets say I want it to smack into that object and stop. Thanks!

Since mobs already have a density of 1, this is inconsistent with what you said about the arrow going through mobs.
What you're going to have to do here is make a custom movement proc for the arrow in flight, and not rely on walk() and Bump() as some do.
obj/arrow/inflight
density=0 // it is anyway, but let's be absolutely sure
var/mob/owner
New(newloc,whofired,_dir)
..()
dir=_dir
owner=whofired
spawn(-1) Go()

proc/Go()
if(!loc) del(src)
var/atom/newloc=get_step(src,dir)
if(newloc.density) // stop at a wall
view(src) << sound('arrow_clink.wav')
del(src)
for(var/obj/O in newloc)
if(O.density) // stop at a dense obj but not a mob
view(src) << sound('arrow_clink.wav')
del(src)
Move(newloc)
// hurt any mobs in the flight path
for(var/mob/M in loc)
var/actualdamage=M.Damage(10)
M << "[owner] hits you with \a [src] <B>([actualdamage])</B>"
if(owner) owner << "You hit [M] with \a [src] <B>([actualdamage])</B>"
oview(M)-owner << "[owner] hits [M] with \a [src] <B>([actualdamage])</B>"
view(M) << sound('arrow_hit.wav')
if(M.health<=0)
M.Die(owner)
owner << "You killed [M]!"
oview(M)-owner << "[M] is killed!"
spawn(2) Go()

When you spawn the arrow, spawn it at your own location (it will immediately travel outward) like this:
verb/Fire()
set src=usr
if(arrows<=0) return
--arrows
new /obj/arrow/inflight(usr.loc,usr.dir)

I hope that helps.

Lummox JR