1 //-------------------------------------------------------------------------
2 /*
3 Copyright (C) 1997, 2005 - 3D Realms Entertainment
4 
5 This file is part of Shadow Warrior version 1.2
6 
7 Shadow Warrior 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.
15 
16 See the GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 
22 Original Source: 1997 - Frank Maddin and Jim Norwood
23 Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms
24 */
25 //-------------------------------------------------------------------------
26 #include "build.h"
27 
28 #include "keys.h"
29 #include "names2.h"
30 #include "panel.h"
31 #include "game.h"
32 #include "tags.h"
33 #include "ai.h"
34 #include "pal.h"
35 #include "player.h"
36 #include "network.h"
37 #include "actor.h"
38 #include "track.h"
39 #include "sprite.h"
40 
41 int DoHariKariBlood(short SpriteNum);
42 //int InitActorMoveCloser(short SpriteNum);
43 
44 DECISION GirlNinjaBattle[] =
45 {
46     {499, InitActorMoveCloser},
47     //{509, InitActorAmbientNoise},
48     //{710, InitActorRunAway},
49     {1024, InitActorAttack}
50 };
51 
52 DECISION GirlNinjaOffense[] =
53 {
54     {499, InitActorMoveCloser},
55     //{509, InitActorAmbientNoise},
56     {1024, InitActorAttack}
57 };
58 
59 DECISION GirlNinjaBroadcast[] =
60 {
61     //{1, InitActorAlertNoise},
62     {6, InitActorAmbientNoise},
63     {1024, InitActorDecide}
64 };
65 
66 DECISION GirlNinjaSurprised[] =
67 {
68     {701, InitActorMoveCloser},
69     {1024, InitActorDecide}
70 };
71 
72 DECISION GirlNinjaEvasive[] =
73 {
74     {400,   InitActorDuck}, // 100
75 //    {300,   InitActorEvade},
76 //    {800,   InitActorRunAway},
77     {1024,  NULL}
78 };
79 
80 DECISION GirlNinjaLostTarget[] =
81 {
82     {900, InitActorFindPlayer},
83     {1024, InitActorWanderAround}
84 };
85 
86 DECISION GirlNinjaCloseRange[] =
87 {
88     {900,   InitActorAttack             },
89     {1024,  InitActorReposition         }
90 };
91 
92 /*
93 
94  !AIC - Collection of decision tables
95 
96 */
97 
98 PERSONALITY GirlNinjaPersonality =
99 {
100     GirlNinjaBattle,
101     GirlNinjaOffense,
102     GirlNinjaBroadcast,
103     GirlNinjaSurprised,
104     GirlNinjaEvasive,
105     GirlNinjaLostTarget,
106     GirlNinjaCloseRange,
107     GirlNinjaCloseRange
108 };
109 
110 
111 ATTRIBUTE GirlNinjaAttrib =
112 {
113     {120, 140, 160, 190},               // Speeds
114     {4, 0, 0, -2},                      // Tic Adjusts
115     3,                                 // MaxWeapons;
116     {
117         DIGI_GIRLNINJAALERT, DIGI_GIRLNINJAALERT, DIGI_STAR,
118         DIGI_GIRLNINJAALERTT, DIGI_GIRLNINJASCREAM,0,0,0,0,0
119     }
120 };
121 
122 //////////////////////
123 //
124 // GIRLNINJA RUN
125 //
126 //////////////////////
127 
128 ANIMATOR DoGirlNinjaMove, DoGirlNinjaCrawl, DoStayOnFloor, NullGirlNinja, DoActorJump, DoActorFall, DoActorDebris, DoGirlNinjaHariKari, DoActorSlide;
129 ANIMATOR InitActorDecide;
130 
131 #define GIRLNINJA_RATE 18
132 
133 STATE s_GirlNinjaRun[5][4] =
134 {
135 
136     {
137         {GIRLNINJA_RUN_R0 + 0, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[0][1]},
138         {GIRLNINJA_RUN_R0 + 1, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[0][2]},
139         {GIRLNINJA_RUN_R0 + 2, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[0][3]},
140         {GIRLNINJA_RUN_R0 + 3, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[0][0]},
141     },
142     {
143         {GIRLNINJA_RUN_R1 + 0, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[1][1]},
144         {GIRLNINJA_RUN_R1 + 1, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[1][2]},
145         {GIRLNINJA_RUN_R1 + 2, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[1][3]},
146         {GIRLNINJA_RUN_R1 + 3, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[1][0]},
147     },
148     {
149         {GIRLNINJA_RUN_R2 + 0, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[2][1]},
150         {GIRLNINJA_RUN_R2 + 1, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[2][2]},
151         {GIRLNINJA_RUN_R2 + 2, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[2][3]},
152         {GIRLNINJA_RUN_R2 + 3, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[2][0]},
153     },
154     {
155         {GIRLNINJA_RUN_R3 + 0, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[3][1]},
156         {GIRLNINJA_RUN_R3 + 1, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[3][2]},
157         {GIRLNINJA_RUN_R3 + 2, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[3][3]},
158         {GIRLNINJA_RUN_R3 + 3, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[3][0]},
159     },
160     {
161         {GIRLNINJA_RUN_R4 + 0, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[4][1]},
162         {GIRLNINJA_RUN_R4 + 1, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[4][2]},
163         {GIRLNINJA_RUN_R4 + 2, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[4][3]},
164         {GIRLNINJA_RUN_R4 + 3, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[4][0]},
165     },
166 
167 };
168 
169 
170 STATEp sg_GirlNinjaRun[] =
171 {
172     s_GirlNinjaRun[0],
173     s_GirlNinjaRun[1],
174     s_GirlNinjaRun[2],
175     s_GirlNinjaRun[3],
176     s_GirlNinjaRun[4]
177 };
178 
179 //////////////////////
180 //
181 // GIRLNINJA STAND
182 //
183 //////////////////////
184 
185 #define GIRLNINJA_STAND_RATE 10
186 
187 STATE s_GirlNinjaStand[5][1] =
188 {
189     {
190         {GIRLNINJA_STAND_R0 + 0, GIRLNINJA_STAND_RATE, DoGirlNinjaMove, &s_GirlNinjaStand[0][0]},
191     },
192     {
193         {GIRLNINJA_STAND_R1 + 0, GIRLNINJA_STAND_RATE, DoGirlNinjaMove, &s_GirlNinjaStand[1][0]},
194     },
195     {
196         {GIRLNINJA_STAND_R2 + 0, GIRLNINJA_STAND_RATE, DoGirlNinjaMove, &s_GirlNinjaStand[2][0]},
197     },
198     {
199         {GIRLNINJA_STAND_R3 + 0, GIRLNINJA_STAND_RATE, DoGirlNinjaMove, &s_GirlNinjaStand[3][0]},
200     },
201     {
202         {GIRLNINJA_STAND_R4 + 0, GIRLNINJA_STAND_RATE, DoGirlNinjaMove, &s_GirlNinjaStand[4][0]},
203     },
204 };
205 
206 
207 STATEp sg_GirlNinjaStand[] =
208 {
209     s_GirlNinjaStand[0],
210     s_GirlNinjaStand[1],
211     s_GirlNinjaStand[2],
212     s_GirlNinjaStand[3],
213     s_GirlNinjaStand[4]
214 };
215 
216 //////////////////////
217 //
218 // GIRLNINJA RISE
219 //
220 //////////////////////
221 
222 #define GIRLNINJA_RISE_RATE 10
223 
224 STATE s_GirlNinjaRise[5][3] =
225 {
226     {
227         {GIRLNINJA_KNEEL_R0 + 0, GIRLNINJA_RISE_RATE, NullGirlNinja, &s_GirlNinjaRise[0][1]},
228         {GIRLNINJA_STAND_R0 + 0, GIRLNINJA_STAND_RATE, NullGirlNinja, &s_GirlNinjaRise[0][2]},
229         {0, 0, NULL, (STATEp)sg_GirlNinjaRun},  // JBF: sg_GirlNinjaRun really is supposed to be the
230         // pointer to the state group. See StateControl() where
231         // it says "if (!u->State->Pic)".
232     },
233     {
234         {GIRLNINJA_KNEEL_R1 + 0, GIRLNINJA_RISE_RATE, NullGirlNinja, &s_GirlNinjaRise[1][1]},
235         {GIRLNINJA_STAND_R1 + 0, GIRLNINJA_STAND_RATE, NullGirlNinja, &s_GirlNinjaRise[1][2]},
236         {0, 0, NULL, (STATEp)sg_GirlNinjaRun},
237     },
238     {
239         {GIRLNINJA_KNEEL_R2 + 0, GIRLNINJA_RISE_RATE, NullGirlNinja, &s_GirlNinjaRise[2][1]},
240         {GIRLNINJA_STAND_R2 + 0, GIRLNINJA_STAND_RATE, NullGirlNinja, &s_GirlNinjaRise[2][2]},
241         {0, 0, NULL, (STATEp)sg_GirlNinjaRun},
242     },
243     {
244         {GIRLNINJA_KNEEL_R3 + 0, GIRLNINJA_RISE_RATE, NullGirlNinja, &s_GirlNinjaRise[3][1]},
245         {GIRLNINJA_STAND_R3 + 0, GIRLNINJA_STAND_RATE, NullGirlNinja, &s_GirlNinjaRise[3][2]},
246         {0, 0, NULL, (STATEp)sg_GirlNinjaRun},
247     },
248     {
249         {GIRLNINJA_KNEEL_R4 + 0, GIRLNINJA_RISE_RATE, NullGirlNinja, &s_GirlNinjaRise[4][1]},
250         {GIRLNINJA_STAND_R4 + 0, GIRLNINJA_STAND_RATE, NullGirlNinja, &s_GirlNinjaRise[4][2]},
251         {0, 0, NULL, (STATEp)sg_GirlNinjaRun},
252     },
253 };
254 
255 
256 STATEp sg_GirlNinjaRise[] =
257 {
258     s_GirlNinjaRise[0],
259     s_GirlNinjaRise[1],
260     s_GirlNinjaRise[2],
261     s_GirlNinjaRise[3],
262     s_GirlNinjaRise[4]
263 };
264 
265 //////////////////////
266 //
267 // GIRLNINJA DUCK
268 //
269 //////////////////////
270 
271 #define GIRLNINJA_DUCK_RATE 10
272 #define GIRLNINJA_CRAWL_RATE 14
273 
274 STATE s_GirlNinjaDuck[5][2] =
275 {
276     {
277         {GIRLNINJA_KNEEL_R0 + 0, GIRLNINJA_DUCK_RATE, NullGirlNinja, &s_GirlNinjaDuck[0][1]},
278         {GIRLNINJA_CRAWL_R0 + 0, GIRLNINJA_CRAWL_RATE, DoGirlNinjaMove, &s_GirlNinjaDuck[0][1]},
279     },
280     {
281         {GIRLNINJA_KNEEL_R1 + 0, GIRLNINJA_DUCK_RATE, NullGirlNinja, &s_GirlNinjaDuck[1][1]},
282         {GIRLNINJA_CRAWL_R1 + 0, GIRLNINJA_CRAWL_RATE, DoGirlNinjaMove, &s_GirlNinjaDuck[1][1]},
283     },
284     {
285         {GIRLNINJA_KNEEL_R2 + 0, GIRLNINJA_DUCK_RATE, NullGirlNinja, &s_GirlNinjaDuck[2][1]},
286         {GIRLNINJA_CRAWL_R2 + 0, GIRLNINJA_CRAWL_RATE, DoGirlNinjaMove, &s_GirlNinjaDuck[2][1]},
287     },
288     {
289         {GIRLNINJA_KNEEL_R3 + 0, GIRLNINJA_DUCK_RATE, NullGirlNinja, &s_GirlNinjaDuck[3][1]},
290         {GIRLNINJA_CRAWL_R3 + 0, GIRLNINJA_CRAWL_RATE, DoGirlNinjaMove, &s_GirlNinjaDuck[3][1]},
291     },
292     {
293         {GIRLNINJA_KNEEL_R4 + 0, GIRLNINJA_DUCK_RATE, NullGirlNinja, &s_GirlNinjaDuck[4][1]},
294         {GIRLNINJA_CRAWL_R4 + 0, GIRLNINJA_CRAWL_RATE, DoGirlNinjaMove, &s_GirlNinjaDuck[4][1]},
295     },
296 };
297 
298 
299 STATEp sg_GirlNinjaDuck[] =
300 {
301     s_GirlNinjaDuck[0],
302     s_GirlNinjaDuck[1],
303     s_GirlNinjaDuck[2],
304     s_GirlNinjaDuck[3],
305     s_GirlNinjaDuck[4]
306 };
307 
308 
309 //////////////////////
310 //
311 // GIRLNINJA SIT
312 //
313 //////////////////////
314 
315 STATE s_GirlNinjaSit[5][1] =
316 {
317     {
318         {GIRLNINJA_KNEEL_R0 + 0, GIRLNINJA_RISE_RATE, DoGirlNinjaMove, &s_GirlNinjaSit[0][0]},
319     },
320     {
321         {GIRLNINJA_KNEEL_R1 + 0, GIRLNINJA_RISE_RATE, DoGirlNinjaMove, &s_GirlNinjaSit[1][0]},
322     },
323     {
324         {GIRLNINJA_KNEEL_R2 + 0, GIRLNINJA_RISE_RATE, DoGirlNinjaMove, &s_GirlNinjaSit[2][0]},
325     },
326     {
327         {GIRLNINJA_KNEEL_R3 + 0, GIRLNINJA_RISE_RATE, DoGirlNinjaMove, &s_GirlNinjaSit[3][0]},
328     },
329     {
330         {GIRLNINJA_KNEEL_R4 + 0, GIRLNINJA_RISE_RATE, DoGirlNinjaMove, &s_GirlNinjaSit[4][0]},
331     },
332 };
333 
334 
335 STATEp sg_GirlNinjaSit[] =
336 {
337     s_GirlNinjaSit[0],
338     s_GirlNinjaSit[1],
339     s_GirlNinjaSit[2],
340     s_GirlNinjaSit[3],
341     s_GirlNinjaSit[4]
342 };
343 
344 
345 //////////////////////
346 //
347 // GIRLNINJA JUMP
348 //
349 //////////////////////
350 
351 #define GIRLNINJA_JUMP_RATE 24
352 
353 STATE s_GirlNinjaJump[5][2] =
354 {
355     {
356         {GIRLNINJA_JUMP_R0 + 0, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[0][1]},
357         {GIRLNINJA_JUMP_R0 + 1, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[0][1]},
358     },
359     {
360         {GIRLNINJA_JUMP_R1 + 0, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[1][1]},
361         {GIRLNINJA_JUMP_R1 + 1, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[1][1]},
362     },
363     {
364         {GIRLNINJA_JUMP_R2 + 0, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[2][1]},
365         {GIRLNINJA_JUMP_R2 + 1, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[2][1]},
366     },
367     {
368         {GIRLNINJA_JUMP_R3 + 0, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[3][1]},
369         {GIRLNINJA_JUMP_R3 + 1, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[3][1]},
370     },
371     {
372         {GIRLNINJA_JUMP_R4 + 0, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[4][1]},
373         {GIRLNINJA_JUMP_R4 + 1, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[4][1]},
374     },
375 };
376 
377 
378 STATEp sg_GirlNinjaJump[] =
379 {
380     s_GirlNinjaJump[0],
381     s_GirlNinjaJump[1],
382     s_GirlNinjaJump[2],
383     s_GirlNinjaJump[3],
384     s_GirlNinjaJump[4]
385 };
386 
387 
388 //////////////////////
389 //
390 // GIRLNINJA FALL
391 //
392 //////////////////////
393 
394 #define GIRLNINJA_FALL_RATE 16
395 
396 STATE s_GirlNinjaFall[5][2] =
397 {
398     {
399         {GIRLNINJA_JUMP_R0 + 1, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[0][1]},
400         {GIRLNINJA_JUMP_R0 + 2, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[0][1]},
401     },
402     {
403         {GIRLNINJA_JUMP_R1 + 1, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[1][1]},
404         {GIRLNINJA_JUMP_R1 + 2, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[1][1]},
405     },
406     {
407         {GIRLNINJA_JUMP_R2 + 1, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[2][1]},
408         {GIRLNINJA_JUMP_R2 + 2, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[2][1]},
409     },
410     {
411         {GIRLNINJA_JUMP_R3 + 1, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[3][1]},
412         {GIRLNINJA_JUMP_R3 + 2, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[3][1]},
413     },
414     {
415         {GIRLNINJA_JUMP_R4 + 1, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[4][1]},
416         {GIRLNINJA_JUMP_R4 + 2, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[4][1]},
417     },
418 };
419 
420 
421 STATEp sg_GirlNinjaFall[] =
422 {
423     s_GirlNinjaFall[0],
424     s_GirlNinjaFall[1],
425     s_GirlNinjaFall[2],
426     s_GirlNinjaFall[3],
427     s_GirlNinjaFall[4]
428 };
429 
430 //////////////////////
431 //
432 // GIRLNINJA PAIN
433 //
434 //////////////////////
435 
436 #define GIRLNINJA_PAIN_RATE 15
437 ANIMATOR DoGirlNinjaPain;
438 
439 STATE s_GirlNinjaPain[5][1] =
440 {
441     {
442         {GIRLNINJA_PAIN_R0 + 0, GIRLNINJA_PAIN_RATE, DoGirlNinjaPain, &s_GirlNinjaPain[0][0]},
443     },
444     {
445         {GIRLNINJA_PAIN_R1 + 0, GIRLNINJA_PAIN_RATE, DoGirlNinjaPain, &s_GirlNinjaPain[1][0]},
446     },
447     {
448         {GIRLNINJA_PAIN_R2 + 0, GIRLNINJA_PAIN_RATE, DoGirlNinjaPain, &s_GirlNinjaPain[2][0]},
449     },
450     {
451         {GIRLNINJA_PAIN_R3 + 0, GIRLNINJA_PAIN_RATE, DoGirlNinjaPain, &s_GirlNinjaPain[3][0]},
452     },
453     {
454         {GIRLNINJA_PAIN_R4 + 0, GIRLNINJA_PAIN_RATE, DoGirlNinjaPain, &s_GirlNinjaPain[4][0]},
455     },
456 };
457 
458 STATEp sg_GirlNinjaPain[] =
459 {
460     s_GirlNinjaPain[0],
461     s_GirlNinjaPain[1],
462     s_GirlNinjaPain[2],
463     s_GirlNinjaPain[3],
464     s_GirlNinjaPain[4]
465 };
466 
467 //////////////////////
468 //
469 // GIRLNINJA STICKY
470 //
471 //////////////////////
472 
473 #define GIRLNINJA_STICKY_RATE 32
474 ANIMATOR InitEnemyMine;
475 
476 STATE s_GirlNinjaSticky[5][6] =
477 {
478     {
479         {GIRLNINJA_THROW_R0 + 0, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[0][1]},
480         {GIRLNINJA_THROW_R0 + 0, GIRLNINJA_STICKY_RATE,       NullGirlNinja,          &s_GirlNinjaSticky[0][2]},
481         {GIRLNINJA_THROW_R0 + 1, 0 | SF_QUICK_CALL,         InitEnemyMine,      &s_GirlNinjaSticky[0][3]},
482         {GIRLNINJA_THROW_R0 + 1, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[0][4]},
483         {GIRLNINJA_THROW_R0 + 2, 0 | SF_QUICK_CALL,         InitActorDecide,    &s_GirlNinjaSticky[0][5]},
484         {GIRLNINJA_THROW_R0 + 2, GIRLNINJA_STICKY_RATE,       DoGirlNinjaMove,        &s_GirlNinjaSticky[0][5]},
485     },
486     {
487         {GIRLNINJA_THROW_R1 + 0, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[1][1]},
488         {GIRLNINJA_THROW_R1 + 0, GIRLNINJA_STICKY_RATE,       NullGirlNinja,          &s_GirlNinjaSticky[1][2]},
489         {GIRLNINJA_THROW_R1 + 1, 0 | SF_QUICK_CALL,         InitEnemyMine,      &s_GirlNinjaSticky[1][3]},
490         {GIRLNINJA_THROW_R1 + 1, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[1][4]},
491         {GIRLNINJA_THROW_R1 + 2, 0 | SF_QUICK_CALL,         InitActorDecide,    &s_GirlNinjaSticky[1][5]},
492         {GIRLNINJA_THROW_R1 + 2, GIRLNINJA_STICKY_RATE,       DoGirlNinjaMove,        &s_GirlNinjaSticky[1][5]},
493     },
494     {
495         {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[2][1]},
496         {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE,       NullGirlNinja,          &s_GirlNinjaSticky[2][2]},
497         {GIRLNINJA_THROW_R2 + 1, 0 | SF_QUICK_CALL,         InitEnemyMine,      &s_GirlNinjaSticky[2][3]},
498         {GIRLNINJA_THROW_R2 + 1, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[2][4]},
499         {GIRLNINJA_THROW_R2 + 2, 0 | SF_QUICK_CALL,         InitActorDecide,    &s_GirlNinjaSticky[2][5]},
500         {GIRLNINJA_THROW_R2 + 2, GIRLNINJA_STICKY_RATE,       DoGirlNinjaMove,        &s_GirlNinjaSticky[2][5]},
501     },
502     {
503         {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[3][1]},
504         {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE,       NullGirlNinja,          &s_GirlNinjaSticky[3][2]},
505         {GIRLNINJA_THROW_R2 + 1, 0 | SF_QUICK_CALL,         InitEnemyMine,      &s_GirlNinjaSticky[3][3]},
506         {GIRLNINJA_THROW_R2 + 1, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[3][4]},
507         {GIRLNINJA_THROW_R2 + 2, 0 | SF_QUICK_CALL,         InitActorDecide,    &s_GirlNinjaSticky[3][5]},
508         {GIRLNINJA_THROW_R2 + 2, GIRLNINJA_STICKY_RATE,       DoGirlNinjaMove,        &s_GirlNinjaSticky[3][5]},
509     },
510     {
511         {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[4][1]},
512         {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE,       NullGirlNinja,          &s_GirlNinjaSticky[4][2]},
513         {GIRLNINJA_THROW_R2 + 1, 0 | SF_QUICK_CALL,         InitEnemyMine,      &s_GirlNinjaSticky[4][3]},
514         {GIRLNINJA_THROW_R2 + 1, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[4][4]},
515         {GIRLNINJA_THROW_R2 + 2, 0 | SF_QUICK_CALL,         InitActorDecide,    &s_GirlNinjaSticky[4][5]},
516         {GIRLNINJA_THROW_R2 + 2, GIRLNINJA_STICKY_RATE,       DoGirlNinjaMove,        &s_GirlNinjaSticky[4][5]},
517     },
518 };
519 
520 STATEp sg_GirlNinjaSticky[] =
521 {
522     s_GirlNinjaSticky[0],
523     s_GirlNinjaSticky[1],
524     s_GirlNinjaSticky[2],
525     s_GirlNinjaSticky[3],
526     s_GirlNinjaSticky[4]
527 };
528 
529 
530 //////////////////////
531 //
532 // GIRLNINJA CROSSBOW
533 //
534 //////////////////////
535 
536 #define GIRLNINJA_CROSSBOW_RATE 14
537 ANIMATOR InitEnemyCrossbow;
538 
539 STATE s_GirlNinjaCrossbow[5][5] =
540 {
541     {
542         {GIRLNINJA_FIRE_R0 + 0, GIRLNINJA_CROSSBOW_RATE * 2, NullGirlNinja, &s_GirlNinjaCrossbow[0][1]},
543         {GIRLNINJA_FIRE_R0 + 1, 0 | SF_QUICK_CALL, InitEnemyCrossbow, &s_GirlNinjaCrossbow[0][2]},
544         {GIRLNINJA_FIRE_R0 + 1, GIRLNINJA_CROSSBOW_RATE, NullGirlNinja, &s_GirlNinjaCrossbow[0][3]},
545         {GIRLNINJA_FIRE_R0 + 1, 0 | SF_QUICK_CALL, InitActorDecide, &s_GirlNinjaCrossbow[0][4]},
546         {GIRLNINJA_FIRE_R0 + 1, GIRLNINJA_CROSSBOW_RATE, DoGirlNinjaMove, &s_GirlNinjaCrossbow[0][4]},
547     },
548     {
549         {GIRLNINJA_FIRE_R1 + 0, GIRLNINJA_CROSSBOW_RATE * 2, NullGirlNinja, &s_GirlNinjaCrossbow[1][1]},
550         {GIRLNINJA_FIRE_R1 + 1, 0 | SF_QUICK_CALL, InitEnemyCrossbow, &s_GirlNinjaCrossbow[1][2]},
551         {GIRLNINJA_FIRE_R1 + 1, GIRLNINJA_CROSSBOW_RATE, NullGirlNinja, &s_GirlNinjaCrossbow[1][3]},
552         {GIRLNINJA_FIRE_R1 + 1, 0 | SF_QUICK_CALL, InitActorDecide, &s_GirlNinjaCrossbow[1][4]},
553         {GIRLNINJA_FIRE_R1 + 1, GIRLNINJA_CROSSBOW_RATE, DoGirlNinjaMove, &s_GirlNinjaCrossbow[1][4]},
554     },
555     {
556         {GIRLNINJA_FIRE_R2 + 0, GIRLNINJA_CROSSBOW_RATE * 2, NullGirlNinja, &s_GirlNinjaCrossbow[2][1]},
557         {GIRLNINJA_FIRE_R2 + 1, 0 | SF_QUICK_CALL, InitEnemyCrossbow, &s_GirlNinjaCrossbow[2][2]},
558         {GIRLNINJA_FIRE_R2 + 1, GIRLNINJA_CROSSBOW_RATE, NullGirlNinja, &s_GirlNinjaCrossbow[2][3]},
559         {GIRLNINJA_FIRE_R2 + 1, 0 | SF_QUICK_CALL, InitActorDecide, &s_GirlNinjaCrossbow[2][4]},
560         {GIRLNINJA_FIRE_R2 + 1, GIRLNINJA_CROSSBOW_RATE, DoGirlNinjaMove, &s_GirlNinjaCrossbow[2][4]},
561     },
562     {
563         {GIRLNINJA_FIRE_R3 + 0, GIRLNINJA_CROSSBOW_RATE * 2, NullGirlNinja, &s_GirlNinjaCrossbow[3][1]},
564         {GIRLNINJA_FIRE_R3 + 1, 0 | SF_QUICK_CALL, InitEnemyCrossbow, &s_GirlNinjaCrossbow[3][2]},
565         {GIRLNINJA_FIRE_R3 + 1, GIRLNINJA_CROSSBOW_RATE, NullGirlNinja, &s_GirlNinjaCrossbow[3][3]},
566         {GIRLNINJA_FIRE_R3 + 1, 0 | SF_QUICK_CALL, InitActorDecide, &s_GirlNinjaCrossbow[3][4]},
567         {GIRLNINJA_FIRE_R3 + 1, GIRLNINJA_CROSSBOW_RATE, DoGirlNinjaMove, &s_GirlNinjaCrossbow[3][4]},
568     },
569     {
570         {GIRLNINJA_FIRE_R4 + 0, GIRLNINJA_CROSSBOW_RATE * 2, NullGirlNinja, &s_GirlNinjaCrossbow[4][1]},
571         {GIRLNINJA_FIRE_R4 + 1, 0 | SF_QUICK_CALL, InitEnemyCrossbow, &s_GirlNinjaCrossbow[4][2]},
572         {GIRLNINJA_FIRE_R4 + 1, GIRLNINJA_CROSSBOW_RATE, NullGirlNinja, &s_GirlNinjaCrossbow[4][3]},
573         {GIRLNINJA_FIRE_R4 + 1, 0 | SF_QUICK_CALL, InitActorDecide, &s_GirlNinjaCrossbow[4][4]},
574         {GIRLNINJA_FIRE_R4 + 1, GIRLNINJA_CROSSBOW_RATE, DoGirlNinjaMove, &s_GirlNinjaCrossbow[4][4]},
575     },
576 };
577 
578 
579 STATEp sg_GirlNinjaCrossbow[] =
580 {
581     s_GirlNinjaCrossbow[0],
582     s_GirlNinjaCrossbow[1],
583     s_GirlNinjaCrossbow[2],
584     s_GirlNinjaCrossbow[3],
585     s_GirlNinjaCrossbow[4]
586 };
587 
588 
589 
590 //////////////////////
591 //
592 // GIRLNINJA DIE
593 //
594 //////////////////////
595 
596 #define GIRLNINJA_DIE_RATE 30
597 ANIMATOR DoGirlNinjaSpecial;
598 
599 STATE s_GirlNinjaDie[] =
600 {
601     {GIRLNINJA_DIE + 0, GIRLNINJA_DIE_RATE*2, NullGirlNinja, &s_GirlNinjaDie[1]},
602     {GIRLNINJA_DIE + 1, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[2]},
603     {GIRLNINJA_DIE + 2, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[3]},
604     {GIRLNINJA_DIE + 3, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[4]},
605     {GIRLNINJA_DIE + 4, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[5]},
606     {GIRLNINJA_DIE + 5, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[6]},
607     {GIRLNINJA_DIE + 6, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[7]},
608     {GIRLNINJA_DIE + 6, SF_QUICK_CALL, DoGirlNinjaSpecial, &s_GirlNinjaDie[8]},
609     {GIRLNINJA_DIE + 7, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[9]},
610     {GIRLNINJA_DIE + 8, SF_QUICK_CALL, QueueFloorBlood, &s_GirlNinjaDie[10]},
611     {GIRLNINJA_DIE + 8, GIRLNINJA_DIE_RATE, DoActorDebris, &s_GirlNinjaDie[10]},
612 };
613 
614 STATE s_GirlNinjaDead[] =
615 {
616     {GIRLNINJA_DIE + 6, GIRLNINJA_DIE_RATE, DoActorDebris, &s_GirlNinjaDead[1]},
617     {GIRLNINJA_DIE + 7, SF_QUICK_CALL, DoGirlNinjaSpecial, &s_GirlNinjaDead[2]},
618     {GIRLNINJA_DIE + 7, GIRLNINJA_DIE_RATE, DoActorDebris, &s_GirlNinjaDead[3]},
619     {GIRLNINJA_DIE + 8, SF_QUICK_CALL, QueueFloorBlood,&s_GirlNinjaDead[4]},
620     {GIRLNINJA_DIE + 8, GIRLNINJA_DIE_RATE, DoActorDebris, &s_GirlNinjaDead[4]},
621 };
622 
623 
624 STATE s_GirlNinjaDeathJump[] =
625 {
626     {GIRLNINJA_DIE + 0, GIRLNINJA_DIE_RATE, DoActorDeathMove, &s_GirlNinjaDeathJump[1]},
627     {GIRLNINJA_DIE + 1, GIRLNINJA_DIE_RATE, DoActorDeathMove, &s_GirlNinjaDeathJump[2]},
628     {GIRLNINJA_DIE + 2, GIRLNINJA_DIE_RATE, DoActorDeathMove, &s_GirlNinjaDeathJump[2]},
629 };
630 
631 STATE s_GirlNinjaDeathFall[] =
632 {
633     {GIRLNINJA_DIE + 3, GIRLNINJA_DIE_RATE, DoActorDeathMove, &s_GirlNinjaDeathFall[1]},
634     {GIRLNINJA_DIE + 4, GIRLNINJA_DIE_RATE, DoActorDeathMove, &s_GirlNinjaDeathFall[1]},
635 };
636 
637 /*
638 STATEp *Stand[MAX_WEAPONS];
639 STATEp *Run;
640 STATEp *Jump;
641 STATEp *Fall;
642 STATEp *Crawl;
643 STATEp *Swim;
644 STATEp *Fly;
645 STATEp *Rise;
646 STATEp *Sit;
647 STATEp *Look;
648 STATEp *Climb;
649 STATEp *Pain;
650 STATEp *Death1;
651 STATEp *Death2;
652 STATEp *Dead;
653 STATEp *DeathJump;
654 STATEp *DeathFall;
655 STATEp *CloseAttack[2];
656 STATEp *Attack[6];
657 STATEp *Special[2];
658 */
659 
660 STATEp sg_GirlNinjaDie[] =
661 {
662     s_GirlNinjaDie
663 };
664 
665 STATEp sg_GirlNinjaDead[] =
666 {
667     s_GirlNinjaDead
668 };
669 
670 STATEp sg_GirlNinjaDeathJump[] =
671 {
672     s_GirlNinjaDeathJump
673 };
674 
675 STATEp sg_GirlNinjaDeathFall[] =
676 {
677     s_GirlNinjaDeathFall
678 };
679 
680 /*
681 
682  !AIC - Collection of states that connect action to states
683 
684 */
685 
686 ACTOR_ACTION_SET GirlNinjaActionSet =
687 {
688     sg_GirlNinjaStand,
689     sg_GirlNinjaRun,
690     sg_GirlNinjaJump,
691     sg_GirlNinjaFall,
692     NULL,
693     NULL,
694     NULL,
695     sg_GirlNinjaRise,
696     sg_GirlNinjaSit,
697     NULL,
698     NULL,
699     sg_GirlNinjaPain,
700     sg_GirlNinjaDie,
701     NULL,
702     sg_GirlNinjaDead,
703     sg_GirlNinjaDeathJump,
704     sg_GirlNinjaDeathFall,
705     {sg_GirlNinjaCrossbow, sg_GirlNinjaSticky},
706     {800, 1024},
707     {sg_GirlNinjaCrossbow, sg_GirlNinjaSticky},
708     {800, 1024},
709     {NULL},
710     sg_GirlNinjaDuck,
711     NULL
712 };
713 
714 int
SetupGirlNinja(short SpriteNum)715 SetupGirlNinja(short SpriteNum)
716 {
717     SPRITEp sp = &sprite[SpriteNum];
718     USERp u;
719     ANIMATOR DoActorDecide;
720 
721     if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE))
722     {
723         u = User[SpriteNum];
724         ASSERT(u);
725     }
726     else
727     {
728         User[SpriteNum] = u = SpawnUser(SpriteNum, GIRLNINJA_RUN_R0, s_GirlNinjaRun[0]);
729         u->Health = 100;
730     }
731 
732     u->StateEnd = s_GirlNinjaDie;
733     u->Rot = sg_GirlNinjaRun;
734     sp->xrepeat = 51;
735     sp->yrepeat = 43;
736 
737     u->Attrib = &GirlNinjaAttrib;
738     sp->pal = u->spal = 26;
739     EnemyDefaults(SpriteNum, &GirlNinjaActionSet, &GirlNinjaPersonality);
740 
741     ChangeState(SpriteNum, s_GirlNinjaRun[0]);
742     DoActorSetSpeed(SpriteNum, NORM_SPEED);
743 
744     u->Radius = 280;
745     RESET(u->Flags, SPR_XFLIP_TOGGLE);
746 
747     return 0;
748 }
749 
750 
751 int
DoGirlNinjaMove(short SpriteNum)752 DoGirlNinjaMove(short SpriteNum)
753 {
754     USERp u = User[SpriteNum];
755 
756     // jumping and falling
757     if (TEST(u->Flags, SPR_JUMPING | SPR_FALLING) && !TEST(u->Flags, SPR_CLIMBING))
758     {
759         if (TEST(u->Flags, SPR_JUMPING))
760             DoActorJump(SpriteNum);
761         else if (TEST(u->Flags, SPR_FALLING))
762             DoActorFall(SpriteNum);
763     }
764 
765     // sliding
766     if (TEST(u->Flags, SPR_SLIDING) && !TEST(u->Flags, SPR_CLIMBING))
767         DoActorSlide(SpriteNum);
768 
769     // !AIC - do track or call current action function - such as DoActorMoveCloser()
770     if (u->track >= 0)
771         ActorFollowTrack(SpriteNum, ACTORMOVETICS);
772     else
773     {
774         (*u->ActorActionFunc)(SpriteNum);
775     }
776 
777     // stay on floor unless doing certain things
778     if (!TEST(u->Flags, SPR_JUMPING | SPR_FALLING | SPR_CLIMBING))
779     {
780         KeepActorOnFloor(SpriteNum);
781     }
782 
783     // take damage from environment
784     DoActorSectorDamage(SpriteNum);
785 
786     return 0;
787 }
788 
789 int
GirlNinjaJumpActionFunc(short SpriteNum)790 GirlNinjaJumpActionFunc(short SpriteNum)
791 {
792     USERp u = User[SpriteNum];
793     SPRITEp sp = User[SpriteNum]->SpriteP;
794     int nx, ny;
795 
796     // Move while jumping
797     nx = sp->xvel * (int) sintable[NORM_ANGLE(sp->ang + 512)] >> 14;
798     ny = sp->xvel * (int) sintable[sp->ang] >> 14;
799 
800     // if cannot move the sprite
801     if (!move_actor(SpriteNum, nx, ny, 0L))
802     {
803         return 0;
804     }
805 
806     if (!TEST(u->Flags, SPR_JUMPING|SPR_FALLING))
807     {
808         InitActorDecide(SpriteNum);
809     }
810 
811     return 0;
812 }
813 
814 int
NullGirlNinja(short SpriteNum)815 NullGirlNinja(short SpriteNum)
816 {
817     USERp u = User[SpriteNum];
818 
819     if (u->WaitTics > 0) u->WaitTics -= ACTORMOVETICS;
820 
821     if (TEST(u->Flags, SPR_SLIDING) && !TEST(u->Flags, SPR_CLIMBING) && !TEST(u->Flags, SPR_JUMPING|SPR_FALLING))
822         DoActorSlide(SpriteNum);
823 
824     if (!TEST(u->Flags, SPR_CLIMBING) && !TEST(u->Flags, SPR_JUMPING|SPR_FALLING))
825         KeepActorOnFloor(SpriteNum);
826 
827     DoActorSectorDamage(SpriteNum);
828 
829     return 0;
830 }
831 
832 
DoGirlNinjaPain(short SpriteNum)833 int DoGirlNinjaPain(short SpriteNum)
834 {
835     USERp u = User[SpriteNum];
836 
837     NullGirlNinja(SpriteNum);
838 
839     if ((u->WaitTics -= ACTORMOVETICS) <= 0)
840         InitActorDecide(SpriteNum);
841 
842     return 0;
843 }
844 
DoGirlNinjaSpecial(short SpriteNum)845 int DoGirlNinjaSpecial(short SpriteNum)
846 {
847     SPRITEp sp = &sprite[SpriteNum];
848     USERp u = User[SpriteNum];
849 
850     if (u->spal == PALETTE_PLAYER5)
851     {
852         RESET(sp->cstat,CSTAT_SPRITE_TRANSLUCENT);
853         sp->hitag = 0;
854         sp->shade = -10;
855     }
856 
857     return 0;
858 }
859 
860 
861 #include "saveable.h"
862 
863 static saveable_code saveable_girlninj_code[] =
864 {
865     SAVE_CODE(SetupGirlNinja),
866     SAVE_CODE(DoGirlNinjaMove),
867     SAVE_CODE(GirlNinjaJumpActionFunc),
868     SAVE_CODE(NullGirlNinja),
869     SAVE_CODE(DoGirlNinjaPain),
870     SAVE_CODE(DoGirlNinjaSpecial),
871 };
872 
873 static saveable_data saveable_girlninj_data[] =
874 {
875     SAVE_DATA(GirlNinjaBattle),
876     SAVE_DATA(GirlNinjaOffense),
877     SAVE_DATA(GirlNinjaBroadcast),
878     SAVE_DATA(GirlNinjaSurprised),
879     SAVE_DATA(GirlNinjaEvasive),
880     SAVE_DATA(GirlNinjaLostTarget),
881     SAVE_DATA(GirlNinjaCloseRange),
882 
883     SAVE_DATA(GirlNinjaPersonality),
884 
885     SAVE_DATA(GirlNinjaAttrib),
886 
887     SAVE_DATA(s_GirlNinjaRun),
888     SAVE_DATA(sg_GirlNinjaRun),
889     SAVE_DATA(s_GirlNinjaStand),
890     SAVE_DATA(sg_GirlNinjaStand),
891     SAVE_DATA(s_GirlNinjaRise),
892     SAVE_DATA(sg_GirlNinjaRise),
893     SAVE_DATA(s_GirlNinjaDuck),
894     SAVE_DATA(sg_GirlNinjaDuck),
895     SAVE_DATA(s_GirlNinjaSit),
896     SAVE_DATA(sg_GirlNinjaSit),
897     SAVE_DATA(s_GirlNinjaJump),
898     SAVE_DATA(sg_GirlNinjaJump),
899     SAVE_DATA(s_GirlNinjaFall),
900     SAVE_DATA(sg_GirlNinjaFall),
901     SAVE_DATA(s_GirlNinjaPain),
902     SAVE_DATA(sg_GirlNinjaPain),
903     SAVE_DATA(s_GirlNinjaSticky),
904     SAVE_DATA(sg_GirlNinjaSticky),
905     SAVE_DATA(s_GirlNinjaCrossbow),
906     SAVE_DATA(sg_GirlNinjaCrossbow),
907     SAVE_DATA(s_GirlNinjaDie),
908     SAVE_DATA(s_GirlNinjaDead),
909     SAVE_DATA(s_GirlNinjaDeathJump),
910     SAVE_DATA(s_GirlNinjaDeathFall),
911     SAVE_DATA(sg_GirlNinjaDie),
912     SAVE_DATA(sg_GirlNinjaDead),
913     SAVE_DATA(sg_GirlNinjaDeathJump),
914     SAVE_DATA(sg_GirlNinjaDeathFall),
915 
916     SAVE_DATA(GirlNinjaActionSet),
917 };
918 
919 saveable_module saveable_girlninj =
920 {
921     // code
922     saveable_girlninj_code,
923     SIZ(saveable_girlninj_code),
924 
925     // data
926     saveable_girlninj_data,
927     SIZ(saveable_girlninj_data)
928 };
929