/** * @brief Modifies the player's standing with the faction. * * Does not affect other faction standings and is not processed by the faction * Lua script, so it indicates exactly the amount to be changed. * * @usage f:modPlayerRaw( 10 ) * * @luaparam f Faction to modify player's standing with. * @luaparam mod The modifier to modify faction by. * @luafunc modPlayerRaw( f, mod ) */ static int factionL_modplayerraw( lua_State *L ) { int f; double n; f = luaL_validfaction(L,1); n = luaL_checknumber(L,2); faction_modPlayerRaw( f, n ); return 0; }
/** * @brief Modifies the player's standing with a faction. * * Affects enemies and allies too. * * @param f Faction to modify player's standing. * @param mod Modifier to modify by. * * @sa faction_modPlayerRaw */ void faction_modPlayer( int f, double mod ) { int i; Faction *faction; double m; if (!faction_isFaction(f)) { WARN("%d is an invalid faction", f); return; } /* Modify faction standing with parent faction. */ faction_modPlayerRaw( f, mod ); /* Now mod allies to a lesser degree */ faction = &faction_stack[f]; for (i=0; i<faction->nallies; i++) { /* Enemies are made faster. */ m = RNG_2SIGMA()/4. + 0.5; if (mod > 0.) m *= 0.75; /* Modify faction standing */ faction_modPlayerRaw( faction->allies[i], m*mod ); } /* Now mod enemies */ for (i=0; i<faction->nenemies; i++) { /* Enemies are made faster. */ m = RNG_2SIGMA()/4. + 0.5; if (mod < 0.) m *= 0.75; /* Modify faction standing. */ faction_modPlayerRaw( faction->enemies[i], -m*mod ); } }
/** * @brief Increases the player's standing to a faction by a fixed amount without * touching other faction standings. * * @luaparam faction Name of the faction. * @luaparam mod Amount to modify standing by. * @luafunc modFactionRaw( faction, mod ) */ static int playerL_modFactionRaw( lua_State *L ) { NLUA_MIN_ARGS(2); int f; double mod; if (lua_isstring(L,1)) f = faction_get( lua_tostring(L,1) ); else NLUA_INVALID_PARAMETER(); mod = luaL_checknumber(L,2); faction_modPlayerRaw( f, mod ); return 0; }