@@ -42,6 +42,7 @@ TFormMain = class(TForm)
42
42
procedure ScanScripts (); // scan scripts folder in the game & update UI
43
43
procedure LaunchGame ( mod_name:string; params: string );
44
44
45
+ procedure MakeAIGood ( mod_name: string );
45
46
procedure ActivateMod ( mod_name: string );
46
47
procedure DeactivateMod ( mod_name: string );
47
48
@@ -124,7 +125,7 @@ function TFormMain.HasModAI(mod_name: string): integer;
124
125
result := ScanZbigsForAI( mod_path );
125
126
126
127
// write it so that I don't have to do zbig scan again.
127
- // mconf.SetValue( 'has_ai', result );
128
+ mconf.SetValue( ' has_ai' , result );
128
129
end ;
129
130
// else, the result read from the config is correct.
130
131
@@ -143,16 +144,22 @@ function TFormMain.ScanZbigsForAI(mod_path: string): integer;
143
144
144
145
Repeat
145
146
// Scan the contents
146
- ShowMessage( info.name );
147
-
148
- big.Create;
149
- big.LoadFile( info.name );
150
- cnt := big.GetNumFiles;
151
- for i := 0 to cnt-1 do
152
- begin
153
- f := big.GetFileInfo( i );
154
- // f.Filename should be used :)
155
- end ;
147
+ big := TBIGPackage.Create;
148
+ big.LoadFile( mod_path + info.name );
149
+ if big.IsValid then
150
+ begin
151
+ // scan through file list, find AI related files.
152
+ cnt := big.GetNumFiles;
153
+ for i := 0 to cnt-1 do
154
+ begin
155
+ f := big.GetFileInfo( i );
156
+ if pos( ' skirmishscripts' , lowercase( f.filename ) ) <> 0 then
157
+ begin
158
+ result := 1 ; // found it!!
159
+ break;
160
+ end ;
161
+ end ;
162
+ end ;
156
163
big.Free;
157
164
Until FindNext(info) <> 0 ;
158
165
@@ -195,6 +202,8 @@ procedure TFormMain.LaunchGame( mod_name: string; params: string );
195
202
// Set the mod as active
196
203
ActivateMod( mod_name );
197
204
205
+ MakeAIGood( mod_name );
206
+
198
207
// Run the mod
199
208
// ShellExecute( 0, 'open', PChar(game_exe), PChar(params), nil, SW_NORMAL );
200
209
output := ' ' ;
@@ -204,6 +213,20 @@ procedure TFormMain.LaunchGame( mod_name: string; params: string );
204
213
DeactivateMod( mod_name );
205
214
end ;
206
215
216
+ procedure TFormMain.MakeAIGood ( mod_name: string );
217
+ var
218
+ has_ai: integer;
219
+ begin
220
+ // Make AI good by activating the scripts folder in ZH dir.
221
+ has_ai := integer( ModList.Items.Objects[ ModList.ItemIndex ] );
222
+
223
+ // if has AI and mod ai needs activation...
224
+ if (has_ai <> 0 ) and (BtnMod.Enabled) then
225
+ BtnMod.Click
226
+ else if (has_ai = 0 ) and (BtnRestore.Enabled) then
227
+ BtnRestore.Click;
228
+ end ;
229
+
207
230
procedure TFormMain.ActivateMod ( mod_name: string );
208
231
var
209
232
i : Integer;
0 commit comments