Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Super Melee for stock PC/CE maps for SAPP
- -- by H® Shaft
- -- Allows players to melee enemy players AND enemy players in vehicles.
- -- Melee to enemy players is instant kill, does not harm yourself or team
- -- Melee to enemy players in vehicles causes vehicle to spill and causes some damage to riders.
- -- WILL work with custom CE maps which have stock weapon sets
- -- don't edit --
- api_version = "1.8.0.0"
- melee = {}
- game_started = false
- function OnScriptLoad()
- local tick_counter_sig = sig_scan("8B2D????????807D0000C644240600")
- if (tick_counter_sig ~= 0) then
- tick_counter_address = read_dword(read_dword(tick_counter_sig + 2)) + 0xC
- register_callback(cb['EVENT_TICK'],"OnTick")
- end
- register_callback(cb['EVENT_GAME_START'], "OnNewGame")
- register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
- register_callback(cb['EVENT_JOIN'], "OnPlayerJoin")
- register_callback(cb['EVENT_LEAVE'], "OnPlayerLeave")
- if get_var(0, "$gt") ~= "n/a" then
- for i=1,16 do
- if player_present(i) then
- melee[i] = 0
- end
- end
- end
- end
- function OnScriptUnload() end
- function OnPlayerJoin(PlayerIndex)
- melee[PlayerIndex] = 0
- rprint(PlayerIndex, "|c Super Melee is active!")
- end
- function OnPlayerLeave(PlayerIndex)
- melee[PlayerIndex] = nil
- end
- function OnNewGame()
- game_started = true
- end
- function OnGameEnd()
- game_started = false
- melee = {}
- end
- function SuperMelee(PlayerIndex, x, y, z)
- if PlayerIndex ~= nil and x ~= nil and y ~= nil and z ~= nil then
- local player_object = get_dynamic_player(PlayerIndex)
- local player_obj_id = read_dword(get_player(PlayerIndex) + 0x34)
- if player_object ~= 0 then
- local grunt = generategrunt(grunt)
- local melee_id = spawn_object("proj", "weapons\\rocket launcher\\rocket", x, y, z+0.7)
- local melee_object = get_object_memory(melee_id)
- if melee_object ~= 0 then
- write_dword(melee_object + 0xC4, player_obj_id)
- write_float(melee_object + 0x74, -0.996)
- write_float(melee_object + 0x70, -5)
- end
- rprint(PlayerIndex, "|c".. grunt)
- end
- end
- end
- function OnTick()
- if game_started then
- -- damage attributes
- local tick_id = read_dword(tick_counter_address)
- local tag_address = read_dword(0x40440000)
- local tag_count = read_word(0x4044000C)
- for A=0,tag_count-1 do
- local tag_id = tag_address + A * 0x20
- if (read_dword(tag_id) == 1785754657) then
- local tag_data = read_dword(tag_id + 0x14)
- if tag_data ~= nil then
- if (read_word(tag_data + 0x1C6) == 4) then -- rocket/explosion damage: values below are based on this
- write_bit(tag_data + 0x1C8, 0, 1) -- doesn't hurt self: 1 = true, 0 = false
- write_bit(tag_data + 0x1C8, 3, 1) -- doesn't hurt team: 1 = true, 0 = false
- write_float(tag_data + 0x1D8, 0.5) -- damage amount: passed to enemy players
- write_float(tag_data + 0x1DC, 0.275) -- damage enemy vehicle riders - 0 damages, 1 = no damage
- write_float(tag_data + 0x1F4, 3) -- force amount: amount of outward force
- elseif (read_word(tag_data + 0x1C6) == 6) then -- melee damage
- write_bit(tag_data + 0x1C8, 7, 1) -- flaming death/instant kill melee
- end
- end
- end
- end
- -- melee detection and activation of super melee
- for PlayerIndex=1,16 do
- if player_alive(PlayerIndex) then
- local player_object = get_dynamic_player(PlayerIndex)
- local player_obj_id = read_dword(get_player(PlayerIndex) + 0x34)
- local x,y,z = read_vector3d(player_object + 0x5C)
- if (player_object ~= 0) then
- -- melee detection
- if not isinvehicle(PlayerIndex) then
- if melee[PlayerIndex] == nil then melee[PlayerIndex] = 0 end
- if melee[PlayerIndex] > 0 then melee[PlayerIndex] = melee[PlayerIndex] - 1 end
- if (melee[PlayerIndex] == 0) and (read_bit(player_object + 0x208, 7) == 1) then
- SuperMelee(PlayerIndex, x, y, z)
- melee[PlayerIndex] = math.floor(1.7*30)
- end
- end
- end
- end
- end
- end
- end
- function isinvehicle(PlayerIndex)
- local player_object = get_dynamic_player(PlayerIndex)
- local vehicleId = read_dword(player_object + 0x11C)
- if vehicleId == 0xFFFFFFFF then
- return false
- else
- return true
- end
- end
- -- when a player melees, this short message is shown to them
- function generategrunt(grunt)
- local grunt = {"Uhn!", "Hiyah!", "Umph!", "Doh!", "Fuuuh!", "Efff!", "Nuh!", "Arrg!", "Ack!", "Smack!", "Thwack!", "Nuh!", "whack!", "Pow!"}
- local gruntcount = #grunt
- local rand_grunt = rand(1, gruntcount+1)
- local grunt_type = string.format("%s", grunt[rand_grunt])
- if grunt_type then
- return grunt_type
- else
- return "Uhn!"
- end
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement