Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
- Fixed a bug in Custom Limits for sound
- Added randomising the item above races/bonus mission
- Added the start of randomising races/bonus missions
- Re-added printing files to log in DebugLevel 5
  • Loading branch information
Hampo committed Oct 10, 2019
1 parent f99b80c commit e1354cb
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Randomiser/CustomLimits.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
; FenceLimit: The maximum amount of fence collision indices. Defaults to 8.
; DynaPhysLimit: The maximum amount of dyna phys collision indices. Defaults to 20.

[Sound] Section
[Sound]
PlayingClipPlayerLimit=100
PlayingStreamPlayerLimit=32

Expand Down
31 changes: 24 additions & 7 deletions Randomiser/Resources/MissionModules/RandomItems.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,23 @@ if Settings.RandomItems then
RandomItemPool["card_idle"] = ""
RandomItemPool["beecamera"] = ""
RandomItemPool["huskA"] = ""

if Settings.RandomItemsIncludeChars then
for i=1,#RandomPedPool do
RandomItemPool[RandomPedPool[i] .. "_h"] = "art\\chars\\" .. RandomPedPool[i]:sub(1, 6) .. "_m"
end
end

local sort = 5
Level = {}
Mission = {}
if not tbl.Level[sort] then
tbl.Level[sort] = Level
else
Level = tbl.Level[sort]
end
if not tbl.Mission[sort] then
tbl.Mission[sort] = Mission
else
Mission = tbl.Mission[sort]
end

function GetTmpTable()
local tmp = CloneKVTable(RandomItemPool)
local tmp = CloneKVTable(RandomItemPool)
if Settings.RandomItemsIncludeCars then
if Settings.RandomMissionVehicles and MissionVehicles then
for k,v in pairs(MissionVehicles) do
Expand All @@ -122,9 +122,26 @@ if Settings.RandomItems then
end
end
end
if Settings.RandomItemsIncludeChars then
for i=1,#RandomPedPool do
tmp[RandomPedPool[i] .. "_h"] = "art\\chars\\" .. RandomPedPool[i]:sub(1, 6) .. "_m"
end
end
return tmp
end

function Level.RandomItems(LoadFile, InitFile, Level, Path)
local TmpItemPool = CloneKVTable(RandomItemPool)
InitFile = InitFile:gsub("AddNPCCharacterBonusMission%s*%(%s*\"([^\n]-)\"%s*,%s*\"([^\n]-)\"%s*,%s*\"([^\n]-)\"%s*,%s*\"([^\n]-)\"%s*,%s*\"([^\n]-)\"", function(npc, skeleton, location, mission, drawable)
local newDrawable, newDrawablePath = GetRandomFromKVTbl(TmpItemPool, true)
if newDrawablePath and newDrawablePath:len() > 0 and not LoadFile:match(newDrawablePath) then
LoadFile = LoadFile .. "\r\nLoadP3DFile(\"" .. newDrawablePath .. ".p3d\");"
end
return "AddNPCCharacterBonusMission(\"" .. npc .. "\",\"" .. skeleton .. "\",\"" .. location .. "\",\"" .. mission .. "\",\"" .. newDrawable .. "\""
end)
return LoadFile, InitFile
end

function Mission.RandomItems(LoadFile, InitFile, Level, Mission, Path)
local items = {}
local randomisedPaths = {}
Expand Down
19 changes: 19 additions & 0 deletions Randomiser/Resources/MissionModules/RandomMissions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ if Settings.RandomMissions then
return "AddMission(\"m" .. orig .. "\""
end
end)
--[[local missions = {"sr1", "sr2", "sr3", "gr1", "bm1"}
local oldMission
local newMission
InitFile = InitFile:gsub("(.-)\n", function(original)
original = original:gsub("AddNPCCharacterBonusMission%s*%(%s*\"([^\n]-)\"%s*,%s*\"([^\n]-)\"%s*,%s*\"([^\n]-)\"%s*,%s*\"([^\n]-)\"", function(npc, skeleton, location, mission)
oldMission = mission
newMission = GetRandomFromTbl(missions, true)
return "AddNPCCharacterBonusMission(\"" .. npc .. "\",\"" .. skeleton .. "\",\"" .. location .. "\",\"" .. newMission .. "\""
end)
if oldMission and newMission then
original = original:gsub("SetBonusMissionDialoguePos%s*%(%s*\"" .. oldMission .. "\"", "SetBonusMissionDialoguePos(\"" .. newMission .. "\"")
original = original:gsub("SetConversationCam%s*%(%s*(%d)%s*,%s*\"([^\n]-)\"%s*,*%s*\"" .. oldMission .. "\"", "SetConversationCam(%1,\"%2\",\"" .. newMission .. "\"")
original = original:gsub("ClearAmbientAnimations%s*%(%s*\"" .. oldMission .. "\"", "ClearAmbientAnimations(\"" .. newMission .. "\"")
original = original:gsub("AddAmbientNpcAnimation%s*%(%s*\"([^\n]-)\"%s*,*%s*\"" .. oldMission .. "\"", "AddAmbientNpcAnimation(\"%1\",\"" .. newMission .. "\"")
original = original:gsub("AddAmbientPcAnimation%s*%(%s*\"([^\n]-)\"%s*,*%s*\"" .. oldMission .. "\"", "AddAmbientPcAnimation(\"%1\",\"" .. newMission .. "\"")
original = original:gsub("SetCamBestSide%s*%(%s*\"([^\n]-)\"%s*,*%s*\"" .. oldMission .. "\"", "SetCamBestSide(\"%1\",\"" .. newMission .. "\"")
end
return original .. "\n"
end)]]--
return LoadFile, InitFile
end
end
4 changes: 2 additions & 2 deletions Randomiser/Resources/MissionScripts/HandleLevelLoad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ if MissionModules.Level then
end
end
LevelInit = InitFile
--[[if Settings.DebugLevel >= 5 then
if Settings.DebugLevel >= 5 then
DebugPrint("Level Load File:\r\n" .. LoadFile)
DebugPrint("Level Init File:\r\n" .. InitFile)
end]]--
end
Output(LoadFile)
end
4 changes: 2 additions & 2 deletions Randomiser/Resources/MissionScripts/HandleMissionLoad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ if MissionModules.Mission then
end
end
MissionInit = InitFile
--[[if Settings.DebugLevel >= 5 then
if Settings.DebugLevel >= 5 then
DebugPrint("Mission Load File:\r\n" .. LoadFile)
DebugPrint("Mission Init File:\r\n" .. InitFile)
end]]--
end
Output(LoadFile)
end
4 changes: 2 additions & 2 deletions Randomiser/Resources/MissionScripts/HandleSDLoad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ if MissionModules.SundayDrive then
LastLevel = nil
PlayerStats = nil
SDInit = InitFile
--[[if Settings.DebugLevel >= 5 then
if Settings.DebugLevel >= 5 then
DebugPrint("SD Load File:\r\n" .. LoadFile)
DebugPrint("SD Init File:\r\n" .. InitFile)
end]]--
end
Output(LoadFile)
end

0 comments on commit e1354cb

Please sign in to comment.