Do GetPersonalityType, SetPersonalityType do anything in the dll?

Pazyryk

Deity
Joined
Jun 13, 2008
Messages
3,584
I played with these a while back and discovered that they "work" in Lua. By work I mean that you can change the value with player:SetPersonalityType(newLeaderID) and that value is gotten back out by GetPersonalityType() even after exit/reload. Contrary to the wiki, the value corresponds to Leader ID as does the civ4 method of the same name.

I'm still not a C++/dll programmer (though I will get to that eventually). Can anyone tell me if this is actually doing anything in the dll? Specifically, is it likely to change AI civ behavior to match the new Leader ID? (Doesn't affect UI, but that's not what I need.) I had tried judging from AI behavior in a game test, but that was a royal pain and kind of inconclusive.
 
I took a quick look at the DLL, and SetPersonalityType seems to be used to change a leader's personality to the personality of another leader - the same function that is exposed to Lua is also used when starting a game with the random personalities option enabled.
 
Well, I can't guarantee that it works properly, for example I'm not sure if the flavors are adjusted when using this function (AFAIK flavors are set before the start of the game, taking a random factor into account). So it's possible that changing the personality during the game only changes the values in the Leaders table (plus the approach biases), but not the flavors. It will require a more detailed analysis of the code to be sure how it works.

Edit: I found a function called CvDiplomacyAI::DoInitializePersonality, which sets all the personality values, and it's only used in the CvGame::setInitialItems function, which is called at the start of the game. So it appears that changing the personality during the game won't work, sorry for my initial positive answer :(

So if I'm not mistaken, changing a personality works only when starting the game, before setInitialItems is called, and doing it effectively during the game requires DLL changes.

Edit2: After further analysis, it's possible that I found a bug that makes the Random Personalities function work incorrectly - the DoInitializePersonality function seems to use the default values for the leader instead of the changed personality (but the function that sets flavors works properly).
 
OK, so I need to:
  1. Debug/fix CvDiplomacyAI::DoInitializePersonality
  2. Set personality using Lua
  3. Then call CvDiplomacyAI::DoInitializePersonality
Thanks for the help. I won't waste time on the Lua side until I'm ready to tackle the dll part.
 
If you want the flavors to update as well, you probably also need to call CvFlavorManager::Init (although I'm still 100% sure if things I'm writing here make sense, if someone who reads this can confirm it, please do it).
 
Back
Top Bottom