AI script is now ported to F.LF! The first ported script is Crusher by YinYin.
You can try beating him on F.LF demo by pressing F4 to go to character selection menu.
The ported source of Crusher is available, and you can read the diff to see the difference side by side, where the left is AI angelscript and right is F.LF javascript.
The translation process was semi automatic. There was indeed a translation program being developed to translate from AI angelscript to F.LF javascript. Major differences are simply naming convention (look at the source of the program to know the translation scheme). However there are few semantic and systematic differences to be pointed out, that must be resolved manually:
that's all about it right now, be sure to try it out, and because things are all preliminary, there are lots of bugs, and please report any problem and suggestion to me. I hope this porting effort is going to raise people's interest in AI scripting and F.LF. For more information about F.LF, visit this thread or F.LF Portal.
I am not sure why Crusher acts awkwardly right now. And it does not defend at all. And the zwidth calculation is a little bit wrong.
A tips on debugging: you can use Chrome > Tools > Javascript Console to debug the application. It is a very good tool.
You can try beating him on F.LF demo by pressing F4 to go to character selection menu.
The ported source of Crusher is available, and you can read the diff to see the difference side by side, where the left is AI angelscript and right is F.LF javascript.
The translation process was semi automatic. There was indeed a translation program being developed to translate from AI angelscript to F.LF javascript. Major differences are simply naming convention (look at the source of the program to know the translation scheme). However there are few semantic and systematic differences to be pointed out, that must be resolved manually:
- function overloading is not allowed in javascript, because a function can have any number of parameters
- javascript has 1 more primitive type 'undefined' than angelscript, such that undefined!==0, but both undefined and 0 evaluates to false. that means one should NOT do `if( some_var!=0)`, instead, should do `if( some_var)`
- F.LF do not use an object number system from 0 to 399. F.LF has a slightly better design by not pre-allocating memory and not imposing a hard limit on max. number of objects (though performance of F.LF at this moment is still bad). Thus, F.LF uses sparse array.
so, instead of
one can simplyCode:for (int i=0;i<400;i++){
if (game.exists[i]) {
// do something about `game.objects[i]`
}
}
Code:for ( var i in game_objects)
{
// every element in the sparse array game_objects exists on scene
// do something about `game_objects[i]`
}
that's all about it right now, be sure to try it out, and because things are all preliminary, there are lots of bugs, and please report any problem and suggestion to me. I hope this porting effort is going to raise people's interest in AI scripting and F.LF. For more information about F.LF, visit this thread or F.LF Portal.
I am not sure why Crusher acts awkwardly right now. And it does not defend at all. And the zwidth calculation is a little bit wrong.
A tips on debugging: you can use Chrome > Tools > Javascript Console to debug the application. It is a very good tool.