From e1354cb06b0c90b246f1b12cba4ed72849ae77f1 Mon Sep 17 00:00:00 2001 From: Proddy3 Date: Thu, 10 Oct 2019 23:51:59 +0100 Subject: [PATCH] Bug fixes - 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 --- Randomiser/CustomLimits.ini | 2 +- .../Resources/MissionModules/RandomItems.lua | 31 ++++++++++++++----- .../MissionModules/RandomMissions.lua | 19 ++++++++++++ .../MissionScripts/HandleLevelLoad.lua | 4 +-- .../MissionScripts/HandleMissionLoad.lua | 4 +-- .../Resources/MissionScripts/HandleSDLoad.lua | 4 +-- 6 files changed, 50 insertions(+), 14 deletions(-) diff --git a/Randomiser/CustomLimits.ini b/Randomiser/CustomLimits.ini index 3c1b94d..c2824b2 100644 --- a/Randomiser/CustomLimits.ini +++ b/Randomiser/CustomLimits.ini @@ -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 diff --git a/Randomiser/Resources/MissionModules/RandomItems.lua b/Randomiser/Resources/MissionModules/RandomItems.lua index 6a87fd8..8d9e62a 100644 --- a/Randomiser/Resources/MissionModules/RandomItems.lua +++ b/Randomiser/Resources/MissionModules/RandomItems.lua @@ -85,15 +85,15 @@ 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 @@ -101,7 +101,7 @@ if Settings.RandomItems then 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 @@ -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 = {} diff --git a/Randomiser/Resources/MissionModules/RandomMissions.lua b/Randomiser/Resources/MissionModules/RandomMissions.lua index f8d2e1d..d5a9b48 100644 --- a/Randomiser/Resources/MissionModules/RandomMissions.lua +++ b/Randomiser/Resources/MissionModules/RandomMissions.lua @@ -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 \ No newline at end of file diff --git a/Randomiser/Resources/MissionScripts/HandleLevelLoad.lua b/Randomiser/Resources/MissionScripts/HandleLevelLoad.lua index d3c0bbf..cc2fae1 100644 --- a/Randomiser/Resources/MissionScripts/HandleLevelLoad.lua +++ b/Randomiser/Resources/MissionScripts/HandleLevelLoad.lua @@ -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 \ No newline at end of file diff --git a/Randomiser/Resources/MissionScripts/HandleMissionLoad.lua b/Randomiser/Resources/MissionScripts/HandleMissionLoad.lua index 524515f..c3cf95e 100644 --- a/Randomiser/Resources/MissionScripts/HandleMissionLoad.lua +++ b/Randomiser/Resources/MissionScripts/HandleMissionLoad.lua @@ -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 \ No newline at end of file diff --git a/Randomiser/Resources/MissionScripts/HandleSDLoad.lua b/Randomiser/Resources/MissionScripts/HandleSDLoad.lua index 775496a..d126ae5 100644 --- a/Randomiser/Resources/MissionScripts/HandleSDLoad.lua +++ b/Randomiser/Resources/MissionScripts/HandleSDLoad.lua @@ -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 \ No newline at end of file