Make VTOL circling less weird.
parent
b37d7f2510
commit
6983eecf7e
|
@ -859,7 +859,7 @@ void actionUpdateDroid(DROID *psDroid)
|
||||||
// if VTOL - return to rearm pad if not patrolling
|
// if VTOL - return to rearm pad if not patrolling
|
||||||
if (isVtolDroid(psDroid))
|
if (isVtolDroid(psDroid))
|
||||||
{
|
{
|
||||||
if (psDroid->order == DORDER_PATROL)
|
if (psDroid->order == DORDER_PATROL || psDroid->order == DORDER_CIRCLE)
|
||||||
{
|
{
|
||||||
// Back to the patrol.
|
// Back to the patrol.
|
||||||
actionDroid(psDroid, DACTION_MOVE, psDroid->orderX,psDroid->orderY);
|
actionDroid(psDroid, DACTION_MOVE, psDroid->orderX,psDroid->orderY);
|
||||||
|
|
|
@ -97,9 +97,6 @@ static void orderCheckList(DROID *psDroid);
|
||||||
// Clear all the orders from the list, up to listSize (without clearing pending (not yet synchronised) orders, that is).
|
// Clear all the orders from the list, up to listSize (without clearing pending (not yet synchronised) orders, that is).
|
||||||
static void orderClearDroidList(DROID *psDroid);
|
static void orderClearDroidList(DROID *psDroid);
|
||||||
|
|
||||||
//Watermelon:add a timestamp to order circle
|
|
||||||
static UDWORD orderStarted;
|
|
||||||
|
|
||||||
// whether an order effect has been displayed
|
// whether an order effect has been displayed
|
||||||
static BOOL bOrderEffectDisplayed = false;
|
static BOOL bOrderEffectDisplayed = false;
|
||||||
// what the droid's action / order is currently
|
// what the droid's action / order is currently
|
||||||
|
@ -558,7 +555,6 @@ void orderUpdateDroid(DROID *psDroid)
|
||||||
{
|
{
|
||||||
if (psDroid->order == DORDER_PATROL)
|
if (psDroid->order == DORDER_PATROL)
|
||||||
{
|
{
|
||||||
UDWORD tempCoord;
|
|
||||||
// see if we have anything queued up
|
// see if we have anything queued up
|
||||||
if (orderDroidList(psDroid))
|
if (orderDroidList(psDroid))
|
||||||
{
|
{
|
||||||
|
@ -571,12 +567,8 @@ void orderUpdateDroid(DROID *psDroid)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// head back to the other point
|
// head back to the other point
|
||||||
tempCoord = psDroid->orderX;
|
std::swap(psDroid->orderX, psDroid->orderX2);
|
||||||
psDroid->orderX = psDroid->orderX2;
|
std::swap(psDroid->orderY, psDroid->orderY2);
|
||||||
psDroid->orderX2 = tempCoord;
|
|
||||||
tempCoord = psDroid->orderY;
|
|
||||||
psDroid->orderY = psDroid->orderY2;
|
|
||||||
psDroid->orderY2 = tempCoord;
|
|
||||||
actionDroid(psDroid, DACTION_MOVE, psDroid->orderX,psDroid->orderY);
|
actionDroid(psDroid, DACTION_MOVE, psDroid->orderX,psDroid->orderY);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -606,7 +598,7 @@ void orderUpdateDroid(DROID *psDroid)
|
||||||
// if there is an enemy around, attack it
|
// if there is an enemy around, attack it
|
||||||
if (psDroid->action == DACTION_MOVE &&
|
if (psDroid->action == DACTION_MOVE &&
|
||||||
secondaryGetState(psDroid, DSO_ATTACK_LEVEL) == DSS_ALEV_ALWAYS &&
|
secondaryGetState(psDroid, DSO_ATTACK_LEVEL) == DSS_ALEV_ALWAYS &&
|
||||||
aiBestNearestTarget(psDroid, &psObj, 0) >= 0)
|
aiBestNearestTarget(psDroid, &psObj, 0, SCOUT_ATTACK_DIST) >= 0)
|
||||||
{
|
{
|
||||||
switch (psDroid->droidType)
|
switch (psDroid->droidType)
|
||||||
{
|
{
|
||||||
|
@ -629,45 +621,27 @@ void orderUpdateDroid(DROID *psDroid)
|
||||||
{
|
{
|
||||||
if (psDroid->action == DACTION_MOVE)
|
if (psDroid->action == DACTION_MOVE)
|
||||||
{
|
{
|
||||||
if ( orderStarted && ((orderStarted + 500) > gameTime) )
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// see if we have anything queued up
|
// see if we have anything queued up
|
||||||
if (orderDroidList(psDroid))
|
if (orderDroidList(psDroid))
|
||||||
{
|
{
|
||||||
// started a new order, quit
|
// started a new order, quit
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
orderStarted = gameTime;
|
|
||||||
}
|
}
|
||||||
psDroid->action = DACTION_NONE;
|
|
||||||
|
|
||||||
xdiff = (SDWORD)psDroid->pos.x - (SDWORD)psDroid->orderX;
|
Vector2i edgeDiff = removeZ(psDroid->pos) - Vector2i(psDroid->actionX, psDroid->actionY);
|
||||||
ydiff = (SDWORD)psDroid->pos.y - (SDWORD)psDroid->orderY;
|
if (psDroid->action != DACTION_MOVE || edgeDiff*edgeDiff <= TILE_UNITS*4 * TILE_UNITS*4)
|
||||||
if (xdiff*xdiff + ydiff*ydiff <= 2000 * 2000)
|
|
||||||
{
|
{
|
||||||
if (psDroid->order == DORDER_CIRCLE)
|
//Watermelon:use orderX,orderY as local space origin and calculate droid direction in local space
|
||||||
|
Vector2i diff = removeZ(psDroid->pos) - Vector2i(psDroid->orderX, psDroid->orderY);
|
||||||
|
uint16_t angle = iAtan2(diff) - DEG(30);
|
||||||
|
do
|
||||||
{
|
{
|
||||||
//Watermelon:use orderX,orderY as local space origin and calculate droid direction in local space
|
|
||||||
uint16_t angle = iAtan2(xdiff, ydiff);
|
|
||||||
xoffset = iSinR(angle, 1500);
|
xoffset = iSinR(angle, 1500);
|
||||||
yoffset = iCosR(angle, 1500);
|
yoffset = iCosR(angle, 1500);
|
||||||
xdiff = psDroid->pos.x - (psDroid->orderX + xoffset);
|
angle -= DEG(10);
|
||||||
ydiff = psDroid->pos.y - (psDroid->orderY + yoffset);
|
} while (!worldOnMap(psDroid->orderX + xoffset, psDroid->orderY + yoffset)); // Don't try to fly off map.
|
||||||
if (xdiff*xdiff + ydiff*ydiff < TILE_UNITS * TILE_UNITS)
|
actionDroid(psDroid, DACTION_MOVE, psDroid->orderX + xoffset, psDroid->orderY + yoffset);
|
||||||
{
|
|
||||||
//Watermelon:conter-clockwise 30 degree's per action
|
|
||||||
angle -= DEG(30);
|
|
||||||
xoffset = iSinR(angle, 1500);
|
|
||||||
yoffset = iCosR(angle, 1500);
|
|
||||||
}
|
|
||||||
actionDroid(psDroid, DACTION_MOVE, psDroid->orderX + xoffset, psDroid->orderY + yoffset);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
psDroid->order = DORDER_NONE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((psDroid->action == DACTION_ATTACK) ||
|
else if ((psDroid->action == DACTION_ATTACK) ||
|
||||||
|
|
Loading…
Reference in New Issue