Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Chaos gulch by 002 v1.1 (not my script)
- -- Configuration
- -- Time in seconds
- CHAOS_GULCH_DURATION = 90
- -- Chance (%age) per game
- CHAOS_GULCH_CHANCE = 100
- -- Chaos gulch (if it happens) happens after this many seconds into the game
- CHAOS_GULCH_TIME_MINIMUM = 20
- -- Chaos gulch (if it happens) happens before this many seconds into the game
- CHAOS_GULCH_TIME_MAXIMUM = 120
- -- Warn this many seconds before carnage begins (0 = don't warn)
- WARNING_TIME = 5.0
- WARNING_MESSAGE = "Prepare for carnage..."
- MESSAGE_BEGINNING = "Begin carnage."
- MESSAGE_ENDING = "Carnage has ended. Resume normal gameplay."
- -- Use random projectiles
- RANDOM_PROJECTILES = true
- -- Don't use projectiles that have a velocity of 0
- NO_SLOW_PROJECTILES = true
- -- Round-based weapons don't use up ammo
- INFINITE_AMMO = true
- -- I believe I can fly
- FLYING_WARTHOGS = true
- -- End of configuration
- api_version = "1.6.0.0"
- game_started_time = nil
- warned = false
- in_progress = false
- chaos_gulch_time = CHAOS_GULCH_TIME_MINIMUM
- -- {Function, Address, Value}
- rollback_actions = {}
- -- Projectiles to choose from
- random_projectiles = {}
- -- Dependencies for weapons
- projectile_dependencies = {}
- function OnScriptLoad()
- if(register_callback ~= nil) then
- register_callback(cb['EVENT_TICK'],"GameTick")
- register_callback(cb['EVENT_GAME_START'],"GameStart")
- register_callback(cb['EVENT_GAME_END'],"GameEnd")
- else
- write_float = writefloat
- read_float = readfloat
- write_dword = writedword
- read_dword = readdword
- write_word = writeword
- read_word = readword
- timer = registertimer
- say_all = say
- rand = getrandomnumber
- SyncAllWeapons = SyncAllWeaponsPhasor
- timer(1/30 * 1000,"GameTick_Phasor")
- end
- end
- function OnScriptUnload()
- RollbackEverything()
- end
- function RollbackEverything()
- for i=1,TableLength(rollback_actions) do
- rollback_actions[i][1](rollback_actions[i][2],rollback_actions[i][3])
- end
- rollback_actions = {}
- projectile_dependencies = {}
- random_projectiles = {}
- end
- function TableLength(TableVariable)
- if(TableVariable == nil or type(TableVariable) ~= "table") then return 0 end
- local table_size = 0
- while TableVariable[table_size + 1] ~= nil do table_size = table_size + 1 end
- return table_size
- end
- function GameStart()
- game_started_time = os.clock()
- warned = false
- in_progress = false
- chaos_gulch_time = rand(CHAOS_GULCH_TIME_MINIMUM,CHAOS_GULCH_TIME_MAXIMUM)
- end
- function GameEnd()
- RollbackEverything()
- game_started_time = nil
- in_progress = false
- end
- function PrepareRollback()
- local tag_array = read_dword(0x40440000)
- local tag_count = read_word(0x4044000C)
- for i=0,tag_count-1 do
- local offset = tag_array + 0x20 * i
- if(RANDOM_PROJECTILES) then
- if(read_dword(offset) == 2003132784) then --weap
- local data_offset = read_dword(offset + 0x14)
- local trigger_count = read_dword(data_offset + 0x4FC)
- if(trigger_count > 0) then
- local trigger_offset = read_dword(data_offset + 0x4FC + 0x4)
- for q=0,trigger_count-1 do
- local trigger_offset = trigger_offset + q * 276
- local value_offset = trigger_offset + q * 276 + 0x94 + 0xC
- rollback_actions[TableLength(rollback_actions) + 1] = { write_dword, value_offset, read_dword(value_offset) }
- projectile_dependencies[TableLength(projectile_dependencies) + 1] = value_offset
- rollback_actions[TableLength(rollback_actions) + 1] = { write_dword, trigger_offset, read_dword(trigger_offset) }
- write_dword(trigger_offset, 0)
- if(INFINITE_AMMO) then
- rollback_actions[TableLength(rollback_actions) + 1] = { write_word, trigger_offset + 0x22, read_word(trigger_offset + 0x22) }
- write_word(trigger_offset + 0x22, 0)
- end
- end
- end
- end
- if(read_dword(offset) == 1886547818) then --proj
- local identity = read_dword(offset + 0xC)
- local data_offset = read_dword(offset + 0x14)
- if(NO_SLOW_PROJECTILES == false or (read_float(data_offset + 0x1E4) ~= 0 and read_float(data_offset + 0x1E8) ~= 0)) then
- random_projectiles[TableLength(random_projectiles) + 1] = identity
- end
- end
- end
- if(FLYING_WARTHOGS) then
- if(read_dword(offset) == 1986357353) then --vehi
- local data_offset = read_dword(offset + 0x14)
- local value = read_word(data_offset + 0x2F4)
- if(value == 0 or value == 1 or value == 2 or value == 4) then
- rollback_actions[TableLength(rollback_actions) + 1] = { write_word, data_offset + 0x2F4, read_word(data_offset + 0x2F4) }
- write_word(data_offset + 0x2F4, 0x3)
- end
- end
- end
- end
- end
- function RandomProjectile()
- if(TableLength(random_projectiles) == 0) then return 0xFFFFFFFF end
- return random_projectiles[rand(1,TableLength(random_projectiles))]
- end
- function GameTick()
- if(game_started_time ~= nil) then
- local time = os.clock()
- if(time > (game_started_time - WARNING_TIME + chaos_gulch_time) and warned == false and WARNING_TIME ~= 0.0) then
- say_all(WARNING_MESSAGE)
- warned = true
- end
- if(time > (game_started_time + chaos_gulch_time) and in_progress == false) then
- say_all(MESSAGE_BEGINNING)
- in_progress = true
- PrepareRollback()
- if(INFINITE_AMMO) then
- timer(1000,"SyncAllWeapons")
- end
- end
- if(time > (game_started_time + chaos_gulch_time + CHAOS_GULCH_DURATION)) then
- say_all(MESSAGE_ENDING)
- in_progress = false
- game_started_time = nil
- RollbackEverything()
- end
- if(in_progress and TableLength(projectile_dependencies) > 0) then
- for i=1,TableLength(projectile_dependencies) do
- write_dword(projectile_dependencies[i],RandomProjectile())
- end
- end
- end
- end
- function SyncAllWeapons()
- for i=1,16 do
- if(player_alive(i) == true) then
- local player_dyn = get_dynamic_player(i)
- for q=0,3 do
- local object_id = read_dword(player_dyn + 0x2F8 + q * 0x4)
- if(object_id ~= 0xFFFFFFFF) then sync_ammo(object_id) end
- end
- end
- end
- return in_progress
- end
- -- Phasor stuff
- function GetRequiredVersion()
- return 200
- end
- function SyncAllWeaponsPhasor()
- for i=0,15 do
- if(getplayer(i) ~= nil) then
- local player_objectid = getplayerobjectid(i)
- if(player_objectid ~= nil) then
- local player_dyn = getobject(player_objectid)
- for q=0,3 do
- local object_id = read_dword(player_dyn + 0x2F8 + q * 0x4)
- if(object_id ~= 0xFFFFFFFF) then updateammo(object_id) end
- end
- end
- end
- end
- return in_progress
- end
- function GameTick_Phasor()
- GameTick()
- return true
- end
- OnNewGame = GameStart
- OnGameEnd = GameEnd
Advertisement
Add Comment
Please, Sign In to add comment