[Add] More thingies.. Factions!!
This commit is contained in:
parent
bc12bbaba2
commit
d246c2cbe2
@ -10,20 +10,40 @@
|
||||
</faction>
|
||||
<faction name = "Militia">
|
||||
</faction>
|
||||
<faction name = "Empire">
|
||||
</faction>
|
||||
<faction name = "Collective">
|
||||
</faction>
|
||||
<Alliances>
|
||||
<alliance name = "Neutral">
|
||||
<ally>Independent</ally>
|
||||
<ally>Merchant</ally>
|
||||
<ally>Militia</ally>
|
||||
</alliance>
|
||||
<alliance name = "Empire United">
|
||||
<ally>Empire</ally>
|
||||
<ally>Merchant</ally>
|
||||
</alliance>
|
||||
</Alliances>
|
||||
<Enemies>
|
||||
<enemies>
|
||||
<enemy type = "alliance">Neutral</enemy>
|
||||
<enemy type = "faction">Pirate</enemy>
|
||||
</enemies>
|
||||
<enemy type="faction">Collective</enemy>
|
||||
<enemy type="alliance">Neutral</enemy>
|
||||
</enemies>
|
||||
<enemies>
|
||||
<enemy type="faction">Collective</enemy>
|
||||
<enemy type="faction">Player</enemy>
|
||||
</enemies>
|
||||
<enemies>
|
||||
<enemy type="alliance">Neutral</enemy>
|
||||
<enemy type="faction">Pirate</enemy>
|
||||
</enemies>
|
||||
<enemies>
|
||||
<enemy type="alliance">Empire United</enemy>
|
||||
<enemy type="faction">Pirate</enemy>
|
||||
</enemies>
|
||||
<enemies>
|
||||
<enemy type="faction">Pirate</enemy>
|
||||
<enemy type="faction">Player</enemy>
|
||||
</enemies>
|
||||
</Enemies>
|
||||
|
@ -25,10 +25,7 @@
|
||||
<ai>merchant</ai>
|
||||
<faction>Merchant</faction>
|
||||
<pilots>
|
||||
<pilot chance='80'>Merchant Ship</pilot>
|
||||
<pilot chance='80'>Merchant Ship</pilot>
|
||||
<pilot chance='80'>Merchant Mule</pilot>
|
||||
<pilot chance='80'>Merchant Mule</pilot>
|
||||
<pilot chance='100'>Merchant Ship</pilot>
|
||||
</pilots>
|
||||
</fleet>
|
||||
<fleet name="Pirate">
|
||||
@ -40,4 +37,23 @@
|
||||
<pilot chance='80'>Leapard</pilot>
|
||||
</pilots>
|
||||
</fleet>
|
||||
<fleet name="Collective Drone">
|
||||
<ai>collective</ai>
|
||||
<faction>Collective</faction>
|
||||
<pilots>
|
||||
<pilot chance='100'>Drone</pilot>
|
||||
</pilots>
|
||||
</fleet>
|
||||
<fleet name="Collective Sml Swarm">
|
||||
<ai>collective</ai>
|
||||
<faction>Collective</faction>
|
||||
<pilots>
|
||||
<pilot chance='100'>Drone</pilot>
|
||||
<pilot chance='90'>Drone</pilot>
|
||||
<pilot chance='80'>Drone</pilot>
|
||||
<pilot chance='70'>Drone</pilot>
|
||||
<pilot chance='60'>Drone</pilot>
|
||||
<pilot chance='50'>Drone</pilot>
|
||||
</pilots>
|
||||
</fleet>
|
||||
</Fleets>
|
||||
|
23
dat/ssys.xml
23
dat/ssys.xml
@ -94,6 +94,29 @@
|
||||
</fleets>
|
||||
<jumps>
|
||||
<jump>NCG-7291</jump>
|
||||
<jump>C-59</jump>
|
||||
</jumps>
|
||||
</ssys>
|
||||
<ssys name="C-59">
|
||||
<pos>
|
||||
<x>90</x>
|
||||
<y>50</y>
|
||||
</pos>
|
||||
<general>
|
||||
<stars>200</stars>
|
||||
<asteroids>0</asteroids>
|
||||
<interference>0</interference>
|
||||
</general>
|
||||
<planets>
|
||||
</planets>
|
||||
<fleets>
|
||||
<fleet chance="80">Collective Drone</fleet>
|
||||
<fleet chance="80">Collective Drone</fleet>
|
||||
<fleet chance="80">Collective Drone</fleet>
|
||||
<fleet chance="60">Collective Sml Swarm</fleet>
|
||||
</fleets>
|
||||
<jumps>
|
||||
<jump>NCG-7292</jump>
|
||||
</jumps>
|
||||
</ssys>
|
||||
</Systems>
|
||||
|
52
scripts/ai/collective.lua
Normal file
52
scripts/ai/collective.lua
Normal file
@ -0,0 +1,52 @@
|
||||
-- Required control rate.
|
||||
control_rate = 2
|
||||
|
||||
function control()
|
||||
if ai.taskname() == "none" then
|
||||
enemy = ai.getenemy()
|
||||
|
||||
if enemey ~= 0 then
|
||||
ai.pushtask(0, "attack", enemy)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Required "attacked" function.
|
||||
function attacked(attacker)
|
||||
task = ai.taskname()
|
||||
if task ~= "attack" then
|
||||
-- Now pilot fights back.
|
||||
ai.pushtask(0, "attack", attacker)
|
||||
|
||||
elseif task == "attack" then
|
||||
if ai.targetid() ~= attacker then
|
||||
ai.pushtask(0, "attack", attacker)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function attack()
|
||||
target = ai.targetid()
|
||||
|
||||
-- Make sure pilot exists.
|
||||
if not ai.exists(target) then
|
||||
ai.poptask()
|
||||
return
|
||||
end
|
||||
|
||||
dir = ai.face(target)
|
||||
dist = ai.dist(ai.pos(target))
|
||||
second = ai.secondary()
|
||||
|
||||
if ai.secondary() == "Launcher" then
|
||||
ai.settarget(target)
|
||||
is.shoot(2)
|
||||
end
|
||||
|
||||
if dir < 10 and dist > 300 then
|
||||
ai.accel()
|
||||
elseif dir < 10 and dist < 300 then
|
||||
ai.shoot()
|
||||
end
|
||||
end
|
||||
|
@ -152,7 +152,8 @@ static void map_render(double bx, double by, double w, double h) {
|
||||
|
||||
// Draw the system.
|
||||
if(sys == cur_system) COLOUR(cRadar_targ);
|
||||
else if(sys->nplanets == 0) COLOUR(cInert);
|
||||
else if(sys->nplanets==0) COLOUR(cInert); // TODO: dependant on planet type.
|
||||
else if(areEnemies(player->faction, sys->faction)) COLOUR(cRed);
|
||||
else COLOUR(cYellow);
|
||||
|
||||
gl_drawCircleInRect(x + sys->pos.x*map_zoom,
|
||||
|
@ -479,7 +479,11 @@ static StarSystem* system_parse(const xmlNodePtr parent) {
|
||||
MELEMENT(flags&FLAG_ASTEROIDSSET, "asteroids"); // Can be 0.
|
||||
MELEMENT(flags&FLAG_INTEFERENCESET, "inteference");
|
||||
#undef MELEMENT
|
||||
|
||||
|
||||
// Post processing.
|
||||
if(tmp->nplanets > 0)
|
||||
// TODO: Make dependant on overall planet faction.
|
||||
tmp->faction = tmp->planets[0].faction;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,8 @@ typedef struct StarSystem_ {
|
||||
int stars, asteroids; // Un numero!
|
||||
double interference; // Un uh.. Percentage.
|
||||
|
||||
Faction* faction; // Overall faction.
|
||||
|
||||
Planet* planets; // Planets.
|
||||
int nplanets; // Total number of planets.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user