[Add] Militia kinda scans now.
This commit is contained in:
parent
dfd60775e2
commit
53d5eb6172
@ -57,7 +57,7 @@ function runaway()
|
||||
target = ai.targetid()
|
||||
|
||||
if not ai.exists(target) then
|
||||
ai.pustask()
|
||||
ai.pushtask()
|
||||
ai.pushtask(0, "hyperspace")
|
||||
return
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ function control()
|
||||
if task ~= "attack" and enemy ~= 0 then
|
||||
ai.pushtask(0, "attack", enemy)
|
||||
elseif ai.taskname() == "none" then
|
||||
ai.pushtask(0, "fly")
|
||||
ai.pushtask(0, "scan", ai.rndpilot())
|
||||
end
|
||||
end
|
||||
|
||||
@ -88,12 +88,18 @@ function attack()
|
||||
end
|
||||
end
|
||||
|
||||
function fly()
|
||||
target = player
|
||||
function scan()
|
||||
target = ai.targetid()
|
||||
if not ai.exists(target) then
|
||||
ai.poptask()
|
||||
return
|
||||
end
|
||||
dir = ai.face(target)
|
||||
dist = ai.dist(ai.pos(target))
|
||||
if dir < 10 and dist > 300 then
|
||||
ai.accel()
|
||||
elseif dist < 300 then -- Scan the target.
|
||||
ai.poptask()
|
||||
end
|
||||
end
|
||||
|
||||
|
7
src/ai.c
7
src/ai.c
@ -100,6 +100,7 @@ static int ai_taskname(lua_State* L); // Number taskname.
|
||||
// Consult values.
|
||||
static int ai_gettarget(lua_State* L); // Pointer gettarget()
|
||||
static int ai_gettargetid(lua_State* L); // Number gettargetis()
|
||||
static int ai_getrndpilot(lua_State* L); // Number getrndpilot()
|
||||
static int ai_armour(lua_State* L); // armour()
|
||||
static int ai_shield(lua_State* L); // shield()
|
||||
static int ai_parmour(lua_State* L); // parmour()
|
||||
@ -160,6 +161,7 @@ static const luaL_Reg ai_methods[] = {
|
||||
{ "incombat", ai_incombat },
|
||||
{ "target", ai_gettarget },
|
||||
{ "targetid", ai_gettargetid },
|
||||
{ "rndpilot", ai_getrndpilot },
|
||||
{ "armour", ai_armour },
|
||||
{ "shield", ai_shield },
|
||||
{ "parmour", ai_parmour },
|
||||
@ -473,6 +475,11 @@ static int ai_gettargetid(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ai_getrndpilot(lua_State* L) {
|
||||
lua_pushnumber(L, pilot_stack[RNG(0, pilots-1)]->id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Get the pilots armour.
|
||||
static int ai_armour(lua_State* L) {
|
||||
double d;
|
||||
|
Loading…
Reference in New Issue
Block a user