Exemple #1
0
/**
**	Handle an attack force.
**
**	@param force	Force pointer.
*/
local void AiGuideAttackForce(AiForce* force)
{
    enum { StartState=1, TransporterLoaded, WaitLanded, AttackNow };

    switch( force->State ) {
	    //
	    //	Load units on transporters.
	    //
	case StartState:
	    AiLoadForce(force);
	    break;
	case TransporterLoaded:
	    AiSendTransporter(force);
	    break;
	case WaitLanded:
	    AiWaitLanded(force);
	    break;
	case AttackNow:
	    force->State=0;
	    AiAttackWithForce(force-AiPlayer->Force);
	    break;

	    //
	    //	Attacking!
	    //
	case 0:
	    AiForceAttacks(force);
	    break;
    }
}
Exemple #2
0
/**
**  Attack with force.
**
**  @param l  Lua state.
*/
static int CclAiAttackWithForce(lua_State *l)
{
	LuaCheckArgs(l, 1);
	int force = LuaToNumber(l, 1);
	if (force < 0 || force >= AI_MAX_FORCES) {
		LuaError(l, "Force out of range: %d" _C_ force);
	}
	AiAttackWithForce(AiPlayer->Force.getScriptForce(force));
	lua_pushboolean(l, 0);
	return 1;
}
Exemple #3
0
/**
**	Step 4)
**	Force on attack ride. We attack until there is no unit or enemy left.
**
**	@param force	Force pointer.
*/
local void AiForceAttacks(AiForce* force)
{
    const AiUnit* aiunit;

    if( (aiunit=force->Units) ) {
	while( aiunit ) {
	    // Still some action
	    if( aiunit->Unit->Orders[0].Action!=UnitActionStill ) {
		break;
	    }
	    aiunit=aiunit->Next;
	}
	if( !aiunit ) {
	    AiAttackWithForce(force-AiPlayer->Force);
	}
    } else {
	force->Attacking=0;
    }
}