Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Fling Race for bloodgulch and gephyrophobia PC/CE
- -- by H® Shaft for SAPP
- -- A fun bloodgulch and gephyrophobia PC/CE race variant which flings players in vehicles from one location to another
- -- Note: Best results: the race gametype should have race navs in "Normal Order" - NOT "Any Order" or "Rally" but - will still work regardless
- -- if script is loaded on a gametype other than race, it will skip to next map, and log error in the sapp log
- -- sapp api version
- api_version = "1.9.0.0"
- function OnScriptLoad()
- register_callback(cb['EVENT_TICK'],"OnTick")
- register_callback(cb['EVENT_GAME_START'], "OnNewGame")
- if get_var(0, "$gt") ~= "n/a" then
- if get_var(0, "$gt") == "race" then
- CreateMarkers()
- else
- cprint("This script is intended for RACE gametypes only.")
- end
- end
- end
- function OnNewGame()
- map_name = get_var(0,"$map")
- if get_var(0, "$gt") == "race" then
- CreateMarkers()
- else
- cprint("This script is intended for RACE gametypes only.")
- local data = string.format("%s on %s: fling-race script is intended for RACE gametypes only.", tostring(map_name), tostring(get_var(0, "$gt")))
- execute_command("log_note \""..data.."\"")
- execute_command("sv_map_next")
- return
- end
- end
- function CreateMarkers()
- map_name = get_var(0,"$map") -- if reloaded after game started, ensure map name is read
- if map_name == "gephyrophobia" then
- -- flag markers used to mark teleports on gephyrophobia, disable them from being picked up
- execute_command("disable_object weapons\\flag\\flag")
- -- below red base teleport to top
- local marker1 = spawn_object("weap", "weapons\\flag\\flag", 26.787, -124.054, -18.315)
- -- below blue base teleport to top
- local marker2 = spawn_object("weap", "weapons\\flag\\flag", 26.80, -20.015, -18.32)
- -- nav3 - throws player thru center tower hole to lower level
- local marker3 = spawn_object("weap", "weapons\\flag\\flag", 26.797, -101.776, -13.213)
- end
- end
- function OnTick()
- 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 vehicleId = read_dword(player_object + 0x11C)
- local vehicle_object = get_object_memory(vehicleId)
- if (player_object ~= 0) then
- if isinvehicle(PlayerIndex) and PlayerIsDriver(PlayerIndex) then
- player_obj_id = vehicleId
- -- bloodgulch specific settings
- if map_name == "bloodgulch" then
- local nav1 = inSphere(player_obj_id, 59.785, -121.995, 0.268, 2)
- local nav2 = inSphere(player_obj_id, 95.514, -171.713, 0.329, 2)
- local nav3 = inSphere(player_obj_id, 40.367, -66.605, 0.640, 2)
- local nav4 = inSphere(player_obj_id, 71.166, -92.553, 4.665, 2)
- local nav5 = inSphere(player_obj_id, 60.645, -150.747, 6.292, 2)
- if nav1 then
- moveobject(player_obj_id, 59.818, -121.994, 2.224)
- write_float(vehicle_object + 0x6C, -0.35)
- write_float(vehicle_object + 0x68, 0.15)
- write_float(vehicle_object + 0x70, 0.25)
- write_float(vehicle_object + 0x8C, 0)
- write_float(vehicle_object + 0x90, 0)
- write_float(vehicle_object + 0x94, -0.2)
- local grunt = generategrunt(grunt)
- rprint(PlayerIndex, "|c".. grunt)
- end
- if nav2 then
- moveobject(player_obj_id, 95.504, -171.680, 2.224)
- write_float(vehicle_object + 0x6C, 0.89)
- write_float(vehicle_object + 0x68, -0.388)
- write_float(vehicle_object + 0x70, 0.265)
- write_float(vehicle_object + 0x8C, 0)
- write_float(vehicle_object + 0x90, 0)
- write_float(vehicle_object + 0x94, -0.2)
- local grunt = generategrunt(grunt)
- rprint(PlayerIndex, "|c".. grunt)
- end
- if nav3 then
- moveobject(player_obj_id, 40.427, -66.627, 2.224)
- write_float(vehicle_object + 0x6C, -0.35)
- write_float(vehicle_object + 0x68, 0.15)
- write_float(vehicle_object + 0x70, 0.3)
- write_float(vehicle_object + 0x8C, 0)
- write_float(vehicle_object + 0x90, 0)
- write_float(vehicle_object + 0x94, -0.2)
- local grunt = generategrunt(grunt)
- rprint(PlayerIndex, "|c".. grunt)
- end
- if nav4 then
- moveobject(player_obj_id, 70.608, -96.019, 6.444)
- write_float(vehicle_object + 0x6C, -0.30)
- write_float(vehicle_object + 0x68, -0.15)
- write_float(vehicle_object + 0x70, 0.25)
- write_float(vehicle_object + 0x8C, 0)
- write_float(vehicle_object + 0x90, 0)
- write_float(vehicle_object + 0x94, -0.2)
- local grunt = generategrunt(grunt)
- rprint(PlayerIndex, "|c".. grunt)
- end
- if nav5 then
- moveobject(player_obj_id, 60.312, -149.034, 7.904)
- write_float(vehicle_object + 0x6C, 0.25)
- write_float(vehicle_object + 0x68, 0.11)
- write_float(vehicle_object + 0x70, 0.20)
- write_float(vehicle_object + 0x8C, 0)
- write_float(vehicle_object + 0x90, 0)
- write_float(vehicle_object + 0x94, -0.2)
- local grunt = generategrunt(grunt)
- rprint(PlayerIndex, "|c".. grunt)
- end
- end -- end bloodgulch specific settings
- -- gephyrophobia specific settings
- if map_name == "gephyrophobia" then
- local nav3 = inSphere(player_obj_id, 26.797, -101.776, -13.213, 2)
- local nav5 = inSphere(player_obj_id, 26.804, -45.347, -17.465, 2)
- local bottomsupred = inSphere(player_obj_id, 26.787, -124.054, -18.315, 2)
- local bottomsupblu = inSphere(player_obj_id, 26.80, -20.015, -18.32, 2)
- if nav3 then
- moveobject(player_obj_id, 26.797, -101.776, -10.583)
- write_float(vehicle_object + 0x6C, 0)
- write_float(vehicle_object + 0x68, 0)
- write_float(vehicle_object + 0x6C, 0.52)
- write_float(vehicle_object + 0x70, 0.15)
- write_float(vehicle_object + 0x8C, 0)
- write_float(vehicle_object + 0x90, 0)
- write_float(vehicle_object + 0x94, 0.2)
- local grunt = generategrunt(grunt)
- rprint(PlayerIndex, "|c".. grunt)
- end
- if nav5 then
- moveobject(player_obj_id, 26.804, -45.347, -10.445)
- write_float(vehicle_object + 0x6C, 0)
- write_float(vehicle_object + 0x68, 0)
- write_float(vehicle_object + 0x6C, -0.52)
- write_float(vehicle_object + 0x70, 0.15)
- write_float(vehicle_object + 0x8C, 0)
- write_float(vehicle_object + 0x90, 0)
- write_float(vehicle_object + 0x94, -0.23)
- local grunt = generategrunt(grunt)
- rprint(PlayerIndex, "|c".. grunt)
- end
- if bottomsupred then -- teleport up
- moveobject(player_obj_id, 14.227, -93.119, -13.975)
- local grunt = generategrunt(grunt)
- rprint(PlayerIndex, "|c".. grunt)
- end
- if bottomsupblu then -- teleport up
- moveobject(player_obj_id, 39.58, -51.50, -13.975)
- local grunt = generategrunt(grunt)
- rprint(PlayerIndex, "|c".. grunt)
- end
- end -- end gephyrophobia specific settings
- 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
- 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 moveobject(ObjectID, x, y, z)
- local object = get_object_memory(ObjectID)
- if get_object_memory(ObjectID) ~= 0 then
- local veh_obj = get_object_memory(read_dword(object + 0x11C))
- write_vector3d((veh_obj ~= 0 and veh_obj or object) + 0x5C, x, y, z)
- end
- end
- function inSphere(ObjectID, X, Y, Z, R)
- if get_object_memory(ObjectID) ~= 0 then
- local x,y,z = getobjectcoords(ObjectID)
- if (X - x)^2 + (Y - y)^2 + (Z - z)^2 <= R then
- return true
- else
- return false
- end
- end
- end
- function getobjectcoords(ObjectID)
- local object = get_object_memory(ObjectID)
- if get_object_memory(ObjectID) ~= 0 then
- local veh_obj = get_object_memory(read_dword(object + 0x11C))
- if veh_obj ~= 0 then
- object = veh_obj
- end
- end
- return read_vector3d(object + 0x5C)
- end
- function generategrunt(grunt)
- local grunt = {"WEEEE!", "Whoa!", "Holy Crap!", "WTF!", "Fuuuh!", "Efff!", "Nuhuh!", "Arrg!", "GEEEZ!", "Who Flung Poo?!"}
- 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 "DUDE!"
- end
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement