Initial commit
This commit is contained in:
commit
0829fd982e
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,29 @@
|
|||
NOTE: THIS CURRENTLY DOESN'T WORK, it is suspected that luac's little endian output isn't liked by the consoles. Need luac to output big endian binaries.
|
||||
|
||||
This is a script that ports Olanov's Felony Rework (https://www.moddb.com/games/driver-san-francisco/downloads/felony-rework) to consoles. It is compatible with Windows and Linux (install Wine).
|
||||
|
||||
Getting ready:
|
||||
* Install Python 3.x (3.4 and up are supported)
|
||||
* Put LuaSF (https://cdn.discordapp.com/attachments/689179524101046424/695257138766807040/LuaSF.zip) into bin/windows/ (LuaSF.exe should be in bin/windows/LuaSF/)
|
||||
* For x360, put xbcompression into bin/windows/ (xbcompress.exe/xbdecompress.exe should be in bin/windows/xbcompression/)
|
||||
* Unpack Felony Rework 2.3 into felony_rework (Common/media should be in felony_rework/)
|
||||
* Put the following PC files into game/ folder:
|
||||
>> ScriptsActionActivities.fchunk
|
||||
>> ScriptsChallenges.fchunk
|
||||
>> ScriptsChapter1.fchunk
|
||||
>> ScriptsChapter2.fchunk
|
||||
>> ScriptsChapter3.fchunk
|
||||
>> ScriptsChapter4.fchunk
|
||||
>> ScriptsChapter5.fchunk
|
||||
>> ScriptsChapter6.fchunk
|
||||
>> ScriptsChapter7.fchunk
|
||||
>> ScriptsLuaScripts.fchunk
|
||||
* Extract the console's ISO of Driver:SF somewhere
|
||||
|
||||
Preparing the patch files:
|
||||
* Run: run.py makepatch
|
||||
|
||||
Creating the mod for the console:
|
||||
* Run: run.py apply <x360/ps3> <path to extracted ISO>
|
||||
|
||||
You can find the output in out/ -- You replace your game's files with the files in this directory.
|
|
@ -0,0 +1,2 @@
|
|||
local bs = user_open("bootstrap.lua")
|
||||
bs.Launch()
|
|
@ -0,0 +1,43 @@
|
|||
--- loadfiles.lua 2023-11-13 00:55:37.873746068 +0100
|
||||
+++ loadfiles_modded.lua 2023-11-13 00:54:23.913742488 +0100
|
||||
@@ -303,6 +303,30 @@
|
||||
Menu.ShowMain = 0
|
||||
end
|
||||
end
|
||||
+UserLuaMediaPath = MediaPath .. "\\UserLuaScripts"
|
||||
+function user_open(filename)
|
||||
+
|
||||
+ print("[NOTE] loading user file '" .. filename .. "'")
|
||||
+
|
||||
+ local error, f = ScriptLoader.ri_dofilefromdisk(UserLuaMediaPath .. filename)
|
||||
+
|
||||
+ if type(f) == "string" then
|
||||
+ print("\t" .. f)
|
||||
+ return true, nil
|
||||
+ elseif type(f) == "function" then
|
||||
+ f()
|
||||
+ return true, nil
|
||||
+ elseif type(f) == "table" then
|
||||
+ return true, f
|
||||
+ elseif f == nil then
|
||||
+ print("\t" .. error)
|
||||
+ return false, nil
|
||||
+ else
|
||||
+ print("Unknown return type???")
|
||||
+ end
|
||||
+
|
||||
+ return false
|
||||
+end
|
||||
function _flagGameReadyForLaunch_callback(_autoTestSuite)
|
||||
return function()
|
||||
if debugOpen then
|
||||
@@ -312,6 +336,9 @@
|
||||
AutoTest.setTestSuite(_autoTestSuite)
|
||||
end
|
||||
end
|
||||
+
|
||||
+ user_open("modloader.lua")
|
||||
+
|
||||
waitForStartScreen()
|
||||
GameLauncher.SetGameState("Game Started")
|
||||
Network.setEmulationConfigID(6)
|
|
@ -0,0 +1,191 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys
|
||||
import os
|
||||
p = os.path.join
|
||||
pUp = os.path.dirname
|
||||
s = False
|
||||
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
|
||||
s = os.path.realpath(sys.executable)
|
||||
else:
|
||||
s = os.path.realpath(__file__)
|
||||
sp = pUp(s)
|
||||
|
||||
## Script start
|
||||
import shutil
|
||||
import platform
|
||||
ops = platform.system().lower()
|
||||
|
||||
import subprocess
|
||||
def procConfirm(proc,cmd = None,success = None):
|
||||
if cmd == None: cmd = lastCmd
|
||||
if success == None: success = [0]
|
||||
rtn = proc.wait()
|
||||
if not rtn in success: raise subprocess.CalledProcessError(rtn,cmd,None)
|
||||
|
||||
lastCmd = []
|
||||
def popen(cmd,*args,**kwargs):
|
||||
global lastCmd
|
||||
lastCmd = cmd
|
||||
return subprocess.Popen(cmd,*args,**kwargs)
|
||||
|
||||
def call(cmd,*args,**kwargs):
|
||||
proc = popen(cmd,*args,**kwargs)
|
||||
procConfirm(proc)
|
||||
|
||||
def callTool(cmd,*args,**kwargs):
|
||||
if ops != "windows":
|
||||
if os.path.isfile(p(sp,"bin",ops,cmd[0])):
|
||||
cmd[0] = p(sp,"bin",ops,cmd[0])
|
||||
else:
|
||||
cmd[0] = p(sp,"bin","windows",cmd[0] + ".exe")
|
||||
cmd.insert(0,"wine")
|
||||
else:
|
||||
cmd[0] = p(sp,"bin","windows",cmd[0] + ".exe")
|
||||
|
||||
call(cmd,*args,**kwargs)
|
||||
|
||||
def wp(*args):
|
||||
pth = p(*args)
|
||||
if ops == "windows": return pth
|
||||
pth = pth.replace(os.path.sep,"\\")
|
||||
if pth[0] == "\\":
|
||||
pth = "Z:" +pth
|
||||
return pth
|
||||
return pth
|
||||
|
||||
def fchunkUnpack(fch,fchOut,pf = "pc"):
|
||||
fchName = fch.rsplit(os.path.sep,1)[-1]
|
||||
|
||||
if os.path.isdir(fchOut): shutil.rmtree(fchOut)
|
||||
if pf == "x360":
|
||||
fchDecomp = p(pUp(fchOut),fchName + ".decomp")
|
||||
callTool([p("xbcompression","xbdecompress"),"/F",wp(fch),wp(fchDecomp)])
|
||||
callTool([p("LuaSF","LuaSF"),"--big",wp(fchDecomp),wp(fchOut)])
|
||||
os.remove(fchDecomp)
|
||||
return
|
||||
|
||||
if pf == "ps3":
|
||||
callTool([p("LuaSF","LuaSF"),"--big",wp(fch),wp(fchOut)])
|
||||
return
|
||||
|
||||
callTool([p("LuaSF","LuaSF"),wp(fch),wp(fchOut)])
|
||||
|
||||
def fchunkPack(fch,fchOut,pf = "pc"):
|
||||
fchName = fch.rsplit(os.path.sep,1)[-1] + ".fchunk"
|
||||
fchOutDir = pUp(fchOut)
|
||||
fchOutLsfName = p(fchOutDir,fchName.rsplit(".fchunk",1)[0])
|
||||
|
||||
if not os.path.isdir(fchOutDir): os.makedirs(fchOutDir)
|
||||
if pf == "x360":
|
||||
callTool([p("LuaSF","LuaSF"),"--big","--compile",wp(fch),wp(fchOutDir)],cwd=p(sp,"bin","windows","LuaSF")) # ugly hack
|
||||
os.replace(fchOutLsfName,fchOut + ".decomp")
|
||||
callTool([p("xbcompression","xbcompress"),"/F",wp(fchOut + ".decomp"),wp(fchOut)])
|
||||
os.remove(fchOut + ".decomp")
|
||||
return
|
||||
|
||||
if pf == "ps3":
|
||||
callTool([p("LuaSF","LuaSF"),"--big","--compile",wp(fch),wp(fchOutDir)])
|
||||
|
||||
if pf == "pc":
|
||||
callTool([p("LuaSF","LuaSF"),"--compile",wp(fch),wp(fchOutDir)])
|
||||
|
||||
if fchOutLsfName == fchOut: return
|
||||
os.replace(fchOutLsfName,fchOut)
|
||||
return
|
||||
|
||||
def createPatchFromDir(dir1,dir2,output):
|
||||
proc = popen(["diff","-crB",dir1,dir2],stdout=subprocess.PIPE)
|
||||
with open(output,"w",encoding="utf-8") as fh:
|
||||
text = proc.stdout.read().decode("utf-8")
|
||||
text = text.replace(dir1,"a")
|
||||
text = text.replace(dir2,"b")
|
||||
fh.write(text)
|
||||
procConfirm(proc,success=[0,1])
|
||||
|
||||
def copytree(dir1,dir2):
|
||||
for root,dirs,files in os.walk(dir1):
|
||||
for file in dirs:
|
||||
ffile = p(root,file)
|
||||
lfile = ffile.replace(dir1 + os.path.sep,"",1)
|
||||
nfile = p(dir2,lfile)
|
||||
os.makedirs(nfile,exist_ok=True)
|
||||
|
||||
for file in files:
|
||||
ffile = p(root,file)
|
||||
lfile = ffile.replace(dir1 + os.path.sep,"",1)
|
||||
nfile = p(dir2,lfile)
|
||||
if os.path.isfile(nfile): os.remove(nfile)
|
||||
shutil.copyfile(ffile,nfile)
|
||||
|
||||
def main():
|
||||
if os.path.isdir(p(sp,"tmp")): shutil.rmtree(p(sp,"tmp"))
|
||||
os.makedirs(p(sp,"tmp"))
|
||||
|
||||
fchunksMod = [
|
||||
"ScriptsActionActivities.fchunk",
|
||||
"ScriptsChallenges.fchunk",
|
||||
"ScriptsChapter1.fchunk",
|
||||
"ScriptsChapter2.fchunk",
|
||||
"ScriptsChapter3.fchunk",
|
||||
"ScriptsChapter4.fchunk",
|
||||
"ScriptsChapter5.fchunk",
|
||||
"ScriptsChapter6.fchunk",
|
||||
"ScriptsChapter7.fchunk"
|
||||
]
|
||||
|
||||
fchunksExtra = [
|
||||
"ScriptsFelonyReworkAudio.fchunk",
|
||||
"ScriptsStimulusPackage.fchunk"
|
||||
]
|
||||
|
||||
if sys.argv[1] == "makepatch":
|
||||
if os.path.isdir(p(sp,"patches")): shutil.rmtree(p(sp,"patches"))
|
||||
os.makedirs(p(sp,"patches"))
|
||||
|
||||
for fchunk in fchunksMod:
|
||||
print(">> " +fchunk+ " ...")
|
||||
fchunkUnpack(p(sp,"game",fchunk),p(sp,"tmp","game",fchunk))
|
||||
fchunkUnpack(p(sp,"felony_rework","media",fchunk),p(sp,"tmp","felony_rework",fchunk))
|
||||
createPatchFromDir(
|
||||
p(sp,"tmp","game",fchunk),
|
||||
p(sp,"tmp","felony_rework",fchunk),
|
||||
p(sp,"patches",fchunk + ".patch")
|
||||
)
|
||||
|
||||
print(">> ScriptsLuaScripts.fchunk ...")
|
||||
fchunkUnpack(p(sp,"game","ScriptsLuaScripts.fchunk"),p(sp,"tmp","game","ScriptsLuaScripts.fchunk"))
|
||||
createPatchFromDir(
|
||||
p(sp,"tmp","game","ScriptsLuaScripts.fchunk"),
|
||||
p(sp,"felony_rework","Common","LuaScripts"),
|
||||
p(sp,"patches","ScriptsLuaScripts.fchunk.patch")
|
||||
)
|
||||
|
||||
if sys.argv[1] == "apply":
|
||||
pf = sys.argv[2]
|
||||
game = sys.argv[3]
|
||||
os.makedirs(p(sp,"tmp","game"))
|
||||
if os.path.isdir(p(sp,"out")): shutil.rmtree(p(sp,"out"))
|
||||
|
||||
fchunksMod.append("ScriptsLuaScripts.fchunk")
|
||||
|
||||
for fchunk in fchunksMod:
|
||||
print(">> " +fchunk+ " ...")
|
||||
fchunkUnpack(p(game,"media",fchunk),p(sp,"tmp","game",fchunk),pf)
|
||||
proc = popen(["patch","-p1"],stdin=subprocess.PIPE,cwd=p(sp,"tmp","game",fchunk))
|
||||
with open(p(sp,"patches",fchunk + ".patch"),"rb") as fh:
|
||||
proc.stdin.write(fh.read())
|
||||
proc.stdin.close()
|
||||
procConfirm(proc)
|
||||
if fchunk == "ScriptsLuaScripts.fchunk":
|
||||
call(["patch",p(sp,"tmp","game",fchunk,"loadfiles.lua"),p(sp,"patches-extra","modloader.patch")])
|
||||
fchunkPack(p(sp,"tmp","game",fchunk),p(sp,"out","media",fchunk),pf)
|
||||
|
||||
for fchunk in fchunksExtra:
|
||||
print(">> " +fchunk+ " ...")
|
||||
fchunkUnpack(p(sp,"felony_rework","media",fchunk),p(sp,"tmp","game",fchunk),"pc")
|
||||
fchunkPack(p(sp,"tmp","game",fchunk),p(sp,"out","media",fchunk),pf)
|
||||
|
||||
copytree(p(sp,"files","xbox_modloader"),p(sp,"out"))
|
||||
copytree(p(sp,"felony_rework","Common","UserLuaScripts"),p(sp,"out","media","UserLuaScripts"))
|
||||
copytree(p(sp,"felony_rework","Common","fmv"),p(sp,"out","media","fmv"))
|
||||
main()
|
Loading…
Reference in New Issue