1
0
forked from 0ad/0ad

Added shouldRun parameter to order(ORDER_GENERIC) calls from scripts.

This was SVN commit r6224.
This commit is contained in:
Matei 2008-07-13 16:31:03 +00:00
parent e4966f6f1b
commit 36b18f646f
2 changed files with 22 additions and 15 deletions

View File

@ -982,7 +982,7 @@ function damage( dmg, inflictor )
this.requestNotification( inflictor, NOTIFY_ORDER_CHANGE, false, true );
this.registerDamage( inflictor );
if( this.isIdle() )
this.order( ORDER_GENERIC, inflictor, this.getAttackAction( inflictor ) );
this.order( ORDER_GENERIC, inflictor, this.getAttackAction( inflictor ), false );
}*/
this.onDamaged( inflictor );
@ -1036,13 +1036,13 @@ function entityEventNotification( evt )
break;
case NOTIFY_ATTACK:
case NOTIFY_DAMAGE:
this.order( ORDER_GENERIC, evt.target, ACTION_ATTACK );
this.order( ORDER_GENERIC, evt.target, ACTION_ATTACK, false );
break;
case NOTIFY_HEAL:
this.order( ORDER_GENERIC, evt.target, ACTION_HEAL );
this.order( ORDER_GENERIC, evt.target, ACTION_HEAL, false );
break;
case NOTIFY_GATHER:
this.order( ORDER_GENERIC, evt.target, ACTION_GATHER );
this.order( ORDER_GENERIC, evt.target, ACTION_GATHER, false );
break;
case NOTIFY_IDLE:
//target is the unit that has become idle. Eventually...do something here.
@ -1099,7 +1099,7 @@ function entityEventTargetExhausted( evt )
// If the target was gatherable, try to gather it.
if( canGather(this, evt.target) )
{
this.order( ORDER_GENERIC, evt.target, ACTION_GATHER );
this.order( ORDER_GENERIC, evt.target, ACTION_GATHER, false );
return;
}
@ -1122,7 +1122,7 @@ function entityEventTargetExhausted( evt )
}
if( bestTarget != null )
{
this.order( ORDER_GENERIC, bestTarget, ACTION_BUILD );
this.order( ORDER_GENERIC, bestTarget, ACTION_BUILD, false );
return;
}
@ -1156,7 +1156,7 @@ function chooseGatherTarget( resourceSubType, targetList )
}
if( bestTarget != null )
{
this.order( ORDER_GENERIC, bestTarget, ACTION_GATHER );
this.order( ORDER_GENERIC, bestTarget, ACTION_GATHER, false );
return true;
}
return false;
@ -1399,7 +1399,7 @@ function entityEventPrepareOrder( evt )
function entityStartConstruction( evt )
{
this.order( ORDER_GENERIC, evt.target, ACTION_BUILD );
this.order( ORDER_GENERIC, evt.target, ACTION_BUILD, false );
}
// ====================================================================

View File

@ -290,8 +290,6 @@ bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, CEntityOrder::EOrde
JS_ReportError( cx, "Invalid location" );
return( false );
}
if ( orderCode == CEntityOrder::ORDER_RUN )
entf_set(ENTF_TRIGGER_RUN);
//It's not a notification order
if ( argc == 3 )
{
@ -303,7 +301,7 @@ bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, CEntityOrder::EOrde
}
break;
case CEntityOrder::ORDER_GENERIC:
JSU_REQUIRE_PARAMS_CPP(3);
JSU_REQUIRE_PARAMS_CPP(4);
target = ToNative<CEntity>( argv[1] );
if( !target )
{
@ -317,11 +315,20 @@ bool CEntity::Order( JSContext* cx, uintN argc, jsval* argv, CEntityOrder::EOrde
}
catch( PSERROR_Scripting_ConversionFailed )
{
JS_ReportError( cx, "Invalid generic order type" );
JS_ReportError( cx, "Invalid generic order type parameter - expected int" );
return( false );
}
try
{
newOrder.m_run = ToPrimitive<bool>( argv[3] );
}
catch( PSERROR_Scripting_ConversionFailed )
{
JS_ReportError( cx, "Invalid generic order run parameter - expected bool" );
return( false );
}
//It's not a notification order
if ( argc == 3 )
if ( argc == 4 )
{
if ( entf_get(ENTF_DESTROY_NOTIFIERS) )
{
@ -402,8 +409,8 @@ jsval_t CEntity::GetSpawnPoint( JSContext* UNUSED(cx), uintN argc, jsval* argv )
int edge = g_Game->GetSimulation()->RandInt( 4 );
int point;
double max_w = oabb->m_w + spawn_clearance + 1.0;
double max_d = oabb->m_d + spawn_clearance + 1.0;
double max_w = oabb->m_w + spawn_clearance + 2.0;
double max_d = oabb->m_d + spawn_clearance + 2.0;
int w_count = (int)( max_w * 2 );
int d_count = (int)( max_d * 2 );