Any way to make ChangeMinorCivFriendshipWithMajor not round to the nearest whole #?

turingmachine

Emperor
Joined
May 4, 2008
Messages
1,438
So I have some lua all written out, it works perfectly, except it seems ChangeMinorCivFriendshipWithMajor refuses to actually add or subtract a decimal value from the influence and always rounds the amount I set to the nearest whole number.

Is there any way around this?
 
Short of modding the DLL, no

Code:
int CvLuaPlayer::l[B]ChangeMinorCivFriendshipWithMajor[/B](lua_State* L)
{
  CvPlayerAI* pkPlayer = GetInstance(L);
  PlayerTypes ePlayer = (PlayerTypes) lua_tointeger(L, 2);
  [B][COLOR="Red"]int iChange [/COLOR][/B]= lua_tointeger(L, 3);

  pkPlayer->GetMinorCivAI()->ChangeFriendshipWithMajor(ePlayer, iChange);
  return 1;
}
 
Short of modding the DLL, no

Code:
int CvLuaPlayer::l[B]ChangeMinorCivFriendshipWithMajor[/B](lua_State* L)
{
  CvPlayerAI* pkPlayer = GetInstance(L);
  PlayerTypes ePlayer = (PlayerTypes) lua_tointeger(L, 2);
  [B][COLOR="Red"]int iChange [/COLOR][/B]= lua_tointeger(L, 3);

  pkPlayer->GetMinorCivAI()->ChangeFriendshipWithMajor(ePlayer, iChange);
  return 1;
}

Ugh, why would they even do that? It makes the function worthless. Even base decay on most speeds uses decimals, not the mention all the % modifiers from policies.
 
Ugh, why would they even do that?

Just about *every* method uses ints and not floats - modifiers are handled as percentages (so 1.25 is actually 125)

As to why they did it, quite simply because they (Firaxis) didn't need it any other way. When they needed floats you will find methods that end in "times100" - such that a parameter of 75 is converted internally to 0.75
 
Just about *every* method uses ints and not floats - modifiers are handled as percentages (so 1.25 is actually 125)

As to why they did it, quite simply because they (Firaxis) didn't need it any other way. When they needed floats you will find methods that end in "times100" - such that a parameter of 75 is converted internally to 0.75

Also, working with ints like that and then using integer division internally is far less prone to messiness than floating point arithmetic.
 
Back
Top Bottom