Jump to content

[MOD] Hostile Factions


Polyman

Recommended Posts

Well, I think I finally have something that works. I'm not sure how many players are interested  but I will provide the code below. All you have to do is Copy+paste the code to the factions.lua script, which is located in data\scripts\server. You can still gain reputation by fighting pirates, or participating in faction wars but it will be much harder to gain reputation. I'm also including an optional modification to SectorGenerator.lua that places turrets on most stations, as I was tired of pirates destroying stations with no resistance. Combined with the mod below it makes rushing to the center much harder.

 

 

 

Code: Find the comment line '-- make sure the player has an early ally' and paste it below 'player:setValue("start_ally", faction.index)'

-- mod make sure the player has plenty of enemies----------------------------------------------------------
for i = -499, 999 do
	local x = i
	local y = i

	delta = math.random(75000,1000) --min/max values for reputation decrease

	local homeSectorFaction = Galaxy():getNearestFaction(home.x, home.y) -- starting allied faction
	local getFaction = Galaxy():getNearestFaction(x, y) -- faction that should hate players and their starting ally

	local relation = player:getRelations(getFaction.index)

	if relation == 0 then 
		Galaxy():setFactionRelations(getFaction, player, -delta) -- makes factions hate the player
		Galaxy():setFactionRelations(getFaction, homeSectorFaction, -delta) -- makes factions hate our starting ally
	end		

	--mod make everyone hate pirates
	local pirates = Galaxy():getPirateFaction(x, y)
	Galaxy():setFactionRelations(pirates, getFaction, -200000) -- everyone hates pirates
	Galaxy():setFactionRelations(pirates, player, -200000) -- everyone hates pirates	
end

 

 

Optional Mod:

Armed Space Stations(SectorGenerator.zip)

Desc:Lightly arms all space stations with turrets based on sector turret level. Equipment Docks and Military Outposts are heavily armed.

ArmedStations.zip

Link to comment
Share on other sites

This relation is set in scripts/server/factions.lua in function initializePlayer, lines 104-108:

 

    -- make sure the player has an early ally
    local faction = Galaxy():getNearestFaction(home.x, home.y)
    faction:setValue("enemy_faction", -1) -- this faction doesn't participate in faction wars
    Galaxy():setFactionRelations(faction, player, 75000)
    player:setValue("start_ally", faction.index)

Link to comment
Share on other sites

I'm not sure what are you asking about but it goes pretty much the same way. First you need to get players or factions you want to edit relations, then you modify them.

local a = Player(1) -- or faction
local b = Faction(2) -- or player
-- You can get these object in any way you want! Just make sure they are at least of Faction type.
Galaxy():setFactionRelations(a, b, 11111)
-- or one liner:
Galaxy():setFactionRelations(Faction(5), Faction(6), 42)

Write function that does that or put it wherever you like - in command script, entity, sector script etc. Then just call it.

Link to comment
Share on other sites

Well I noticed in some new galaxy spawns the player is spawned in a sector near multiple hostile factions and their default 'allied' faction didnt attack enemy ships to the player. I updated the code and everything seems to be working now.

Link to comment
Share on other sites

Thanks for your mod, I'm sure the helpless stations will love their turrets.

 

One note for the hostile factions, a way I found for players to bypass most bad relations is to sell asteroids from nearby sectors to that faction. This allows them to befriend any faction within minutes and without too many effort.

Would you know any way to battle this?

Link to comment
Share on other sites

Thanks for your mod, I'm sure the helpless stations will love their turrets.

 

One note for the hostile factions, a way I found for players to bypass most bad relations is to sell asteroids from nearby sectors to that faction. This allows them to befriend any faction within minutes and without too many effort.

Would you know any way to battle this?

 

 

Yep, easy to solve by modifying the sellobject.lua script.  Change this line of code local reputation = lerp(relations, -100000, 100000, 15000, 1000)

 

Here's an example that only populates the sell table/list with factions that have at least 1,000 reputation with the player faction.

 

function getFactions()

    local ownFaction = Faction(Entity().factionIndex)

    local factions = {}
    local x, y = Sector():getCoordinates()
    local offsets =
    {
        {x = 0, y = 0},
        {x = -8, y = 0},
        {x = 8, y = 0},
        {x = 0, y = -8},
        {x = 0, y = 8}
    }

    for _, offset in pairs(offsets) do
        local faction = Galaxy():getNearestFaction(x + offset.x, y + offset.y)
        local relations = ownFaction:getRelations(faction.index)

        local price = lerp(relations, -100000, 100000, 500, 40000)
        local reputation = lerp(relations, -100000, 100000, 100, 500) --- mod change 100 and 500 for lower/higher reputation value scale

        price = price * Balancing_GetSectorRichnessFactor(x, y)

if relations >= 1000 then factions[faction.index] = {index = faction.index, price = price, reputation = reputation}end --mod only factions with 1k reputation will show up in table
    end

    return factions
end

 

Link to comment
Share on other sites

Some players spend way too much time in a sector with a friendly faction. (Perhaps we have player-own factories in the system or are doing a lot of mining.) And as a consequence, some of us are seeing friendly factions become allies with bandits. (Bandits join forces with factions to fight Xsotan and, thus, can become allies.) And, now, every bandit I kill subtracts roughly 13000 relation points with any (formerly) friendly faction in the system. (See my Enemy of my enemy... topic for details.)

 

My point? Making it quote, "much harder to gain reputation" with friendly factions could be problematic if we experience this issue and want to balance relations as a workaround for this game oversight. Just thought that I would point out that this is a potential issue, should a faction decide to ally itself with bandits.

Link to comment
Share on other sites

Are you sure that there's an AI faction allied with the Xsotan? When the alien attack event takes place all factions in the current sector are set to -200k reputation.

 

I'm afraid that you misread what I wrote. I said that, sometimes, factions will become allied with bandits - and by that, I'm referring to "pirates". (I said that they can quote, "join forces with factions to fight Xsotan.")

Link to comment
Share on other sites

hi im really new to the whole lua modding or what not but imi have a quick question i am confused on how i am to install/add the mod and the secter generater one too if u could maybe help me out would be much appreciated. and keep up the good work i like mods that make gameplay more difficult

Link to comment
Share on other sites

 

I'm afraid that you misread what I wrote. I said that, sometimes, factions will become allied with bandits - and by that, I'm referring to "pirates". (I said that they can quote, "join forces with factions to fight Xsotan.")

 

I changed both the pirateattack.lua and alienattack.lua events. What happens now is once the event starts and creates ships bandit factions(pirates), xsotan, etc. will have -200k reputation with each other. I'm pretty sure this fixes the scenario you're describing.

 

 

 

hi im really new to the whole lua modding or what not but imi have a quick question i am confused on how i am to install/add the mod and the secter generater one too if u could maybe help me out would be much appreciated. and keep up the good work i like mods that make gameplay more difficult

 

Just download the ArmedStation.zip and extract inside the Avorion game directory.  ;)

eventchanges.zip

Link to comment
Share on other sites

  • 1 month later...

I said that, sometimes, factions will become allied with bandits - and by that, I'm referring to "pirates"...

 

I changed both the pirateattack.lua and alienattack.lua events. What happens now is once the event starts and creates ships bandit factions(pirates), xsotan, etc. will have -200k reputation with each other. I'm pretty sure this fixes the scenario you're describing.

 

Looking at the code in eventchanges.zip, I think these are the important bits:

 

piratattack.lua:

 

	local pirates = Galaxy():getPirateFaction(Sector():getCoordinates())
local others = Galaxy():getNearestFaction(Sector():getCoordinates())
Galaxy():changeFactionRelations(pirates, others, -200000) -- pirates hate other factions

 

alienattack.lua:

 

	local pirates = Galaxy():getPirateFaction(Sector():getCoordinates()) -- get local pirate faction
	if pirates ~= nill then	--checks if pirate faction in sector
		Galaxy():changeFactionRelations(faction, pirates, -200000) -- pirates hate xsotan
		Galaxy():changeFactionRelations(pirates, others, -200000) -- pirates hate other factions
end

 

Well, this was a really good idea. However...

I'm not sure whether it's due to a recent patch or whether it never truly worked, but this fix does not seem to work now.

 

Actually, I had not bothered trying to use this fix until recently because, until recently, I'd been playing multiplayer on a server that had been using Hostile Factions and this fix. But in my single-player game I had this happen - bandits ended up allied with the local faction.

 

Remembering this topic, I downloaded eventchanges.zip and installed it. But this did not fix it.

 

No matter how many different sectors I move to and no matter how many different waves of randomly generated bandits, the bandits never seem to attack this faction, nor does this faction ever attack them. Further, my relations still drop with this faction if they witness me destroying a bandit ship.

 

As I mentioned in the Military & Bandit ships treated as CIVILIAN topic, part of the problem is that a recent patch made all military (i.e., headhunter) and bandit ships civilian, very heavily penalizing the player for destroying them. After learning of this, I altered pirategenerator.lua and shipgenerator.lua to comment out the code that did this. But, I still lose reputation with said faction for destroying bandit ships, just not nearly as much.

 

Would you consider looking at your eventchanges.zip to see if it could be fixed?

Link to comment
Share on other sites

  • 4 weeks later...

As far as I have played, I found out it's clearly easy to grind the reputation, and that's perhaps 'too easy',

but at the same time, it's really 'too easy' to lose faction too. Especially with the AI of the ships flying

really 'stupidly' sometimes.

 

Is there a way to diminish the loss of reputation when hitting an allied ship ?

Any clue on what part of the codes do the calculation ?

 

As I must say I would enjoy using the 'hostile faction' mod, but I also would like to be sure I would not

end up losing the few factions I nurse if their pilots are of the suicidal kind and jumping in front

of my auto targeting "hail of death".

 

Things are even worse when you start losing faction because one of their salesman decide to park his ship

next to your ship while you are salvaging/mining, and your lasers hit the guy....

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...