1
2
In response to SSJ2GohanDBGT
|
|
Ok, Sorry I jumped at you then.
|
In response to Crispy
|
|
But each Enemy I have coded does something different >_>..
Also, to make all the mobs do 1 loop instead...would I just run the code of the base mob? mob |
In response to ITG Master
|
|
Meh Bump
|
In response to ITG Master
|
|
You've got the wrong end of the stick, I'm afraid. =) That will still produce 1 loop per mob. Also, you can still have each mob behaving differently.
In its simplest (and crappiest) form, a global mob AI loop generally looks something like this: world/New() // When the game starts Problems with the above snippet:
|
In response to Crispy
|
|
It loops through the entire world looking for mobs every second. This is bad. A better way is to keep a list of all /mob/Enemy objects, and loop through that instead. The most efficient way to do so is to make a global variable to hold the list, add src to it in mob/Enemy/New(), and remove src from it in mob/Enemy/Del(). Remember to call ..() in both New() and Del(); also, any lines after ..() in Del() will not be executed, so remove src from the list before the ..() line. Better yet rather than in New() and Del() only do it when a mob needs to be active like when a player enters the area or gets close. No point in having a mob do stuff if no one is around to see or be affected. |
In response to ITG Master
|
|
ITG Master wrote:
I just have never had to deal with loops before. Amazing... Really, never? I've rarely coded anything that didn't involve some sort of a loop. Absolute Zer0 |
1
2
Exactly. That's the more efficient way to do it.