Go to this thread for updates: https://www.lf-empire.de/forum/showthread.php?tid=10945
Quick Steps! (Thanks to Azriel)
2.2:
2.1:
2.0:
1.2:
Download:
1.2 ddraw.rar (Size: 313.82 KB / Downloads: 311)
To lazy to make a release one, console isn't that annoying. Live with it . I've given Someone Else the source so he can play around with it and maybe implement anglescript(or not, don't blame him if he doesn't ).
1.1:
1.0:
0.6
0.5:
0.4:
0.3:
0.2:
Original Post:
Quick Steps! (Thanks to Azriel)
Quote:quick steps:
1. put the dll in the lf2 folder (i.e. /lf2/ddraw.dll).
2. make a folder "ai" in the lf2 folder (i.e. /lf2/ai)
3. in this ai folder, any [id].as files ([id] being the id of ur char) will be used as an ai script for ur char, so you'll have 13.as for an id 13: char.
4. start coding.
2.2:
Spoiler (Click to View)
Someone else Wrote:Updated!
Version 2.2
The rand() function now works correctly with replays.
Added weapon_num.
Download: http://www.mediafire.com/?pxd026nqoqgw0
Spoiler (Click to View)
(06-30-2012, 03:54 PM)Someone else Wrote: Minor update: 2.1
Added stage_bound and stage_clear global variables.
Download: http://www.mediafire.com/?pxd026nqoqgw0
Spoiler (Click to View)
Another big update. Here's Someone Else's post:
Lot's of things changed, performance is awesome now. I tested it with 100 bandits and in all of them had a for loop and had 0 lag . Wait for YinYin to update things.
(06-30-2012, 01:36 PM)Someone else Wrote: Time for an update:
Presenting version 2.0:
Download: http://www.mediafire.com/?pxd026nqoqgw0Change log (Click to View)
- Now using AngelScript, this means more syntax and more speed.
- Scripts are now compiled. This doesn't mean much, but if you plan on modifying scripts, while you are running LF2, this only works in the debug version.
- You now use preprocessor directives, #include and #if-#endif.
- The script files now have a ".as" extension instead of the previous ".chai" extension.
- Actually useful error messages.
- You can define global, functions, variables and classes, within your scripts. They can help you speed things up.
- Functions are now defined as '<return-type> <function-name>([<parameter-type> <parameter-name>,...]){<function body>};'.
- If a function doesn't return a value, you can use 'void' as a return type.
- It is no longer enough to define variables as 'var <variable-name>[ = <initial-value>]'. You must define them as '<variable-type> <variable-name>[ = <initial-value>]'.
- Classes are defined as '<class-name> {<functions-and-variables>};'.
- Build in types are, void, bool, int8, int16, int/int32, int64, int8, uint16, uint/uint32, uint64, float, double and string.
- up, down, A, J, D now have the same parameters as left and right had.
- There are now two main functions, the ego and the id.
- ego is defined as 'int ego()', and is basically what we had.
- id is defined as 'void id()', and is the most basic AI. You will have to do everything yourself.
- If you define id, the game will not call ego. You can either keep all functionality within id, or call ego from within id.
- When you are using id, you will have to "release" a key, using for example 'J(0,0);'. Otherwise the AI will keep holding/pressing it.
Release, is the version you should use, when you actually play the game. Debug is for when you are writing your code.
The source code is available too. You'll need Visual C++ Express 2010, directX SDK 2007 and AngelScript 2.23.1.
Depending on where you install them you might have to change some of the paths in the project.
AngelScript should be compiled with the same code generation options as the DLL.
Lot's of things changed, performance is awesome now. I tested it with 100 bandits and in all of them had a for loop and had 0 lag . Wait for YinYin to update things.
Spoiler (Click to View)
- Fixed vrest for yinyin (i guess more people as well)
- added type
- made self and target global so they can be accessed via fucntions without lots of weird hacks (looking at you azriel) (might not work)
- Changed left and right. Now its left(int holding, int left) (same for right). Figure out how it works, or wait for YinYin. If you just want the old functionality back then just use left(1,0); and it'll be just like before.
- added reserve. Might be useful for someone
Download:
1.2 ddraw.rar (Size: 313.82 KB / Downloads: 311)
To lazy to make a release one, console isn't that annoying. Live with it . I've given Someone Else the source so he can play around with it and maybe implement anglescript(or not, don't blame him if he doesn't ).
1.1:
Spoiler (Click to View)
1.1
Updates:
The velocities are doubles, I'd recommend avoid using them if you can because floating point arithmetic is slow.
Download:
Debug:
ddraw.rar (Size: 305.52 KB / Downloads: 313)
Debug only for now until vrest/arest are confirmed 100% working
Updates:
- Added velocities (x_velocity, y_velocity, z_velocity)
- Added clone, -1 if not clone, some other random number if it is (2 or 3 usually but not always)
- Fixed loadTarget always returning -1
- Added vrest and arest. YinYin says vrest is buggy for him - Works fine for me... Need more testers =]
The velocities are doubles, I'd recommend avoid using them if you can because floating point arithmetic is slow.
Download:
Debug:
ddraw.rar (Size: 305.52 KB / Downloads: 313)
Debug only for now until vrest/arest are confirmed 100% working
Spoiler (Click to View)
1.0 Release
We are finally here! The 1.0 release is here, this breaks all backwards compatibility (again) - hopefully for the last time. All performance issues have been fixed. Changes to the syntax are as follows:
Example of defining functions now(you need to check if they were defined before)
There is only one chai script object now (instead of a new one been created each time a file is evaluated, huge performance improvement). Because of this everything exists in global space. That's why we are adding { and } at the start and end of our code and why functions have to be checked if they are defined. The problem with functions is that if two people make a function called SilvaIsAwesome() they are competing for that name. Because of this I have decided to create a convention where people should called their functions id_SilvaIsAwesome() (replace id with your characters ID).
Download:
Debug (has console, useful for developing):
ddraw DEBUG.rar (Size: 311.92 KB / Downloads: 308)
Release(no console, for users):
ddraw RELEASE.rar (Size: 308.95 KB / Downloads: 301)
We are finally here! The 1.0 release is here, this breaks all backwards compatibility (again) - hopefully for the last time. All performance issues have been fixed. Changes to the syntax are as follows:
- You must put a { and } at the start and end of your file.
- self_ and target_ have been replaced with self. and target.
- a,j,d have been replaced with A, J, D
- defining functions is a bit trickier now, see below for an example
- added self.num and target.num
- added ctimer (catch point timer)
Example of defining functions now(you need to check if they were defined before)
Code:
{
clr();
var 1_abc = fun(x) {
return true;
};
var value = 1_abc(1);
print("1_abc: ${value}");
return 1;
}
There is only one chai script object now (instead of a new one been created each time a file is evaluated, huge performance improvement). Because of this everything exists in global space. That's why we are adding { and } at the start and end of our code and why functions have to be checked if they are defined. The problem with functions is that if two people make a function called SilvaIsAwesome() they are competing for that name. Because of this I have decided to create a convention where people should called their functions id_SilvaIsAwesome() (replace id with your characters ID).
Download:
Debug (has console, useful for developing):
ddraw DEBUG.rar (Size: 311.92 KB / Downloads: 308)
Release(no console, for users):
ddraw RELEASE.rar (Size: 308.95 KB / Downloads: 301)
Spoiler (Click to View)
Updates:
Todo:
Download:
[attachment=2848]
- Added useful error messages (sometimes)
- Added bg params (bg_width, bg_zwidth1, bg_zwidth2)
- Added mode to detect which mode
- Added difficulty (0 = difficult, 2 = easy, 1 = normal , -1 = crazy)
- ORIGINAL AI!!! Now if there is no .chai file, lf2 will use the original AI
Todo:
Quote:#1: fix performance issues / memory leaks
#2: add all holding variables (to fix instant running and maybe more?)
#3: add move() come() stay()
#4: add target_num self_num
Download:
[attachment=2848]
Spoiler (Click to View)
Updates:
Example of using loadTarget:
Todo:
Download:
[attachment=2847]
- Improved performance, sometimes, a tiny bit, hopefully, in some situtations, maybe?
- Added weapon_type and shake (yinyin asked for shake, don't ask me why)
- Added loadTarget(int n) function. This lets you change which object is now stored in target_ . Returns -1 if object doesn't exist or the object type if it does.
- Added rand(int n).
- Instead of crashing when you mess up your chaiscript, it now provides (un)helpful error messages! Fix your code bros!
Example of using loadTarget:
Code:
clr();
for (var i = 0; i < 400; ++i)
{
if (loadTarget(i) != -1)
{
print (target_hp);
}
}
return 0;
Todo:
Quote:#1: leave original AI intact - only replace for existing .chai files
#2: add all holding variables (to fix instant running and maybe more?)
#3: fix performance issues / memory leaks
Download:
[attachment=2847]
Spoiler (Click to View)
Ok, important update. You must include return 0 or return 1 at the end. If you return 0 then everything is normal, if you return 1 you will disable large amounts of the basic AI. This is very useful if you are trying to combo things. If you do not put a return thing at the end of your script, lf2 will crash!
Other updates:
added blink (to see if your blinking - invincible)
added state
Todo:
Improve performance
Call original AI if .chai file isn't found
Holding (to allow walking instead of always running)
?????
Download:
[attachment=2843]
Other updates:
added blink (to see if your blinking - invincible)
added state
Todo:
Improve performance
Call original AI if .chai file isn't found
Holding (to allow walking instead of always running)
?????
Download:
[attachment=2843]
Spoiler (Click to View)
Update 0.3:
Todo:
too lazy to write this bit.
download:
[attachment=2842]
- up()/down()/left()/right()
- added abs() function
- added team/id for self and target
Todo:
too lazy to write this bit.
download:
[attachment=2842]
Spoiler (Click to View)
Update 0.2:
Download:
[attachment=2838]
You need to have an AI folder, with a file [id].chai where [id] = the id of the character you want the AI for. For example 1.chai will work for deep. Do NOT put [ ] around the number.
To do:
- Fixed y/z bug
- Fixed facing
- added frame / bdefend / fall
- Made AI id dependent
Download:
[attachment=2838]
You need to have an AI folder, with a file [id].chai where [id] = the id of the character you want the AI for. For example 1.chai will work for deep. Do NOT put [ ] around the number.
To do:
- Fix Memory Leaks
- Fix/Remove up()/down()/left()/right()/A()/J()/D()
- Anything else yinyin finds
Spoiler (Click to View)
Programmable AI
I made it possible to write scripts to replace the move AI of characters. Right now it replaces all the AI's with the one in myfile.chai but I'll change that in the future so that it loads AI's from an AI folder with [ID goes here].chai .
Play around with it. It uses Chaiscript (http://www.chaiscript.com/doxygen/index.html#basics) which I know nothing about, but used because integrating it was a lot easier than anything else I could find.
You have access to :
For self and target. Add self_ or target_ as the prefix. So if you want to see your health use:
The list is about reading values. If you want to make the AI do things you have to call the function of that action, so
DJA(), DdA(), DrA() etc.
Figure out what the letters mean or wait for YinYin.
If you've ever programmed before the syntax makes sense. You can use print("bla") to print things for debugging purposes. Check myfile.chai for a super super super simple example.
DirectDraw Hook
Another cool thing is the direct draw wrapper. Before you had to patch your exe to make it load dlls. Those days are over! Just stick ddraw.dll into a folder with a lf2 2.0a (must be a or it wont work) exe and it works! Weeeeeeeeeeeeeeee!
PS: If you post useless things I will kill you.
Oh yeah, and credit to this guy : http://iki.fi/sol/ I basically stole his directdraw wrapper and changed one line to make it work for lf2.
Instructions:
1. Extract in lf2 folder
2. Run lf2
3. Play around with myfile.chai
I made it possible to write scripts to replace the move AI of characters. Right now it replaces all the AI's with the one in myfile.chai but I'll change that in the future so that it loads AI's from an AI folder with [ID goes here].chai .
Play around with it. It uses Chaiscript (http://www.chaiscript.com/doxygen/index.html#basics) which I know nothing about, but used because integrating it was a lot easier than anything else I could find.
You have access to :
Code:
x;
y;
z;
facing;
holding_up;
holding_down;
holding_left;
holding_right;
holding_a;
holding_j;
holding_d;
up;
down;
left;
right;
A;
J;
D;
DrA;
DlA;
DuA;
DdA;
DrJ;
DlJ;
DuJ;
DdJ;
DJA;
hp;
dark_hp;
max_hp;
mp;
Code:
self_hp
The list is about reading values. If you want to make the AI do things you have to call the function of that action, so
DJA(), DdA(), DrA() etc.
Figure out what the letters mean or wait for YinYin.
If you've ever programmed before the syntax makes sense. You can use print("bla") to print things for debugging purposes. Check myfile.chai for a super super super simple example.
DirectDraw Hook
Another cool thing is the direct draw wrapper. Before you had to patch your exe to make it load dlls. Those days are over! Just stick ddraw.dll into a folder with a lf2 2.0a (must be a or it wont work) exe and it works! Weeeeeeeeeeeeeeee!
PS: If you post useless things I will kill you.
Oh yeah, and credit to this guy : http://iki.fi/sol/ I basically stole his directdraw wrapper and changed one line to make it work for lf2.
Instructions:
1. Extract in lf2 folder
2. Run lf2
3. Play around with myfile.chai
10 ʏᴇᴀʀs sɪɴᴄᴇ ɪʀᴄ ɢᴏᴏᴅ.ɪ ᴡᴀʟᴋ ᴛʜʀᴏᴜɢʜ ᴛʜᴇ ᴇᴍᴘᴛʏ sᴛʀᴇᴇᴛs ᴛʀʏɪɴɢ ᴛᴏ ᴛʜɪɴᴋ ᴏғ sᴏᴍᴇᴛʜɪɴɢ ᴇʟsᴇ ʙᴜᴛ ᴍʏ ᴘᴀᴛʜ ᴀʟᴡᴀʏs ʟᴇᴀᴅs ᴛᴏ ᴛʜᴇ ɪʀᴄ. ɪ sᴛᴀʀᴇ ᴀᴛ ᴛʜᴇ sᴄʀᴇᴇɴ ғᴏʀ ʜᴏᴜʀs ᴀɴᴅ ᴛʀʏ ᴛᴏ sᴜᴍᴍᴏɴ ᴛʜᴇ ɢᴏᴏᴅ ɪʀᴄ. ɪ ᴡᴀᴛᴄʜ ᴏᴛʜᴇʀ ɪʀᴄ ᴄʜᴀɴɴᴇʟs ʙᴜᴛ ɪᴛ ɪs ɴᴏ ɢᴏᴏᴅ. ɪ ᴘᴇsᴛᴇʀ ᴢᴏʀᴛ ᴀɴᴅ ᴛʀʏ ᴛᴏ ʀᴇsɪsᴛ ʜɪs sᴇxɪɴᴇss ʙᴜᴛ ɪᴛ ɪs ᴀʟʟ ᴍᴇᴀɴɪɴɢʟᴇss. ᴛʜᴇ ᴇɴᴅ ɪs ɴᴇᴀʀ.ɪ ᴛʜᴇɴ ᴜsᴜᴀʟʟʏ ʀᴇᴀᴅ sᴏᴍᴇ ᴏʟᴅ ɪʀᴄ ʟᴏɢs ᴀɴᴅ ᴄʀʏ ᴍʏsᴇʟғ ᴛᴏ sʟᴇᴇᴘ.