1 /* DooM2D: Midnight on the Firing Line
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 module d2dplayer is "monster" "Player";
27 public field(Actor) uint plrstate;
28 public field(Actor) int air; // bit 30 set: not in the water
30 public field(Actor) int looky;
32 field(Actor) uint aitime; // something connected with BFG shot
35 const PL_RUN = 8; // 24 for "formula1"
44 public const PL_AQUA_AIR = 1091+9;
46 public const PL_AIR_NOTUW_BIT = BIT(30);
47 public const PL_AIR_MASK = BIT(30)-1;
50 // setup actor animations
51 public void initializeAnim () {
53 animClearFrames("monster", "Player", "stand");
54 animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playa1a2.vga");
55 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "sprites/monsters/player/play_a1_a2.vga"); // shooting down
56 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "sprites/monsters/player/playx1x2.vga"); // aiming up
57 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "sprites/monsters/player/playy1y2.vga"); // shooting up
58 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "sprites/monsters/player/playz1z2.vga"); // aiming down up
59 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "monsters/man/graphics/attack/playf1f2.vga"); // shooting forward
60 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "monsters/man/graphics/pain/playg1g2.vga");
61 animAddFrame("monster", "Player", "stand", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playa1a2_mirrored.vga");
65 animClearFrames("monster", "Player", "sleep");
67 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playa1a2.vga");
68 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playa1a2.vga");
69 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playa1a2.vga");
70 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playb1b2.vga");
71 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playb1b2.vga");
72 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playb1b2.vga");
74 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playa1a2_mirrored.vga");
75 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playa1a2_mirrored.vga");
76 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playa1a2_mirrored.vga");
77 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playb1b2_mirrored.vga");
78 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playb1b2_mirrored.vga");
79 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playb1b2_mirrored.vga");
81 animClearFrames("monster", "Player", "go");
83 animAddFrame("monster", "Player", "go", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playa1a2.vga");
84 animAddFrame("monster", "Player", "go", ACTOR_DIR_LEFT, "monsters/man/graphics/go/playc1c2.vga");
85 animAddFrame("monster", "Player", "go", ACTOR_DIR_LEFT, "monsters/man/graphics/go/playd1d2.vga");
86 animAddFrame("monster", "Player", "go", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playa1a2.vga");
87 animAddFrame("monster", "Player", "go", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playb1b2.vga");
88 animAddFrame("monster", "Player", "go", ACTOR_DIR_LEFT, "monsters/man/graphics/go/playd1d2.vga");
90 animAddFrame("monster", "Player", "go", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playa1a2_mirrored.vga");
91 animAddFrame("monster", "Player", "go", ACTOR_DIR_RIGHT, "monsters/man/graphics/go/playc1c2_mirrored.vga");
92 animAddFrame("monster", "Player", "go", ACTOR_DIR_RIGHT, "monsters/man/graphics/go/playd1d2_mirrored.vga");
93 animAddFrame("monster", "Player", "go", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playa1a2_mirrored.vga");
94 animAddFrame("monster", "Player", "go", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playb1b2_mirrored.vga");
95 animAddFrame("monster", "Player", "go", ACTOR_DIR_RIGHT, "monsters/man/graphics/go/playd1d2_mirrored.vga");
97 animClearFrames("monster", "Player", "pain");
99 animAddFrame("monster", "Player", "pain", ACTOR_DIR_LEFT, "monsters/man/graphics/pain/playg1g2.vga");
101 animAddFrame("monster", "Player", "pain", ACTOR_DIR_RIGHT, "monsters/man/graphics/pain/playg1g2_mirrored.vga");
103 animClearFrames("monster", "Player", "wait");
105 animAddFrame("monster", "Player", "wait", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playe1e2.vga");
107 animAddFrame("monster", "Player", "wait", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playe1e2_mirrored.vga");
109 animClearFrames("monster", "Player", "attack");
111 animAddFrame("monster", "Player", "attack", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playe1e2.vga");
112 animAddFrame("monster", "Player", "attack", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playe1e2.vga");
113 animAddFrame("monster", "Player", "attack", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playe1e2.vga");
114 animAddFrame("monster", "Player", "attack", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playe1e2.vga");
115 animAddFrame("monster", "Player", "attack", ACTOR_DIR_LEFT, "monsters/man/graphics/attack/playf1f2.vga");
116 animAddFrame("monster", "Player", "attack", ACTOR_DIR_LEFT, "monsters/man/graphics/attack/playf1f2.vga");
118 animAddFrame("monster", "Player", "attack", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playe1e2_mirrored.vga");
119 animAddFrame("monster", "Player", "attack", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playe1e2_mirrored.vga");
120 animAddFrame("monster", "Player", "attack", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playe1e2_mirrored.vga");
121 animAddFrame("monster", "Player", "attack", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playe1e2_mirrored.vga");
122 animAddFrame("monster", "Player", "attack", ACTOR_DIR_RIGHT, "monsters/man/graphics/attack/playf1f2_mirrored.vga");
123 animAddFrame("monster", "Player", "attack", ACTOR_DIR_RIGHT, "monsters/man/graphics/attack/playf1f2_mirrored.vga");
125 animClearFrames("monster", "Player", "die");
127 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playh0.vga");
128 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playh0.vga");
129 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playh0.vga");
130 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playh0.vga");
131 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playi0.vga");
132 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playi0.vga");
133 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playi0.vga");
134 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playi0.vga");
135 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playj0.vga");
136 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playj0.vga");
137 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playj0.vga");
138 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playj0.vga");
139 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playk0.vga");
140 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playk0.vga");
141 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playk0.vga");
142 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playk0.vga");
143 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playl0.vga");
144 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playl0.vga");
145 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playl0.vga");
146 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playl0.vga");
147 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playm0.vga");
148 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playm0.vga");
149 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playm0.vga");
150 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playm0.vga");
152 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playh0.vga");
153 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playh0.vga");
154 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playh0.vga");
155 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playh0.vga");
156 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playi0.vga");
157 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playi0.vga");
158 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playi0.vga");
159 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playi0.vga");
160 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playj0.vga");
161 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playj0.vga");
162 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playj0.vga");
163 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playj0.vga");
164 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playk0.vga");
165 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playk0.vga");
166 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playk0.vga");
167 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playk0.vga");
168 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playl0.vga");
169 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playl0.vga");
170 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playl0.vga");
171 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playl0.vga");
172 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playm0.vga");
173 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playm0.vga");
174 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playm0.vga");
175 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playm0.vga");
177 animClearFrames("monster", "Player", "slop");
179 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playo0.vga");
180 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playo0.vga");
181 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playp0.vga");
182 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playp0.vga");
183 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playq0.vga");
184 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playq0.vga");
185 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playr0.vga");
186 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playr0.vga");
187 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/plays0.vga");
188 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/plays0.vga");
189 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playt0.vga");
190 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playt0.vga");
191 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playu0.vga");
192 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playu0.vga");
193 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playv0.vga");
194 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playv0.vga");
196 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playo0.vga");
197 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playo0.vga");
198 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playp0.vga");
199 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playp0.vga");
200 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playq0.vga");
201 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playq0.vga");
202 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playr0.vga");
203 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playr0.vga");
204 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/plays0.vga");
205 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/plays0.vga");
206 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playt0.vga");
207 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playt0.vga");
208 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playu0.vga");
209 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playu0.vga");
210 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playv0.vga");
211 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playv0.vga");
213 animClearFrames("monster", "Player", "dead");
215 animAddFrame("monster", "Player", "dead", ACTOR_DIR_LEFT, "monsters/man/graphics/dead/playn0.vga");
217 animAddFrame("monster", "Player", "dead", ACTOR_DIR_RIGHT, "monsters/man/graphics/dead/playn0.vga");
219 animClearFrames("monster", "Player", "mess");
221 animAddFrame("monster", "Player", "mess", ACTOR_DIR_LEFT, "monsters/man/graphics/mess/playw0.vga");
223 animAddFrame("monster", "Player", "mess", ACTOR_DIR_RIGHT, "monsters/man/graphics/mess/playw0.vga");
228 // change actor animation
229 public void setAnim (Actor me, string state) {
232 case "sleep": me.animname = "sleep"; me.animstr = "AAABBB"; break;
233 case "go": me.animname = "go"; me.animstr = "ACDABD"; break;
234 case "pain": me.animname = "pain"; me.animstr = "G"; break;
235 case "wait": me.animname = "wait"; me.animstr = "E"; break;
236 case "attack": me.animname = "attack"; me.animstr = "EEEEFF"; break;
237 case "die": me.animname = "die"; me.animstr = "HHHHIIIIJJJJKKKKLLLLMMMM"; break;
238 case "slop": me.animname = "slop"; me.animstr = "OOPPQQRRSSTTUUVV"; break;
239 case "dead": me.animname = "dead"; me.animstr = "N"; break;
240 case "mess": me.animname = "mess"; me.animstr = "W"; break;
241 case "run": me.animname = "go"; me.animstr = "ACDABD"; break;
242 case "climb": me.animname = "go"; me.animstr = "ACDABD"; break;
243 case "runout": me.animname = "go"; me.animstr = "ACDABD"; break;
244 case "shoot": me.animname = "attack"; me.animstr = "EEEEFF"; break;
245 case "revive": me.animname = "revive"; me.animstr = "MMMMLLLLKKKKJJJJIIIIHHHH"; break;
246 default: me.animname = "sleep"; me.animstr = "AAABBB"; break;
248 me.actorSetAnimation(state);
252 // setup actor properties
253 public void initialize (Actor me) {
254 // `classname` and `classtype` will be set by the engine
255 //me.classname = "Player";
256 //me.classtype = "monster";
259 me.hitpoints = me.life = 400;
266 me.plrstate = PLST_STAND;
268 me.air = PL_AIR|PL_AIR_NOTUW_BIT;
269 //me.setAnim("sleep");
271 // add attached light
273 me.attLightYOfs = -12;
274 me.attachedLightColorless(96, 44);
276 me.flags |= AF_NOANIMATE;
277 if (me.plrnum == 1) setCameraChick(me);
282 public void think (Actor me) {
284 //writeln("canstand: ", Z_canstand(me.x, me.y, me.radius));
285 //writeln("cangodown: ", Z_cangodown(me.x, me.y, me.radius));
286 //if (((st = Z_moveobj(&me.o))&Z_FALLOUT) && me.y >= MapHeight*TileSize+50) {
287 //int st = Z_moveobj(me); dumpSt(st); writeln(st);
290 /*if (me.plrnum == 1)*/ {
291 int tiltHeight = getMapViewHeight()/4;
293 if (vy < -tiltHeight) vy = -tiltHeight; else if (vy > tiltHeight) vy = tiltHeight;
297 if (me.atm > 0) --me.atm;
298 if (getPlayerButtons(me.plrnum)&PLK_FIRE) {
301 me.target = actorSpawn("switch", "DummyPressActor", me.x, me.y-12, ACTOR_DIR_LEFT);
302 me.target.atm = 2; // 1: act; 0: die
309 void dumpSt (int st) {
311 if (st == 0) { writeln(" NONE"); return; }
312 if (st&Z_HITWALL) write(" Z_HITWALL");
313 if (st&Z_HITCEIL) write(" Z_HITCEIL");
314 if (st&Z_HITLAND) write(" Z_HITLAND");
315 if (st&Z_FALLOUT) write(" Z_FALLOUT");
316 if (st&Z_INWATER) write(" Z_INWATER");
317 if (st&Z_HITWATER) write(" Z_HITWATER");
318 if (st&Z_HITAIR) write(" Z_HITAIR");
319 if (st&Z_BLOCK) write(" Z_BLOCK");
324 void jump (Actor me, int st) {
325 if (Z_canbreathe(me.x, me.y, me.radius, me.height)) {
326 /*if (me.air < PL_AIR)*/ me.air = PL_AIR|PL_AIR_NOTUW_BIT;
328 int air = (me.air&PL_AIR_MASK)-1;
331 //!PL_hit(me, 10, -3, HIT_WATER);
332 } else if ((air&31) == 0) {
333 miscBubble.spawn(me.x, me.y-20, 0, 0, 5);
335 //miscBubble.spawn(me.x, me.y-20, 0, 0, 5);
339 if (!p_ghost && ISKEY(KB_JUMP)) {
343 if (Z_canstand(OBJT_PLAYER, me.x, me.y, me.radius)) me.yv = -PL_JUMP;
344 else if (st&Z_INWATER) me.yv = -PL_SWUP;
348 //writeln("0: me.yv=", me.yv);
349 if (getPlayerButtons(me.plrnum)&PLK_JUMP) {
350 if (Z_canstand(me.x, me.y, me.radius)) {
353 if (st&Z_INWATER) me.yv = -PL_SWUP;
356 //writeln("1: me.yv=", me.yv);
360 void godown (Actor me) {
362 if (ISKEY(KB_DOWN) && ISKEY(KB_UP)) {
363 //fprintf(stderr, "trying to go down\n");
364 if (Z_cangodown(OBJT_PLAYER, me.x, me.y, me.radius)) {
365 //fprintf(stderr, "going down\n");
373 void PL_act (Actor me) {
375 //if (me.plrnum != 1) return;
377 auto btn = getPlayerButtons(me.plrnum);
378 if (me.plrnum != 1) btn = 0;
379 //writeln("left: ", (btn&PLK_LEFT), "; right: ", (btn&PLK_RIGHT));
381 //if ((btn&PLK_DOWN) && p_ghost) me.yv = 4;
382 //if ((btn&PLK_UP) && p_ghost) me.yv = -4;
384 if (--me.aitime < 0) me.aitime = 0;
386 //SW_press(me.x, me.y, me.radius, me.height, 4|me.keys, me.id);
388 //if (!me.suit && (g_time&15) == 0) PL_hit(me, Z_getacid(me.x, me.y, me.radius, me.height), -3, HIT_SOME);
390 if (me.plrstate != PLST_FALL && me.plrstate != PLST_PLOUT) {
392 //writeln("st=", st);
394 if ((st&Z_FALLOUT) && me.y >= MapHeight*TileSize+50) {
395 writeln(" FALLING!");
396 switch (me.plrstate) {
404 //me.s = Z_sound(snd[10], 128);
406 //if (g_dm) --me.frag;
409 me.plrstate = PLST_FALL;
415 //if (p_ghost) { me.yv = me.vy = 0; }
417 if (st&Z_HITWATER) Z_splash(me, PL_RAD+PL_HT, st);
419 //!if ((me.f&PLF_FIRE) && me.fire != 2) me.f &= ~PLF_FIRE;
422 if ((btn&(PLK_UP|PLK_DOWN)) != (PLK_UP|PLK_DOWN)) {
426 } else if (btn&PLK_DOWN) {
431 //me.f &= ~(PLF_UP|PLF_DOWN);
432 me.looky = Z_dec(me.looky, 5);
436 //!if ((btn&PLK_USE)) SW_press(me.x, me.y, me.radius, me.height, 1|me.keys, me.id);
439 if (me.fire) --me.fire;
440 if (me.cwpn) --me.cwpn;
441 if (me.csnd) --me.csnd;
442 if (me.invl) --me.invl;
443 if (me.suit) --me.suit;
446 switch (me.plrstate) {
449 //!if (!dieanim[++me.s]) { me.plrstate = PLST_DEAD; MN_killedp(); }
450 me.xv = Z_dec(me.xv, 1);
454 //!if (!slopanim[++me.s]) { me.plrstate = PLST_MESS; MN_killedp(); }
455 me.xv = Z_dec(me.xv, 1);
465 //!if (p_fly) SMK_gas(me.x, me.y-2, 2, 3, me.xv+me.vx, me.yv+me.vy, 128);
467 if ((me.s += abs(me.xv)/2) >= 24) me.s %= 24;
469 if (!(btn&(PLK_LEFT|PLK_RIGHT))) {
470 if (me.xv) me.xv = Z_dec(me.xv, 1); else me.plrstate = PLST_STAND;
474 if (me.xv < PL_RUN && (btn&PLK_RIGHT)) {
477 } else if (PL_RUN > 8) {
478 //!SMK_gas(me.x, me.y-2, 2, 3, me.xv+me.vx, me.yv+me.vy, 32);
481 if (me.xv > -PL_RUN && (btn&PLK_LEFT)) {
484 } else if (PL_RUN > 8) {
485 //!SMK_gas(me.x, me.y-2, 2, 3, me.xv+me.vx, me.yv+me.vy, 32);
496 //!if (p_fly) SMK_gas(me.x, me.y-2, 2, 3, me.xv+me.vx, me.yv+me.vy, 128);
498 if ((btn&(PLK_LEFT|PLK_RIGHT)) != (PLK_LEFT|PLK_RIGHT)) {
500 me.plrstate = PLST_GO;
503 } else if (btn&PLK_RIGHT) {
504 me.plrstate = PLST_GO;
513 me.xv = Z_dec(me.xv, 1);
515 for (int f = 0; f < PLK_MAX; ++f) {
517 if (me.plrstate != PLST_PLOUT) MN_spawn_deadpl(&me. me.color, (me.plrstate == PLST_MESS ? 1 : 0));
519 if (g_dm) { G_respawn_player(me); break; }
520 if (g_plrcount == 1) {
521 if (--me.lives == 0) {
527 me.dir = dm_pos[0].dir;
534 me.dir = dm_pos[0].dir;
538 me.dir = dm_pos[1].dir;
545 if (--me.s <= 0) me.plrstate = PLST_PLOUT;
553 void PL_draw (Actor me) {
555 //static const int wytab[] = {-1, -2, -1, 0};
560 switch (me.plrstate) {
566 } else if (me.pain) {
569 wx = (me.d ? 2 : -2);
589 wx = (me.d ? 2 : -2);
593 w = (me.f&PLF_FIRE ? 'B' : 'A');
594 wx = (me.d ? 2 : -2);
603 //s = slopanim[me.s];
611 if (me.wpn == PWPN_FIST) w = 0;
612 if (w) Z_drawspr(me.o.x+wx, me.o.y+wy, &wpn[me.wpn&0x7f][w-'A'], me.d);
613 if (s) Z_drawmanspr(me.o.x, me.o.y, &spr[(s-'A')*2+me.d], sprd[(s-'A')*2+me.d], me.color);