AI methods in JS
Moderators: winston, another_commander
AI methods in JS
I'd like to code purely in JS, yet there are some methods which are seemingly only available using legacy AI scripts - eg performFlyToRangeFromDestination, performFaceDestination to mention just the two I needed to use recently. This inevitably results in having to mix scripts if you want to use the more advanced stuff only available through JS. Is there some way to run commands like this from JS that I'm missing, or if not, are there plans to incorporate stuff like this into JS so coding can become more consistent?
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
AIs will retain their current form through the next stable release. After that, there is the outline of a plan to add a Javascript AI system. An effect of this will be to make all AI methods available to Javascript.
E-mail: [email protected]
The best way at the moment is to twin together an AI plist and a JS script. There is the AI command sendScriptMessage and the js command reactToAIMessage which allows the two to interact and steer each other.
Plus you can use the JS commands setAI and switchAI to change the AI the entity is currently using (with or without leaving the old one on the stack) and AIState to switch states within the current AI (ATTACK_SHIP, GLOBAL, FLEE or your own custom states etc).
Have a look in some of my OXPs (Drones, Captured Thargons, Aquatics to name but three) to find some examples of those in use, plus OXPs by Eric Walch and several other people.
Plus you can use the JS commands setAI and switchAI to change the AI the entity is currently using (with or without leaving the old one on the stack) and AIState to switch states within the current AI (ATTACK_SHIP, GLOBAL, FLEE or your own custom states etc).
Have a look in some of my OXPs (Drones, Captured Thargons, Aquatics to name but three) to find some examples of those in use, plus OXPs by Eric Walch and several other people.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link