Hey guys, ive searched a few demos looking for how to make monsters attack the user. they wander around randomly until they see the user. but... this is the bit i cant code >__<
can some one give me an idea or a snippet of code i can start from?
Thanks in advance,
Farkas
ID:171447
Sep 23 2004, 3:02 am
|
|
In response to Farkas
|
|
Three problems:
|
In response to Lummox JR
|
|
ok, i have done this based on your advice,
proc now the monsters run to me but then go CRAZY and keep runing round me, which is lagging me!! what am i doing wrong now? |
In response to Farkas
|
|
Farkas wrote:
now the monsters run to me but then go CRAZY and keep runing round me, which is lagging me!! You shouldn't be making your decision to move inside the for() loop. Instead, use that to find a mob suitable to attack. If such a mob is found, break. If the loop finishes without any player being found, then M will be null. To change this, you need to declare var/mob/M before the for() loop. Lummox JR |
In response to Lummox JR
|
|
i have tried different ways to use the for loop, none of which seem to work for me, perhaps you could do me a small example of how to use the for loop correctly?
Farkas |
In response to Farkas
|
|
i have been trying for well over 6 hours now, i am not getting any closer to achieving my goal, can some one please, lend me a hand?
Farkas |
In response to Lummox JR
|
|
Lummox JR wrote:
You shouldn't be making your decision to move inside the for() loop. Instead, use that to find a mob suitable to attack. If such a mob is found, break. If the loop finishes without any player being found, then M will be null. If the loop finishes without a player being found, M will either be an NPC or, if NO mobs are found, null. If view(src) is being used, M will never be null, because src is always in view(src). |
In response to Garthor
|
|
Garthor wrote:
Lummox JR wrote: I'm talking about a corrected loop here. If it finishes normally, M will be null. If he breaks out when he finds a player to attack, M will be that player. If view(src) is being used, M will never be null, because src is always in view(src). Ah, but you can also go by the NPC test here. If looking for a player, then the mob itself will be skipped. Still oview(src) would be a better choice. Lummox JR |
In response to Lummox JR
|
|
SORTED
|
In response to Farkas
|
|
Not really. I won't start an argument over something as trivial as this, but, despite his statements to the contrary, he did say to do something along the lines of:
var/mob/M Which isn't right. |
In response to Garthor
|
|
Eh. That would actually work, although I didn't say it's the best method. Clearly the best method is to have a target preselected, move toward it if it's in view, and if not to find another target.
Lummox JR |
the monster still wont walk to me, can any one tell me whats wrong?