mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Reset speed when stopping.
And use an explicit function for running. Differential revision: https://code.wildfiregames.com/D4957 Comments by: @Stan This was SVN commit r27706.
This commit is contained in:
parent
0e57957a09
commit
291f17b3c5
2 changed files with 18 additions and 18 deletions
|
|
@ -1928,7 +1928,6 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
|
||||
"leave": function(msg) {
|
||||
this.StopMoving();
|
||||
this.ResetSpeedMultiplier();
|
||||
this.StopTimer();
|
||||
this.SetDefaultAnimationVariant();
|
||||
},
|
||||
|
|
@ -1999,7 +1998,7 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
|
||||
this.PlaySound("panic");
|
||||
|
||||
this.SetSpeedMultiplier(this.GetRunMultiplier());
|
||||
this.Run();
|
||||
return false;
|
||||
},
|
||||
|
||||
|
|
@ -2024,7 +2023,6 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
},
|
||||
|
||||
"leave": function() {
|
||||
this.ResetSpeedMultiplier();
|
||||
this.StopMoving();
|
||||
},
|
||||
|
||||
|
|
@ -2302,16 +2300,14 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
if (!this.formationAnimationVariant)
|
||||
this.SetAnimationVariant("combat");
|
||||
|
||||
var cmpUnitAI = Engine.QueryInterface(this.order.data.target, IID_UnitAI);
|
||||
if (cmpUnitAI && cmpUnitAI.IsFleeing())
|
||||
this.SetSpeedMultiplier(this.GetRunMultiplier());
|
||||
if (Engine.QueryInterface(this.order.data.target, IID_UnitAI)?.IsFleeing())
|
||||
this.Run();
|
||||
|
||||
this.StartTimer(1000, 1000);
|
||||
return false;
|
||||
},
|
||||
|
||||
"leave": function() {
|
||||
this.ResetSpeedMultiplier();
|
||||
this.StopMoving();
|
||||
this.StopTimer();
|
||||
},
|
||||
|
|
@ -4647,9 +4643,12 @@ UnitAI.prototype.SetAnimationSync = function(actiontime, repeattime)
|
|||
|
||||
UnitAI.prototype.StopMoving = function()
|
||||
{
|
||||
let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion);
|
||||
if (cmpUnitMotion)
|
||||
cmpUnitMotion.StopMoving();
|
||||
const cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion);
|
||||
if (!cmpUnitMotion)
|
||||
return;
|
||||
|
||||
cmpUnitMotion.StopMoving();
|
||||
cmpUnitMotion.SetSpeedMultiplier(1);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -6139,20 +6138,19 @@ UnitAI.prototype.GetStanceName = function()
|
|||
};
|
||||
|
||||
/*
|
||||
* Make the unit walk at its normal pace.
|
||||
* Make the unit run.
|
||||
*/
|
||||
UnitAI.prototype.ResetSpeedMultiplier = function()
|
||||
UnitAI.prototype.Run = function()
|
||||
{
|
||||
let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion);
|
||||
if (cmpUnitMotion)
|
||||
cmpUnitMotion.SetSpeedMultiplier(1);
|
||||
this.SetSpeedMultiplier(this.GetRunMultiplier());
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} speed - The multiplier to set the speed to.
|
||||
*/
|
||||
UnitAI.prototype.SetSpeedMultiplier = function(speed)
|
||||
{
|
||||
let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion);
|
||||
if (cmpUnitMotion)
|
||||
cmpUnitMotion.SetSpeedMultiplier(speed);
|
||||
Engine.QueryInterface(this.entity, IID_UnitMotion)?.SetSpeedMultiplier(speed);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ function TestFormationExiting(mode)
|
|||
AddMock(unit, IID_UnitMotion, {
|
||||
"GetWalkSpeed": () => 1,
|
||||
"GetAcceleration": () => 1,
|
||||
"SetSpeedMultiplier": () => {},
|
||||
"MoveToFormationOffset": (target, x, z) => {},
|
||||
"MoveToTargetRange": (target, min, max) => true,
|
||||
"SetMemberOfFormation": () => {},
|
||||
|
|
@ -359,6 +360,7 @@ function TestMoveIntoFormationWhileAttacking()
|
|||
AddMock(unit + i, IID_UnitMotion, {
|
||||
"GetWalkSpeed": () => 1,
|
||||
"GetAcceleration": () => 1,
|
||||
"SetSpeedMultiplier": () => {},
|
||||
"MoveToFormationOffset": (target, x, z) => {},
|
||||
"MoveToTargetRange": (target, min, max) => true,
|
||||
"SetMemberOfFormation": () => {},
|
||||
|
|
|
|||
Loading…
Reference in a new issue