Github repository, made some minor improvements - zort - 11-21-2018
There were some changes I wanted to make. To share them, I put them in a github repository: https://github.com/zort/lf2-ai-scriptengine Can consider this zort's fork until Silva or SomeoneElse give their approval I guess.
Here's the list of changes:- Upgraded to Angelscript 2.32.0 (mainly for array.sort() that takes comparator function)
- Added Object.vrests (was split into int vrest and char unkwn8[396])
- Added global elapsed_time (number of TUs since start of match)
- Added vector3 type
- Copy more fields from Object to Info (the self and target globals):
- x_real, y_real, z_real
- vector3 position, velocity
- wait_counter (also fixed offset in Object, previously was 4 bytes off, as was ctimer and ccatcher)
- weapon_holder
- Added function setEnemy(int) for use in ego() for setting the enemy that the AI targets when you return 0 from ego() (in fact I initially thought this was what loadTarget did) - though it's only as useful as ego() is, which at the moment is not very useful because it's limited to basic Template AI
- Fixed signatures of Info constructors, now you can construct an Info via Info(object_num) (useful because unlike Object, Info stores its own num and other goodies)
- Made Info fields changeable (non-const), now you can do like obj.frame = obj.data.frames[obj.frame].next to simulate obj in the next TU
- Added enum ItrKinds:
KIND_NORMAL = 0,
KIND_CATCH_DOP = 1,
KIND_PICK_WEAPON = 2,
KIND_CATCH = 3,
KIND_THROWN = 4,
KIND_WEAPON = 5,
KIND_FINISH_HIM = 6,
KIND_ROWING_PICK = 7,
KIND_HEAL = 8,
KIND_SHIELD = 9,
KIND_FLUTE = 10,
KIND_FLUTE_2 = 11,
KIND_OBSTACLE = 14,
KIND_WHIRLWIND_LIFT = 15,
KIND_WHIRLWIND_FREEZE = 16,
Here's the DLLs: debug, release
Everything is backwards compatible of course, or at least it should be.
To show some of the new features, here's a script that always targets the nearest enemy (gets very confused):
AI-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;
}
|
RE: Github repository, made some minor improvements - Boop - 11-23-2018
I'm fine with marking this as the official release.
RE: Github repository, made some minor improvements - Som1Lse - 12-11-2018
Seconded.
RE: Github repository, made some minor improvements - seikosantana - 10-05-2019
(11-21-2018, 02:54 AM)zort Wrote: Here's the DLLs: debug, release
The links are dead.
Refer to this thread for links and a repository.
Sorry for grave-digging, but there may be many guys came here for the DLL..
RE: Github repository, made some minor improvements - Nyamaiku - 08-15-2020
sry for grave digging, was using debug version of this but ctimer seems to be bugged
Edit: fixed ctimer version linked by JohnDoeAntler on discord
https://github.com/JohnDoeAntler/LF2-AI-Abstraction/releases/tag/0.0.1
RE: Github repository, made some minor improvements - bashscrazy - 08-15-2020
(08-15-2020, 07:00 AM)Nyamaiku Wrote: sry for grave digging, was using debug version of this but ctimer seems to be bugged
Edit: fixed ctimer version linked by JohnDoeAntler on discord
https://github.com/JohnDoeAntler/LF2-AI-Abstraction/releases/tag/0.0.1
ohhh i had issues with c-timer not working i ended up using randomizer to do moves while catching enemy.
This fixes the c-timer bug where it doesn't work?
|