hsmissile
icon_state = "hsmissile"
New()
spawn(55)
del(src)
spawn(5)
Seek()
proc/Seek()
var/mob/M
var/N=NORTH ; var/NE=NORTHEAST ; var/E=EAST ; var/SE=SOUTHEAST ; var/S=SOUTH ; var/SW=SOUTHWEST ; var/W=WEST ; var/NW=NORTHWEST
var/one = turn(src.dir, 45) ; var/two = turn(src.dir, -45)
for(M in oview(6))
var/D = get_dir(src,M)
if(D == N) {if(src.dir == N) ..();if(src.dir == NE) src.dir = one ;if(src.dir == E) src.dir = one ;if(src.dir == SE) src.dir = one ;if(src.dir == S) src.dir = one ;if(src.dir == SW) src.dir = two ;if(src.dir == W) src.dir = two ;if(src.dir == NW)src.dir = two }
if(D == NE) {if(src.dir == N) src.dir = two ;if(src.dir == NE) ..();if(src.dir == E) src.dir = one ;if(src.dir == SE) src.dir = one ;if(src.dir == S) src.dir = one ;if(src.dir == SW) src.dir = one ;if(src.dir == W) src.dir = two ;if(src.dir == NW)src.dir = two }
if(D == E) {if(src.dir == N) src.dir = two ;if(src.dir == NE) src.dir = two ;if(src.dir == E) ..();if(src.dir == SE) src.dir = one ;if(src.dir == S) src.dir = one ;if(src.dir == SW) src.dir = one ;if(src.dir == W) src.dir = one ;if(src.dir == NW)src.dir = two }
if(D == SE) {if(src.dir == N) src.dir = two ;if(src.dir == NE) src.dir = two ;if(src.dir == E) src.dir = two ;if(src.dir == SE) ..();if(src.dir == S) src.dir = one ;if(src.dir == SW) src.dir = one ;if(src.dir == W) src.dir = one ;if(src.dir == NW)src.dir = two }
if(D == S) {if(src.dir == N) src.dir = two ;if(src.dir == NE) src.dir = two ;if(src.dir == E) src.dir = two ;if(src.dir == SE) src.dir = two ;if(src.dir == S) ..();if(src.dir == SW) src.dir = one ;if(src.dir == W) src.dir = one ;if(src.dir == NW)src.dir = one }
if(D == SW) {if(src.dir == N) src.dir = one ;if(src.dir == NE) src.dir = two ;if(src.dir == E) src.dir = two ;if(src.dir == SE) src.dir = two ;if(src.dir == S) src.dir = two ;if(src.dir == SW) ..();if(src.dir == W) src.dir = one ;if(src.dir == NW)src.dir = one }
if(D == W) {if(src.dir == N) src.dir = one ;if(src.dir == NE) src.dir = one ;if(src.dir == E) src.dir = two ;if(src.dir == SE) src.dir = two ;if(src.dir == S) src.dir = two ;if(src.dir == SW) src.dir = two ;if(src.dir == W) ..();if(src.dir == NW)src.dir = one }
if(D == NW) {if(src.dir == N) src.dir = one ;if(src.dir == NE) src.dir = one ;if(src.dir == E) src.dir = one ;if(src.dir == SE) src.dir = two ;if(src.dir == S) src.dir = two ;if(src.dir == SW) src.dir = two ;if(src.dir == W) src.dir = two ;if(src.dir == NW) ..()}
walk(src,src.dir,2)
spawn(5)
Seek()
Bump(mob/M)
if(istype(M,/mob))//if its a mob
world<<"[M] was shot by [src.owner]'s heet seeking missile."
del(src)//delete the obj that hit the mob
else
del(src)
..()<dm>
And then the verb to fire the missile is
<dm>
fire_heat_seeker()
var/obj/hsmissile/H = new(usr.loc)
H.owner = usr.name
H.dir = usr.dir
walk(H,H.dir,2)
<dm>
I'm assuming youll ask why im not working with bit flags Lummox, well i couldnt figure it out, i need some time to get used to them.
ID:148552
![]() Jan 1 2003, 8:58 pm
|
|
Theres just a couple problems, when you get 3 or 4 mobs within range, the missile goes crazy, is there a way to select one mob within range and only track that mob? A way that will work with what I have here that is, if it wont work ill have to make it work.
|
Instead of looping through mobs in Seek(), when the missile is first spawned you should give it a target right then and there. If it doesn't have one, it should go straight, possibly locking onto a target if one comes into range.
This wouldn't be the best way to go about this; instead, using the New() code I did above where the player who fired is a 2nd argument to new():
Most of that code is cut & paste, though; it shouldn't be hard to adapt to what you have. I can't fault you for not understanding them, though; a lot of what I wrote there was brand new to me, something I'd just come up with.
Lummox JR