Advertisement
HR_Shaft

Death Messages V2 for stock PC/CE maps for SAPP

Mar 3rd, 2016
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.29 KB | None | 0 0
  1. -- Death Messages V2 for stock PC/CE maps for SAPP
  2. -- by H® Shaft
  3.  
  4. -- V2 Changelog: added melee damage variable, and fixed/edited backtap
  5.  
  6. -- Script will show how players were killed/died: Normal death messages are blocked (no chat spam), examples :
  7. -- "H® Shaft was blasted by sehé°°'s banshee plasma cannon."
  8. -- "H® Shaft was blown-up by sehé°°'s's frag grenade."
  9. -- "H® Shaft was shot by Btcc22's sniper rifle."
  10. -- "H® Shaft was melee'd by Btcc22!"
  11. -- Will tell Killer and Victim if they were killed by Headshot (pistol and sniper only) "BOOM! You were headshot! by H® Shaft"
  12. -- Will show when a player died by: Falling, by Vehicle or Team Change, will not show if killed by the server
  13. -- Will show player their combination kills, and announce to everyone your sprees: "H® Shaft is on a Killing Spree!"
  14. -- Allows server admins to turn fall damage on/off PER map: see LoadDefaults() true, fall damage is on, false it is off (line 416)
  15.  
  16. -- specify the amount of damage done by melee or backtap: 0 = disable melee kill, 1 = normal, 2 = double, 3 = triple, 4 = quadruple
  17. melee_damage = 1
  18.  
  19. -- don't edit --
  20. game_started = false
  21. team_play = false
  22. last_damage = {}
  23. head_shot = {}
  24. back_tap = {}
  25. killed_by_nothing = {}
  26. api_version = "1.9.0.0"
  27.  
  28. function OnScriptLoad()
  29.     register_callback(cb['EVENT_GAME_START'], "OnNewGame")
  30.     register_callback(cb['EVENT_PRESPAWN'],"OnPlayerPreSpawn")
  31.     register_callback(cb['EVENT_DAMAGE_APPLICATION'], "OnDamageApplication")
  32.     register_callback(cb['EVENT_DIE'], "OnPlayerDie")
  33.     register_callback(cb['EVENT_KILL'], "OnPlayerKill")
  34.     register_callback(cb['EVENT_TEAM_SWITCH'],"OnTeamSwitch")  
  35.     register_callback(cb['EVENT_GAME_END'],"OnGameEnd")    
  36.     register_callback(cb['EVENT_LEAVE'], "OnPlayerLeave")
  37.     disable_killmsg_addr = sig_scan("8B42348A8C28D500000084C9") + 3
  38.     original_code_1 = read_dword(disable_killmsg_addr)
  39.     safe_write(true)
  40.     write_dword(disable_killmsg_addr, 0x03EB01B1)
  41.     safe_write(false)  
  42.  
  43.     if get_var(0, "$gt") ~= "n/a" then 
  44.         game_started = true
  45.         team_play = getteamplay()
  46.         GetMetaIDs()
  47.         LoadDefaults()
  48.         map_name = get_var(1,"$map")
  49.         for i=1,16 do
  50.             if player_present(i) then
  51.                 last_damage[i] = 0
  52.                 killed_by_nothing[i] = false
  53.                 head_shot[i] = false
  54.                 back_tap[i] = false
  55.             end
  56.         end    
  57.     end    
  58. end
  59.  
  60. function OnScriptUnload()
  61.     safe_write(true)
  62.     write_dword(disable_killmsg_addr, original_code_1)
  63.     safe_write(false)
  64.     killed_by_nothing = {}
  65.     last_damage = {}
  66.     head_shot = {}
  67.     back_tap = {}
  68. end
  69.  
  70. function OnPlayerPreSpawn(PlayerIndex)
  71.     last_damage[PlayerIndex] = 0
  72.     head_shot[PlayerIndex] = false
  73.     back_tap[PlayerIndex] = false
  74. end
  75.  
  76. function OnNewGame()
  77.     game_started = true
  78.     map_name = get_var(1,"$map")
  79.     team_play = getteamplay()
  80.     GetMetaIDs()
  81.     LoadDefaults() 
  82.     for i=1,16 do
  83.         if player_present(i) then  
  84.             last_damage[i] = 0
  85.             killed_by_nothing[i] = false
  86.             head_shot[i] = false
  87.             back_tap[i] = false
  88.         end
  89.     end    
  90. end
  91.  
  92. function OnPlayerLeave(PlayerIndex)
  93.     last_damage[PlayerIndex] = nil
  94.     killed_by_nothing[PlayerIndex] = nil
  95.     head_shot[PlayerIndex] = nil
  96.     back_tap[PlayerIndex] = false  
  97. end
  98.  
  99. function OnGameEnd()
  100.     game_started = false
  101.     for i=1,16 do
  102.         if player_present(i) then      
  103.             last_damage[i] = 0
  104.             killed_by_nothing[i] = false
  105.             head_shot[i] = false
  106.             back_tap[i] = false
  107.         end
  108.     end
  109. end
  110.  
  111. function OnPlayerDie(PlayerIndex, KillerIndex)
  112.     -- Killer Index is: -- falling = -1, server = -1, team-switch = -1, vehicle = 0, other players = 1 or greater
  113.     if (game_started == true) then
  114.         local vname = get_var(PlayerIndex, "$name")
  115.         local vteam = get_var(PlayerIndex, "$team")
  116.         local killer = tonumber(KillerIndex)
  117.  
  118.         if (killer == -1) then
  119.             if last_damage[PlayerIndex] == 0 then
  120.                 killed_by_nothing[PlayerIndex] = true
  121.             elseif last_damage[PlayerIndex] == falling_damage or last_damage[PlayerIndex] == distance_damage then
  122.                 say_all(vname.. " fell and died.")
  123.                 last_damage[PlayerIndex] = 0
  124.                 killed_by_nothing[PlayerIndex] = false             
  125.             end
  126.            
  127.         elseif (killer == 0) then
  128.             if last_damage[PlayerIndex] == veh_damage then
  129.                 say_all(vname.. " was killed by a vehicle.")
  130.                 last_damage[PlayerIndex] = 0           
  131.             end
  132.            
  133.         elseif (killer == nil) then
  134.             if last_damage[PlayerIndex] == 0 then
  135.                 say_all(vname.. " was killed by the guardians.")
  136.             end
  137.            
  138.         elseif (killer > 0) then
  139.             local kname = get_var(KillerIndex, "$name")
  140.             local kteam = get_var(KillerIndex, "$team")
  141.             if PlayerIndex ~= KillerIndex  then
  142.                 if last_damage[PlayerIndex] == veh_damage then
  143.                     if isinvehicle(KillerIndex) then
  144.                         say_all(vname.. " was run over by " .. kname .. ".")
  145.                     else
  146.                         say_all(vname.. " was killed by a vehicle.")
  147.                     end
  148.                 elseif last_damage[PlayerIndex] == banshee_bolt then
  149.                     say_all(vname.. " was shot by " .. kname .. "'s banshee guns. ")
  150.                 elseif last_damage[PlayerIndex] == banshee_explode then
  151.                     say_all(vname.. " was blasted by " .. kname .. "'s banshee plasma cannon. ")
  152.                 elseif last_damage[PlayerIndex] == turret_bolt then
  153.                     say_all(vname.. " was shot by " .. kname .. "'s turret. ")
  154.                 elseif last_damage[PlayerIndex] == ghost_bolt then
  155.                     say_all(vname.. " was shot by " .. kname .. "'s ghost guns. ")
  156.                 elseif last_damage[PlayerIndex] == tank_shell then
  157.                     say_all(vname.. " was blasted by " .. kname .. "'s tank shell. ")  
  158.                 elseif last_damage[PlayerIndex] == tank_bullet then
  159.                     say_all(vname.. " was shot by " .. kname .. "'s tank guns. ")
  160.                 elseif last_damage[PlayerIndex] == chain_bullet then
  161.                     say_all(vname.. " was shot by " .. kname .. "'s chain gun. ")
  162.                 elseif last_damage[PlayerIndex] == assault_bullet then
  163.                     say_all(vname.. " was shot by " .. kname .. "'s assault rifle. ")
  164.                 elseif last_damage[PlayerIndex] == flame_explode then
  165.                     say_all(vname.. " was toasted by " .. kname .. "'s flame-thrower. ")
  166.                 elseif last_damage[PlayerIndex] == frag_explode then
  167.                     say_all(vname.. " was blown-up by " .. kname .. "'s frag grenade. ")
  168.                 elseif last_damage[PlayerIndex] == needle_detonate then
  169.                     say_all(vname.. " was shot by " .. kname .. "'s needler. ")
  170.                 elseif last_damage[PlayerIndex] == needle_explode then
  171.                     say_all(vname.. " was shot by " .. kname .. "'s needler. ")
  172.                 elseif last_damage[PlayerIndex] == needle_impact then
  173.                     say_all(vname.. " was shot by " .. kname .. "'s needler. ")    
  174.                 elseif last_damage[PlayerIndex] == pistol_bullet then
  175.                     say_all(vname.. " was shot by " .. kname .. "'s pistol. ")
  176.                     if head_shot[PlayerIndex] then  -- only the pistol and sniper actually cause headshots
  177.                         say(PlayerIndex, "BOOM! You were headshot! by " .. kname)
  178.                         say(KillerIndex, "BOOM! headshot!")
  179.                         head_shot[PlayerIndex] = false
  180.                     end                
  181.                 elseif last_damage[PlayerIndex] == plasma_attach then
  182.                     say_all(vname.. " was stickied by " .. kname .. "'s plasma grenade! ") 
  183.                 elseif last_damage[PlayerIndex] == plasma_explode then
  184.                     say_all(vname.. " was blown-up by " .. kname .. "'s plasma grenade. ")
  185.                 elseif last_damage[PlayerIndex] == ppistol_bolt then
  186.                     say_all(vname.. " was shot by " .. kname .. "'s plasma pistol. ")
  187.                 elseif last_damage[PlayerIndex] == ppistol_charged then
  188.                     say_all(vname.. " was shot by " .. kname .. "'s plasma pistol. ")
  189.                 elseif last_damage[PlayerIndex] == prifle_bolt then
  190.                     say_all(vname.. " was shot by " .. kname .. "'s plasma rifle. ")
  191.                 elseif last_damage[PlayerIndex] == pcannon_explode then
  192.                     say_all(vname.. " was shot by " .. kname .. "'s plasma cannon. ")
  193.                 elseif last_damage[PlayerIndex] == rocket_explode then
  194.                     if isinvehicle(KillerIndex) then
  195.                         say_all(vname.. " was blown-up by " .. kname .. "'s warthog rocket. ")
  196.                     else   
  197.                         say_all(vname.. " was blown-up by " .. kname .. "'s rocket. ")
  198.                     end
  199.                 elseif last_damage[PlayerIndex] == shotgun_pellet then
  200.                     say_all(vname.. " was shot by " .. kname .. "'s shotgun. ")
  201.                 elseif last_damage[PlayerIndex] == sniper_bullet then
  202.                     say_all(vname.. " was shot by " .. kname .. "'s sniper rifle. ")
  203.                     if head_shot[PlayerIndex] then -- only the pistol and sniper actually cause headshots
  204.                         say(PlayerIndex, "BOOM! You were headshot! by " .. kname)
  205.                         say(KillerIndex, "BOOM! headshot!")
  206.                         head_shot[PlayerIndex] = false
  207.                     end
  208.                 elseif last_damage[PlayerIndex] == assault_melee or
  209.                     last_damage[PlayerIndex] == assault_melee or
  210.                     last_damage[PlayerIndex] == ball_melee or
  211.                     last_damage[PlayerIndex] == flag_melee or
  212.                     last_damage[PlayerIndex] == flame_melee or
  213.                     last_damage[PlayerIndex] == needle_melee or
  214.                     last_damage[PlayerIndex] == pistol_melee or
  215.                     last_damage[PlayerIndex] == ppistol_melee or
  216.                     last_damage[PlayerIndex] == prifle_melee or
  217.                     last_damage[PlayerIndex] == pcannon_melee or
  218.                     last_damage[PlayerIndex] == rocket_melee or
  219.                     last_damage[PlayerIndex] == shotgun_melee or
  220.                     last_damage[PlayerIndex] == sniper_melee then              
  221.                     say_all(vname.. " was melee'd by " .. kname .. "!")
  222.                     back_tap[PlayerIndex] = false              
  223.                 elseif back_tap[PlayerIndex] then
  224.                     say_all(vname.. " was melee'd by " .. kname .. "!")
  225.                     back_tap[PlayerIndex] = false
  226.                 elseif last_damage[PlayerIndex] == 0 then
  227.                     say_all(vname.. " was killed by " .. kname .. ".") 
  228.                 end
  229.                
  230.             elseif PlayerIndex == KillerIndex then
  231.                 say_all(vname.. " committed suicide, derp.")
  232.                 if not team_play then
  233.                     if read_dword(get_player(PlayerIndex) + 0xC0) > 0 then
  234.                         write_dword(get_player(PlayerIndex) + 0xC0, 0)
  235.                     end
  236.                 end
  237.                
  238.             elseif kteam == vteam and PlayerIndex ~= KillerIndex then
  239.                 if team_play then
  240.                     say_all(vname.. " was betrayed by " .. kname .. ".")
  241.                 end
  242.                
  243.             else
  244.                 say_all(vname.. " was killed by the guardians. ")          
  245.             end
  246.         end
  247.         last_damage[PlayerIndex] = 0
  248.         head_shot[PlayerIndex] = false
  249.         back_tap[PlayerIndex] = false
  250.     end
  251. end
  252.  
  253. function OnTeamSwitch(PlayerIndex)
  254.     if (game_started == true) then
  255.         if team_play then
  256.             if (killed_by_nothing[PlayerIndex] == true) then
  257.                 say_all(get_var(PlayerIndex,"$name") .. " switched to the " .. get_var(PlayerIndex,"$team") .. " team.")       
  258.                 killed_by_nothing[PlayerIndex] = false             
  259.             end    
  260.         end
  261.     end
  262. end
  263.  
  264. function OnDamageApplication(PlayerIndex, CauserIndex, MetaID, Damage, HitString, Backtap)
  265.     if (game_started == true) then
  266.         if (HitString == "head") then
  267.             head_shot[PlayerIndex] = true
  268.         end
  269.         if (Backtap == true) then
  270.             back_tap[PlayerIndex] = true
  271.             return true, Damage * melee_damage
  272.         end
  273.         if MetaID == assault_melee or
  274.             MetaID == assault_melee or
  275.             MetaID == ball_melee or
  276.             MetaID == flag_melee or
  277.             MetaID == flame_melee or
  278.             MetaID == needle_melee or
  279.             MetaID == pistol_melee or
  280.             MetaID == ppistol_melee or
  281.             MetaID == prifle_melee or
  282.             MetaID == pcannon_melee or
  283.             MetaID == rocket_melee or
  284.             MetaID == shotgun_melee or
  285.             MetaID == sniper_melee then
  286.             return true, Damage * melee_damage
  287.         end
  288.         if MetaID == falling_damage then
  289.             last_damage[PlayerIndex] = falling_damage
  290.             if not fall_damage[map_name] then
  291.                 return true, 0
  292.             end
  293.         elseif MetaID == distance_damage then
  294.             last_damage[PlayerIndex] = distance_damage
  295.             if not fall_damage[map_name] then
  296.                 return true, 0
  297.             end
  298.         end    
  299.         last_damage[PlayerIndex] = MetaID  
  300.     end
  301. end
  302.  
  303. function GetMetaIDs()
  304.     falling_damage = read_dword(lookup_tag("jpt!", "globals\\falling") + 12)
  305.     distance_damage = read_dword(lookup_tag("jpt!", "globals\\distance") + 12)
  306.     veh_damage = read_dword(lookup_tag("jpt!", "globals\\vehicle_collision") + 12)
  307.     banshee_bolt = read_dword(lookup_tag("jpt!", "vehicles\\banshee\\banshee bolt") + 12)
  308.     banshee_explode = read_dword(lookup_tag("jpt!", "vehicles\\banshee\\mp_fuel rod explosion") + 12)
  309.     turret_bolt = read_dword(lookup_tag("jpt!", "vehicles\\c gun turret\\mp bolt") + 12)
  310.     ghost_bolt = read_dword(lookup_tag("jpt!", "vehicles\\ghost\\ghost bolt") + 12)
  311.     tank_shell = read_dword(lookup_tag("jpt!", "vehicles\\scorpion\\shell explosion") + 12)
  312.     tank_bullet = read_dword(lookup_tag("jpt!", "vehicles\\scorpion\\bullet") + 12)
  313.     chain_bullet = read_dword(lookup_tag("jpt!", "vehicles\\warthog\\bullet") + 12)
  314.     assault_bullet = read_dword(lookup_tag("jpt!", "weapons\\assault rifle\\bullet") + 12)
  315.     assault_melee = read_dword(lookup_tag("jpt!", "weapons\\assault rifle\\melee") + 12)
  316.     ball_melee = read_dword(lookup_tag("jpt!", "weapons\\ball\\melee") + 12)
  317.     flag_melee = read_dword(lookup_tag("jpt!", "weapons\\flag\\melee") + 12)
  318.     flame_explode = read_dword(lookup_tag("jpt!", "weapons\\flamethrower\\explosion") + 12)
  319.     flame_melee = read_dword(lookup_tag("jpt!", "weapons\\flamethrower\\melee") + 12)
  320.     frag_explode = read_dword(lookup_tag("jpt!", "weapons\\frag grenade\\explosion") + 12)
  321.     needle_detonate = read_dword(lookup_tag("jpt!", "weapons\\needler\\detonation damage") + 12)
  322.     needle_explode = read_dword(lookup_tag("jpt!", "weapons\\needler\\explosion") + 12)
  323.     needle_impact = read_dword(lookup_tag("jpt!", "weapons\\needler\\impact damage") + 12)
  324.     needle_melee = read_dword(lookup_tag("jpt!", "weapons\\needler\\melee") + 12)
  325.     pistol_bullet = read_dword(lookup_tag("jpt!", "weapons\\pistol\\bullet") + 12)
  326.     pistol_melee = read_dword(lookup_tag("jpt!", "weapons\\pistol\\melee") + 12)
  327.     plasma_attach = read_dword(lookup_tag("jpt!", "weapons\\plasma grenade\\attached") + 12)
  328.     plasma_explode = read_dword(lookup_tag("jpt!", "weapons\\plasma grenade\\explosion") + 12)
  329.     ppistol_bolt = read_dword(lookup_tag("jpt!", "weapons\\plasma pistol\\bolt") + 12)
  330.     ppistol_charged = read_dword(lookup_tag("jpt!", "weapons\\plasma rifle\\charged bolt") + 12)
  331.     ppistol_melee = read_dword(lookup_tag("jpt!", "weapons\\plasma pistol\\melee") + 12)
  332.     prifle_bolt = read_dword(lookup_tag("jpt!", "weapons\\plasma rifle\\bolt") + 12)
  333.     prifle_melee = read_dword(lookup_tag("jpt!", "weapons\\plasma rifle\\melee") + 12)
  334.     pcannon_explode = read_dword(lookup_tag("jpt!", "weapons\\plasma_cannon\\effects\\plasma_cannon_explosion") + 12)
  335.     pcannon_melee = read_dword(lookup_tag("jpt!", "weapons\\plasma_cannon\\effects\\plasma_cannon_melee") + 12)
  336.     rocket_explode = read_dword(lookup_tag("jpt!", "weapons\\rocket launcher\\explosion") + 12)
  337.     rocket_melee = read_dword(lookup_tag("jpt!", "weapons\\rocket launcher\\melee") + 12)
  338.     shotgun_pellet = read_dword(lookup_tag("jpt!", "weapons\\shotgun\\pellet") + 12)
  339.     shotgun_melee = read_dword(lookup_tag("jpt!", "weapons\\shotgun\\melee") + 12)
  340.     sniper_bullet = read_dword(lookup_tag("jpt!", "weapons\\sniper rifle\\sniper bullet") + 12)
  341.     sniper_melee = read_dword(lookup_tag("jpt!", "weapons\\sniper rifle\\melee") + 12)
  342. end
  343.  
  344. function OnPlayerKill(PlayerIndex, VictimIndex)
  345.     local combo = tonumber(get_var(PlayerIndex, "$combo"))
  346.     local spree = tonumber(get_var(PlayerIndex, "$streak"))
  347.     local Name = get_var(PlayerIndex, "$name")
  348.    
  349.     if combo == 2 then
  350.         rprint(PlayerIndex, "|r" .. "Double Kill!")
  351.     elseif combo == 3 then
  352.         rprint(PlayerIndex, "|r" .. "Triple Kill!")
  353.     elseif combo == 4 then
  354.         rprint(PlayerIndex, "|r" .. "Overkill!")   
  355.     elseif combo == 5 then
  356.         rprint(PlayerIndex, "|r" .. "Killtacular!")
  357.     elseif combo == 6 then
  358.         rprint(PlayerIndex, "|r" .. "Killtrocity!")
  359.     elseif combo == 7 then
  360.         rprint(PlayerIndex, "|r" .. "Killimanjaro!")   
  361.     elseif combo == 8 then
  362.         rprint(PlayerIndex, "|r" .. "Killtastrophe!")  
  363.     elseif combo == 9 then
  364.         rprint(PlayerIndex, "|r" .. "Killpocalypse!")  
  365.     elseif combo == 10 then
  366.         rprint(PlayerIndex, "|r" .. "Killionaire!")
  367.     end
  368.    
  369.     if spree == 5 then
  370.         AnnounceSpree(Name, "is on a Killing Spree!")
  371.     elseif spree == 10 then
  372.         AnnounceSpree(Name, "is in a Killing Frenzy!")
  373.     elseif spree == 15 then
  374.         AnnounceSpree(Name, "just got a Running Riot!")
  375.     elseif spree == 20 then
  376.         AnnounceSpree(Name, "is on a Rampage!")
  377.     elseif spree == 25 then
  378.         AnnounceSpree(Name, "is Untouchable!")
  379.     elseif spree == 30 then
  380.         AnnounceSpree(Name, "is Inconceivable!")
  381.     elseif spree == 35 then
  382.         AnnounceSpree(Name, "is Unfrigginbelievable!")
  383.     elseif spree == 40 then
  384.         AnnounceSpree(Name, "is running AMOK!")
  385.     elseif spree >= 50 then
  386.         AnnounceSpree(Name, "is going BESERK!")    
  387.     end
  388. end
  389.  
  390. function AnnounceSpree(Name, Message)
  391.     for i = 1,16 do
  392.         if player_present(i) then
  393.             rprint(i, "|r" .. "" .. Name .. " " .. Message)
  394.         end
  395.     end
  396. end
  397.  
  398. function isinvehicle(PlayerIndex)  
  399.     local player_object = get_dynamic_player(PlayerIndex)
  400.     local vehicleId = read_dword(player_object + 0x11C)
  401.     if vehicleId == 0xFFFFFFFF then
  402.         return false
  403.     else
  404.         return true
  405.     end
  406. end
  407.  
  408. function getteamplay()
  409.     if get_var(0,"$ffa") == "0" then
  410.         return true
  411.     else
  412.         return false
  413.     end
  414. end
  415.  
  416. function LoadDefaults()
  417.     -- turn fall damage on (true) or off (false) for each map,
  418.     -- note: damnation & gephyrophobia players can get stuck on bottom if it's turned off
  419.     fall_damage = {
  420.         ["beavercreek"] = true,
  421.         ["bloodgulch"] = true,
  422.         ["boardingaction"] = true,
  423.         ["carousel"] = true,
  424.         ["chillout"] = true,
  425.         ["damnation"] = true,
  426.         ["dangercanyon"] = true,
  427.         ["deathisland"] = true,
  428.         ["gephyrophobia"] = true,
  429.         ["hangemhigh"] = true,
  430.         ["icefields"] = true,
  431.         ["infinity"] = true,
  432.         ["longest"] = true,
  433.         ["prisoner"] = true,
  434.         ["putput"] = true,
  435.         ["ratrace"] = true,
  436.         ["sidewinder"] = true,
  437.         ["timberland"] = true,
  438.         ["wizard"] = true
  439.     }
  440. end
  441.  
  442. function OnError(Message)
  443.     print(debug.traceback())
  444. end
  445.  
  446. -- Created by H® Shaft
  447. -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement