Changing CS attitudes in current game

skodkim

Deity
Joined
Jan 16, 2004
Messages
2,497
Location
Denmark
Hi
I've found myself surrounded by hostile City States and want to cheat (yes, better to put it out in the open :) ).

Is there any way of changing this in an ongoing game? Editors, database editing, ...

\Skodkim
 
You'd need to change m_ePersonality in CvMinorCivAI.h/cpp and there's no way to do that from Lua, so unless you could find it in the save file and change it with a hex editor ...
 
... and change it with a hex editor ...

Or hang on until v41 of my DLL as I've added it to the list of things to add to the Lua API ;)
 
Code:
-- Make the first City State friendly and the second irrational
Players[22]:SetPersonality(MinorCivPersonalityTypes.MINOR_CIV_PERSONALITY_FRIENDLY)
Players[23]:SetPersonality(MinorCivPersonalityTypes.MINOR_CIV_PERSONALITY_IRRATIONAL)

-- Make all hostile City States neutral
for iCS = GameDefines.MAX_MAJOR_CIVS, GameDefines.MAX_CIV_PLAYERS-2, 1 do
  local pCS = Players[iCS]
  if (pCS:IsEverAlive() and pCS:GetPersonality() == MinorCivPersonalityTypes.MINOR_CIV_PERSONALITY_HOSTILE) then
    pCS:SetPersonality(MinorCivPersonalityTypes.MINOR_CIV_PERSONALITY_NEUTRAL)
  end
end
 
Great! A couple of questions regarding the use of the code:

  1. Are CS always numbered from 22 and onwards?
  2. Do nr. 1 correspond to the first CS in the maps panel of the fire tuner? (can test this if you don't know)?
  3. I was thinking making a new panel in the fire tuner with a button for city state 1 to 10 (or so). For each CS I'd make a button making the CS friendly, neutral, ... Is that doable with the code above or do I need another component (like your fire tuner panel mods which require a mod to be installed in the mod directory as well)?

Thumbs up :goodjob: !

\Skodkim
 
Are CS always numbered from 22 and onwards?
Assuming there are only 22 playable major civs, yes. But see the loop for a better way to determine the first and last possible CS id

Do nr. 1 correspond to the first CS in the maps panel of the fire tuner? (can test this if you don't know)?
Yes

I was thinking making a new panel in the fire tuner with a button for city state 1 to 10 (or so). For each CS I'd make a button making the CS friendly, neutral, ... Is that doable with the code above
You can do that with only the code given, an alternative would be to have a list with the City States in and 4 buttons
 
Just tested in my current game (dll v41 installed) and couldn't get it to Work.

I made a panel with a number of buttons. Only two of them have your code assigned so far but nothing happens when I press the buttons. The active buttons are "CS 1 Friendly and "CS 1 Neutral" - the rest ar just place holders

Could I possibly convince you to have a look?

\Skodkim
 
What context are you running it in? It will need to be InGame or WorldView
 
Sorry, but to be totally frank I have no idea what you're talking about :(

I just made the panel and tried using it while playing the game in the normal map view.

\Skodkim
 
See attached - except you want InGame or WorldView, not MainState
 
Hi Whoward

Thanks for all the help.

I've made a panel where you can change the attitudes of player 22-37, 16 in total. It isn't as "nice" as it could be but so far I haven't been able to do better (leaning by doing and improving slight every day :) ), e.g. make a list and just four buttons.

Right now every player from 22-37 has a button for the four attitude types and there's a list showing which CS has which player number.

It Works - maybe you should consider making a small mod out of this. Feel free to use my attached file (for what it's worth).

\Skodkim
 
Menu controls would be more compact, but have the slight disadvantage of suffering from update lag/flicker
 
That is so cool!

I got an error first time I opened it but afterwards it Works fine (no, not fine - Great!).

\Skodkim
 
I got an error first time I opened it

That's because I hijacked g_PlopperSettings.Player, and that can be nil

the selected conditions (two of them) should look like

Code:
(g_PlopperSettings and g_PlopperSettings.Player and Players[g_PlopperSettings.Player]:IsAlive() and Players[g_PlopperSettings.Player]:IsMinorCiv() and {existing_condition_here})

(but I was too lazy to type that twice!)
 
That's because I hijacked g_PlopperSettings.Player, and that can be nil

the selected conditions (two of them) should look like

Code:
(g_PlopperSettings and g_PlopperSettings.Player and Players[g_PlopperSettings.Player]:IsAlive() and Players[g_PlopperSettings.Player]:IsMinorCiv() and {existing_condition_here})

(but I was too lazy to type that twice!)

As usual you're waaaay over my League - I have no idea where to change this :)

\Skodkim
 
In City States.ltp, at the indicated lines

Code:
 76:	item["Selected"] = ({put_extra_here} and Players[g_PlopperSettings.Player]:GetPersonality() == (p-1))
117:	item["Selected"] = ({put_extra_here} and Players[g_PlopperSettings.Player]:GetMinorCivTrait() == (t-1))
 
Back
Top Bottom