Silier Posted June 25, 2018 Author Report Share Posted June 25, 2018 @gaius , I will not send you whole file because I have there another changes and you probably do not want them so: file: /helpers/Commands.js find function GetFormationUnitAIs and rename it to something like this e.g. GetMergedFormationUnitAIs. Now find "formation": function(player, cmd, data) should be around line 612 and use renamed function instead old (you need it to form new formation, reform or merge more formations on command) For rest of not renamed callings, create this function, which is not merging selected units into one formation but keeping existing: function GetFormationUnitAIs(ents, player) { // Separate out the units that don't support the chosen formation let formedEnts = []; let nonformedUnitAIs = []; for (let ent of ents) { // Skip units with no UnitAI or no position let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); let cmpPosition = Engine.QueryInterface(ent, IID_Position); if (!cmpUnitAI || !cmpPosition || !cmpPosition.IsInWorld()) continue; let cmpIdentity = Engine.QueryInterface(ent, IID_Identity); let nullFormation = cmpUnitAI.GetFormationTemplate() == "special/formations/null"; if (nullFormation) { RemoveFromFormation([ent]); nonformedUnitAIs.push(cmpUnitAI); } else { formedEnts.push(ent); } } // No units support the formation - return all the others if (formedEnts.length == 0) return nonformedUnitAIs; let formationUnitAIs = []; let formations = ExtractFormations(formedEnts); for (let i = 0; i < formations.ids.length; ++i) { let fId = formations.ids[i]; let cmpUnitAI = Engine.QueryInterface(+fId, IID_UnitAI); if(cmpUnitAI) formationUnitAIs.push(cmpUnitAI); } return nonformedUnitAIs.concat(formationUnitAIs); } Quote Link to comment Share on other sites More sharing options...
Silier Posted June 25, 2018 Author Report Share Posted June 25, 2018 some showcase from controll video 1 1 Quote Link to comment Share on other sites More sharing options...
gaius Posted June 26, 2018 Report Share Posted June 26, 2018 Very nice, Angen. And i guess you will decrease turning rate of formation so its possible to flank a formation. Quote Link to comment Share on other sites More sharing options...
Guest Posted June 26, 2018 Report Share Posted June 26, 2018 2 hours ago, gaius said: Very nice, Angen. And i guess you will decrease turning rate of formation so its possible to flank a formation. Isn’t that already supported? IIRC, there was a <turn rate> element in the formation xml files. Quote Link to comment Share on other sites More sharing options...
Guest Posted June 26, 2018 Report Share Posted June 26, 2018 15 hours ago, Angen said: some showcase from controll video Good work! Quote Link to comment Share on other sites More sharing options...
gaius Posted June 26, 2018 Report Share Posted June 26, 2018 there is a turnrate element but I'm pretty sure it makes no difference, prob. not implemented Quote Link to comment Share on other sites More sharing options...
Silier Posted June 26, 2018 Author Report Share Posted June 26, 2018 (edited) 1 hour ago, (-_-) said: Isn’t that already supported? IIRC, there was a <turn rate> element in the formation xml files. Yes, there is turn rate, but I am not using it now. I am just turning +/- 12 on button click, but I ll probably turn down movement speed for this action so they will get to turned position slower. Quote 3 hours ago, gaius said: Very nice, Angen. And i guess you will decrease turning rate of formation so its possible to flank a formation. Currently there is no difference based on side you are attacking formation from. Edited June 26, 2018 by Angen Quote Link to comment Share on other sites More sharing options...
gaius Posted June 26, 2018 Report Share Posted June 26, 2018 (edited) I inserted your code in my newest version. Works great and is really useful, thanks @Angen. Also my Infantry can now fight better in pure Formation when put on StandGround. I solved it that way, that they heal each other a bit when idle. It is not a perfect solution, but an interesting one and also nice as a tactical move. https://0ad.mod.io/formation-fighting-mod Edited June 26, 2018 by gaius 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.