man_s_our Posted January 5, 2022 Report Share Posted January 5, 2022 (edited) I was trying to implement the feature of seperate entities for horse riders but I got a problem and didn't knew what the thing that keeps changing coordinates. the logs gave me: the horse 7079 got the order from 7085, x = 608.2567138671875 z = 852.1669311523438 7079 ordered to Walk to x = 841.0175601990993, z = 100 the function is: UnitAI.prototype.Walk = function(x, z, queued, pushFront) { let mov = 1; log(this.entity + " ordered to Walk to x = " + x + ", z = " + z); let cmpTurretable = Engine.QueryInterface(this.entity, IID_Turretable); if (cmpTurretable) { mov = 0; log(this.entity + " Turretable"); let tur = cmpTurretable.HolderID(); log(tur + " is Turret"); if (tur) { let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); if (cmpTimer) { log("the horse " + tur + " got the order from " + this.entity + ", x = " + x + " z = " + z); cmpTimer.SetTimeout(tur, IID_UnitAI, "Walk", 100, x, z, queued, pushFront); } } else mov = 1; } if (mov) { if (!pushFront && this.expectedRoute && queued) this.expectedRoute.push({ "x": x, "z": z }); else this.AddOrder("Walk", { "x": x, "z": z, "force": true }, queued, pushFront); } }; any ideas? Edited January 5, 2022 by man_s_our Quote Link to comment Share on other sites More sharing options...
man_s_our Posted January 5, 2022 Author Report Share Posted January 5, 2022 I fond the problem was in the need to turn the args into dictionary first. this code solves the problem: UnitAI.prototype.Walk = function(x, z, queued, pushFront) { let mov = 1; let cmpTurretable = Engine.QueryInterface(this.entity, IID_Turretable); if (cmpTurretable) { mov = 0; let tur = cmpTurretable.HolderID(); if (tur) { let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); if (cmpTimer) { var data = { "x": x, "z": z, "queued": queued, "pushFront": pushFront }; cmpTimer.SetTimeout(tur, IID_UnitAI, "Walkt", 100, data); } } else mov = 1; } if (mov) { if (!pushFront && this.expectedRoute && queued) this.expectedRoute.push({ "x": x, "z": z }); else this.AddOrder("Walk", { "x": x, "z": z, "force": true }, queued, pushFront); } }; UnitAI.prototype.Walkt = function(data, lateness) { let x = data.x; let z = data.z; let queued = data.queued; let pushFront = data.pushFront; if (!pushFront && this.expectedRoute && queued) this.expectedRoute.push({ "x": x, "z": z }); else this.AddOrder("Walk", { "x": x, "z": z, "force": true }, queued, pushFront); }; Quote Link to comment Share on other sites More sharing options...
Freagarach Posted January 6, 2022 Report Share Posted January 6, 2022 Glad you got it working. I've bitten my teeth on this turret-order problem before, so I'm very interested in any results, so please do keep us (me) updated. 1 Quote Link to comment Share on other sites More sharing options...
man_s_our Posted January 6, 2022 Author Report Share Posted January 6, 2022 (edited) 11 hours ago, Freagarach said: Glad you got it working. I've bitten my teeth on this turret-order problem before, so I'm very interested in any results, so please do keep us (me) updated. till now the problems I got is: when order the unit to gather while it's riding a horse (propably will be solved after editing more UnitAI functions) if I order a melee unit to ride a horse and send it to fight it doesn't attack the enemies. I don't know which function that will return the current movement speed (instead of max speed) to use it for archer's spread. (solved) Edited January 6, 2022 by man_s_our Quote Link to comment Share on other sites More sharing options...
man_s_our Posted January 17, 2022 Author Report Share Posted January 17, 2022 @Freagarach this is what I reached till the moment. couldn't find the reason why melee units can't attack while turretting horses. UnitAI.js 1 Quote Link to comment Share on other sites More sharing options...
man_s_our Posted January 24, 2022 Author Report Share Posted January 24, 2022 (edited) @Freagarach changelog: riders' orientation is now the same with the horse most the time when the horse is walking (turretable.js) the horse will automatically go to the targeted unit so that the rider attack it instead of having to make 2 seperate orders. the cavalry units are automatically using hit-run tactics (can be disabled by replacing "range.max / 2" in the line 5087 by range.min) TODO: fix the bugs related to gathering (when gather order issued you can't stop it) UnitAI.js Turretable.js Edited January 24, 2022 by man_s_our Quote Link to comment Share on other sites More sharing options...
man_s_our Posted January 24, 2022 Author Report Share Posted January 24, 2022 this attack.js patch has the increased spread for archers when the horse is moving. Attack.js 1 Quote Link to comment Share on other sites More sharing options...
Freagarach Posted January 25, 2022 Report Share Posted January 25, 2022 Very cool! It seems you are coming close to something we may be able include in the main game (feature wise), could you upload a patch on our Phabricator, please? (https://trac.wildfiregames.com/wiki/SubmittingPatches) It will allow us to give direct comments on your code and speed up the inclusion. (I see quite some hardcoding in some functions, but it might be unavoidable.) Quote Link to comment Share on other sites More sharing options...
man_s_our Posted January 25, 2022 Author Report Share Posted January 25, 2022 10 hours ago, Freagarach said: Very cool! It seems you are coming close to something we may be able include in the main game (feature wise), could you upload a patch on our Phabricator, please? (https://trac.wildfiregames.com/wiki/SubmittingPatches) It will allow us to give direct comments on your code and speed up the inclusion. (I see quite some hardcoding in some functions, but it might be unavoidable.) I already planned to do it when I complete the TODO list. the same with the hunger script when finishing the last bug. 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.