Advertisement
Combreal

Melee.lua

Feb 4th, 2014
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.46 KB | None | 0 0
  1. -- Inspired from TelyX, A§H»Wizard, H»Kennan & AelitePrime 's work --
  2.                         -- For the skull weapon --
  3.  
  4.  
  5.     skull = {}
  6.     frag_count = 0
  7.     plasma_count = 0
  8.     max_health = 0.1
  9.  
  10.  
  11. function GetRequiredVersion() return 200 end
  12.  
  13. function OnScriptLoad(processid, game, persistent) end
  14.  
  15. function OnNewGame(map)
  16.     LoadTags()
  17. end
  18.  
  19. function OnPlayerSpawn(player)
  20.     writefloat(getobject(getplayerobjectid(player)) + 0xE0, max_health)
  21. end
  22.  
  23. function OnPlayerSpawnEnd(player, m_objectId)
  24.     local hash = gethash(player)
  25.     skull[hash] = skull[hash] or {}
  26.     local m_object = getobject(m_objectId)
  27.     if m_object then
  28.         writebyte(m_object + 0x31E, frag_count)
  29.         writebyte(m_object + 0x31F, plasma_count)
  30.     end
  31.     for i = 0,3 do
  32.         local m_object = getobject(m_objectId)
  33.         if m_object then
  34.             local weapID = readdword(m_object + 0x2F8 + i*4)
  35.             local weap = getobject(weapID)
  36.             if weap then
  37.                 destroyobject(weapID)
  38.             end
  39.         end
  40.     end
  41.     skull[hash].objId = createobject(oddball_tag_id, 0, 1, false, 0, 0, 0)
  42.     assignweapon(player, skull[hash].objId)
  43. end
  44.  
  45. function OnObjectCreationAttempt(mapId, parentId, player)
  46.     return checkObject(mapId)
  47. end
  48.  
  49. function OnObjectInteraction(player, objId, mapId)
  50.     if mapId == fragnade_tag_id or plasmanade_tag_id or oddball_tag_id then
  51.             return false
  52.     end
  53.     return true
  54. end
  55.  
  56.  
  57. function OnDamageLookup(receiving, causing, mapId, tagdata)
  58.     if mapId == global_fallingId then
  59.         return false
  60.     elseif mapId == oddball_melee_tag_id then
  61.         writefloat(tagdata, 0x1D0, 500)
  62.         writefloat(tagdata, 0x1D4, 500)
  63.         writefloat(tagdata, 0x1D8, 500)
  64.     end
  65.     if causing then
  66.         local c_object = getobject(causing)
  67.         if c_object then
  68.             local causer = objectaddrtoplayer(c_object)
  69.             if causer then
  70.                 if isinvehicle(causer) then
  71.                     local m_vehicleId = getplayervehicleid(causer)
  72.                     if m_vehicleId then
  73.                         local m_vehicle = getobject(m_vehicleId)
  74.                         local driver = getdriverplayer(m_vehicle)
  75.                         if driver == causer then
  76.                             return false
  77.                         end
  78.                     end
  79.                 end
  80.             end
  81.         end
  82.     end
  83. end
  84.  
  85. function OnPlayerKill(killer, victim, mode)
  86.     if mode == 2 then
  87.         local victim_kills = readword (getplayer(victim), 0x9C)
  88.         victim_kills = victim_kills + 1
  89.         --guardianed = getplayer(victim)
  90.         writeword(getplayer(victim) + 0x9C, victim_kills)
  91.         privatesay(getplayer(victim), "Damned guardians, here earn your frag")
  92.     end
  93.     local m_player = getplayer(victim)
  94.     if m_player == nil then
  95.         return
  96.     end
  97.     local m_object = getobject(readdword(m_player +  0x34))
  98.     if m_object then
  99.         for i = 0,3 do
  100.             local weapID = readdword(m_object + 0x2F8 + i*4)
  101.             if weapID then
  102.                 local weap = getobject(weapID)
  103.                 if weap then
  104.                     destroyobject(weapID)
  105.                 end
  106.             end
  107.         end
  108.     end
  109. end
  110.  
  111. function OnClientUpdate(player)
  112.     local hash = gethash(player)
  113.     local m_player = getplayer(player)
  114.     if m_player == nil then
  115.         return
  116.     end
  117.     local m_objectId = getplayerobjectid(player)
  118.     if m_objectId == nil then
  119.         return
  120.     end
  121.     local m_object = getobject(m_objectId)
  122.     if m_object then
  123.         local shooting = readbit(m_object + 0x209, 4)
  124.         local nading2 = readbit(m_object + 0x209, 2)
  125.         local nading = readbit(m_object + 0x209, 3)
  126.         if shooting == true or nading == true then
  127.             weapID = skull[hash].objId
  128.             if m_player then
  129.                 if weapID then
  130.                     if getobject(weapID) then
  131.                         assignweapon(player, weapID)
  132.                     end
  133.                 end
  134.             end
  135.         end
  136.     end
  137. end
  138.  
  139. function checkObject(mapId)
  140.     if mapId == "nil" then
  141.         return false
  142.     end
  143.     return oddball_tag_id
  144. end
  145.  
  146. function LoadTags()
  147.     -- Equipment
  148.     camouflage_tag_id = gettagid("eqip", "powerups\\active camouflage")
  149.     healthpack_tag_id = gettagid("eqip", "powerups\\health pack")
  150.     overshield_tag_id = gettagid("eqip", "powerups\\over shield")
  151.     doublespeed_tag_id = gettagid("eqip", "powerups\\double speed")
  152.     fullspec_tag_id = gettagid("eqip", "powerups\\full-spectrum vision")
  153.     fragnade_tag_id = gettagid("eqip", "weapons\\frag grenade\\frag grenade")
  154.     plasmanade_tag_id = gettagid("eqip", "weapons\\plasma grenade\\plasma grenade")
  155.     rifleammo_tag_id = gettagid("eqip", "powerups\\assault rifle ammo\\assault rifle ammo")
  156.     needlerammo_tag_id = gettagid("eqip", "powerups\\needler ammo\\needler ammo")
  157.     pistolammo_tag_id = gettagid("eqip", "powerups\\pistol ammo\\pistol ammo")
  158.     rocketammo_tag_id = gettagid("eqip", "powerups\\rocket launcher ammo\\rocket launcher ammo")
  159.     shotgunammo_tag_id = gettagid("eqip", "powerups\\shotgun ammo\\shotgun ammo")
  160.     sniperammo_tag_id = gettagid("eqip", "powerups\\sniper rifle ammo\\sniper rifle ammo")
  161.     flameammo_tag_id = gettagid("eqip", "powerups\\flamethrower ammo\\flamethrower ammo")
  162.     -- Weapons
  163.     assaultrifle_tag_id = gettagid("weap", "weapons\\assault rifle\\assault rifle")
  164.     oddball_tag_id = gettagid("weap", "weapons\\ball\\ball")
  165.     flag_tag_id = gettagid("weap", "weapons\\flag\\flag")
  166.     flamethrower_tag_id = gettagid("weap", "weapons\\flamethrower\\flamethrower")
  167.     gravityrifle_tag_id = gettagid("weap", "weapons\\gravity rifle\\gravity rifle")
  168.     needler_tag_id = gettagid("weap", "weapons\\needler\\mp_needler")
  169.     pistol_tag_id = gettagid("weap", "weapons\\pistol\\pistol")
  170.     plasmapistol_tag_id = gettagid("weap", "weapons\\plasma pistol\\plasma pistol")
  171.     plasmarifle_tag_id = gettagid("weap", "weapons\\plasma rifle\\plasma rifle")
  172.     plasmacannon_tag_id = gettagid("weap", "weapons\\plasma_cannon\\plasma_cannon")
  173.     rocketlauncher_tag_id = gettagid("weap", "weapons\\rocket launcher\\rocket launcher")
  174.     shotgun_tag_id = gettagid("weap", "weapons\\shotgun\\shotgun")
  175.     sniper_tag_id = gettagid("weap", "weapons\\sniper rifle\\sniper rifle")
  176.     -- Globals
  177.     global_distanceId = gettagid("jpt!", "globals\\distance")
  178.     global_fallingId = gettagid("jpt!", "globals\\falling")
  179.     -- Others
  180.     assaultrifle_melee_tag_id = gettagid("jpt!", "weapons\\assault rifle\\melee")
  181.     flag_melee_tag_id = gettagid("jpt!", "weapons\\flag\\melee")
  182.     flamethrower_melee_tag_id = gettagid("jpt!", "weapons\\flamethrower\\melee")
  183.     needler_melee_tag_id = gettagid("jpt!", "weapons\\ball\\melee")
  184.     pistol_melee_tag_id = gettagid("jpt!", "weapons\\pistol\\melee")
  185.     plasmapistol_melee_tag_id = gettagid("jpt!", "weapons\\plasma pistol\\melee")
  186.     plasmarifle_melee_tag_id = gettagid("jpt!", "weapons\\plasma rifle\\melee")
  187.     plasmacannon_melee_tag_id = gettagid("jpt!", "weapons\\effects\\plasma_cannon_melee")
  188.     rocketlauncher_melee_tag_id = gettagid("jpt!", "weapons\\rocket launcher\\melee")
  189.     shotgun_melee_tag_id = gettagid("jpt!", "weapons\\shotgun\\melee")
  190.     sniper_melee_tag_id = gettagid("jpt!", "weapons\\sniper rifle\\melee")
  191. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement