3 import mapapi; // for flags
7 public extern field(Actor) string classtype;
8 public extern field(Actor) string classname;
9 public extern field(Actor) string state; // used in action scripts; also, defines animation
10 public extern field(Actor) int x, y; // coordinates
12 public extern field(Actor) uint flags; // actor flags (see AF_xxx)
14 // internal fields for animation
15 public extern field(Actor) string zAnimstate;
16 public extern field(Actor) int zAnimidx;
18 // each actor can have attached light (to avoid creating and destroying light objects at each frame)
19 public field(Actor) int attLightXOfs, attLightYOfs; // light offset from actor x,y
20 public field(Actor) uint attLightRGBX; // light rgb and radius (R is MSB, X(radius) is LSB)
21 // if (G==0 && B==1) -- this is colorless light, intensity in R
23 public field(Actor) uint plrnum; // >0: player
26 public field(Actor) uint switchabf; // (a<<16)|(b<<8)|flags
28 public /*extern*/ field(Actor) uint tag; // userdata
29 public /*extern*/ field(Actor) int xv, yv; // current velocity
30 public /*extern*/ field(Actor) int vx, vy; // desired velocity (usually)
31 public /*extern*/ field(Actor) int radius, height; // radius, height
32 public /*extern*/ field(Actor) int hitpoints;
33 // starting monster stats (usually will not be changed by thinkers)
34 public /*extern*/ field(Actor) int painin, painout;
35 public /*extern*/ field(Actor) int xvel, yvel;
36 public /*extern*/ field(Actor) int slophit;
37 public /*extern*/ field(Actor) int angertime;
38 // instead of `ap`; used by the engine to animate actors
39 public /*extern*/ field(Actor) string animname;
40 public /*extern*/ field(Actor) string animstr;
41 public /*extern*/ field(Actor) int animidx;
42 // various monster and other actor's fields
43 public /*extern*/ field(Actor) Actor target;
44 public /*extern*/ field(Actor) uint dir; // 1: right
45 public /*extern*/ field(Actor) int st;
46 public /*extern*/ field(Actor) int ftime;
47 public /*extern*/ field(Actor) int fobj; //???
48 public /*extern*/ field(Actor) int s; // for item too
49 public /*extern*/ field(Actor) int aim;
50 public /*extern*/ field(Actor) int life /*is "life"*/;
51 public /*extern*/ field(Actor) int pain;
52 public /*extern*/ field(Actor) int ac;
53 public /*extern*/ field(Actor) int tx;
54 public /*extern*/ field(Actor) int ty;
55 public /*extern*/ field(Actor) int ammo;
56 public /*extern*/ field(Actor) int atm; // anger time (decreasing counter)
59 public auto isPlayer (Actor me) { return (me.plrnum > 0); }
60 public auto isLeft (Actor me) { return (me.dir&ACTOR_DIR_RIGHT); }
61 public auto isRight (Actor me) { return !(me.dir&ACTOR_DIR_RIGHT); }
64 uint packLightRGBX (int r, int g, int b, int radius) {
65 if (radius < 4) return 0;
66 if (r < 0) r = 0; else if (r > 255) r = 255;
67 if (g < 0) g = 0; else if (g > 255) g = 255;
68 if (b < 0) b = 0; else if (b > 255) b = 255;
69 if (radius > 255) radius = 255;
70 return (r<<24)|(g<<16)|(b<<8)|radius;
74 uint packLightColorless (int intens, int radius) {
75 if (radius < 4 || intens < 1) return 0;
76 if (intens > 255) intens = 255;
77 if (radius > 255) radius = 255;
78 return (intens<<24)|(0<<16)|(1<<8)|radius;
82 public void attachedLightRGBX (Actor me, int r, int g, int b, int radius) {
83 me.attLightRGBX = packLightRGBX(r, g, b, radius);
86 public void attachedLightColorless (Actor me, int intens, int radius) {
87 me.attLightRGBX = packLightColorless(intens, radius);
90 // monster state names
91 public const MNST_SLEEP = "sleep"; // ÔÕÐÉÔ
92 public const MNST_GO = "go"; // Õ×ÉÄÅÌ ÄÏÌÂÏ£ÂÁ, ÁÔÁËÕÅÔ
93 public const MNST_RUN = "run"; // ÔÕÐÏ ÂÅÖÉÔ
94 public const MNST_CLIMB = "climb"; // × ÐÒÙÖËÅ(?)
95 public const MNST_DIE = "die"; // ÐÏÄÙÈÁÅÔ
96 public const MNST_DEAD = "dead"; // ÐÏÄÏÈ
97 public const MNST_ATTACK = "attack"; // ÁÔÁËÕÅÔ ÒÕËÏÎÏÇÏÚÕÂÏÍ
98 public const MNST_SHOOT = "shoot"; // ÓÔÒÅÌÑÅÔ
99 public const MNST_PAIN = "pain"; // ËÏÎÞÁÅÔ ÏÔ ÂÏÌÉ
100 public const MNST_WAIT = "wait"; // ÔÕÐÏ ÎÉÞÅÇÏ ÎÅ ÄÅÌÁÅÔ ×ÏÏÂÝÅ, ÏÖÉÄÁÑ ÈÕÊ ÚÎÁÅÔ ÞÅÇÏ 4 ÔÉËÁ
101 public const MNST_REVIVE = "revive"; // ÏÖÉ×ÁÅÔ
102 public const MNST_RUNOUT = "runout"; // Õ£ÂÙ×ÁÅÔ × ÔÕÍÁÎ
105 public const PLST_STAND = 0;
106 public const PLST_GO = 1;
107 public const PLST_DIE = 2;
108 public const PLST_SLOP = 3;
109 public const PLST_DEAD = 4;
110 public const PLST_MESS = 5;
111 public const PLST_PLOUT = 6;
112 public const PLST_FALL = 7;
115 public const PLK_UP = BIT(0);
116 public const PLK_DOWN = BIT(1);
117 public const PLK_LEFT = BIT(2);
118 public const PLK_RIGHT = BIT(3);
119 public const PLK_FIRE = BIT(4);
120 public const PLK_JUMP = BIT(5);
121 public const PLK_USE = BIT(6);
123 public extern uint getPlayerButtons (uint pidx) pure;
125 // animation sequences
126 public const ACTOR_DIR_LEFT = 0;
127 public const ACTOR_DIR_RIGHT = 1;
129 public extern void animClearFrames (string classtype, string classname, string state);
130 public extern void animAddFrame (string classtype, string classname, string state, uint dir, string sprname);
132 public extern void actorSetAnimation (Actor me, string state);
134 // note that spawned actor will not "think" in this turn
135 public extern Actor actorSpawn (string classtype, string classname, int x, int y, uint dir);
137 public extern Actor actorSpawnVanillaSwitch (string classname, int x, int y, uint flags, int tilex, int tiley);
140 public extern Actor getPlayerCount () pure;
141 //public extern Actor getPlayer () pure; // current player (if it's player script) or 0
142 public extern Actor getPlayerActor (uint pnum) pure;
144 //public extern int isPlayer (Actor a) pure;
146 public extern uint actorMove (Actor a);
147 public extern uint actorPressSwitches (Actor a);
148 public extern uint actorFallen (Actor a);
150 public const Z_HITWALL = BIT(0);
151 public const Z_HITCEIL = BIT(1);
152 public const Z_HITLAND = BIT(2);
153 public const Z_FALLOUT = BIT(3);
154 public const Z_INWATER = BIT(4);
155 public const Z_HITWATER = BIT(5);
156 public const Z_HITAIR = BIT(6);
157 public const Z_BLOCK = BIT(7);
160 public extern uint gameMode () pure;
162 public const GM_NOTPLAYING = 0;
163 public const GM_SINGLE = 1;
164 public const GM_COOP = 2;
165 public const GM_DEATHMATCH = 3;
169 public const SW_PL_PRESS = BIT(0);
170 public const SW_MN_PRESS = BIT(1);
171 public const SW_PL_NEAR = BIT(2);
172 public const SW_MN_NEAR = BIT(3);
173 public const SW_KEY_R = BIT(4);
174 public const SW_KEY_G = BIT(5);
175 public const SW_KEY_B = BIT(6);
179 public const AF_NOCOLLISION = BIT(0);
180 public const AF_NOGRAVITY = BIT(1);
181 public const AF_NOTHINK = BIT(2);
182 public const AF_NOONTOUCH = BIT(3); // `onTouch` will never be called with `me` for this actor
183 public const AF_NODRAW = BIT(4); // don't draw sprite
184 public const AF_NOLIGHT = BIT(5); // no attached light
185 public const AF_NOANIMATE = BIT(6); // don't do animation
188 public extern int actorsOverlap (Actor a, Actor b) pure;
190 /// remove actor from scene immediately
191 public extern void actorRemove (Actor me);
192 //TODO: actormarkdead
195 // return number of items in touchlist
196 //public extern int actorSetupPossibleTouchList (Actor me);
198 // continue until actor is valid, i.e. `if (!act) break;`
199 public extern void rewindTouchList ();
200 public extern Actor getNextTouchListItem ();
202 // note that current actor is not on grid when it's `think()` is called,
203 // so it won't go in any touchlist at all
207 public extern int getCheatNoDoors ();