Player:CreateGreatGeneral issue

LeeS

Imperator
Joined
Jul 23, 2013
Messages
7,241
Location
Illinois, USA
This (taken from here on the modwiki) appears not to be accurate:
Code:
Player:CreateGreatGeneral(Unit eGreatPersonUnit, bool incrementThreshold, bool incrementExperience, int x, int y) 


Parameters 

eGreatPersonUnit:  No description available.  
incrementThreshold:  No description available.  
incrementExperience:  No description available.  
x:  No description available.  
y:  No description available

Using the arguments in the order shown:
Code:
pPlayer:CreateGreatGeneral(gProconsulUnitID, true, true, iPlotX, iPlotY)
Always wanted to spawn a Great General at grid position X0Y0. The correct great general unit was spawned and the threshold for the next Great General was incremented correctly, just at the wrong map position, and always at 0,0..

In order to get the great general to spawn in the desired plot position I had to alter my use of the arguments as follows:
Code:
pPlayer:CreateGreatGeneral(gProconsulUnitID, iPlotX, iPlotY, true, true)

  1. Am I misunderstanding something here?
  2. Do we have a thread somewhere wherein people are recording such issues where they find the modwiki is either incorrect or too vague to be of much use?

(and if you're wondering why I need to do this, it appears the game does not like what I did with my Great General Replacement Unit in my Scipio's Rome mod. I had thought it was working correctly, but when I actually moused-over the Military Overview panel player's combat experience towards the next Great General spawning I had 3,825/200 combat experience towards the next Great General).
 
Based on the following comment in the DLL:

Code:
//void CreateGreatGeneral(int eGreatPersonUnit, bool bIncrementThreshold, bool bIncrementExperience, int iX, int iY);

I'd guess the version in the modwiki used to be correct, but Firaxis changed the function signature in a patch. The ModWiki used to be maintained automatically by some software DonQuiche wrote, but he hasn't been active for a while. The C++ source is the only real definitive documentation of what's available in Lua. If you wish to fix this page in the ModWiki I think you can by just signing up for an account (it's all free).
 
Except the comment disagrees with the code!

Code:
//void CreateGreatGeneral(int eGreatPersonUnit, bool bIncrementThreshold, bool bIncrementExperience, int iX, int iY);
int CvLuaPlayer::lCreateGreatGeneral(lua_State* L)
{
  CvPlayerAI* pkPlayer = GetInstance(L);
  const UnitTypes eGreatPersonUnit = (UnitTypes)lua_tointeger(L, 2);
  const int x = lua_tointeger(L, 3);
  const int y = lua_tointeger(L, 4);

  pkPlayer->createGreatGeneral(eGreatPersonUnit, x, y);
  return 0;
}

So the correct method signature is

pPlayer:CreateGreatGeneral(iUnitType, iPlotX, iPlotY)
 
Except the comment disagrees with the code!

Code:
//void CreateGreatGeneral(int eGreatPersonUnit, bool bIncrementThreshold, bool bIncrementExperience, int iX, int iY);
int CvLuaPlayer::lCreateGreatGeneral(lua_State* L)
{
  CvPlayerAI* pkPlayer = GetInstance(L);
  const UnitTypes eGreatPersonUnit = (UnitTypes)lua_tointeger(L, 2);
  const int x = lua_tointeger(L, 3);
  const int y = lua_tointeger(L, 4);

  pkPlayer->createGreatGeneral(eGreatPersonUnit, x, y);
  return 0;
}

So the correct method signature is

pPlayer:CreateGreatGeneral(iUnitType, iPlotX, iPlotY)

So the next Threshold value and Combat Experience value adjustments are automatic as part of the method?

This is actually good for me since it is what I want anyway. And I can eliminate the spurious arguments in my code.
 
Back
Top Bottom