10-05-2019, 12:41 PM
This is totally not a new thing. It's zort's fork (https://www.lf-empire.de/forum/showthread.php?tid=10945).
Links to DLLs, in case you only need DLLs, not sources:
Debug, for developing AI scripts,
Release, if you only want to play with custom AIs.
I made a new repository for this, https://github.com/seikosantana/lf2-ai-scriptengine
I didn't change anything in code. It was a clone of zort's repository. I added angelscript.lib (by compiling AngelScript SDK) and also added angelscript.h header so now it should compile without missing files. See readme in the repository for more info.
What you can't do on previous ddraw is setting a target as an enemy.
loadtarget does not set them as enemy. It loads information about the target instead.
So what's new?
This version has improvements, enables setting target as enemy (setEnemy(int)). An example by the original author:
Backward compatible with previous AI scripts? Yes so far. All my old AI scripts builds and runs without problems.
(Let's migrate to this version of ddraw wrapper )
Links to DLLs, in case you only need DLLs, not sources:
Debug, for developing AI scripts,
Release, if you only want to play with custom AIs.
I made a new repository for this, https://github.com/seikosantana/lf2-ai-scriptengine
I didn't change anything in code. It was a clone of zort's repository. I added angelscript.lib (by compiling AngelScript SDK) and also added angelscript.h header so now it should compile without missing files. See readme in the repository for more info.
What you can't do on previous ddraw is setting a target as an enemy.
loadtarget does not set them as enemy. It loads information about the target instead.
So what's new?
This version has improvements, enables setting target as enemy (setEnemy(int)). An example by the original author:
Spoiler (Click to View)
(11-21-2018, 02:54 AM)zort Wrote: [ -> ]To show some of the new features, here's a script that always targets the nearest enemy (gets very confused):
Code:double distance_to(const Info& other) {
return (self.position - other.position).length();
}
bool closer(const Info& a, const Info& b) {
return distance_to(a) < distance_to(b);
}
array<const Info@> getEnemyObjects() {
array<const Info@> ret = {};
for (int i = 0; i < 400; i++) {
// exists
if (!game.exists[i])
continue;
// not us
if (i == self.num)
continue;
// is enemy
if (game.objects[i].team == self.team)
continue;
// is alive
if (game.objects[i].hp <= 0)
continue;
ret.insertLast(Info(i));
}
return ret;
}
array<const Info@> getEnemies() {
array<const Info@> enemyObjects = getEnemyObjects();
array<const Info@> ret = {};
for (uint i = 0; i < enemyObjects.length(); i++) {
// is human
if (enemyObjects[i].type != 0)
continue;
ret.insertLast(enemyObjects[i]);
}
return ret;
}
array<const Info@> attackableEnemies() {
array<const Info@> enemies = getEnemies();
array<const Info@> ret = {};
for (uint i = 0; i < enemies.length(); i++) {
if (enemies[i].state == STATE_LYING)
continue;
if (enemies[i].blink != 0)
continue;
ret.insertLast(@enemies[i]);
}
return ret;
}
array<const Info@> attackableEnemiesByDistance() {
array<const Info@> attackable_enemies = attackableEnemies();
attackable_enemies.sort(function(a,b){return closer(a,b);});
return attackable_enemies;
}
int ego() {
array<const Info@> enemies = attackableEnemiesByDistance();
if (enemies.length > 0)
setEnemy(enemies[0].num);
return 0;
}
Backward compatible with previous AI scripts? Yes so far. All my old AI scripts builds and runs without problems.
(Let's migrate to this version of ddraw wrapper )