Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Slaughterhouse - a Mini-Game - All Players will get 'slaughtered' - not intended for pussies.
- -- Players spawn at random locations
- -- When a player spawns they will spawn in a rocket hog, in the gunner seat, and will also be the driver
- -- If a player tips over/crashes - they will be auto-flipped to keep drivers on their tires (Thanks to Giraffe)
- -- to get a new warthog, players should type: HOG or /HOG
- -- If Teamkill is on and a player betrays a teammate, they too will be killed.
- -- Various areas on maps are blocked from entering with a vehicle - so you can't hide like a momma's boy.
- -- Supports: bloodgulch, sidewinder, deathisland, dangercanyon, (and boardingaction - on top of map)
- -- Suggested Gametypes: FFA/Team/Rally Race, FFA/Team Slayer, CTF, FFA/Team King of the Hill
- -- Suggested Maps: bloodgulch, danger canyon and boardingaction
- -- ===== Gametypes should NOT spawn vehicles! This script creates them ==========
- -- NOTE: boardingaction:
- -- I suggest FFA/Team Slayer ONLY: - it is NOT compatible with CTF as this script disables picking up the flag,
- -- and players spawn ON TOP of map: so no King, no CTF, no SKULL oddball, but can be juggernaught-oddball type (fun!)
- -- Amount of time in seconds before a spawned hog is destroyed after players leave it, and if it has 'no driver'.
- destroy_time = 2
- -- Amount of time in seconds to add to a players respawn time for betrays
- respawn_time = 10
- -- message given to vehicle drivers when they attempt to enter a blocked area
- blocked_message = "**BLOCKED!** Vehicles prohibited! ~~ Prohibe los vehiculos!"
- -- sapp api version
- api_version = "1.9.0.0"
- team_play = false
- loop_end = 8
- vehicles = {}
- cont_check = nil
- destroyvehicle = nil
- function OnScriptLoad()
- register_callback(cb['EVENT_GAME_START'], "OnNewGame")
- register_callback(cb['EVENT_GAME_END'], "OnGameEnd")
- register_callback(cb['EVENT_PRESPAWN'], "OnPlayerPrespawn")
- register_callback(cb['EVENT_SPAWN'], "OnPlayerSpawn")
- register_callback(cb['EVENT_VEHICLE_ENTER'], "OnVehicleEntry")
- register_callback(cb['EVENT_VEHICLE_EXIT'], "OnVehicleExit")
- register_callback(cb['EVENT_TICK'], "OnTick")
- register_callback(cb['EVENT_TEAM_SWITCH'], "ChangeColor")
- register_callback(cb['EVENT_DIE'], "ChangeColor")
- register_callback(cb['EVENT_JOIN'], "OnPlayerJoin")
- register_callback(cb['EVENT_BETRAY'], "OnPlayerBetray")
- register_callback(cb['EVENT_CHAT'], "OnPlayerChat")
- -- begin color
- location_store = sig_scan("741F8B482085C9750C")
- if(location_store == 0) then
- location_store = sig_scan("EB1F8B482085C9750C")
- if(location_store == 0) then
- cprint("Failed to find color assignment signature")
- end
- end
- safe_write(true)
- write_char(location_store,235)
- safe_write(false)
- -- end color
- if get_var(0, "$gt") ~= "n/a" then
- game_started = true
- map_name = get_var(0,"$map")
- game_type = get_var(0,"$gt")
- team_play = getteamplay()
- Load_Tables()
- execute_command("rider_ejection 0")
- if cont_check == nil then
- cont_check = timer(1000, "continuous_vehicle_check")
- end
- end
- end
- function OnScriptUnload()
- execute_command("rider_ejection 1")
- end
- function OnNewGame()
- game_started = true
- map_name = get_var(0,"$map")
- game_type = get_var(0,"$gt")
- team_play = getteamplay()
- execute_command("rider_ejection 0")
- Load_Tables()
- if team_play then loop_end = 8 else loop_end = 16 end -- default number of spawns for duplicate spawn check
- if cont_check == nil then
- cont_check = timer(1000, "continuous_vehicle_check")
- end
- if map_name == "boardingaction" then
- placemarkers = timer(100, "Place_Markers")
- execute_command('disable_object "weapons\\flag\\flag" 0')
- end
- end
- function OnGameEnd()
- game_started = false
- execute_command("rider_ejection 1")
- destroyvehicle = nil
- end
- function OnPlayerJoin(PlayerIndex)
- ChangeColor(PlayerIndex)
- timedwelcome = timer(7000, "TimedWelcome", PlayerIndex)
- end
- function TimedWelcome(PlayerIndex)
- if player_present(PlayerIndex) and game_started then
- local welcome1 = "~~~~ Welcome to the Driver-Gunner Slaughterhouse! ~~~~"
- rprint(PlayerIndex, "|c " .. welcome1)
- rprint(PlayerIndex,"|n ")
- rprint(PlayerIndex,"|n ")
- rprint(PlayerIndex,"|n ")
- rprint(PlayerIndex,"|n ")
- rprint(PlayerIndex,"|n ")
- rprint(PlayerIndex,"|n ")
- end
- return false
- end
- function Place_Markers()
- if game_started then
- if map_name == "boardingaction" then
- spawn_object("weap", "weapons\\flag\\flag", 56.332, -5.123, 63.328) -- center
- spawn_object("weap", "weapons\\flag\\flag", 56.764, -62.689, 47.539) -- below
- spawn_object("weap", "weapons\\flag\\flag", 55.827, 28.029, 63.338) -- near
- spawn_object("weap", "weapons\\flag\\flag", 55.339, -39.422, 63.328) -- far
- spawn_object("vehi", "vehicles\\c gun turret\\c gun turret_mp", 35.151, -4.693, 63.251, 6.25) -- center left
- spawn_object("vehi", "vehicles\\c gun turret\\c gun turret_mp", 75.993, -5.240, 63.251, 3.11) -- center right
- end
- end
- return false
- end
- function OnPlayerSpawn(PlayerIndex)
- ChangeColor(PlayerIndex)
- -- execute_command_sequence("ammo me 0 5;mag me 0 5;nades me 0", PlayerIndex)
- local Deaths = tonumber(get_var(PlayerIndex, "$deaths"))
- if player_alive(PlayerIndex) and (game_started == true) then
- timer(1100, "PutInVehicle", PlayerIndex)
- if Deaths > 15 then
- overshield = timer(6000, "GiveOverShield", PlayerIndex)
- end
- end
- end
- function OnPlayerChat(PlayerIndex, Message)
- local response = nil
- local Message = string.lower(Message)
- local name = get_var(PlayerIndex,"$name")
- if (Message == "help") then
- response = false
- say(PlayerIndex, "~~~~~~~Driver-Gunner Help~~~~~~~")
- say(PlayerIndex, "You will drive from the gunner seat.")
- say(PlayerIndex, "Sometimes you will wreck, if so, we will help")
- say(PlayerIndex, "if you need a warthog, type HOG")
- say_all(string.format("%s is reading HELP. ", tostring(name)))
- elseif (Message == "hog") or (Message == "/hog") or (Message == "/v") then
- response = false
- if isinvehicle(PlayerIndex) then
- say(PlayerIndex, "You already have a hog, DUH!")
- else
- timer(400, "PutInVehicle", PlayerIndex)
- end
- say_all(string.format("%s requested a HOG. ", tostring(name)))
- elseif (Message == "coord") then
- response = false
- local player_static = get_player(PlayerIndex)
- local x,y,z = GetPlayerCoords(PlayerIndex)
- local Z = z+0.3
- local rotation = read_float(player_static + 0x138)
- local map_name = get_var(0,"$map")
- local data = string.format("%s, %s, %s, %s, %s", tostring(map_name),tostring(x),tostring(y),tostring(Z),tostring(math.round(rotation, 2)))
- execute_command("log_note \""..data.."\"")
- say(PlayerIndex, "XYZR: " .. x .. ", " .. y .. ", " .. Z .. ", " .. math.round(rotation, 2))
- else
- response = true
- end
- return response
- end
- function OnPlayerBetray(PlayerIndex, VictimIndex)
- if not team_play then return end
- if not player_present(PlayerIndex) then return end
- local name = get_var(PlayerIndex,"$name")
- if player_alive(PlayerIndex) and game_started then
- local respawn_time_old = read_dword(get_player(PlayerIndex) + 0x30)
- write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old + 30 * respawn_time)
- kill(PlayerIndex)
- write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old)
- say(PlayerIndex, name .. "PLEASE AVOID TEAMKILLS, AIM CAREFULLY! NOW =YOU= DIE!")
- say(PlayerIndex, name .. "NO MATAR A COMPANEROS DE EQUIPO, APUNTAR CON CUIDADO ! AHORA SE MUERE!")
- say(PlayerIndex, respawn_time .. " seconds added respawn time! ~~ ".. respawn_time .. " segundos anadidos a su tiempo de desove!")
- end
- end
- function OnVehicleEntry(PlayerIndex, Seat)
- if (game_started == true) then
- execute_command("rider_ejection 0", PlayerIndex)
- if Seat == "0" then
- say(PlayerIndex, "You are driver and gunner! Go! ~~ Estas conductor y artillero! Conduce!")
- end
- end
- end
- function OnVehicleExit(PlayerIndex)
- if player_alive(PlayerIndex) and (game_started == true) then
- rprint(PlayerIndex, "|cPlease STAY in your vehicle! ~~ Por favor, PERMANEZCA en su vehiculo!")
- rprint(PlayerIndex, "|cType HOG to get a vehicle ~~ Escriba HOG para conseguir un vehiculo.")
- rprint(PlayerIndex,"|n ")
- rprint(PlayerIndex,"|n ")
- rprint(PlayerIndex,"|n ")
- rprint(PlayerIndex,"|n ")
- rprint(PlayerIndex,"|n ")
- end
- end
- function Punish(PlayerIndex)
- if player_alive(PlayerIndex) and (game_started == true) then
- local respawn_time_old = read_dword(get_player(PlayerIndex) + 0x30)
- write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old + 30 * respawn_time)
- kill(PlayerIndex)
- write_dword(get_player(PlayerIndex) + 0x30, respawn_time_old)
- else
- return false
- end
- return false
- end
- function GiveOverShield(PlayerIndex)
- if (game_started == true) then
- if player_alive(PlayerIndex) then
- local name = get_var(PlayerIndex,"$name")
- say(PlayerIndex, "** " .. name .. " ** You're gettin your ass kicked, here's an over-shield, cupcake.")
- local ObjectID = spawn_object("eqip", "powerups\\over shield")
- powerup_interact(ObjectID, PlayerIndex)
- end
- end
- return false
- end
- function PutInVehicle(PlayerIndex)
- if (game_started == true) then
- if not isinvehicle(PlayerIndex) then
- local player_object = get_dynamic_player(PlayerIndex)
- if (player_object ~= 0) then
- local player_static = get_player(PlayerIndex)
- local x,y,z = read_vector3d(player_object + 0x5C)
- local rotation = read_float(player_static + 0x138)
- local vehicleId = spawn_object("vehi", "vehicles\\rwarthog\\rwarthog", x, y, z+0.5, rotation)
- if vehicleId then
- table.insert(vehicles, {vehicleId, tonumber(destroy_time)})
- enter_vehicle(vehicleId, PlayerIndex, 0)
- enter_vehicle(vehicleId, PlayerIndex, 2)
- end
- end
- end
- end
- return false
- end
- function OnTick()
- if (game_started == true) then
- 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)
- local vehicleId = read_dword(player_object + 0x11C)
- local vehicle_object = get_object_memory(vehicleId)
- local obj_health = tonumber(get_var(PlayerIndex, "$hp"))
- if (vehicleId ~= 0xFFFFFFFF) then
- flip_vehicle(vehicle_object)
- end
- if (player_object ~= 0) then
- -- vehicle blocked areas per map
- if map_name == "bloodgulch" then
- local health_lapnav = inSphere(player_obj_id, 60.987, -121.606, 0.274, 1)
- if health_lapnav then
- if (obj_health < 1) then
- bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
- end
- end
- local block1 = inSphere(player_obj_id, 95.64, -155.22, -0.07, 2)
- local block2 = inSphere(player_obj_id, 95.49, -164.05, -0.03, 2)
- local block3 = inSphere(player_obj_id, 95.63, -159.42, -0.2, 2)
- local block4 = inSphere(player_obj_id, 96.65, -115.62, 3.79, 2)
- local block5 = inSphere(player_obj_id, 99.07, -100.57, 4.24, 2)
- local block6 = inSphere(player_obj_id, 69.05, -92.24, 4.71, 2) -- cave/4th nav
- local block7 = inSphere(player_obj_id, 71.30, -85.51, 5.66, 2) -- cave/4th nav
- local block8 = inSphere(player_obj_id, 40.06, -83.70, -0.01, 2)
- local block9 = inSphere(player_obj_id, 40.19, -74.59, 0.03, 2)
- local block10 = inSphere(player_obj_id, 40.17, -79.10, -0.88, 2)
- if isinvehicle(PlayerIndex) then
- if block1 then moveobject(player_obj_id, 95.79, -150.45, 0.06+0.3) say(PlayerIndex, blocked_message) end
- if block2 then moveobject(player_obj_id, 95.92, -168.40, 0.18+0.3) say(PlayerIndex, blocked_message) end
- if block3 then moveobject(player_obj_id, 95.79, -150.45, 0.06+0.3) say(PlayerIndex, blocked_message) end
- if block4 then moveobject(player_obj_id, 91.85, -121.03, 2.45+0.3) say(PlayerIndex, blocked_message) end
- if block5 then moveobject(player_obj_id, 97.15, -96.86, 4.40+0.3) say(PlayerIndex, blocked_message) end
- --if block6 then moveobject(player_obj_id, 73.42, -92.75, 4.68+0.3) say(PlayerIndex, blocked_message) end
- --if block7 then moveobject(player_obj_id, 66.03, -81.32, 1.14+0.3) say(PlayerIndex, blocked_message) end
- if block8 then moveobject(player_obj_id, 40.40, -88.23, 0.10+0.3) say(PlayerIndex, blocked_message) end
- if block9 then moveobject(player_obj_id, 39.91, -70.12, 0.28+0.3) say(PlayerIndex, blocked_message) end
- if block10 then moveobject(player_obj_id, 39.91, -70.12, 0.28+0.3) say(PlayerIndex, blocked_message) end
- end
- elseif map_name == "boardingaction" then
- local health_lapnav = inSphere(player_obj_id, 35.151, -4.693, 63.251, 1)
- if health_lapnav then
- if (obj_health < 1) then
- bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
- end
- end
- local near = inSphere(player_obj_id, 55.827, 28.029, 63.338, 1.5)
- local far = inSphere(player_obj_id, 55.339, -39.422, 63.328, 1.5)
- local center = inSphere(player_obj_id, 56.332, -5.123, 63.242, 1.5)
- local below = inSphere(player_obj_id, 56.764, -62.689, 47.539, 1.5)
- if below then
- moveobject(player_obj_id, 56.332, -5.123, 63.242)
- end
- if near and isinvehicle(PlayerIndex) then
- moveobject(player_obj_id, 56.332, -5.123, 63.242)
- end
- if far and isinvehicle(PlayerIndex) then
- moveobject(player_obj_id, 56.332, -5.123, 63.242)
- end
- if center and isinvehicle(PlayerIndex) then
- local rspin = rand(1,11)
- if rspin >=6 then
- rspin = -0.6
- else
- rspin = 0.6
- end
- moveobject(player_obj_id, 56.332, -5.123, 66.978)
- write_float(vehicle_object + 0x70, 0.25)
- write_float(vehicle_object + 0x94, rspin)
- rprint(PlayerIndex, "|c~~ Whoa! ~~ Ay Caramba! ~~")
- end
- elseif map_name == "sidewinder" then
- local health_lapnav = inSphere(player_obj_id, 1.984, 54.499, -2.801, 1)
- if health_lapnav then
- if (obj_health < 1) then
- bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
- end
- end
- local red_tun = inSphere(player_obj_id, -18.892, -35.596, -3.551, 1.5)
- local blu_tun = inSphere(player_obj_id, 17.511, -29.548, -3.611, 1.5)
- if red_tun and isinvehicle(PlayerIndex) then
- moveobject(player_obj_id, -20.456, -33.856, -3.551)
- say(PlayerIndex, blocked_message)
- end
- if blu_tun and isinvehicle(PlayerIndex) then
- moveobject(player_obj_id, 18.968, -28.187, -3.611)
- say(PlayerIndex, blocked_message)
- end
- elseif map_name == "deathisland" then
- local health_lapnav1 = inSphere(player_obj_id, 1.499, -55.629, 1.645, 1) -- lap nav
- local health_lapnav2 = inSphere(player_obj_id, -5.238, 57.429, 2.103, 1) -- bottom jump hill sandy
- if health_lapnav1 or health_lapnav2 then
- if (obj_health < 1) then
- bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
- end
- end
- local red_base1 = inSphere(player_obj_id, -26.631, -10.149, 9.988, 1.5)
- local red_base2 = inSphere(player_obj_id, -26.622, -3.865, 9.988, 1.5)
- local blu_base1 = inSphere(player_obj_id, 29.824, 19.246, 8.665, 1.5)
- local blu_base2 = inSphere(player_obj_id, 29.956, 12.850, 8.665, 1.5)
- if red_base1 or red_base2 and isinvehicle(PlayerIndex) then
- moveobject(player_obj_id, -31.875, -7.144, 9.868)
- say(PlayerIndex, blocked_message)
- end
- if blu_base1 or blu_base2 and isinvehicle(PlayerIndex) then
- moveobject(player_obj_id, 35.013, 16.012, 8.485)
- say(PlayerIndex, blocked_message)
- end
- elseif map_name == "dangercanyon" then
- local health_lapnav = inSphere(player_obj_id, -0.110, 40.452, -5.807, 1) -- lap nav
- if health_lapnav then
- if (obj_health < 1) then
- bonushealth = timer(3000, "Bonus_HP", PlayerIndex)
- end
- end
- local red_tun = inSphere(player_obj_id, -12.165, 2.978, -2.109, 1.5)
- local blu_tun = inSphere(player_obj_id, 11.982, 2.954, -2.109, 1.5)
- local red_tele = inSphere(player_obj_id, -4.034, -3.469, 1.874, 1)
- local blu_tele = inSphere(player_obj_id, 3.859, -3.452, 1.874, 1)
- if red_tun and isinvehicle(PlayerIndex) then
- moveobject(player_obj_id, -12.125, -3.429, -2.109)
- say(PlayerIndex, blocked_message)
- end
- if blu_tun and isinvehicle(PlayerIndex) then
- moveobject(player_obj_id, 11.983, -3.473, -2.109)
- say(PlayerIndex, blocked_message)
- end
- if red_tele and isinvehicle(PlayerIndex) then
- moveobject(player_obj_id, 8.027, -3.487, 0.004)
- rprint(PlayerIndex, "|c~~ Whoa! ~~ Ay Caramba! ~~")
- end
- if blu_tele and isinvehicle(PlayerIndex) then
- moveobject(player_obj_id, -8.002, -3.640, 0.004)
- rprint(PlayerIndex, "|c~~ Whoa! ~~ Ay Caramba! ~~")
- end
- end
- end
- end
- end
- end
- end
- function Bonus_HP(PlayerIndex)
- if (game_started == true) then
- if player_alive(PlayerIndex) then
- local player_object = get_dynamic_player(PlayerIndex)
- if player_object ~= 0 then
- local obj_health = tonumber(get_var(PlayerIndex, "$hp"))
- if obj_health < 1 then
- write_float(player_object + 0xE0, 1)
- rprint(PlayerIndex, "|cYour health has been restored. ~~ Su salud se ha restaurado.")
- end
- end
- end
- end
- return false
- end
- function flip_vehicle(object)
- if (read_bit(object + 0x8B, 7) == 1) then
- if (read_bit(object + 0x10, 1) == 0) then
- return
- end
- write_vector3d(object + 0x80, 0, 0, 1)
- end
- end
- function continuous_vehicle_check()
- if (game_started == true) then
- for _,id in pairs(vehicles) do
- local veh_obj = get_object_memory(id[1])
- if (veh_obj ~= 0) then
- local driver = read_dword(veh_obj + 0x324)
- if (driver == 0xFFFFFFFF) and (id[2] <= 0) then
- destroyvehicle = timer(34, "destroy_vehicle", id[1])
- elseif (driver == 0xFFFFFFFF) and (id[2] > 0) then
- id[2] = id[2] - 1
- elseif (driver ~= 0xFFFFFFFF) then
- id[2] = destroy_time
- end
- end
- end
- return true
- else
- return false
- end
- end
- function destroy_vehicle(ObjectID)
- if (game_started == true) then
- local veh_obj = get_object_memory(ObjectID)
- if (veh_obj == 0) then return false end
- table.remove(vehicles, ObjectID)
- destroy_object(ObjectID)
- end
- return false
- end
- function OnPlayerPrespawn(PlayerIndex)
- local player_object = get_dynamic_player(PlayerIndex)
- if (player_object ~= 0) then
- if (game_type == "race") then -- players will spawn at either teams base, random coin toss
- local coin_toss = rand(1,3)
- if (coin_toss == 1) then
- local redcoord = SelectRedSpawnCoord()
- if redcoord then
- write_vector3d(player_object + 0x5C, red_spawn_coord[redcoord][1], red_spawn_coord[redcoord][2], red_spawn_coord[redcoord][3]+0.3)
- write_dword(get_player(PlayerIndex) + 0xF0, 0)
- write_dword(get_player(PlayerIndex) + 0x164, 0)
- local fx, fy, fz = red_rotation[1][1],red_rotation[1][2],red_rotation[1][3]
- local px, py, pz = GetPlayerCoords(PlayerIndex)
- local vx = fx - px
- local vy = fy - py
- local vz = fz - pz
- local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
- vx = vx / magnitude
- vy = vy / magnitude
- vz = vz / magnitude
- write_float(player_object + 0x74, vx)
- write_float(player_object + 0x78, vy)
- write_float(player_object + 0x7c, vz)
- end
- elseif (coin_toss == 2) then
- local blucoord = SelectBluSpawnCoord()
- if blucoord then
- write_vector3d(player_object + 0x5C, blu_spawn_coord[blucoord][1], blu_spawn_coord[blucoord][2], blu_spawn_coord[blucoord][3]+0.3)
- write_dword(get_player(PlayerIndex) + 0xF0, 0)
- write_dword(get_player(PlayerIndex) + 0x164, 0)
- local fx, fy, fz = blue_rotation[1][1],blue_rotation[1][2],blue_rotation[1][3]
- local px, py, pz = GetPlayerCoords(PlayerIndex)
- local vx = fx - px
- local vy = fy - py
- local vz = fz - pz
- local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
- vx = vx / magnitude
- vy = vy / magnitude
- vz = vz / magnitude
- write_float(player_object + 0x74, vx)
- write_float(player_object + 0x78, vy)
- write_float(player_object + 0x7c, vz)
- end
- end
- else -- it's not race
- if team_play then -- players will only spawn with their team
- local team = get_var(PlayerIndex, "$team")
- if team == "red" then
- local redcoord = SelectRedSpawnCoord()
- if redcoord then
- write_vector3d(player_object + 0x5C, red_spawn_coord[redcoord][1], red_spawn_coord[redcoord][2], red_spawn_coord[redcoord][3]+0.3)
- write_dword(get_player(PlayerIndex) + 0xF0, 0)
- write_dword(get_player(PlayerIndex) + 0x164, 0)
- local fx, fy, fz = red_rotation[1][1],red_rotation[1][2],red_rotation[1][3]
- local px, py, pz = GetPlayerCoords(PlayerIndex)
- local vx = fx - px
- local vy = fy - py
- local vz = fz - pz
- local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
- vx = vx / magnitude
- vy = vy / magnitude
- vz = vz / magnitude
- write_float(player_object + 0x74, vx)
- write_float(player_object + 0x78, vy)
- write_float(player_object + 0x7c, vz)
- end
- elseif team == "blue" then
- local blucoord = SelectBluSpawnCoord()
- if blucoord then
- write_vector3d(player_object + 0x5C, blu_spawn_coord[blucoord][1], blu_spawn_coord[blucoord][2], blu_spawn_coord[blucoord][3]+0.3)
- write_dword(get_player(PlayerIndex) + 0xF0, 0)
- write_dword(get_player(PlayerIndex) + 0x164, 0)
- local fx, fy, fz = blue_rotation[1][1],blue_rotation[1][2],blue_rotation[1][3]
- local px, py, pz = GetPlayerCoords(PlayerIndex)
- local vx = fx - px
- local vy = fy - py
- local vz = fz - pz
- local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
- vx = vx / magnitude
- vy = vy / magnitude
- vz = vz / magnitude
- write_float(player_object + 0x74, vx)
- write_float(player_object + 0x78, vy)
- write_float(player_object + 0x7c, vz)
- end
- end
- else -- players will spawn at either teams base, random coin toss
- local coin_toss = rand(1,3)
- if (coin_toss == 1) then
- local redcoord = SelectRedSpawnCoord()
- if redcoord then
- write_vector3d(player_object + 0x5C, red_spawn_coord[redcoord][1], red_spawn_coord[redcoord][2], red_spawn_coord[redcoord][3]+0.3)
- write_dword(get_player(PlayerIndex) + 0xF0, 0)
- write_dword(get_player(PlayerIndex) + 0x164, 0)
- local fx, fy, fz = red_rotation[1][1],red_rotation[1][2],red_rotation[1][3]
- local px, py, pz = GetPlayerCoords(PlayerIndex)
- local vx = fx - px
- local vy = fy - py
- local vz = fz - pz
- local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
- vx = vx / magnitude
- vy = vy / magnitude
- vz = vz / magnitude
- write_float(player_object + 0x74, vx)
- write_float(player_object + 0x78, vy)
- write_float(player_object + 0x7c, vz)
- end
- elseif (coin_toss == 2) then
- local blucoord = SelectBluSpawnCoord()
- if blucoord then
- write_vector3d(player_object + 0x5C, blu_spawn_coord[blucoord][1], blu_spawn_coord[blucoord][2], blu_spawn_coord[blucoord][3]+0.3)
- write_dword(get_player(PlayerIndex) + 0xF0, 0)
- write_dword(get_player(PlayerIndex) + 0x164, 0)
- local fx, fy, fz = blue_rotation[1][1],blue_rotation[1][2],blue_rotation[1][3]
- local px, py, pz = GetPlayerCoords(PlayerIndex)
- local vx = fx - px
- local vy = fy - py
- local vz = fz - pz
- local magnitude = math.sqrt(vx*vx + vy*vy + vz*vz)
- vx = vx / magnitude
- vy = vy / magnitude
- vz = vz / magnitude
- write_float(player_object + 0x74, vx)
- write_float(player_object + 0x78, vy)
- write_float(player_object + 0x7c, vz)
- end
- end
- end
- end
- end
- end
- function SelectRedSpawnCoord()
- if #red_spawn_coord > 0 then
- local index = rand(1, #red_spawn_coord+1)
- local coord = red_spawn_coord[index]
- if (CheckForDuplicateSpawn(coord) == false) then
- return index
- end
- end
- return nil
- end
- function SelectBluSpawnCoord()
- if #blu_spawn_coord > 0 then
- local index = rand(1, #blu_spawn_coord+1)
- local coord = blu_spawn_coord[index]
- if (CheckForDuplicateSpawn(coord) == false) then
- return index
- end
- end
- return nil
- end
- function CheckForDuplicateSpawn(coord)
- for i=1,loop_end do
- local dyn_player = get_dynamic_player(i)
- if(dyn_player ~= 0) then
- local px,py,pz = GetPlayerCoords(i)
- local distance = DistanceFormula(coord[1],coord[2],coord[3],px,py,pz)
- if (distance < 1/3) then
- return true
- end
- end
- end
- return false
- end
- function DistanceFormula(x1,y1,z1,x2,y2,z2)
- return math.sqrt(math.pow(x1 - x2,2) + math.pow(y1 - y2,2) + math.pow(z1 - z2,2))
- end
- -- Colors:
- -- 0 = white, 1 = black, 2 = red, 3 = blue, 4 = gray, 5 = yellow, 6 = green
- -- 7 = pink, 8 = purple, 9 = cyan, 10 = cobalt, 11 = orange, 12 = teal, 13 = sage,
- -- 14 = brown, 15 = tan, 16 = maroon, 17 = salmon
- SKITTLES = {0,2,3,5,6,7,8,9,10,11,12,13,17} -- no dark colors: no black, gray, brown, tan, maroon
- function ChangeColor(PlayerIndex)
- local color = rand(1, #SKITTLES+1) --old: rand(0, 18)
- local red_color = 0
- local blue_color = 11
- if map_name == "boardingaction" then red_color = 7 blue_color = 5 end
- if (player_present(PlayerIndex) == true) then
- if team_play then
- if (get_var(PlayerIndex,"$team") == "red") then
- write_word(get_player(PlayerIndex) + 0x60, red_color)
- else
- write_word(get_player(PlayerIndex) + 0x60, blue_color)
- end
- else
- write_word(get_player(PlayerIndex) + 0x60, color)
- end
- end
- end
- function Load_Tables()
- red_spawn_coord = {}
- blu_spawn_coord = {}
- ffa_blu_spawn_coord = {}
- ffa_red_spawn_coord = {}
- red_rotation = {}
- blue_rotation = {}
- if map_name == "bloodgulch" then
- red_rotation[1] = {60.987, -121.606, 0.274} -- direction a red player faces relative to this x,y,z coordinate (1st nav)
- blue_rotation[1] = {60.987, -121.606, 0.274} -- direction a blue player faces relative to this x,y,z coordinate(1st nav)
- if team_play then loop_end = 14 else loop_end = 28 end -- default number of spawns for duplicate spawn check
- -- 14 red player spawns
- red_spawn_coord[1] = {71.972, -149.555, 0.914}
- red_spawn_coord[2] = {83.435, -147.405, 0.134}
- red_spawn_coord[3] = {95.646, -141.733, 0.434}
- red_spawn_coord[4] = {109.604, -133.539, 0.984}
- red_spawn_coord[5] = {110.368, -145.701, 0.314}
- red_spawn_coord[6] = {100.182, -152.792, 0.294}
- red_spawn_coord[7] = {88.121, -159.214, 0.324}
- red_spawn_coord[8] = {108.054, -163.087, 0.294}
- red_spawn_coord[9] = {79.792, -163.393, 0.504}
- red_spawn_coord[10] = {69.950, -172.245, 1.314}
- red_spawn_coord[11] = {86.032, -168.319, 0.324}
- red_spawn_coord[12] = {84.557, -176.190, 0.704}
- red_spawn_coord[13] = {96.490, -175.511, 1.154}
- red_spawn_coord[14] = {110.034, -173.677, 0.784}
- -- 14 blue player spawns
- blu_spawn_coord[1] = {56.687, -84.156, 0.324}
- blu_spawn_coord[2] = {47.260, -81.080, 0.264}
- blu_spawn_coord[3] = {42.720, -86.531, 0.294}
- blu_spawn_coord[4] = {45.686, -96.196, 1.734}
- blu_spawn_coord[5] = {30.861, -94.013, 0.974}
- blu_spawn_coord[6] = {23.784, -104.564, 2.664}
- blu_spawn_coord[7] = {33.291, -80.404, 0.214}
- blu_spawn_coord[8] = {25.868, -79.263, 0.744}
- blu_spawn_coord[9] = {13.501, -71.233, 3.974}
- blu_spawn_coord[10] = {27.702, -68.885, 0.854}
- blu_spawn_coord[11] = {41.159, -62.410, 1.264}
- blu_spawn_coord[12] = {47.594, -72.545, 0.124}
- blu_spawn_coord[13] = {52.955, -63.441, 1.684}
- blu_spawn_coord[14] = {63.075, -70.659, 1.734}
- elseif map_name == "boardingaction" then -- top circle duel
- red_rotation[1] = {54.453, -3.000, 63.299} -- direction a red player faces relative to this x,y,z coordinate (1st nav)
- blue_rotation[1] = {54.453, -3.000, 63.299} -- direction a blue player faces relative to this x,y,z coordinate(1st nav)
- if team_play then loop_end = 12 else loop_end = 24 end
- -- 12 blue player spawns
- red_spawn_coord[1] = {54.646, -22.164, 63.211}
- red_spawn_coord[2] = {60.039, -20.691, 63.211}
- red_spawn_coord[3] = {63.968, -18.362, 63.211}
- red_spawn_coord[4] = {67.747, -14.964, 63.211}
- red_spawn_coord[5] = {70.650, -11.336, 63.211}
- red_spawn_coord[6] = {72.477, -7.185, 63.211}
- red_spawn_coord[7] = {73.282, -2.899, 63.211}
- red_spawn_coord[8] = {72.473, 1.539, 63.211}
- red_spawn_coord[9] = {70.742, 6.051, 63.211}
- red_spawn_coord[10] = {68.074, 9.748, 63.211}
- red_spawn_coord[11] = {64.011, 12.583, 63.211}
- red_spawn_coord[12] = {60.061, 14.715, 63.211}
- -- 12 blue player spawns
- blu_spawn_coord[1] = {54.447, 15.572, 63.211}
- blu_spawn_coord[2] = {50.116, 14.673, 63.211}
- blu_spawn_coord[3] = {46.262, 12.553, 63.211}
- blu_spawn_coord[4] = {43.029, 9.801, 63.211}
- blu_spawn_coord[5] = {40.269, 6.307, 63.211}
- blu_spawn_coord[6] = {38.030, 1.624, 63.211}
- blu_spawn_coord[7] = {37.312, -2.881, 63.211}
- blu_spawn_coord[8] = {37.985, -7.338, 63.211}
- blu_spawn_coord[9] = {40.191, -11.560, 63.211}
- blu_spawn_coord[10] = {42.853, -15.126, 63.211}
- blu_spawn_coord[11] = {46.043, -18.314, 63.211}
- blu_spawn_coord[12] = {49.845, -20.785, 63.211}
- elseif map_name == "sidewinder" then
- red_rotation[1] = {1.984, 54.499, -2.801} -- direction a red player faces relative to this x,y,z coordinate (1st nav)
- blue_rotation[1] = {1.984, 54.499, -2.801} -- direction a blue player faces relative to this x,y,z coordinate(1st nav)
- if team_play then loop_end = 10 else loop_end = 20 end -- default number of spawns for duplicate spawn check
- -- 10 red player spawns
- red_spawn_coord[1] = {-12.384, 0.223, -3.551}
- red_spawn_coord[2] = {-27.763, -8.341, -3.551}
- red_spawn_coord[3] = {-20.076, -19.530, -3.551}
- red_spawn_coord[4] = {-29.403, -19.944, -3.551}
- red_spawn_coord[5] = {-22.507, -36.581, -3.551}
- red_spawn_coord[6] = {-32.377, -24.577, -3.551}
- red_spawn_coord[7] = {-38.141, -21.449, -3.311}
- red_spawn_coord[8] = {-47.971, -17.862, -3.551}
- red_spawn_coord[9] = {-35.921, -6.185, -3.551}
- red_spawn_coord[10] = {-44.115, 1.357, -3.551}
- -- 10 blue player spawns
- blu_spawn_coord[1] = {20.145, -33.973, -3.611}
- blu_spawn_coord[2] = {27.842, -27.690, -3.381}
- blu_spawn_coord[3] = {34.602, -28.499, -3.381}
- blu_spawn_coord[4] = {44.241, -21.996, -3.491}
- blu_spawn_coord[5] = {43.216, -9.929, -3.771}
- blu_spawn_coord[6] = {48.448, 12.211, -3.711}
- blu_spawn_coord[7] = {35.687, 2.006, -3.711}
- blu_spawn_coord[8] = {19.494, -3.963, -3.611}
- blu_spawn_coord[9] = {29.766, -10.996, -3.611}
- blu_spawn_coord[10] = {18.778, -19.560, -3.611}
- elseif map_name == "deathisland" then
- red_rotation[1] = {-37.972, -7.168, 5.958} -- direction a red player faces relative to this x,y,z coordinate (1st nav)
- blue_rotation[1] = {43.350, 16.334, 4.905} -- direction a blue player faces relative to this x,y,z coordinate(1st nav)
- if team_play then loop_end = 10 else loop_end = 20 end -- default number of spawns for duplicate spawn check
- -- 10 red player spawns
- red_spawn_coord[1] = {-72.592, 12.072, 1.918}
- red_spawn_coord[2] = {-86.863, 2.426, 1.918}
- red_spawn_coord[3] = {-72.936, -6.734, 1.918}
- red_spawn_coord[4] = {-82.246, -12.163, 1.918}
- red_spawn_coord[5] = {-71.184, -20.207, 1.918}
- red_spawn_coord[6] = {-78.008, -29.144, 1.918}
- red_spawn_coord[7] = {-64.951, -31.880, 1.918}
- red_spawn_coord[8] = {-78.379, -43.287, 1.918}
- red_spawn_coord[9] = {-68.724, -50.679, 1.918}
- red_spawn_coord[10] = {-53.071, -61.466, 1.918}
- -- 10 blue player spawns
- blu_spawn_coord[1] = {67.315, -35.584, 1.985}
- blu_spawn_coord[2] = {69.620, -17.083, 1.985}
- blu_spawn_coord[3] = {83.420, -17.758, 1.985}
- blu_spawn_coord[4] = {73.718, -2.966, 1.985}
- blu_spawn_coord[5] = {88.080, 7.826, 1.985}
- blu_spawn_coord[6] = {74.635, 17.851, 1.985}
- blu_spawn_coord[7] = {82.911, 30.977, 1.985}
- blu_spawn_coord[8] = {73.635, 38.455, 1.985}
- blu_spawn_coord[9] = {68.304, 55.613, 1.985}
- blu_spawn_coord[10] = {63.068, 64.263, 1.985}
- elseif map_name == "dangercanyon" then
- red_rotation[1] = {-0.018, 36.449, -7.517} -- direction a red player faces relative to this x,y,z coordinate (1st nav)
- blue_rotation[1] = {-0.018, 36.449, -7.517} -- direction a blue player faces relative to this x,y,z coordinate(1st nav)
- if team_play then loop_end = 9 else loop_end = 18 end -- default number of spawns for duplicate spawn check
- -- 9 red player spawns
- red_spawn_coord[1] = {-6.805, 55.087, -7.340}
- red_spawn_coord[2] = {-14.742, 53.988, -8.430}
- red_spawn_coord[3] = {-24.504, 48.229, -9.140}
- red_spawn_coord[4] = {-33.591, 38.375, -7.360}
- red_spawn_coord[5] = {-44.865, 33.303, -8.610}
- red_spawn_coord[6] = {-52.497, 28.552, -10.140}
- red_spawn_coord[7] = {-58.111, 19.136, -8.950}
- red_spawn_coord[8] = {-43.594, -0.295, -1.820}
- red_spawn_coord[9] = {-34.229, 24.165, -6.630}
- -- 9 blue player spawns
- blu_spawn_coord[1] = {7.086, 54.012, -7.940}
- blu_spawn_coord[2] = {21.758, 51.079, -8.660}
- blu_spawn_coord[3] = {27.562, 44.293, -9.500}
- blu_spawn_coord[4] = {31.610, 39.054, -7.690}
- blu_spawn_coord[5] = {42.533, 33.726, -7.690}
- blu_spawn_coord[6] = {50.971, 29.671, -9.670}
- blu_spawn_coord[7] = {57.635, 19.581, -8.950}
- blu_spawn_coord[8] = {47.326, -0.289, -1.930}
- blu_spawn_coord[9] = {38.166, 23.633, -7.300}
- end
- end
- function moveobject(ObjectID, x, y, z)
- if not game_started then return end
- 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 not game_started then return end
- 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)
- if not game_started then return end
- 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 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 getteamplay()
- if (get_var(0, "$ffa") == "0") then
- return true
- else
- return false
- end
- end
- function GetPlayerCoords(PlayerIndex)
- local player_object = get_dynamic_player(PlayerIndex)
- if (player_object ~= 0) then
- local x,y,z = read_vector3d(get_dynamic_player(PlayerIndex) + 0x5C)
- local vehicle_objectid = read_dword(player_object + 0x11C)
- local vehicle_object = get_object_memory(vehicle_objectid)
- if (vehicle_object ~= 0 and vehicle_object ~= nil) then
- local vx,vy,vz = read_vector3d(vehicle_object + 0x5C)
- x = x + vx
- y = y + vy
- z = z + vz
- end
- return math.round(x, 2),math.round(y, 2),math.round(z, 2)
- end
- return nil
- end
- function math.round(num, idp)
- return tonumber(string.format("%." .. (idp or 0) .. "f", num))
- end
- function OnError(Message)
- print(debug.traceback())
- end
- -- Created by H® Shaft
- -- Visit http://halorace.org/forum/index.php
- -- 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