1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 
24 
25 #include "engines/engine.h"
26 
27 #include "scumm/insane/insane.h"
28 #include "scumm/scumm_v7.h"
29 
30 namespace Scumm {
31 
enemyInitializer(int num,int32 actor1,int32 actor2,int32 probability)32 int32 Insane::enemyInitializer(int num, int32 actor1, int32 actor2, int32 probability) {
33 	switch (num) {
34 	case EN_ROTT1:
35 		return enemy0initializer(actor1, actor2, probability);
36 	case EN_ROTT2:
37 		return enemy1initializer(actor1, actor2, probability);
38 	case EN_ROTT3:
39 		return enemy2initializer(actor1, actor2, probability);
40 	case EN_VULTF1:
41 		return enemy3initializer(actor1, actor2, probability);
42 	case EN_VULTM1:
43 		return enemy4initializer(actor1, actor2, probability);
44 	case EN_VULTF2:
45 		return enemy5initializer(actor1, actor2, probability);
46 	case EN_VULTM2:
47 		return enemy6initializer(actor1, actor2, probability);
48 	case EN_CAVEFISH:
49 		return enemy7initializer(actor1, actor2, probability);
50 	case EN_TORQUE:
51 		return enemy8initializer(actor1, actor2, probability);
52 	case -1:
53 		// nothing
54 		break;
55 	}
56 
57 	return 0;
58 }
59 
60 
enemyHandler(int num,int32 actor1,int32 actor2,int32 probability)61 int32 Insane::enemyHandler(int num, int32 actor1, int32 actor2, int32 probability) {
62 	switch (num) {
63 	case EN_ROTT1:
64 		return enemy0handler(actor1, actor2, probability);
65 	case EN_ROTT2:
66 		return enemy1handler(actor1, actor2, probability);
67 	case EN_ROTT3:
68 		return enemy2handler(actor1, actor2, probability);
69 	case EN_VULTF1:
70 		return enemy3handler(actor1, actor2, probability);
71 	case EN_VULTM1:
72 		return enemy4handler(actor1, actor2, probability);
73 	case EN_VULTF2:
74 		return enemy5handler(actor1, actor2, probability);
75 	case EN_VULTM2:
76 		return enemy6handler(actor1, actor2, probability);
77 	case EN_CAVEFISH:
78 		return enemy7handler(actor1, actor2, probability);
79 	case EN_TORQUE:
80 		return enemy8handler(actor1, actor2, probability);
81 	case EN_BEN:
82 		return enemyBenHandler(actor1, actor2, probability);
83 	case -1:
84 		// nothing
85 		break;
86 	}
87 	return 0;
88 }
89 
enemy0handler(int32 actor1,int32 actor2,int32 probability)90 int32 Insane::enemy0handler(int32 actor1, int32 actor2, int32 probability) {
91 	int32 dist;
92 
93 	int32 retval = 0;
94 	int32 act1damage = _actor[actor1].damage; // ebx
95 	int32 act2damage = _actor[actor2].damage; // ebp
96 	int32 act1x = _actor[actor1].x; // esi
97 	int32 act2x = _actor[actor2].x; // edi
98 
99 	if (!_actor[actor1].defunct) {
100 		if (_enHdlVar[EN_ROTT1][1] > _enHdlVar[EN_ROTT1][2]) {
101 			if (act1damage - act2damage >= 30) {
102 				if (_vm->_rnd.getRandomNumber(probability - 1) != 1)
103 					_enHdlVar[EN_ROTT1][0] = 0;
104 				else
105 					_enHdlVar[EN_ROTT1][0] = 1;
106 			}
107 			_enHdlVar[EN_ROTT1][1] = 0;
108 			_enHdlVar[EN_ROTT1][2] = _vm->_rnd.getRandomNumber(probability * 2 - 1);
109 		}
110 
111 		dist = ABS(act1x - act2x);
112 
113 		if (_enHdlVar[EN_ROTT1][3] > _enHdlVar[EN_ROTT1][4]) {
114 			if (_enHdlVar[EN_ROTT1][0] == 1) {
115 				if (weaponMaxRange(actor1) < dist) {
116 					if (act2x < act1x)
117 						_actor[actor1].cursorX = -101;
118 					else
119 						_actor[actor1].cursorX = 101;
120 				} else {
121 					if (weaponMinRange(actor1) > dist) {
122 						if (act2x < act1x)
123 							_actor[actor1].cursorX = 101;
124 						else
125 							_actor[actor1].cursorX = -101;
126 					} else {
127 						_actor[actor1].cursorX = 0;
128 					}
129 				}
130 			} else {
131 				if (weaponMaxRange(actor2) >= dist) {
132 					if (act2x < act1x)
133 						_actor[actor1].cursorX = 101;
134 					else
135 						_actor[actor1].cursorX = -101;
136 				} else {
137 					_actor[actor1].cursorX = 0;
138 				}
139 			}
140 			_enHdlVar[EN_ROTT1][3] = 0;
141 			_enHdlVar[EN_ROTT1][4] = _vm->_rnd.getRandomNumber(probability - 1);
142 		}
143 
144 		if (_enHdlVar[EN_ROTT1][5] > _enHdlVar[EN_ROTT1][6]) {
145 			if (weaponMaxRange(actor2) + 40 >= dist) {
146 				if (_vm->_rnd.getRandomNumber(probability - 1) == 1)
147 					retval = 1;
148 			}
149 			if (_actor[actor2].kicking) {
150 				if (weaponMaxRange(actor2) >= dist)
151 					if (_vm->_rnd.getRandomNumber(probability * 2 - 1) <= 1)
152 						retval = 1;
153 			}
154 			_enHdlVar[EN_ROTT1][5] = 0;
155 			_enHdlVar[EN_ROTT1][6] = _vm->_rnd.getRandomNumber(probability - 1) / 2;
156 		}
157 
158 		if (_actor[actor1].weapon == -1)
159 			retval = 2;
160 
161 		if ((_actor[actor1].field_54 == 0) &&
162 			(_actor[actor2].lost == 0) &&
163 			(_actor[actor1].lost == 0)) {
164 			if (_actor[actor1].act[3].state == 54) {
165 				switch (_vm->_rnd.getRandomNumber(9)) {
166 				case 3:
167 					if (!_enemyState[EN_ROTT1][6]) {
168 						_enemyState[EN_ROTT1][6] = 1;
169 						prepareScenePropScene(54, 0, 0);
170 					}
171 					break;
172 				case 8:
173 					if (!_enemyState[EN_ROTT1][4]) {
174 						_enemyState[EN_ROTT1][4] = 1;
175 						prepareScenePropScene(52, 0, 0);
176 					}
177 					break;
178 				}
179 			} else {
180 				switch (_vm->_rnd.getRandomNumber(14)) {
181 				case 2:
182 					if (!_enemyState[EN_ROTT1][2]) {
183 						_enemyState[EN_ROTT1][2] = 1;
184 						prepareScenePropScene(50, 0, 0);
185 					}
186 					break;
187 				case 4:
188 					if (!_enemyState[EN_ROTT1][3]) {
189 						_enemyState[EN_ROTT1][3] = 1;
190 						prepareScenePropScene(51, 0, 0);
191 					}
192 					break;
193 				case 6:
194 					if (!_enemyState[EN_ROTT1][7]) {
195 						_enemyState[EN_ROTT1][7] = 1;
196 						if (_enemy[EN_ROTT1].occurences)
197 							prepareScenePropScene(55, 0, 0);
198 					}
199 					break;
200 				case 9:
201 					if (!_enemyState[EN_ROTT1][5]) {
202 						_enemyState[EN_ROTT1][5] = 1;
203 						prepareScenePropScene(53, 0, 0);
204 					}
205 					break;
206 				case 11:
207 					if (!_enemyState[EN_ROTT1][8]) {
208 						_enemyState[EN_ROTT1][8] = 1;
209 						prepareScenePropScene(56, 0, 0);
210 					}
211 					break;
212 				default:
213 					break;
214 				}
215 			}
216 		}
217 		_enHdlVar[EN_ROTT1][1]++;
218 		_enHdlVar[EN_ROTT1][3]++;
219 		_enHdlVar[EN_ROTT1][5]++;
220 	}
221 
222 	if (act1x > 310)
223 		_actor[actor1].cursorX = -320;
224 	else if (act1x < 10)
225 		_actor[actor1].cursorX = 320;
226 	else if (act1x > 280)
227 		_actor[actor1].cursorX = -160;
228 
229 	// Shift+V cheat to win the battle
230 	if (_vm->getKeyState('V') && !_beenCheated &&
231 		!_actor[0].lost && !_actor[1].lost) {
232 		_beenCheated = 1;
233 		_actor[1].damage = _actor[1].maxdamage + 10;
234 	}
235 
236 	return retval;
237 }
238 
enemy0initializer(int32 actor1,int32 actor2,int32 probability)239 int32 Insane::enemy0initializer(int32 actor1, int32 actor2, int32 probability) {
240 	int i;
241 
242 	for (i = 0; i < 9; i++)
243 		_enemyState[EN_ROTT1][i] = 0;
244 
245 	for (i = 0; i < 9; i++)
246 		_enHdlVar[EN_ROTT1][i] = 0;
247 
248 	_beenCheated = 0;
249 
250 	return 1;
251 }
252 
enemy1handler(int32 actor1,int32 actor2,int32 probability)253 int32 Insane::enemy1handler(int32 actor1, int32 actor2, int32 probability) {
254 	int32 dist;
255 
256 	int32 retval = 0;
257 	int32 act1damage = _actor[actor1].damage; // ebx
258 	int32 act2damage = _actor[actor2].damage; // ebp
259 	int32 act1x = _actor[actor1].x; // esi
260 	int32 act2x = _actor[actor2].x; // edi
261 
262 	if (!_actor[actor1].defunct) {
263 		if (_enHdlVar[EN_ROTT2][1] > _enHdlVar[EN_ROTT2][2]) {
264 			if (act1damage - act2damage >= 30) {
265 				if (_vm->_rnd.getRandomNumber(probability - 1) != 1)
266 					_enHdlVar[EN_ROTT2][0] = 0;
267 				else
268 					_enHdlVar[EN_ROTT2][0] = 1;
269 			} else {
270 				_enHdlVar[EN_ROTT2][0] = 1;
271 			}
272 			_enHdlVar[EN_ROTT2][1] = 0;
273 			_enHdlVar[EN_ROTT2][2] = _vm->_rnd.getRandomNumber(probability * 2 - 1);
274 		}
275 
276 		dist = ABS(act1x - act2x);
277 
278 		if (_enHdlVar[EN_ROTT2][3] > _enHdlVar[EN_ROTT2][4]) {
279 			if (_enHdlVar[EN_ROTT2][0] == 1) {
280 				if (weaponMaxRange(actor1) < dist) {
281 					if (act2x < act1x)
282 						_actor[actor1].cursorX = -101;
283 					else
284 						_actor[actor1].cursorX = 101;
285 				} else {
286 					if (weaponMinRange(actor1) > dist) {
287 						if (act2x < act1x)
288 							_actor[actor1].cursorX = 101;
289 						else
290 							_actor[actor1].cursorX = -101;
291 					} else {
292 						_actor[actor1].cursorX = 0;
293 					}
294 				}
295 			} else {
296 				if (weaponMaxRange(actor2) >= dist) {
297 					if (act2x < act1x)
298 						_actor[actor1].cursorX = 101;
299 					else
300 						_actor[actor1].cursorX = -101;
301 				} else {
302 					_actor[actor1].cursorX = 0;
303 				}
304 			}
305 			_enHdlVar[EN_ROTT2][3] = 0;
306 			_enHdlVar[EN_ROTT2][4] = _vm->_rnd.getRandomNumber(probability - 1);
307 		}
308 
309 		if (_enHdlVar[EN_ROTT2][5] > _enHdlVar[EN_ROTT2][6]) {
310 			if (weaponMaxRange(actor2) + 40 >= dist) {
311 				if (_vm->_rnd.getRandomNumber(probability - 1) == 1)
312 					retval = 1;
313 			}
314 			if (_actor[actor2].kicking) {
315 				if (weaponMaxRange(actor2) >= dist)
316 					if (_vm->_rnd.getRandomNumber(probability * 2 - 1) <= 1)
317 						retval = 1;
318 			}
319 			_enHdlVar[EN_ROTT1][5] = 0;
320 			_enHdlVar[EN_ROTT1][6] = _vm->_rnd.getRandomNumber(probability - 1) / 2;
321 		}
322 
323 		if (_actor[actor1].weapon == -1)
324 			retval = 2;
325 
326 		if ((_actor[actor1].field_54 == 0) &&
327 			(_actor[actor2].lost == 0) &&
328 			(_actor[actor1].lost == 0)) {
329 			if (_actor[actor1].act[3].state == 54) {
330 				switch (_vm->_rnd.getRandomNumber(9)) {
331 				case 3:
332 					if (!_enemyState[EN_ROTT2][6]) {
333 						_enemyState[EN_ROTT2][6] = 1;
334 						prepareScenePropScene(38, 0, 0);
335 					}
336 					break;
337 				case 8:
338 					if (!_enemyState[EN_ROTT2][5]) {
339 						_enemyState[EN_ROTT2][5] = 1;
340 						prepareScenePropScene(37, 0, 0);
341 					}
342 					break;
343 				}
344 			} else {
345 				switch (_vm->_rnd.getRandomNumber(14)) {
346 				case 2:
347 					if (!_enemyState[EN_ROTT2][2]) {
348 						_enemyState[EN_ROTT2][2] = 1;
349 						prepareScenePropScene(34, 0, 0);
350 					}
351 					break;
352 				case 11:
353 					if (!_enemyState[EN_ROTT1][7]) {
354 						_enemyState[EN_ROTT1][7] = 1;
355 						prepareScenePropScene(39, 0, 0);
356 					}
357 					break;
358 				default:
359 					break;
360 				}
361 			}
362 		}
363 		_enHdlVar[EN_ROTT2][1]++;
364 		_enHdlVar[EN_ROTT2][3]++;
365 		_enHdlVar[EN_ROTT2][5]++;
366 	}
367 
368 	if (act1x > 310)
369 		_actor[actor1].cursorX = -320;
370 	else if (act1x < 10)
371 		_actor[actor1].cursorX = 320;
372 	else if (act1x > 280)
373 		_actor[actor1].cursorX = -160;
374 	else if (_actor[actor1].defunct)
375 		_actor[actor1].cursorX = 0;
376 
377 	// Shift+V cheat to win the battle
378 	if (_vm->getKeyState('V') && !_beenCheated &&
379 		!_actor[0].lost && !_actor[1].lost) {
380 		_beenCheated = 1;
381 		_actor[1].damage = _actor[1].maxdamage + 10;
382 	}
383 
384 	return retval;
385 }
386 
enemy1initializer(int32 actor1,int32 actor2,int32 probability)387 int32 Insane::enemy1initializer(int32 actor1, int32 actor2, int32 probability) {
388 	int i;
389 
390 	for (i = 0; i < 9; i++)
391 		_enemyState[EN_ROTT2][i] = 0;
392 
393 	for (i = 0; i < 9; i++)
394 		_enHdlVar[EN_ROTT2][i] = 0;
395 
396 	_beenCheated = 0;
397 
398 	return 1;
399 }
400 
enemy2handler(int32 actor1,int32 actor2,int32 probability)401 int32 Insane::enemy2handler(int32 actor1, int32 actor2, int32 probability) {
402 	int32 dist;
403 
404 	int32 retval = 0;
405 	int32 act1damage = _actor[actor1].damage; // ebx
406 	int32 act2damage = _actor[actor2].damage; // ebp
407 	int32 act1x = _actor[actor1].x; // esi
408 	int32 act2x = _actor[actor2].x; // edi
409 
410 	if (!_actor[actor1].defunct) {
411 		if (_enHdlVar[EN_ROTT3][1] > _enHdlVar[EN_ROTT3][2]) {
412 			if (act1damage - act2damage >= 30) {
413 				if (_vm->_rnd.getRandomNumber(probability - 1) != 1)
414 					_enHdlVar[EN_ROTT3][0] = 0;
415 				else
416 					_enHdlVar[EN_ROTT3][0] = 1;
417 			} else
418 				_enHdlVar[EN_ROTT3][0] = 1;
419 
420 			_enHdlVar[EN_ROTT3][1] = 0;
421 			_enHdlVar[EN_ROTT3][2] = _vm->_rnd.getRandomNumber(probability * 2 - 1);
422 		}
423 
424 		dist = ABS(act1x - act2x);
425 
426 		if (_enHdlVar[EN_ROTT3][3] > _enHdlVar[EN_ROTT3][4]) {
427 			if (_enHdlVar[EN_ROTT3][0] == 1) {
428 				if (weaponMaxRange(actor1) < dist) {
429 					if (act2x < act1x)
430 						_actor[actor1].cursorX = -101;
431 					else
432 						_actor[actor1].cursorX = 101;
433 				} else {
434 					if (weaponMinRange(actor1) > dist) {
435 						if (act2x < act1x)
436 							_actor[actor1].cursorX = 101;
437 						else
438 							_actor[actor1].cursorX = -101;
439 					} else {
440 						_actor[actor1].cursorX = 0;
441 					}
442 				}
443 			} else {
444 				if (weaponMaxRange(actor2) >= dist) {
445 					if (act2x < act1x)
446 						_actor[actor1].cursorX = 101;
447 					else
448 						_actor[actor1].cursorX = -101;
449 				} else {
450 					_actor[actor1].cursorX = 0;
451 				}
452 			}
453 			_enHdlVar[EN_ROTT3][3] = 0;
454 			_enHdlVar[EN_ROTT3][4] = _vm->_rnd.getRandomNumber(probability - 1);
455 		}
456 		if (_enHdlVar[EN_ROTT3][5] > _enHdlVar[EN_ROTT3][6]) {
457 			if (weaponMaxRange(actor2) + 40 >= dist) {
458 				if (_vm->_rnd.getRandomNumber(probability - 1) == 1)
459 					retval = 1;
460 			}
461 			if (_actor[actor2].kicking) {
462 				if (weaponMaxRange(actor2) <= dist)
463 					if (_vm->_rnd.getRandomNumber(probability * 2 - 1) <= 1)
464 						retval = 1;
465 			}
466 			_enHdlVar[EN_ROTT3][5] = 0;
467 			_enHdlVar[EN_ROTT3][6] = _vm->_rnd.getRandomNumber(probability - 1) / 2;
468 		}
469 
470 		if (_actor[actor1].weapon == -1)
471 			retval = 2;
472 
473 		if ((_actor[actor1].field_54 == 0) &&
474 			(_actor[actor2].lost == 0) &&
475 			(_actor[actor1].lost == 0)) {
476 			if (_actor[actor1].act[3].state == 54) {
477 				switch (_vm->_rnd.getRandomNumber(9)) {
478 				case 3:
479 					if (!_enemyState[EN_ROTT3][1]) {
480 						_enemyState[EN_ROTT3][1] = 1;
481 						prepareScenePropScene(26, 0, 0);
482 					}
483 					break;
484 				case 5:
485 					if (!_enemyState[EN_ROTT3][3]) {
486 						_enemyState[EN_ROTT3][3] = 1;
487 						prepareScenePropScene(28, 0, 0);
488 					}
489 					break;
490 				case 8:
491 					if (!_enemyState[EN_ROTT3][2]) {
492 						_enemyState[EN_ROTT3][2] = 1;
493 						prepareScenePropScene(27, 0, 0);
494 					}
495 					break;
496 				}
497 			} else {
498 				if (_actor[actor1].kicking) {
499 					if (_vm->_rnd.getRandomNumber(9) == 9) {
500 						if (!_enemyState[EN_ROTT3][6]) {
501 							_enemyState[EN_ROTT3][6] = 1;
502 							prepareScenePropScene(31, 0, 0);
503 						}
504 					}
505 				} else {
506 					if (_vm->_rnd.getRandomNumber(14) == 7) {
507 						if (!_enemyState[EN_ROTT3][5]) {
508 							_enemyState[EN_ROTT3][5] = 1;
509 							prepareScenePropScene(30, 0, 0);
510 						}
511 					}
512 				}
513 			}
514 		}
515 		_enHdlVar[EN_ROTT3][1]++;
516 		_enHdlVar[EN_ROTT3][3]++;
517 		_enHdlVar[EN_ROTT3][5]++;
518 	}
519 
520 	if (act1x > 310)
521 		_actor[actor1].cursorX = -320;
522 	else if (act1x < 10)
523 		_actor[actor1].cursorX = 320;
524 	else if (act1x > 280)
525 		_actor[actor1].cursorX = -160;
526 
527 	// Shift+V cheat to win the battle
528 	if (_vm->getKeyState('V') && !_beenCheated &&
529 		!_actor[0].lost && !_actor[1].lost) {
530 		_beenCheated = 1;
531 		_actor[1].damage = _actor[1].maxdamage + 10;
532 	}
533 
534 	return retval;
535 }
536 
enemy2initializer(int32 actor1,int32 actor2,int32 probability)537 int32 Insane::enemy2initializer(int32 actor1, int32 actor2, int32 probability) {
538 	int i;
539 
540 	for (i = 0; i < 7; i++)
541 		_enemyState[EN_ROTT3][i] = 0;
542 
543 	for (i = 0; i < 9; i++)
544 		_enHdlVar[EN_ROTT3][i] = 0;
545 
546 	_beenCheated = 0;
547 
548 	return 1;
549 }
550 
enemy3handler(int32 actor1,int32 actor2,int32 probability)551 int32 Insane::enemy3handler(int32 actor1, int32 actor2, int32 probability) {
552 	int32 dist;
553 
554 	int32 retval = 0;
555 	int32 act1damage = _actor[actor1].damage; // ebx
556 	int32 act2damage = _actor[actor2].damage; // ebp
557 	int32 act1x = _actor[actor1].x; // esi
558 	int32 act2x = _actor[actor2].x; // edi
559 
560 	if (!_actor[actor1].defunct) {
561 		if (_enHdlVar[EN_VULTF1][1] > _enHdlVar[EN_VULTF1][2]) {
562 			if (act1damage - act2damage >= 30) {
563 				if (_vm->_rnd.getRandomNumber(probability - 1) != 1)
564 					_enHdlVar[EN_VULTF1][0] = 0;
565 				else
566 					_enHdlVar[EN_VULTF1][0] = 1;
567 			} else
568 				_enHdlVar[EN_VULTF1][0] = 1;
569 
570 			_enHdlVar[EN_VULTF1][1] = 0;
571 			_enHdlVar[EN_VULTF1][2] = _vm->_rnd.getRandomNumber(probability * 2 - 1);
572 		}
573 
574 		dist = ABS(act1x - act2x);
575 
576 		if (_enHdlVar[EN_VULTF1][3] > _enHdlVar[EN_VULTF1][4]) {
577 			if (_enHdlVar[EN_VULTF1][0] == 1) {
578 				if (weaponMaxRange(actor1) < dist) {
579 					if (act2x < act1x)
580 						_actor[actor1].cursorX = -101;
581 					else
582 						_actor[actor1].cursorX = 101;
583 				} else {
584 					if (weaponMinRange(actor1) > dist) {
585 						if (act2x < act1x)
586 							_actor[actor1].cursorX = 101;
587 						else
588 							_actor[actor1].cursorX = -101;
589 					} else {
590 						_actor[actor1].cursorX = 0;
591 					}
592 				}
593 			} else {
594 				if (weaponMaxRange(actor2) >= dist) {
595 					if (act2x < act1x)
596 						_actor[actor1].cursorX = 101;
597 					else
598 						_actor[actor1].cursorX = -101;
599 				} else {
600 					_actor[actor1].cursorX = 0;
601 				}
602 			}
603 			_enHdlVar[EN_VULTF1][3] = 0;
604 			_enHdlVar[EN_VULTF1][4] = _vm->_rnd.getRandomNumber(probability - 1);
605 		}
606 
607 		if (_enHdlVar[EN_VULTF1][5] > _enHdlVar[EN_VULTF1][6]) {
608 			if (_enHdlVar[EN_VULTF1][0] == 1) {
609 				if (weaponMaxRange(actor2) + 40 >= dist)
610 					if (_vm->_rnd.getRandomNumber(probability - 1) == 1)
611 						retval = 1;
612 			} else {
613 				if (_actor[actor1].kicking)
614 					if (weaponMaxRange(actor2) >= dist)
615 						if (_vm->_rnd.getRandomNumber(probability - 1) <= 1)
616 							retval = 1;
617 			}
618 			_enHdlVar[EN_VULTF1][5] = 0;
619 			_enHdlVar[EN_VULTF1][6] = _vm->_rnd.getRandomNumber(probability - 1) / 2;
620 		}
621 
622 		if (_actor[actor1].weapon == -1)
623 			retval = 2;
624 
625 		if ((_actor[actor1].field_54 == 0) &&
626 			(_actor[actor2].lost == 0) &&
627 			(_actor[actor1].lost == 0)) {
628 			_enHdlVar[EN_VULTF1][8] = _vm->_rnd.getRandomNumber(25);
629 			if (_enHdlVar[EN_VULTF1][8] != _enHdlVar[EN_VULTF1][7]) {
630 				switch (_enHdlVar[EN_VULTF1][8]) {
631 				case 0:
632 					if (!_enemyState[EN_VULTF1][4]) {
633 						_enemyState[EN_VULTF1][4] = 1;
634 						prepareScenePropScene(3, 0, 0);
635 					}
636 					break;
637 				case 1:
638 					if (!_enemyState[EN_VULTF1][1]) {
639 						_enemyState[EN_VULTF1][1] = 1;
640 						prepareScenePropScene(4, 0, 0);
641 					}
642 					break;
643 				case 2:
644 					if (!_enemyState[EN_VULTF1][2]) {
645 						_enemyState[EN_VULTF1][2] = 1;
646 						prepareScenePropScene(5, 0, 0);
647 					}
648 					break;
649 				case 3:
650 					if (!_enemyState[EN_VULTF1][3]) {
651 						_enemyState[EN_VULTF1][3] = 1;
652 						prepareScenePropScene(6, 0, 0);
653 					}
654 					break;
655 				case 4:
656 					if (!_enemyState[EN_VULTF1][4]) {
657 						_enemyState[EN_VULTF1][4] = 1;
658 						prepareScenePropScene(7, 0, 0);
659 					}
660 					break;
661 				case 5:
662 					if (!_enemyState[EN_VULTF1][5]) {
663 						_enemyState[EN_VULTF1][5] = 1;
664 						prepareScenePropScene(8, 0, 0);
665 					}
666 					break;
667 				}
668 				_enHdlVar[EN_VULTF1][7] = _enHdlVar[EN_VULTF1][8];
669 			}
670 
671 		}
672 		_enHdlVar[EN_VULTF1][1]++;
673 		_enHdlVar[EN_VULTF1][3]++;
674 		_enHdlVar[EN_VULTF1][5]++;
675 	} else {
676 		_actor[actor1].cursorX = 0;
677 	}
678 
679 	if (act1x > 310)
680 		_actor[actor1].cursorX = -320;
681 	else if (act1x < 10)
682 		_actor[actor1].cursorX = 320;
683 	else if (act1x > 280)
684 		_actor[actor1].cursorX = -160;
685 
686 	// Shift+V cheat to win the battle
687 	if (_vm->getKeyState('V') && !_beenCheated &&
688 		!_actor[0].lost && !_actor[1].lost) {
689 		_beenCheated = 1;
690 		_actor[1].damage = _actor[1].maxdamage + 10;
691 	}
692 
693 	return retval;
694 }
695 
enemy3initializer(int32 actor1,int32 actor2,int32 probability)696 int32 Insane::enemy3initializer(int32 actor1, int32 actor2, int32 probability) {
697 	int i;
698 
699 	for (i = 0; i < 6; i++)
700 		_enemyState[EN_VULTF1][i] = 0;
701 
702 	for (i = 0; i < 9; i++)
703 		_enHdlVar[EN_VULTF1][i] = 0;
704 
705 	_beenCheated = 0;
706 
707 	return 1;
708 }
709 
enemy4handler(int32 actor1,int32 actor2,int32 probability)710 int32 Insane::enemy4handler(int32 actor1, int32 actor2, int32 probability) {
711 	int32 dist;
712 
713 	int32 retval = 0;
714 	int32 act1damage = _actor[actor1].damage; // ebx
715 	int32 act2damage = _actor[actor2].damage; // ebp
716 	int32 act1x = _actor[actor1].x; // esi
717 	int32 act2x = _actor[actor2].x; // edi
718 
719 	if (!_actor[actor1].defunct) {
720 		if (_enHdlVar[EN_VULTM1][1] > _enHdlVar[EN_VULTM1][2]) {
721 			if (act1damage - act2damage >= 30) {
722 				if (_vm->_rnd.getRandomNumber(probability - 1) != 1)
723 					_enHdlVar[EN_VULTM1][0] = 0;
724 				else
725 					_enHdlVar[EN_VULTM1][0] = 1;
726 			} else
727 				_enHdlVar[EN_VULTM1][0] = 1;
728 
729 			_enHdlVar[EN_VULTM1][1] = 0;
730 			_enHdlVar[EN_VULTM1][2] = _vm->_rnd.getRandomNumber(probability * 2 - 1);
731 		}
732 
733 		dist = ABS(act1x - act2x);
734 
735 		if (_enHdlVar[EN_VULTM1][3] > _enHdlVar[EN_VULTM1][4]) {
736 			if (_enHdlVar[EN_VULTM1][0] == 1) {
737 				if (weaponMaxRange(actor1) < dist) {
738 					if (act2x < act1x)
739 						_actor[actor1].cursorX = -101;
740 					else
741 						_actor[actor1].cursorX = 101;
742 				} else {
743 					if (weaponMinRange(actor1) > dist) {
744 						if (act2x < act1x)
745 							_actor[actor1].cursorX = 101;
746 						else
747 							_actor[actor1].cursorX = -101;
748 					} else {
749 						_actor[actor1].cursorX = 0;
750 					}
751 				}
752 			} else {
753 				if (weaponMaxRange(actor2) >= dist) {
754 					if (act2x < act1x)
755 						_actor[actor1].cursorX = 101;
756 					else
757 						_actor[actor1].cursorX = -101;
758 				} else {
759 					_actor[actor1].cursorX = 0;
760 				}
761 			}
762 			_enHdlVar[EN_VULTM1][3] = 0;
763 			_enHdlVar[EN_VULTM1][4] = _vm->_rnd.getRandomNumber(probability - 1);
764 		}
765 		if (_enHdlVar[EN_VULTM1][5] > _enHdlVar[EN_VULTM1][6]) {
766 			if (weaponMaxRange(actor2) + 40 >= dist) {
767 				if (_vm->_rnd.getRandomNumber(probability - 1) == 1)
768 					retval = 1;
769 			}
770 			if (_actor[actor2].kicking) {
771 				if (weaponMaxRange(actor2) >= dist)
772 					if (_vm->_rnd.getRandomNumber(probability * 2 - 1) <= 1)
773 						retval = 1;
774 			}
775 			_enHdlVar[EN_VULTM1][5] = 0;
776 			_enHdlVar[EN_VULTM1][6] = _vm->_rnd.getRandomNumber(probability - 1) / 2;
777 		}
778 
779 		if (_actor[actor1].weapon == -1)
780 			retval = 2;
781 
782 		if ((_actor[actor1].field_54 == 0) &&
783 			(_actor[actor2].lost == 0) &&
784 			(_actor[actor1].lost == 0)) {
785 			if (_actor[actor1].act[3].state == 54) {
786 				switch (_vm->_rnd.getRandomNumber(9)) {
787 				case 4:
788 					if (!_enemyState[EN_VULTM1][7]) {
789 						_enemyState[EN_VULTM1][7] = 1;
790 						prepareScenePropScene(46, 0, 0);
791 					}
792 					break;
793 				case 8:
794 					if (!_enemyState[EN_VULTM1][8]) {
795 						_enemyState[EN_VULTM1][8] = 1;
796 						prepareScenePropScene(47, 0, 0);
797 					}
798 					break;
799 				}
800 			} else {
801 				if (_actor[actor1].kicking) {
802 					switch (_vm->_rnd.getRandomNumber(9)) {
803 					case 3:
804 						prepareScenePropScene(44, 0, 0);
805 						break;
806 					case 9: // Original is 10 here which never happens
807 						prepareScenePropScene(45, 0, 0);
808 						break;
809 					}
810 				} else {
811 					if (weaponMaxRange(actor2) >= dist) {
812 						switch (_vm->_rnd.getRandomNumber(9)) {
813 						case 3:
814 							if (!_enemyState[EN_VULTM1][3]) {
815 								_enemyState[EN_VULTM1][3] = 1;
816 								prepareScenePropScene(42, 0, 0);
817 							}
818 							break;
819 						case 9: // Original is 10 here which never happens
820 							if (!_enemyState[EN_VULTM1][4]) {
821 								_enemyState[EN_VULTM1][4] = 1;
822 								prepareScenePropScene(43, 0, 0);
823 							}
824 							break;
825 						}
826 					} else {
827 						switch (_vm->_rnd.getRandomNumber(14)) {
828 						case 7:
829 							if (!_enemyState[EN_VULTM1][9]) {
830 								_enemyState[EN_VULTM1][9] = 1;
831 								prepareScenePropScene(48, 0, 0);
832 							}
833 							break;
834 						case 11:
835 							if (!_enemyState[EN_VULTM1][1]) {
836 								_enemyState[EN_VULTM1][1] = 1;
837 								prepareScenePropScene(40, 0, 0);
838 							}
839 							break;
840 						}
841 					}
842 				}
843 			}
844 		}
845 		_enHdlVar[EN_VULTM1][1]++;
846 		_enHdlVar[EN_VULTM1][3]++;
847 		_enHdlVar[EN_VULTM1][5]++;
848 	}
849 
850 	if (act1x > 310)
851 		_actor[actor1].cursorX = -320;
852 	else if (act1x < 10)
853 		_actor[actor1].cursorX = 320;
854 	else if (act1x > 280)
855 		_actor[actor1].cursorX = -160;
856 
857 	// Shift+V cheat to win the battle
858 	if (_vm->getKeyState('V') && !_beenCheated &&
859 		!_actor[0].lost && !_actor[1].lost) {
860 		_beenCheated = 1;
861 		_actor[1].damage = _actor[1].maxdamage + 10;
862 	}
863 
864 	return retval;
865 }
866 
enemy4initializer(int32 actor1,int32 actor2,int32 probability)867 int32 Insane::enemy4initializer(int32 actor1, int32 actor2, int32 probability) {
868 	int i;
869 
870 	for (i = 0; i < 10; i++)
871 		_enemyState[EN_VULTM1][i] = 0;
872 
873 	for (i = 0; i < 9; i++)
874 		_enHdlVar[EN_VULTM1][i] = 0;
875 
876 	_beenCheated = 0;
877 
878 	return 1;
879 }
880 
enemy5handler(int32 actor1,int32 actor2,int32 probability)881 int32 Insane::enemy5handler(int32 actor1, int32 actor2, int32 probability) {
882 	int32 retval = 0;
883 	int32 act1damage = _actor[actor1].damage; // ebx
884 	int32 act1x = _actor[actor1].x; // esi
885 	int32 act2x = _actor[actor2].x; // ebp
886 
887 	int32 dist = ABS(act1x - act2x);
888 
889 	if (weaponMaxRange(actor1) >= dist) {
890 		if (!_enHdlVar[EN_VULTF2][2])
891 			_enHdlVar[EN_VULTF2][3]++;
892 		_enHdlVar[EN_VULTF2][1] = 1;
893 	} else {
894 		_enHdlVar[EN_VULTF2][1] = 0;
895 	}
896 
897 	if (!_actor[actor1].defunct) {
898 		if (_enHdlVar[EN_VULTF2][3] >= 2 || act1damage) {
899 			_actor[actor1].damage = 10;
900 
901 			if (weaponMaxRange(actor1) <= dist) {
902 				if (act2x < act1x)
903 					_actor[actor1].cursorX = -101;
904 				else
905 					_actor[actor1].cursorX = 101;
906 			} else {
907 				_actor[actor1].cursorX = 0;
908 			}
909 
910 			if (weaponMaxRange(actor1) + 20 >= dist)
911 				if (_vm->_rnd.getRandomNumber(probability - 1) == 1)
912 					retval = 1;
913 		} else {
914 			if (weaponMaxRange(actor2) >= dist && _actor[actor2].weapon == INV_CHAINSAW) {
915 				if (_actor[actor2].kicking || (_vm->_rnd.getRandomNumber(probability - 1) == 1))
916 					retval = 1;
917 			}
918 			_actor[actor1].cursorX = 0;
919 			if (_enHdlVar[EN_VULTF2][0] >= 100)
920 				_enHdlVar[EN_VULTF2][3] = 3;
921 		}
922 
923 		if ((_actor[actor1].field_54 == 0) &&
924 			(_actor[actor2].lost == 0) &&
925 			(_actor[actor1].lost == 0)) {
926 			if (_actor[actor1].act[3].state == 54)
927 				switch (_vm->_rnd.getRandomNumber(9)) {
928 				case 4:
929 					if (!_enemyState[EN_VULTF2][6]) {
930 						_enemyState[EN_VULTF2][6] = 1;
931 						prepareScenePropScene(15, 0, 0);
932 					}
933 					break;
934 				case 8:
935 					if (!_enemyState[EN_VULTF2][3]) {
936 						_enemyState[EN_VULTF2][3] = 1;
937 						prepareScenePropScene(12, 0, 0);
938 					}
939 					break;
940 				}
941 			else {
942 				if (_actor[actor1].kicking) {
943 					switch (_vm->_rnd.getRandomNumber(9)) {
944 					case 2:
945 						if (!_enemyState[EN_VULTF2][8]) {
946 							_enemyState[EN_VULTF2][8] = 1;
947 							prepareScenePropScene(17, 0, 0);
948 						}
949 						break;
950 					case 5:
951 						prepareScenePropScene(11, 0, 0);
952 						_enemyState[EN_VULTF2][2] = 1;
953 						break;
954 					case 9: // Original is 10
955 						_enemyState[EN_VULTF2][1] = 1;
956 						prepareScenePropScene(10, 0, 0);
957 						break;
958 					}
959 				} else {
960 					switch (_vm->_rnd.getRandomNumber(14)) {
961 					case 3:
962 						if (!_enemyState[EN_VULTF2][4]) {
963 							_enemyState[EN_VULTF2][4] = 1;
964 							prepareScenePropScene(13, 0, 0);
965 						}
966 						break;
967 					case 11:
968 						if (!_enemyState[EN_VULTF2][5]) {
969 							_enemyState[EN_VULTF2][5] = 1;
970 							prepareScenePropScene(14, 0, 0);
971 						}
972 						break;
973 					}
974 				}
975 			}
976 		}
977 	}
978 
979 	if (_actor[actor1].weapon == -1)
980 		retval = 2;
981 
982 	if (act1x > 310)
983 		_actor[actor1].cursorX = -320;
984 	else if (act1x < 10)
985 		_actor[actor1].cursorX = 320;
986 	else if (act1x > 280)
987 		_actor[actor1].cursorX = -160;
988 	else if (_actor[actor1].defunct)
989 		_actor[actor1].cursorX = 0;
990 
991 	_enHdlVar[EN_VULTF2][2] = _enHdlVar[EN_VULTF2][1];
992 	_enHdlVar[EN_VULTF2][0]++;
993 
994 	// Shift+V cheat to win the battle
995 	if (_vm->getKeyState('V') && !_beenCheated &&
996 		!_actor[0].lost && !_actor[1].lost) {
997 		_beenCheated = 1;
998 		_actor[1].damage = _actor[1].maxdamage + 10;
999 		_actor[1].act[2].state = 113;
1000 	}
1001 
1002 	return retval;
1003 }
1004 
enemy5initializer(int32 actor1,int32 actor2,int32 probability)1005 int32 Insane::enemy5initializer(int32 actor1, int32 actor2, int32 probability) {
1006 	int i;
1007 
1008 	for (i = 0; i < 9; i++)
1009 		_enemyState[EN_VULTF2][i] = 0;
1010 
1011 	for (i = 0; i < 9; i++)
1012 		_enHdlVar[EN_VULTF2][i] = 0;
1013 
1014 	_beenCheated = 0;
1015 
1016 	return 1;
1017 }
1018 
enemy6handler(int32 actor1,int32 actor2,int32 probability)1019 int32 Insane::enemy6handler(int32 actor1, int32 actor2, int32 probability) {
1020 	int32 retval = 0;
1021 	int32 act1damage = _actor[actor1].damage; // ebx //ebx
1022 	//int32 act2damage = _actor[actor2].damage; // ebp // edi
1023 	int32 act1x = _actor[actor1].x; // esi
1024 	int32 act2x = _actor[actor2].x; // edi
1025 
1026 	if (_actor[actor2].weapon == INV_CHAINSAW)
1027 		retval = 1;
1028 
1029 	int32 dist = ABS(act1x - act2x);
1030 
1031 	if (_actor[actor1].defunct) {
1032 		/*                       scenePropIdx[18] */
1033 		if (_currScenePropIdx == 50 && _currScenePropSubIdx == 3)
1034 			retval = 1;
1035 	} else {
1036 		if (act1damage > 0 || _enHdlVar[EN_VULTM2][0] > 20) {
1037 			_actor[actor1].damage = 10;
1038 			if (!_enHdlVar[EN_VULTM2][1] && !_actor[actor1].lost) {
1039 				if (!_actor[actor1].field_54) {
1040 					switch (_vm->_rnd.getRandomNumber(3)) {
1041 					case 0:
1042 						if (!_enemyState[EN_VULTM2][1]) {
1043 							_enemyState[EN_VULTM2][1] = 1;
1044 							prepareScenePropScene(19, 0, 0);
1045 						}
1046 						break;
1047 					case 1:
1048 						if (!_enemyState[EN_VULTM2][2]) {
1049 							_enemyState[EN_VULTM2][2] = 1;
1050 							prepareScenePropScene(20, 0, 0);
1051 						}
1052 						break;
1053 					case 2:
1054 						if (!_enemyState[EN_VULTM2][3]) {
1055 							_enemyState[EN_VULTM2][3] = 1;
1056 							prepareScenePropScene(21, 0, 0);
1057 						}
1058 						break;
1059 					case 3:
1060 						if (!_enemyState[EN_VULTM2][4]) {
1061 							_enemyState[EN_VULTM2][4] = 1;
1062 							prepareScenePropScene(22, 0, 0);
1063 						}
1064 						break;
1065 					}
1066 					_enHdlVar[EN_VULTM2][1] = 1;
1067 					goto _label1;
1068 				}
1069 			} else {
1070 				if (_actor[actor1].field_54 == 0 &&
1071 					_actor[actor1].lost == 0) {
1072 					retval = 1;
1073 					_enHdlVar[EN_VULTM2][0] = 0;
1074 				}
1075 			}
1076 		} else {
1077 			if (weaponMaxRange(actor2) >= dist) {
1078 				if (act2x < act1x)
1079 					_actor[actor1].cursorX = 101;
1080 				else
1081 					_actor[actor1].cursorX = -101;
1082 			} else {
1083 				_actor[actor1].cursorX = 0;
1084 			}
1085 		}
1086 
1087 		if ((_enHdlVar[EN_VULTM2][1] == 0) &&
1088 			( _actor[actor1].field_54 == 0) &&
1089 			(_actor[actor2].lost == 0) &&
1090 			(_actor[actor1].lost == 0)) {
1091 			switch (_vm->_rnd.getRandomNumber(14)) {
1092 			case 2:
1093 				if (!_enemyState[EN_VULTM2][5]) {
1094 					_enemyState[EN_VULTM2][5] = 1;
1095 					prepareScenePropScene(23, 0, 0);
1096 				}
1097 				break;
1098 			case 7:
1099 				if (!_enemyState[EN_VULTF1][6]) {
1100 					_enemyState[EN_VULTF1][6] = 1;
1101 					prepareScenePropScene(24, 0, 0);
1102 				}
1103 				break;
1104 			}
1105 		}
1106 	}
1107 
1108 	_label1:
1109 	if (act1x > 310)
1110 		_actor[actor1].cursorX = -320;
1111 	else if (act1x < 219)
1112 		_actor[actor1].cursorX = 320;
1113 	else if (act1x > 280)
1114 		_actor[actor1].cursorX = -160;
1115 	else
1116 		_actor[actor1].cursorX = 0;
1117 
1118 	if (_actor[actor1].weapon == -1)
1119 		retval = 2;
1120 
1121 	_enHdlVar[EN_VULTM2][0]++;
1122 
1123 	// Shift+V cheat to win the battle
1124 	if (_vm->getKeyState('V') && !_beenCheated &&
1125 		!_actor[0].lost && !_actor[1].lost) {
1126 		_beenCheated = 1;
1127 		_actor[0].act[2].state = 97;
1128 		smlayer_setActorFacing(0, 2, 20, 180);
1129 		_actor[0].act[2].room = 0;
1130 		_actor[0].act[1].room = 0;
1131 		_actor[0].act[0].room = 0;
1132 		smlayer_setActorLayer(1, 2, 25);
1133 		smlayer_setActorCostume(1, 2, readArray(45));
1134 		smlayer_setActorFacing(1, 2, 6, 180);
1135 		_actor[1].act[2].state = 97;
1136 		_actor[1].act[2].room = 1;
1137 		_actor[1].act[1].room = 0;
1138 		_actor[1].act[0].room = 0;
1139 	}
1140 
1141 	if (_actor[actor1].lost)
1142 		retval = 0;
1143 
1144 	return retval;
1145 }
1146 
enemy6initializer(int32 actor1,int32 actor2,int32 probability)1147 int32 Insane::enemy6initializer(int32 actor1, int32 actor2, int32 probability) {
1148 	int i;
1149 
1150 	for (i = 0; i < 7; i++)
1151 		_enemyState[EN_VULTM2][i] = 0;
1152 
1153 	for (i = 0; i < 9; i++)
1154 		_enHdlVar[EN_VULTM2][i] = 0;
1155 
1156 	_beenCheated = 0;
1157 
1158 	return 1;
1159 }
1160 
enemy7handler(int32 actor1,int32 actor2,int32 probability)1161 int32 Insane::enemy7handler(int32 actor1, int32 actor2, int32 probability) {
1162 	int32 retval = 0;
1163 	int32 act1damage = _actor[actor1].damage; // ebx
1164 	int32 act1x = _actor[actor1].x; // ebp, esi
1165 	int32 act2x = _actor[actor2].x; // edi
1166 
1167 	int32 dist = ABS(act1x - act2x);
1168 
1169 	if (_enHdlVar[EN_CAVEFISH][1] >= 600) {
1170 		_enHdlVar[EN_CAVEFISH][2] = 1;
1171 		_enHdlVar[EN_CAVEFISH][1] = 0;
1172 	} else {
1173 		if (!_enHdlVar[EN_CAVEFISH][2]) {
1174 			if (weaponMaxRange(actor2) + 30 >= dist) {
1175 				if (act2x < act1x)
1176 					_actor[actor1].cursorX = 101;
1177 				else
1178 					_actor[actor1].cursorX = -101;
1179 			} else {
1180 				_actor[actor1].cursorX = 0;
1181 			}
1182 			goto _labelA;
1183 		}
1184 	}
1185 
1186 	if (weaponMaxRange(actor1) <= dist) {
1187 		if (act2x < act1x)
1188 			_actor[actor1].cursorX = -101;
1189 		else
1190 			_actor[actor1].cursorX = 101;
1191 	} else {
1192 		_actor[actor1].cursorX = 0;
1193 	}
1194 
1195 	_labelA:
1196 	if (act1x > 310)
1197 		_actor[actor1].cursorX = -320;
1198 	else if (act1x < 10)
1199 		_actor[actor1].cursorX = 320;
1200 
1201 	if (dist <= 95)
1202 		retval = 1;
1203 
1204 	if (_actor[actor1].weapon == -1)
1205 		retval = 2;
1206 
1207 	_enHdlVar[EN_CAVEFISH][1]++;
1208 	_enHdlVar[EN_CAVEFISH][0] = act1damage;
1209 
1210 	// Shift+V cheat to win the battle
1211 	if (_vm->getKeyState('V') && !_beenCheated &&
1212 		!_actor[0].lost && !_actor[1].lost) {
1213 		_beenCheated = 1;
1214 		_actor[1].damage = _actor[1].maxdamage + 10;
1215 		_actor[1].act[2].state = 102;
1216 	}
1217 
1218 	return retval;
1219 }
1220 
enemy7initializer(int32 actor1,int32 actor2,int32 probability)1221 int32 Insane::enemy7initializer(int32 actor1, int32 actor2, int32 probability) {
1222 	int i;
1223 
1224 	for (i = 0; i < 9; i++)
1225 		_enHdlVar[EN_CAVEFISH][i] = 0;
1226 
1227 	_beenCheated = 0;
1228 
1229 	return 1;
1230 }
1231 
enemy8handler(int32 actor1,int32 actor2,int32 probability)1232 int32 Insane::enemy8handler(int32 actor1, int32 actor2, int32 probability) {
1233 	_actor[actor1].cursorX = 0;
1234 	return 0;
1235 }
1236 
enemy8initializer(int32 actor1,int32 actor2,int32 probability)1237 int32 Insane::enemy8initializer(int32 actor1, int32 actor2, int32 probability) {
1238 	return 1;
1239 }
1240 
1241 
ouchSoundEnemy()1242 void Insane::ouchSoundEnemy() {
1243 	int32 tmp;
1244 
1245 	_actor[1].act[3].state = 52;
1246 
1247 	if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS)) {
1248 		smlayer_startVoice(55);
1249 		return;
1250 	}
1251 
1252 	switch (_currEnemy) {
1253 	case EN_VULTF1:
1254 		if (_actor[0].weapon == INV_DUST) {
1255 			smlayer_startVoice(287);
1256 		} else {
1257 			if (_vm->_rnd.getRandomNumber(1)) {
1258 				smlayer_startVoice(279);
1259 			} else {
1260 				smlayer_startVoice(280);
1261 			}
1262 		}
1263 		break;
1264 	case EN_VULTF2:
1265 		smlayer_startVoice(271);
1266 		break;
1267 	case EN_VULTM1:
1268 		smlayer_startVoice(162);
1269 		break;
1270 	case EN_ROTT1:
1271 		tmp = _vm->_rnd.getRandomNumber(2);
1272 
1273 		if (!tmp) {
1274 			smlayer_startVoice(216);
1275 		} else if (tmp == 1) {
1276 			smlayer_startVoice(217);
1277 		} else {
1278 			smlayer_startVoice(218);
1279 		}
1280 		break;
1281 	case EN_ROTT2:
1282 		tmp = _vm->_rnd.getRandomNumber(2);
1283 
1284 		if (!tmp) {
1285 			smlayer_startVoice(243);
1286 		} else if (tmp == 1) {
1287 			smlayer_startVoice(244);
1288 		} else {
1289 			smlayer_startVoice(245);
1290 		}
1291 		break;
1292 	case EN_VULTM2:
1293 		smlayer_startVoice(180);
1294 		break;
1295 	default:
1296 		smlayer_startVoice(99);
1297 		break;
1298 	}
1299 }
1300 
loadScenePropSounds(int32 scenePropNum)1301 bool Insane::loadScenePropSounds(int32 scenePropNum) {
1302 	int32 num = 0;
1303 	int32 res = 1;
1304 
1305 	if (_sceneProp[scenePropNum + num].index != 1) {
1306 		while (num < 12) {
1307 			res &= smlayer_loadSound(_sceneProp[scenePropNum + num].sound, 0, 2);
1308 			num = _sceneProp[scenePropNum + num].index;
1309 
1310 			if (!num)
1311 				break;
1312 		}
1313 	}
1314 
1315 	return res != 0;
1316 }
1317 
turnEnemy(bool battle)1318 void Insane::turnEnemy(bool battle) {
1319 	int buttons;
1320 
1321 	if (_actor[1].damage < _actor[1].maxdamage) {
1322 		_actor[1].lost = false;
1323 	} else {
1324 		if (!_actor[1].lost && !_actor[0].lost) {
1325 			_actor[1].lost = true;
1326 			_actor[1].act[2].state = 36;
1327 			_actor[1].act[1].state = 36;
1328 			_actor[1].act[0].state = 36;
1329 			_actor[1].act[1].room = 0;
1330 			_actor[1].act[0].room = 0;
1331 		}
1332 	}
1333 
1334 	buttons = 0;
1335 
1336 	if (_actor[1].lost == 0)
1337 		if (battle)
1338 			buttons = actionEnemy();
1339 
1340 	debug(5, "11:%d 12:%d 13:%d 10:%d", _actor[1].act[1].state,
1341 				_actor[1].act[2].state, _actor[1].act[3].state, _actor[1].act[0].state);
1342 	actor11Reaction(buttons);
1343 	actor12Reaction(buttons);
1344 	actor13Reaction(buttons);
1345 	actor10Reaction(buttons);
1346 }
1347 
actor11Reaction(int32 buttons)1348 void Insane::actor11Reaction(int32 buttons) {
1349 	int32 tmpx, tmpy;
1350 
1351 	chooseEnemyWeaponAnim(buttons);
1352 
1353 	switch (_actor[1].tilt) {
1354 	case -3:
1355 		if (_actor[1].act[1].state != 41 || _actor[1].weaponClass != _actor[1].animWeaponClass) {
1356 			setEnemyAnimation(1, 6);
1357 			_actor[1].act[1].state = 41;
1358 		}
1359 
1360 		if (_actor[1].cursorX >= -100) {
1361 			setEnemyAnimation(1, 7);
1362 			_actor[1].act[1].state = 40;
1363 			_actor[1].field_8 = 48;
1364 			_actor[1].tilt = -2;
1365 		}
1366 
1367 		_actor[1].x += _actor[1].cursorX / 32;
1368 		break;
1369 	case -2:
1370 		if (_actor[1].act[1].state != 40 || _actor[1].weaponClass != _actor[1].animWeaponClass) {
1371 			setEnemyAnimation(1, 7);
1372 			_actor[1].act[1].state = 40;
1373 		}
1374 		if (_actor[1].field_8 == 48)
1375 			_actor[1].tilt = -1;
1376 		else
1377 			_actor[1].tilt = -3;
1378 
1379 		_actor[1].x += _actor[1].cursorX / 32;
1380 		break;
1381 	case -1:
1382 		if (_actor[1].act[1].state != 39 || _actor[1].weaponClass != _actor[1].animWeaponClass) {
1383 		    setEnemyAnimation(1, 8);
1384 			_actor[1].act[1].state = 39;
1385 		}
1386 
1387 		if (_actor[1].field_8 == 48)
1388 			_actor[1].tilt = 0;
1389 		else
1390 			_actor[1].tilt = -2;
1391 
1392 		_actor[1].x += _actor[1].cursorX / 32;
1393 		break;
1394 	case 0:
1395 		if (_actor[1].act[1].state != 1 || _actor[1].weaponClass != _actor[1].animWeaponClass) {
1396 			setEnemyAnimation(1, 9);
1397 			_actor[1].act[1].state = 1;
1398 		}
1399 		_actor[1].field_8 = 1;
1400 		if (_actor[1].cursorX < -100) {
1401 			setEnemyAnimation(1, 8);
1402 			_actor[1].act[1].state = 39;
1403 			_actor[1].field_8 = 46;
1404 			_actor[1].tilt = -1;
1405 		} else {
1406 			if (_actor[1].cursorX > 100) {
1407 				setEnemyAnimation(1, 10);
1408 				_actor[1].act[1].state = 55;
1409 				_actor[1].field_8 = 49;
1410 				_actor[1].tilt = 1;
1411 			}
1412 		}
1413 		break;
1414 	case 1:
1415 		if (_actor[1].act[1].state != 55 || _actor[1].weaponClass != _actor[1].animWeaponClass) {
1416 			setEnemyAnimation(1, 10);
1417 			_actor[1].act[1].state = 55;
1418 		}
1419 		if (_actor[1].field_8 == 51)
1420 			_actor[1].tilt = 0;
1421 		else
1422 			_actor[1].tilt = 2;
1423 
1424 		_actor[1].x += _actor[1].cursorX / 32;
1425 		break;
1426 	case 2:
1427 		if (_actor[1].act[1].state != 56 || _actor[1].weaponClass != _actor[1].animWeaponClass) {
1428 			setEnemyAnimation(1, 11);
1429 			_actor[1].act[1].state = 56;
1430 		}
1431 		if (_actor[1].field_8 == 51)
1432 			_actor[1].tilt = 1;
1433 		else
1434 			_actor[1].tilt = 3;
1435 
1436 		_actor[1].x += _actor[1].cursorX / 32;
1437 		break;
1438 	case 3:
1439 		if (_actor[1].act[1].state != 57 || _actor[1].weaponClass != _actor[1].animWeaponClass) {
1440 			setEnemyAnimation(1, 12);
1441 			_actor[1].act[1].state = 57;
1442 		}
1443 
1444 		if (_actor[1].cursorX <= 100) {
1445 			setEnemyAnimation(1, 11);
1446 			_actor[1].act[1].state = 56;
1447 			_actor[1].field_8 = 51;
1448 			_actor[1].tilt = 2;
1449 		}
1450 
1451 		_actor[1].x += _actor[1].cursorX / 32;
1452 		break;
1453 	}
1454 
1455 	tmpx = _actor[1].x;
1456 	tmpy = _actor[1].y + _actor[1].y1;
1457 
1458 	if (_actor[1].act[1].room)
1459 		smlayer_putActor(1, 1, tmpx, tmpy, _smlayer_room2);
1460 	else
1461 		smlayer_putActor(1, 1, tmpx, tmpy, _smlayer_room);
1462 
1463 	_actor[1].animWeaponClass = _actor[1].weaponClass;
1464 }
1465 
chooseEnemyWeaponAnim(int32 buttons)1466 void Insane::chooseEnemyWeaponAnim(int32 buttons) {
1467 	// kick
1468 	if ((buttons & 1) && (!_actor[0].lost)) {
1469 		if (!_kickEnemyProgress && actor0StateFlags2(_actor[1].act[2].state + _actor[1].weapon * 119)) {
1470 			switch (_actor[1].weapon) {
1471 			case INV_CHAIN:
1472 				_actor[1].act[2].state = 10;
1473 				break;
1474 			case INV_CHAINSAW:
1475 				_actor[1].act[2].state = 14;
1476 				break;
1477 			case INV_MACE:
1478 				_actor[1].act[2].state = 18;
1479 				break;
1480 			case INV_2X4:
1481 				_actor[1].act[2].state = 22;
1482 				break;
1483 			case INV_WRENCH:
1484 				_actor[1].act[2].state = 26;
1485 				break;
1486 			case INV_BOOT:
1487 				_actor[1].act[2].state = 93;
1488 				break;
1489 			case INV_HAND:
1490 				_actor[1].act[2].state = 2;
1491 				break;
1492 			case INV_DUST:
1493 				_actor[1].act[2].state = 89;
1494 				break;
1495 			default:
1496 				break;
1497 			}
1498 			_kickEnemyProgress = true;
1499 		}
1500 	} else {
1501 		_kickEnemyProgress = false;
1502 	}
1503 
1504 	// switch weapon
1505 	if ((buttons & 2) && (_currEnemy != EN_TORQUE)) {
1506 		if (_weaponEnemyJustSwitched || _actor[1].act[2].state == 35 ||
1507 			_actor[1].act[2].state == 34)
1508 			return;
1509 
1510 		switch (_actor[1].weapon) {
1511 		case INV_CHAIN:
1512 		case INV_CHAINSAW:
1513 		case INV_MACE:
1514 		case INV_2X4:
1515 		case INV_WRENCH:
1516 			_actor[1].act[2].state = 35;
1517 			smlayer_setActorFacing(1, 2, 24, 180);
1518 			break;
1519 		case INV_BOOT:
1520 		case INV_HAND:
1521 		case INV_DUST:
1522 			// fallthrough
1523 		default:
1524 			switchEnemyWeapon();
1525 		}
1526 
1527 		_weaponEnemyJustSwitched = true;
1528 	} else {
1529 		_weaponEnemyJustSwitched = false;
1530 	}
1531 }
1532 
switchEnemyWeapon()1533 void Insane::switchEnemyWeapon() {
1534 	do {
1535 		_actor[1].weapon++;
1536 		if (_actor[1].weapon > 7)
1537 			_actor[1].weapon = INV_CHAIN;
1538 	} while (!_actor[1].inventory[_actor[1].weapon]);
1539 
1540 	switch (_actor[1].weapon) {
1541 	case INV_CHAIN:
1542 	case INV_CHAINSAW:
1543 	case INV_MACE:
1544 	case INV_2X4:
1545 	case INV_WRENCH:
1546 		smlayer_setActorCostume(1, 2, readArray(_enemy[_currEnemy].costume4));
1547 		smlayer_setActorFacing(1, 2, 18, 180);
1548 		_actor[1].weaponClass = 1;
1549 		_actor[1].act[2].state = 34;
1550 		break;
1551 	case INV_BOOT:
1552 		_actor[1].weaponClass = 2;
1553 		_actor[1].act[2].state = 1;
1554 		break;
1555 	case INV_HAND:
1556 		smlayer_setActorCostume(1, 2, readArray(_enemy[_currEnemy].costume4));
1557 		_actor[1].weaponClass = 2;
1558 		_actor[1].act[2].state = 1;
1559 		break;
1560 	case INV_DUST:
1561 		setEnemyState();
1562 		break;
1563 	default:
1564 		break;
1565 	}
1566 }
1567 
setEnemyState()1568 void Insane::setEnemyState() {
1569 	if (_actor[1].lost)
1570 		return;
1571 
1572 	_actor[1].act[2].animTilt = -1000;
1573 
1574 	if (_currEnemy == EN_CAVEFISH) {
1575 		_actor[1].weaponClass = 2;
1576 		if (!_roadBumps)
1577 			_actor[1].act[2].state = 98;
1578 		else
1579 			_actor[1].act[2].state = 99;
1580 
1581 		return;
1582 	}
1583 
1584 	switch (_actor[1].weapon) {
1585 	case INV_CHAIN:
1586 		_actor[1].weaponClass = 1;
1587 		_actor[1].act[2].state = 63;
1588 		break;
1589 	case INV_CHAINSAW:
1590 		_actor[1].weaponClass = 1;
1591 		_actor[1].act[2].state = 64;
1592 		break;
1593 	case INV_MACE:
1594 		_actor[1].weaponClass = 1;
1595 		_actor[1].act[2].state = 65;
1596 		break;
1597 	case INV_2X4:
1598 		_actor[1].weaponClass = 1;
1599 		_actor[1].act[2].state = 66;
1600 		break;
1601 	case INV_WRENCH:
1602 		_actor[1].weaponClass = 1;
1603 		_actor[1].act[2].state = 62;
1604 		break;
1605 	case INV_BOOT:
1606 	case INV_HAND:
1607 	case INV_DUST:
1608 		_actor[1].weaponClass = 2;
1609 		_actor[1].act[2].state = 1;
1610 	}
1611 }
1612 
actor12Reaction(int32 buttons)1613 void Insane::actor12Reaction(int32 buttons) {
1614 	int32 tmp, tmp2;
1615 
1616 	switch (_actor[1].act[2].state) {
1617 	case 1:
1618 		smlayer_setActorLayer(1, 2, 5);
1619 		_actor[1].weaponClass = 2;
1620 		_actor[1].kicking = false;
1621 
1622 		switch (_actor[1].tilt) {
1623 		case -3:
1624 			if (_actor[1].act[2].animTilt != -3) {
1625 				smlayer_setActorFacing(1, 2, 6, 180);
1626 				_actor[1].act[2].animTilt = -3;
1627 			}
1628 			break;
1629 		case -2:
1630 			if (_actor[1].field_8 == 48)
1631 				smlayer_setActorFacing(1, 2, 7, 180);
1632 			_actor[1].act[2].animTilt = -2;
1633 			break;
1634 		case -1:
1635 			if (_actor[1].field_8 == 46)
1636 				smlayer_setActorFacing(1, 2, 8, 180);
1637 			_actor[1].act[2].animTilt = -1;
1638 			break;
1639 		case 0:
1640 			if (_actor[1].act[2].animTilt) {
1641 				smlayer_setActorFacing(1, 2, 9, 180);
1642 				_actor[1].act[2].animTilt = 0;
1643 			}
1644 			break;
1645 		case 1:
1646 			if (_actor[1].field_8 == 49)
1647 				smlayer_setActorFacing(1, 2, 10, 180);
1648 			_actor[1].act[2].animTilt = 1;
1649 			break;
1650 		case 2:
1651 			if (_actor[1].field_8 == 51)
1652 				smlayer_setActorFacing(1, 2, 11, 180);
1653 			_actor[1].act[2].animTilt = 2;
1654 			break;
1655 		case 3:
1656 			if (_actor[1].act[2].animTilt != 3) {
1657 				smlayer_setActorFacing(1, 2, 12, 180);
1658 				_actor[1].act[2].animTilt = 3;
1659 			}
1660 			break;
1661 		default:
1662 			break;
1663 		}
1664 		_actor[1].act[2].tilt = 0;
1665 		break;
1666 	case 2:
1667 		smlayer_setActorLayer(1, 2, 4);
1668 		smlayer_setActorFacing(1, 2, 17, 180);
1669 		_actor[1].kicking = true;
1670 		_actor[1].weaponClass = 1;
1671 		_actor[1].act[2].state = 3;
1672 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1673 		if (!((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS)))
1674 			smlayer_startSfx(63);
1675 		break;
1676 	case 3:
1677 		smlayer_setActorLayer(1, 2, 4);
1678 		_actor[1].weaponClass = 1;
1679 		if (_actor[1].act[2].frame >= 6) {
1680 			tmp = calcBenDamage(1, 1);
1681 			if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS)) {
1682 				if (tmp == 1)
1683 					smlayer_startSfx(50);
1684 			} else if (tmp == 1)
1685 				smlayer_startSfx(60);
1686 			else if (tmp == 1000)
1687 				smlayer_startSfx(62);
1688 			smlayer_setActorFacing(1, 2, 20, 180);
1689 			_actor[1].act[2].state = 4;
1690 		}
1691 		_actor[1].kicking = true;
1692 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1693 		break;
1694 	case 4:
1695 		smlayer_setActorLayer(1, 2, 5);
1696 		_actor[1].weaponClass = 1;
1697 		_actor[1].kicking = true;
1698 		if (_actor[1].act[2].frame >= 2) {
1699 			smlayer_setActorFacing(1, 2, 9, 180);
1700 			_actor[1].act[2].state = 1;
1701 			_actor[1].act[2].animTilt = -1000;
1702 			_actor[1].weaponClass = 2;
1703 			_actor[1].kicking = false;
1704 		}
1705 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1706 		break;
1707 	case 5:
1708 		smlayer_setActorLayer(1, 2, 5);
1709 		break;
1710 	case 10:
1711 		smlayer_setActorLayer(1, 2, 4);
1712 		_actor[1].weaponClass = 1;
1713 		_actor[1].kicking = true;
1714 		smlayer_setActorFacing(1, 2, 19, 180);
1715 		_actor[1].act[2].state = 11;
1716 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1717 		smlayer_startSfx(75);
1718 		break;
1719 	case 11:
1720 		smlayer_setActorLayer(1, 2, 4);
1721 		_actor[1].weaponClass = 1;
1722 		_actor[1].kicking = true;
1723 		if (_actor[1].act[2].frame >= 2) {
1724 			if (weaponEnemyIsEffective()) {
1725 				smlayer_setActorFacing(1, 2, 22, 180);
1726 				_actor[1].act[2].state = 79;
1727 			} else {
1728 				smlayer_setActorFacing(1, 2, 20, 180);
1729 				_actor[1].act[2].state = 12;
1730 			}
1731 		}
1732 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1733 		break;
1734 	case 12:
1735 		smlayer_setActorLayer(1, 2, 4);
1736 		_actor[1].weaponClass = 1;
1737 		_actor[1].kicking = true;
1738 		if (_actor[1].act[2].frame >= 1) {
1739 			switch (_actor[0].weapon) {
1740 			case INV_CHAIN:
1741 			case INV_CHAINSAW:
1742 			case INV_MACE:
1743 			case INV_2X4:
1744 			case INV_DUST:
1745 			case INV_WRENCH:
1746 			case INV_BOOT:
1747 				tmp = calcBenDamage(1, 1);
1748 				if (tmp == 1)
1749 					smlayer_startSfx(73);
1750 				if (tmp == 1000)
1751 					smlayer_startSfx(74);
1752 				break;
1753 			case INV_HAND:
1754 				if (calcBenDamage(1, 0))
1755 					smlayer_startSfx(73);
1756 				break;
1757 			}
1758 			smlayer_setActorFacing(1, 2, 21, 180);
1759 			_actor[1].act[2].state = 13;
1760 		}
1761 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1762 		break;
1763 	case 13:
1764 		smlayer_setActorLayer(1, 2, 5);
1765 		_actor[1].weaponClass = 1;
1766 		_actor[1].kicking = false;
1767 		if (_actor[1].act[2].frame >= 3) {
1768 			smlayer_setActorFacing(1, 2, 25, 180);
1769 			_actor[1].act[2].state = 63;
1770 		}
1771 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1772 		break;
1773 	case 14:
1774 		smlayer_setActorLayer(1, 2, 8);
1775 		_actor[1].weaponClass = 1;
1776 		_actor[1].kicking = true;
1777 		smlayer_setActorFacing(1, 2, 19, 180);
1778 		_actor[1].act[2].state = 15;
1779 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1780 		smlayer_startSfx(78);
1781 		break;
1782 	case 15:
1783 		smlayer_setActorLayer(1, 2, 8);
1784 		_actor[1].weaponClass = 1;
1785 		_actor[1].kicking = true;
1786 		if (_actor[1].act[2].frame >= 5) {
1787 			switch (_actor[0].weapon) {
1788 			case INV_CHAIN:
1789 			case INV_CHAINSAW:
1790 			case INV_MACE:
1791 			case INV_2X4:
1792 			case INV_WRENCH:
1793 				if (weaponEnemyIsEffective()) {
1794 					smlayer_setActorFacing(1, 2, 22, 180);
1795 					_actor[1].act[2].state = 81;
1796 				} else {
1797 					smlayer_setActorFacing(1, 2, 20, 180);
1798 					_actor[1].act[2].state = 16;
1799 				}
1800 				break;
1801 			default:
1802 				smlayer_setActorFacing(1, 2, 20, 180);
1803 				_actor[1].act[2].state = 16;
1804 				break;
1805 			}
1806 		}
1807 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1808 		break;
1809 	case 16:
1810 		smlayer_setActorLayer(1, 2, 8);
1811 		_actor[1].weaponClass = 1;
1812 		_actor[1].kicking = true;
1813 		if (_actor[1].act[2].frame >= 3) {
1814 			switch (_actor[0].weapon) {
1815 			case INV_CHAIN:
1816 			case INV_CHAINSAW:
1817 			case INV_MACE:
1818 			case INV_2X4:
1819 			case INV_WRENCH:
1820 				tmp = calcBenDamage(1, 1);
1821 				if (tmp == 1)
1822 					smlayer_startSfx(76);
1823 				if (tmp == 1000)
1824 					smlayer_startSfx(77);
1825 				break;
1826 			default:
1827 				calcBenDamage(1, 0);
1828 				break;
1829 			}
1830 			smlayer_setActorFacing(1, 2, 21,180);
1831 			_actor[1].act[2].state = 17;
1832 		}
1833 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1834 		break;
1835 	case 17:
1836 		smlayer_setActorLayer(1, 2, 5);
1837 		_actor[1].weaponClass = 1;
1838 		_actor[1].kicking = false;
1839 		if (_actor[1].act[2].frame >= 1) {
1840 			smlayer_setActorFacing(1, 2, 26, 180);
1841 			_actor[1].act[2].state = 64;
1842 			smlayer_stopSound(76);
1843 		}
1844 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1845 		break;
1846 	case 18:
1847 		smlayer_setActorLayer(1, 2, 4);
1848 		_actor[1].weaponClass = 1;
1849 		_actor[1].kicking = true;
1850 		smlayer_setActorFacing(1, 2, 19, 180);
1851 		_actor[1].act[2].state = 19;
1852 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1853 		if (!((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))) {
1854 			smlayer_startSfx(69);
1855 			 if (!_actor[1].field_54) {
1856 				tmp = _vm->_rnd.getRandomNumber(4);
1857 				if (tmp == 1)
1858 					smlayer_startSfx(213);
1859 				else if (tmp == 3)
1860 					smlayer_startSfx(215);
1861 			}
1862 		} else {
1863 			smlayer_startSfx(53);
1864 		}
1865 		break;
1866 	case 19:
1867 		smlayer_setActorLayer(1, 2, 4);
1868 		_actor[1].weaponClass = 1;
1869 		if (_actor[1].act[2].frame >= 3) {
1870 			switch (_actor[0].weapon) {
1871 			case INV_CHAIN:
1872 				if (_actor[0].kicking) {
1873 					_actor[0].act[2].state = 108;
1874 					_actor[1].act[2].state = 110;
1875 				} else {
1876 					smlayer_setActorFacing(1, 2, 20, 180);
1877 					_actor[1].act[2].state = 20;
1878 				}
1879 				break;
1880 			case INV_CHAINSAW:
1881 				if (_actor[0].kicking || _actor[0].field_44)
1882 					_actor[1].act[2].state = 106;
1883 				else {
1884 					smlayer_setActorFacing(1, 2, 20, 180);
1885 					_actor[1].act[2].state = 20;
1886 				}
1887 				break;
1888 			case INV_BOOT:
1889 			case INV_DUST:
1890 				smlayer_setActorFacing(1, 2, 20, 180);
1891 				_actor[1].act[2].state = 20;
1892 				break;
1893 			default:
1894 				if (weaponEnemyIsEffective()) {
1895 					smlayer_setActorFacing(1, 2, 22, 180);
1896 					_actor[1].act[2].state = 77;
1897 				} else {
1898 					smlayer_setActorFacing(1, 2, 20, 180);
1899 					_actor[1].act[2].state = 20;
1900 				}
1901 				break;
1902 			}
1903 		}
1904 		_actor[1].kicking = true;
1905 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1906 		break;
1907 	case 20:
1908 		smlayer_setActorLayer(1, 2, 4);
1909 		_actor[1].weaponClass = 1;
1910 		_actor[1].kicking = true;
1911 		if (_actor[1].act[2].frame >= 1) {
1912 			switch (_actor[1].weapon) {
1913 			case INV_CHAINSAW:
1914 			case INV_MACE:
1915 			case INV_2X4:
1916 			case INV_BOOT:
1917 				tmp = calcBenDamage(1, 1);
1918 				if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS)) {
1919 					if (tmp == 1)
1920 						smlayer_startSfx(52);
1921 					else if (tmp == 1000)
1922 						smlayer_startSfx(56);
1923 				} else {
1924 					if (tmp == 1)
1925 						smlayer_startSfx(67);
1926 					else if (tmp == 1000)
1927 						smlayer_startSfx(68);
1928 				}
1929 				break;
1930 			default:
1931 				calcBenDamage(1, 0);
1932 				break;
1933 			}
1934 			smlayer_setActorFacing(1, 2, 21, 180);
1935 			_actor[1].act[2].state = 21;
1936 		}
1937 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1938 		break;
1939 	case 21:
1940 		smlayer_setActorLayer(1, 2, 5);
1941 		_actor[1].weaponClass = 1;
1942 		_actor[1].kicking = false;
1943 		if (_actor[1].act[2].frame >= 5) {
1944 			smlayer_setActorFacing(1, 2, 25, 180);
1945 			smlayer_setActorLayer(1, 2, 5);
1946 			_actor[1].act[2].state = 65;
1947 		}
1948 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1949 		break;
1950 	case 22:
1951 		smlayer_setActorLayer(1, 2, 4);
1952 		_actor[1].weaponClass = 0;
1953 		_actor[1].kicking = true;
1954 		smlayer_setActorFacing(1, 2, 19, 180);
1955 		_actor[1].act[2].state = 23;
1956 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1957 		smlayer_startSfx(81);
1958 		break;
1959 	case 23:
1960 		smlayer_setActorLayer(1, 2, 4);
1961 		_actor[1].weaponClass = 0;
1962 		_actor[1].kicking = true;
1963 		if (_actor[1].act[2].frame >= 3) {
1964 			if (weaponEnemyIsEffective()) {
1965 				smlayer_setActorFacing(1, 2, 22, 180);
1966 				_actor[1].act[2].state = 83;
1967 			} else {
1968 				smlayer_setActorFacing(1, 2, 20, 180);
1969 				_actor[1].act[2].state = 24;
1970 
1971 				if (!_actor[1].field_54)
1972 					smlayer_startSfx(246);
1973 			}
1974 		}
1975 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1976 		break;
1977 	case 24:
1978 		smlayer_setActorLayer(1, 2, 4);
1979 		_actor[1].weaponClass = 0;
1980 		_actor[1].kicking = true;
1981 		if (_actor[1].act[2].frame >= 1) {
1982 			tmp = calcBenDamage(1, 1);
1983 
1984 			if (tmp == 1)
1985 				smlayer_startSfx(79);
1986 
1987 			if (tmp == 1000)
1988 				smlayer_startSfx(80);
1989 
1990 			smlayer_setActorFacing(1, 2, 21, 180);
1991 			_actor[1].act[2].state = 25;
1992 		}
1993 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
1994 		break;
1995 	case 25:
1996 		smlayer_setActorLayer(1, 2, 5);
1997 		_actor[1].weaponClass = 0;
1998 		_actor[1].kicking = false;
1999 		if (_actor[1].act[2].frame >= 3) {
2000 			smlayer_setActorFacing(1, 2, 25, 180);
2001 			_actor[1].act[2].state = 66;
2002 			_actor[1].weaponClass = 1;
2003 		}
2004 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2005 		break;
2006 	case 26:
2007 		smlayer_setActorLayer(1, 2, 4);
2008 		_actor[1].weaponClass = 1;
2009 		_actor[1].kicking = true;
2010 		smlayer_setActorFacing(1, 2, 19, 180);
2011 		_actor[1].act[2].state = 27;
2012 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2013 		smlayer_startSfx(72);
2014 		break;
2015 	case 27:
2016 		smlayer_setActorLayer(1, 2, 4);
2017 		_actor[1].weaponClass = 1;
2018 		_actor[1].kicking = true;
2019 		if (_actor[1].act[2].frame >= 1) {
2020 			if (weaponEnemyIsEffective()) {
2021 				smlayer_setActorFacing(1, 2, 22, 180);
2022 				_actor[1].act[2].state = 75;
2023 			} else {
2024 				smlayer_setActorFacing(1, 2, 20, 180);
2025 				_actor[1].act[2].state = 28;
2026 			}
2027 		}
2028 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2029 		break;
2030 	case 28:
2031 		smlayer_setActorLayer(1, 2, 4);
2032 		_actor[1].weaponClass = 1;
2033 		_actor[1].kicking = true;
2034 		if (_actor[1].act[2].frame >= 3) {
2035 			tmp = calcBenDamage(1, 1);
2036 			if ((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS)) {
2037 				if (tmp == 1)
2038 					smlayer_startSfx(57);
2039 			} else if (tmp == 1)
2040 				smlayer_startSfx(70);
2041 			else if (tmp == 1000)
2042 				smlayer_startSfx(71);
2043 
2044 			smlayer_setActorFacing(1, 2, 21, 180);
2045 			_actor[1].act[2].state = 29;
2046 		}
2047 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2048 		break;
2049 	case 29:
2050 		smlayer_setActorLayer(1, 2, 5);
2051 		_actor[1].weaponClass = 1;
2052 		_actor[1].kicking = false;
2053 		if (_actor[1].act[2].frame >= 6) {
2054 			smlayer_setActorFacing(1, 2, 25, 180);
2055 			_actor[1].act[2].state = 62;
2056 			_actor[1].kicking = false;
2057 		}
2058 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2059 		break;
2060 	case 34:
2061 		smlayer_setActorLayer(1, 2, 5);
2062 		_actor[1].kicking = false;
2063 
2064 		if (!smlayer_actorNeedRedraw(1, 2)) {
2065 			setEnemyState();
2066 			_actor[1].act[2].tilt = 0;
2067 			// for some reason there is no break at this
2068 			// place, so tilt gets overridden on next line
2069 		}
2070 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2071 		break;
2072 	case 35:
2073 		smlayer_setActorLayer(1, 2, 5);
2074 		_actor[1].kicking = false;
2075 
2076 		if (!smlayer_actorNeedRedraw(1, 2))
2077 			switchEnemyWeapon();
2078 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2079 		break;
2080 	case 36:
2081 		_actor[1].lost = true;
2082 		_actor[1].field_54 = 1;
2083 		_actor[1].cursorX = 0;
2084 		_actor[1].kicking = false;
2085 		smlayer_setActorCostume(1, 2, readArray(_enemy[_currEnemy].costumevar));
2086 		smlayer_setActorFacing(1, 2, 6, 180);
2087 		smlayer_setActorLayer(1, 2, 25);
2088 		_actor[1].act[2].state = 37;
2089 
2090 		if (!((_vm->_game.features & GF_DEMO) && (_vm->_game.platform == Common::kPlatformDOS))) {
2091 			smlayer_startSfx(96);
2092 			switch (_currEnemy) {
2093 			case EN_ROTT1:
2094 				smlayer_startVoice(212);
2095 				break;
2096 			case EN_ROTT2:
2097 				smlayer_startVoice(259);
2098 				break;
2099 			case EN_ROTT3:
2100 				smlayer_startVoice(232);
2101 				break;
2102 			case EN_VULTF1:
2103 				smlayer_startVoice(281);
2104 				break;
2105 			case EN_VULTF2:
2106 				smlayer_startVoice(276);
2107 				break;
2108 			}
2109 		}
2110 		break;
2111 	case 37:
2112 		_actor[1].cursorX = 0;
2113 		_actor[1].kicking = false;
2114 
2115 		if (_actor[1].act[2].frame < _enemy[_currEnemy].maxframe) {
2116 			if (_actor[1].x >= 50 && _actor[1].x <= 270)
2117 				break;
2118 
2119 			if (_actor[1].act[2].frame < _enemy[_currEnemy].maxframe / 2)
2120 				break;
2121 		}
2122 		if (_currSceneId == 21) {
2123 			queueSceneSwitch(22, 0, "rottflip.san", 64, 0, 0, 0);
2124 			_actor[1].act[2].state = 38;
2125 		} else {
2126 			queueSceneSwitch(11, 0, _enemy[_currEnemy].filename, 64, 0, 0, 0);
2127 			_actor[1].act[2].state = 38;
2128 		}
2129 		break;
2130 	case 38:
2131 		smlayer_setActorLayer(1, 2, 25);
2132 		_actor[1].kicking = false;
2133 
2134 		if (_actor[1].act[2].frame < _enemy[_currEnemy].maxframe + 20)
2135 			break;
2136 
2137 		_actor[1].act[2].frame = 0;
2138 
2139 		if (_currSceneId == 21) {
2140 			queueSceneSwitch(22, 0, "rottflip.san", 64, 0, 0, 0);
2141 			_actor[1].act[2].state = 38;
2142 		} else {
2143 			queueSceneSwitch(11, 0, _enemy[_currEnemy].filename, 64, 0, 0, 0);
2144 			_actor[1].act[2].state = 38;
2145 		}
2146 		break;
2147 	case 63:
2148 		smlayer_setActorLayer(1, 2, 5);
2149 		if (_actor[1].act[2].animTilt) {
2150 			smlayer_setActorFacing(1, 2, 25, 180);
2151 			_actor[1].act[2].animTilt = 0;
2152 		}
2153 		_actor[1].weaponClass = 1;
2154 		_actor[1].kicking = false;
2155 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2156 		break;
2157 	case 64:
2158 		smlayer_setActorLayer(1, 2, 5);
2159 		if (_actor[1].act[2].animTilt) {
2160 			smlayer_setActorFacing(1, 2, 26, 180);
2161 			_actor[1].act[2].animTilt = 0;
2162 		}
2163 		_actor[1].weaponClass = 1;
2164 		_actor[1].kicking = false;
2165 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2166 		break;
2167 	case 62:
2168 	case 65:
2169 	case 66:
2170 		smlayer_setActorLayer(1, 2, 5);
2171 		if (_actor[1].act[2].animTilt) {
2172 			smlayer_setActorFacing(1, 2, 25, 180);
2173 			_actor[1].act[2].animTilt = 0;
2174 		}
2175 		_actor[1].weaponClass = 1;
2176 		_actor[1].kicking = false;
2177 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2178 		break;
2179 	case 73:
2180 		smlayer_setActorLayer(1, 2, 6);
2181 		_actor[1].weaponClass = 1;
2182 		_actor[1].kicking = false;
2183 		_actor[1].field_44 = true;
2184 		if (_actor[1].act[2].frame >= 2 && !_kickEnemyProgress) {
2185 			smlayer_setActorFacing(1, 2, 19, 180);
2186 			_actor[1].act[2].state = 74;
2187 		}
2188 
2189 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2190 		break;
2191 	case 74:
2192 		smlayer_setActorLayer(1, 2, 6);
2193 		_actor[1].weaponClass = 1;
2194 		_actor[1].kicking = false;
2195 		_actor[1].field_44 = false;
2196 		if (_actor[1].act[2].frame >= 2) {
2197 			smlayer_setActorFacing(1, 2, 9, 180);
2198 			_actor[1].act[2].state = 1;
2199 			_actor[1].weaponClass = 2;
2200 		}
2201 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2202 		break;
2203 	case 75:
2204 		smlayer_setActorLayer(1, 2, 6);
2205 		_actor[1].weaponClass = 1;
2206 		_actor[1].kicking = false;
2207 		_actor[1].field_44 = true;
2208 		if (_actor[1].act[2].frame >= 4 && !_kickEnemyProgress) {
2209 			smlayer_setActorFacing(1, 2, 23, 180);
2210 			_actor[1].act[2].state = 76;
2211 		}
2212 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2213 		break;
2214 	case 76:
2215 		smlayer_setActorLayer(1, 2, 6);
2216 		_actor[1].weaponClass = 1;
2217 		_actor[1].kicking = false;
2218 		_actor[1].field_44 = false;
2219 		if (_actor[1].act[2].frame >= 4) {
2220 			smlayer_setActorFacing(1, 2, 25, 180);
2221 			_actor[1].act[2].state = 62;
2222 		}
2223 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2224 		break;
2225 	case 77:
2226 		smlayer_setActorLayer(1, 2, 6);
2227 		_actor[1].weaponClass = 1;
2228 		_actor[1].kicking = false;
2229 		_actor[1].field_44 = true;
2230 		if (_actor[1].act[2].frame >= 1 && !_kickEnemyProgress) {
2231 			smlayer_setActorFacing(1, 2, 23, 180);
2232 			_actor[1].act[2].state = 78;
2233 		}
2234 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2235 		break;
2236 	case 78:
2237 		smlayer_setActorLayer(1, 2, 6);
2238 		_actor[1].weaponClass = 1;
2239 		_actor[1].kicking = false;
2240 		_actor[1].field_44 = false;
2241 		if (_actor[1].act[2].frame >= 5) {
2242 			smlayer_setActorFacing(1, 2, 25, 180);
2243 			_actor[1].act[2].state = 65;
2244 		}
2245 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2246 		break;
2247 	case 79:
2248 		smlayer_setActorLayer(1, 2, 6);
2249 		_actor[1].weaponClass = 1;
2250 		_actor[1].kicking = false;
2251 		_actor[1].field_44 = true;
2252 		if (_actor[1].act[2].frame >= 1 && !_kickEnemyProgress) {
2253 			smlayer_setActorFacing(1, 2, 23, 180);
2254 			_actor[1].act[2].state = 80;
2255 		}
2256 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2257 		break;
2258 	case 80:
2259 		smlayer_setActorLayer(1, 2, 6);
2260 		_actor[1].weaponClass = 1;
2261 		_actor[1].kicking = false;
2262 		_actor[1].field_44 = false;
2263 		if (_actor[1].act[2].frame >= 6) {
2264 			smlayer_setActorFacing(1, 2, 25, 180);
2265 			_actor[1].act[2].state = 63;
2266 		}
2267 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2268 		break;
2269 	case 81:
2270 		smlayer_setActorLayer(1, 2, 6);
2271 		_actor[1].weaponClass = 1;
2272 		_actor[1].kicking = false;
2273 		_actor[1].field_44 = true;
2274 		if (_actor[1].act[2].frame >= 2 && !_kickEnemyProgress) {
2275 			smlayer_setActorFacing(1, 2, 23, 180);
2276 			_actor[1].act[2].state = 82;
2277 		}
2278 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2279 		break;
2280 	case 82:
2281 		smlayer_setActorLayer(1, 2, 6);
2282 		_actor[1].weaponClass = 1;
2283 		_actor[1].kicking = false;
2284 		_actor[1].field_44 = false;
2285 		if (_actor[1].act[2].frame >= 3) {
2286 			smlayer_setActorFacing(1, 2, 26, 180);
2287 			_actor[1].act[2].state = 64;
2288 		}
2289 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2290 		break;
2291 	case 83:
2292 		smlayer_setActorLayer(1, 2, 6);
2293 		_actor[1].weaponClass = 0;
2294 		_actor[1].kicking = false;
2295 		_actor[1].field_44 = true;
2296 		if (_actor[1].act[2].frame >= 2 && !_kickEnemyProgress) {
2297 			smlayer_setActorFacing(1, 2, 23, 180);
2298 			_actor[1].act[2].state = 84;
2299 		}
2300 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2301 		break;
2302 	case 84:
2303 		smlayer_setActorLayer(1, 2, 6);
2304 		_actor[1].weaponClass = 0;
2305 		_actor[1].kicking = false;
2306 		_actor[1].field_44 = false;
2307 		if (_actor[1].act[2].frame >= 5) {
2308 			smlayer_setActorFacing(1, 2, 25, 180);
2309 			_actor[1].act[2].state = 66;
2310 		}
2311 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2312 		break;
2313 	case 89:
2314 		smlayer_setActorLayer(1, 2, 26);
2315 		_actor[1].weaponClass = 1;
2316 		_actor[1].kicking = false;
2317 		if (_roadBumps)
2318 			smlayer_setActorFacing(1, 2, 13, 180);
2319 		else
2320 			smlayer_setActorFacing(1, 2, 12, 180);
2321 
2322 		smlayer_startSfx(100);
2323 		_actor[1].act[2].state = 90;
2324 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2325 		smlayer_setActorLayer(1, 2, 26);
2326 		break;
2327 	case 90:
2328 		smlayer_setActorLayer(1, 2, 26);
2329 		_actor[1].weaponClass = 2;
2330 		_actor[1].kicking = false;
2331 		if (_actor[1].act[2].frame >= 5)
2332 			if (_actor[1].x - _actor[0].x <= 125)
2333 				_actor[0].damage += 90;
2334 
2335 		if (_actor[1].act[2].frame >= 12) {
2336 			_actor[1].kicking = false;
2337 			setEnemyState();
2338 			smlayer_setActorLayer(1, 2, 5);
2339 		}
2340 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2341 		break;
2342 	case 91:
2343 		smlayer_setActorLayer(1, 2, 26);
2344 		_actor[1].kicking = false;
2345 		break;
2346 	case 92:
2347 	case 96:
2348 		smlayer_setActorLayer(1, 2, 5);
2349 		_actor[1].kicking = false;
2350 		break;
2351 	case 93:
2352 		smlayer_setActorLayer(1, 2, 4);
2353 		_actor[1].weaponClass = 1;
2354 		_actor[1].kicking = false;
2355 		smlayer_setActorFacing(1, 2, 18, 180);
2356 		_actor[1].act[2].state = 94;
2357 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2358 		smlayer_startSfx(102);
2359 		break;
2360 	case 94:
2361 		smlayer_setActorLayer(1, 2, 4);
2362 		_actor[1].weaponClass = 1;
2363 		_actor[1].kicking = false;
2364 		if (_actor[1].act[2].frame >= 15) {
2365 			smlayer_setActorCostume(1, 2, readArray(44));
2366 			smlayer_setActorFacing(1, 2, 6, 180);
2367 			_actor[1].act[2].state = 95;
2368 			_actor[1].act[0].room = 0;
2369 			_actor[1].act[1].room = 0;
2370 		}
2371 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2372 		break;
2373 	case 95:
2374 		smlayer_setActorLayer(1, 2, 4);
2375 		_actor[1].kicking = false;
2376 		if (_actor[1].act[2].frame >= 19) {
2377 			queueSceneSwitch(1, _smush_minedrivFlu, "minedriv.san", 64, 0,
2378 							 _continueFrame1, 1300);
2379 			_actor[1].act[2].state = 96;
2380 		}
2381 		break;
2382 	case 97:
2383 		smlayer_setActorLayer(1, 2, 25);
2384 		_actor[1].lost = true;
2385 		if (_actor[1].act[2].frame >= 18) {
2386 			writeArray(7, 1);
2387 			_enemy[EN_VULTM2].isEmpty = 1;
2388 			queueSceneSwitch(12, 0, "getnitro.san", 0, 0, 0, 0);
2389 		}
2390 		break;
2391 	case 98:
2392 		smlayer_setActorLayer(1, 2, 5);
2393 		if (_actor[1].act[2].animTilt) {
2394 			smlayer_setActorFacing(1, 2, 6, 180);
2395 			_actor[1].act[2].animTilt = 0;
2396 		}
2397 		if (_roadBumps) {
2398 			smlayer_setActorFacing(1, 2, 7, 180);
2399 			_actor[1].act[2].state = 100;
2400 		}
2401 		_actor[1].kicking = false;
2402 		break;
2403 	case 99:
2404 		smlayer_setActorLayer(1, 2, 5);
2405 		if (_actor[1].act[2].animTilt) {
2406 			smlayer_setActorFacing(1, 2, 9, 180);
2407 			_actor[1].act[2].animTilt = 0;
2408 		}
2409 		if (!_roadBumps) {
2410 			smlayer_setActorFacing(1, 2, 8, 180);
2411 			_actor[1].act[2].state = 101;
2412 		}
2413 		_actor[1].kicking = false;
2414 		break;
2415 	case 100:
2416 		smlayer_setActorLayer(1, 2, 5);
2417 		if (_actor[1].act[2].frame >= 4) {
2418 			smlayer_setActorFacing(1, 2, 9, 180);
2419 			_actor[1].act[2].state = 99;
2420 		}
2421 		_actor[1].kicking = false;
2422 		break;
2423 	case 101:
2424 		smlayer_setActorLayer(1, 2, 5);
2425 		if (_actor[1].act[2].frame >= 4) {
2426 			smlayer_setActorFacing(1, 2, 6, 180);
2427 			_actor[1].act[2].state = 98;
2428 		}
2429 		_actor[1].kicking = false;
2430 		break;
2431 	case 102:
2432 		_actor[1].lost = true;
2433 		_actor[1].cursorX = 0;
2434 		_actor[1].kicking = false;
2435 		smlayer_setActorCostume(1, 2, readArray(40));
2436 		smlayer_setActorFacing(1, 2, 6, 180);
2437 		smlayer_setActorLayer(1, 2, 25);
2438 		_actor[1].act[2].state = 103;
2439 		break;
2440 	case 103:
2441 		_actor[1].kicking = false;
2442 
2443 		if (_actor[1].act[2].frame >= 18 || ((_actor[1].x < 50 || _actor[1].x > 270) &&
2444 											 _actor[1].act[2].frame >= 9)) {
2445 			_enemy[EN_CAVEFISH].isEmpty = 1;
2446 			queueSceneSwitch(20, 0, "wr2_cvko.san", 64, 0, 0, 0);
2447 			_actor[1].act[2].state = 38;
2448 		}
2449 		break;
2450 	case 106:
2451 		smlayer_setActorLayer(1, 2, 5);
2452 		_actor[1].weaponClass = 1;
2453 		_actor[1].kicking = false;
2454 		smlayer_setActorFacing(1, 2, 29, 180);
2455 		_actor[1].act[2].state = 107;
2456 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2457 		break;
2458 	case 107:
2459 		smlayer_setActorLayer(1, 2, 5);
2460 		_actor[1].weaponClass = 1;
2461 		_actor[1].kicking = false;
2462 		if (_actor[1].act[2].frame >= 8)
2463 			_actor[1].damage = _actor[1].maxdamage + 10;
2464 
2465 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2466 		break;
2467 	case 108:
2468 		smlayer_setActorLayer(1, 2, 5);
2469 		_actor[1].weaponClass = 1;
2470 		_actor[1].kicking = false;
2471 		smlayer_setActorFacing(1, 2, 28, 180);
2472 		_actor[1].act[2].state = 109;
2473 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2474 		break;
2475 	case 109:
2476 		smlayer_setActorLayer(1, 2, 5);
2477 		_actor[1].weaponClass = 1;
2478 		_actor[1].kicking = false;
2479 		if (_actor[1].act[2].frame >= 6)
2480 			_actor[1].damage = _actor[1].maxdamage + 10;
2481 
2482 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2483 		break;
2484 	case 110:
2485 		smlayer_setActorLayer(1, 2, 4);
2486 		_actor[1].weaponClass = 1;
2487 		_actor[1].kicking = false;
2488 		smlayer_setActorFacing(1, 2, 30, 180);
2489 		_actor[1].act[2].state = 111;
2490 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2491 		break;
2492 	case 111:
2493 		smlayer_setActorLayer(1, 2, 4);
2494 		_actor[1].weaponClass = 1;
2495 		_actor[1].kicking = false;
2496 		if (_actor[1].act[2].frame >= 7) {
2497 			smlayer_setActorFacing(1, 2, 25, 180);
2498 			_actor[1].act[2].state = 65;
2499 			smlayer_setActorLayer(1, 2, 5);
2500 		}
2501 		_actor[1].act[2].tilt = calcTilt(_actor[1].tilt);
2502 		break;
2503 	case 113:
2504 		_actor[1].lost = true;
2505 		_actor[1].kicking = false;
2506 		smlayer_setActorCostume(1, 2, readArray(46));
2507 		smlayer_setActorFacing(1, 2, 6, 180);
2508 		smlayer_setActorLayer(1, 2, 25);
2509 		_actor[1].act[1].room = 0;
2510 		_actor[1].act[0].room = 0;
2511 		_actor[1].cursorX = 0;
2512 		_actor[1].act[2].state = 114;
2513 		_enemy[EN_VULTF2].isEmpty = 1;
2514 		smlayer_startVoice(275);
2515 		break;
2516 	case 114:
2517 		smlayer_setActorLayer(1, 2, 25);
2518 		_actor[1].kicking = false;
2519 
2520 		if (_actor[1].act[2].frame >= 16 || ((_actor[1].x < 50 || _actor[1].x > 270)
2521 											 && (_actor[1].act[2].frame >= 8))) {
2522 			queueSceneSwitch(11, 0, _enemy[_currEnemy].filename, 64, 0, 0, 0);
2523 			_actor[1].act[2].state = 38;
2524 		}
2525 		break;
2526 	case 115:
2527 		_actor[1].lost = true;
2528 		_actor[1].kicking = false;
2529 		smlayer_setActorCostume(1, 2, readArray(47));
2530 		smlayer_setActorFacing(1, 2, 6, 180);
2531 		smlayer_setActorLayer(1, 2, 25);
2532 		_actor[1].act[1].room = 0;
2533 		_actor[1].act[0].room = 0;
2534 		_actor[1].cursorX = 0;
2535 		_actor[1].act[2].state = 116;
2536 		break;
2537 	case 116:
2538 		smlayer_setActorLayer(1, 2, 25);
2539 		_actor[1].kicking = false;
2540 
2541 		if (_actor[1].act[2].frame >= 17 || ((_actor[1].x < 50 || _actor[1].x > 270)
2542 											 && _actor[1].act[2].frame >= 8)) {
2543 			queueSceneSwitch(11, 0, _enemy[_currEnemy].filename, 64, 0, 0, 0);
2544 			_actor[1].act[2].state = 38;
2545 		}
2546 		break;
2547 	default:
2548 		break;
2549 	}
2550 	tmp = _actor[1].x + _actor[1].act[2].tilt - 17;
2551 	tmp2 = _actor[1].y + _actor[1].y1 - 98;
2552 
2553 	if (_actor[1].act[2].room)
2554 		smlayer_putActor(1, 2, tmp, tmp2, _smlayer_room2);
2555 	else
2556 		smlayer_putActor(1, 2, tmp, tmp2, _smlayer_room);
2557 }
2558 
calcEnemyDamage(bool arg_0,bool arg_4)2559 int32 Insane::calcEnemyDamage(bool arg_0, bool arg_4) {
2560 	if ((_actor[1].x - _actor[0].x > weaponMaxRange(0)) ||
2561 		(_actor[1].x - _actor[0].x < weaponMinRange(0)))
2562 		return 0;
2563 
2564 	if (_actor[1].field_44 && arg_4)
2565 		return 1000;
2566 
2567 	if (!actor1StateFlags(_actor[1].act[2].state))
2568 		return 0;
2569 
2570 	if (arg_0) {
2571 		ouchSoundEnemy();
2572 		_actor[1].damage += weaponDamage(0);
2573 	}
2574 
2575 	return 1;
2576 }
2577 
weaponEnemyIsEffective()2578 bool Insane::weaponEnemyIsEffective() {
2579 	if ((_actor[1].x - _actor[0].x > weaponMaxRange(1)) ||
2580 		(_actor[1].x - _actor[0].x < weaponMinRange(1)) ||
2581 		!_actor[0].kicking)
2582 		return false;
2583 
2584 	return true;
2585 }
2586 
actor13Reaction(int32 buttons)2587 void Insane::actor13Reaction(int32 buttons) {
2588 	int32 tmp;
2589 
2590 	switch (_actor[1].act[3].state) {
2591 	case 1:
2592 	case 54:
2593 		_actor[1].field_54 = 0;
2594 		break;
2595 	case 52:
2596 		if (_actor[1].runningSound)
2597 			smlayer_stopSound(_actor[1].runningSound);
2598 
2599 		if (_currScenePropIdx)
2600 			shutCurrentScene();
2601 
2602 		_actor[1].runningSound = 0;
2603 		_actor[1].defunct = 0;
2604 		_actor[1].field_54 = 0;
2605 		smlayer_setActorFacing(1, 3, 15, 180);
2606 		_actor[1].act[3].state = 53;
2607 		break;
2608 	case 53:
2609 		_actor[1].field_54 = 0;
2610 		if (_actor[1].act[3].frame >= 2) {
2611 			smlayer_setActorFacing(1, 3, 16, 180);
2612 			_actor[1].act[3].state = 54;
2613 		}
2614 		break;
2615 	case 69:
2616 		if (_actor[1].act[3].frame >= 2)
2617 			_actor[1].act[3].state = 70;
2618 		break;
2619 	case 70:
2620 		if (_actor[1].scenePropSubIdx) {
2621 			smlayer_setActorFacing(1, 3, 4, 180);
2622 			tmp = _currScenePropIdx + _actor[1].scenePropSubIdx;
2623 			if (!smlayer_startVoice(_sceneProp[tmp].sound))
2624 				_actor[1].runningSound = 0;
2625 			else
2626 				_actor[1].runningSound = _sceneProp[tmp].sound;
2627 			_actor[1].act[3].state = 72;
2628 		} else {
2629 			_actor[1].act[3].state = 118;
2630 		}
2631 		break;
2632 	case 71:
2633 		_actor[1].field_54 = 0;
2634 		if (_actor[1].act[3].frame >= 2)
2635 			_actor[1].act[3].state = 1;
2636 		break;
2637 	case 72:
2638 		if (_actor[1].runningSound) {
2639 			if (!smlayer_isSoundRunning(_actor[1].runningSound)) {
2640 				smlayer_setActorFacing(1, 3, 5, 180);
2641 				_actor[1].act[3].state = 70;
2642 				_actor[1].scenePropSubIdx = 0;
2643 			}
2644 		} else {
2645 			tmp = _currScenePropIdx + _actor[1].scenePropSubIdx;
2646 			if (_sceneProp[tmp].counter >= _sceneProp[tmp].maxCounter) {
2647 				smlayer_setActorFacing(1, 3, 5, 180);
2648 				_actor[1].act[3].state = 70;
2649 				_actor[1].scenePropSubIdx = 0;
2650 				_actor[1].runningSound = 0;
2651 			}
2652 		}
2653 		break;
2654 	case 117:
2655 		smlayer_setActorFacing(1, 3, 13, 180);
2656 		_actor[1].field_54 = 1;
2657 		_actor[1].act[3].state = 69;
2658 		break;
2659 	case 118:
2660 		smlayer_setActorFacing(1, 3, 14, 180);
2661 		_actor[1].act[3].state = 71;
2662 		break;
2663 	default:
2664 		break;
2665 	}
2666 }
2667 
2668 
2669 // FIXME: this is exact actor00Reaction. Combine
actor10Reaction(int32 buttons)2670 void Insane::actor10Reaction(int32 buttons) {
2671 	int32 tmpx, tmpy;
2672 
2673 	switch (_actor[1].tilt) {
2674 	case -3:
2675 		if (_actor[1].act[0].state != 41) {
2676 			smlayer_setActorFacing(1, 0, 6, 180);
2677 			_actor[1].act[0].state = 41;
2678 		}
2679 		break;
2680 	case -2:
2681 		if (_actor[1].act[0].state != 40) {
2682 			smlayer_setActorFacing(1, 0, 7, 180);
2683 			_actor[1].act[0].state = 40;
2684 		}
2685 		break;
2686 	case -1:
2687 		if (_actor[1].act[0].state != 39) {
2688 			smlayer_setActorFacing(1, 0, 8, 180);
2689 			_actor[1].act[0].state = 39;
2690 		}
2691 		break;
2692 	case 0:
2693 		if (_actor[1].act[0].state != 1) {
2694 			smlayer_setActorFacing(1, 0, 9, 180);
2695 			_actor[1].act[0].state = 1;
2696 		}
2697 		break;
2698 	case 1:
2699 		if (_actor[1].act[0].state != 55) {
2700 			smlayer_setActorFacing(1, 0, 10, 180);
2701 			_actor[1].act[0].state = 55;
2702 		}
2703 		break;
2704 	case 2:
2705 		if (_actor[1].act[0].state != 56) {
2706 			smlayer_setActorFacing(1, 0, 11, 180);
2707 			_actor[1].act[0].state = 56;
2708 		}
2709 		break;
2710 	case 3:
2711 		if (_actor[1].act[0].state != 57) {
2712 			smlayer_setActorFacing(1, 0, 12, 180);
2713 			_actor[1].act[0].state = 57;
2714 		}
2715 		break;
2716 	default:
2717 		break;
2718 	}
2719 	tmpx = _actor[1].x + _actor[1].x1;
2720 	tmpy = _actor[1].y + _actor[1].y1;
2721 
2722 	if (_actor[1].act[0].room)
2723 		smlayer_putActor(1, 0, tmpx, tmpy, _smlayer_room2);
2724 	else
2725 		smlayer_putActor(1, 0, tmpx, tmpy, _smlayer_room);
2726 }
2727 
actionEnemy()2728 int32 Insane::actionEnemy() {
2729 	int32 buttons;
2730 
2731 	if (_actor[1].enemyHandler != -1)
2732 		buttons = enemyHandler(_actor[1].enemyHandler, 1, 0, _actor[1].probability);
2733 	else
2734 		buttons = enemyHandler(EN_TORQUE, 1, 0, _actor[1].probability);
2735 
2736 	if (_actor[1].tilt) {
2737 		_actor[1].speed += _actor[1].cursorX / 40;
2738 	} else {
2739 		if (_actor[1].speed < 0)
2740 			_actor[1].speed++;
2741 		else
2742 			_actor[1].speed--;
2743 	}
2744 
2745 	if (_actor[1].speed > 8)
2746 		_actor[1].speed = 8;
2747 
2748 	if (_actor[1].speed < -8)
2749 		_actor[1].speed = -8;
2750 
2751 	_actor[1].x += _actor[0].speed;
2752 
2753 	if (_actor[1].x > 250)
2754 		_actor[1].x--;
2755 	else if (_actor[1].x < 250)
2756 		_actor[1].x++;
2757 
2758 	if (_actor[1].x > 320) {
2759 		_actor[1].x = 320;
2760 		_actor[1].damage++;
2761 		_actor[1].x1 = -_actor[1].x1;
2762 		_actor[1].damage++;
2763 
2764 		return buttons;
2765 	}
2766 
2767 	if (!_actor[1].lost) {
2768 		if (_actor[0].x + 90 > _actor[1].x)
2769 			_actor[1].x = _actor[0].x + 90;
2770 	}
2771 
2772 	if (_actor[1].x < 0) {
2773 		_actor[1].x = 0;
2774 		_actor[1].x1 = -_actor[1].x1;
2775 		_actor[1].damage++;
2776 	} else if (_actor[1].x > 310) {
2777 		_actor[1].x1 = -_actor[1].x1;
2778 		_actor[1].damage++;
2779 	}
2780 
2781 	return buttons;
2782 }
2783 
2784 }
2785