@@ -28,11 +28,20 @@ variable begin
2828 active_encounter_pids := 0 ;
2929 total_encounter_mobs := 0 ; //Per area in map
3030
31-
3231 special_theif_encounter := 0 ;
3332
3433 choose_enc_pid := 0 ;
3534 choose_enc_sid := 0 ;
35+
36+ encounter_mobs_min := 0 ;
37+ encounter_mobs_max := 0 ;
38+
39+ caverns_reduce_mobs ;
40+ end
41+
42+ procedure SetMobCount (variable min , variable max ) begin
43+ encounter_mobs_min := min ;
44+ encounter_mobs_max := max ;
3645end
3746
3847procedure Choose_Encounter begin
@@ -45,77 +54,77 @@ procedure Choose_Encounter begin
4554 if (dude_level < 6 ) then begin
4655 encounter_pid1 := PID_GECKO_SMALL ;
4756 encounter_sid1 := SCRIPT_ECGECKO ;
48- total_encounter_mobs : = Random (3 , 5 );
57+ call SetMobCount (3 , 5 );
4958 end else if (dude_level < 12 ) then begin
5059 encounter_pid1 := PID_TOUGH_GECKO_SMALL ;
5160 encounter_sid1 := SCRIPT_ECGECKO ;
52- total_encounter_mobs : = Random (3 , 5 );
61+ call SetMobCount (3 , 5 );
5362 end else if (dude_level < 13 ) then begin
5463 encounter_pid1 := PID_FIRE_GECKO ;
5564 encounter_sid1 := SCRIPT_ECGECKO ;
56- total_encounter_mobs : = Random (3 , 5 );
65+ call SetMobCount (3 , 5 );
5766 end else begin
5867 encounter_pid1 := PID_TOUGH_FIRE_GECKO ;
5968 encounter_sid1 := SCRIPT_ECGECKO ;
60- total_encounter_mobs : = Random (3 , 5 );
69+ call SetMobCount (3 , 5 );
6170 end
6271 end else if (val == 2 ) then begin
6372 active_encounter_pids := 1 ;
6473 if (dude_level < 5 ) then begin
6574 encounter_pid1 := PID_GOLDEN_GECKO ;
6675 encounter_sid1 := SCRIPT_ECGECKO ;
67- total_encounter_mobs : = Random (3 , 5 );
76+ call SetMobCount (3 , 5 );
6877 end else if (dude_level < 12 ) then begin
6978 encounter_pid1 := PID_TOUGH_GOLDEN_GECKO ;
7079 encounter_sid1 := SCRIPT_ECGECKO ;
71- total_encounter_mobs : = Random (3 , 5 );
80+ call SetMobCount (3 , 5 );
7281 end else if (dude_level < 13 ) then begin
7382 encounter_pid1 := PID_FIRE_GECKO ;
7483 encounter_sid1 := SCRIPT_ECGECKO ;
75- total_encounter_mobs : = Random (3 , 5 );
84+ call SetMobCount (3 , 5 );
7685 end else begin
7786 encounter_pid1 := PID_TOUGH_FIRE_GECKO ;
7887 encounter_sid1 := SCRIPT_ECGECKO ;
79- total_encounter_mobs : = Random (3 , 5 );
88+ call SetMobCount (3 , 5 );
8089 end
8190 end else if (val == 3 ) then begin
8291 active_encounter_pids := 1 ;
8392 encounter_pid1 := PID_SMALL_RADSCORPION ;
8493 encounter_sid1 := SCRIPT_ECSCORP ;
85- total_encounter_mobs : = Random (3 , 5 );
94+ call SetMobCount (3 , 5 );
8695 end else if (val == 4 ) then begin
8796 active_encounter_pids := 1 ;
8897 encounter_pid1 := PID_LARGE_RADSCORPION ;
8998 encounter_sid1 := SCRIPT_ECSCORP ;
90- total_encounter_mobs : = Random (3 , 5 );
99+ call SetMobCount (3 , 5 );
91100 end else if (val == 5 ) then begin
92101 active_encounter_pids := 1 ;
93102 encounter_pid1 := PID_SMALL_DEATHCLAW ;
94103 encounter_sid1 := SCRIPT_ZCLDTHCL ;
95- total_encounter_mobs : = Random (3 , 5 );
104+ call SetMobCount (3 , 5 );
96105 end else if (val == 6 ) then begin
97106 active_encounter_pids := 1 ;
98107 encounter_pid1 := PID_LARGE_DEATHCLAW ;
99108 encounter_sid1 := SCRIPT_ZCLDTHCL ;
100- total_encounter_mobs : = 5 ;
109+ call SetMobCount ( 5 , 5 ) ;
101110 end else if (val == 7 ) then begin
102111 active_encounter_pids := 1 ;
103112 encounter_pid1 := PID_MUTATED_MOLE_RAT ;
104113 encounter_sid1 := SCRIPT_ECRAT ;
105- total_encounter_mobs : = Random (3 , 5 );
114+ call SetMobCount (3 , 5 );
106115 end else if (val == 8 ) then begin
107116 active_encounter_pids := 1 ;
108117 encounter_pid1 := PID_MUTATED_PIG_RAT ;
109118 encounter_sid1 := SCRIPT_ECRAT ;
110- total_encounter_mobs : = Random (4 , 5 );
119+ call SetMobCount (4 , 5 );
111120 end else if (val == 9 ) then begin
112121 active_encounter_pids := 2 ;
113122 if (dude_level < 5 ) then begin
114123 encounter_pid1 := PID_GECKO_SMALL ;
115124 encounter_pid2 := PID_GOLDEN_GECKO ;
116125 encounter_sid1 := SCRIPT_ECGECKO ;
117126 encounter_sid2 := SCRIPT_ECGECKO ;
118- total_encounter_mobs : = Random (3 , 5 );
127+ call SetMobCount (3 , 5 );
119128 end else begin
120129 encounter_pid1 := PID_TOUGH_GECKO_SMALL ;
121130 encounter_pid2 := PID_TOUGH_GOLDEN_GECKO ;
@@ -130,29 +139,29 @@ procedure Choose_Encounter begin
130139 encounter_pid3 := PID_TOUGH_FIRE_GECKO ;
131140 encounter_sid3 := SCRIPT_ECGECKO ;
132141 end
133- total_encounter_mobs : = 5 ;
142+ call SetMobCount ( 5 , 5 ) ;
134143 end
135144 end else if (val == 10 ) then begin
136145 active_encounter_pids := 2 ;
137146 encounter_pid1 := PID_SMALL_RADSCORPION ;
138147 encounter_pid2 := PID_LARGE_RADSCORPION ;
139148 encounter_sid1 := SCRIPT_ECSCORP ;
140149 encounter_sid2 := SCRIPT_ECSCORP ;
141- total_encounter_mobs : = Random (3 , 5 );
150+ call SetMobCount (3 , 5 );
142151 end else if (val == 11 ) then begin
143152 active_encounter_pids := 2 ;
144153 encounter_pid1 := PID_SMALL_DEATHCLAW ;
145154 encounter_pid2 := PID_LARGE_DEATHCLAW ;
146155 encounter_sid1 := SCRIPT_ZCLDTHCL ;
147156 encounter_sid2 := SCRIPT_ZCLDTHCL ;
148- total_encounter_mobs : = 5 ;
157+ call SetMobCount ( 5 , 5 ) ;
149158 end else if (val == 12 ) then begin
150159 active_encounter_pids := 2 ;
151160 encounter_pid1 := PID_MUTATED_MOLE_RAT ;
152161 encounter_pid1 := PID_MUTATED_PIG_RAT ;
153162 encounter_sid1 := SCRIPT_ECRAT ;
154163 encounter_sid2 := SCRIPT_ECRAT ;
155- total_encounter_mobs : = 5 ;
164+ call SetMobCount ( 5 , 5 ) ;
156165 end else if (val == 13 ) then begin
157166 if (stat_success (dude_obj , STAT_lu , 0 )) then begin
158167 special_theif_encounter := 1 ;
@@ -162,19 +171,19 @@ procedure Choose_Encounter begin
162171 encounter_pid2 := PID_MYSTERIOUS_STRANGER_FEMALE ;
163172 encounter_sid1 := SCRIPT_ECROBBER ;
164173 encounter_sid2 := SCRIPT_ECROBBER ;
165- total_encounter_mobs : = Random (2 , 3 );
174+ call SetMobCount (2 , 3 );
166175 end else if (dude_level < 11 ) then begin
167176 encounter_pid1 := PID_BOUNTY_MALE_7_12 ;
168177 encounter_pid2 := PID_BOUNTY_FEMALE_7_12 ;
169178 encounter_sid1 := SCRIPT_ECROBBER ;
170179 encounter_sid2 := SCRIPT_ECROBBER ;
171- total_encounter_mobs : = Random (3 , 4 );
180+ call SetMobCount (3 , 4 );
172181 end else begin
173182 encounter_pid1 := PID_BOUNTY_MALE_13_18 ;
174183 encounter_pid2 := PID_BOUNTY_FEMALE_13_18 ;
175184 encounter_sid1 := SCRIPT_ECROBBER ;
176185 encounter_sid2 := SCRIPT_ECROBBER ;
177- total_encounter_mobs : = Random (3 , 4 );
186+ call SetMobCount (3 , 4 );
178187 end
179188 end
180189 end
249258procedure PlaceCritterGroup (variable tile ) begin
250259 variable count ;
251260
252- count := total_encounter_mobs ;
261+ count := random (encounter_mobs_min , encounter_mobs_max )
262+ if caverns_reduce_mobs
263+ else total_encounter_mobs ;
253264 while (count > 0 ) do begin
254265 call Choose_Pid ;
255266 call placeCritter (choose_enc_pid , choose_enc_sid , tile );
@@ -260,13 +271,26 @@ end
260271procedure DistributeCritters (variable areaList , variable numActiveAreas ) begin
261272 variable i , idx , tile ;
262273
274+ caverns_reduce_mobs := upu_msetting (caverns_reduce_mobs );
275+ if (not caverns_reduce_mobs ) then begin
276+ numActiveAreas := len_array (areaList );
277+ total_encounter_mobs := random (encounter_mobs_min , encounter_mobs_max );
278+ end else
279+ total_encounter_mobs := -1 ;
280+
263281 ndebug ("total_encounter_mobs = " + total_encounter_mobs + ", areas = " + len_array (areaList ) + ", numActive = " + numActiveAreas );
264282
265- for (i := 0 ; i < numActiveAreas and len_array (areaList ) > 0 ; i ++ ) begin
266- idx := random (0 , len_array (areaList ) - 1 );
267- tile := areaList [idx ];
268- call array_cut (areaList , idx , 1 );
269- call PlaceCritterGroup (tile );
283+ if (numActiveAreas >= len_array (areaList )) then begin
284+ foreach (tile in areaList ) begin
285+ call PlaceCritterGroup (tile );
286+ end
287+ end else begin
288+ for (i := 0 ; i < numActiveAreas and len_array (areaList ) > 0 ; i ++ ) begin
289+ idx := random (0 , len_array (areaList ) - 1 );
290+ tile := areaList [idx ];
291+ call array_cut (areaList , idx , 1 );
292+ call PlaceCritterGroup (tile );
293+ end
270294 end
271295end
272296
0 commit comments