I’d just like to make a few suggestions that I think are important! What’s missing are event listeners, especially in technologies for track status progress. Furthermore, working with arrays could be a bit simpler, similar to the JavaScript programming language. Function names are just examples. I’m not very good at english.
Suggestion about event listeners:
int xsEvent(string eventName, void function, bool once); // once is optional parameter
bool xsRemoveEvent(int eventId);
suggested events: technologyinprogress = in progress, technologyresearched = research completed, technologyqueued = in queue/pending, technologyresearchstopped, playerdefeated, playerresigned
Example for tech listener:
// Create listener. retuns a unique id
int aEvent = xsEvent("technologyresearch", (int playerId, int technologyId) {
});
// Or
void MyCustomFunction(int playerId, int technologyId) {
};
int aEvent = xsEvent("technologyresearch", MyCustomFunction);
// Remove event
bool isAEventRemoved = xsRemoveEvent(aEvent);
or just all-in one for technologies:
void MyCustomFunction(int playerId, int technologyId, string technologyState) {
};
int aEvent = xsEvent("technologystate", MyCustomFunction);
Extra: If you want to disable civilization bonuses or create a custom technology tree /bonuses before starting the game. Currently, bonuses are activated before main function runs.
void MyCustomFunction() {
for(i = 0; < xsGetNumPlayers()) {
int getCivId = xsGetPlayerCivilization(i);
if(getCivId == cBulgarians) {
xsEnableTech(i, 45, true); // Enable faith
xsResearchTech(i, 505, true); // Research Recurve Bow. No matter is civ specific tech or not when "force" parameter are true
}
}
};
int aEvent = xsEvent("ready", MyCustomFunction, true); // or beforeready / beforestart etc... run once
Simplified array creation, and objects
I don’t really need to go into too much detail. The example explains it:
array randomItems = [10024, 1020, 301401, 502402, {"hey" : "hooo"}, 815135, "string", 1.222, true];
array scores = [2,3232,42424,25525];
array players = [
["Hun player", "Barbar"],
["Byzantine Player", "Defensive"]
];
object aObj = {
"name" : "Blah",
"age" : 10,
"aura" : 1.5
};
array aTable = [{
"name" : "Hera",
"civilization" : "Byzantines",
"civId" : 7,
"isAlive" : true
}, {
"name" : "Red Phosphorus",
"civilization" : "Goths",
"civId" : 3,
"isAlive" : true
}];
xsChatData(aObj.name); // prints Blah
object getHera = aTable[0];
string getBlahName = aObj.name;
// print scores
for(i = 0; <= xsTotalArrayItems(scores)) { // or xsTotal(array arr) / xsCount(array arr)
xsChatData(scores[i]);
}
As well we need a basic array functions, like: filter, sort, find, push, pop, split, includes, copy etc…
Perhaps Map and Set-like functions:
Set - JavaScript | MDN … and … Map() constructor - JavaScript | MDN
Additional Suggested Functions / Simplified existing features … or maybe it would be possible to add them into a single function (extending xsEffect function) …although it may be less “user friendly”
For techs and units
array[object] xsGetTechResources(int techId); // or xsGetUnitResources
bool xsSetTechResourceCost(int techId, int resourceIndex, int resourceId, int value); // Or xsSetUnitResourceCost
bool xsRemoveTechResourceCost(int techId, int resourceIndex); // or xsRemoveUnitResourceCost
int xsGetTechResourceStoreMode(int techId, int resourceIndex);// or xsGetUnitResourceStoreMode
bool xsSetTechResourceStoreMode(int techId, int resourceIndex, int storeMode); // or xsSetUnitResourceStoreMode
// Only for techs
bool xsEnableTech(int playerId, int techId, bool enableOrDisable);
bool xsResearchTech(int playerId, int techId, bool force);
string xsGetTechState(int playerId, int techId);
array[object] xsGetTechRequiredTechs(int techId);
int xsGetTechRequiredTech(int techId, int index);
bool xsRemoveTechRequiredTech(int techId, int index);
bool xsSetTechRequiredTech(int techId, int index, int requiredTechId);
int xsGetTechMinimumReqTechsCount(int techId);
bool xsSetTechMinimumReqTechsCount(int techId, int value);
int xsGetTechRepeatableCount(id techId);
bool xsSetTechRepeatableCount(id techId, int value);
int xsGetTechIcon(id techId);
bool xsSetTechIcon(id techId, int value);
// Exclusive techs
int xsCreateExclusiveTechBucket(string type, array[techIds], object options = {"instant" : false, "startingTech" : -1, "enabled" : false});
bool xsRemoveExclusiveTechBucket(int exclusiveBucketId);
bool xsRemoveExclusiveTech(int exclusiveBucketId, int index);
bool xsAddExclusiveTech(int exclusiveBucketId, int techId, int index); // Index is optional
bool xsSetExclusiveTechBucketType(string type);
string xsGetExclusiveTechBucketType(int exclusiveBucketId);
bool xsSetInstant(int exclusiveBucketId, bool instant);
bool xsSetStartingTechId(int exclusiveBucketId, int techId);
bool xsIsInstant(int exclusiveBucketId);
int xsGetActiveTech(int exclusiveBucketId);
bool xsSetActiveTech(int exclusiveBucketId, id techId); // false if the specified tech already active
bool xsSetExclusiveTechBucketState(bool enable);
int xsGetStartingTechId(int exclusiveBucketId);
array[object {"id" : int, "startingTech" : bool, "active" : bool}] xsGetExclusiveTechs(int exclusiveBucketId);
Examples:
array castleAgeCosts = xsGetTechResources(102);
bool isRemovedCost = xsRemoveTechResourceCost(102, 2); // removes 2nd resource
result for xsGetTechResources:
[
{"type" : 0, "value" : 800, "storeMode" : 1}, // 0 = food
{"type" : 1, "value" : 200, "storeMode" : 1} // 1 = gold
]
Example for making exclusive techs:
// Create an exclusive tech bucket
int bucket = xsCreateExclusiveTechBucket("Cycle", [1281, 1282, 1283], {"instant" : true, "startingTech" : 1281, "enabled" : true});
bool added = xsAddExclusiveTech(bucket, 1284); // Index is optional, so it places at the end of the array, as the last element
xsChatData(xsGetExclusiveTechBucketType(bucket)) // Prints Cycle
bool isRemoved = xsRemoveExclusiveTech(bucket, 1282); // false if technology is starting tech. if removed, this tech are deactivated and next technology are activated (1283)
bool byebyeBucket = xsRemoveExclusiveTechBucket(bucket); // Removed and deactivated
Player/civilization related functions:
array[int] xsGetAllDisabledTechIds(int playerId);
array[int] xsGetAllEnabledTechIds(int playerId);
array[int] xsGetAllCivilizationSpecificTechIds(int civilizationId); // team Bonuses, unique unit upgrades, civ specific techs...
bool xsRevertTech(int playerId, int technologyId); // This is useful if you want to remove the civilization bonus later, returns true if success
bool xsApplyTech(int playerId, int technologyId); // This is useful if you want to apply or reactivate civilization bonus or civilization specific tech. Perhaps this could be resolved using the “xsEnableTech”
At least i couldn’t figure out how to disable the civilization bonus in the xs script before it was applied. If anyone knows the secret, please tell me but without full tech mode! It’s midnight here right now, so im going to sleep. If anything else comes to mind—for me or for you—don’t keep it to yourself!
Edit: + Maybe we need a module based system! (import/export)