Freagarach Posted May 20, 2019 Report Share Posted May 20, 2019 15 hours ago, asterix said: Look at the section formations https://trac.wildfiregames.com/wiki/Alpha23 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. 4 hours ago, (-_-) 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) 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 1 hour ago, Angen said: @Freagarach what is your code to set formation to run speed? 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 45 minutes ago, Angen said: I use something like this 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 5/20/2019 at 1: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 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 5 hours ago, Lion.Kanzen said: Now is possible ? Or we need more pathfinder changes? Well, my solution was neither regarding the pathfinder nor UnitMotion, it was regarding a function in Formation.js. Spoiler 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 7/23/2019 at 12: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); }; 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 4 hours ago, Lion.Kanzen said: But how will work for the user, a hotkeys or mouse command? 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.