Fix Idle formation rearranging when an entity dies.
Idle formations re-arrange whenever a member leaves the formation. Because Idle formation entities can attack nearby units (the formation stays idle for this), any death will re-arrange the formation, causing the entities to move in formation before going back to attack. This looks odd and makes formation less usable. Given that it's tricky to change the controller state with the current code, this instead reforms the formation on a timer, only when all members are IDLE. It fixes the issue and looks generally similar in other cases. Reported By: wowgetoffyourcellphone Reviewed By: Freagarach Differential Revision: https://code.wildfiregames.com/D3236 This was SVN commit r24467.
This commit is contained in:
parent
f0faab7a42
commit
71a61d5f50
@ -902,8 +902,29 @@ UnitAI.prototype.UnitFsmSpec = {
|
||||
|
||||
"IDLE": {
|
||||
"enter": function(msg) {
|
||||
// Turn rearrange off. Otherwise, if the formation is idle,
|
||||
// but individual units go off to fight, any death
|
||||
// will rearrange the formation, looking odd.
|
||||
// Instead, move idle units in formation on a timer.
|
||||
let cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
|
||||
cmpFormation.SetRearrange(false);
|
||||
this.StartTimer(0, 2000);
|
||||
return false;
|
||||
},
|
||||
|
||||
"leave": function() {
|
||||
this.StopTimer();
|
||||
},
|
||||
|
||||
"Timer": function(msg) {
|
||||
let cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
|
||||
if (!cmpFormation)
|
||||
return;
|
||||
|
||||
if (this.TestAllMemberFunction("IsIdle"))
|
||||
cmpFormation.MoveMembersIntoFormation(false, false);
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
"WALKING": {
|
||||
@ -6462,12 +6483,9 @@ UnitAI.prototype.CallPlayerOwnedEntitiesFunctionInRange = function(funcname, arg
|
||||
*/
|
||||
UnitAI.prototype.TestAllMemberFunction = function(funcname, args)
|
||||
{
|
||||
var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
|
||||
if (!cmpFormation)
|
||||
return false;
|
||||
|
||||
return cmpFormation.GetMembers().every(ent => {
|
||||
var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
|
||||
let cmpFormation = Engine.QueryInterface(this.entity, IID_Formation);
|
||||
return cmpFormation && cmpFormation.GetMembers().every(ent => {
|
||||
let cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI);
|
||||
return cmpUnitAI[funcname].apply(cmpUnitAI, args);
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user