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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 "net.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     {DIGI_GIRLNINJAALERT, DIGI_GIRLNINJAALERT, DIGI_STAR,
117      DIGI_GIRLNINJAALERTT, DIGI_GIRLNINJASCREAM,0,0,0,0,0}
118     };
119 
120 //////////////////////
121 //
122 // GIRLNINJA RUN
123 //
124 //////////////////////
125 
126 ANIMATOR DoGirlNinjaMove, DoGirlNinjaCrawl, DoStayOnFloor, NullGirlNinja, DoActorJump, DoActorFall, DoActorDebris, DoGirlNinjaHariKari, DoActorSlide;
127 ANIMATOR InitActorDecide;
128 
129 #define GIRLNINJA_RATE 18
130 
131 STATE s_GirlNinjaRun[5][4] =
132     {
133 
134     {
135     {GIRLNINJA_RUN_R0 + 0, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[0][1]},
136     {GIRLNINJA_RUN_R0 + 1, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[0][2]},
137     {GIRLNINJA_RUN_R0 + 2, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[0][3]},
138     {GIRLNINJA_RUN_R0 + 3, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[0][0]},
139     },
140     {
141     {GIRLNINJA_RUN_R1 + 0, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[1][1]},
142     {GIRLNINJA_RUN_R1 + 1, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[1][2]},
143     {GIRLNINJA_RUN_R1 + 2, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[1][3]},
144     {GIRLNINJA_RUN_R1 + 3, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[1][0]},
145     },
146     {
147     {GIRLNINJA_RUN_R2 + 0, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[2][1]},
148     {GIRLNINJA_RUN_R2 + 1, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[2][2]},
149     {GIRLNINJA_RUN_R2 + 2, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[2][3]},
150     {GIRLNINJA_RUN_R2 + 3, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[2][0]},
151     },
152     {
153     {GIRLNINJA_RUN_R3 + 0, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[3][1]},
154     {GIRLNINJA_RUN_R3 + 1, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[3][2]},
155     {GIRLNINJA_RUN_R3 + 2, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[3][3]},
156     {GIRLNINJA_RUN_R3 + 3, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[3][0]},
157     },
158     {
159     {GIRLNINJA_RUN_R4 + 0, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[4][1]},
160     {GIRLNINJA_RUN_R4 + 1, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[4][2]},
161     {GIRLNINJA_RUN_R4 + 2, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[4][3]},
162     {GIRLNINJA_RUN_R4 + 3, GIRLNINJA_RATE | SF_TIC_ADJUST, DoGirlNinjaMove, &s_GirlNinjaRun[4][0]},
163     },
164 
165     };
166 
167 
168 STATEp sg_GirlNinjaRun[] =
169     {
170     s_GirlNinjaRun[0],
171     s_GirlNinjaRun[1],
172     s_GirlNinjaRun[2],
173     s_GirlNinjaRun[3],
174     s_GirlNinjaRun[4]
175     };
176 
177 //////////////////////
178 //
179 // GIRLNINJA STAND
180 //
181 //////////////////////
182 
183 #define GIRLNINJA_STAND_RATE 10
184 
185 STATE s_GirlNinjaStand[5][1] =
186     {
187     {
188     {GIRLNINJA_STAND_R0 + 0, GIRLNINJA_STAND_RATE, DoGirlNinjaMove, &s_GirlNinjaStand[0][0]},
189     },
190     {
191     {GIRLNINJA_STAND_R1 + 0, GIRLNINJA_STAND_RATE, DoGirlNinjaMove, &s_GirlNinjaStand[1][0]},
192     },
193     {
194     {GIRLNINJA_STAND_R2 + 0, GIRLNINJA_STAND_RATE, DoGirlNinjaMove, &s_GirlNinjaStand[2][0]},
195     },
196     {
197     {GIRLNINJA_STAND_R3 + 0, GIRLNINJA_STAND_RATE, DoGirlNinjaMove, &s_GirlNinjaStand[3][0]},
198     },
199     {
200     {GIRLNINJA_STAND_R4 + 0, GIRLNINJA_STAND_RATE, DoGirlNinjaMove, &s_GirlNinjaStand[4][0]},
201     },
202     };
203 
204 
205 STATEp sg_GirlNinjaStand[] =
206     {
207     s_GirlNinjaStand[0],
208     s_GirlNinjaStand[1],
209     s_GirlNinjaStand[2],
210     s_GirlNinjaStand[3],
211     s_GirlNinjaStand[4]
212     };
213 
214 //////////////////////
215 //
216 // GIRLNINJA RISE
217 //
218 //////////////////////
219 
220 #define GIRLNINJA_RISE_RATE 10
221 
222 STATE s_GirlNinjaRise[5][3] =
223     {
224     {
225     {GIRLNINJA_KNEEL_R0 + 0, GIRLNINJA_RISE_RATE, NullGirlNinja, &s_GirlNinjaRise[0][1]},
226     {GIRLNINJA_STAND_R0 + 0, GIRLNINJA_STAND_RATE, NullGirlNinja, &s_GirlNinjaRise[0][2]},
227     {0, 0, NULL, (STATEp)sg_GirlNinjaRun},	// JBF: sg_GirlNinjaRun really is supposed to be the
228     						// pointer to the state group. See StateControl() where
229 						// it says "if (!u->State->Pic)".
230     },
231     {
232     {GIRLNINJA_KNEEL_R1 + 0, GIRLNINJA_RISE_RATE, NullGirlNinja, &s_GirlNinjaRise[1][1]},
233     {GIRLNINJA_STAND_R1 + 0, GIRLNINJA_STAND_RATE, NullGirlNinja, &s_GirlNinjaRise[1][2]},
234     {0, 0, NULL, (STATEp)sg_GirlNinjaRun},
235     },
236     {
237     {GIRLNINJA_KNEEL_R2 + 0, GIRLNINJA_RISE_RATE, NullGirlNinja, &s_GirlNinjaRise[2][1]},
238     {GIRLNINJA_STAND_R2 + 0, GIRLNINJA_STAND_RATE, NullGirlNinja, &s_GirlNinjaRise[2][2]},
239     {0, 0, NULL, (STATEp)sg_GirlNinjaRun},
240     },
241     {
242     {GIRLNINJA_KNEEL_R3 + 0, GIRLNINJA_RISE_RATE, NullGirlNinja, &s_GirlNinjaRise[3][1]},
243     {GIRLNINJA_STAND_R3 + 0, GIRLNINJA_STAND_RATE, NullGirlNinja, &s_GirlNinjaRise[3][2]},
244     {0, 0, NULL, (STATEp)sg_GirlNinjaRun},
245     },
246     {
247     {GIRLNINJA_KNEEL_R4 + 0, GIRLNINJA_RISE_RATE, NullGirlNinja, &s_GirlNinjaRise[4][1]},
248     {GIRLNINJA_STAND_R4 + 0, GIRLNINJA_STAND_RATE, NullGirlNinja, &s_GirlNinjaRise[4][2]},
249     {0, 0, NULL, (STATEp)sg_GirlNinjaRun},
250     },
251     };
252 
253 
254 STATEp sg_GirlNinjaRise[] =
255     {
256     s_GirlNinjaRise[0],
257     s_GirlNinjaRise[1],
258     s_GirlNinjaRise[2],
259     s_GirlNinjaRise[3],
260     s_GirlNinjaRise[4]
261     };
262 
263 //////////////////////
264 //
265 // GIRLNINJA DUCK
266 //
267 //////////////////////
268 
269 #define GIRLNINJA_DUCK_RATE 10
270 #define GIRLNINJA_CRAWL_RATE 14
271 
272 STATE s_GirlNinjaDuck[5][2] =
273     {
274     {
275     {GIRLNINJA_KNEEL_R0 + 0, GIRLNINJA_DUCK_RATE, NullGirlNinja, &s_GirlNinjaDuck[0][1]},
276     {GIRLNINJA_CRAWL_R0 + 0, GIRLNINJA_CRAWL_RATE, DoGirlNinjaMove, &s_GirlNinjaDuck[0][1]},
277     },
278     {
279     {GIRLNINJA_KNEEL_R1 + 0, GIRLNINJA_DUCK_RATE, NullGirlNinja, &s_GirlNinjaDuck[1][1]},
280     {GIRLNINJA_CRAWL_R1 + 0, GIRLNINJA_CRAWL_RATE, DoGirlNinjaMove, &s_GirlNinjaDuck[1][1]},
281     },
282     {
283     {GIRLNINJA_KNEEL_R2 + 0, GIRLNINJA_DUCK_RATE, NullGirlNinja, &s_GirlNinjaDuck[2][1]},
284     {GIRLNINJA_CRAWL_R2 + 0, GIRLNINJA_CRAWL_RATE, DoGirlNinjaMove, &s_GirlNinjaDuck[2][1]},
285     },
286     {
287     {GIRLNINJA_KNEEL_R3 + 0, GIRLNINJA_DUCK_RATE, NullGirlNinja, &s_GirlNinjaDuck[3][1]},
288     {GIRLNINJA_CRAWL_R3 + 0, GIRLNINJA_CRAWL_RATE, DoGirlNinjaMove, &s_GirlNinjaDuck[3][1]},
289     },
290     {
291     {GIRLNINJA_KNEEL_R4 + 0, GIRLNINJA_DUCK_RATE, NullGirlNinja, &s_GirlNinjaDuck[4][1]},
292     {GIRLNINJA_CRAWL_R4 + 0, GIRLNINJA_CRAWL_RATE, DoGirlNinjaMove, &s_GirlNinjaDuck[4][1]},
293     },
294     };
295 
296 
297 STATEp sg_GirlNinjaDuck[] =
298     {
299     s_GirlNinjaDuck[0],
300     s_GirlNinjaDuck[1],
301     s_GirlNinjaDuck[2],
302     s_GirlNinjaDuck[3],
303     s_GirlNinjaDuck[4]
304     };
305 
306 
307 //////////////////////
308 //
309 // GIRLNINJA SIT
310 //
311 //////////////////////
312 
313 STATE s_GirlNinjaSit[5][1] =
314     {
315     {
316     {GIRLNINJA_KNEEL_R0 + 0, GIRLNINJA_RISE_RATE, DoGirlNinjaMove, &s_GirlNinjaSit[0][0]},
317     },
318     {
319     {GIRLNINJA_KNEEL_R1 + 0, GIRLNINJA_RISE_RATE, DoGirlNinjaMove, &s_GirlNinjaSit[1][0]},
320     },
321     {
322     {GIRLNINJA_KNEEL_R2 + 0, GIRLNINJA_RISE_RATE, DoGirlNinjaMove, &s_GirlNinjaSit[2][0]},
323     },
324     {
325     {GIRLNINJA_KNEEL_R3 + 0, GIRLNINJA_RISE_RATE, DoGirlNinjaMove, &s_GirlNinjaSit[3][0]},
326     },
327     {
328     {GIRLNINJA_KNEEL_R4 + 0, GIRLNINJA_RISE_RATE, DoGirlNinjaMove, &s_GirlNinjaSit[4][0]},
329     },
330     };
331 
332 
333 STATEp sg_GirlNinjaSit[] =
334     {
335     s_GirlNinjaSit[0],
336     s_GirlNinjaSit[1],
337     s_GirlNinjaSit[2],
338     s_GirlNinjaSit[3],
339     s_GirlNinjaSit[4]
340     };
341 
342 
343 //////////////////////
344 //
345 // GIRLNINJA JUMP
346 //
347 //////////////////////
348 
349 #define GIRLNINJA_JUMP_RATE 24
350 
351 STATE s_GirlNinjaJump[5][2] =
352     {
353     {
354     {GIRLNINJA_JUMP_R0 + 0, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[0][1]},
355     {GIRLNINJA_JUMP_R0 + 1, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[0][1]},
356     },
357     {
358     {GIRLNINJA_JUMP_R1 + 0, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[1][1]},
359     {GIRLNINJA_JUMP_R1 + 1, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[1][1]},
360     },
361     {
362     {GIRLNINJA_JUMP_R2 + 0, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[2][1]},
363     {GIRLNINJA_JUMP_R2 + 1, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[2][1]},
364     },
365     {
366     {GIRLNINJA_JUMP_R3 + 0, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[3][1]},
367     {GIRLNINJA_JUMP_R3 + 1, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[3][1]},
368     },
369     {
370     {GIRLNINJA_JUMP_R4 + 0, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[4][1]},
371     {GIRLNINJA_JUMP_R4 + 1, GIRLNINJA_JUMP_RATE, DoGirlNinjaMove, &s_GirlNinjaJump[4][1]},
372     },
373     };
374 
375 
376 STATEp sg_GirlNinjaJump[] =
377     {
378     s_GirlNinjaJump[0],
379     s_GirlNinjaJump[1],
380     s_GirlNinjaJump[2],
381     s_GirlNinjaJump[3],
382     s_GirlNinjaJump[4]
383     };
384 
385 
386 //////////////////////
387 //
388 // GIRLNINJA FALL
389 //
390 //////////////////////
391 
392 #define GIRLNINJA_FALL_RATE 16
393 
394 STATE s_GirlNinjaFall[5][2] =
395     {
396     {
397     {GIRLNINJA_JUMP_R0 + 1, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[0][1]},
398     {GIRLNINJA_JUMP_R0 + 2, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[0][1]},
399     },
400     {
401     {GIRLNINJA_JUMP_R1 + 1, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[1][1]},
402     {GIRLNINJA_JUMP_R1 + 2, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[1][1]},
403     },
404     {
405     {GIRLNINJA_JUMP_R2 + 1, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[2][1]},
406     {GIRLNINJA_JUMP_R2 + 2, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[2][1]},
407     },
408     {
409     {GIRLNINJA_JUMP_R3 + 1, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[3][1]},
410     {GIRLNINJA_JUMP_R3 + 2, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[3][1]},
411     },
412     {
413     {GIRLNINJA_JUMP_R4 + 1, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[4][1]},
414     {GIRLNINJA_JUMP_R4 + 2, GIRLNINJA_FALL_RATE, DoGirlNinjaMove, &s_GirlNinjaFall[4][1]},
415     },
416     };
417 
418 
419 STATEp sg_GirlNinjaFall[] =
420     {
421     s_GirlNinjaFall[0],
422     s_GirlNinjaFall[1],
423     s_GirlNinjaFall[2],
424     s_GirlNinjaFall[3],
425     s_GirlNinjaFall[4]
426     };
427 
428 //////////////////////
429 //
430 // GIRLNINJA PAIN
431 //
432 //////////////////////
433 
434 #define GIRLNINJA_PAIN_RATE 15
435 ANIMATOR DoGirlNinjaPain;
436 
437 STATE s_GirlNinjaPain[5][1] =
438     {
439     {
440     {GIRLNINJA_PAIN_R0 + 0, GIRLNINJA_PAIN_RATE, DoGirlNinjaPain, &s_GirlNinjaPain[0][0]},
441     },
442     {
443     {GIRLNINJA_PAIN_R1 + 0, GIRLNINJA_PAIN_RATE, DoGirlNinjaPain, &s_GirlNinjaPain[1][0]},
444     },
445     {
446     {GIRLNINJA_PAIN_R2 + 0, GIRLNINJA_PAIN_RATE, DoGirlNinjaPain, &s_GirlNinjaPain[2][0]},
447     },
448     {
449     {GIRLNINJA_PAIN_R3 + 0, GIRLNINJA_PAIN_RATE, DoGirlNinjaPain, &s_GirlNinjaPain[3][0]},
450     },
451     {
452     {GIRLNINJA_PAIN_R4 + 0, GIRLNINJA_PAIN_RATE, DoGirlNinjaPain, &s_GirlNinjaPain[4][0]},
453     },
454     };
455 
456 STATEp sg_GirlNinjaPain[] =
457     {
458     s_GirlNinjaPain[0],
459     s_GirlNinjaPain[1],
460     s_GirlNinjaPain[2],
461     s_GirlNinjaPain[3],
462     s_GirlNinjaPain[4]
463     };
464 
465 //////////////////////
466 //
467 // GIRLNINJA STICKY
468 //
469 //////////////////////
470 
471 #define GIRLNINJA_STICKY_RATE 32
472 ANIMATOR InitEnemyMine;
473 
474 STATE s_GirlNinjaSticky[5][6] =
475     {
476     {
477     {GIRLNINJA_THROW_R0 + 0, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[0][1]},
478     {GIRLNINJA_THROW_R0 + 0, GIRLNINJA_STICKY_RATE,       NullGirlNinja,          &s_GirlNinjaSticky[0][2]},
479     {GIRLNINJA_THROW_R0 + 1, 0 | SF_QUICK_CALL,         InitEnemyMine,      &s_GirlNinjaSticky[0][3]},
480     {GIRLNINJA_THROW_R0 + 1, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[0][4]},
481     {GIRLNINJA_THROW_R0 + 2, 0 | SF_QUICK_CALL,         InitActorDecide,    &s_GirlNinjaSticky[0][5]},
482     {GIRLNINJA_THROW_R0 + 2, GIRLNINJA_STICKY_RATE,       DoGirlNinjaMove,        &s_GirlNinjaSticky[0][5]},
483     },
484     {
485     {GIRLNINJA_THROW_R1 + 0, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[1][1]},
486     {GIRLNINJA_THROW_R1 + 0, GIRLNINJA_STICKY_RATE,       NullGirlNinja,          &s_GirlNinjaSticky[1][2]},
487     {GIRLNINJA_THROW_R1 + 1, 0 | SF_QUICK_CALL,         InitEnemyMine,      &s_GirlNinjaSticky[1][3]},
488     {GIRLNINJA_THROW_R1 + 1, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[1][4]},
489     {GIRLNINJA_THROW_R1 + 2, 0 | SF_QUICK_CALL,         InitActorDecide,    &s_GirlNinjaSticky[1][5]},
490     {GIRLNINJA_THROW_R1 + 2, GIRLNINJA_STICKY_RATE,       DoGirlNinjaMove,        &s_GirlNinjaSticky[1][5]},
491     },
492     {
493     {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[2][1]},
494     {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE,       NullGirlNinja,          &s_GirlNinjaSticky[2][2]},
495     {GIRLNINJA_THROW_R2 + 1, 0 | SF_QUICK_CALL,         InitEnemyMine,      &s_GirlNinjaSticky[2][3]},
496     {GIRLNINJA_THROW_R2 + 1, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[2][4]},
497     {GIRLNINJA_THROW_R2 + 2, 0 | SF_QUICK_CALL,         InitActorDecide,    &s_GirlNinjaSticky[2][5]},
498     {GIRLNINJA_THROW_R2 + 2, GIRLNINJA_STICKY_RATE,       DoGirlNinjaMove,        &s_GirlNinjaSticky[2][5]},
499     },
500     {
501     {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[3][1]},
502     {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE,       NullGirlNinja,          &s_GirlNinjaSticky[3][2]},
503     {GIRLNINJA_THROW_R2 + 1, 0 | SF_QUICK_CALL,         InitEnemyMine,      &s_GirlNinjaSticky[3][3]},
504     {GIRLNINJA_THROW_R2 + 1, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[3][4]},
505     {GIRLNINJA_THROW_R2 + 2, 0 | SF_QUICK_CALL,         InitActorDecide,    &s_GirlNinjaSticky[3][5]},
506     {GIRLNINJA_THROW_R2 + 2, GIRLNINJA_STICKY_RATE,       DoGirlNinjaMove,        &s_GirlNinjaSticky[3][5]},
507     },
508     {
509     {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[4][1]},
510     {GIRLNINJA_THROW_R2 + 0, GIRLNINJA_STICKY_RATE,       NullGirlNinja,          &s_GirlNinjaSticky[4][2]},
511     {GIRLNINJA_THROW_R2 + 1, 0 | SF_QUICK_CALL,         InitEnemyMine,      &s_GirlNinjaSticky[4][3]},
512     {GIRLNINJA_THROW_R2 + 1, GIRLNINJA_STICKY_RATE * 2,     NullGirlNinja,            &s_GirlNinjaSticky[4][4]},
513     {GIRLNINJA_THROW_R2 + 2, 0 | SF_QUICK_CALL,         InitActorDecide,    &s_GirlNinjaSticky[4][5]},
514     {GIRLNINJA_THROW_R2 + 2, GIRLNINJA_STICKY_RATE,       DoGirlNinjaMove,        &s_GirlNinjaSticky[4][5]},
515     },
516     };
517 
518 STATEp sg_GirlNinjaSticky[] =
519     {
520     s_GirlNinjaSticky[0],
521     s_GirlNinjaSticky[1],
522     s_GirlNinjaSticky[2],
523     s_GirlNinjaSticky[3],
524     s_GirlNinjaSticky[4]
525     };
526 
527 
528 //////////////////////
529 //
530 // GIRLNINJA CROSSBOW
531 //
532 //////////////////////
533 
534 #define GIRLNINJA_CROSSBOW_RATE 14
535 ANIMATOR InitEnemyCrossbow;
536 
537 STATE s_GirlNinjaCrossbow[5][5] =
538     {
539     {
540     {GIRLNINJA_FIRE_R0 + 0, GIRLNINJA_CROSSBOW_RATE * 2, NullGirlNinja, &s_GirlNinjaCrossbow[0][1]},
541     {GIRLNINJA_FIRE_R0 + 1, 0 | SF_QUICK_CALL, InitEnemyCrossbow, &s_GirlNinjaCrossbow[0][2]},
542     {GIRLNINJA_FIRE_R0 + 1, GIRLNINJA_CROSSBOW_RATE, NullGirlNinja, &s_GirlNinjaCrossbow[0][3]},
543     {GIRLNINJA_FIRE_R0 + 1, 0 | SF_QUICK_CALL, InitActorDecide, &s_GirlNinjaCrossbow[0][4]},
544     {GIRLNINJA_FIRE_R0 + 1, GIRLNINJA_CROSSBOW_RATE, DoGirlNinjaMove, &s_GirlNinjaCrossbow[0][4]},
545     },
546     {
547     {GIRLNINJA_FIRE_R1 + 0, GIRLNINJA_CROSSBOW_RATE * 2, NullGirlNinja, &s_GirlNinjaCrossbow[1][1]},
548     {GIRLNINJA_FIRE_R1 + 1, 0 | SF_QUICK_CALL, InitEnemyCrossbow, &s_GirlNinjaCrossbow[1][2]},
549     {GIRLNINJA_FIRE_R1 + 1, GIRLNINJA_CROSSBOW_RATE, NullGirlNinja, &s_GirlNinjaCrossbow[1][3]},
550     {GIRLNINJA_FIRE_R1 + 1, 0 | SF_QUICK_CALL, InitActorDecide, &s_GirlNinjaCrossbow[1][4]},
551     {GIRLNINJA_FIRE_R1 + 1, GIRLNINJA_CROSSBOW_RATE, DoGirlNinjaMove, &s_GirlNinjaCrossbow[1][4]},
552     },
553     {
554     {GIRLNINJA_FIRE_R2 + 0, GIRLNINJA_CROSSBOW_RATE * 2, NullGirlNinja, &s_GirlNinjaCrossbow[2][1]},
555     {GIRLNINJA_FIRE_R2 + 1, 0 | SF_QUICK_CALL, InitEnemyCrossbow, &s_GirlNinjaCrossbow[2][2]},
556     {GIRLNINJA_FIRE_R2 + 1, GIRLNINJA_CROSSBOW_RATE, NullGirlNinja, &s_GirlNinjaCrossbow[2][3]},
557     {GIRLNINJA_FIRE_R2 + 1, 0 | SF_QUICK_CALL, InitActorDecide, &s_GirlNinjaCrossbow[2][4]},
558     {GIRLNINJA_FIRE_R2 + 1, GIRLNINJA_CROSSBOW_RATE, DoGirlNinjaMove, &s_GirlNinjaCrossbow[2][4]},
559     },
560     {
561     {GIRLNINJA_FIRE_R3 + 0, GIRLNINJA_CROSSBOW_RATE * 2, NullGirlNinja, &s_GirlNinjaCrossbow[3][1]},
562     {GIRLNINJA_FIRE_R3 + 1, 0 | SF_QUICK_CALL, InitEnemyCrossbow, &s_GirlNinjaCrossbow[3][2]},
563     {GIRLNINJA_FIRE_R3 + 1, GIRLNINJA_CROSSBOW_RATE, NullGirlNinja, &s_GirlNinjaCrossbow[3][3]},
564     {GIRLNINJA_FIRE_R3 + 1, 0 | SF_QUICK_CALL, InitActorDecide, &s_GirlNinjaCrossbow[3][4]},
565     {GIRLNINJA_FIRE_R3 + 1, GIRLNINJA_CROSSBOW_RATE, DoGirlNinjaMove, &s_GirlNinjaCrossbow[3][4]},
566     },
567     {
568     {GIRLNINJA_FIRE_R4 + 0, GIRLNINJA_CROSSBOW_RATE * 2, NullGirlNinja, &s_GirlNinjaCrossbow[4][1]},
569     {GIRLNINJA_FIRE_R4 + 1, 0 | SF_QUICK_CALL, InitEnemyCrossbow, &s_GirlNinjaCrossbow[4][2]},
570     {GIRLNINJA_FIRE_R4 + 1, GIRLNINJA_CROSSBOW_RATE, NullGirlNinja, &s_GirlNinjaCrossbow[4][3]},
571     {GIRLNINJA_FIRE_R4 + 1, 0 | SF_QUICK_CALL, InitActorDecide, &s_GirlNinjaCrossbow[4][4]},
572     {GIRLNINJA_FIRE_R4 + 1, GIRLNINJA_CROSSBOW_RATE, DoGirlNinjaMove, &s_GirlNinjaCrossbow[4][4]},
573     },
574     };
575 
576 
577 STATEp sg_GirlNinjaCrossbow[] =
578     {
579     s_GirlNinjaCrossbow[0],
580     s_GirlNinjaCrossbow[1],
581     s_GirlNinjaCrossbow[2],
582     s_GirlNinjaCrossbow[3],
583     s_GirlNinjaCrossbow[4]
584     };
585 
586 
587 
588 //////////////////////
589 //
590 // GIRLNINJA DIE
591 //
592 //////////////////////
593 
594 #define GIRLNINJA_DIE_RATE 30
595 ANIMATOR DoGirlNinjaSpecial;
596 
597 STATE s_GirlNinjaDie[] =
598     {
599     {GIRLNINJA_DIE + 0, GIRLNINJA_DIE_RATE*2, NullGirlNinja, &s_GirlNinjaDie[1]},
600     {GIRLNINJA_DIE + 1, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[2]},
601     {GIRLNINJA_DIE + 2, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[3]},
602     {GIRLNINJA_DIE + 3, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[4]},
603     {GIRLNINJA_DIE + 4, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[5]},
604     {GIRLNINJA_DIE + 5, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[6]},
605     {GIRLNINJA_DIE + 6, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[7]},
606     {GIRLNINJA_DIE + 6, SF_QUICK_CALL , DoGirlNinjaSpecial, &s_GirlNinjaDie[8]},
607     {GIRLNINJA_DIE + 7, GIRLNINJA_DIE_RATE, NullGirlNinja, &s_GirlNinjaDie[9]},
608     {GIRLNINJA_DIE + 8, SF_QUICK_CALL , QueueFloorBlood, &s_GirlNinjaDie[10]},
609     {GIRLNINJA_DIE + 8, GIRLNINJA_DIE_RATE, DoActorDebris, &s_GirlNinjaDie[10]},
610     };
611 
612 STATE s_GirlNinjaDead[] =
613     {
614     {GIRLNINJA_DIE + 6, GIRLNINJA_DIE_RATE, DoActorDebris, &s_GirlNinjaDead[1]},
615     {GIRLNINJA_DIE + 7, SF_QUICK_CALL , DoGirlNinjaSpecial, &s_GirlNinjaDead[2]},
616     {GIRLNINJA_DIE + 7, GIRLNINJA_DIE_RATE, DoActorDebris, &s_GirlNinjaDead[3]},
617     {GIRLNINJA_DIE + 8, SF_QUICK_CALL , QueueFloorBlood,&s_GirlNinjaDead[4]},
618     {GIRLNINJA_DIE + 8, GIRLNINJA_DIE_RATE, DoActorDebris, &s_GirlNinjaDead[4]},
619     };
620 
621 
622 STATE s_GirlNinjaDeathJump[] =
623     {
624     {GIRLNINJA_DIE + 0, GIRLNINJA_DIE_RATE, DoActorDeathMove, &s_GirlNinjaDeathJump[1]},
625     {GIRLNINJA_DIE + 1, GIRLNINJA_DIE_RATE, DoActorDeathMove, &s_GirlNinjaDeathJump[2]},
626     {GIRLNINJA_DIE + 2, GIRLNINJA_DIE_RATE, DoActorDeathMove, &s_GirlNinjaDeathJump[2]},
627     };
628 
629 STATE s_GirlNinjaDeathFall[] =
630     {
631     {GIRLNINJA_DIE + 3, GIRLNINJA_DIE_RATE, DoActorDeathMove, &s_GirlNinjaDeathFall[1]},
632     {GIRLNINJA_DIE + 4, GIRLNINJA_DIE_RATE, DoActorDeathMove, &s_GirlNinjaDeathFall[1]},
633     };
634 
635 /*
636 STATEp *Stand[MAX_WEAPONS];
637 STATEp *Run;
638 STATEp *Jump;
639 STATEp *Fall;
640 STATEp *Crawl;
641 STATEp *Swim;
642 STATEp *Fly;
643 STATEp *Rise;
644 STATEp *Sit;
645 STATEp *Look;
646 STATEp *Climb;
647 STATEp *Pain;
648 STATEp *Death1;
649 STATEp *Death2;
650 STATEp *Dead;
651 STATEp *DeathJump;
652 STATEp *DeathFall;
653 STATEp *CloseAttack[2];
654 STATEp *Attack[6];
655 STATEp *Special[2];
656 */
657 
658 STATEp sg_GirlNinjaDie[] =
659     {
660     s_GirlNinjaDie
661     };
662 
663 STATEp sg_GirlNinjaDead[] =
664     {
665     s_GirlNinjaDead
666     };
667 
668 STATEp sg_GirlNinjaDeathJump[] =
669     {
670     s_GirlNinjaDeathJump
671     };
672 
673 STATEp sg_GirlNinjaDeathFall[] =
674     {
675     s_GirlNinjaDeathFall
676     };
677 
678 /*
679 
680  !AIC - Collection of states that connect action to states
681 
682 */
683 
684 ACTOR_ACTION_SET GirlNinjaActionSet =
685     {
686     sg_GirlNinjaStand,
687     sg_GirlNinjaRun,
688     sg_GirlNinjaJump,
689     sg_GirlNinjaFall,
690     NULL,
691     NULL,
692     NULL,
693     sg_GirlNinjaRise,
694     sg_GirlNinjaSit,
695     NULL,
696     NULL,
697     sg_GirlNinjaPain,
698     sg_GirlNinjaDie,
699     NULL,
700     sg_GirlNinjaDead,
701     sg_GirlNinjaDeathJump,
702     sg_GirlNinjaDeathFall,
703     {sg_GirlNinjaCrossbow, sg_GirlNinjaSticky},
704     {800, 1024},
705     {sg_GirlNinjaCrossbow, sg_GirlNinjaSticky},
706     {800, 1024},
707     {NULL},
708     sg_GirlNinjaDuck,
709     NULL
710     };
711 
712 int
SetupGirlNinja(short SpriteNum)713 SetupGirlNinja(short SpriteNum)
714     {
715     SPRITEp sp = &sprite[SpriteNum];
716     USERp u;
717     ANIMATOR DoActorDecide;
718     short pic = sp->picnum;
719 
720     if (TEST(sp->cstat, CSTAT_SPRITE_RESTORE))
721         {
722         u = User[SpriteNum];
723         ASSERT(u);
724         }
725     else
726         {
727         User[SpriteNum] = u = SpawnUser(SpriteNum, GIRLNINJA_RUN_R0, s_GirlNinjaRun[0]);
728         u->Health = 100;
729         }
730 
731     u->StateEnd = s_GirlNinjaDie;
732     u->Rot = sg_GirlNinjaRun;
733     sp->xrepeat = 51;
734     sp->yrepeat = 43;
735 
736     u->Attrib = &GirlNinjaAttrib;
737     sp->pal = u->spal = 26;
738     EnemyDefaults(SpriteNum, &GirlNinjaActionSet, &GirlNinjaPersonality);
739 
740     ChangeState(SpriteNum, s_GirlNinjaRun[0]);
741     DoActorSetSpeed(SpriteNum, NORM_SPEED);
742 
743     u->Radius = 280;
744     RESET(u->Flags, SPR_XFLIP_TOGGLE);
745 
746     return (0);
747     }
748 
749 
750 int
DoGirlNinjaMove(short SpriteNum)751 DoGirlNinjaMove(short SpriteNum)
752     {
753     USERp u = User[SpriteNum];
754     SPRITEp sp = User[SpriteNum]->SpriteP;
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     SPRITEp sp = User[SpriteNum]->SpriteP;
819 
820     if(u->WaitTics > 0) u->WaitTics -= ACTORMOVETICS;
821 
822     if (TEST(u->Flags, SPR_SLIDING) && !TEST(u->Flags, SPR_CLIMBING) && !TEST(u->Flags, SPR_JUMPING|SPR_FALLING))
823         DoActorSlide(SpriteNum);
824 
825     if (!TEST(u->Flags, SPR_CLIMBING) && !TEST(u->Flags, SPR_JUMPING|SPR_FALLING))
826         KeepActorOnFloor(SpriteNum);
827 
828     DoActorSectorDamage(SpriteNum);
829 
830     return (0);
831     }
832 
833 
DoGirlNinjaPain(short SpriteNum)834 int DoGirlNinjaPain(short SpriteNum)
835 {
836     SPRITEp sp = &sprite[SpriteNum];
837     USERp u = User[SpriteNum];
838 
839     NullGirlNinja(SpriteNum);
840 
841     if ((u->WaitTics -= ACTORMOVETICS) <= 0)
842         InitActorDecide(SpriteNum);
843 
844     return(0);
845 }
846 
DoGirlNinjaSpecial(short SpriteNum)847 int DoGirlNinjaSpecial(short SpriteNum)
848     {
849     SPRITEp sp = &sprite[SpriteNum];
850     USERp u = User[SpriteNum];
851 
852     if(u->spal == PALETTE_PLAYER5)
853         {
854         RESET(sp->cstat,CSTAT_SPRITE_TRANSLUCENT);
855         sp->hitag = 0;
856         sp->shade = -10;
857         }
858 
859     return(0);
860     }
861 
862 
863 #include "saveable.h"
864 
865 static saveable_code saveable_girlninj_code[] = {
866 	SAVE_CODE(SetupGirlNinja),
867 	SAVE_CODE(DoGirlNinjaMove),
868 	SAVE_CODE(GirlNinjaJumpActionFunc),
869 	SAVE_CODE(NullGirlNinja),
870 	SAVE_CODE(DoGirlNinjaPain),
871 	SAVE_CODE(DoGirlNinjaSpecial),
872 };
873 
874 static saveable_data saveable_girlninj_data[] = {
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 	// code
921 	saveable_girlninj_code,
922 	SIZ(saveable_girlninj_code),
923 
924 	// data
925 	saveable_girlninj_data,
926 	SIZ(saveable_girlninj_data)
927 };
928