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;
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 const PL_AQUA_AIR = 1091;
47 // setup actor animations
48 public void initializeAnim () {
50 animClearFrames("monster", "Player", "stand");
51 animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playa1a2.vga");
52 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "sprites/monsters/player/play_a1_a2.vga"); // shooting down
53 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "sprites/monsters/player/playx1x2.vga"); // aiming up
54 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "sprites/monsters/player/playy1y2.vga"); // shooting up
55 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "sprites/monsters/player/playz1z2.vga"); // aiming down up
56 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "monsters/man/graphics/attack/playf1f2.vga"); // shooting forward
57 //animAddFrame("monster", "Player", "stand", ACTOR_DIR_LEFT, "monsters/man/graphics/pain/playg1g2.vga");
58 animAddFrame("monster", "Player", "stand", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playa1a2_mirrored.vga");
62 animClearFrames("monster", "Player", "sleep");
64 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playa1a2.vga");
65 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playa1a2.vga");
66 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playa1a2.vga");
67 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playb1b2.vga");
68 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playb1b2.vga");
69 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playb1b2.vga");
71 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playa1a2_mirrored.vga");
72 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playa1a2_mirrored.vga");
73 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playa1a2_mirrored.vga");
74 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playb1b2_mirrored.vga");
75 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playb1b2_mirrored.vga");
76 animAddFrame("monster", "Player", "sleep", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playb1b2_mirrored.vga");
78 animClearFrames("monster", "Player", "go");
80 animAddFrame("monster", "Player", "go", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playa1a2.vga");
81 animAddFrame("monster", "Player", "go", ACTOR_DIR_LEFT, "monsters/man/graphics/go/playc1c2.vga");
82 animAddFrame("monster", "Player", "go", ACTOR_DIR_LEFT, "monsters/man/graphics/go/playd1d2.vga");
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/shared/playb1b2.vga");
85 animAddFrame("monster", "Player", "go", ACTOR_DIR_LEFT, "monsters/man/graphics/go/playd1d2.vga");
87 animAddFrame("monster", "Player", "go", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playa1a2_mirrored.vga");
88 animAddFrame("monster", "Player", "go", ACTOR_DIR_RIGHT, "monsters/man/graphics/go/playc1c2_mirrored.vga");
89 animAddFrame("monster", "Player", "go", ACTOR_DIR_RIGHT, "monsters/man/graphics/go/playd1d2_mirrored.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/shared/playb1b2_mirrored.vga");
92 animAddFrame("monster", "Player", "go", ACTOR_DIR_RIGHT, "monsters/man/graphics/go/playd1d2_mirrored.vga");
94 animClearFrames("monster", "Player", "pain");
96 animAddFrame("monster", "Player", "pain", ACTOR_DIR_LEFT, "monsters/man/graphics/pain/playg1g2.vga");
98 animAddFrame("monster", "Player", "pain", ACTOR_DIR_RIGHT, "monsters/man/graphics/pain/playg1g2_mirrored.vga");
100 animClearFrames("monster", "Player", "wait");
102 animAddFrame("monster", "Player", "wait", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playe1e2.vga");
104 animAddFrame("monster", "Player", "wait", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playe1e2_mirrored.vga");
106 animClearFrames("monster", "Player", "attack");
108 animAddFrame("monster", "Player", "attack", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playe1e2.vga");
109 animAddFrame("monster", "Player", "attack", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playe1e2.vga");
110 animAddFrame("monster", "Player", "attack", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playe1e2.vga");
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/attack/playf1f2.vga");
113 animAddFrame("monster", "Player", "attack", ACTOR_DIR_LEFT, "monsters/man/graphics/attack/playf1f2.vga");
115 animAddFrame("monster", "Player", "attack", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playe1e2_mirrored.vga");
116 animAddFrame("monster", "Player", "attack", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playe1e2_mirrored.vga");
117 animAddFrame("monster", "Player", "attack", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playe1e2_mirrored.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/attack/playf1f2_mirrored.vga");
120 animAddFrame("monster", "Player", "attack", ACTOR_DIR_RIGHT, "monsters/man/graphics/attack/playf1f2_mirrored.vga");
122 animClearFrames("monster", "Player", "die");
124 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playh0.vga");
125 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playh0.vga");
126 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playh0.vga");
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/playi0.vga");
129 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playi0.vga");
130 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playi0.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/playj0.vga");
133 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playj0.vga");
134 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playj0.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/playk0.vga");
137 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playk0.vga");
138 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playk0.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/playl0.vga");
141 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playl0.vga");
142 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playl0.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/playm0.vga");
145 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playm0.vga");
146 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playm0.vga");
147 animAddFrame("monster", "Player", "die", ACTOR_DIR_LEFT, "monsters/man/graphics/die/playm0.vga");
149 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playh0.vga");
150 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playh0.vga");
151 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playh0.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/playi0.vga");
154 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playi0.vga");
155 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playi0.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/playj0.vga");
158 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playj0.vga");
159 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playj0.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/playk0.vga");
162 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playk0.vga");
163 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playk0.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/playl0.vga");
166 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playl0.vga");
167 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playl0.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/playm0.vga");
170 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playm0.vga");
171 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playm0.vga");
172 animAddFrame("monster", "Player", "die", ACTOR_DIR_RIGHT, "monsters/man/graphics/die/playm0.vga");
174 animClearFrames("monster", "Player", "slop");
176 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playo0.vga");
177 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playo0.vga");
178 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playp0.vga");
179 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playp0.vga");
180 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playq0.vga");
181 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playq0.vga");
182 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playr0.vga");
183 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playr0.vga");
184 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/plays0.vga");
185 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/plays0.vga");
186 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playt0.vga");
187 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playt0.vga");
188 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playu0.vga");
189 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playu0.vga");
190 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playv0.vga");
191 animAddFrame("monster", "Player", "slop", ACTOR_DIR_LEFT, "monsters/man/graphics/slop/playv0.vga");
193 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playo0.vga");
194 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playo0.vga");
195 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playp0.vga");
196 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playp0.vga");
197 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playq0.vga");
198 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playq0.vga");
199 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playr0.vga");
200 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playr0.vga");
201 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/plays0.vga");
202 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/plays0.vga");
203 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playt0.vga");
204 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playt0.vga");
205 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playu0.vga");
206 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playu0.vga");
207 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playv0.vga");
208 animAddFrame("monster", "Player", "slop", ACTOR_DIR_RIGHT, "monsters/man/graphics/slop/playv0.vga");
210 animClearFrames("monster", "Player", "dead");
212 animAddFrame("monster", "Player", "dead", ACTOR_DIR_LEFT, "monsters/man/graphics/dead/playn0.vga");
214 animAddFrame("monster", "Player", "dead", ACTOR_DIR_RIGHT, "monsters/man/graphics/dead/playn0.vga");
216 animClearFrames("monster", "Player", "mess");
218 animAddFrame("monster", "Player", "mess", ACTOR_DIR_LEFT, "monsters/man/graphics/mess/playw0.vga");
220 animAddFrame("monster", "Player", "mess", ACTOR_DIR_RIGHT, "monsters/man/graphics/mess/playw0.vga");
225 // change actor animation
226 public void setAnim (Actor me, string state) {
229 case "sleep": me.animname = "sleep"; me.animstr = "AAABBB"; break;
230 case "go": me.animname = "go"; me.animstr = "ACDABD"; break;
231 case "pain": me.animname = "pain"; me.animstr = "G"; break;
232 case "wait": me.animname = "wait"; me.animstr = "E"; break;
233 case "attack": me.animname = "attack"; me.animstr = "EEEEFF"; break;
234 case "die": me.animname = "die"; me.animstr = "HHHHIIIIJJJJKKKKLLLLMMMM"; break;
235 case "slop": me.animname = "slop"; me.animstr = "OOPPQQRRSSTTUUVV"; break;
236 case "dead": me.animname = "dead"; me.animstr = "N"; break;
237 case "mess": me.animname = "mess"; me.animstr = "W"; break;
238 case "run": me.animname = "go"; me.animstr = "ACDABD"; break;
239 case "climb": me.animname = "go"; me.animstr = "ACDABD"; break;
240 case "runout": me.animname = "go"; me.animstr = "ACDABD"; break;
241 case "shoot": me.animname = "attack"; me.animstr = "EEEEFF"; break;
242 case "revive": me.animname = "revive"; me.animstr = "MMMMLLLLKKKKJJJJIIIIHHHH"; break;
243 default: me.animname = "sleep"; me.animstr = "AAABBB"; break;
245 me.actorSetAnimation(state);
249 // setup actor properties
250 public void initialize (Actor me) {
251 // `classname` and `classtype` will be set by the engine
252 //me.classname = "Player";
253 //me.classtype = "monster";
256 me.hitpoints = me.life = 400;
263 me.plrstate = PLST_STAND;
266 //me.setAnim("sleep");
268 // add attached light
270 me.attLightYOfs = -12;
271 me.attachedLightColorless(96, 44);
273 me.flags |= AF_NOANIMATE;
274 if (me.plrnum == 1) setCameraChick(me);
279 public void think (Actor me) {
281 //writeln("canstand: ", Z_canstand(me.x, me.y, me.radius));
282 //writeln("cangodown: ", Z_cangodown(me.x, me.y, me.radius));
283 //if (((st = Z_moveobj(&me.o))&Z_FALLOUT) && me.y >= MapHeight*TileSize+50) {
284 //int st = Z_moveobj(me); dumpSt(st); writeln(st);
287 /*if (me.plrnum == 1)*/ {
288 int tiltHeight = getMapViewHeight()/4;
290 if (vy < -tiltHeight) vy = -tiltHeight; else if (vy > tiltHeight) vy = tiltHeight;
293 if (me.atm > 0) --me.atm;
294 if (getPlayerButtons(me.plrnum)&PLK_FIRE) {
297 me.target = actorSpawn("switch", "DummyPressActor", me.x, me.y-12, ACTOR_DIR_LEFT);
298 me.target.atm = 2; // 1: act; 0: die
304 void dumpSt (int st) {
306 if (st == 0) { writeln(" NONE"); return; }
307 if (st&Z_HITWALL) write(" Z_HITWALL");
308 if (st&Z_HITCEIL) write(" Z_HITCEIL");
309 if (st&Z_HITLAND) write(" Z_HITLAND");
310 if (st&Z_FALLOUT) write(" Z_FALLOUT");
311 if (st&Z_INWATER) write(" Z_INWATER");
312 if (st&Z_HITWATER) write(" Z_HITWATER");
313 if (st&Z_HITAIR) write(" Z_HITAIR");
314 if (st&Z_BLOCK) write(" Z_BLOCK");
319 void jump (Actor me, int st) {
320 if (Z_canbreathe(me.x, me.y, me.radius, me.height)) {
321 if (me.air < PL_AIR) me.air = PL_AIR;
325 //!PL_hit(me, 10, -3, HIT_WATER);
326 } else if ((me.air&31) == 0) {
327 //!FX_bubble(me.x, me.y-20, 0, 0, 5);
328 miscBubble.spawn(me.x, me.y-20, 0, 0, 5);
330 //miscBubble.spawn(me.x, me.y-20, 0, 0, 5);
333 if (!p_ghost && ISKEY(KB_JUMP)) {
337 if (Z_canstand(OBJT_PLAYER, me.x, me.y, me.radius)) me.yv = -PL_JUMP;
338 else if (st&Z_INWATER) me.yv = -PL_SWUP;
342 //writeln("0: me.yv=", me.yv);
343 if (getPlayerButtons(me.plrnum)&PLK_JUMP) {
344 if (Z_canstand(me.x, me.y, me.radius)) {
347 if (st&Z_INWATER) me.yv = -PL_SWUP;
350 //writeln("1: me.yv=", me.yv);
354 void godown (Actor me) {
356 if (ISKEY(KB_DOWN) && ISKEY(KB_UP)) {
357 //fprintf(stderr, "trying to go down\n");
358 if (Z_cangodown(OBJT_PLAYER, me.x, me.y, me.radius)) {
359 //fprintf(stderr, "going down\n");
367 void PL_act (Actor me) {
369 //if (me.plrnum != 1) return;
371 auto btn = getPlayerButtons(me.plrnum);
372 if (me.plrnum != 1) btn = 0;
373 //writeln("left: ", (btn&PLK_LEFT), "; right: ", (btn&PLK_RIGHT));
375 //if ((btn&PLK_DOWN) && p_ghost) me.yv = 4;
376 //if ((btn&PLK_UP) && p_ghost) me.yv = -4;
378 if (--me.aitime < 0) me.aitime = 0;
380 //SW_press(me.x, me.y, me.radius, me.height, 4|me.keys, me.id);
382 //if (!me.suit && (g_time&15) == 0) PL_hit(me, Z_getacid(me.x, me.y, me.radius, me.height), -3, HIT_SOME);
384 if (me.plrstate != PLST_FALL && me.plrstate != PLST_PLOUT) {
386 //writeln("st=", st);
388 if ((st&Z_FALLOUT) && me.y >= MapHeight*TileSize+50) {
389 writeln(" FALLING!");
390 switch (me.plrstate) {
398 //me.s = Z_sound(snd[10], 128);
400 //if (g_dm) --me.frag;
403 me.plrstate = PLST_FALL;
409 //if (p_ghost) { me.yv = me.vy = 0; }
411 if (st&Z_HITWATER) Z_splash(me, PL_RAD+PL_HT, st);
413 //!if ((me.f&PLF_FIRE) && me.fire != 2) me.f &= ~PLF_FIRE;
416 if ((btn&(PLK_UP|PLK_DOWN)) != (PLK_UP|PLK_DOWN)) {
420 } else if (btn&PLK_DOWN) {
425 //me.f &= ~(PLF_UP|PLF_DOWN);
426 me.looky = Z_dec(me.looky, 5);
430 //!if ((btn&PLK_USE)) SW_press(me.x, me.y, me.radius, me.height, 1|me.keys, me.id);
433 if (me.fire) --me.fire;
434 if (me.cwpn) --me.cwpn;
435 if (me.csnd) --me.csnd;
436 if (me.invl) --me.invl;
437 if (me.suit) --me.suit;
440 switch (me.plrstate) {
443 //!if (!dieanim[++me.s]) { me.plrstate = PLST_DEAD; MN_killedp(); }
444 me.xv = Z_dec(me.xv, 1);
448 //!if (!slopanim[++me.s]) { me.plrstate = PLST_MESS; MN_killedp(); }
449 me.xv = Z_dec(me.xv, 1);
459 //!if (p_fly) SMK_gas(me.x, me.y-2, 2, 3, me.xv+me.vx, me.yv+me.vy, 128);
461 if ((me.s += abs(me.xv)/2) >= 24) me.s %= 24;
463 if (!(btn&(PLK_LEFT|PLK_RIGHT))) {
464 if (me.xv) me.xv = Z_dec(me.xv, 1); else me.plrstate = PLST_STAND;
468 if (me.xv < PL_RUN && (btn&PLK_RIGHT)) {
471 } else if (PL_RUN > 8) {
472 //!SMK_gas(me.x, me.y-2, 2, 3, me.xv+me.vx, me.yv+me.vy, 32);
475 if (me.xv > -PL_RUN && (btn&PLK_LEFT)) {
478 } else if (PL_RUN > 8) {
479 //!SMK_gas(me.x, me.y-2, 2, 3, me.xv+me.vx, me.yv+me.vy, 32);
490 //!if (p_fly) SMK_gas(me.x, me.y-2, 2, 3, me.xv+me.vx, me.yv+me.vy, 128);
492 if ((btn&(PLK_LEFT|PLK_RIGHT)) != (PLK_LEFT|PLK_RIGHT)) {
494 me.plrstate = PLST_GO;
497 } else if (btn&PLK_RIGHT) {
498 me.plrstate = PLST_GO;
507 me.xv = Z_dec(me.xv, 1);
509 for (int f = 0; f < PLK_MAX; ++f) {
511 if (me.plrstate != PLST_PLOUT) MN_spawn_deadpl(&me. me.color, (me.plrstate == PLST_MESS ? 1 : 0));
513 if (g_dm) { G_respawn_player(me); break; }
514 if (g_plrcount == 1) {
515 if (--me.lives == 0) {
521 me.dir = dm_pos[0].dir;
528 me.dir = dm_pos[0].dir;
532 me.dir = dm_pos[1].dir;
539 if (--me.s <= 0) me.plrstate = PLST_PLOUT;
547 void PL_draw (Actor me) {
549 //static const int wytab[] = {-1, -2, -1, 0};
554 switch (me.plrstate) {
560 } else if (me.pain) {
563 wx = (me.d ? 2 : -2);
583 wx = (me.d ? 2 : -2);
587 w = (me.f&PLF_FIRE ? 'B' : 'A');
588 wx = (me.d ? 2 : -2);
597 //s = slopanim[me.s];
605 if (me.wpn == PWPN_FIST) w = 0;
606 if (w) Z_drawspr(me.o.x+wx, me.o.y+wy, &wpn[me.wpn&0x7f][w-'A'], me.d);
607 if (s) Z_drawmanspr(me.o.x, me.o.y, &spr[(s-'A')*2+me.d], sprd[(s-'A')*2+me.d], me.color);