1
0
forked from 0ad/0ad

Secondary order script support; run order addition

This was SVN commit r3362.
This commit is contained in:
pyrolink 2006-01-16 10:55:01 +00:00
parent 2cc7221166
commit 01ff2fdf3b
4 changed files with 59 additions and 9 deletions

View File

@ -25,7 +25,12 @@
<Health>
<Bar_Height>-1.0</Bar_Height>
<Bar_Size>20</Bar_Size>
</Health>
<Stamina>
<Bar_Height>-1.0</Bar_Height>
<Bar_Size>20</Bar_Size>
</Stamina>
</Traits>

View File

@ -48,6 +48,10 @@ function entityInit()
if (this.traits.health && this.traits.health.max)
this.traits.health.curr = this.traits.health.max
// If entity has health, set current to same.
if (this.traits.stamina && this.traits.stamina.max)
this.traits.stamina.curr = this.traits.stamina.max
if (this.traits.supply)
{
// If entity has supply, set current to same.
@ -545,6 +549,9 @@ function entityEventGeneric( evt )
console.write( "Unknown generic action: " + evt.action );
}
}
//======================================================================
function entityEventNotification( evt )
{
switch( evt.type )
@ -554,11 +561,10 @@ function entityEventNotification( evt )
case NOTIFY_ATTACK:
case NOTIFY_DAMAGE:
this.Order( ORDER_GENERIC, evt.target, ACTION_ATTACK);
this.Order( ORDER_GENERIC, evt.target, ACTION_ATTACK);
case NOTIFY_HEAL:
this.Order( ORDER_GENERIC, evt.target, ACTION_HEAL);
this.Order( ORDER_GENERIC, evt.target, ACTION_HEAL );
case NOTIFY_GATHER:
this.Order( ORDER_GENERIC, evt.target, ACTION_GATHER);
this.Order( ORDER_GENERIC, evt.target, ACTION_GATHER );
}
}
@ -579,6 +585,9 @@ function entityEventTargetChanged( evt )
evt.defaultOrder = NMT_Goto;
evt.defaultCursor = "arrow-default";
evt.secondaryOrder = NMT_Run;
evt.secondaryCursor = "arrow-default";
if( evt.target && this.actions )
{
/*
@ -597,6 +606,7 @@ function entityEventTargetChanged( evt )
evt.defaultCursor = "action-gather-" + evt.target.traits.supply.subtype;
}
*/
if( this.actions.attack &&
evt.target.player != this.player &&
evt.target.traits.health &&
@ -605,13 +615,22 @@ function entityEventTargetChanged( evt )
evt.defaultOrder = NMT_Generic;
evt.defaultAction = ACTION_ATTACK;
evt.defaultCursor = "action-attack";
evt.secondaryOrder = NMT_Generic;
evt.secondaryAction = ACTION_ATTACK;
evt.secondaryCursor = "action-attack";
}
if( canGather( this, evt.target ) )
{
evt.defaultOrder = NMT_Generic;
evt.defaultAction = ACTION_GATHER;
// Set cursor (eg "action-gather-fruit").
evt.defaultCursor = "action-gather-" + evt.target.traits.supply.subtype;
// Set cursor (eg "action-gather-fruit").
evt.defaultCursor = "action-gather-" + evt.target.traits.supply.subtype;
evt.secondaryOrder = NMT_Generic;
evt.secondaryAction = ACTION_GATHER;
// Set cursor (eg "action-gather-fruit").
evt.secondaryCursor = "action-gather-" + evt.target.traits.supply.subtype;
}
}
}
@ -636,6 +655,10 @@ function entityEventPrepareOrder( evt )
if( !this.actions.move )
evt.preventDefault();
break;
case ORDER_RUN:
if( !this.actions.move.run )
evt.preventDefault();
break;
case ORDER_PATROL:
if( !this.actions.patrol )
evt.preventDefault();

View File

@ -30,8 +30,15 @@
<Health>
<Max>100</Max>
<Bar_Height>5.0</Bar_Height>
<Bar_Size>20</Bar_Size>
</Health>
<Stamina>
<Max>5.0</Max>
<Bar_Height>5.2</Bar_Height>
<Bar_Size>20</Bar_Size>
</Stamina>
<MiniMap>
<Type>Unit</Type>
</MiniMap>
@ -48,6 +55,8 @@
<TurningRadius>0.0</TurningRadius>
<Run>
<Speed>0.0</Speed>
<Regen_Rate>10.0</Regen_Rate>
<Decay_Rate>5.0</Decay_Rate>
</Run>
</Move>

View File

@ -2,7 +2,6 @@
DESCRIPTION : Functions for the world click handler and manipulating entities.
NOTES :
*/
// ====================================================================
addGlobalHandler ("worldClick", worldClickHandler);
@ -43,6 +42,7 @@ function worldClickHandler(event)
{
// location target commands
case NMT_Goto:
case NMT_Run:
case NMT_Patrol:
if (event.queued)
{
@ -65,7 +65,10 @@ function worldClickHandler(event)
// break;
case NMT_Generic:
args[0]=event.entity;
args[1]=event.action;
if ( event.clicks == 1)
args[1]=event.action;
else
args[1]=event.secondaryAction;
break;
default:
console.write("worldClickHandler: Unknown order: "+cmd);
@ -73,6 +76,9 @@ function worldClickHandler(event)
break;
}
if (event.clicks == 2)
triggerSelectionRun();
issueCommand (selection, cmd, args[0], args[1]);
}
@ -161,6 +167,13 @@ function selected()
// ====================================================================
function triggerSelectionRun()
{
for ( i=0; i< selection.length; i++ )
{
selection[i].triggerRun();
}
}