damage feed improvements

This commit is contained in:
Lorenc Pekaj 2018-10-13 23:21:05 +11:00
parent 812e0b2397
commit 763689448f

View File

@ -10,7 +10,6 @@
/* ** Macros ** */
#define IsDamageFeedActive(%0) ( IsPlayerSettingToggled( %0, SETTING_HITMARKER ) )
#define IsPlayerHit(%0) ( p_GotHit{%0} )
/* ** Definitions ** */
#define MAX_FEED_HEIGHT ( 5 )
@ -46,10 +45,9 @@ static stock
g_damageGiven [ MAX_PLAYERS ] [ MAX_FEED_HEIGHT ] [ E_DAMAGE_FEED ],
g_damageTaken [ MAX_PLAYERS ] [ MAX_FEED_HEIGHT ] [ E_DAMAGE_FEED ],
Text3D: g_BulletLabel [ MAX_PLAYERS ],
g_BulletTimer [ MAX_PLAYERS ],
//Text3D: g_BulletLabel [ MAX_PLAYERS ],
//g_BulletTimer [ MAX_PLAYERS ],
p_PlayerDamageObject [ MAX_PLAYERS ],
bool: p_GotHit [ MAX_PLAYERS char ],
PlayerText: g_damageFeedTakenTD [ MAX_PLAYERS ] = { PlayerText: INVALID_TEXT_DRAW, ... },
@ -110,10 +108,9 @@ hook OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
}
/* ** Functions ** */
function OnHideBulletLabel( playerid )
function DamageFeed_HideBulletLabel( labelid )
{
DestroyDynamic3DTextLabel( g_BulletLabel[ playerid ] );
KillTimer( g_BulletTimer[ playerid ] ); g_BulletTimer[ playerid ] = -1;
DestroyDynamic3DTextLabel( Text3D: labelid );
return 1;
}
@ -125,31 +122,28 @@ public OnPlayerTakenDamage( playerid, issuerid, Float: amount, weaponid, bodypar
static Float: fromX, Float: fromY, Float: fromZ;
static Float: toX, Float: toY, Float: toZ;
if ( IsValidDynamic3DTextLabel( g_BulletLabel[ issuerid ] ) )
{
DestroyDynamic3DTextLabel( g_BulletLabel[ issuerid ] );
KillTimer( g_BulletTimer[ issuerid ] );
g_BulletTimer[ issuerid ] = -1;
}
GetPlayerLastShotVectors( issuerid, fromX, fromY, fromZ, toX, toY, toZ );
g_BulletLabel[ issuerid ] = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xDD202088, toX, toY, toZ, 100.0, playerid, INVALID_VEHICLE_ID, 0, GetPlayerVirtualWorld( playerid ), GetPlayerInterior( playerid ) );
Streamer_Update( issuerid, STREAMER_TYPE_3D_TEXT_LABEL );
new
Text3D: bullet_label = CreateDynamic3DTextLabel( sprintf( "%.0f", amount ), 0xFFFFFF80, toX, toY, toZ, 100.0, .interiorid = GetPlayerVirtualWorld( playerid ), .worldid = GetPlayerInterior( playerid ), .testlos = 1 );
g_BulletTimer[ issuerid ] = SetTimerEx( "OnHideBulletLabel", 3000, false, "d", issuerid );
if ( IsValidDynamic3DTextLabel( bullet_label ) )
{
Streamer_Update( issuerid, STREAMER_TYPE_3D_TEXT_LABEL );
Streamer_Update( playerid, STREAMER_TYPE_3D_TEXT_LABEL );
SetTimerEx( "DamageFeed_HideBulletLabel", 1250, false, "d", _: bullet_label );
}
/* ** Armour and Health Object Damage ** */
if ( !IsPlayerHit( playerid ) )
if ( ! p_GotHit{ playerid } )
{
static
Float: fArmour;
Float: armour;
if ( GetPlayerArmour( playerid, fArmour ) )
if ( GetPlayerArmour( playerid, armour ) )
{
SetPlayerAttachedObject(playerid, 4, fArmour == 0 ? ( 1240 ) : ( 1242 ), 1, 1.400000, -0.004999, 0.034999, 4.499999, 83.500030, -3.799998, 1.000000, 1.000000, 1.026999);
SetPlayerAttachedObject( playerid, 4, armour - amount <= 0.0 ? ( 1240 ) : ( 1242 ), 1, 1.400000, -0.004999, 0.034999, 4.499999, 83.500030, -3.799998, 1.000000, 1.000000, 1.026999 );
SetTimerEx( "HideDamageObject", 1000, false, "d", playerid );
Streamer_Update( playerid, STREAMER_TYPE_OBJECT );
@ -179,7 +173,6 @@ function HideDamageObject( playerid )
if( IsPlayerAttachedObjectSlotUsed( playerid, 4 ) )
RemovePlayerAttachedObject( playerid, 4 );
DestroyObject( p_PlayerDamageObject[ playerid ] );
p_GotHit{ playerid } = false;
return 1;
}
@ -377,11 +370,11 @@ stock UpdateDamageFeedLabel( playerid )
if ( g_damageGiven[ playerid ] [ givenid ] [ E_ISSUER ] == INVALID_PLAYER_ID )
{
format( szLabel, sizeof( szLabel ), "%s%s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] );
format( szLabel, sizeof( szLabel ), "%s%s +%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ] [ givenid ] [ E_AMOUNT ] );
}
else
{
format( szLabel, sizeof( szLabel ), "%s%s - %s ~w~+%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ][ givenid ][ E_NAME ], g_damageGiven[ playerid ][ givenid ][ E_AMOUNT ] );
format( szLabel, sizeof( szLabel ), "%s%s - %s +%.2f~n~", szLabel, szWeapon, g_damageGiven[ playerid ] [ givenid ] [ E_NAME ], g_damageGiven[ playerid ] [ givenid ] [ E_AMOUNT ] );
}
}
@ -419,11 +412,11 @@ stock UpdateDamageFeedLabel( playerid )
if ( g_damageTaken[ playerid ] [ takenid ] [ E_ISSUER ] == INVALID_PLAYER_ID )
{
format( szLabel, sizeof( szLabel ), "%s%s ~w~-%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] );
format( szLabel, sizeof( szLabel ), "%s%s -%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ] [ takenid ] [ E_AMOUNT ] );
}
else
{
format( szLabel, sizeof( szLabel ), "%s%s - %s ~w~-%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ][ takenid ][ E_NAME ], g_damageTaken[ playerid ][ takenid ][ E_AMOUNT ] );
format( szLabel, sizeof( szLabel ), "%s%s - %s -%.2f~n~", szLabel, szWeapon, g_damageTaken[ playerid ] [ takenid ] [ E_NAME ], g_damageTaken[ playerid ] [ takenid ] [ E_AMOUNT ] );
}
}