ID:178485
 
I need a way for the code to determine if an object has passed over a turf with a density of 1.

This is using the missile() proc, and I can't seem to prevent it from passing through walls.

Oh, and please don't direct me to the s_missile() lib. It would be much more helpful if you could simply post the code required here.

Thanks.
Malver wrote:
This is using the missile() proc, and I can't seem to prevent it from passing through walls.

True, because if you look at the help for the missile proc, you'll see this: "The effect is purely visual."

Oh, and please don't direct me to the s_missile() lib. It would be much more helpful if you could simply post the code required here.

I won't direct you to s_missile, instead I would like you to write a missile lib that uses pixel movement to create the smooth exact movement you want.

Please let me know when you're finished!


/Andreas
I haven't used the missile proc before, but take a look at the reference entry for it:
<font color="white">
Format:
missile(Type, Start, End)
Args:
Type: An object prototype or icon file.
Start: The starting location.
End: The ending location.

Send a missile of the given Type between two locations. The effect is purely visual. When Type is an object, its icon is used for the missile.
</font>

It looks like this is a pretty general proc that will not take density into account. I don't think you're going to be able to do it without coding you're own missile proc.

Try a loop with get_step_towards(). That proc will check the next location in a given direction. Grab the turf there, and check its density.


In response to Gazoot
"I won't direct you to s_missile, instead I would like you to write a missile lib that uses pixel movement to create the smooth exact movement you want." - Gazoot

If I knew how to, then why would I of asked for help on this forum? o.O

I know how to now, thanks to Skysaw's suggestions. Thanks, Sky. :)
In response to Gazoot
Hey, I'm slowly working on one of those :o)
In response to Malver
Errrr....its not going along as smoothly as planned. ;)

Here's what I've got:

Shoot_Arrow(mob/NPC/M as mob in oview(4))
var/obj/A
A = new /obj/arrow
if(src.arrows < 1)
src<<"You have no arrows!"
return
src<<"You nock an arrow to your bow."
sleep(20)
A.loc = src.loc
while(A)
if(M in oview(1))
del(A)
break
if(M in oview(4))
step_towards(A, M)
sleep(1)
else
del(A)
break

sleep(7)
src.arrows--
M.HP-=30
M.Deathcheck()

Now, the arrow goes to the enemy and kills them fine, but I need a way for it to know if it is being blocked by a wall. It's a bit odd to see the arrow hover there next to the wall for 20 seconds, and when the mob that it has targetted finally goes near it, the arrow changes it's direction to kill it. ;)

Oh, and I need to be able to implement exceptions for certain turfs, seeing as I don't want the arrows to be blocked by water. ;)

Thankyap.
In response to Malver
Make sure the arrow object you're shooting is dense, then tell it to delete (or stop, whatever) if it Bump()s any dense atoms that aren't mobs.

<code>obj/arrow/Bump(atom/A) if(!ismob(A)) del(src)</code>

Something like that.
In response to Malver
There are some nice little html tags you can use on these forums called "code" and "DM". Here's an example: <code>Shoot_Arrow(mob/NPC/M as mob in oview(4)) var/obj/A A = new /obj/arrow if(src.arrows < 1) src<<"You have no arrows!" return src<<"You nock an arrow to your bow." sleep(20) A.loc = src.loc while(A) if(M in oview(1)) del(A) break if(M in oview(4)) step_towards(A, M) sleep(1) else del(A) break sleep(7) src.arrows-- M.HP-=30 M.Deathcheck()</code>

Just to make it easier to read, for future reference. the DM tag does the same thing, only it doesn't render html within the code.
In response to Malver
Malver wrote:
"I won't direct you to s_missile, instead I would like you to write a missile lib that uses pixel movement to create the smooth exact movement you want." - Gazoot

If I knew how to, then why would I of asked for help on this forum? o.O

Just wanted you to think a little longer. get_step_towards() has some strange behaviour on longer distances. Why do you think s_missile was created?


/Andreas
In response to Gazoot
Gazoot wrote:
Malver wrote:
"I won't direct you to s_missile, instead I would like you to write a missile lib that uses pixel movement to create the smooth exact movement you want." - Gazoot

If I knew how to, then why would I of asked for help on this forum? o.O

Just wanted you to think a little longer. get_step_towards() has some strange behaviour on longer distances. Why do you think s_missile was created?


/Andreas

Eh, it's okay now. I've got it figured out and it's working fine.

As for that whole "thinking" part...you lost me at "Just".

Heh, just kidding. Thanks for caring, but I learn better if I have something to work from.

I don't feel like reading this entire thread, but I'm going to post a possible solution anyway. I have a hunch that there may be an easier way to do this, but I would handle it in the following way:

seeker
parent_type = /obj
invisibility = 100
density = 0 //objs may already have a density of 0, but I don't want to look it up
proc/checkDensity()
var/i = locate(x,y,z)
var/dense = i.density
for(var/atom/A in i) dense += A.density
if(!dense) return 1
else return 0
mob/proc/fireArrow(var/turf/target)
var/seeker = new /seeker (x,y,z)
step(seeker,get_dir(src,target))
while(seeker.checkDensity())
step(seeker,get_dir(seeker,target))
var/i = locate(seeker.x,seeker.y,seeker.z)
missile(yourArrowImage,src,i)

Note you that this is untested, but it should work with a little or no tweaking. Good luck!

-LoW
In response to Lord of Water
Lord of Water wrote:
I don't feel like reading this entire thread, but I'm going to post a possible solution anyway.

Well, if you DID read it, then you might of known that the problem was solved. Man, wasting time is fun, eh? ;)