-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
import_legacy.au3
147 lines (107 loc) · 4.66 KB
/
import_legacy.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#NoTrayIcon
;- This script is used to extract the original balance and import it into remastered scripts.
;- I don't see why anyone would get some use out of this but here you go.
#Include <File.au3>
#Include <Array.au3>
HotKeySet("{F5}","_END")
Func _END()
Exit
EndFunc
Global $LegacyPath = "C:/Users/RX1500x-METEOR/Desktop/original" ;- Path to original lua weapon folder
Global $RemasteredPath = "C:/Users/RX1500x-METEOR/Desktop/remastered" ;- Path to remastered lua weapon folder
Global $OutputDir = "C:/Users/RX1500x-METEOR/Desktop/output" ;- Where to put the result
Global $LegacyRead = _FileListToArrayRec($LegacyPath,"*.lua",$FLTAR_FILES,$FLTAR_RECUR,$FLTAR_SORT,$FLTAR_FULLPATH)
_ArrayDelete($LegacyRead,0)
Global $RemasteredRead = _FileListToArrayRec($RemasteredPath,"*.lua",$FLTAR_FILES,$FLTAR_RECUR,$FLTAR_SORT,$FLTAR_FULLPATH)
_ArrayDelete($RemasteredRead,0)
Local $ArrayTagInfoText[9] = ["SWEP.Primary.RPM","SWEP.Primary.ClipSize","SWEP.Primary.KickUp","SWEP.Primary.KickDown","SWEP.Primary.KickHorizontal","SWEP.Primary.Automatic","SWEP.Primary.NumShots","SWEP.Primary.Damage","SWEP.Primary.Spread"]
Local $Blacklist[22] = [ _
"-- This is in Rounds Per Minute", _
"-- Size of a clip", _
"-- Maximum up recoil (rise)", _
"-- Maximum down recoil (skeet)", _
"-- Maximum up recoil (stock)", _
"-- Automatic/Semi Auto", _
"-- How many bullets to shoot per trigger pull, AKA pellets", _
"-- Base damage per bullet", _
"-- Define from-the-hip accuracy 1 is terrible, .0001 is exact)", _
"-- Automatic = true; Semi Auto = false", _
"-- How many bullets to shoot per trigger pull", _
"--how many bullets to shoot per trigger pull", _
"--define from-the-hip accuracy 1 is terrible, .0001 is exact)", _
"--base damage per bullet", _
"-- Define from-the-hip accuracy (1 is terrible, .0001 is exact)", _
"//how many bullets to shoot, use with shotguns", _
"//base damage, scaled by game", _
"//define from-the-hip accuracy 1 is terrible, .0001 is exact)", _
"--how many bullets to shoot, use with shotguns", _
"--base damage, scaled by game", _
"//define from-the-hip accuracy (1 is terrible, .0001 is exact)", _
"-- pistol, 357, smg1, ar2, buckshot, slam, SniperPenetratedRound, AirboatGun" _
]
For $AZ = 0 To uBound($LegacyRead) - 1 Step 1
Local $ArrayTagInfo[9] = ["RPM = ","ClipSize = ","KickUp = ","KickDown = ","KickHorizontal = ","Automatic = ","NumShots = ","Damage = ","Spread = "]
Local $ReadLeg = FileReadToArray($LegacyRead[$AZ])
Local $Lines = @extended
For $I = 0 To $Lines - 1 Step 1
For $B = 0 To 8 Step 1
If StringLeft($ReadLeg[$I],StringLen($ArrayTagInfoText[$B])) == $ArrayTagInfoText[$B] Then
Local $FindEqual = 0
For $A = 0 To StringLen($ReadLeg[$I]) Step 1
If StringMid($ReadLeg[$I],$A,1) == "=" Then
$FindEqual = $A
ExitLoop
EndIf
Next
$ArrayTagInfo[$B] = $ArrayTagInfo[$B] & StringMid($ReadLeg[$I],$FindEqual+1)
$ArrayTagInfo[$B] = StringReplace($ArrayTagInfo[$B]," "," ") ;- Byebye double spaces
$ArrayTagInfo[$B] = StringReplace($ArrayTagInfo[$B]," "," ")
$ArrayTagInfo[$B] = StringReplace($ArrayTagInfo[$B]," "," ")
$ArrayTagInfo[$B] = StringReplace($ArrayTagInfo[$B],@Tab,"") ;- Remove tabs
For $Z = 0 To uBound($Blacklist) - 1 Step 1 ;- Filter text
$ArrayTagInfo[$B] = StringReplace($ArrayTagInfo[$B],$Blacklist[$Z],"")
Next
If $B <> 8 Then
$ArrayTagInfo[$B] = $ArrayTagInfo[$B] & ","
EndIf
EndIf
Next
Next
Local $Str = "SWEP.LegacyBalance = {" & @CRLF & @TAB & "Primary = {" & @CRLF
For $I = 0 To uBound($ArrayTagInfo) - 1 Step 1
$Str = $Str & @Tab & @Tab & $ArrayTagInfo[$I] & @CRLF
Next
$Str = $Str & @TAB & "}" & @CRLF & "}"
;- Retrieve file name
Local $FName = ""
For $I = StringLen($LegacyRead[$AZ]) To 1 Step -1
If StringMid($LegacyRead[$AZ],$I,1) == "\" Then
$FName = StringMid($LegacyRead[$AZ],$I+1)
$FName = StringReplace($FName,"\shared.lua","")
EndIf
Next
$FName = $FName & ".lua"
;- Does it exist in remastered? If so, add the balance table!
Local $iLen = StringLen($FName)
For $I = 0 To uBound($RemasteredRead) - 1 Step 1
If StringRight($RemasteredRead[$I],$iLen) == $FName Then
;- Find the last line that starts with SWEP.
Local $FileRead = FileReadToArray($RemasteredRead[$I])
Local $Lines = @extended
Local $iLast = 1
For $A = 1 To $Lines - 1 Step 1
If StringLeft($FileRead[$A],5) == "SWEP." Then
$iLast = $A
EndIf
Next
If $iLast+1 == $Lines or $iLast == $Lines Then
_ArrayAdd($FileRead,@CRLF & $Str)
Else
_ArrayInsert($FileRead,$iLast + 1,@CRLF & $Str)
EndIf
$FileRead = _ArrayToString($FileRead,@CRLF)
FileWrite($OutputDir & "\" & $FName,$FileRead)
ExitLoop
EndIf
Next
Next