• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[AI] jass new gen and AI

Status
Not open for further replies.
Level 4
Joined
Nov 23, 2007
Messages
113
Yes, the command line option does. But you have to do some fudging to get the vjass compiler to compile it without errors (because it looks for the existence of "call InitBlizzard( )" which of course doesn't exist in an AI file).

And since common.ai is not a default command line parameter, you have to include common.ai using '//! import "common.ai"' above your AI code to appease the compiler. Then you need to take the output file created by vJass and remove that common.ai code. I've requested that common.ai be added as a possible parameter for us AI coders, but not sure if it was/will be implemented.

If you have UltraEdit editor, this whole process is much easier since you can simply write a java script to parse your vjass compiled files for you (I could send you the java script).


This took a bit of trial & error, but this is how I do it. If someone knows an easier way, feel free to comment.

Here's a short (but not in-depth) tutorial:

1.
In your main AI file at the bottom inside your main() function, add the following comments to appease the compiler:

JASS:
// This is to appease the vJass compiler which demands a InitBlizzard() call
// which is not used in AI files

//! inject main

//! dovjassinit
//	call InitBlizzard(  )
//! endinject

2.
Add the following line to the top of your AI file:

//! import "common.ai"


3.
Compile your vJass AI source file to create a vJass output file.

You will need to use the following format when using vjass:
jasshelper.exe --debug --scriptonly common.j blizzard.j "myrace.ai" "myraceOutput.ai"

Debug is not necessary, but good for debugging your AI code.

Note there is an error in the vjass manual which describes this method. The input and output files need to be swapped as shown above.

4.
Open the myraceOutput.ai file and strip the common.ai code. vJass also adds an initializer function and a call to ExecuteFunc() - you will need to delete these as well from the bottom of your AI file. Again, this is easier with UltraEdit especially if you use libraries etc.

NOTE: Before you delete that initialization function, make sure there is no code in it. If there is, you will need to rewrite your code to avoid any initialization code being generated by vjass (such as triggers it might create for onDestroy() methods).

You have to write your vjass code in a way that does not produce any triggers.


Once you have a system set up, it is really quick & easy to edit/test your race AI. Just use the AI editor to test your custom AI at whatever speed you desire. It's easy to test your AI on many different maps this way without having to actually import the race AI into the map itself. However, if your map is not melee, you won't be able to use the AI editor this way (although, what I do is just create a melee version of the map I want to test it on - but for certain types of maps, you can't do that).


Hope that helps.
 
Status
Not open for further replies.
Top