NoBots Map Patcher

Started by Phobos, May 13, 2015, 11:58:00 PM

Previous topic - Next topic
Attached is a useful tool for modding zombies (and other mods) where ammunition should be strictly limited. This will instantly remove all health, ammo, and R2 droids from any mod map where the source is not available. I'll update this tool later for removing turrets and other stuff. Credit goes to Tirpider for writing 99% of the code.

No Bots Patcher Source
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=nobots.ico
MsgBox(0, "No Bots Patcher by Phobos", "Removes ammo/health droids from any mod map! Name the LVL to nobots.lvl and run the patch. Be sure to make a backup copy first of the map.")
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Change2CUI=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
nobots r1
- added _MakeNullString() - returns a string of null characters of equal length for a given string.
- removed file renaming. overwrites source file now.
#ce ----------------------------------------------------------------------------
Opt("MustDeclareVars", 1)

_main()

Func _main()
Local $sFilename = @ScriptDir & "\nobots.lvl"
Local $sPattern = "com_item_healthrecharge"
Local $sReplace = _MakeNullString($sPattern)

ConsoleWrite("Loading " & $sFilename)
Local $bFile = _LoadFile($sFilename) ;                               load the file
ConsoleWrite(@CRLF)

Local $sFile = BinaryToString($bFile) ;                              convert it to a string for StringRegExpReplace

ConsoleWrite("replacing :" & $sPattern)
Local $sOutput = StringRegExpReplace($sFile, $sPattern, $sReplace) ; replace all occurances
ConsoleWrite(@CRLF)

$bFile = StringToBinary($sOutput) ;                                  convert it back for _SaveFile

ConsoleWrite("Saving " & $sFilename)
_SaveFile($sFilename, $bFile);                                       save the file
ConsoleWrite(@CRLF)



Local $tFilename = @ScriptDir & "\nobots.lvl"
Local $tPattern = "com_item_vehiclerecharge"
Local $tReplace = _MakeNullString($tPattern)

ConsoleWrite("Loading " & $tFilename)
Local $bFile = _LoadFile($tFilename) ;                               load the file
ConsoleWrite(@CRLF)

Local $tFile = BinaryToString($bFile) ;                              convert it to a string for StringRegExpReplace

ConsoleWrite("replacing :" & $tPattern)
Local $tOutput = StringRegExpReplace($tFile, $tPattern, $tReplace) ; replace all occurances
ConsoleWrite(@CRLF)

$bFile = StringToBinary($tOutput) ;                                  convert it back for _SaveFile

ConsoleWrite("Saving " & $tFilename)
_SaveFile($tFilename, $bFile);                                       save the file
ConsoleWrite(@CRLF)



Local $uFilename = @ScriptDir & "\nobots.lvl"
Local $uPattern = "com_item_weaponrecharge"
Local $uReplace = _MakeNullString($uPattern)

ConsoleWrite("Loading " & $uFilename)
Local $bFile = _LoadFile($uFilename) ;                               load the file
ConsoleWrite(@CRLF)

Local $uFile = BinaryToString($bFile) ;                              convert it to a string for StringRegExpReplace

ConsoleWrite("replacing :" & $uPattern)
Local $uOutput = StringRegExpReplace($uFile, $uPattern, $uReplace) ; replace all occurances
ConsoleWrite(@CRLF)

$bFile = StringToBinary($uOutput) ;                                  convert it back for _SaveFile

ConsoleWrite("Saving " & $uFilename)
_SaveFile($uFilename, $bFile);                                       save the file
ConsoleWrite(@CRLF)

Exit ; end the program
EndFunc   ;==>_main

Func _LoadFile($sFilename)
Local $hFile = FileOpen($sFilename, 16)
FileSetPos($hFile, 0, 0)
Local $bFile = FileRead($hFile)
FileFlush($hFile)
FileClose($hFile)
Return $bFile
EndFunc   ;==>_LoadFile

Func _SaveFile($sFilename, ByRef $bFile)
Local $hFile = FileOpen($sFilename, 26)
FileSetPos($hFile, 0, 0)
FileWrite($hFile, $bFile)
FileFlush($hFile)
FileClose($hFile)
EndFunc   ;==>_SaveFile

Func _MakeNullString($string)
Local $sNullString = ""
Local $length = StringLen($string)
For $i = 1 to $length
$sNullString &= Chr(0)
Next
Return $sNullString
EndFunc