Kills the player weapon_id can be -1 for no weapon
| 757 | // Kills the player |
| 758 | // weapon_id can be -1 for no weapon |
| 759 | void KillPlayer(object *playerobj, object *killer, float damage_amount, int weapon_id) { |
| 760 | // Save the killer |
| 761 | Players[playerobj->id].killer_objnum = killer ? OBJNUM(killer) : 0; |
| 762 | |
| 763 | // Set some stuff |
| 764 | Players[playerobj->id].damage_magnitude = 0; |
| 765 | Players[playerobj->id].edrain_magnitude = 0; |
| 766 | |
| 767 | tOSIRISEventInfo ei; |
| 768 | ei.evt_player_dies.it_handle = playerobj->handle; |
| 769 | Osiris_CallLevelEvent(EVT_PLAYER_DIES, &ei); |
| 770 | |
| 771 | // If single-player, record & initiate death |
| 772 | if (!(Game_mode & GM_MULTI)) { |
| 773 | |
| 774 | if (Demo_flags == DF_RECORDING) |
| 775 | DemoWritePlayerDeath(playerobj, (killer && IS_ROBOT(killer))); |
| 776 | |
| 777 | if (Demo_flags != DF_PLAYBACK) |
| 778 | InitiatePlayerDeath(playerobj, (killer && IS_ROBOT(killer))); |
| 779 | } else if (Netgame.local_role == LR_SERVER) { // Multiplayer & server |
| 780 | |
| 781 | // Call DLL stuff |
| 782 | DLLInfo.me_handle = playerobj->handle; |
| 783 | |
| 784 | if (killer != NULL) |
| 785 | DLLInfo.it_handle = killer->handle; |
| 786 | else |
| 787 | DLLInfo.it_handle = OBJECT_HANDLE_NONE; |
| 788 | |
| 789 | DLLInfo.iParam = weapon_id; |
| 790 | |
| 791 | CallGameDLL(EVT_GAMEPLAYERKILLED, &DLLInfo); |
| 792 | |
| 793 | // pick a fate for this guy |
| 794 | int fate = PlayerChooseDeathFate(playerobj->id, damage_amount, false); |
| 795 | |
| 796 | // Send it to everyone |
| 797 | MultiSendPlayerDead(playerobj->id, fate); |
| 798 | |
| 799 | // Figure out new rankings |
| 800 | GetNewRankings(playerobj, killer); |
| 801 | } |
| 802 | } |
| 803 | |
| 804 | // Applies damage to a player object, returns false if damage wasn't applied due to things like |
| 805 | // invunerability |
no test coverage detected