ID:168268
 
Is there a way to find out if a mob is on a turf? I would be using a for statement.

Like:

for(var/turf/T in oview())
if(src.Target is in on the turf)
T.Click(src)
if(src.Target in T)
In response to Jon88 (#1)
Wouldn't that mean that Target has to be in T, a turf's contents? I don't even think turf has contents.
Why not just if(src.Target.loc==T.loc)?
In response to Jon88 (#1)
Another question, how would I locate a target. I am already using a for() for turfs in the view. If I added a for() for selected a mob target that would cause lag, is there another way I can get the player a target.
In response to Blakdragon77 (#3)
if(locate(src.Target)in oview(T))?
In response to Artemio (#2)
Nope, turf has contents.
In response to Artemio (#4)
I mean selecting a target.
In response to Kalzar (#5)
Ah, thanks for clearing that up.
At any rate, I would doubt that a turf would contain a mob in the general type of games on BYOND.

Blak, could you elaborate? I don't get what you mean exactly.
In response to Artemio (#7)
Um, when you Enter() a turf, you enter it's contents. So where ever you are, whatever the game is (except for text-based games), you are in the turf's contents.
In response to Kalzar (#8)
Meh. Never knew that. I never looked it up in the reference and assumed that when you Entered() a turf you were in/on its location.
In response to Artemio (#9)
I mean, how would you make a mob in the src's view a target without causing lag, I used a for() loop before.
In response to Blakdragon77 (#10)
Blakdragon77 wrote:
I mean, how would you make a mob in the src's view a target without causing lag, I used a for() loop before.

If you want to pick one at psuedo-random...
var/mob/specifictypeofmob/M = locate() in view(src)
if(M)
src << "We found a mob!"
else
src << "Nothing..."
In response to Jon88 (#11)
This is what I have, so far it isnt looking to good.
mob/proc/Fire()
while(src)
if(!src.Target)
var/mob/M = locate() in view(src)
if(M)
src.Target = M
else
for(var/turf/T in oview(src))
if(src.Target == T)
T.Click(src)
sleep(50)


We will need to take this to Code Problems soon?