Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Fling Race v2 - for bloodgulch, gephyrophobia, deathisland, dangercanyon & sidewinder PC/CE stock maps
- -- by H® Shaft for SAPP
- -- A fun bloodgulch, gephyrophobia, deathisland, dangercanyon & sidewinder PC/CE race variant which flings players in vehicles from one location to another, or launches them
- -- 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
- -- NOte: for best experience - sidewinder race navs should be set to In-Order, NOT any-order
- -- sapp api version
- api_version = "1.9.0.0"
- function OnScriptLoad()
- register_callback(cb['EVENT_TICK'],"OnTick")
- register_callback(cb['EVENT_GAME_START'], "OnNewGame")
- register_callback(cb['EVENT_JOIN'],"OnPlayerJoin")
- 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 OnPlayerJoin(PlayerIndex)
- announce = timer(12000, "timedannounce", PlayerIndex)
- end
- function timedannounce(PlayerIndex)
- if player_present(PlayerIndex) then
- rprint(PlayerIndex, "|c CAUTION: Wormholes detected and marked with flags!")
- end
- return false
- end
- function CreateMarkers()
- map_name = get_var(0,"$map") -- if reloaded after game started, ensure map name is read
- if map_name == "gephyrophobia" then
- execute_command("disable_object weapons\\flag\\flag")
- execute_command("disable_object powerups\\full-spectrum vision")
- --nav 0
- local marker1 = spawn_object("eqip", "powerups\\full-spectrum vision", 42.081, -71.723, -12.681)
- --nav 1
- local marker2 = spawn_object("eqip", "powerups\\full-spectrum vision", 26.811, -42.343, -14.451)
- --nav2
- local marker3 = spawn_object("eqip", "powerups\\full-spectrum vision", 11.582, -71.646, -12.681)
- --nav3 - throws player thru center tower hole to lower level
- local marker4 = spawn_object("weap", "weapons\\flag\\flag", 26.822, -101.771, -14.441)
- --nav4 - throws player thru center tower hole back to
- local marker5 = spawn_object("weap", "weapons\\flag\\flag", 26.810, -45.347, -18.321)
- --nav5
- local marker6 = spawn_object("eqip", "powerups\\full-spectrum vision", 26.799, -98.932, -18.321)
- -- below red base teleport to top
- local marker7 = spawn_object("eqip", "powerups\\full-spectrum vision", 26.787, -124.054, -18.315)
- local marker8 = spawn_object("weap", "weapons\\flag\\flag", 26.787, -124.054, -18.315)
- -- below blue base teleport to top
- local marker9 = spawn_object("eqip", "powerups\\full-spectrum vision", 26.80, -20.015, -18.32)
- local marker10 = spawn_object("weap", "weapons\\flag\\flag", 26.80, -20.015, -18.32)
- elseif map_name == "sidewinder" then
- execute_command("disable_object weapons\\flag\\flag")
- execute_command("disable_object powerups\\full-spectrum vision")
- --nav 0
- --local marker1 = spawn_object("eqip", "powerups\\full-spectrum vision", 1.849, 54.577, -2.571)
- --local marker1a = spawn_object("weap", "weapons\\flag\\flag", 1.849, 54.577, -2.571)
- --nav 1
- local marker2 = spawn_object("eqip", "powerups\\full-spectrum vision", -40.485, 32.898, 0.319)
- local marker2a = spawn_object("weap", "weapons\\flag\\flag", -40.485, 32.898, 0.319)
- --nav2
- local marker3 = spawn_object("eqip", "powerups\\full-spectrum vision", 39.157, 29.981, 0.329)
- local marker3a = spawn_object("weap", "weapons\\flag\\flag", 39.157, 29.981, 0.329)
- --nav3
- local marker4 = spawn_object("eqip", "powerups\\full-spectrum vision", 30.345, -46.087, -3.591)
- local marker4a = spawn_object("weap", "weapons\\flag\\flag", 30.345, -46.087, -3.591)
- --nav4
- local marker5 = spawn_object("eqip", "powerups\\full-spectrum vision", 60.645, -150.747, 6.292)
- local marker5a = spawn_object("weap", "weapons\\flag\\flag", -32.035, -42.080, -3.601)
- elseif map_name == "bloodgulch" then
- execute_command("disable_object weapons\\flag\\flag")
- execute_command("disable_object powerups\\full-spectrum vision")
- --nav 0
- local marker1 = spawn_object("eqip", "powerups\\full-spectrum vision", 59.785, -121.995, 0.268)
- local marker1a = spawn_object("weap", "weapons\\flag\\flag", 59.785, -121.995, 0.268)
- --nav 1
- local marker2 = spawn_object("eqip", "powerups\\full-spectrum vision", 95.514, -171.713, 0.329)
- local marker2a = spawn_object("weap", "weapons\\flag\\flag", 95.514, -171.713, 0.329)
- --nav2
- local marker3 = spawn_object("eqip", "powerups\\full-spectrum vision", 40.367, -66.605, 0.640)
- local marker3a = spawn_object("weap", "weapons\\flag\\flag", 40.367, -66.605, 0.640)
- --nav3
- local marker4 = spawn_object("eqip", "powerups\\full-spectrum vision", 71.166, -92.553, 4.665)
- local marker4a = spawn_object("weap", "weapons\\flag\\flag", 71.166, -92.553, 4.665)
- --nav4
- local marker5 = spawn_object("eqip", "powerups\\full-spectrum vision", 60.645, -150.747, 6.292)
- local marker5a = spawn_object("weap", "weapons\\flag\\flag", 60.645, -150.747, 6.292)
- elseif map_name == "deathisland" then
- execute_command("disable_object weapons\\flag\\flag")
- local marker1 = spawn_object("weap", "weapons\\flag\\flag", 1.499, -55.629, 1.645)
- local marker2 = spawn_object("weap", "weapons\\flag\\flag", -31.086, 53.225, 10.655)
- local marker3 = spawn_object("weap", "weapons\\flag\\flag", 27.119, 62.588, 1.621)
- elseif map_name == "dangercanyon" then
- execute_command("disable_object weapons\\flag\\flag")
- execute_command("disable_object powerups\\full-spectrum vision")
- local redbase = spawn_object("weap", "weapons\\flag\\flag", -12.141, -3.438, -1.010)
- local bluebase = spawn_object("weap", "weapons\\flag\\flag", 12.017, -3.437, -0.960)
- local center = spawn_object("weap", "weapons\\flag\\flag", -0.104, 52.28, -0.2)
- local centera = spawn_object("eqip", "powerups\\full-spectrum vision", -0.104, 52.28, -0.2)
- 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)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- 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)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- 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)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- 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)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- 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)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- 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)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- 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)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- if bottomsupred then -- teleport up
- moveobject(player_obj_id, 14.227, -93.119, -13.975)
- local grunt = generategrunt(grunt)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- if bottomsupblu then -- teleport up
- moveobject(player_obj_id, 39.58, -51.50, -13.975)
- local grunt = generategrunt(grunt)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- end -- end gephyrophobia specific settings
- -- sidewinder specific settings
- if map_name == "sidewinder" then
- local nav1 = inSphere(player_obj_id, 1.849, 54.577, -2.571, 2)
- local nav2 = inSphere(player_obj_id, -40.485, 32.898, 0.319, 2)
- local nav3 = inSphere(player_obj_id, 39.157, 29.981, 0.329, 2)
- local nav4 = inSphere(player_obj_id, 30.345, -46.087, -3.591, 2)
- local nav5 = inSphere(player_obj_id, -32.035, -42.080, -3.601, 2)
- -- not used, drivers will be at a pitch angle that is hard to recover from, to enable - remove block comment brackets "--[[" and "]]--"
- --[[if nav1 then
- moveobject(player_obj_id, -1.834, 54.433, -2.181) -- fling0 towards 2nd nav
- write_float(vehicle_object + 0x6C, -0.17)
- write_float(vehicle_object + 0x68, -0.30)
- write_float(vehicle_object + 0x70, 0.15)
- write_float(vehicle_object + 0x8C, 0)
- write_float(vehicle_object + 0x90, 0)
- local grunt = generategrunt(grunt)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end]]--
- if nav2 then
- moveobject(player_obj_id, -35.444, 35.780, 0.999) -- fling1 towards 3rd nav
- write_float(vehicle_object + 0x6C, 0.10) -- y
- write_float(vehicle_object + 0x68, 0.40) -- x
- 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)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- if nav3 then
- moveobject(player_obj_id, 39.680, 26.583, 1.419) -- fling2 towards 4th nav
- write_float(vehicle_object + 0x6C, -0.25) -- 0.40 + -0.10 towards 1st
- write_float(vehicle_object + 0x68, -0.02)
- 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)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- if nav4 then
- moveobject(player_obj_id, 32.497, -32.823, -1.221) -- fling3 towards 1st nav
- write_float(vehicle_object + 0x6C, 0.40)
- write_float(vehicle_object + 0x68, -0.10)
- 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)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- if nav5 then
- moveobject(player_obj_id, -37.935, -29.914, -2.091) -- fling4 towards 1st nav
- write_float(vehicle_object + 0x6C, 0.35)
- write_float(vehicle_object + 0x68, 0.11)
- write_float(vehicle_object + 0x70, 0.23)
- write_float(vehicle_object + 0x8C, 0)
- write_float(vehicle_object + 0x90, 0)
- write_float(vehicle_object + 0x94, -0.2)
- local grunt = generategrunt(grunt)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- end -- end sidewinder specific settings
- -- deathisland specific settings -- only launches, doesn't fling in a specific direction
- if map_name == "deathisland" then
- local nav0 = inSphere(player_obj_id, 1.499, -55.629, 1.645, 2)
- local nav1 = inSphere(player_obj_id, -24.667, -59.929, 1.645, 2)
- local nav2 = inSphere(player_obj_id, -48.867, -49.267, 1.645, 2)
- local nav3 = inSphere(player_obj_id, -55.439, -21.230, 1.762, 2)
- local nav4 = inSphere(player_obj_id, -61.979, 4.219, 2.491, 2)
- local nav5 = inSphere(player_obj_id, -68.167, 34.964, 2.688, 2)
- local nav6 = inSphere(player_obj_id, -51.014, 51.562, 6.718, 2)
- local nav7 = inSphere(player_obj_id, -31.086, 53.225, 10.655, 2) -- large jump
- local nav8 = inSphere(player_obj_id, -5.238, 57.429, 2.103, 2)
- local nav9 = inSphere(player_obj_id, 27.119, 62.588, 1.621, 2)
- local nav10 = inSphere(player_obj_id, 51.606, 42.879, 1.978, 2)
- local nav11 = inSphere(player_obj_id, 50.571, 8.179, 2.966, 2)
- local nav12 = inSphere(player_obj_id, 36.759, -18.843, 4.130, 2)
- local nav13 = inSphere(player_obj_id, 28.260, -43.767, 2.407, 2)
- if nav0 then -- traditional lap nav in-order
- moveobject(player_obj_id, 1.499, -55.629, 5.645)
- write_float(vehicle_object + 0x70, 0.24) -- upward velocity
- write_float(vehicle_object + 0x8C, -0.11) -- roll
- local grunt = generategrunt(grunt)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- if nav9 then -- in blue base sandy corner
- moveobject(player_obj_id, 27.119, 62.588, 4.645)
- write_float(vehicle_object + 0x70, 0.24) -- upward velocity
- write_float(vehicle_object + 0x8C, -0.11) -- roll
- local grunt = generategrunt(grunt)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- if nav7 then -- large jump
- moveobject(player_obj_id, -31.086, 53.225, 15.805) -- move directly up a bit tp prevent hitting canyon walls
- write_float(vehicle_object + 0x70, 0.25) -- upward velocity
- write_float(vehicle_object + 0x94, 0.4) -- spin/yaw neg # is opposite direction
- local grunt = generategrunt(grunt)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- end -- end deathisland specific settings
- -- dangercanyon specific settings
- if map_name == "dangercanyon" then
- local redbase = inSphere(player_obj_id, -12.141, -3.438, -1.010, 2)
- local bluebase = inSphere(player_obj_id, 12.017, -3.437, -0.960, 2)
- local center = inSphere(player_obj_id, -0.104, 52.28, -8.41, 2)
- if redbase then -- nav 5 redbase bounceback
- moveobject(player_obj_id, -12.141, -3.438, 6.270)
- write_float(vehicle_object + 0x6C, -0.015)
- write_float(vehicle_object + 0x68, -0.25)
- write_float(vehicle_object + 0x70, 0.08)
- write_float(vehicle_object + 0x8C, 0)
- write_float(vehicle_object + 0x90, 0)
- write_float(vehicle_object + 0x94, -0.13)
- local grunt = generategrunt(grunt)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- if bluebase then -- nav 2 redbase bounceback
- moveobject(player_obj_id, 12.017, -3.437, 6.270)
- write_float(vehicle_object + 0x6C, 0.015)
- write_float(vehicle_object + 0x68, 0.25)
- write_float(vehicle_object + 0x70, 0.08)
- write_float(vehicle_object + 0x8C, 0)
- write_float(vehicle_object + 0x90, 0)
- write_float(vehicle_object + 0x94, 0.13)
- local grunt = generategrunt(grunt)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- if center then -- nav 0 center
- moveobject(player_obj_id, 0.006, 41.710, -1.709) -- move directly up a bit over center ramps
- write_float(vehicle_object + 0x70, 0.08) -- upward velocity
- write_float(vehicle_object + 0x94, 0.15) -- spin/yaw neg # is opposite direction
- local grunt = generategrunt(grunt)
- if grunt ~= nil then rprint(PlayerIndex, "|c".. grunt) end
- end
- end -- dangercanyon 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 rand_grunt = rand(1, #grunt+1)
- local grunt_type = string.format("%s", grunt[rand_grunt])
- if grunt_type ~= nil then
- return grunt_type
- end
- end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement