A guide to scripting methods

Discussion and help with using the in-game editor
Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

A guide to scripting methods

Postby Hieronymus » Sat Apr 14, 2007 1:29 pm

The purpose of this thread is to collect in one place what I've discovered about the available methods you can use in the CS scenario scripts (having gone through the list that Pecunia posted some time back). Hopefully one or two people will find it useful :) If anyone has any other insights, please share them!

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Part 1 - Sending messages

Postby Hieronymus » Sat Apr 14, 2007 1:34 pm

SendGameMessage(uint inCategory, uint inDisplay, ref string inTitle, ref string inText, ref string inSoundFilename)
This issues a message to the player, which is recorded in the message log, and may also be displayed on the screen.
Possible categories to specify are:
(uint)MessageCategory.kEpidemicsMessage
(uint)MessageCategory.kFireCollapseMessage
(uint)MessageCategory.kGodEventsMessage
(uint)MessageCategory.kInvasionsMessage
(uint)MessageCategory.kLocalEventMessage
(uint)MessageCategory.kOrderRequestMessage

Usually the ‘Local Event Message’ will be used (on testing the others, there was no observable difference in the message display).
Possible Display values are:
(uint)MessageDisplay.kMessageDisplayNone
(uint)MessageDisplay.kMessageDisplaySignificant
(uint)MessageDisplay.kMessageDisplayStandard
(uint)MessageDisplay.kMessageDisplayTutorial

'None' results in the message not being displayed on the screen, although it will be recorded in the message log. This can be handy for longer messages that don’t need to be read immediately.

'Significant' is the 'normal' method – the message is displayed, and recorded in the message log. Example usage (triggered wage change message):
string msgTitle="EVENT_Wage_Change_Title";
string msgText="EVENT_Wage_Change_Message;
msgSound="message1.mp3";
game.SendGameMessage((uint)MessageCategory.kLocalEventMessage, (uint)MessageDisplay.kMessageDisplaySignificant, ref msgTitle, ref msgText, ref msgSound);


This uses the default message sound file. The default location it will look in is the "Caesar IV\Data\Audio\Voice\Tutorials" folder. However, other locations can be used. For example:

msgSound="/../figures/praefect_15.mp3";

will play the praefect saying his "I hate arsonists..." piece.

The message itself is defined in the XML file, for example:
<String id="EVENT_Wage_Change_Title">Change in Wage Expectations</String>
<String id="EVENT_Wage_Change_Message">The increasing wealth of your city has led to demands for higher wages amongst plebs and equites alike. Check with your Labor Advisor for more information.</String>

'Standard' does not appear to have any use. The message is logged in the message log, but all that is displayed to the user is a blank ‘warning’ message.

'Tutorial' uses the display method as seen (as its name suggests) in the tutorials. This requires a different way of specifying the message text in the XML file. Such messages are not recorded in the Message Log, but are retained via an Instructions display. This can allow for quick and easy reference to essential information, rather than trawling through the message log. The following example can be seen in the Arretium tutorial XML file. The variable msgText is set to "TUTORIAL_011", and msgTitle to "TITLE_011". This illustrates some other notable features: "\n" is used for "new line", whilst the Image tag displays the 'build insula' button. (Note that any other 'tutorial' type messages should also be included between the <Layouts> tags.)

<Layouts>
...
<Layout id="TUTORIAL_011">
<Header>Get To Work</Header>
<Text>Let's get right to work. To start, you'll need some plebs to move into the city. As the labor class, plebs are the backbone of your city's economy.\n\nBuild some Insulae\n</Text>
<Image value="help_build_insula_button" />
<Text>to attract plebs to your city. You will need four occupied insulae to move on in this assignment.</Text>
</Layout>
...
</Layouts>

SendWarningMessage(ref string inMessage, ref string inSoundFilename)
This issues a one line ‘warning’ message to the player, which appears at the top of the screen. Such messages are not recorded in the message log. Example use:
String msgWarn = “Patrician_Tip”;
String msgSound = “message1.mp3”;
game.SendWarningMessage(ref msgWarn, ref msgSound);

The string variable msgWarn identifies the message text in the XML file, as below. The string msgSound identifies the sound file to be played when the message is sent (see above).
<String id="Patrician_Tip">Patricians demand security, culture and a variety of luxury goods in store.</String>
DebugOut(ref string inMessage)
Not tested this one - any ideas as to purpose or use?
Last edited by Hieronymus on Tue Jun 26, 2007 5:34 pm, edited 1 time in total.

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Part 2 - City ratings and other stats

Postby Hieronymus » Sat Apr 14, 2007 1:38 pm

GetCityFunds(out int outFunds)
Returns the current city funds. This can be useful to trigger (for example) a wage increase or an invasion.
int nCityFunds = 0;
game.GetCityFunds(out nCityFunds);

GetPopulation(out int outPopulation)
Returns the current city population. This can be useful as a trigger, for example to unlock a building.
int nPopulation = 0;
game.GetPopulation (out nPopulation);

GetCultureRating(out uint outRating)
Returns the current culture rating. This can be useful as a trigger, for example to unlock a building. Example use:
uint nCultureRating = 0;
game.GetCultureRating(out nCultureRating);


GetFavorRating(out uint outFavor)
Returns the current favor rating. This can be useful as a trigger, for example to unlock a building. Note: the returned value appears to be the “rounded up” version. Example usage:
uint nFavorRating = 0;
game.GetFavorRating(out nFavorRating);

GetProsperityRating(out uint outRating)
Returns the current prosperity rating. This can be useful as a trigger, for example to unlock a building.
uint nProsperityRating = 0;
game.GetProsperityRating(out nProsperityRating);

GetSecurityRating(out uint outRating)
Returns the current prosperity rating. This can be useful as a trigger, for example to unlock a building. Example use:
uint nSecurityRating = 0;
game.GetSecurityRating(out nSecurityRating);


GetGovernorPersonalFunds(out int outFunds)
Returns the amount of savings you currently have. This could be used to trigger certain events, such as a raid or wage rise.
int nGovernorFunds=0;
game.GetGovernorPersonalFunds(out nGovernorFunds);

GetGovernorRank(out uint outRank)
Returns the specified rank of the governor. This could be used in conjunction with GetGovernorSalaryLevel as a trigger, e.g. wage rise if paying more than entitled; or some reward if paying less than entitled. Note that, since the rank doesn’t change in a scenario, there is no absolute need to call this function; however, it may be useful in a reusable function (and also to catch any changes you make when designing the scenario).
uint nRank=0;
game.GetGovernorRank(out nRank);


GetGovernorSalaryLevel(out uint outLevel)
Returns the current salary level, which could be used in conjunction with GetGovernorRank to compare it with what the governor is entitled to take as salary.
uint nSalaryLevel=0;
game.GetGovernorSalaryLevel(out nSalaryLevel);

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Part 3 - Buildings and resources

Postby Hieronymus » Sat Apr 14, 2007 1:41 pm

GetResource(int inResourceID, out uint outAmount)
Returns the amount of the specified resource currently stored in warehouses or the buildings that produce it. The resource ID is determined from IDMaker. This can be useful as a trigger, for example to unlock a building. Example:
Int32 mDataIDOlives = IDMaker.FromString("c4cr Olives");
game.GetResource(mDataIDOlives, out nOlives);

This tells you how many olives are stored in the city. Note that the input to IDMaker.FromString is generally of the form “c4cr <XXXX>” where <XXXX> is the name of the resource.

GetActiveBuildings(int inBuildingID, out uint outAmount)
This returns the number of active (i.e. not mothballed) buildings of the specified type, as indicated by the ID returned from IDMaker. Example use – this counts the number of (non-mothballed) medium domi:
uint nMedDomi = 0;
Int32 mIDDomus2 = IDMaker.FromString("C4b Equites Housing 02");
game.GetActiveBuildings(mIDDomus, out nMedDomi);

See Part 10 below for a complete (I believe) list of building IDs.

GetInactiveBuildings(int inBuildingID, out uint outAmount)
This returns the number of inactive (i.e. mothballed) buildings of the specified type, as indicated by the ID returned from IDMaker. Usage is otherwise as for GetActiveBuildings described above.

GetTotalBuildings(int inBuildingID, out uint outAmount)
Returns the total number of buildings of the specified type, whether active or inactive. Usage is otherwise as for GetActiveBuildings described above.

GetBuildingsCollapsing(out bool outCollapsing)
Not tested but presumably returns the flag as true if there are any buildings that are about to collapse.

GetBuildingsOnFire(out bool outOnFire)
Not tested, but presumably the returned flag indicates if there are currently any buildings on fire.

GetBuildingsPlagued(out bool outPlagued)
Not tested, but presumably the returned flag indicates if plague is currently affecting any buildings.

GetFigures(out bool outOnMap)
Returns the outOnMap flag as TRUE if there are any people on the map - whether traders, or people immigrating, emigrating, wandering around or staying at home doing nothing.
Last edited by Hieronymus on Mon Jul 16, 2007 9:56 pm, edited 1 time in total.
Reason: Added description for GetFigures

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Part 4 - UI Controls

Postby Hieronymus » Sat Apr 14, 2007 1:46 pm

Note: all of the following require a call to Tools.Init before they will work (generally following scenario start or load). This in turn requires the following declaration:
private Toolset Tools;

FlashUIControl(int inProgrammerCode, int inFormID, int inFlashPeriod)
Flashes the specified build button, unsually when it has just been unlocked. The flash period appears to be measured in milliseconds: the smaller the value, the quicker the flash. See LockUIControl below for more details on its use.

LockUIControl(int inProgrammerCode, int inFormID)
This locks the specified build button, preventing the player from building that particular structure. This would be used normally to disable a building until particular requirements are met.
The control has to be identified by its ID; for some buildings, this can be obtained from IDMaker. (For others I had to find the absolute ID value by a ‘brute force’ custom script.) All known values are posted in the annex. Note that there are a small number for which we have not been able to find an ID. Examples (locking the furniture and utensils factory buttons_:
Int32 mUIIDFurniture = IDMaker.FromString("FACTORY_FURNITURE");
Int32 mUIIDUtensils = 246675851;
game.LockUIControl(mUIIDFurniture, Toolset.MainGameFormID);
game.LockUIControl(mUIIDUtensils, Toolset.MainGameFormID);

See Part 11 below for a complete list of UI control IDs.

Notes:
  1. If you are writing a script that uses this technique, you will need to keep track of which ones have been locked/unlocked by means of Boolean flags that are persistent across loads, i.e. their values are retained when the scenario is loaded from a saved game. The function ResetBaseUI is generally used on scenario start and load to reset the controls based on the values of these flags.
  2. For the major buttons e.g. Government, there is a method in Tools.cs that can be used to lock/unlock these buttons. For example:
    Tools.LockUI((int)Toolset.UIID._Govt);


UnlockUIControl(int inProgrammerCode, int inFormID)
This unlocks the specified control, which will have been locked using LockUIControl as described above.

GetUIControlLocked(int inProgrammerCode, int inFormID, out bool outLocked)
Not tested, but presumably works in much the same way as LockUIControl etc. It has no obvious purpose (except perhaps for debugging), since if controls are being locked/unlocked then the script will need to keep track of these using its own boolean flags.

GetUIControlUsed(int inProgrammerCode, int inFormID, out bool outUsed)
Not tested, but presumably works in much the same way as LockUIControl etc. Its purpose is unknown.

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Part 5 - Triggered events

Postby Hieronymus » Sat Apr 14, 2007 1:49 pm

TriggerDisasterEffect(int inType)
This can be used to trigger a one-off disaster. Example use:
Int32 mEarthquake = IDMaker.FromString("Short earthquake");
game.TriggerDisasterEffect(mEarthquake);


TriggerFireDamage(int inBuildingType, int inNumBuildingsAffected, int inAmountOfDamage)
This can be used to set a number of buildings of the specified type on fire. Example use – sets two luxury markets on fire, 80% damage:
Int32 mIDLuxury = IDMaker.FromString("C4b Market Luxury");
game.TriggerFireDamage(mIDLuxury, 2, 80);

See Part 10 below for a list of building IDs that can be used.

TriggerStructureDamage(int inBuildingType, int inNumBuildingsAffected, int inAmountOfDamage)
This can be used to cause structural damage to a number of buildings of the specified type on fire. Example use – 90% damage to the forum:
Int32 mIDForum = IDMaker.FromString("C4b service Forum");
game.TriggerStructureDamage(mIDForum, 1, 90);

See Part 10 below for a list of building IDs that can be used.

TriggerWeatherEffect(int inName)
This can be used to trigger a one-off weather event such as a blizzard, thunderstorm or sandstorm. Example use:
Int32 mSandStorm = IDMaker.FromString("SANDSTORM");
game.TriggerWeatherEffect(mSandStorm);

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Part 6 - Other event methods

Postby Hieronymus » Sat Apr 14, 2007 1:52 pm

SetFireCollapse(bool inActive)
This is used to set whether buildings on fire can collapse.
fireCollapseState = true;
game.SetFireCollapse(fireCollapseState);


SetGodEvents(bool inActive)
This is used to switch god events on or off (presumably including benevolences). For example, this code is used in the tutorials, so that god events do not get in the way.
bool bGahds = false;
game.SetGodEvents(bGahds);


SetPlagueEvents(bool inActive)
This is used to switch health events on or off. Used in the Arretium tutorial, thus:
bool bHealth = false;
game.SetPlagueEvents(bHealth);


SetRomeStandardRate(bool inPlebWages, int inAmount)
Used to set the standard wage level for plebs or equites to the specified amount. This can be used as an alternative to the usual random setting of wages, for example to link into the prosperity rating or city funds. Example use:
int nPlebWages = 23;
int nEquiteWages = 30;
game.SetRomeStandardRate(true, nPlebWages);
game.SetRomeStandardRate(false, nEquiteWages);

This code sets the Pleb and Equite standard wages to 23 and 30dn respectively.

SetWeatherActive(bool inActive)
Used to disable or enable weather events – whether scripted or random. Used in the tutorials to prevent events like thunderstorms interfering with progress.
bool bWeather = false;
game.SetWeatherActive(bWeather);


DisableEvent(string inEventName)
Not tested but presumably will disable events as listed in the editor. Not clear what string input would be used, but presumably can be found in one of the .dat files. Usage is unclear (there being specific methods for the most likely events: god, weather and health), but would be used in conjunction with EnableEvent. No idea (as yet) what would be valid inputs for the event name.

EnableEvent(string inEventName)
Not tested but presumably will enable events as listed in the editor.

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Part 7 - Trade & Empire map

Postby Hieronymus » Sat Apr 14, 2007 1:55 pm

CloseTradeRoute(uint inRouteIndex)
This closes the trade route identified by its world site index in the XML file. Example use:
game.CloseTradeRoute(7);
This closes world site 7. This can be used when certain specified conditions are met or randomly to reflect periodic disruptions to trade. If the site is visible then the player can re-open the trade route again by paying the appropriate price. If invisible, then it can only be opened again through OpenTradeRoute (described below). Note that trade route closure by this route does not take immediate effect - traders only stop appearing when a new year starts.

GetEmpireLevelLocked(uint inRouteIndex, out bool outLocked)
Not tested, but presumably determines whether the site has been locked/unlocked as described below. Given that locking/unlocking only changes the appearance of the site on the Empire Map, this would appear to be of limited use.

GetIsTradeRouteOpen(uint inRouteIndex, out bool outOpen)
Called to determine if the specified trade route, identified by its world site index in the XML file, is open. Example use:
bool isOpenLatium = false;
game.GetIsTradeRouteOpen(0, out isOpenLatium);

If the world site index corresponds to that of the home city, outOpen will be returned as "true". The flag will also be "true" if it is an enemy camp, but only if it is active and visible.

GetIsTradeRouteOpen(ref string inRouteName, out bool outOpen)
Called to determine if the specified trade route, identified by its name, is open. Usage is otherwise as described above. Example (from the Genoa tutorial):
bool isOpenCaralis = false;
string szSiteName = "Caralis";
game.GetIsTradeRouteOpen(ref szSiteName, out isOpenCaralis);

LockEmpireLevelSite(uint inRouteIndex)
This function has no effect other than to change the color of the specified site to grey on the Empire Map. It has no effects on trade routes (if trade is open, it remains open; if closed, it can still be opened in the usual manner). Therefore, its only apparent use is to illustrate changes in the state of a site following a particular storyline (e.g. an enemy camp is taken out; a trade partner is under siege, etc.). Example use:
game.LockEmpireLevelSite(7);

OpenTradeRoute(uint inRouteIndex)
This opens the trade route identified by its world site index in the XML file. Example use:
game.OpenTradeRoute(7);
This opens world site 7. This can be used when certain specified conditions are met. It is the only way of opening an ‘invisible’ trade city; if the city is visible on the Empire map, the player can always pay the cost of opening the route without meeting the conditions specified in the custom script.
It can also be used if an invisible city is used as a trigger for Victory or Defeat – the effect is to activate the city which can be set as a victory/defeat condition within the editor.
Notes:
  1. If the trade depot/port is already built, this call appears to spawn a trader.
  2. Calling this on an Enemy Camp has no effect (you cannot open trade with an enemy).
UnlockEmpireLevelSite(uint inRouteIndex)
This function has no effect other than to change the color of the specified site from grey to colored on the Empire Map. It has no effects on trade routes (if trade is closed, it remains closed). Therefore, its only apparent use is to illustrate changes in the state of a site following a particular storyline (e.g. an enemy camp becomes active, indicating imminent attack, trade partner recovers from a disaster, etc.). Example use (affecting world site 7 as identified in the XML file):
game.UnlockEmpireLevelSite(7);

ClearWorldWaypointsBetween(ref string inFromMapLabel, ref string inToMapLabel)
Purpose unclear. I thought this might enable you to edit the Empire map during a game. However, from testing I've not seen any observable effect.

InsertWorldWaypoint(int inWaypointNumber, int inWaypointType, ref string inFromMapLabel, ref string inToMapLabel, int inX, int inY)
Unknown purpose. Tried testing this but no observable effect, e.g. on Empire Map.
Last edited by Hieronymus on Fri May 04, 2007 10:19 pm, edited 1 time in total.

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Part 8 - Invasions

Postby Hieronymus » Sat Apr 14, 2007 2:00 pm

ClearInvasions()
This appears to clear records of invasions previously set up in memory. Have only used this to clear memory of the remnants of invasion data in a .scn file (which was causing an unscripted invasion to appear). Presumably this could be used as a way of preventing any future invasions of any type.

GetEnemyCohortData(int inCohortID, out string outDbID, out RomeScriptInterfaces.BasicCohortType outBasicType)
Obtains the cohort type ( Gaul light, Greek cavalry etc.) in outDbID, for the given CohortID (obtained from GetInvaderCohorts). The outher output parameter (not used in Tools.cs) is believed to identify whether the cohort type are either Archers, Cavalry, Infantry, Other, or Siege.

GetInvaderCohorts(ref string inInvasionName, out int[] outIDs)
This is used in Tools.cs, and could be used to monitor an ongoing invasion. Example use (derived from Tools.cs):
Int32[] enemyCohorts;
String invasion = mGame.RunInvasion;
game.GetInvaderCohorts(ref invasion, out enemyCohorts);

This returns a set of IDs to the enemyCohorts array. This could then be used to manipulate an ongoing invasion, e.g. through SetCohortOrders below.

SetCohortOrders(int inCohortID, ref string inOrders)
Used in Tools.cs to set the orders of individual enemy cohorts, identified by their ID (as obtained through GetInvaderCohorts above). Example (derived from Tools.cs):
foreach (Int32 cohortID in enemyCohorts)
{
[INDENT]String cohortDbID;
String orders = sCohortOrders.kRetreat;
game.SetCohortOrders(cohortID, ref orders);

}
[/INDENT]
This causes every invading cohort to retreat, e.g. after a certain time or condition met. You can use kFlee or any of the other possible orders given in the public structure sCohortOrders in Tools.cs.

SetCohortTargets(int inCohortID, ref string[] inTargets)
Used in Tools.cs to control the invasion. It could in principle (not tested yet) be used to direct enemy cohorts to target specific buildings. The input array inTargets consists of the string identifiers for the buildings to be targeted, such as “C4b Governor's Palace Large”, “C4b infra granary”. See Part 10 below for a complete list of building IDs that could be used.

StartInvasion(ref string inInvasionName)
Can be used to trigger an invasion (which has to have been just created – does not work on those set up in OnBeginScenario).
Example from Cyrene Revisited:
mInvasion = new InvasionSetup(invasionName, sInvasionFactions.kCarthaginian,
eInvasionType.kPillagers, nRaidBribe, 4, 0);
mInvasion.AddCohort(sCohortDbIDs.kCarth_Lt, 1, 3, 3);
mInvasion.AddCohort(sCohortDbIDs.kCarth_Aux, 1, 3, 3);
mInvasion.CreateInvasion(game, nInvasion, 0);
game.StartInvasion(ref invasionName);

It should be noted that this method gives the player no warning of the attack, so it requires a separate message to be fired. Also, the invaders can only be bribed via the Legion Adviser screen.

StopCurrentInvasions()
This is used in Tools.cs to stop the current invasion after a defined period of time, or after a specified percentage of buildings have been razed. It can be used in conjunction with SetCohortOrders, which gets them to leave the map. This suggests (not verified through testing yet) that this function just stops the enemy attacking further targets.

StopInvasion(ref string inInvasionName, bool inStopFutureRecurrences)
This seems to perform a similar function, but is aimed at the identified invasion. The additional effect is (potentially) to stop this invasion recurring again, as directed by the Boolean flag. For example:
String invasion = mGame.RunInvasion;
bool bStop = true;
game.StopInvasion(ref invasion, bStop);


AddCohortToInvasion(ref string inInvasionName, ref string inCohortID, uint inNumFullCohorts, uint inEntryWaypoint, uint inExitWaypoint)
This is called from the CreateInvasion method of the InvasionSetup class. It has no obvious use as it allows you to do no more than the methods available through InvasionSetup (as invoked in OnBeginScenario).

CreateInvasion(ref string inInvasionName, int inTextIndex, ref string inFaction, int inBuyoffDenarii, int inStartWeek, int inVariance, int inDuration, int inRecurrenceInterval)
Used in Tools.cs, called from mInvasions.CreateInvasion. This suggests that invasions can be set up directly, although this does not seem to be advisable, e.g. OnInvasionArrival won’t recognise the invasion.

EDIT: I've discovered that if, instead of using something like sCohortDbIDs.kCarth_Lt to identify the invading cohorts you put this in instead:

String sRomans = "ENEMY_ROMAN";

and use that as input, then Caesar's legions will appear. From brief testing they seem to behave as would be expected. Note you can also use "ENEMY_ROMAN_CATAPULT" as input too.
Last edited by Hieronymus on Sat Oct 06, 2007 5:48 pm, edited 1 time in total.
Reason: Added discovery about Caesar's legions

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Part 9 - Military requests

Postby Hieronymus » Sat Apr 14, 2007 2:01 pm

I include these two methods for completeness, as they do not seem to have any obvious use. Both are called within Tools.cs as part of the MilitaryRequest.AddMilitaryRequest method. They could be used to set up a military request by an alternative means; however, since they does not allow you to do anything that can’t be done via the MilitaryRequest class, there is no obvious gain (Calling them from OnTick has no effect.)

AddTroopRequestCohort(int inRequestID, ref string inCohortID, int inNumCohorts)

CreateTroopRequest(int inRequestID, int inStartWeek, int inRecursionWeeks, int inVariance, int inFirstWarning, int inSecondWarning, int inDeadline, int inReward, int inPenalty, int inTravelTime, int inWorldSiteIndex)

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Part 10 - Building IDs

Postby Hieronymus » Sat Apr 14, 2007 2:08 pm

These are the strings to be input into IDMaker.FromString, in order to find the IDs when working out the number of buildings (all, active or inactive) of the specified type.

Farms
"C4b harvester <XXXX> farmer's house" where <XXXX> is one of:
"Grain”, “Vegetable”, “Livestock”, “Olives”, “Grape” or “Wool”
“c4r Grain Field”
”c4r Vegetable Field”
”c4r Livestock pasture”
”c4r sheep pasture”
”c4r Grape Vinyard”
”c4r Olive Grove”

Other Raw Material Gatherers
"C4b harvester <XXXX> house" where <XXXX> is one of:
“Sand collector's”, “Clay collector’s”, “Timber miller’s”, “Iron miner’s” or “Gold miner’s”
“C4b harvester Marble collector’s camp”
“c4r Clay Pit”
“c4r Sand Pit”
”c4r Gold mine”
”c4r Iron mine”
“c4r Timber Tree”
”C4r Marble Site”

Factories
"C4b factory <XXXX>" where <XXXX> is one of:
”Pottery”, “Glass”, “Clothing”, “Olive Oil”, “Wine”, “Furniture”, “Jewelry”, “Utensils”, “Armor” or “Weapons”

Homes
"C4b Plebian home <NN>" where <NN> is “01” to “03”
"C4b Equites Housing <NN>" where <NN> is “01” to “03”
"C4b Patrician home <NN>" where <NN> is “01” to “09”

Storage & Markets
"C4b Market <XXXX>" where <XXXX> is one of: “Food”, “Basic”, “Luxury” or “Exotic”
“C4b infra Granary”
“C4b infra Warehouse”
“C4b Depot”
“C4b Depot with Dock”

Health
"C4b service <XXXX>" where <XXXX> is one of:
“Barber shop”, “Clinic”, “Bathhouse” or “Hospital”

Religion
"C4b Service Shrine <XXXX>” or “C4b Service Temple <XXXX>”
where <XXXX> is the relevant god, i.e. “Jupiter”, “Mars”, “Ceres”, “Mercury” or “Bacchus”

Education
"C4b service School"
"C4b service Library"

Entertainment
"C4b service <XXXX>" where <XXXX> is one of:
“Odeum”, “Theater”, “Arena”, “Coliseum” or “Circus”
"C4b Training <XXXX>" where <XXXX> is one of:
“Actor”, “Gladiator”, “Animal” or “Charioteer”

Water
"C4b Infra Pumphouse"
"C4b service Reservoir"
“C4b infra Well”
"C4b infra Fountain”

Government
"C4b Office <XXXX>" where <XXXX> is one of: “Engineer”, “Praefect” or “Tax Collector”
"C4b service Forum"
"C4b service Basilica"
"C4b Governor's Palace <XXXX>" where <XXXX> is one of ”Small”, “Medium” or “Large”

Decorative Items
“C4 Deco <XXXX>” where <XXXX> is one of:
”Garden”, “Hedge Small”, “Hedge Large”, “Bush Small”, “Bush Large”, “Tree Small”, “Tree Medium”, “Tree Large”, ”HedgeRow Small” or “HedgeRow Large”
"C4 Deco Statue <N>" where <N> is numbered “1” to “6”
”C4b Statue Obelisk”

Military
"C4b Mil Fort <XXXX>” where <XXXX> is one of:
“Auxilia", "Auxilia Cavalry", " Infantry Hvy", or "Infantry Lt"

"C4b infra Gate"
"C4b service Tower"
”C4b infra Wall”

“C4b Mil <XXXX>” where <XXXX> is one of:
“Drill Yard”, “Armory”, or “Mess Hall”

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Part 11 - UI Control IDs

Postby Hieronymus » Sat Apr 14, 2007 2:15 pm

I originally posted this under another thread, but this seemed a good place to repost it.
You do not have the required permissions to view the files attached to this post.

ClaudiusXXXIII
Posts: 11
Joined: Wed Feb 07, 2007 1:01 am
Location: Pennsylvania

Postby ClaudiusXXXIII » Sun Apr 15, 2007 1:40 am

WOW!!!
Thanks for all the hard work.

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Postby Hieronymus » Mon Apr 23, 2007 7:09 pm

Just to highlight that I've added an important note on the behaviour of game.CloseTradeRoute above (part 7).

Oh, and you're welcome ClaudiusXXXIII :cool:

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Postby Hieronymus » Fri May 04, 2007 10:21 pm

I've updated the guide with a little more info on game.GetIsTradeRouteOpen (in Part 7 above), explaining how it behaves when the "trade route" points to the home city or to an enemy camp.

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Postby Hieronymus » Tue Jun 26, 2007 5:36 pm

Included a little edit on the sending of messages (Part 1) - how to get the script to play other sound files.

ahk-horus
Posts: 139
Joined: Thu Sep 02, 2004 5:53 pm
Location: Germany
Contact:

Postby ahk-horus » Mon Jul 02, 2007 6:13 am

Question to Hieronymus:

To Lock/Unlock the timbercamp I need to use this ID:

private Int32 Lager = IDMaker.FromString("C4b harvester Timber miller's house");

But it does'nt work to count the camps with <game.GetTotalBuildings>. For this case I have to use this string:

private Int32 LagerT = IDMaker.FromString("CAMP_TIMBER");

And i can't Lock/Unlock the camp with this string.

Do i something wrong? Are there other double Stringoptions? And does anyone know how to edit DAT files ?

ahk-horus


P.S. See this CS, it works proper.
You do not have the required permissions to view the files attached to this post.
Last edited by ahk-horus on Mon Jul 02, 2007 6:18 am, edited 1 time in total.

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Postby Hieronymus » Mon Jul 02, 2007 2:46 pm

OK, I'll have a proper look at this later today when I get chance, and get back to you. But just to clarify:

ahk-horus wrote: private Int32 Lager = IDMaker.FromString("C4b harvester Timber miller's house");

is what you use to count the number of buildings of that type, whereas

ahk-horus wrote: private Int32 LagerT = IDMaker.FromString("CAMP_TIMBER");

is used for locking/unlocking the build buttons for that building. I don't recall actually testing either of these specifically, but the first is used in Tools.cs (when enemy cohorts are deciding what buildings to attack) and the second is used in the Verona tutorial to unlock the timber camp. So there's no obvious reason why they wouldn't work.

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Postby Hieronymus » Mon Jul 02, 2007 8:15 pm

OK, I tested the following bit of code, based on your script (with Lager and LagerT defined as per the script):

UInt32 NumLager = 0;

game.GetTotalBuildings(Lager, out NumLager);
if (NumLager > 4)
game.LockUIControl(LagerT, Toolset.MainGameFormID);

if (NumLager < 5)
game.UnlockUIControl(LagerT, Toolset.MainGameFormID);

I found this worked in that the timber camp was enabled until the script detected that I had built more than 4 camps - after that it was disabled. However, it's possible to get around this because the code is executed only every game tick, which gives the player a window of opportunity - around 2 seconds, or indefinitely if the player hits the pause button.

Also, I note that following these checks there is code that checks if NumLager is > 5 which "shouldn't" be possible (except as I've described above).

Hieronymus
Posts: 537
Joined: Fri Dec 08, 2006 9:10 am
Location: Londinium, with the insane parakeets

Postby Hieronymus » Mon Jul 16, 2007 9:58 pm

Added an unremarkable discovery about GetFigures, added to Part 3 above. Who knows, someone might find a used for it. :)


Return to “Editing”

Who is online

Users browsing this forum: No registered users and 2 guests