Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Driver Bonus v2 for Team Race for SAPP version 10+
- -- by H® Shaft
- -- Designed for TEAM RACE, Halo PC/CE, for SAPP version 10
- -- * NOT compatibible with earlier sapp versions
- -- Update: Added driver must have a gunner to get a driver bonus.
- -- When a DRIVER of a multi-seat vehicle 'scores a lap' in a team race game, they will be given 2 ASSISTS and a message is shown to all (ASSIST_MESSAGE).
- -- When the DRIVER reaches 10 assists they will be given an extra +1 SCORE/lap and a message is shown to all (SCORE_MESSAGE) and their assists are reset to 0.
- -- will only work if player is in a multi-seat vehicle, such as a warthog. Will not work in solo vehicles: tanks, ghosts, banshees, turrets, jets, etc.
- -- Why? This will help balance out driver/gunner scoring. Commonly in race, the GUNNER, and NOT the DRIVER, will win the game when they have the SAME score.
- -- If the game is one point away from being won, this does not ensure the driver (and not the gunner) gets the lap - halo decides that.
- -- Assist message shown to all when a driver in a multi-seat vehicle receives an ASSIST driving bonus.
- ASSIST_MESSAGE = "was given +2 ASSISTS driving bonus! Get 10 for +1 score!"
- -- Score message shown to all when a driver in a multi-seat vehicle receives a SCORE driving bonus.
- SCORE_MESSAGE = "was given +1 SCORE/lap driving bonus!"
- -- don't edit --
- api_version = "1.10.0.0"
- function OnScriptLoad()
- register_callback(cb['EVENT_GAME_START'], "OnNewGame")
- register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
- register_callback(cb['EVENT_SCORE'], "OnPlayerScore")
- if get_var(0, "$gt") ~= "n/a" then
- game_started = true
- team_play = getteamplay()
- else
- game_started = false
- team_play = false
- end
- end
- function OnNewGame()
- game_started = true
- team_play = getteamplay()
- end
- function OnGameEnd()
- game_started = false
- end
- function OnPlayerScore(PlayerIndex)
- if (get_var(0,"$gt") == "race") and (team_play == true) then
- if isinvehicle(PlayerIndex) and PlayerIsDriver(PlayerIndex) then
- local player_object = get_dynamic_player(PlayerIndex)
- if (player_object ~= 0) then
- local vehicleId = read_dword(player_object + 0x11C)
- local veh_name = string.lower(GetPlayerVehicleTagName(PlayerIndex))
- if (veh_name ~= nil) then
- if string.find(veh_name, "snowh") or string.find(veh_name, "civi") or string.find(veh_name, "wart") or
- string.find(veh_name, "hawg") or string.find(veh_name, "puma") or string.find(veh_name, "booger") or
- string.find(veh_name, "gaus") then
- local driver = get_var(PlayerIndex,"$name")
- local Assists = tonumber(get_var(PlayerIndex, "$assists"))
- if (Assists +2 <= 9) and VehicleHasGunner(vehicleId) then
- execute_command("assists me +2", PlayerIndex)
- rprint(PlayerIndex, "|rDRIVER BONUS: +2 assists!")
- rprint(PlayerIndex, " ")
- for i=1,16 do
- if player_present(i) then
- say(i, driver .. " " .. ASSIST_MESSAGE)
- end
- end
- elseif (Assists +2 >= 10) and VehicleHasGunner(vehicleId) then
- execute_command("score me +1", PlayerIndex)
- rprint(PlayerIndex, "|rDRIVER BONUS: +1 score!")
- rprint(PlayerIndex, " ")
- execute_command("assists me 0", PlayerIndex)
- for i=1,16 do
- if player_present(i) then
- say(i, driver .. " " .. SCORE_MESSAGE)
- end
- end
- end
- end
- end
- end
- end
- end
- end
- function getteamplay()
- if get_var(0,"$ffa") == "0" then
- return true
- else
- return false
- end
- end
- function isinvehicle(PlayerIndex)
- local player_object = get_dynamic_player(PlayerIndex)
- if player_object ~= 0 then
- local vehicleId = read_dword(player_object + 0x11C)
- if vehicleId == 0xFFFFFFFF then
- return false
- else
- return true
- end
- else
- return false
- end
- end
- function PlayerIsDriver(PlayerIndex)
- if (player_alive(PlayerIndex) == false) then return false end
- local player_object = get_dynamic_player(PlayerIndex)
- local player_object_id = read_dword(get_player(PlayerIndex) + 0x34)
- local vehicleId = read_dword(player_object + 0x11C)
- if (vehicleId == 0xFFFFFFFF) then return false end
- local obj_id = get_object_memory(vehicleId)
- return read_dword(obj_id + 0x324) == player_object_id
- end
- function VehicleHasGunner(VehicleID)
- local vehicle_object = get_object_memory(VehicleID)
- if (vehicle_object == 0) then return false end
- return read_dword(vehicle_object + 0x328) ~= 0xFFFFFFFF
- end
- function GetPlayerVehicleTagName(PlayerIndex)
- if isinvehicle(PlayerIndex) and game_started then
- local player_object = get_dynamic_player(PlayerIndex)
- local vehicleId = read_dword(player_object + 0x11C)
- local vehicle_obj = get_object_memory(vehicleId)
- if (vehicle_obj ~= 0) then
- local vehicle_metaid = read_dword(vehicle_obj)
- local veh_name = get_vehicle_name(vehicle_metaid)
- if (veh_name ~= nil and veh_name ~= "NULL METAID") then
- return veh_name
- else
- return nil
- end
- end
- end
- end
- function get_vehicle_name(MetaID) -- Thanks to Giraffe!
- if (MetaID == 0xFFFFFFFF) then
- return "NULL METAID"
- else
- local globals_tag = lookup_tag("matg", "globals\\globals")
- local globals_data = read_dword(globals_tag + 0x14)
- local interface_bitmaps_data = read_dword(globals_data + 0x144)
- local hud_globals_metaid = read_dword(interface_bitmaps_data + 0x6C)
- local hud_globals_tag = lookup_tag(hud_globals_metaid)
- local hud_globals_data = read_dword(hud_globals_tag + 0x14)
- local hud_icon_messages_metaid = read_dword(hud_globals_data + 0xC0)
- local hud_icon_messages_tag = lookup_tag(hud_icon_messages_metaid)
- local hud_icon_messages_data = read_dword(hud_icon_messages_tag + 0x14)
- local string_references_count = read_dword(hud_icon_messages_data)
- local string_references_data = read_dword(hud_icon_messages_data + 0x4)
- local strings = {}
- for i=0,string_references_count-1 do
- local bytes = read_dword(string_references_data + i*20)
- local string_data = read_dword(string_references_data + i*20 + 0xC)
- local string = ''
- for j=0,bytes-3,2 do
- string = string .. string.char(read_char(string_data +j))
- end
- strings[i] = string
- end
- local vehicle_tag = lookup_tag(MetaID)
- local vehicle_data = read_dword(vehicle_tag + 0x14)
- local hud_text_message_index = read_short(vehicle_data + 0x13C)
- if(strings[hud_text_message_index] ~= nil) then
- return strings[hud_text_message_index]
- else
- return strings[0]
- end
- end
- end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
- -- Email: debtproblems@hotmail.com
- -- The player -db-GoNe/Juhleek - a well spoken liar, cheat.
- -- -db- is: "diverging from the believable" - How ironic. A race clan where admins use rcon to favor themselves to win.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement