[Change] Missions increase/lower faction standing. Fixed bug with factions.
This commit is contained in:
parent
d6f266323f
commit
71b68003f9
@ -47,13 +47,16 @@ function create()
|
||||
i = rnd.int(6)
|
||||
if i < 4 then -- Cargo delivery.
|
||||
misn_type = "Cargo"
|
||||
misn.faction = rnd.int(2)
|
||||
i = rnd.int(3)
|
||||
misn.setTitle(string.format(title[i+1], planet))
|
||||
elseif i < 6 then-- Rush delivery.
|
||||
misn_type = "Rush"
|
||||
misn.faction = rnd.int(5)
|
||||
misn.setTitle(string.format(title[11], planet))
|
||||
else -- People delivery :P
|
||||
misn_type = "People"
|
||||
misn.faction = rnd.int(1)
|
||||
carg_mass = 0
|
||||
i = rnd.int(5)
|
||||
if i < 2 then
|
||||
@ -132,6 +135,18 @@ function land()
|
||||
if player.rmCargo(carg_id) then
|
||||
player.pay( reward )
|
||||
tk.msg(finish_title, string.format( finish_msg, carg_type))
|
||||
|
||||
-- Modify the faction standing.
|
||||
if player.getFaction("Merchant") < 70 then
|
||||
player.modFaction("Merchant", misn_faction)
|
||||
end
|
||||
if player.getFaction("Independent") < 30 then
|
||||
player.modFaction("Independent", misn_faction/2)
|
||||
end
|
||||
if player.getFaction("Empire") < 10 then
|
||||
player.modFaction("Empire", misn_faction/3)
|
||||
end
|
||||
|
||||
misn.finish(true)
|
||||
else
|
||||
tk.msg(miss_title, string.format( miss_msg, carg_mass, carg_type))
|
||||
|
@ -49,6 +49,7 @@ function land()
|
||||
-- More flavour text.
|
||||
tk.msg(title[3], string.format(text[4], dest))
|
||||
var.push("es_cargo", true)
|
||||
player.modFaction("Empire", 3)
|
||||
misn.finish(true)
|
||||
end
|
||||
end
|
||||
|
@ -73,6 +73,7 @@ function land()
|
||||
|
||||
if misn_stage == 1 and planet == misn_base then
|
||||
tk.msg(title[3], string.format(text[3],misn_target))
|
||||
player.modFaction("Empire", 5)
|
||||
misn.finish(true)
|
||||
end
|
||||
end
|
||||
|
@ -99,6 +99,11 @@ function land()
|
||||
var.push("es_misn", 1)
|
||||
end
|
||||
|
||||
-- Increase faction.
|
||||
if player.getFaction("Empire") < 50 then
|
||||
player.modFaction("Empire", rnd.int(5))
|
||||
end
|
||||
|
||||
misn.finish(true)
|
||||
else
|
||||
tk.msg(miss_title, string.format( miss_msg, carg_mass, carg_type))
|
||||
|
@ -103,6 +103,17 @@ void faction_modPlayer(int f, int mod) {
|
||||
}
|
||||
}
|
||||
|
||||
int faction_getPlayer(int f) {
|
||||
if(faction_isFaction(f)) {
|
||||
if(faction_isFaction(f)) {
|
||||
return faction_stack[f].player;
|
||||
}
|
||||
} else {
|
||||
DEBUG("%d is an invalid faction/alliance", f);
|
||||
return -1000;
|
||||
}
|
||||
}
|
||||
|
||||
// Return 1 if Faction a and b are enemies.
|
||||
int areEnemies(int a, int b) {
|
||||
Faction* fa, *fb;
|
||||
|
@ -9,6 +9,7 @@ char* faction_name(int f);
|
||||
|
||||
// Player stuff.
|
||||
void faction_modPlayer(int f, int mod);
|
||||
int faction_getPlayer(int f);
|
||||
|
||||
// Works with only factions.
|
||||
int areEnemies(int a, int b);
|
||||
|
@ -128,6 +128,8 @@ static int player_addCargo(lua_State* L);
|
||||
static int player_rmCargo(lua_State* L);
|
||||
static int player_pay(lua_State* L);
|
||||
static int player_msg(lua_State* L);
|
||||
static int player_modFaction(lua_State* L);
|
||||
static int player_getFaction(lua_State* L);
|
||||
static const luaL_reg player_methods[] = {
|
||||
{ "name", player_getname },
|
||||
{ "ship", player_shipname },
|
||||
@ -136,6 +138,8 @@ static const luaL_reg player_methods[] = {
|
||||
{ "rmCargo", player_rmCargo },
|
||||
{ "pay", player_pay },
|
||||
{ "msg", player_msg },
|
||||
{ "modFaction", player_modFaction },
|
||||
{ "getFaction", player_getFaction },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
@ -768,6 +772,32 @@ static int player_msg(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int player_modFaction(lua_State* L) {
|
||||
MIN_ARGS(2);
|
||||
int f, mod;
|
||||
|
||||
if(lua_isstring(L, -2)) f = faction_get(lua_tostring(L, -2));
|
||||
else MISN_INVALID_PARAMETER();
|
||||
|
||||
if(lua_isnumber(L, -1)) mod = (int)lua_tonumber(L, -1);
|
||||
else MISN_INVALID_PARAMETER();
|
||||
|
||||
faction_modPlayer(f, mod);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int player_getFaction(lua_State* L) {
|
||||
MIN_ARGS(1);
|
||||
int f;
|
||||
|
||||
if(lua_isstring(L, -1)) f = faction_get(lua_tostring(L, -1));
|
||||
else MISN_INVALID_PARAMETER();
|
||||
lua_pushnumber(L, faction_getPlayer(f));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// -- RND. --
|
||||
static int rnd_int(lua_State* L) {
|
||||
int o;
|
||||
|
@ -322,7 +322,8 @@ static void weapon_hit(Weapon* w, Pilot* p, WeaponLayer layer) {
|
||||
// Someone should let the ai know it's been attacked.
|
||||
if(!pilot_isPlayer(p)) {
|
||||
if((player_target == p->id) || (RNG(0,2) == 0)) {
|
||||
if(pilot_isFlag(p, PILOT_HOSTILE) || (RNG(0, 2) == 0))
|
||||
if((w->parent == PLAYER_ID) &&
|
||||
(!pilot_isFlag(p, PILOT_HOSTILE) || (RNG(0, 2) == 0)))
|
||||
faction_modPlayer(p->faction, -1); // Slowly lower faction.
|
||||
ai_attacked(p, w->parent);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user