From f4bf5fd1f706e8cd6ce622130909088d2eb8c1ea Mon Sep 17 00:00:00 2001 From: lalien Date: Thu, 4 May 2006 13:29:18 +0000 Subject: [PATCH] ********************************************************* * 2006/05/04 * * Madd Mugsy * * Developed in VS 2003 * ********************************************************* - Added tile lighting animation effects to tracer bullets, forced muzzle flash on tracers so enemies can see you, regardless of flash suppression - Re-enabled laptop animation, since Lesh fixed it (I forgot to mention that in my earlier changes :p) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@54 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Laptop/laptop.cpp | 227 +++++++++++++++++----------------- Tactical/Bullets.h | 1 + Tactical/Items.cpp | 6 +- Tactical/Items.h | 2 +- Tactical/Rain.cpp | 2 +- Tactical/Soldier Control.cpp | 2 +- Tactical/Weapons.cpp | 2 +- Tactical/bullets.cpp | 2 + TileEngine/Tile Animation.cpp | 27 ++++ TileEngine/Tile Animation.h | 5 +- 10 files changed, 153 insertions(+), 123 deletions(-) diff --git a/Laptop/laptop.cpp b/Laptop/laptop.cpp index 316c3941..f96af261 100644 --- a/Laptop/laptop.cpp +++ b/Laptop/laptop.cpp @@ -1811,15 +1811,14 @@ UINT32 LaptopScreenHandle() if( gfStartMapScreenToLaptopTransition ) { - // WANNE 2: I disabled the animation of the laptop, because the screen redrawing does not work correct! - // Madd: It'd be nice if someone who knows more about graphics than I do could re-enable this, at least for 640x480 //Everything is set up to start the transition animation. - //SGPRect SrcRect2, DstRect; - //INT32 iPercentage, iScalePercentage, iFactor; - //UINT32 uiStartTime, uiTimeRange, uiCurrTime; - //INT32 iX, iY, iWidth, iHeight; + //SGPRect SrcRect1; + SGPRect SrcRect2, DstRect; + INT32 iPercentage, iScalePercentage, iFactor; + UINT32 uiStartTime, uiTimeRange, uiCurrTime; + INT32 iX, iY, iWidth, iHeight; - //INT32 iRealPercentage; + INT32 iRealPercentage; SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); //Step 1: Build the laptop image into the save buffer. @@ -1834,63 +1833,62 @@ UINT32 LaptopScreenHandle() PrintNumberOnTeam( ); ShowLights(); - //// WANNE 2 - ////Step 2: The mapscreen image is in the EXTRABUFFER, and laptop is in the SAVEBUFFER - //// Start transitioning the screen. - //DstRect.iLeft = iScreenWidthOffset; //0 - //DstRect.iTop = iScreenHeightOffset; //0 - //DstRect.iRight = iScreenWidthOffset + 640; //640 - //DstRect.iBottom = iScreenHeightOffset + 480; //480 - //uiTimeRange = 1000; - //iPercentage = iRealPercentage = 0; - //uiStartTime = GetJA2Clock(); + //Step 2: The mapscreen image is in the EXTRABUFFER, and laptop is in the SAVEBUFFER + // Start transitioning the screen. + DstRect.iLeft = iScreenWidthOffset; //0 + DstRect.iTop = iScreenHeightOffset; //0 + DstRect.iRight = iScreenWidthOffset + 640; //640 + DstRect.iBottom = iScreenHeightOffset + 480; //480 + uiTimeRange = 1000; + iPercentage = iRealPercentage = 0; + uiStartTime = GetJA2Clock(); - //BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, iScreenWidthOffset, iScreenHeightOffset, - // 640, 480 ); - //BlitBufferToBuffer( guiEXTRABUFFER, FRAME_BUFFER, iScreenWidthOffset, iScreenHeightOffset, 640, 480 ); + BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, iScreenWidthOffset, iScreenHeightOffset, + 640, 480 ); + BlitBufferToBuffer( guiEXTRABUFFER, FRAME_BUFFER, iScreenWidthOffset, iScreenHeightOffset, 640, 480 ); - //PlayJA2SampleFromFile( "SOUNDS\\Laptop power up (8-11).wav", RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); - // - //// WANNE 2 with laptop zooming - //while( iRealPercentage < 100 ) - //{ - // uiCurrTime = GetJA2Clock(); - // iPercentage = (uiCurrTime-uiStartTime) * 100 / uiTimeRange; - // iPercentage = min( iPercentage, 100 ); + PlayJA2SampleFromFile( "SOUNDS\\Laptop power up (8-11).wav", RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); + + // WANNE 2 with laptop zooming + while( iRealPercentage < 100 ) + { + uiCurrTime = GetJA2Clock(); + iPercentage = (uiCurrTime-uiStartTime) * 100 / uiTimeRange; + iPercentage = min( iPercentage, 100 ); - // iRealPercentage = iPercentage; + iRealPercentage = iPercentage; - // //Factor the percentage so that it is modified by a gravity falling acceleration effect. - // iFactor = (iPercentage - 50) * 2; - // if( iPercentage < 50 ) - // iPercentage = (UINT32)(iPercentage + iPercentage * iFactor * 0.01 + 0.5); - // else - // iPercentage = (UINT32)(iPercentage + (100-iPercentage) * iFactor * 0.01 + 0.5); + //Factor the percentage so that it is modified by a gravity falling acceleration effect. + iFactor = (iPercentage - 50) * 2; + if( iPercentage < 50 ) + iPercentage = (UINT32)(iPercentage + iPercentage * iFactor * 0.01 + 0.5); + else + iPercentage = (UINT32)(iPercentage + (100-iPercentage) * iFactor * 0.01 + 0.5); - // //Laptop source rect - // if( iPercentage < 99 ) - // iScalePercentage = 10000 / (100-iPercentage); - // else - // iScalePercentage = 5333; - // iWidth = 12 * iScalePercentage / 100; - // iHeight = 9 * iScalePercentage / 100; + //Laptop source rect + if( iPercentage < 99 ) + iScalePercentage = 10000 / (100-iPercentage); + else + iScalePercentage = 5333; + iWidth = 12 * iScalePercentage / 100; + iHeight = 9 * iScalePercentage / 100; - // iX = iScreenWidthOffset + 472 - (472-320) * iScalePercentage / 5333; - // iY = iScreenHeightOffset + 424 - (424-240) * iScalePercentage / 5333; + iX = 472 - (472 - (iScreenWidthOffset + 320)) * iScalePercentage / 5333; + iY = 424 - (424 - (iScreenHeightOffset + 240)) * iScalePercentage / 5333; - // SrcRect2.iLeft = iX - iWidth / 2; - // SrcRect2.iRight = SrcRect2.iLeft + iWidth; - // SrcRect2.iTop = iY - iHeight / 2; - // SrcRect2.iBottom = SrcRect2.iTop + iHeight; - // - // BltStretchVideoSurface(FRAME_BUFFER, guiSAVEBUFFER, 0, 0, 0, &DstRect, &SrcRect2 ); + SrcRect2.iLeft = iX - iWidth / 2; + SrcRect2.iRight = SrcRect2.iLeft + iWidth; + SrcRect2.iTop = iY - iHeight / 2; + SrcRect2.iBottom = SrcRect2.iTop + iHeight; + + BltStretchVideoSurface( FRAME_BUFFER, guiSAVEBUFFER, iScreenWidthOffset, iScreenHeightOffset, 0, &DstRect, &SrcRect2 ); - // //WANNE 2 - // InvalidateScreen(); - // - // //WANNE 2 - // RefreshScreen( NULL ); - //} + //WANNE 2 + InvalidateScreen(); + + //WANNE 2 + RefreshScreen( NULL ); + } fReDrawScreenFlag = TRUE; } @@ -2445,14 +2443,11 @@ BOOLEAN LeaveLapTopScreen( void ) if( !gfDontStartTransitionFromLaptop ) { - // WANNE 2: I disabled the laptop animation, because the screen redrawing does not work correctly! - // Madd: It'd be nice if someone who knows more about graphics than I do could re-enable this, at least for 640x480 - - //SGPRect SrcRect1, SrcRect2, DstRect; - //INT32 iPercentage, iScalePercentage, iFactor; - //UINT32 uiStartTime, uiTimeRange, uiCurrTime; - //INT32 iX, iY, iWidth, iHeight; - //INT32 iRealPercentage; + SGPRect SrcRect1, SrcRect2, DstRect; + INT32 iPercentage, iScalePercentage, iFactor; + UINT32 uiStartTime, uiTimeRange, uiCurrTime; + INT32 iX, iY, iWidth, iHeight; + INT32 iRealPercentage; gfDontStartTransitionFromLaptop = TRUE; SetCurrentCursorFromDatabase( VIDEO_NO_CURSOR ); @@ -2467,66 +2462,66 @@ BOOLEAN LeaveLapTopScreen( void ) PrintNumberOnTeam( ); ShowLights(); - ////Step 2: The mapscreen image is in the EXTRABUFFER, and laptop is in the SAVEBUFFER - //// Start transitioning the screen. - //DstRect.iLeft = iScreenWidthOffset + 0; // 0 - //DstRect.iTop = iScreenHeightOffset + 0; // 0 - //DstRect.iRight = iScreenWidthOffset + 640; // 640 - //DstRect.iBottom = iScreenHeightOffset + 480; // 480 - //uiTimeRange = 1000; - //iPercentage = iRealPercentage = 100; - //uiStartTime = GetJA2Clock(); + //Step 2: The mapscreen image is in the EXTRABUFFER, and laptop is in the SAVEBUFFER + // Start transitioning the screen. + DstRect.iLeft = iScreenWidthOffset + 0; // 0 + DstRect.iTop = iScreenHeightOffset + 0; // 0 + DstRect.iRight = iScreenWidthOffset + 640; // 640 + DstRect.iBottom = iScreenHeightOffset + 480; // 480 + uiTimeRange = 1000; + iPercentage = iRealPercentage = 100; + uiStartTime = GetJA2Clock(); - //BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, iScreenWidthOffset, iScreenHeightOffset, - // 640, 480 ); + BlitBufferToBuffer( FRAME_BUFFER, guiSAVEBUFFER, iScreenWidthOffset, iScreenHeightOffset, + 640, 480 ); - //PlayJA2SampleFromFile( "SOUNDS\\Laptop power down (8-11).wav", RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); + PlayJA2SampleFromFile( "SOUNDS\\Laptop power down (8-11).wav", RATE_11025, HIGHVOLUME, 1, MIDDLEPAN ); - //// WANNE 2 - //while( iRealPercentage > 0 ) - //{ - // BlitBufferToBuffer( guiEXTRABUFFER, FRAME_BUFFER, iScreenWidthOffset, iScreenHeightOffset, 640, 480 ); + // WANNE 2 + while( iRealPercentage > 0 ) + { + BlitBufferToBuffer( guiEXTRABUFFER, FRAME_BUFFER, iScreenWidthOffset, iScreenHeightOffset, 640, 480 ); - // uiCurrTime = GetJA2Clock(); - // iPercentage = (uiCurrTime-uiStartTime) * 100 / uiTimeRange; - // iPercentage = min( iPercentage, 100 ); - // iPercentage = 100 - iPercentage; + uiCurrTime = GetJA2Clock(); + iPercentage = (uiCurrTime-uiStartTime) * 100 / uiTimeRange; + iPercentage = min( iPercentage, 100 ); + iPercentage = 100 - iPercentage; - // iRealPercentage = iPercentage; + iRealPercentage = iPercentage; - // //Factor the percentage so that it is modified by a gravity falling acceleration effect. - // iFactor = (iPercentage - 50) * 2; - // if( iPercentage < 50 ) - // iPercentage = (UINT32)(iPercentage + iPercentage * iFactor * 0.01 + 0.5); - // else - // iPercentage = (UINT32)(iPercentage + (100-iPercentage) * iFactor * 0.01 + 0.5); + //Factor the percentage so that it is modified by a gravity falling acceleration effect. + iFactor = (iPercentage - 50) * 2; + if( iPercentage < 50 ) + iPercentage = (UINT32)(iPercentage + iPercentage * iFactor * 0.01 + 0.5); + else + iPercentage = (UINT32)(iPercentage + (100-iPercentage) * iFactor * 0.01 + 0.5); - // //Mapscreen source rect - // SrcRect1.iLeft = iScreenWidthOffset + 464 * iPercentage / 100; - // SrcRect1.iRight = iScreenWidthOffset + 640 - 163 * iPercentage / 100; - // SrcRect1.iTop = iScreenHeightOffset + 417 * iPercentage / 100; - // SrcRect1.iBottom = iScreenHeightOffset + 480 - 55 * iPercentage / 100; - // //Laptop source rect - // if( iPercentage < 99 ) - // iScalePercentage = 10000 / (100-iPercentage); - // else - // iScalePercentage = 5333; - // iWidth = 12 * iScalePercentage / 100; - // iHeight = 9 * iScalePercentage / 100; - // iX = iScreenWidthOffset + 472 - (472-320) * iScalePercentage / 5333; - // iY = iScreenHeightOffset + 424 - (424-240) * iScalePercentage / 5333; + //Mapscreen source rect + SrcRect1.iLeft = iScreenWidthOffset + 464 * iPercentage / 100; + SrcRect1.iRight = iScreenWidthOffset + 640 - 163 * iPercentage / 100; + SrcRect1.iTop = iScreenHeightOffset + 417 * iPercentage / 100; + SrcRect1.iBottom = iScreenHeightOffset + 480 - 55 * iPercentage / 100; + //Laptop source rect + if( iPercentage < 99 ) + iScalePercentage = 10000 / (100-iPercentage); + else + iScalePercentage = 5333; + iWidth = 12 * iScalePercentage / 100; + iHeight = 9 * iScalePercentage / 100; + iX = 472 - (472 - (iScreenWidthOffset + 320)) * iScalePercentage / 5333; + iY = 424 - (424 - (iScreenHeightOffset + 240)) * iScalePercentage / 5333; - // SrcRect2.iLeft = iX - iWidth / 2; - // SrcRect2.iRight = SrcRect2.iLeft + iWidth; - // SrcRect2.iTop = iY - iHeight / 2; - // SrcRect2.iBottom = SrcRect2.iTop + iHeight; + SrcRect2.iLeft = iX - iWidth / 2; + SrcRect2.iRight = SrcRect2.iLeft + iWidth; + SrcRect2.iTop = iY - iHeight / 2; + SrcRect2.iBottom = SrcRect2.iTop + iHeight; - // BltStretchVideoSurface( FRAME_BUFFER, guiSAVEBUFFER, 0, 0, 0, &DstRect, &SrcRect2 ); + BltStretchVideoSurface( FRAME_BUFFER, guiSAVEBUFFER, 0, iScreenWidthOffset, iScreenHeightOffset, &DstRect, &SrcRect2 ); - // InvalidateScreen(); - // //gfPrintFrameBuffer = TRUE; - // RefreshScreen( NULL ); - //} + InvalidateScreen(); + //gfPrintFrameBuffer = TRUE; + RefreshScreen( NULL ); + } } } return( TRUE ); @@ -4519,8 +4514,8 @@ BOOLEAN DisplayTitleBarMaximizeGraphic(BOOLEAN fForward, BOOLEAN fInit, UINT16 u sPosBottomY = LAPTOP_TITLE_BAR_HEIGHT; - SrcRect.iLeft = iScreenWidthOffset; - SrcRect.iTop = iScreenHeightOffset; + SrcRect.iLeft = 0; + SrcRect.iTop = 0; SrcRect.iRight = LAPTOP_TITLE_BAR_WIDTH; SrcRect.iBottom = LAPTOP_TITLE_BAR_HEIGHT; diff --git a/Tactical/Bullets.h b/Tactical/Bullets.h index cbbd3b5d..55185539 100644 --- a/Tactical/Bullets.h +++ b/Tactical/Bullets.h @@ -61,6 +61,7 @@ typedef struct ANITILE *pShadowAniTile; UINT8 ubItemStatus; UINT16 fromItem; + INT32 flash; } BULLET; extern UINT32 guiNumBullets; diff --git a/Tactical/Items.cpp b/Tactical/Items.cpp index 9875093b..d47d30e8 100644 --- a/Tactical/Items.cpp +++ b/Tactical/Items.cpp @@ -6637,10 +6637,14 @@ BOOLEAN IsRemoteDetonatorAttached( OBJECTTYPE * pObj ) return( FALSE ); } -BOOLEAN IsFlashSuppressor( OBJECTTYPE * pObj ) +BOOLEAN IsFlashSuppressor( OBJECTTYPE * pObj, SOLDIERTYPE * pSoldier ) { INT8 bLoop; + //Madd: tracers automatically negate any muzzle flash suppression due to inherent lighting effects + if (Item[pObj->usItem].usItemClass == IC_GUN && AmmoTypes[pObj->ubGunAmmoType].tracerEffect && pSoldier->bDoBurst ) + return FALSE; + if (Item[pObj->usItem].hidemuzzleflash ) return TRUE; diff --git a/Tactical/Items.h b/Tactical/Items.h index 7c67cfe4..862ec697 100644 --- a/Tactical/Items.h +++ b/Tactical/Items.h @@ -245,7 +245,7 @@ INT8 FindNonSmokeLaunchable( SOLDIERTYPE * pSoldier, UINT16 usWeapon ); INT8 FindNonSmokeLaunchableAttachment( OBJECTTYPE * pObj, UINT16 usWeapon ); UINT16 PickARandomLaunchable(UINT16 itemIndex); -BOOLEAN IsFlashSuppressor( OBJECTTYPE * pObj ); +BOOLEAN IsFlashSuppressor( OBJECTTYPE * pObj, SOLDIERTYPE * pSoldier ); INT16 GetFlashSuppressorStatus( OBJECTTYPE * pObj ); BOOLEAN IsRemoteDetonator( OBJECTTYPE * pObj ); BOOLEAN IsDetonator( OBJECTTYPE * pObj ); diff --git a/Tactical/Rain.cpp b/Tactical/Rain.cpp index 5a8d94f5..fcde5340 100644 --- a/Tactical/Rain.cpp +++ b/Tactical/Rain.cpp @@ -198,7 +198,7 @@ void ResetRain() void GenerateRainDropsList() { - guiCurrMaxAmountOfRainDrops = (UINT32)BASE_MAXIMUM_DROPS * gbCurrentRainIntensity; + guiCurrMaxAmountOfRainDrops = (UINT32)(BASE_MAXIMUM_DROPS) * gbCurrentRainIntensity; pRainDrops = (TRainDrop *)MemAlloc( sizeof( TRainDrop ) * guiCurrMaxAmountOfRainDrops ); memset( pRainDrops, 0, sizeof( TRainDrop ) * guiCurrMaxAmountOfRainDrops ); diff --git a/Tactical/Soldier Control.cpp b/Tactical/Soldier Control.cpp index 86e29c1f..2448345a 100644 --- a/Tactical/Soldier Control.cpp +++ b/Tactical/Soldier Control.cpp @@ -2796,7 +2796,7 @@ void EVENT_FireSoldierWeapon( SOLDIERTYPE *pSoldier, INT16 sTargetGridNo ) // break; //} - if ( IsFlashSuppressor (&pSoldier->inv[ pSoldier->ubAttackingHand ] ) ) + if ( IsFlashSuppressor (&pSoldier->inv[ pSoldier->ubAttackingHand ], pSoldier ) ) pSoldier->fMuzzleFlash = FALSE; else pSoldier->fMuzzleFlash = TRUE; diff --git a/Tactical/Weapons.cpp b/Tactical/Weapons.cpp index d41ad077..cff36c4a 100644 --- a/Tactical/Weapons.cpp +++ b/Tactical/Weapons.cpp @@ -1737,7 +1737,7 @@ BOOLEAN UseGun( SOLDIERTYPE *pSoldier , INT16 sTargetGridNo ) fBuckshot = FALSE; if (!CREATURE_OR_BLOODCAT( pSoldier ) ) { - if ( IsFlashSuppressor(&pSoldier->inv[ pSoldier->ubAttackingHand ]) ) + if ( IsFlashSuppressor(&pSoldier->inv[ pSoldier->ubAttackingHand ], pSoldier ) ) pSoldier->fMuzzleFlash = FALSE; else pSoldier->fMuzzleFlash = TRUE; diff --git a/Tactical/bullets.cpp b/Tactical/bullets.cpp index 85256d33..bf3b583c 100644 --- a/Tactical/bullets.cpp +++ b/Tactical/bullets.cpp @@ -409,9 +409,11 @@ void AddMissileTrail( BULLET *pBullet, FIXEDPT qCurrX, FIXEDPT qCurrY, FIXEDPT q else if ( pBullet->usFlags & ( BULLET_FLAG_TRACER ) ) { strcpy( AniParams.zCachedFile, "TILECACHE\\BULLET_TRACER.STI" ); + AniParams.uiFlags |= ANITILE_LIGHT; } CreateAnimationTile( &AniParams ); + } diff --git a/TileEngine/Tile Animation.cpp b/TileEngine/Tile Animation.cpp index b1c84153..6766b53e 100644 --- a/TileEngine/Tile Animation.cpp +++ b/TileEngine/Tile Animation.cpp @@ -136,6 +136,24 @@ ANITILE *CreateAnimationTile( ANITILE_PARAMS *pAniParams ) pNewAniNode->pLevelNode = pNode; + if ( uiFlags & ANITILE_LIGHT ) + { + if ( ubAmbientLightLevel >= MIN_AMB_LEVEL_FOR_MERC_LIGHTS ) + { + + if( ( pNewAniNode->lightSprite=LightSpriteCreate("L-R03.LHT", 0 ) )!=(-1)) + { + LightSpritePower(pNewAniNode->lightSprite, TRUE); + { + INT16 sXPos, sYPos; + + ConvertGridNoToCenterCellXY( sGridNo, &sXPos, &sYPos ); + LightSpritePosition( pNewAniNode->lightSprite, (INT16)(sXPos/CELL_X_SIZE), (INT16)(sYPos/CELL_Y_SIZE)); + } + } + } + } + if ( ( uiFlags & ANITILE_CACHEDTILE ) ) { pNewAniNode->pLevelNode->uiFlags |= ( LEVELNODE_CACHEDANITILE ); @@ -363,6 +381,10 @@ void DeleteAniTile( ANITILE *pAniTile ) break; } + if ( pAniNode->uiFlags & ANITILE_LIGHT ) + { + LightSpriteDestroy(pAniNode->lightSprite); + } if ( ( pAniNode->uiFlags & ANITILE_CACHEDTILE ) ) { @@ -592,6 +614,11 @@ void UpdateAniTiles( ) } else { + //if ( pNode->uiFlags & ANITILE_LIGHT ) + //{ + // LightSpriteDestroy(pNode->lightSprite); + //} + // Delete from world! DeleteAniTile( pNode ); diff --git a/TileEngine/Tile Animation.h b/TileEngine/Tile Animation.h index 762ac507..8f0f158a 100644 --- a/TileEngine/Tile Animation.h +++ b/TileEngine/Tile Animation.h @@ -24,6 +24,7 @@ #define ANITILE_EXPLOSION 0x20000000 #define ANITILE_RELEASE_ATTACKER_WHEN_DONE 0x40000000 #define ANITILE_USE_4DIRECTION_FOR_START_FRAME 0x02000000 +#define ANITILE_LIGHT 0x80000000 #define ANI_LAND_LEVEL 1 @@ -71,7 +72,7 @@ typedef struct TAG_anitile UINT32 uiUserData3; INT8 bFrameCountAfterStart; - + INT32 lightSprite; } ANITILE; @@ -100,7 +101,7 @@ typedef struct TAG_anitile_params UINT32 uiUserData; UINT8 ubUserData2; UINT32 uiUserData3; - + INT32 lightSprite; } ANITILE_PARAMS;