Franc160th Posted August 24, 2018 Report Share Posted August 24, 2018 Hi everyone, I'm playing a bit with the Atlas editor and I'm wondering how to garrison units from the editor itself, if possibile. Thank you in advance Quote Link to comment Share on other sites More sharing options...
Silier Posted August 24, 2018 Report Share Posted August 24, 2018 Hi, This is not currently possible. If you need it, you have to use triggers. @elexis But if you just want to see how building changes if is garrisoned you can switch to actor viewer. Quote Link to comment Share on other sites More sharing options...
Franc160th Posted August 24, 2018 Author Report Share Posted August 24, 2018 First of all thanks for your reply, what do you mean with "triggers"? Quote Link to comment Share on other sites More sharing options...
Stan` Posted August 24, 2018 Report Share Posted August 24, 2018 5 minutes ago, Franc160th said: First of all thanks for your reply, what do you mean with "triggers"? Triggers are basically a JavaScript script that you add to your map to trigger specific events. For instance you can make units spawn from a specific area, or make the water rise. There is no current way to edit it directly in the editor, so you have to create it manually. Look at other maps to see how it is done. One thing you can try (I'm absolutely not sure whether it works) is to start the simulation in atlas, make entities garrison walls, and save the map. Quote Link to comment Share on other sites More sharing options...
Franc160th Posted August 24, 2018 Author Report Share Posted August 24, 2018 (edited) 4 minutes ago, stanislas69 said: Triggers are basically a JavaScript script that you add to your map to trigger specific events. For instance you can make units spawn from a specific area, or make the water rise. There is no current way to edit it directly in the editor, so you have to create it manually. Look at other maps to see how it is done. One thing you can try (I'm absolutely not sure whether it works) is to start the simulation in atlas, make entities garrison walls, and save the map. Ouuh ok, understood, I'll try to make my way through these scripts By the way every kind of help is welcomed Edited August 24, 2018 by Franc160th Quote Link to comment Share on other sites More sharing options...
elexis Posted August 24, 2018 Report Share Posted August 24, 2018 Quote TriggerHelper.SpawnAndGarrisonAtClasses(5, "Tower", TriggerHelper.GetTemplateNamesByClasses("CitizenSoldier+Infantry", "kush", undefined, "Basic", true), 0.6); This garrisons all towers to 60% capacity with kush Citizen Soldier Infantry units for player 5. Taken from elephantine_trigger_scripts.json. One can do it without a trigger script too, for example Sicilia Nomad has this: Quote "Garrison": { "3434": [3435, 3436, 3437, 3438, 3439, 3440, 3441, 3442, 3443, 3444, 3429, 3430, 3431, 3432, 3433], "3445": [3446, 3447, 3448, 3449, 3450, 3451, 3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3460] }, But you can see it's quite uncomfortable - one has to place the entities manually and find the entity IDs of these units. See Gallic Fields for example to see how triggerscript files can be loaded. 2 Quote Link to comment Share on other sites More sharing options...
Franc160th Posted August 25, 2018 Author Report Share Posted August 25, 2018 18 hours ago, elexis said: This garrisons all towers to 60% capacity with kush Citizen Soldier Infantry units for player 5. Taken from elephantine_trigger_scripts.json. One can do it without a trigger script too, for example Sicilia Nomad has this: But you can see it's quite uncomfortable - one has to place the entities manually and find the entity IDs of these units. See Gallic Fields for example to see how triggerscript files can be loaded. 18 hours ago, elexis said: TriggerHelper.SpawnAndGarrisonAtClasses(5, "Tower", TriggerHelper.GetTemplateNamesByClasses("CitizenSoldier+Infantry", "kush", undefined, "Basic", true), 0.6); Ok, but let's assume that I need my kush soldiers of player 5 to get into the towers. Is it enough if I copy that script and paste it in the js console of the editor? Quote Link to comment Share on other sites More sharing options...
Guest Posted August 25, 2018 Report Share Posted August 25, 2018 How should garrisons be handled at mapGen stage if its decided to support this? I have been working with making it possible to set stances. If it can be done in a clean way, I might look into it. 1 hour ago, Franc160th said: Is it enough if I copy that script and paste it in the js console of the editor? Not quite, you would need the script in a .js file and change the map xml file to load it. More info can be found here. Quote Link to comment Share on other sites More sharing options...
elexis Posted August 25, 2018 Report Share Posted August 25, 2018 Quote "TriggerScripts": [ "scripts/TriggerHelper.js", "skirmishes/Gallic Fields (3).js" ], Above is added to the XML file, taken from Gallic Fields (3).xml. Below is the triggerscript JS file: Quote Trigger.prototype.InitMyMap = function() { TriggerHelper.SpawnAndGarrisonAtClasses(5, "Tower", TriggerHelper.GetTemplateNamesByClasses("CitizenSoldier+Infantry", "kush", undefined, "Basic", true), 0.6); }; { Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger).RegisterTrigger("OnInitGame", "InitMyMap", { "enabled": true }); } Quote Link to comment Share on other sites More sharing options...
Franc160th Posted August 26, 2018 Author Report Share Posted August 26, 2018 20 hours ago, (-_-) said: How should garrisons be handled at mapGen stage if its decided to support this? I have been working with making it possible to set stances. If it can be done in a clean way, I might look into it. Not quite, you would need the script in a .js file and change the map xml file to load it. More info can be found here. Ok, I took a look at that page and it was useful, thanks Quote "TriggerScripts": [ "scripts/TriggerHelper.js", "skirmishes/Gallic Fields (3).js" ], @elexis I added the above lines to my map.xml file, changing the "Gallic Fields (3).js" file with another one, where I added the following lines: Quote { warn("My first trigger script"); }; Trigger.prototype.InitMyMap_GarrisonBuildings = function() { let romeInfantryUnits = TriggerHelper.GetTemplateNamesByClasses("CitizenSoldier+Infantry", "rome", undefined, "Elite", true); TriggerHelper.SpawnAndGarrisonAtClasses(2, "Tower", romeInfantryUnits, 1); }; { Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger).RegisterTrigger("OnInitGame", "InitMyMap", { "enabled": true }); } I understood that had to define who "romeInfantryUnits" are and I tried to do so with this as you can see: Quote let romeInfantryUnits = TriggerHelper.GetTemplateNamesByClasses("CitizenSoldier+Infantry", "rome", undefined, "Elite", true); But I still get these errors: Quote [2000.822] error: JavaScript error: maps/skirmishes/Gauls_vs_Romans.js line 14 (even if there are 13 lines) [2000.822] error: SyntaxError: illegal character [2000.822] error: I know that I may seem stupid, but I never used java or any other code and I actually don't know anything about it, sorry Quote Link to comment Share on other sites More sharing options...
Guest Posted August 26, 2018 Report Share Posted August 26, 2018 Which editor did you use? Editors such as Microsoft Word could mess up a sourcecode file. Quote Link to comment Share on other sites More sharing options...
elexis Posted August 26, 2018 Report Share Posted August 26, 2018 Yeah sounds like an encoding issue. You can also check for JavaScript syntax errors on http://jshint.com/ Also InitMyMap != InitMyMap_GarrisonBuildings Quote Link to comment Share on other sites More sharing options...
Franc160th Posted August 26, 2018 Author Report Share Posted August 26, 2018 9 minutes ago, elexis said: Yeah sounds like an encoding issue. You can also check for JavaScript syntax errors on http://jshint.com/ Also InitMyMap != InitMyMap_GarrisonBuildings Ok gonna check that out 32 minutes ago, (-_-) said: Which editor did you use? Editors such as Microsoft Word could mess up a sourcecode file. I use xed, I'm on linux. I'll download gedit just to see if the editor messes up with the code Quote Link to comment Share on other sites More sharing options...
Guest Posted August 26, 2018 Report Share Posted August 26, 2018 (edited) For future reference, you can use cat to check if a file (not a good idea for a large file) has any wierd invisible characters. You would just need the -A option IIRC. cat -A <your trigger script>; $ indicates a newline, ^I would be tab. Edited August 26, 2018 by Guest Reformat Quote Link to comment Share on other sites More sharing options...
Franc160th Posted August 26, 2018 Author Report Share Posted August 26, 2018 4 hours ago, elexis said: Yeah sounds like an encoding issue. You can also check for JavaScript syntax errors on http://jshint.com/ Also InitMyMap != InitMyMap_GarrisonBuildings Ok, I checked those lines in that site and solved about everything, I do not get the error messages and I get the warning I wantend (My first trigger script). There's one last thing: where shall I put this? Quote InitMyMap != InitMyMap_GarrisonBuildings 4 hours ago, (-_-) said: For future reference, you can use cat to check if a file (not a good idea for a large file) has any wierd invisible characters. You would just need the -A option IIRC. cat -A <your trigger script>; $ indicates a newline, ^I would be tab. Thanks for the tip, didn't know that Quote Link to comment Share on other sites More sharing options...
Guest Posted August 26, 2018 Report Share Posted August 26, 2018 (edited) 7 minutes ago, Franc160th said: where shall I put this? In a new .js file in the same directory as where your .xml file is. Convention is to name both files the same. Also dont forget to update the xml files “TriggerScripts” part. Edit: seems like I misread your post if you meant where to put the qouted statement. It was merely stating that the two functions are not the same. Edited August 26, 2018 by Guest Quote Link to comment Share on other sites More sharing options...
Franc160th Posted August 26, 2018 Author Report Share Posted August 26, 2018 3 minutes ago, (-_-) said: In a new .js file in the same directory as where your .xml file is. Convention is to name both files the same. Also dont forget to update the xml files “TriggerScripts” part. In my .xml file I put this: Quote "TriggerScripts": [ "scripts/TriggerHelper.js", "skirmishes/Gauls_vs_Romans.js" ], I should add that line to "Gauls_vs_Romans.js"? Quote Link to comment Share on other sites More sharing options...
Guest Posted August 26, 2018 Report Share Posted August 26, 2018 You defined InitMyMap_GarrisonBuildings but used InitMyMap as the function name while registering the trigger. The last InitMyMap should be changed to InitMyMap_GarrisonBuildings. Quote Link to comment Share on other sites More sharing options...
Franc160th Posted August 26, 2018 Author Report Share Posted August 26, 2018 (edited) 20 minutes ago, (-_-) said: You defined InitMyMap_GarrisonBuildings but used InitMyMap as the function name while registering the trigger. The last InitMyMap should be changed to InitMyMap_GarrisonBuildings. Oh yeah you're right. This one shall be good: Quote { warn("My first trigger script"); } Trigger.prototype.InitMyMap_GarrisonBuildings = function() { let romeInfantryUnits = TriggerHelper.GetTemplateNamesByClasses("CitizenSoldier+Infantry", "rome", undefined, "Elite", true); TriggerHelper.SpawnAndGarrisonAtClasses(2, "Tower", romeInfantryUnits, 1); }; { Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger).RegisterTrigger("OnInitGame", "InitMyMap_GarrisonBuildings", { "enabled": true }); } Yess, it is. I succeded in garrisoning the tower. I now need to garrison tents..I'll let you know. Edited August 26, 2018 by Franc160th Quote Link to comment Share on other sites More sharing options...
Franc160th Posted August 26, 2018 Author Report Share Posted August 26, 2018 (edited) Ok, done. Thank you so much for your support!! This is my final Gauls_vs_Romans.js: Quote { warn("My first trigger script"); } Trigger.prototype.InitMyMap_GarrisonBuildings = function() { let romeInfantryUnits = TriggerHelper.GetTemplateNamesByClasses("CitizenSoldier+Infantry", "rome", undefined, "Elite", true); TriggerHelper.SpawnAndGarrisonAtClasses(2, "Tower", romeInfantryUnits, 1); TriggerHelper.SpawnAndGarrisonAtClasses(2, "House", romeInfantryUnits, 1); TriggerHelper.SpawnAndGarrisonAtClasses(2, "defense_wall_long", romeInfantryUnits, 1); }; { Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger).RegisterTrigger("OnInitGame", "InitMyMap_GarrisonBuildings", { "enabled": true }); } The only problem now is garrisoning units on the siege wall, but I'll try to solve this problem, which is less important than garrisoning in 80 tents and so many wall towers Edited August 26, 2018 by Franc160th 1 Quote Link to comment Share on other sites More sharing options...
Guest Posted August 31, 2018 Report Share Posted August 31, 2018 For future references, it is possible to garrison units without using a trigger script. But I'm guessing that no UI has been implemented. So it would be pretty troublesome to do this by hand for a couple dozen units and buildings. But putting this here just because it is possible. Basically you would need a Garrison value in the xml file. "Garrison": { "3434": [3435, 3436, 3437, 3438, 3439, 3440, 3441, 3442, 3443, 3444, 3429, 3430, 3431, 3432, 3433], "3445": [3446, 3447, 3448, 3449, 3450, 3451, 3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3460] }, This is copy pasted from Sicilia Nomad map file. 3434 is the entity which is housing the units. The array contains the entityIDs of all units garrisoned in entity 3434. There are two players who have garrisoned ships, hence two keys. Quote Link to comment Share on other sites More sharing options...
Silier Posted August 31, 2018 Report Share Posted August 31, 2018 2 hours ago, (-_-) said: For future references, it is possible to garrison units without using a trigger script. But I'm guessing that no UI has been implemented. So it would be pretty troublesome to do this by hand for a couple dozen units and buildings. But putting this here just because it is possible. Basically you would need a Garrison value in the xml file. "Garrison": { "3434": [3435, 3436, 3437, 3438, 3439, 3440, 3441, 3442, 3443, 3444, 3429, 3430, 3431, 3432, 3433], "3445": [3446, 3447, 3448, 3449, 3450, 3451, 3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3460] }, This is copy pasted from Sicilia Nomad map file. 3434 is the entity which is housing the units. The array contains the entityIDs of all units garrisoned in entity 3434. There are two players who have garrisoned ships, hence two keys. said by elexis allready Quote Link to comment Share on other sites More sharing options...
Franc160th Posted September 4, 2018 Author Report Share Posted September 4, 2018 On 8/31/2018 at 2:38 PM, (-_-) said: For future references, it is possible to garrison units without using a trigger script. But I'm guessing that no UI has been implemented. So it would be pretty troublesome to do this by hand for a couple dozen units and buildings. But putting this here just because it is possible. Basically you would need a Garrison value in the xml file. "Garrison": { "3434": [3435, 3436, 3437, 3438, 3439, 3440, 3441, 3442, 3443, 3444, 3429, 3430, 3431, 3432, 3433], "3445": [3446, 3447, 3448, 3449, 3450, 3451, 3452, 3453, 3454, 3455, 3456, 3457, 3458, 3459, 3460] }, This is copy pasted from Sicilia Nomad map file. 3434 is the entity which is housing the units. The array contains the entityIDs of all units garrisoned in entity 3434. There are two players who have garrisoned ships, hence two keys. Yeah, but it's actually very unconfortable On 8/31/2018 at 4:58 PM, Angen said: said by elexis allready ahah yep Btw still thank you so much, I did manage to garrison what I needed except for walls, but they're not a big problem 1 Quote Link to comment Share on other sites More sharing options...
elexis Posted September 4, 2018 Report Share Posted September 4, 2018 Garrisoning walls shouldn't be a problem. Notice that SpawnAndGarrisonAtClasses spawns at classes of the Identity component, such as Tower, House, or Wall or SiegeWall, not template names. 1 Quote Link to comment Share on other sites More sharing options...
Caros Posted October 1, 2022 Report Share Posted October 1, 2022 And what's the nuber for Gaia? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.