Freagarach Posted May 20, 2019 Report Share Posted May 20, 2019 On 19/05/2019 at 11:24 PM, asterix said: Look at the section formations https://trac.wildfiregames.com/wiki/Alpha23 Expand Is says that the speed bonus is removed, is that what you are referring to? Because I tried to let units actually run in the formations (visualise an awesome cavalry charge) but, strangely, they only slow down when I try to use the run speed. On 20/05/2019 at 10:39 AM, (-_-) said: What kind of information do you need from the hyrule code? (I talked to exo and while he did adapt it, the core concept remains the same) Expand Well, I don't *need* anything, but I'm just curious I wanted to see what code they used for the different steps, but if it is basically the same it is okay. Quote Link to comment Share on other sites More sharing options...
Silier Posted May 20, 2019 Report Share Posted May 20, 2019 @Freagarach what is your code to set formation to run speed? Quote Link to comment Share on other sites More sharing options...
Freagarach Posted May 20, 2019 Report Share Posted May 20, 2019 On 20/05/2019 at 4:55 PM, Angen said: @Freagarach what is your code to set formation to run speed? Expand Well it does not really matter, as I just saw that in Formation.js "ComputeMotionParameters" only uses the walking speed. So I'll need to tinker with that Quote Link to comment Share on other sites More sharing options...
Silier Posted May 20, 2019 Report Share Posted May 20, 2019 Formation.prototype.Run = function() { let maxSpeed = 0; for (let ent of this.members) { let cmpUnitMotion = Engine.QueryInterface(ent, IID_UnitMotion); if (cmpUnitMotion) { if (maxSpeed == 0) maxSpeed = cmpUnitMotion.GetRunMultiplier(); else maxSpeed = Math.min(maxSpeed, cmpUnitMotion.GetRunMultiplier()); } } maxSpeed *= this.GetSpeedMultiplier(); <- apply formation speed multiplier this.speed = maxSpeed * this.minSpeed; <- this.minSpeed is minimal walking speed of formation this.running = true; let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); cmpUnitMotion.SetSpeedMultiplier(this.speed); } I use something like this 1 1 Quote Link to comment Share on other sites More sharing options...
Freagarach Posted May 20, 2019 Report Share Posted May 20, 2019 On 20/05/2019 at 6:22 PM, Angen said: I use something like this Expand I changed the "ComputeMotionParameters" function to include a check whether "run" is called, to remove duplication But that is not on SVN, so I probably need to use your code in the future Quote Link to comment Share on other sites More sharing options...
Lion.Kanzen Posted July 23, 2019 Report Share Posted July 23, 2019 On 20/05/2019 at 7:10 PM, Freagarach said: I changed the "ComputeMotionParameters" function to include a check whether "run" is called, to remove duplication But that is not on SVN, so I probably need to use your code in the future Expand Now is possible ? Or we need more pathfinder changes? Quote Link to comment Share on other sites More sharing options...
Freagarach Posted July 23, 2019 Report Share Posted July 23, 2019 On 23/07/2019 at 12:42 AM, Lion.Kanzen said: Now is possible ? Or we need more pathfinder changes? Expand Well, my solution was neither regarding the pathfinder nor UnitMotion, it was regarding a function in Formation.js. Reveal hidden contents For reference this was my (currently hopelessly outdated) solution: /** * Set formation controller's speed based on its current members. * @param {boolean} - whether the run-speed is wanted */ Formation.prototype.ComputeMotionParameters = function(run = false) { let minSpeed = Infinity; for (let ent of this.members) { let cmpUnitMotion = Engine.QueryInterface(ent, IID_UnitMotion); if (cmpUnitMotion) minSpeed = run ? Math.min(minSpeed, cmpUnitMotion.GetRunSpeed()) : Math.min(minSpeed, cmpUnitMotion.GetWalkSpeed()); } minSpeed *= this.GetSpeedMultiplier(); let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); if (cmpUnitMotion) cmpUnitMotion.SetSpeed(minSpeed); }; 1 Quote Link to comment Share on other sites More sharing options...
Lion.Kanzen Posted August 15, 2019 Report Share Posted August 15, 2019 On 23/07/2019 at 6:36 AM, Freagarach said: Well, my solution was neither regarding the pathfinder nor UnitMotion, it was regarding a function in Formation.js. Reveal hidden contents For reference this was my (currently hopelessly outdated) solution: /** * Set formation controller's speed based on its current members. * @param {boolean} - whether the run-speed is wanted */ Formation.prototype.ComputeMotionParameters = function(run = false) { let minSpeed = Infinity; for (let ent of this.members) { let cmpUnitMotion = Engine.QueryInterface(ent, IID_UnitMotion); if (cmpUnitMotion) minSpeed = run ? Math.min(minSpeed, cmpUnitMotion.GetRunSpeed()) : Math.min(minSpeed, cmpUnitMotion.GetWalkSpeed()); } minSpeed *= this.GetSpeedMultiplier(); let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); if (cmpUnitMotion) cmpUnitMotion.SetSpeed(minSpeed); }; Expand But how will work for the user, a hotkeys or mouse command? Quote Link to comment Share on other sites More sharing options...
Freagarach Posted August 15, 2019 Report Share Posted August 15, 2019 On 15/08/2019 at 12:59 AM, Lion.Kanzen said: But how will work for the user, a hotkeys or mouse command? Expand The way I implemented it was that at a certain (template-based) range from their targets, the units started running instead of walking. No user input required. 1 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.