Author Topic: Reinforcing from the edge of Map  (Read 1093 times)

0 Members and 1 Guest are viewing this topic.

Offline Drewbs

  • 24
Reinforcing from the edge of Map
So, I have gone over several missions that others have released where reinforcements come in off the edge of the map. When I try to copy them, I have met with limited success... as in about 50% of the units stay off the map while the others follow their orders.  :confused:

Is there any advice you all have for having units reliably come in from the gray zone?

 

Offline zzc

  • 26
Re: Reinforcing from the edge of Map
iirc the unit/squad's abl orders need to have it move 1 step into the map, then the next move order. You cannot give a direct move order for a unit that is off map.

  

Offline zzc

  • 26
Re: Reinforcing from the edge of Map
heres a code snippet from a brain that comes in from offmap.

Code: [Select]

startPosition[0] = 3904 + x1;
startPosition[1] = -64;
startPosition[2] = 0;
Move_in_Point[0] = -576 + x1;
Move_in_Point[1] = -5994;
Move_in_Point[2] = 0;
setWillHelp(True);



the full abl

Code: [Select]

//****************************************************************************************//
//
//
// If Contact: If detect enemy contact will leave it patrol path and attack
//
//
//
//****************************************************************************************//

//[EDIT]
fsm e_4_6_patrol_PowerDown; //EACH BRAIN MUST HAVE AN UNIQUE FSM ID..
//[EDIT END]


var

static WorldPosition startPosition;
static boolean willRequestHelp;
static real lastHelpRequestTime;
static real helpRequestFrequency;
static integer AttackStateHandle;
static boolean poweredDown;
static integer scanRange;
static boolean been_hit;
static boolean All_power;
static boolean move_in;
static WorldPosition Move_in_Point;
static PatrolState PState;
static PatrolPath PPath;
//****************************************************************************************

function init;

    code

//[EDIT]
//********************************************************************
// Scan Ranges for Unit
scanRange = 400; //This is the Range in which the AI will Scan for Enemies in meters
x1 = x1 + 50;
PState[0] = 1;    // This is the Type of Patrol. 0 = Linear. 1 = Looping
//(Linear = Unit will move from 1 to 2 to 3, then 3 to 2 to 1) Assuming there are only 3 points to the Patrol
//(Looping = Unit will move from 1 to 2 to 3, then 1 to 2 to 3) Assuming there are only 3 points to the Patrol
PState[1] = 11;    //This is the Amount of Move Points there are listed below. Make sure you Count Patrol Point '0'
PState[2] = 1;    //This is How many Times the unit will perform the Patrol.. (-1 = Forever).

// Patrol Points below

//Enter the Coordinates of where you want the Unit to Patrol. It will do them in Order Start from 0 and ending at the Last Point
//Make sure you change the Index number (numbers in Brackets [0, 0] to match the correct Patrol Point.
//Also, the number of Mover Points MUST match the number you have entered in the Patrol State.

PPath[0, 0] = -576; //X coordinate found in the editor
PPath[0, 1] = -5184; //Y coordinate found in the editor
PPath[1, 0] = -576;
PPath[1, 1] = -4032;
PPath[2, 0] = -960;
PPath[2, 1] = -4032;
PPath[3, 0] = -960;
PPath[3, 1] = -3008;
PPath[4, 0] = -1728;
PPath[4, 1] = -3008;
PPath[5, 0] = -1728;
PPath[5, 1] = 1344;
PPath[6, 0] = -2624;
PPath[6, 1] = 1344;
PPath[7, 0] = -2624;
PPath[7, 1] = 2624;
PPath[8, 0] = -3264;
PPath[8, 1] = 2624;
PPath[9, 0] = -3264;
PPath[9, 1] = 3904;
PPath[10, 0] = -3733;
PPath[10, 1] = 4117;
//********************************************************************
// DO NOT EDIT BELOW THIS LINE
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
setTargetPriority(0, TARGET_PRIORITY_CURTARGET, -1, 150, CONTACT_CRITERIA_ENEMY + CONTACT_CRITERIA_VISUAL_OR_SENSOR + CONTACT_CRITERIA_NOT_DISABLED);
setTargetPriority(1, TARGET_PRIORITY_MOVER, 0, scanRange , CONTACT_CRITERIA_ENEMY + CONTACT_CRITERIA_VISUAL_OR_SENSOR + CONTACT_CRITERIA_NOT_DISABLED);
setTargetPriority(2, TARGET_PRIORITY_NONE, 0, 0, 0);

PState[3] = PATROL_DIRECTION_FORWARD;   
PState[4] = -1;    //reset cur point
PState[5] = -1;    //reset cur cycle
PState[6] = CONTACT_CRITERIA_ENEMY + CONTACT_CRITERIA_VISUAL_OR_SENSOR + CONTACT_CRITERIA_NOT_DISABLED;

// Grab his start position...
getObjectPosition(-1, startPosition);
AttackStateHandle = getStateHandle("attack");
willRequestHelp = true; //?true or false
helpRequestFrequency = 20.0; //?in secs
lastHelpRequestTime = -100.0;

been_hit = True;
poweredDown = False;
All_power = True;
move_in = True;

startPosition[0] = 3904 + x1;
startPosition[1] = -64;
startPosition[2] = 0;
Move_in_Point[0] = -576 + x1;
Move_in_Point[1] = -5994;
Move_in_Point[2] = 0;
setWillHelp(True);

endfunction;

//----------------------------------------------------------------------------------------

function update : integer;

var

boolean processingPilotEvents;
// boolean thinking;
integer pilotEventID;
integer pilotState;
integer[20] pilotEventParams;
integer curTarget;
real curTime;
real[3] myPos;
real[3] attackerPos;
// real distanceToAttacker;
integer curStateHandle;
static integer numFunctionalWeapons;
static integer[20] weaponList;

code
curTime = getTime;
curStateHandle = getCurrentStateHandle;

//--------------------------------------------------
// Process the pilot events since the last update...
numFunctionalWeapons = getWeapons(weaponList, 1);
if (numFunctionalWeapons == 0) then
trans noWeapons;
endif;

processingPilotEvents = TRUE;
while (processingPilotEvents) do
pilotEventID = getNextPilotEvent(pilotEventParams);
if (pilotEventID == PILOT_EVENT_NONE) then
processingPilotEvents = FALSE;
else
switch (pilotEventID)
case PILOT_EVENT_TARGETED:
curTarget = getTarget(-1);
if (lastHelpRequestTime < (curTime - helpRequestFrequency)) then
lastHelpRequestTime = curTime;
if (willRequestHelp) then
//distanceToAttacker = distanceToObject(-1, pilotEventParams[0]);
getObjectPosition(pilotEventParams[0], attackerPos);
getObjectPosition(-1, myPos);
requestHelp(pilotEventParams[0], myPos, 300.0, attackerPos, 300.0, 1);
endif;
endif;
numFunctionalWeapons = getWeapons(weaponList, 0);
if (curStateHandle <> AttackStateHandle) then
if ((numFunctionalWeapons > 0) and (curTarget == 0)) then
coreRun = True;
magicAttack(pilotEventParams[0]); //, TACORDER_PARAM_RANGE_OPTIMAL);
setState(AttackStateHandle);
endif;
endif;
endcase;
case PILOT_EVENT_ATTACK_ORDER:
curTarget = getTarget(-1);
if (curStateHandle <> AttackStateHandle) then
if ((numFunctionalWeapons > 0) and (curTarget == 0))then
coreRun = True;
magicAttack(pilotEventParams[0]); //, TACORDER_PARAM_RANGE_OPTIMAL);
setState(AttackStateHandle);
endif;
endif;
endcase;
case PILOT_EVENT_FIRED_WEAPON:
endcase;
endswitch;
endif;
endwhile;

return(0);

endfunction;

//----------------------------------------------------------------------------------------

state noWeapons;

code

if (objectClass(-1) == 2) then
coreEject;
else
corePower(false);
endif;

endstate;

//----------------------------------------------------------------------------------------

state attack;

code

update;
coreRun = True;
magicAttack(0);
resetOrders(1);
transBack;

endstate;

//----------------------------------------------------------------------------------------

state start;

code
if (not poweredDown) then
corePower(false);
poweredDown = true;
endif;

if ((been_hit) AND (beenhit)) then
corePower(True);
been_hit = False;
Star1_powerup = True;
All_power = False;
endif;

if ((All_power) AND (Star1_powerup)) then
corePower(True);
All_power = False;
been_hit = False;
endif;

if NOT All_power then
update;
if move_in then
coreMoveTo(Move_in_Point, TACORDER_PARAM_RUN);
move_in = False;
else
coreRun = True;
// magicGuard(startposition, -1);
magicPatrol(PState, PPath);
endif;
resetOrders(1);
endif;

endstate;

//----------------------------------------------------------------------------------------

endfsm.

//****************************************************************************************



 

Offline magic

  • Moderator
  • 211
Re: Reinforcing from the edge of Map
Check the coordinates, move in point must be right in front of the unit and very close to the map edge.
If its further away the unit will not enter.