console executor reworked a little
[dd2d.git] / data / scripts / d2dplayer.dacs
blob9e431761e20515f07b32690446d4f01e9d9c2242
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.
4  *
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.
9  *
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.
14  *
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/>.
17  */
18 module d2dplayer is "monster" "Player";
20 import apiActor;
21 import aiMonster;
22 import apiMap;
23 import apiMove;
24 import miscBubble;
25 import stdlib;
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
34 const PL_JUMP = 10;
35 const PL_RUN = 8; // 24 for "formula1"
37 const PL_RAD = 8;
38 const PL_HT  = 26;
40 const PL_SWUP  = 4;
41 const PL_FLYUP = 4;
43 const PL_AIR      = 360+9;
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 () {
52   // stand
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");
64   // sleep
65   animClearFrames("monster", "Player", "sleep");
66   // left
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");
73   // right
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");
80   // go
81   animClearFrames("monster", "Player", "go");
82   // left
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");
89   // right
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");
96   // pain
97   animClearFrames("monster", "Player", "pain");
98   // left
99   animAddFrame("monster", "Player", "pain", ACTOR_DIR_LEFT, "monsters/man/graphics/pain/playg1g2.vga");
100   // right
101   animAddFrame("monster", "Player", "pain", ACTOR_DIR_RIGHT, "monsters/man/graphics/pain/playg1g2_mirrored.vga");
102   // wait
103   animClearFrames("monster", "Player", "wait");
104   // left
105   animAddFrame("monster", "Player", "wait", ACTOR_DIR_LEFT, "monsters/man/graphics/shared/playe1e2.vga");
106   // right
107   animAddFrame("monster", "Player", "wait", ACTOR_DIR_RIGHT, "monsters/man/graphics/shared/playe1e2_mirrored.vga");
108   // attack
109   animClearFrames("monster", "Player", "attack");
110   // left
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");
117   // right
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");
124   // die
125   animClearFrames("monster", "Player", "die");
126   // left
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");
151   // right
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");
176   // slop
177   animClearFrames("monster", "Player", "slop");
178   // left
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");
195   // right
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");
212   // dead
213   animClearFrames("monster", "Player", "dead");
214   // left
215   animAddFrame("monster", "Player", "dead", ACTOR_DIR_LEFT, "monsters/man/graphics/dead/playn0.vga");
216   // right
217   animAddFrame("monster", "Player", "dead", ACTOR_DIR_RIGHT, "monsters/man/graphics/dead/playn0.vga");
218   // mess
219   animClearFrames("monster", "Player", "mess");
220   // left
221   animAddFrame("monster", "Player", "mess", ACTOR_DIR_LEFT, "monsters/man/graphics/mess/playw0.vga");
222   // right
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) {
230   me.animidx = 0;
231   switch (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;
247   }
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";
257   me.radius = 8;
258   me.height = 26;
259   me.hitpoints = me.life = 400;
260   me.painin = 70;
261   me.xvel = 8;
262   me.yvel = 10;
263   me.slophit = 30;
264   me.painout = 50;
265   me.angertime = 90;
266   me.plrstate = PLST_STAND;
267   me.aitime = 0;
268   me.air = PL_AIR|PL_AIR_NOTUW_BIT;
269   //me.setAnim("sleep");
270   me.setAnim("stand");
271   // add attached light
272   me.attLightXOfs = 0;
273   me.attLightYOfs = -12;
274   me.attachedLightColorless(96, 44);
275   // flags
276   me.flags |= AF_NOANIMATE;
277   if (me.plrnum == 1) setCameraChick(me);
281 // thinker
282 public void think (Actor me) {
283   //monsterThink(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);
288   PL_act(me);
289   // fix level view
290   /*if (me.plrnum == 1)*/ {
291     int tiltHeight = getMapViewHeight()/4;
292     int vy = me.looky;
293     if (vy < -tiltHeight) vy = -tiltHeight; else if (vy > tiltHeight) vy = tiltHeight;
294     me.looky = vy;
295   }
296   /*
297   if (me.atm > 0) --me.atm;
298   if (getPlayerButtons(me.plrnum)&PLK_FIRE) {
299     if (me.atm <= 0) {
300       me.atm = 4;
301       me.target = actorSpawn("switch", "DummyPressActor", me.x, me.y-12, ACTOR_DIR_LEFT);
302       me.target.atm = 2; // 1: act; 0: die
303     }
304   }
305   */
309 void dumpSt (int st) {
310   write("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");
320   writeln;
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;
327   } else {
328     int air = (me.air&PL_AIR_MASK)-1;
329     if (air < 0) {
330       air = 0;
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);
334     }
335     //miscBubble.spawn(me.x, me.y-20, 0, 0, 5);
336     me.air = air;
337   }
338   /*
339   if (!p_ghost && ISKEY(KB_JUMP)) {
340     if (p_fly) {
341       me.yv = -PL_FLYUP;
342     } else {
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;
345     }
346   }
347   */
348   //writeln("0: me.yv=", me.yv);
349   if (getPlayerButtons(me.plrnum)&PLK_JUMP) {
350     if (Z_canstand(me.x, me.y, me.radius)) {
351       me.yv = -PL_JUMP;
352     } else {
353       if (st&Z_INWATER) me.yv = -PL_SWUP;
354     }
355   }
356   //writeln("1: me.yv=", me.yv);
360 void godown (Actor me) {
361   /*
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");
366       me.y += 2;
367     }
368   }
369   */
373 void PL_act (Actor me) {
374   int st;
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) {
391     st = Z_moveobj(me);
392     //writeln("st=", st);
393     //dumpSt(st);
394     if ((st&Z_FALLOUT) && me.y >= MapHeight*TileSize+50) {
395       writeln(" FALLING!");
396       switch (me.plrstate) {
397         case PLST_DEAD:
398         case PLST_MESS:
399         case PLST_DIE:
400         case PLST_SLOP:
401           me.s = 5;
402           break;
403         default:
404           //me.s = Z_sound(snd[10], 128);
405           me.s = 64; //???
406           //if (g_dm) --me.frag;
407           break;
408       }
409       me.plrstate = PLST_FALL;
410     }
411   } else {
412     st = 0;
413   }
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;
421   // look up/down
422   if ((btn&(PLK_UP|PLK_DOWN)) != (PLK_UP|PLK_DOWN)) {
423     if (btn&PLK_UP) {
424       //me.f |= PLF_UP;
425       me.looky -= 5;
426     } else if (btn&PLK_DOWN) {
427       //me.f &= ~PLF_UP;
428       //me.f |= PLF_DOWN;
429       me.looky += 5;
430     } else {
431       //me.f &= ~(PLF_UP|PLF_DOWN);
432       me.looky = Z_dec(me.looky, 5);
433     }
434   }
436   //!if ((btn&PLK_USE)) SW_press(me.x, me.y, me.radius, me.height, 1|me.keys, me.id);
438   /*
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;
444   */
446   switch (me.plrstate) {
447     case PLST_DIE:
448       me.height = 7;
449       //!if (!dieanim[++me.s]) { me.plrstate = PLST_DEAD; MN_killedp(); }
450       me.xv = Z_dec(me.xv, 1);
451       break;
452     case PLST_SLOP:
453       me.height = 6;
454       //!if (!slopanim[++me.s]) { me.plrstate = PLST_MESS; MN_killedp(); }
455       me.xv = Z_dec(me.xv, 1);
456       break;
457     case PLST_GO:
458       /*
459       chgwpn(me);
460       fire(me);
461       */
462       me.jump(st);
463       me.godown();
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;
471         break;
472       }
474       if (me.xv < PL_RUN && (btn&PLK_RIGHT)) {
475         me.xv += PL_RUN>>3;
476         me.dir = 1;
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);
479       }
480       //
481       if (me.xv > -PL_RUN && (btn&PLK_LEFT)) {
482         me.xv -= PL_RUN>>3;
483         me.dir = 0;
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);
486       }
487       break;
488     case PLST_STAND:
489       /*
490       chgwpn(me);
491       fire(me);
492       */
493       me.jump(st);
494       me.godown();
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)) {
499         if (btn&PLK_LEFT) {
500           me.plrstate = PLST_GO;
501           me.s = 0;
502           me.dir = 0;
503         } else if (btn&PLK_RIGHT) {
504           me.plrstate = PLST_GO;
505           me.s = 0;
506           me.dir = 1;
507         }
508       }
509       break;
510     case PLST_DEAD:
511     case PLST_MESS:
512     case PLST_PLOUT:
513       me.xv = Z_dec(me.xv, 1);
514       /*respawn
515       for (int f = 0; f < PLK_MAX; ++f) {
516         if (ISKEYX(me, f)) {
517           if (me.plrstate != PLST_PLOUT) MN_spawn_deadpl(&me. me.color, (me.plrstate == PLST_MESS ? 1 : 0));
518           PL_restore(me);
519           if (g_dm) { G_respawn_player(me); break; }
520           if (g_plrcount == 1) {
521             if (--me.lives == 0) {
522               G_start();
523               break;
524             } else {
525               me.x = dm_pos[0].x;
526               me.y = dm_pos[0].y;
527               me.dir = dm_pos[0].dir;
528             }
529           }
530           //
531           if (me.id == -1) {
532             me.x = dm_pos[0].x;
533             me.y = dm_pos[0].y;
534             me.dir = dm_pos[0].dir;
535           } else {
536             me.x = dm_pos[1].x;
537             me.y = dm_pos[1].y;
538             me.dir = dm_pos[1].dir;
539           }
540         }
541       }
542       */
543       break;
544     case PLST_FALL:
545       if (--me.s <= 0) me.plrstate = PLST_PLOUT;
546       break;
547     default:
548   }
553 void PL_draw (Actor me) {
554   int s, w, wx, wy;
555   //static const int wytab[] = {-1, -2, -1, 0};
557   s = 'A';
558   w = 0;
559   wx = wy = 0;
560   switch (me.plrstate) {
561     case PLST_STAND:
562       /*
563       if (me.f&PLF_FIRE) {
564         s = standspr(p)+1;
565         w = wpnspr(p)+1;
566       } else if (me.pain) {
567         s = 'G';
568         w = 'A';
569         wx = (me.d ? 2 : -2);
570         wy = 1;
571       } else {
572         s = standspr(p);
573         w = wpnspr(p);
574       }
575       */
576       break;
577     case PLST_DEAD:
578       //s = 'N';
579       //break;
580       return;
581     case PLST_MESS:
582       //s = 'W';
583       //break;
584       return;
585     case PLST_GO:
586       if (me.pain) {
587         s = 'G';
588         w = 'A';
589         wx = (me.d ? 2 : -2);
590         wy = 1;
591       } else {
592         s = goanim[me.s/8];
593         w = (me.f&PLF_FIRE ? 'B' : 'A');
594         wx = (me.d ? 2 : -2);
595         wy = 1+wytab[s-'A'];
596       }
597       break;
598     case PLST_DIE:
599       //s = dieanim[me.s];
600       //break;
601       return;
602     case PLST_SLOP:
603       //s = slopanim[me.s];
604       //break;
605       return;
606     case PLST_PLOUT:
607       //s = 0;
608       //break;
609       return;
610   }
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);