Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | pmbaty | 1 | /* |
2 | * src/e_box.c |
||
3 | * |
||
4 | * Copyright (C) 1998-2002 BigOrno (bigorno@bigorno.net). All rights reserved. |
||
5 | * |
||
6 | * The use and distribution terms for this software are contained in the file |
||
7 | * named README, which can be found in the root of this distribution. By |
||
8 | * using this software in any fashion, you are agreeing to be bound by the |
||
9 | * terms of this license. |
||
10 | * |
||
11 | * You must not remove this notice, or any other, from this software. |
||
12 | */ |
||
13 | |||
14 | #include "system.h" |
||
15 | #include "game.h" |
||
16 | #include "ents.h" |
||
17 | #include "e_box.h" |
||
18 | |||
19 | #include "e_bullet.h" |
||
20 | #include "e_bomb.h" |
||
21 | #include "e_rick.h" |
||
22 | #include "maps.h" |
||
23 | #include "util.h" |
||
24 | |||
25 | /* |
||
26 | * FIXME this is because the same structure is used |
||
27 | * for all entities. Need to replace this w/ an inheritance |
||
28 | * solution. |
||
29 | */ |
||
30 | #define cnt c1 |
||
31 | |||
32 | /* |
||
33 | * Constants |
||
34 | */ |
||
35 | #define SEQ_INIT 0x0A |
||
36 | |||
37 | /* |
||
38 | * Prototypes |
||
39 | */ |
||
40 | static void explode (U8); |
||
41 | |||
42 | |||
43 | /* |
||
44 | * Entity action |
||
45 | * |
||
46 | * ASM 245A |
||
47 | */ |
||
48 | void e_box_action (U8 e) |
||
49 | { |
||
50 | static U8 sp[] = {0x24, 0x25, 0x26, 0x27, 0x28}; /* explosion sprites sequence */ |
||
51 | |||
52 | if (ent_ents[e].n & ENT_LETHAL) |
||
53 | { |
||
54 | /* |
||
55 | * box is lethal i.e. exploding |
||
56 | * play sprites sequence then stop |
||
57 | */ |
||
58 | ent_ents[e].sprite = sp[ent_ents[e].cnt >> 1]; |
||
59 | |||
60 | if (--ent_ents[e].cnt == 0) |
||
61 | { |
||
62 | ent_ents[e].n = 0; |
||
63 | map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT; |
||
64 | } |
||
65 | } |
||
66 | else |
||
67 | { |
||
68 | if (E_RICK_STTST (E_RICK_STZOMBIE)) |
||
69 | return; |
||
70 | |||
71 | /* |
||
72 | * not lethal: check to see if triggered |
||
73 | */ |
||
74 | if (e_rick_boxtest (e)) |
||
75 | { |
||
76 | /* rick: collect bombs or bullets and stop */ |
||
77 | syssnd_play (WAV_BOX, 1); |
||
78 | |||
79 | if (ent_ents[e].n == 0x10) |
||
80 | game_bombs = GAME_BOMBS_INIT; |
||
81 | else /* 0x11 */ |
||
82 | game_bullets = GAME_BULLETS_INIT; |
||
83 | |||
84 | ent_ents[e].n = 0; |
||
85 | map_marks[ent_ents[e].mark].ent |= MAP_MARK_NACT; |
||
86 | } |
||
87 | else if (E_RICK_STTST (E_RICK_STSTOP) && u_fboxtest (e, e_rick_stop_x, e_rick_stop_y)) |
||
88 | explode (e); // rick's stick: explode |
||
89 | else if (E_BULLET_ENT.n && u_fboxtest(e, e_bullet_xc, e_bullet_yc)) |
||
90 | { |
||
91 | /* bullet: explode (and stop bullet) */ |
||
92 | E_BULLET_ENT.n = 0; |
||
93 | explode (e); |
||
94 | } |
||
95 | else if (e_bomb_lethal && e_bomb_hit (e)) |
||
96 | explode (e); // bomb: explode |
||
97 | } |
||
98 | } |
||
99 | |||
100 | |||
101 | /* |
||
102 | * Explode when |
||
103 | */ |
||
104 | static void explode (U8 e) |
||
105 | { |
||
106 | ent_ents[e].cnt = SEQ_INIT; |
||
107 | ent_ents[e].n |= ENT_LETHAL; |
||
108 | syssnd_play (WAV_EXPLODE, 1); |
||
109 | } |