Lander cleanup: former MENU_STATE fields sorted out; some pointless casts removed; some comments; other random changes
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3321 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+162
-143
@@ -123,9 +123,15 @@ const LIFEFORM_DESC CreatureData[] =
|
|||||||
extern PRIM_LINKS DisplayLinks;
|
extern PRIM_LINKS DisplayLinks;
|
||||||
|
|
||||||
#define DAMAGE_CYCLE 6
|
#define DAMAGE_CYCLE 6
|
||||||
|
// XXX: There are actually only 9 explosion images.
|
||||||
|
// The last frame is drawn twice.
|
||||||
#define EXPLOSION_LIFE 10
|
#define EXPLOSION_LIFE 10
|
||||||
|
// How long to wait after the lander explodes, so that the full
|
||||||
#define SHIELD_BIT (1 << 7)
|
// gravity of the player's situation sinks in
|
||||||
|
#define EXPLOSION_WAIT (ONE_SECOND * 2)
|
||||||
|
#define EXPLOSION_WAIT_FRAMES (EXPLOSION_WAIT / PLANET_SIDE_RATE)
|
||||||
|
// The actual number of frame that the explosion and wait takes is:
|
||||||
|
// EXPLOSION_LIFE * 3 + EXPLOSION_WAIT_FRAMES
|
||||||
|
|
||||||
#define DEATH_EXPLOSION 0
|
#define DEATH_EXPLOSION 0
|
||||||
|
|
||||||
@@ -144,6 +150,18 @@ extern PRIM_LINKS DisplayLinks;
|
|||||||
|
|
||||||
static BYTE lander_flags;
|
static BYTE lander_flags;
|
||||||
static POINT curLanderLoc;
|
static POINT curLanderLoc;
|
||||||
|
static int crew_left;
|
||||||
|
static int shieldHit;
|
||||||
|
// which shield was hit, assuming it helped
|
||||||
|
static int damage_index;
|
||||||
|
// number of lander damage frames left
|
||||||
|
static int explosion_index;
|
||||||
|
// lander explosion progression. Semantics are similar to an
|
||||||
|
// inverse of ELEMENT.life_span
|
||||||
|
static int turn_wait;
|
||||||
|
// thus named for similar semantics to ELEMENT.turn_wait
|
||||||
|
static int weapon_wait;
|
||||||
|
// semantics similar to STARSHIP.weapon_counter
|
||||||
|
|
||||||
#define NUM_LANDING_DELTAS 11
|
#define NUM_LANDING_DELTAS 11
|
||||||
#define ON_THE_GROUND -1
|
#define ON_THE_GROUND -1
|
||||||
@@ -275,16 +293,19 @@ object_animation (ELEMENT *ElementPtr)
|
|||||||
{
|
{
|
||||||
ElementPtr->turn_wait += HINIBBLE (ElementPtr->turn_wait);
|
ElementPtr->turn_wait += HINIBBLE (ElementPtr->turn_wait);
|
||||||
|
|
||||||
pPrim->Object.Stamp.frame =
|
pPrim->Object.Stamp.frame = IncFrameIndex (pPrim->Object.Stamp.frame);
|
||||||
IncFrameIndex (pPrim->Object.Stamp.frame);
|
|
||||||
if (ElementPtr->state_flags & FINITE_LIFE)
|
if (ElementPtr->state_flags & FINITE_LIFE)
|
||||||
{
|
{
|
||||||
/* A natural disaster */
|
/* A natural disaster */
|
||||||
if (ElementPtr->mass_points == DEATH_EXPLOSION)
|
if (ElementPtr->mass_points == DEATH_EXPLOSION)
|
||||||
{
|
{ // Lander explosion
|
||||||
if (++pLanderInputState->CurState >= EXPLOSION_LIFE)
|
++explosion_index;
|
||||||
|
if (explosion_index >= EXPLOSION_LIFE)
|
||||||
|
{ // XXX: The last frame is drawn twice
|
||||||
pPrim->Object.Stamp.frame =
|
pPrim->Object.Stamp.frame =
|
||||||
DecFrameIndex (pPrim->Object.Stamp.frame);
|
DecFrameIndex (pPrim->Object.Stamp.frame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (ElementPtr->mass_points == EARTHQUAKE_DISASTER)
|
else if (ElementPtr->mass_points == EARTHQUAKE_DISASTER)
|
||||||
{
|
{
|
||||||
@@ -303,7 +324,7 @@ object_animation (ELEMENT *ElementPtr)
|
|||||||
|
|
||||||
if (ElementPtr->mass_points == LAVASPOT_DISASTER
|
if (ElementPtr->mass_points == LAVASPOT_DISASTER
|
||||||
&& frame_index == 5
|
&& frame_index == 5
|
||||||
&& (BYTE)TFB_Random () < 256 * 90 / 100)
|
&& TFB_Random () % 100 < 90)
|
||||||
{
|
{
|
||||||
HELEMENT hLavaElement;
|
HELEMENT hLavaElement;
|
||||||
|
|
||||||
@@ -327,7 +348,7 @@ object_animation (ELEMENT *ElementPtr)
|
|||||||
else
|
else
|
||||||
LavaElementPtr->next.location.x %= MAP_WIDTH << MAG_SHIFT;
|
LavaElementPtr->next.location.x %= MAP_WIDTH << MAG_SHIFT;
|
||||||
LavaElementPtr->facing = NORMALIZE_FACING (
|
LavaElementPtr->facing = NORMALIZE_FACING (
|
||||||
ElementPtr->facing + ((COUNT)TFB_Random () % 3) - 1);
|
ElementPtr->facing + (TFB_Random () % 3 - 1));
|
||||||
UnlockElement (hLavaElement);
|
UnlockElement (hLavaElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -376,7 +397,7 @@ object_animation (ELEMENT *ElementPtr)
|
|||||||
// as repeating 'random(x / 30)' 30 times doesn't
|
// as repeating 'random(x / 30)' 30 times doesn't
|
||||||
// generally have the same result as repeating
|
// generally have the same result as repeating
|
||||||
// 'random(x / 35)' 25 times. - SvdB
|
// 'random(x / 35)' 25 times. - SvdB
|
||||||
if (((BYTE)TFB_Random () % 100) < DetectPercent)
|
if (TFB_Random () % 100 < DetectPercent)
|
||||||
{
|
{
|
||||||
ElementPtr->thrust_wait = 0;
|
ElementPtr->thrust_wait = 0;
|
||||||
ElementPtr->mass_points |= CREATURE_AWARE;
|
ElementPtr->mass_points |= CREATURE_AWARE;
|
||||||
@@ -400,7 +421,7 @@ object_animation (ELEMENT *ElementPtr)
|
|||||||
{
|
{
|
||||||
COUNT rand_val;
|
COUNT rand_val;
|
||||||
|
|
||||||
rand_val = (COUNT)TFB_Random ();
|
rand_val = TFB_Random ();
|
||||||
angle = NORMALIZE_ANGLE (LOBYTE (rand_val));
|
angle = NORMALIZE_ANGLE (LOBYTE (rand_val));
|
||||||
ElementPtr->thrust_wait =
|
ElementPtr->thrust_wait =
|
||||||
(HIBYTE (rand_val) >> 2) + 10;
|
(HIBYTE (rand_val) >> 2) + 10;
|
||||||
@@ -418,7 +439,7 @@ object_animation (ELEMENT *ElementPtr)
|
|||||||
|| old_angle == (FULL_CIRCLE - QUADRANT))
|
|| old_angle == (FULL_CIRCLE - QUADRANT))
|
||||||
angle = old_angle;
|
angle = old_angle;
|
||||||
else
|
else
|
||||||
angle = (((COUNT)TFB_Random () & 1)
|
angle = ((TFB_Random () & 1)
|
||||||
* HALF_CIRCLE) - QUADRANT;
|
* HALF_CIRCLE) - QUADRANT;
|
||||||
ElementPtr->thrust_wait = 5;
|
ElementPtr->thrust_wait = 5;
|
||||||
}
|
}
|
||||||
@@ -462,38 +483,29 @@ DeltaLanderCrew (SIZE crew_delta, COUNT which_disaster)
|
|||||||
if (crew_delta > 0)
|
if (crew_delta > 0)
|
||||||
{
|
{
|
||||||
// Filling up the crew bar when landing.
|
// Filling up the crew bar when landing.
|
||||||
crew_delta = HIBYTE (pLanderInputState->delta_item);
|
crew_delta = crew_left;
|
||||||
pLanderInputState->delta_item += MAKE_WORD (0, 1);
|
crew_left += 1;
|
||||||
|
|
||||||
s.frame = SetAbsFrameIndex (LanderFrame[0], 55);
|
s.frame = SetAbsFrameIndex (LanderFrame[0], 55);
|
||||||
}
|
}
|
||||||
else /* if (crew_delta < 0) */
|
else /* if (crew_delta < 0) */
|
||||||
{
|
{
|
||||||
BYTE ShieldFlags;
|
if (crew_left < 1)
|
||||||
|
return; // irrelevant -- all dead
|
||||||
ShieldFlags = GET_GAME_STATE (LANDER_SHIELDS);
|
|
||||||
ShieldFlags &= 1 << which_disaster;
|
shieldHit = GET_GAME_STATE (LANDER_SHIELDS);
|
||||||
crew_delta = HIBYTE (pLanderInputState->delta_item);
|
shieldHit &= 1 << which_disaster;
|
||||||
if (crew_delta < 1)
|
if (!shieldHit || TFB_Random () % 100 >= 95)
|
||||||
return;
|
{ // No shield, or it did not help
|
||||||
if (ShieldFlags && (BYTE)TFB_Random () < 256 * 95 / 100)
|
shieldHit = 0;
|
||||||
{
|
--crew_left;
|
||||||
// Protected by a lander shield.
|
|
||||||
pLanderInputState->delta_item = SHIELD_BIT;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Deal damage.
|
|
||||||
ShieldFlags = 0;
|
|
||||||
if (--crew_delta == 0)
|
|
||||||
pLanderInputState->CurState = 0;
|
|
||||||
pLanderInputState->delta_item = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pLanderInputState->delta_item |= MAKE_WORD (DAMAGE_CYCLE, crew_delta);
|
damage_index = DAMAGE_CYCLE;
|
||||||
if (ShieldFlags)
|
if (shieldHit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
crew_delta = crew_left;
|
||||||
s.frame = SetAbsFrameIndex (LanderFrame[0], 56);
|
s.frame = SetAbsFrameIndex (LanderFrame[0], 56);
|
||||||
|
|
||||||
PlaySound (SetAbsSoundIndex (LanderSounds, LANDER_INJURED),
|
PlaySound (SetAbsSoundIndex (LanderSounds, LANDER_INJURED),
|
||||||
@@ -634,8 +646,7 @@ CheckObjectCollision (COUNT index)
|
|||||||
if (pLanderPrim == 0)
|
if (pLanderPrim == 0)
|
||||||
{
|
{
|
||||||
/* Collision of lander with another object */
|
/* Collision of lander with another object */
|
||||||
if (HIBYTE (pLanderInputState->delta_item) == 0
|
if (crew_left == 0 || pPSD->InTransit)
|
||||||
|| pPSD->InTransit)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (ElementPtr->state_flags & FINITE_LIFE)
|
if (ElementPtr->state_flags & FINITE_LIFE)
|
||||||
@@ -646,7 +657,7 @@ CheckObjectCollision (COUNT index)
|
|||||||
{
|
{
|
||||||
case EARTHQUAKE_DISASTER:
|
case EARTHQUAKE_DISASTER:
|
||||||
case LAVASPOT_DISASTER:
|
case LAVASPOT_DISASTER:
|
||||||
if ((BYTE)TFB_Random () < (256 >> 2))
|
if (TFB_Random () % 100 < 25)
|
||||||
DeltaLanderCrew (-1, scan);
|
DeltaLanderCrew (-1, scan);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -658,21 +669,21 @@ CheckObjectCollision (COUNT index)
|
|||||||
{
|
{
|
||||||
if (ElementPtr->mass_points == 1)
|
if (ElementPtr->mass_points == 1)
|
||||||
{
|
{
|
||||||
|
#define FWIFFO_FRAGS 8
|
||||||
DWORD TimeIn;
|
DWORD TimeIn;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* Ran into Spathi on Pluto */
|
/* Ran into Spathi on Pluto */
|
||||||
TimeIn = GetTimeCounter ();
|
TimeIn = GetTimeCounter ();
|
||||||
which_node = 8;
|
for (i = 0; i < FWIFFO_FRAGS && crew_left; ++i)
|
||||||
do
|
|
||||||
{
|
{
|
||||||
DeltaLanderCrew (-1, LANDER_INJURED);
|
DeltaLanderCrew (-1, LANDER_INJURED);
|
||||||
SleepThreadUntil (TimeIn + ONE_SECOND / 20);
|
SleepThreadUntil (TimeIn + ONE_SECOND / 20);
|
||||||
TimeIn = GetTimeCounter();
|
TimeIn = GetTimeCounter();
|
||||||
} while (HIBYTE (pLanderInputState->delta_item) &&
|
}
|
||||||
--which_node);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HIBYTE (pLanderInputState->delta_item)
|
if (crew_left
|
||||||
&& pSolarSysState->SysInfo.PlanetInfo.DiscoveryString
|
&& pSolarSysState->SysInfo.PlanetInfo.DiscoveryString
|
||||||
&& CurStarDescPtr->Index != ANDROSYNTH_DEFINED)
|
&& CurStarDescPtr->Index != ANDROSYNTH_DEFINED)
|
||||||
{
|
{
|
||||||
@@ -703,8 +714,7 @@ CheckObjectCollision (COUNT index)
|
|||||||
(CreatureData[creatureIndex].Attributes &
|
(CreatureData[creatureIndex].Attributes &
|
||||||
DANGER_MASK) >> DANGER_SHIFT;
|
DANGER_MASK) >> DANGER_SHIFT;
|
||||||
|
|
||||||
if (((COUNT)TFB_Random () & 127) <
|
if (TFB_Random () % 128 < danger_vals[dangerLevel])
|
||||||
danger_vals[dangerLevel])
|
|
||||||
{
|
{
|
||||||
PlaySound (SetAbsSoundIndex (
|
PlaySound (SetAbsSoundIndex (
|
||||||
LanderSounds, BIOLOGICAL_DISASTER),
|
LanderSounds, BIOLOGICAL_DISASTER),
|
||||||
@@ -940,8 +950,7 @@ lightning_process (ELEMENT *ElementPtr)
|
|||||||
{
|
{
|
||||||
/* This one always strikes the lander and can hurt */
|
/* This one always strikes the lander and can hurt */
|
||||||
PLANETSIDE_DESC *pPSD = pLanderInputState->planetSideDesc;
|
PLANETSIDE_DESC *pPSD = pLanderInputState->planetSideDesc;
|
||||||
if (HIBYTE (pLanderInputState->delta_item)
|
if (crew_left && TFB_Random () % 100 < 10
|
||||||
&& (BYTE)TFB_Random () < (256 / 10)
|
|
||||||
&& !pPSD->InTransit)
|
&& !pPSD->InTransit)
|
||||||
lander_flags |= KILL_CREW;
|
lander_flags |= KILL_CREW;
|
||||||
|
|
||||||
@@ -950,7 +959,7 @@ lightning_process (ELEMENT *ElementPtr)
|
|||||||
|
|
||||||
pPrim->Object.Stamp.frame =
|
pPrim->Object.Stamp.frame =
|
||||||
SetAbsFrameIndex (pPrim->Object.Stamp.frame,
|
SetAbsFrameIndex (pPrim->Object.Stamp.frame,
|
||||||
(COUNT)TFB_Random () % num_frames);
|
TFB_Random () % num_frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementPtr->turn_wait += HINIBBLE (ElementPtr->turn_wait);
|
ElementPtr->turn_wait += HINIBBLE (ElementPtr->turn_wait);
|
||||||
@@ -976,7 +985,7 @@ AddLightning (void)
|
|||||||
LightningElementPtr->playerNr = PS_NON_PLAYER;
|
LightningElementPtr->playerNr = PS_NON_PLAYER;
|
||||||
LightningElementPtr->state_flags = FINITE_LIFE;
|
LightningElementPtr->state_flags = FINITE_LIFE;
|
||||||
LightningElementPtr->preprocess_func = lightning_process;
|
LightningElementPtr->preprocess_func = lightning_process;
|
||||||
if ((BYTE)TFB_Random () >= (256 >> 2))
|
if (TFB_Random () % 100 >= 25)
|
||||||
LightningElementPtr->mass_points = 0; /* harmless */
|
LightningElementPtr->mass_points = 0; /* harmless */
|
||||||
else
|
else
|
||||||
LightningElementPtr->mass_points = LIGHTNING_DISASTER;
|
LightningElementPtr->mass_points = LIGHTNING_DISASTER;
|
||||||
@@ -1280,10 +1289,10 @@ ScrollPlanetSide (SIZE dx, SIZE dy, int landingIndex)
|
|||||||
|
|
||||||
DrawBatch (DisplayArray, DisplayLinks, 0);
|
DrawBatch (DisplayArray, DisplayLinks, 0);
|
||||||
|
|
||||||
if (pLanderInputState->delta_item || pLanderInputState->CurState < 3)
|
// Draw the lander while is still alive and keep drawing for a few
|
||||||
|
// frames while it is exploding
|
||||||
|
if (crew_left || damage_index || explosion_index < 3)
|
||||||
{
|
{
|
||||||
BYTE damage_index;
|
|
||||||
|
|
||||||
lander_s.origin.x = SURFACE_WIDTH >> 1;
|
lander_s.origin.x = SURFACE_WIDTH >> 1;
|
||||||
lander_s.frame = LanderFrame[0];
|
lander_s.frame = LanderFrame[0];
|
||||||
if (landingIndex == ON_THE_GROUND)
|
if (landingIndex == ON_THE_GROUND)
|
||||||
@@ -1300,40 +1309,37 @@ ScrollPlanetSide (SIZE dx, SIZE dy, int landingIndex)
|
|||||||
DrawFilledStamp (&shadow_s);
|
DrawFilledStamp (&shadow_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
damage_index = LOBYTE (pLanderInputState->delta_item);
|
|
||||||
if (damage_index == 0)
|
if (damage_index == 0)
|
||||||
|
{ // No damage -- normal lander
|
||||||
DrawStamp (&lander_s);
|
DrawStamp (&lander_s);
|
||||||
else
|
}
|
||||||
{
|
else if (shieldHit)
|
||||||
--pLanderInputState->delta_item;
|
{ // Was protected by a shield
|
||||||
if (!(damage_index & SHIELD_BIT))
|
--damage_index;
|
||||||
|
if (damage_index > 0)
|
||||||
{
|
{
|
||||||
SetContextForeGroundColor (DamageColorCycle (0, damage_index));
|
shield_s.origin = lander_s.origin;
|
||||||
DrawFilledStamp (&lander_s);
|
shield_s.frame = SetEquFrameIndex (
|
||||||
}
|
LanderFrame[4], lander_s.frame);
|
||||||
else
|
|
||||||
{
|
|
||||||
damage_index = (BYTE)((damage_index & ~SHIELD_BIT) - 1);
|
|
||||||
if (damage_index == 0)
|
|
||||||
pLanderInputState->delta_item &= ~SHIELD_BIT;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
shield_s.origin = lander_s.origin;
|
|
||||||
shield_s.frame = SetEquFrameIndex (
|
|
||||||
LanderFrame[4], lander_s.frame);
|
|
||||||
|
|
||||||
SetContextForeGroundColor (BUILD_COLOR (
|
// XXX: Shouldn't this color-cycle with damage_index?
|
||||||
MAKE_RGB15 (0x1F, 0x1F, 0x1F) | 0x8000,
|
// damage_index is used, but only as a VGA index!
|
||||||
damage_index));
|
SetContextForeGroundColor (BUILD_COLOR (
|
||||||
DrawFilledStamp (&shield_s);
|
MAKE_RGB15 (0x1F, 0x1F, 0x1F) | 0x8000,
|
||||||
}
|
damage_index));
|
||||||
DrawStamp (&lander_s);
|
DrawFilledStamp (&shield_s);
|
||||||
}
|
}
|
||||||
|
DrawStamp (&lander_s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Direct hit, no shield
|
||||||
|
--damage_index;
|
||||||
|
SetContextForeGroundColor (DamageColorCycle (0, damage_index));
|
||||||
|
DrawFilledStamp (&lander_s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (landingIndex == ON_THE_GROUND
|
if (landingIndex == ON_THE_GROUND && crew_left
|
||||||
&& HIBYTE (pLanderInputState->delta_item)
|
|
||||||
&& GetPredLink (DisplayLinks) != END_OF_LIST)
|
&& GetPredLink (DisplayLinks) != END_OF_LIST)
|
||||||
CheckObjectCollision (END_OF_LIST);
|
CheckObjectCollision (END_OF_LIST);
|
||||||
|
|
||||||
@@ -1507,14 +1513,14 @@ InitPlanetSide (POINT pt)
|
|||||||
// Adjust landing location by a random jitter.
|
// Adjust landing location by a random jitter.
|
||||||
#define RANDOM_MISS 64
|
#define RANDOM_MISS 64
|
||||||
// Jitter the X landing point.
|
// Jitter the X landing point.
|
||||||
pt.x -= RANDOM_MISS - (SIZE)(LOWORD (TFB_Random ()) % (RANDOM_MISS << 1));
|
pt.x -= RANDOM_MISS - TFB_Random () % (RANDOM_MISS << 1);
|
||||||
if (pt.x < 0)
|
if (pt.x < 0)
|
||||||
pt.x += (MAP_WIDTH << MAG_SHIFT);
|
pt.x += (MAP_WIDTH << MAG_SHIFT);
|
||||||
else if (pt.x >= (MAP_WIDTH << MAG_SHIFT))
|
else if (pt.x >= (MAP_WIDTH << MAG_SHIFT))
|
||||||
pt.x -= (MAP_WIDTH << MAG_SHIFT);
|
pt.x -= (MAP_WIDTH << MAG_SHIFT);
|
||||||
|
|
||||||
// Jitter the Y landing point.
|
// Jitter the Y landing point.
|
||||||
pt.y -= RANDOM_MISS - (SIZE)(LOWORD (TFB_Random ()) % (RANDOM_MISS << 1));
|
pt.y -= RANDOM_MISS - TFB_Random () % (RANDOM_MISS << 1);
|
||||||
if (pt.y < 0)
|
if (pt.y < 0)
|
||||||
pt.y = 0;
|
pt.y = 0;
|
||||||
else if (pt.y >= (MAP_HEIGHT << MAG_SHIFT))
|
else if (pt.y >= (MAP_HEIGHT << MAG_SHIFT))
|
||||||
@@ -1569,12 +1575,13 @@ InitPlanetSide (POINT pt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
LanderFire (LanderInputState *inputState, SIZE index)
|
LanderFire (SIZE facing)
|
||||||
{
|
{
|
||||||
#define SHUTTLE_FIRE_WAIT 15
|
#define SHUTTLE_FIRE_WAIT 15
|
||||||
HELEMENT hWeaponElement;
|
HELEMENT hWeaponElement;
|
||||||
SIZE wdx, wdy;
|
SIZE wdx, wdy;
|
||||||
ELEMENT *WeaponElementPtr;
|
ELEMENT *WeaponElementPtr;
|
||||||
|
COUNT angle;
|
||||||
|
|
||||||
hWeaponElement = AllocElement ();
|
hWeaponElement = AllocElement ();
|
||||||
if (hWeaponElement == NULL)
|
if (hWeaponElement == NULL)
|
||||||
@@ -1594,9 +1601,9 @@ LanderFire (LanderInputState *inputState, SIZE index)
|
|||||||
|
|
||||||
SetPrimType (&DisplayArray[WeaponElementPtr->PrimIndex], STAMP_PRIM);
|
SetPrimType (&DisplayArray[WeaponElementPtr->PrimIndex], STAMP_PRIM);
|
||||||
DisplayArray[WeaponElementPtr->PrimIndex].Object.Stamp.frame =
|
DisplayArray[WeaponElementPtr->PrimIndex].Object.Stamp.frame =
|
||||||
SetAbsFrameIndex (
|
SetAbsFrameIndex (LanderFrame[0],
|
||||||
LanderFrame[0],
|
/* shot images immediately follow the lander images */
|
||||||
index + ANGLE_TO_FACING (FULL_CIRCLE));
|
facing + ANGLE_TO_FACING (FULL_CIRCLE));
|
||||||
|
|
||||||
if (!CurrentInputState.key[PlayerControls[0]][KEY_UP])
|
if (!CurrentInputState.key[PlayerControls[0]][KEY_UP])
|
||||||
{
|
{
|
||||||
@@ -1608,11 +1615,11 @@ LanderFire (LanderInputState *inputState, SIZE index)
|
|||||||
GetCurrentVelocityComponents (&GLOBAL (velocity), &wdx, &wdy);
|
GetCurrentVelocityComponents (&GLOBAL (velocity), &wdx, &wdy);
|
||||||
}
|
}
|
||||||
|
|
||||||
index = FACING_TO_ANGLE (index);
|
angle = FACING_TO_ANGLE (facing);
|
||||||
SetVelocityComponents (
|
SetVelocityComponents (
|
||||||
&WeaponElementPtr->velocity,
|
&WeaponElementPtr->velocity,
|
||||||
COSINE (index, WORLD_TO_VELOCITY (2 * 3)) + wdx,
|
COSINE (angle, WORLD_TO_VELOCITY (2 * 3)) + wdx,
|
||||||
SINE (index, WORLD_TO_VELOCITY (2 * 3)) + wdy);
|
SINE (angle, WORLD_TO_VELOCITY (2 * 3)) + wdy);
|
||||||
|
|
||||||
UnlockElement (hWeaponElement);
|
UnlockElement (hWeaponElement);
|
||||||
|
|
||||||
@@ -1620,11 +1627,43 @@ LanderFire (LanderInputState *inputState, SIZE index)
|
|||||||
|
|
||||||
PlaySound (SetAbsSoundIndex (LanderSounds, LANDER_SHOOTS),
|
PlaySound (SetAbsSoundIndex (LanderSounds, LANDER_SHOOTS),
|
||||||
NotPositional (), NULL, GAME_SOUND_PRIORITY);
|
NotPositional (), NULL, GAME_SOUND_PRIORITY);
|
||||||
|
}
|
||||||
|
|
||||||
wdx = SHUTTLE_FIRE_WAIT;
|
static BOOLEAN
|
||||||
if (GET_GAME_STATE (IMPROVED_LANDER_SHOT))
|
LanderExplosion (void)
|
||||||
wdx >>= 1;
|
{
|
||||||
inputState->CurState = MAKE_BYTE (LONIBBLE (inputState->CurState), wdx);
|
HELEMENT hExplosionElement;
|
||||||
|
ELEMENT *ExplosionElementPtr;
|
||||||
|
|
||||||
|
hExplosionElement = AllocElement ();
|
||||||
|
if (!hExplosionElement)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
LockElement (hExplosionElement, &ExplosionElementPtr);
|
||||||
|
|
||||||
|
ExplosionElementPtr->playerNr = PS_HUMAN_PLAYER;
|
||||||
|
ExplosionElementPtr->mass_points = DEATH_EXPLOSION;
|
||||||
|
ExplosionElementPtr->state_flags = FINITE_LIFE;
|
||||||
|
ExplosionElementPtr->next.location = curLanderLoc;
|
||||||
|
ExplosionElementPtr->preprocess_func = object_animation;
|
||||||
|
// Animation advances every 3rd frame
|
||||||
|
ExplosionElementPtr->turn_wait = MAKE_BYTE (2, 2);
|
||||||
|
ExplosionElementPtr->life_span = EXPLOSION_LIFE
|
||||||
|
* (LONIBBLE (ExplosionElementPtr->turn_wait) + 1);
|
||||||
|
|
||||||
|
SetPrimType (&DisplayArray[ExplosionElementPtr->PrimIndex],
|
||||||
|
STAMP_PRIM);
|
||||||
|
DisplayArray[ExplosionElementPtr->PrimIndex].Object.Stamp.frame =
|
||||||
|
SetAbsFrameIndex (LanderFrame[0], 46);
|
||||||
|
|
||||||
|
UnlockElement (hExplosionElement);
|
||||||
|
|
||||||
|
InsertElement (hExplosionElement, GetHeadElement ());
|
||||||
|
|
||||||
|
PlaySound (SetAbsSoundIndex (LanderSounds, LANDER_DESTROYED),
|
||||||
|
NotPositional (), NULL, GAME_SOUND_PRIORITY + 1);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOLEAN
|
static BOOLEAN
|
||||||
@@ -1644,7 +1683,9 @@ DoPlanetSide (LanderInputState *pMS)
|
|||||||
COUNT angle;
|
COUNT angle;
|
||||||
|
|
||||||
pMS->Initialized = TRUE;
|
pMS->Initialized = TRUE;
|
||||||
pMS->CurState = 0;
|
|
||||||
|
turn_wait = 0;
|
||||||
|
weapon_wait = 0;
|
||||||
|
|
||||||
angle = FACING_TO_ANGLE (GetFrameIndex (LanderFrame[0]));
|
angle = FACING_TO_ANGLE (GetFrameIndex (LanderFrame[0]));
|
||||||
landerSpeedNumer = GET_GAME_STATE (IMPROVED_LANDER_SPEED) ?
|
landerSpeedNumer = GET_GAME_STATE (IMPROVED_LANDER_SPEED) ?
|
||||||
@@ -1661,52 +1702,28 @@ landerSpeedNumer = WORLD_TO_VELOCITY (48);
|
|||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if (pMS->delta_item == 0
|
else if (crew_left /* alive and taking off */
|
||||||
|| (HIBYTE (pMS->delta_item)
|
|
||||||
&& ((CurrentInputState.key[PlayerControls[0]][KEY_ESCAPE] ||
|
&& ((CurrentInputState.key[PlayerControls[0]][KEY_ESCAPE] ||
|
||||||
CurrentInputState.key[PlayerControls[0]][KEY_SPECIAL])
|
CurrentInputState.key[PlayerControls[0]][KEY_SPECIAL])
|
||||||
|| pLanderInputState->planetSideDesc->InTransit)))
|
|| pLanderInputState->planetSideDesc->InTransit))
|
||||||
{
|
{
|
||||||
if (pMS->delta_item || pMS->CurState > EXPLOSION_LIFE + 60)
|
return FALSE;
|
||||||
|
}
|
||||||
|
else if (!crew_left && !damage_index)
|
||||||
|
{ // Dead, damage dealt, and exploding
|
||||||
|
if (explosion_index > EXPLOSION_LIFE + EXPLOSION_WAIT_FRAMES)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (pMS->CurState > EXPLOSION_LIFE)
|
if (explosion_index > EXPLOSION_LIFE)
|
||||||
++pMS->CurState;
|
{ // Keep going until the wait expires
|
||||||
else if (pMS->CurState == 0)
|
++explosion_index;
|
||||||
{
|
}
|
||||||
HELEMENT hExplosionElement;
|
else if (explosion_index == 0)
|
||||||
|
{ // Start the explosion animation
|
||||||
hExplosionElement = AllocElement ();
|
if (LanderExplosion ())
|
||||||
if (hExplosionElement)
|
|
||||||
{
|
{
|
||||||
ELEMENT *ExplosionElementPtr;
|
|
||||||
|
|
||||||
// Advance the state only once we've got the element
|
// Advance the state only once we've got the element
|
||||||
++pMS->CurState;
|
++explosion_index;
|
||||||
|
|
||||||
LockElement (hExplosionElement, &ExplosionElementPtr);
|
|
||||||
|
|
||||||
ExplosionElementPtr->playerNr = PS_HUMAN_PLAYER;
|
|
||||||
ExplosionElementPtr->mass_points = DEATH_EXPLOSION;
|
|
||||||
ExplosionElementPtr->state_flags = FINITE_LIFE;
|
|
||||||
ExplosionElementPtr->next.location = curLanderLoc;
|
|
||||||
ExplosionElementPtr->preprocess_func = object_animation;
|
|
||||||
ExplosionElementPtr->turn_wait = MAKE_BYTE (2, 2);
|
|
||||||
ExplosionElementPtr->life_span = EXPLOSION_LIFE
|
|
||||||
* (LONIBBLE (ExplosionElementPtr->turn_wait) + 1);
|
|
||||||
|
|
||||||
SetPrimType (&DisplayArray[ExplosionElementPtr->PrimIndex],
|
|
||||||
STAMP_PRIM);
|
|
||||||
DisplayArray[ExplosionElementPtr->PrimIndex].Object.Stamp.frame =
|
|
||||||
SetAbsFrameIndex (LanderFrame[0], 46);
|
|
||||||
|
|
||||||
UnlockElement (hExplosionElement);
|
|
||||||
|
|
||||||
InsertElement (hExplosionElement, GetHeadElement ());
|
|
||||||
|
|
||||||
PlaySound (SetAbsSoundIndex (
|
|
||||||
LanderSounds, LANDER_DESTROYED
|
|
||||||
), NotPositional (), NULL, GAME_SOUND_PRIORITY + 1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // We could not allocate because the queue was full, but
|
{ // We could not allocate because the queue was full, but
|
||||||
@@ -1718,11 +1735,11 @@ landerSpeedNumer = WORLD_TO_VELOCITY (48);
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (HIBYTE (pMS->delta_item) != 0)
|
if (crew_left)
|
||||||
{
|
{
|
||||||
SIZE index = GetFrameIndex (LanderFrame[0]);
|
SIZE index = GetFrameIndex (LanderFrame[0]);
|
||||||
if (LONIBBLE (pMS->CurState))
|
if (turn_wait)
|
||||||
pMS->CurState -= MAKE_BYTE (1, 0);
|
--turn_wait;
|
||||||
else if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT] ||
|
else if (CurrentInputState.key[PlayerControls[0]][KEY_LEFT] ||
|
||||||
CurrentInputState.key[PlayerControls[0]][KEY_RIGHT])
|
CurrentInputState.key[PlayerControls[0]][KEY_RIGHT])
|
||||||
{
|
{
|
||||||
@@ -1750,8 +1767,7 @@ landerSpeedNumer = WORLD_TO_VELOCITY (48);
|
|||||||
COSINE (angle, landerSpeedNumer) / LANDER_SPEED_DENOM,
|
COSINE (angle, landerSpeedNumer) / LANDER_SPEED_DENOM,
|
||||||
SINE (angle, landerSpeedNumer) / LANDER_SPEED_DENOM);
|
SINE (angle, landerSpeedNumer) / LANDER_SPEED_DENOM);
|
||||||
|
|
||||||
pMS->CurState = MAKE_BYTE (
|
turn_wait = SHUTTLE_TURN_WAIT;
|
||||||
SHUTTLE_TURN_WAIT, HINIBBLE (pMS->CurState));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CurrentInputState.key[PlayerControls[0]][KEY_UP])
|
if (!CurrentInputState.key[PlayerControls[0]][KEY_UP])
|
||||||
@@ -1762,11 +1778,15 @@ landerSpeedNumer = WORLD_TO_VELOCITY (48);
|
|||||||
else
|
else
|
||||||
GetNextVelocityComponents (&GLOBAL (velocity), &dx, &dy, 1);
|
GetNextVelocityComponents (&GLOBAL (velocity), &dx, &dy, 1);
|
||||||
|
|
||||||
if (HINIBBLE (pMS->CurState))
|
if (weapon_wait)
|
||||||
pMS->CurState -= MAKE_BYTE (0, 1);
|
--weapon_wait;
|
||||||
else if (CurrentInputState.key[PlayerControls[0]][KEY_WEAPON])
|
else if (CurrentInputState.key[PlayerControls[0]][KEY_WEAPON])
|
||||||
{
|
{
|
||||||
LanderFire (pMS, index);
|
LanderFire (index);
|
||||||
|
|
||||||
|
weapon_wait = SHUTTLE_FIRE_WAIT;
|
||||||
|
if (GET_GAME_STATE (IMPROVED_LANDER_SHOT))
|
||||||
|
weapon_wait >>= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1989,9 +2009,11 @@ PlanetSide (POINT planetLoc)
|
|||||||
// something like an 'intptr_t private' field
|
// something like an 'intptr_t private' field
|
||||||
pLanderInputState = &landerInputState;
|
pLanderInputState = &landerInputState;
|
||||||
|
|
||||||
index = NORMALIZE_FACING ((COUNT)TFB_Random ());
|
index = NORMALIZE_FACING (TFB_Random ());
|
||||||
LanderFrame[0] = SetAbsFrameIndex (LanderFrame[0], index);
|
LanderFrame[0] = SetAbsFrameIndex (LanderFrame[0], index);
|
||||||
landerInputState.delta_item = 0;
|
crew_left = 0;
|
||||||
|
damage_index = 0;
|
||||||
|
explosion_index = 0;
|
||||||
pSolarSysState->MenuState.Initialized += 4;
|
pSolarSysState->MenuState.Initialized += 4;
|
||||||
|
|
||||||
InitPlanetSide (planetLoc);
|
InitPlanetSide (planetLoc);
|
||||||
@@ -2007,12 +2029,9 @@ PlanetSide (POINT planetLoc)
|
|||||||
|
|
||||||
if (!(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
if (!(GLOBAL (CurrentActivity) & CHECK_ABORT))
|
||||||
{
|
{
|
||||||
SIZE crew_left;
|
|
||||||
RECT r;
|
RECT r;
|
||||||
//CONTEXT OldContext;
|
//CONTEXT OldContext;
|
||||||
|
|
||||||
crew_left = HIBYTE (landerInputState.delta_item);
|
|
||||||
|
|
||||||
r.corner.x = SIS_ORG_X;
|
r.corner.x = SIS_ORG_X;
|
||||||
r.corner.y = SIS_ORG_Y;
|
r.corner.y = SIS_ORG_Y;
|
||||||
r.extent.width = SIS_SCREEN_WIDTH;
|
r.extent.width = SIS_SCREEN_WIDTH;
|
||||||
|
|||||||
@@ -35,8 +35,6 @@ typedef struct
|
|||||||
// Landing on or taking of from a planet.
|
// Landing on or taking of from a planet.
|
||||||
// Setting it while landed will initiate takeoff.
|
// Setting it while landed will initiate takeoff.
|
||||||
|
|
||||||
SOUND OldMenuSounds;
|
|
||||||
|
|
||||||
COUNT ElementLevel;
|
COUNT ElementLevel;
|
||||||
COUNT MaxElementLevel;
|
COUNT MaxElementLevel;
|
||||||
COUNT BiologicalLevel;
|
COUNT BiologicalLevel;
|
||||||
@@ -68,15 +66,6 @@ struct LanderInputState {
|
|||||||
SIZE Initialized;
|
SIZE Initialized;
|
||||||
TimeCount NextTime;
|
TimeCount NextTime;
|
||||||
// Frame rate control
|
// Frame rate control
|
||||||
|
|
||||||
// The following fields need to be renamed:
|
|
||||||
BYTE CurState;
|
|
||||||
// High byte: ?
|
|
||||||
// Low byte: ?
|
|
||||||
SIZE delta_item;
|
|
||||||
// High byte: ?
|
|
||||||
// Low byte: bits 0-6: current lander crew count
|
|
||||||
// bit 7: set if damage was prevented by a shield
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern LanderInputState *pLanderInputState;
|
extern LanderInputState *pLanderInputState;
|
||||||
|
|||||||
Reference in New Issue
Block a user