Collision based AI trigger (/AITrigger)

by Tafe
Manage CPU usage by using bounds and collision detection to trigger AI
ID:2473639
 
Been using this method a while myself, it's probably one of the most efficient ways you can pull this off on BYOND.
In response to Nadrew
Nadrew wrote:
Been using this method a while myself, it's probably one of the most efficient ways you can pull this off on BYOND.

Yes, I agree. I honestly thought it was weird how i couldn't find other libraries or demos for this, so i simply couldn't stop myself from making one.
I threw one out on Discord a while ago but never really bothered to properly turn it into a hub entry. It's still sitting on my Google drive.
One thing you do need to add is type checking in your Crossed(), having

Crossed(mob/M)


Doesn't actually assure that the argument is in fact a mob, just like Entered(). You'll want an ismob() there otherwise mobile objects will also trigger your monsters.
Forsome oddball reason, it wasn't working correctly durring ResetState. Bugs the crap out of me when i make something work, copy it into an empty project. now it doesn't work anymore.

Working on a fix.
Somehow, the movement in ResetState() gets stuck in a loop, and isn't properly calculated to move towars home_loc. the distance is greater than 0, but yet he stops moving and continues the movement loop.

Edit:
The location is saved as a turf, which is 32x32 while Monster is moving 2 steps. So it is probably a conflict between tile size and step size

Login to reply.