[Add] Lua logic for traders.

This commit is contained in:
Allanis 2013-11-26 15:07:41 +00:00
parent 6c4983120d
commit 01243e12e3
3 changed files with 32 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Fleets> <Fleets>
<fleet name="Goddard Goddard"> <fleet name="Goddard Goddard">
<ai>militia</ai> <ai>goddard</ai>
<faction>Goddard</faction> <faction>Goddard</faction>
<pilots> <pilots>
<pilot chance="100">Goddard</pilot> <pilot chance="100">Goddard</pilot>

30
scripts/ai/trader.lua Normal file
View File

@ -0,0 +1,30 @@
include("../scripts/ai/merchant.lua")
function sos()
msg = {
"Mayday! We are under attack!",
"Requesting assistance. We are under attack!",
"Merchant vessle here under attack! HELP!"
}
ai.broadcast(msg[rnd.int(1, #msg)])
end
function create()
ai.setcredits(rnd.int(100, ai.shipprice()/50))
-- Some stuff has more than others.
num = rnd.int(12)
if num < 5 then
cargo = "Food"
elseif num < 8 then
cargo = "Ore"
elseif num < 10 then
cargo = "Industrial Goods"
elseif num < 12 then
cargo = "Luxury Goods"
else
cargo = "Medicine"
end
ai.setcargo(cargo, rnd.int(0, ai.cargofree()))
end

View File

@ -31,7 +31,7 @@ void expl_explode(double x, double y, double vx, double vy,
/* Standard stuff. */ /* Standard stuff. */
exp_s = spfx_get("ExpS"); exp_s = spfx_get("ExpS");
exp_m = spfx_get("ExpM"); exp_m = spfx_get("ExpM");
exp_s = spfx_get("ExpL"); exp_l = spfx_get("ExpL");
layer = SPFX_LAYER_FRONT; layer = SPFX_LAYER_FRONT;
/* Number of explosions. */ /* Number of explosions. */