Yep, you modders read it right. I have the solution to finding out a players (Human or AI) government attached to this very thread.
WARNING!
This modification will NOT run by itself! This is a modders resource! Of course, if you were to add it to the default game, it will work.
Concept:
Okay. Here I was just quietly fixing Citrix profiles, when it suddenly hit me that a Cleric and Fascist is only built by certain governments. Then I remembered that it's possible to check what's in the build queue. So by putting two and two together, an idea formed........
1. Create units specific to one government.
2. Put that unit in the build queue.
3. Check if that unit is in the build queue.
4. If it is, then logically the player is in that government.
Now to find a unit which is in the game all the time....... a settler is available from turn 0, but is obsoleted by the urban planner. But who would build a settler over an urban planner? Not even the vanilla AI. So I figured, add a unit, call it something like "DONT BUILD ME AS I DISAPPEAR EVERY TURN!", and voila. I should be able to extract what government someone is in be checking what govt-specific unit I can build.
Installing:
1. Put the SLIC file in the usual place, and enable it through script.slc.
2. Add what's contained in units.txt to the real units.txt (my file only contains the changed values).
3. Add names for each unit in gl_str.txt.
4. And away we go! No need for uniticon.txt, newsprite.txt or any other file to be modified.
How to use:
The variable GOVT_WhatGovtAmI[player] contains the integar which correlates to the GovernmentDB index (hence why the array is setup in govern.txt order). Just check the value of that variable, and you have your government!
Bugs:
The bane of a modder.......
1. The unit will actually stay in the build queue. No matter where I put KillUnitFromBuildQueue, it only worked from HandleEvent(EndTurn). Maybe if we give the units names like "DONT BUILD ME!" or something, and definitely not put it in unitbuildlists.txt for the AI.
2. Because of the above bug, if you have nothing in the build queue, the production will accumulate and you'll eventually be able to build one of the temp units (not good). I'd say a simple CreateUnit check to see if one's built, and replace it with a standard settler if one actually is built will do nicely here.
This is definitely a huge step for us modders. SOOOOOOOOOOOOOOOOO much can be done with knowing what Government someone is in.
EDIT: Clarification - The temp unit only stays in the build queue till the EndTurn event is called. The KillUnitFromBuildQueue command works from there. So as soon as you hit the "End Turn" button, the temp unit disappears.
WARNING!
This modification will NOT run by itself! This is a modders resource! Of course, if you were to add it to the default game, it will work.
Concept:
Okay. Here I was just quietly fixing Citrix profiles, when it suddenly hit me that a Cleric and Fascist is only built by certain governments. Then I remembered that it's possible to check what's in the build queue. So by putting two and two together, an idea formed........
1. Create units specific to one government.
2. Put that unit in the build queue.
3. Check if that unit is in the build queue.
4. If it is, then logically the player is in that government.
Now to find a unit which is in the game all the time....... a settler is available from turn 0, but is obsoleted by the urban planner. But who would build a settler over an urban planner? Not even the vanilla AI. So I figured, add a unit, call it something like "DONT BUILD ME AS I DISAPPEAR EVERY TURN!", and voila. I should be able to extract what government someone is in be checking what govt-specific unit I can build.
Installing:
1. Put the SLIC file in the usual place, and enable it through script.slc.
2. Add what's contained in units.txt to the real units.txt (my file only contains the changed values).
3. Add names for each unit in gl_str.txt.
4. And away we go! No need for uniticon.txt, newsprite.txt or any other file to be modified.
How to use:
The variable GOVT_WhatGovtAmI[player] contains the integar which correlates to the GovernmentDB index (hence why the array is setup in govern.txt order). Just check the value of that variable, and you have your government!
Bugs:
The bane of a modder.......
1. The unit will actually stay in the build queue. No matter where I put KillUnitFromBuildQueue, it only worked from HandleEvent(EndTurn). Maybe if we give the units names like "DONT BUILD ME!" or something, and definitely not put it in unitbuildlists.txt for the AI.
2. Because of the above bug, if you have nothing in the build queue, the production will accumulate and you'll eventually be able to build one of the temp units (not good). I'd say a simple CreateUnit check to see if one's built, and replace it with a standard settler if one actually is built will do nicely here.
This is definitely a huge step for us modders. SOOOOOOOOOOOOOOOOO much can be done with knowing what Government someone is in.
EDIT: Clarification - The temp unit only stays in the build queue till the EndTurn event is called. The KillUnitFromBuildQueue command works from there. So as soon as you hit the "End Turn" button, the temp unit disappears.
Comment