Improved frame selection for frozen soldiers.

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8042 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2016-01-28 21:46:11 +00:00
parent 2f84d10f07
commit d2be96384f
4 changed files with 69 additions and 6 deletions
+65 -4
View File
@@ -7903,6 +7903,67 @@ void SOLDIERTYPE::EVENT_BeginMercTurn( BOOLEAN fFromRealTime, INT32 iRealTimeCou
// UTILITY FUNCTIONS CALLED BY OVERHEAD.H
UINT8 gDirectionFrom8to2[] = {0, 0, 1, 1, 0, 1, 1, 0};
// Flugente: frozen soldiers do not move. We simulate this by using fixed animation frames, which we determine here
UINT16 SOLDIERTYPE::CryoAniFrame()
{
// get anim surface and determine # of frames
UINT16 usAnimSurface = GetSoldierAnimationSurface( this, this->usAnimState );
//If we are only one frame, ignore what the script is telling us!
if ( usAnimSurface == INVALID_ANIMATION_SURFACE || gAnimSurfaceDatabase[usAnimSurface].hVideoObject == NULL || gAnimSurfaceDatabase[usAnimSurface].ubFlags & ANIM_DATA_FLAG_NOFRAMES )
{
return 0;
}
// COnvert world direction into sprite direction
UINT8 ubTempDir = gOneCDirection[this->ubDirection];
if ( gAnimSurfaceDatabase[usAnimSurface].uiNumDirections == 32 )
{
ubTempDir = gExtOneCDirection[this->ubHiResDirection];
}
// Check # of directions /surface, adjust if ness.
else if ( gAnimSurfaceDatabase[usAnimSurface].uiNumDirections == 4 )
{
ubTempDir = ubTempDir / 2;
}
// Check # of directions /surface, adjust if ness.
else if ( gAnimSurfaceDatabase[usAnimSurface].uiNumDirections == 1 )
{
ubTempDir = 0;
}
// Check # of directions /surface, adjust if ness.
else if ( gAnimSurfaceDatabase[usAnimSurface].uiNumDirections == 3 )
{
if ( this->ubDirection == NORTHWEST )
{
ubTempDir = 1;
}
else if ( this->ubDirection == WEST )
{
ubTempDir = 0;
}
else if ( this->ubDirection == EAST )
{
ubTempDir = 2;
}
}
else if ( gAnimSurfaceDatabase[usAnimSurface].uiNumDirections == 2 )
{
ubTempDir = gDirectionFrom8to2[this->ubDirection];
}
UINT16 cryoframe = 0;
UINT16 newframe = cryoframe + (UINT16)((gAnimSurfaceDatabase[usAnimSurface].uiNumFramesPerDir * ubTempDir));
if ( newframe >= gAnimSurfaceDatabase[usAnimSurface].hVideoObject->usNumberOfObjects )
{
return 0;
}
return newframe;
}
BOOLEAN SOLDIERTYPE::ConvertAniCodeToAniFrame( UINT16 usAniFrame )
{
@@ -7945,11 +8006,11 @@ BOOLEAN SOLDIERTYPE::ConvertAniCodeToAniFrame( UINT16 usAniFrame )
{
ubTempDir = 1;
}
if ( this->ubDirection == WEST )
else if ( this->ubDirection == WEST )
{
ubTempDir = 0;
}
if ( this->ubDirection == EAST )
else if ( this->ubDirection == EAST )
{
ubTempDir = 2;
}
@@ -18477,7 +18538,7 @@ void SOLDIERTYPE::PrintDiseaseDesc( CHAR16* apStr, BOOLEAN fFullDesc )
{
if ( fShowExactPoints )
{
swprintf( atStr, L"\n\n%s (undiagnosed) - %d / %d\n", Disease[i].szFatName, this->sDiseasePoints[i], Disease[i].sInfectionPtsFull );
swprintf( atStr, L"\n\n%s - %d / %d\n", Disease[i].szFatName, this->sDiseasePoints[i], Disease[i].sInfectionPtsFull );
}
else
{
@@ -18592,7 +18653,7 @@ void SOLDIERTYPE::PrintFoodDesc( CHAR16* apStr, BOOLEAN fFullDesc )
// only for living mercs with a profile
if ( this->flags.uiStatusFlags & SOLDIER_VEHICLE || this->ubProfile == NO_PROFILE )
return;
CHAR16 atStr[500];
swprintf( atStr, L"" );
+2
View File
@@ -1627,6 +1627,8 @@ public:
// Soldier Management functions called by Overhead.c
// Flugente: frozen soldiers do not move. We simulate this by using fixed animation frames, which we determine here
UINT16 CryoAniFrame();
BOOLEAN ConvertAniCodeToAniFrame( UINT16 usAniFrame );
void TurnSoldier( void );
void ChangeSoldierStance( UINT8 ubDesiredStance );
+1 -1
View File
@@ -9654,7 +9654,7 @@ INT32 BulletImpact( SOLDIERTYPE *pFirer, BULLET *pBullet, SOLDIERTYPE * pTarget,
}
// Flugente: if this is cryo ammo, freeze target.
if ( !TANK( pTarget ) && AmmoTypes[ubAmmoType].ammoflag & AMMO_CRYO )
if ( !TANK( pTarget ) && !(pTarget->flags.uiStatusFlags & SOLDIER_VEHICLE) && AmmoTypes[ubAmmoType].ammoflag & AMMO_CRYO )
{
pTarget->usSkillCooldown[SOLDIER_COOLDOWN_CRYO] += 2;
+1 -1
View File
@@ -1834,7 +1834,7 @@ void RenderTiles(UINT32 uiFlags, INT32 iStartPointX_M, INT32 iStartPointY_M, INT
// Flugente: frozen soldiers don't move
if ( pSoldier->usSkillCooldown[SOLDIER_COOLDOWN_CRYO] && pSoldier->stats.bLife > 0 )
{
usImageIndex = 0;
usImageIndex = pSoldier->CryoAniFrame( );
}
uiDirtyFlags=BGND_FLAG_SINGLE|BGND_FLAG_ANIMATED| BGND_FLAG_MERC;