replay_saving = 0 local store_replay_delay = 1 local fired = 0 local linesofdata = 0 local temp_fired = 0 local last_frame = {} function save_replay_init(e) end --no way to zoom in down sights yet function save_replay_main(e) if replay_saving == 0 then file = io.output("replay.txt") replay_saving = 1 return elseif replay_saving == 1 then if fired == 0 then if g_PlayerGunFired == 1 then fired = 1 end end if GetTimer(e) > store_replay_delay then StartTimer(e) linesofdata = linesofdata + 1 io.write(g_PlayerPosX.."\n") io.write(g_PlayerPosY.."\n") io.write(g_PlayerPosZ.."\n") io.write(g_PlayerAngX.."\n") io.write(g_PlayerAngY.."\n") io.write(g_PlayerAngZ.."\n") io.write(g_PlayerHealth.."\n") io.write(g_PlayerGunID.."\n") io.write(g_PlayerGunAmmoCount.."\n") if fired == 1 then io.write((1).."\n") fired = 0 else io.write((0).."\n") end for a = 1, 2999 do if g_Entity[a] ~= nil then if a ~= g_PlayerObjNo then if g_Entity[a]['obj'] ~= nil then if ai_soldier_state[a] ~= nil then io.write(g_Entity[a]['x'].."\n") io.write(g_Entity[a]['y'].."\n") io.write(g_Entity[a]['z'].."\n") io.write(g_Entity[a]['angley'].."\n") io.write(g_Entity[a]['health'].."\n") --io.write(ai_soldier_state[a].."\n") io.write(GetAnimationFrame(a).."\n") end end end end end end elseif replay_saving == 2 then for a = 1, 2999 do if g_Entity[a] ~= nil then if a ~= g_PlayerObjNo then if g_Entity[a]['obj'] ~= nil then if ai_soldier_state[a] ~= nil then --SetAttachmentVisible(a,0) StopAnimation(a) SwitchScript(a,"") end end end end end file:close() --io.input("replay.txt") file = io.open("replay.txt","r") replay_saving = 3 elseif replay_saving == 3 then if g_PlayerHealth > 0 then --FreezePlayer() current_line = 0 FreezeAI() replay_saving = 4 end elseif replay_saving == 4 then if current_line < linesofdata then if GetTimer(e) > store_replay_delay then current_line = current_line + 1 StartTimer(e) SetFreezePosition(file:read("*n","*l"),file:read("*n","*l"),file:read("*n","*l")) SetFreezeAngle(file:read("*n","*l"),file:read("*n","*l"),file:read("*n","*l")) temp = file:read("*n","*l") if g_PlayerHealth > temp then HurtPlayer(e,g_PlayerHealth-temp) else SetPlayerHealth(temp) end temp_gun = file:read("*n","*l") if g_PlayerGunID ~= temp_gun then ChangePlayerWeaponID(temp_gun) end temp_ammo = file:read("*n","*l") temp_fired = file:read("*n","*l") UnFreezeAI() for a = 1, 2999 do if g_Entity[a] ~= nil then if a ~= g_PlayerObjNo then if g_Entity[a]['obj'] ~= nil then if ai_soldier_state[a] ~= nil then CollisionOff(a) SetPosition(a,file:read("*n","*l"),file:read("*n","*l"),file:read("*n","*l")) SetRotation(a,0,file:read("*n","*l"),0) SetEntityHealth(a,file:read("*n","*l")) --ai_soldier_state[a] = tostring(file:read("*n","*l")) last_frame[a] = file:read("*n","*l") SetAnimationFrame(a,last_frame[a]) end end end end end FreezeAI() end --UnFreezePlayer() FirePlayerWeapon(temp_fired) temp_fired = 0 TransportToFreezePosition() --FreezePlayer() else file:close() replay_saving = 5 end --]] elseif replay_saving == 5 then Prompt("DONE") JumpToLevelIfUsed(e) end for a = 1, 2999 do if g_Entity[a] ~= nil then if a ~= g_PlayerObjNo then if g_Entity[a]['obj'] ~= nil then if ai_soldier_state[a] ~= nil then if g_Entity[a]['health'] < 1 then Spawn(a) SetEntityHealth(a,100) SetPosition(a,0,0,0) end end end end end end --Text(0,1,4,replay_saving) end function save_replay_exit(e) end