Revision | 9ebf9fc0d00992b4eca9ed54d51b1cf74467f6a7 (tree) |
---|---|
Time | 2022-04-24 09:19:52 |
Author | Adam Kaminski <kaminskiadam9@gmai...> |
Commiter | Adam Kaminski |
Fixed: Player.DamageScreenColor didn't work properly in online games if it used a specific damage type.
@@ -59,6 +59,15 @@ | ||
59 | 59 | Actor attacker with NullAllowed |
60 | 60 | EndCommand |
61 | 61 | |
62 | +Command DamagePlayerWithType | |
63 | + ExtendedCommand | |
64 | + Player player with MoTest | |
65 | + Variable health | |
66 | + Variable armor | |
67 | + String damageType | |
68 | + Actor attacker with NullAllowed | |
69 | +EndCommand | |
70 | + | |
62 | 71 | Command KillPlayer |
63 | 72 | Player player with MoTest |
64 | 73 | Actor source with NullAllowed |
@@ -3837,7 +3837,7 @@ | ||
3837 | 3837 | |
3838 | 3838 | //***************************************************************************** |
3839 | 3839 | // |
3840 | -void ServerCommands::DamagePlayer::Execute() | |
3840 | +static void client_DamagePlayer( player_t *player, int health, int armor, AActor *attacker ) | |
3841 | 3841 | { |
3842 | 3842 | // Level not loaded, ignore... |
3843 | 3843 | if ( gamestate != GS_LEVEL ) |
@@ -3883,6 +3883,26 @@ | ||
3883 | 3883 | |
3884 | 3884 | //***************************************************************************** |
3885 | 3885 | // |
3886 | +void ServerCommands::DamagePlayer::Execute() | |
3887 | +{ | |
3888 | + // [AK] No damage type was sent to us, revert the player's DamageTypeReceived to "none". | |
3889 | + player->mo->DamageTypeReceived = "None"; | |
3890 | + | |
3891 | + client_DamagePlayer( player, health, armor, attacker ); | |
3892 | +} | |
3893 | + | |
3894 | +//***************************************************************************** | |
3895 | +// | |
3896 | +void ServerCommands::DamagePlayerWithType::Execute() | |
3897 | +{ | |
3898 | + // [AK] Set the player's DamageTypeReceived to whatever was sent to us. | |
3899 | + player->mo->DamageTypeReceived = damageType; | |
3900 | + | |
3901 | + client_DamagePlayer( player, health, armor, attacker ); | |
3902 | +} | |
3903 | + | |
3904 | +//***************************************************************************** | |
3905 | +// | |
3886 | 3906 | void ServerCommands::KillPlayer::Execute() |
3887 | 3907 | { |
3888 | 3908 | // Set the player's new health. |
@@ -371,6 +371,7 @@ | ||
371 | 371 | ENUM_ELEMENT ( SVC2_SYNCMAPROTATION ), |
372 | 372 | ENUM_ELEMENT ( SVC2_UPDATEMAPROTATION ), |
373 | 373 | ENUM_ELEMENT ( SVC2_STOPALLSOUNDSONTHING ), |
374 | + ENUM_ELEMENT ( SVC2_DAMAGEPLAYERWITHTYPE ), | |
374 | 375 | // [BB] Commands necessary for the account system. |
375 | 376 | ENUM_ELEMENT ( SVC2_SRP_USER_START_AUTHENTICATION ), |
376 | 377 | ENUM_ELEMENT ( SVC2_SRP_USER_PROCESS_CHALLENGE ), |
@@ -347,6 +347,8 @@ | ||
347 | 347 | { |
348 | 348 | ULONG ulArmorPoints; |
349 | 349 | AInventory *pArmor; |
350 | + PalEntry painFlash; | |
351 | + bool bSendDamageType = false; | |
350 | 352 | |
351 | 353 | if ( PLAYER_IsValidPlayer( ulPlayer ) == false ) |
352 | 354 | return; |
@@ -361,6 +363,12 @@ | ||
361 | 363 | |
362 | 364 | // If the player doesn't possess any armor, then his armor points are 0. |
363 | 365 | ulArmorPoints = ( pArmor != NULL ) ? pArmor->Amount : 0; |
366 | + | |
367 | + // [AK] Check if the player's class has a special pain flash for the damage type they just | |
368 | + // received. If it does, then we'll also send the damage type under a different command so | |
369 | + // that the pain flash appears properly on the client's screen. | |
370 | + if ( players[ulPlayer].mo->GetClass( )->ActorInfo->GetPainFlash( players[ulPlayer].mo->DamageTypeReceived, &painFlash )) | |
371 | + bSendDamageType = true; | |
364 | 372 | } |
365 | 373 | |
366 | 374 | ServerCommands::DamagePlayer fullCommand; |
@@ -374,12 +382,33 @@ | ||
374 | 382 | // [EP] Send the updated health and armor of the player who's being damaged to this client |
375 | 383 | // only if this client is allowed to know. |
376 | 384 | if ( SERVER_IsPlayerAllowedToKnowHealth( *it, ulPlayer )) |
377 | - fullCommand.sendCommandToClients( *it, SVCF_ONLYTHISCLIENT ); | |
385 | + { | |
386 | + // [AK] If we're going to send the damage type, make sure that this client is watching the | |
387 | + // player. Otherwise, they don't need to know the damage type. | |
388 | + if (( bSendDamageType ) && ( SERVER_GetClient( *it )->ulDisplayPlayer == ulPlayer )) | |
389 | + SERVERCOMMANDS_DamagePlayerWithType( ulPlayer, ulArmorPoints, *it ); | |
390 | + else | |
391 | + fullCommand.sendCommandToClients( *it, SVCF_ONLYTHISCLIENT ); | |
392 | + } | |
378 | 393 | } |
379 | 394 | } |
380 | 395 | |
381 | 396 | //***************************************************************************** |
382 | 397 | // |
398 | +void SERVERCOMMANDS_DamagePlayerWithType( ULONG ulPlayer, ULONG ulArmorPoints, ULONG ulPlayerExtra ) | |
399 | +{ | |
400 | + ServerCommands::DamagePlayerWithType command; | |
401 | + command.SetPlayer( &players[ulPlayer] ); | |
402 | + command.SetHealth( players[ulPlayer].health ); | |
403 | + command.SetArmor( ulArmorPoints ); | |
404 | + command.SetDamageType( players[ulPlayer].mo->DamageTypeReceived.GetChars() ); | |
405 | + command.SetAttacker( players[ulPlayer].attacker ); | |
406 | + | |
407 | + command.sendCommandToClients( ulPlayerExtra, SVCF_ONLYTHISCLIENT ); | |
408 | +} | |
409 | + | |
410 | +//***************************************************************************** | |
411 | +// | |
383 | 412 | void SERVERCOMMANDS_KillPlayer( ULONG ulPlayer, AActor *pSource, AActor *pInflictor, FName MOD ) |
384 | 413 | { |
385 | 414 | if ( PLAYER_IsValidPlayer( ulPlayer ) == false ) |
@@ -91,6 +91,7 @@ | ||
91 | 91 | void SERVERCOMMANDS_SpawnPlayer( ULONG ulPlayer, LONG lPlayerState, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0, bool bMorph = false ); |
92 | 92 | void SERVERCOMMANDS_MovePlayer( ULONG ulPlayer, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); |
93 | 93 | void SERVERCOMMANDS_DamagePlayer( ULONG ulPlayer ); |
94 | +void SERVERCOMMANDS_DamagePlayerWithType( ULONG ulPlayer, ULONG ulArmorPoints, ULONG ulPlayerExtra ); | |
94 | 95 | void SERVERCOMMANDS_KillPlayer( ULONG ulPlayer, AActor *pSource, AActor *pInflictor, FName MOD ); |
95 | 96 | void SERVERCOMMANDS_SetPlayerHealth( ULONG ulPlayer, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); |
96 | 97 | void SERVERCOMMANDS_SetPlayerArmor( ULONG ulPlayer, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); |