splash particles
[dd2d.git] / data / scripts / actor.dacs
blob728e8819aae081b9c55cb2339ab388a4f38b7092
1 module actor;
3 import mapapi; // for flags
6 // actor declaration
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
25 // for d2d switches
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; // `d` for switch -- revert time
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 for monster (decreasing counter); cooldown time for switch
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"; // Õ£ÂÙ×ÁÅÔ × ÔÕÍÁÎ
104 // player states
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;
114 // player keys
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);
136 // flags: SWITCH_*
137 public extern Actor actorSpawnVanillaSwitch (string classname, int x, int y, uint flags, int tilex, int tiley);
140 public extern int 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);
159 // "real" water type (for Z_HITWATER)
160 public const Z_WATER_0  = BIT(16);
161 public const Z_WATER_1  = BIT(17);
162 public const Z_WATER_2  = BIT(18);
164 // "texture" water type (for Z_HITWATER)
165 public const Z_WATER_T0  = BIT(19);
166 public const Z_WATER_T1  = BIT(20);
167 public const Z_WATER_T2  = BIT(21);
170 public extern uint gameMode () pure;
171 // game modes
172 public const GM_NOTPLAYING = 0;
173 public const GM_SINGLE     = 1;
174 public const GM_COOP       = 2;
175 public const GM_DEATHMATCH = 3;
178 // switch flags
179 public const SW_PL_PRESS = BIT(0);
180 public const SW_MN_PRESS = BIT(1);
181 public const SW_PL_NEAR = BIT(2);
182 public const SW_MN_NEAR = BIT(3);
183 public const SW_KEY_R = BIT(4);
184 public const SW_KEY_G = BIT(5);
185 public const SW_KEY_B = BIT(6);
188 // actor flags
189 public const AF_NOCOLLISION = BIT(0);
190 public const AF_NOGRAVITY   = BIT(1);
191 public const AF_NOTHINK     = BIT(2);
192 public const AF_NOONTOUCH   = BIT(3); // `onTouch` will never be called with `me` for this actor
193 public const AF_NODRAW      = BIT(4); // don't draw sprite
194 public const AF_NOLIGHT     = BIT(5); // no attached light
195 public const AF_NOANIMATE   = BIT(6); // don't do animation
198 public extern int actorsOverlap (Actor a, Actor b) pure;
200 /// remove actor from scene immediately
201 public extern void actorRemove (Actor me);
202 //TODO: actormarkdead
205 // return number of items in touchlist
206 //public extern int actorSetupPossibleTouchList (Actor me);
208 // continue until actor is valid, i.e. `if (!act) break;`
209 public extern void rewindTouchList ();
210 public extern Actor getNextTouchListItem ();
212 // note that current actor is not on grid when it's `think()` is called,
213 // so it won't go in any touchlist at all
216 public extern int getCheatNoDoors ();
219 // ////////////////////////////////////////////////////////////////////////// //
220 public extern void dotAddBlood (int x, int y, int xv, int yv, int n);
221 public extern void dotAddSpark (int x, int y, int xv, int yv, int n);
222 public extern void dotAddWater (int x, int y, int xv, int yv, int n, int color);