1
0
forked from 0ad/0ad

-rank/formation stuff and fixes. To give a unit a rank texture, just set rank.name in the entity's XML to the filename of the texture e.g. elite.dds or advanced.dds

This was SVN commit r3711.
This commit is contained in:
pyrolink 2006-03-31 03:37:36 +00:00
parent 3408b078b7
commit cf14a7bc15
5 changed files with 94 additions and 2 deletions

View File

@ -0,0 +1,51 @@
<formation Tag="Form Box 2"
bonus="actions.move.speed"
bonustype="sword"
bonusval=".2"
penalty=""
penaltytype=""
penaltyval=""
required="10"
next="BoxForm3"
prior="BoxForm1"
movement="Group Line"
rankspacing="5.0f"
filespacing="5.0f"
>
<fl category="Melee">
<rk order="1"></rk>
<rk order="10"></rk>
<rk order="2"></rk>
<rk order="11"></rk>
<rk order="3"></rk>
</fl>
<fl category="Melee">
<rk order="12"></rk>
<rk category="Melee, Ranged" order="18"></rk>
<rk category="Melee, Ranged" order="22"></rk>
<rk category="Melee, Ranged" order="19"></rk>
<rk order="13"></rk>
</fl>
<fl category="Melee">
<rk order="4"></rk>
<rk category="Melee, Ranged" order="23"></rk>
<rk category="Support, Lead, Ranged" order="5"></rk>
<rk category="Melee, Ranged" order="24"></rk>
<rk order="6"></rk>
</fl>
<fl category="melee">
<rk order="14"></rk>
<rk category="Melee, Ranged" order="20"></rk>
<rk category="Melee, Ranged" order="25"></rk>
<rk category="Melee, Ranged" order="21"></rk>
<rk order="15"></rk>
</fl>
<fl category="Melee">
<rk order="7"></rk>
<rk order="16"></rk>
<rk order="8"></rk>
<rk order="17"></rk>
<rk order="9"></rk>
</fl>
</formation>

View File

@ -34,6 +34,11 @@
<Bar_Height>-1.0</Bar_Height>
<Bar_Size>20</Bar_Size>
</Stamina>
<Rank>
<Height>7.0</Height>
<Size>17</Size>
<Name></Name>
</Rank>
</Traits>

View File

@ -20,5 +20,6 @@
<Event On="Generic" Function="entityEventGeneric" />
<Event On="TargetChanged" Function="entityEventTargetChanged" />
<Event On="Notification" Function="entityEventNotification" />
<Event On="Formation" Function="entityEventFormation" />
</Entity>

View File

@ -742,6 +742,7 @@ function entityEventTargetChanged( evt )
// If we can gather, and the target supplies, gather. If it's our enemy, and we're armed, attack.
// If all else fails, move (or run on a right-click).
evt.defaultOrder = NMT_Goto;
evt.defaultCursor = "arrow-default";
evt.defaultAction = ACTION_NONE;
@ -1312,3 +1313,32 @@ function GotoInRange( x, y, run )
else
this.order( ORDER_GOTO, x, y - this.actions.escort.distance, true);
}
function entityEventFormation( evt )
{
if ( evt.formationEvent == FORMATION_ENTER )
{
if ( this.getFormationBonus() && this.isInClass( this.getFormationBonusType() ) )
{
eval( this + this.getFormationBonus() ) += eval( this + this.getFormationBonus() ) *
this.getFormationBonusVal();
}
if ( this.getFormationPenalty() && this.isInClass( this.getFormationPenaltyType() ) )
{
eval( this + this.getFormationPenalty() ) -= eval( this + this.getFormationbonus() ) *
this.getFormationPenaltyVal();
}
}
//Reverse the bonuses
else if ( evt.formationEvent == FORMATION_LEAVE )
{
if ( this.getFormationBonus() && this.isInClass( this.getFormationBonusType() ) )
{
eval( this + this.getFormationBonus() ) -= eval( this + this.getFormationBonus() ) * this.getFormationBonusVal();
}
if ( this.getFormationPenalty() && this.isInClass( this.getFormationPenaltyType() ) )
{
eval( this + this.getFormationPenalty() ) += eval( this + this.getFormationbonus() ) *
this.getFormationPenaltyVal();
}
}
}

View File

@ -70,6 +70,7 @@ function worldClickHandler(event)
else
args[1]=event.secondaryAction;
break;
//TODO: get rid of order() calls.
case NMT_NotifyRequest:
if (event.clicks == 1)
action = event.action;
@ -78,8 +79,10 @@ function worldClickHandler(event)
if (event.entity.isIdle())
{
for (i=0; i<selection.length;i++)
for (var i=0; i<selection.length;i++)
{
if (!selection[i].actions)
continue;
console.write("Requesting notification for " + event.entity);
selection[i].requestNotification( event.entity, action, true );
selection[i].order( ORDER_GOTO, event.entity.position.x, event.entity.position.z - selection[i].actions.escort.distance, true);
@ -87,8 +90,10 @@ function worldClickHandler(event)
}
else
{
for (i=0; i<selection.length;i++)
for (var i=0; i<selection.length;i++)
{
if (!selection[i].actions)
continue;
console.write("Requesting notification for " + event.entity);
selection[i].requestNotification( event.entity, action, true );
}