[Add] faction_modPlayerRaw and the misn bindings for it.
This commit is contained in:
parent
01b3f2f77b
commit
b387cf0da7
@ -148,10 +148,10 @@ function land()
|
||||
|
||||
-- Modify the faction standing.
|
||||
if player.getFaction("Merchant") < 70 then
|
||||
player.modFaction("Merchant", misn_faction)
|
||||
player.modFactionRaw("Merchant", misn_faction)
|
||||
end
|
||||
if player.getFaction("Independent") < 30 then
|
||||
player.modFaction("Independent", misn_faction/2)
|
||||
player.modFactionRaw("Independent", misn_faction/2)
|
||||
end
|
||||
if player.getFaction("Empire") < 10 then
|
||||
player.modFaction("Empire", misn_faction/3)
|
||||
|
@ -85,33 +85,47 @@ void faction_modPlayer(int f, int mod) {
|
||||
int i;
|
||||
Faction* faction, *ally, *enemy;
|
||||
|
||||
if(faction_isFaction(f)) {
|
||||
faction = &faction_stack[f];
|
||||
|
||||
/* Faction in question gets direct increment. */
|
||||
faction->player += mod;
|
||||
faction_sanitizePlayer(faction);
|
||||
|
||||
/* Now mod allies to a lesser degree. */
|
||||
for(i = 0; i < faction->nallies; i++) {
|
||||
ally = &faction_stack[faction->allies[i]];
|
||||
|
||||
ally->player += RNG(0, (mod*3)/4);
|
||||
faction_sanitizePlayer(ally);
|
||||
}
|
||||
|
||||
/* Now mod enemies. */
|
||||
for(i = 0; i < faction->nenemies; i++) {
|
||||
enemy = &faction_stack[faction->enemies[i]];
|
||||
|
||||
enemy->player -= MIN(1, RNG(0, (mod*3)/4));
|
||||
faction_sanitizePlayer(enemy);
|
||||
}
|
||||
|
||||
} else {
|
||||
if(!faction_isFaction(f)) {
|
||||
WARN("%d is an invalid faction.", f);
|
||||
return;
|
||||
}
|
||||
|
||||
faction = &faction_stack[f];
|
||||
|
||||
/* Faction in question gets direct increment. */
|
||||
faction->player += mod;
|
||||
faction_sanitizePlayer(faction);
|
||||
|
||||
/* Now mod allies to a lesser degree. */
|
||||
for(i = 0; i < faction->nallies; i++) {
|
||||
ally = &faction_stack[faction->allies[i]];
|
||||
|
||||
ally->player += RNG(0, (mod*3)/4);
|
||||
faction_sanitizePlayer(ally);
|
||||
}
|
||||
|
||||
/* Now mod enemies. */
|
||||
for(i = 0; i < faction->nenemies; i++) {
|
||||
enemy = &faction_stack[faction->enemies[i]];
|
||||
|
||||
enemy->player -= MIN(1, RNG(0, (mod*3)/4));
|
||||
faction_sanitizePlayer(enemy);
|
||||
}
|
||||
}
|
||||
|
||||
/* Modifies a players standing with a faction without affecting others. */
|
||||
void faction_modPlayerRaw(int f, int mod) {
|
||||
Faction* faction;
|
||||
|
||||
if(!faction_isFaction(f)) {
|
||||
WARN("%d is an invalid faction.", f);
|
||||
return;
|
||||
}
|
||||
|
||||
faction = &faction_stack[f];
|
||||
|
||||
faction->player += mod;
|
||||
faction_sanitizePlayer(faction);
|
||||
}
|
||||
|
||||
/* Get the player's standing with a faction. */
|
||||
|
@ -10,6 +10,7 @@ char* faction_longname(int f);
|
||||
|
||||
/* Player stuff. */
|
||||
void faction_modPlayer(int f, int mod);
|
||||
void faction_modPlayerRaw(int f, int mod);
|
||||
int faction_getPlayer(int f);
|
||||
char* faction_getStanding(int mod);
|
||||
glColour* faction_getColour(int f);
|
||||
|
@ -105,19 +105,21 @@ 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_modFactionRaw(lua_State* L);
|
||||
static int player_getFaction(lua_State* L);
|
||||
static int player_getRating(lua_State* L);
|
||||
static const luaL_reg player_methods[] = {
|
||||
{ "name", player_getname },
|
||||
{ "ship", player_shipname },
|
||||
{ "freeCargo", player_freeSpace },
|
||||
{ "addCargo", player_addCargo },
|
||||
{ "rmCargo", player_rmCargo },
|
||||
{ "pay", player_pay },
|
||||
{ "msg", player_msg },
|
||||
{ "modFaction", player_modFaction },
|
||||
{ "getFaction", player_getFaction },
|
||||
{ "getRating", player_getRating },
|
||||
{ "name", player_getname },
|
||||
{ "ship", player_shipname },
|
||||
{ "freeCargo", player_freeSpace },
|
||||
{ "addCargo", player_addCargo },
|
||||
{ "rmCargo", player_rmCargo },
|
||||
{ "pay", player_pay },
|
||||
{ "msg", player_msg },
|
||||
{ "modFaction", player_modFaction },
|
||||
{ "modFactionRaw", player_modFactionRaw },
|
||||
{ "getFaction", player_getFaction },
|
||||
{ "getRating", player_getRating },
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
@ -687,6 +689,21 @@ static int player_modFaction(lua_State* L) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int player_modFactionRaw(lua_State* L) {
|
||||
LLUA_MIN_ARGS(2);
|
||||
int f, mod;
|
||||
|
||||
if(lua_isstring(L, 1)) f = faction_get(lua_tostring(L,1));
|
||||
else LLUA_INVALID_PARAMETER();
|
||||
|
||||
if(lua_isnumber(L,2)) mod = (int) lua_tonumber(L,2);
|
||||
else LLUA_INVALID_PARAMETER();
|
||||
|
||||
faction_modPlayerRaw(f, mod);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int player_getFaction(lua_State* L) {
|
||||
LLUA_MIN_ARGS(1);
|
||||
int f;
|
||||
|
Loading…
Reference in New Issue
Block a user