mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
Make cheering moddable
Reviewed by: @Angen Differential Revision: https://code.wildfiregames.com/D3081 This was SVN commit r24192.
This commit is contained in:
parent
bd43bdca69
commit
3a4a7ee5f9
2 changed files with 21 additions and 4 deletions
|
|
@ -24,6 +24,11 @@ UnitAI.prototype.Schema =
|
|||
"<element name='CanPatrol'>" +
|
||||
"<data type='boolean'/>" +
|
||||
"</element>" +
|
||||
"<optional>" +
|
||||
"<element name='CheeringTime'>" +
|
||||
"<data type='nonNegativeInteger'/>" +
|
||||
"</element>" +
|
||||
"</optional>" +
|
||||
"<optional>" +
|
||||
"<interleave>" +
|
||||
"<element name='NaturalBehaviour' a:help='Behaviour of the unit in the absence of player commands (intended for animals)'>" +
|
||||
|
|
@ -1433,7 +1438,12 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
|
||||
"IDLE": {
|
||||
"Order.Cheer": function() {
|
||||
// Do not cheer if there is no cheering time.
|
||||
if (!this.cheeringTime)
|
||||
return { "discardOrder": true };
|
||||
|
||||
this.SetNextState("CHEERING");
|
||||
return false;
|
||||
},
|
||||
|
||||
"enter": function() {
|
||||
|
|
@ -1930,7 +1940,9 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
}
|
||||
|
||||
let cmpUnitAI = Engine.QueryInterface(this.order.data.target, IID_UnitAI);
|
||||
this.shouldCheer = cmpUnitAI && (!cmpUnitAI.IsAnimal() || cmpUnitAI.IsDangerousAnimal());
|
||||
|
||||
// Units with no cheering time do not cheer.
|
||||
this.shouldCheer = cmpUnitAI && (!cmpUnitAI.IsAnimal() || cmpUnitAI.IsDangerousAnimal()) && this.cheeringTime > 0;
|
||||
|
||||
return false;
|
||||
},
|
||||
|
|
@ -2013,7 +2025,11 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
|
||||
"FINDINGNEWTARGET": {
|
||||
"Order.Cheer": function() {
|
||||
if (!this.cheeringTime)
|
||||
return { "discardOrder": true };
|
||||
|
||||
this.SetNextState("CHEERING");
|
||||
return false;
|
||||
},
|
||||
|
||||
"enter": function() {
|
||||
|
|
@ -3043,7 +3059,7 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
"CHEERING": {
|
||||
"enter": function() {
|
||||
this.SelectAnimation("promotion");
|
||||
this.StartTimer(2800);
|
||||
this.StartTimer(this.cheeringTime);
|
||||
return false;
|
||||
},
|
||||
|
||||
|
|
@ -3279,7 +3295,7 @@ UnitAI.prototype.UnitFsmSpec = {
|
|||
"CHEERING": {
|
||||
"enter": function() {
|
||||
this.SelectAnimation("promotion");
|
||||
this.StartTimer(2800);
|
||||
this.StartTimer(this.cheeringTime);
|
||||
return false;
|
||||
},
|
||||
|
||||
|
|
@ -3328,7 +3344,7 @@ UnitAI.prototype.Init = function()
|
|||
this.lastHealed = undefined;
|
||||
|
||||
this.formationAnimationVariant = undefined;
|
||||
|
||||
this.cheeringTime = +(this.template.CheeringTime || 0);
|
||||
this.SetStance(this.template.DefaultStance);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@
|
|||
<FormationController>false</FormationController>
|
||||
<CanGuard>true</CanGuard>
|
||||
<CanPatrol>true</CanPatrol>
|
||||
<CheeringTime>2800</CheeringTime>
|
||||
</UnitAI>
|
||||
<UnitMotion>
|
||||
<FormationController>false</FormationController>
|
||||
|
|
|
|||
Loading…
Reference in a new issue