"no doors" cheat
[dd2d.git] / data / scripts / actor.dacs
blobc4742b92f3593ac087bf181151a188894944e28e
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 /*extern*/ field(Actor) uint tag; // userdata
24 public /*extern*/ field(Actor) int xv, yv; // current velocity
25 public /*extern*/ field(Actor) int vx, vy; // desired velocity (usually)
26 public /*extern*/ field(Actor) int radius, height;   // radius, height
27 public /*extern*/ field(Actor) int hitpoints;
28 // starting monster stats (usually will not be changed by thinkers)
29 public /*extern*/ field(Actor) int painin, painout;
30 public /*extern*/ field(Actor) int xvel, yvel;
31 public /*extern*/ field(Actor) int slophit;
32 public /*extern*/ field(Actor) int angertime;
33 // instead of `ap`; used by the engine to animate actors
34 public /*extern*/ field(Actor) string animname;
35 public /*extern*/ field(Actor) string animstr;
36 public /*extern*/ field(Actor) int animidx;
37 // various monster and other actor's fields
38 public /*extern*/ field(Actor) Actor target;
39 public /*extern*/ field(Actor) uint dir;  // 1: right
40 public /*extern*/ field(Actor) int st;
41 public /*extern*/ field(Actor) int ftime;
42 public /*extern*/ field(Actor) int fobj; //???
43 public /*extern*/ field(Actor) int s; // for item too
44 public /*extern*/ field(Actor) int aim;
45 public /*extern*/ field(Actor) int life /*is "life"*/;
46 public /*extern*/ field(Actor) int pain;
47 public /*extern*/ field(Actor) int ac;
48 public /*extern*/ field(Actor) int tx;
49 public /*extern*/ field(Actor) int ty;
50 public /*extern*/ field(Actor) int ammo;
51 public /*extern*/ field(Actor) int atm; // anger time (decreasing counter)
54 public auto isLeft (Actor me) { return (me.dir&ACTOR_DIR_RIGHT); }
55 public auto isRight (Actor me) { return !(me.dir&ACTOR_DIR_RIGHT); }
58 uint packLightRGBX (int r, int g, int b, int radius) {
59   if (radius < 4) return 0;
60   if (r < 0) r = 0; else if (r > 255) r = 255;
61   if (g < 0) g = 0; else if (g > 255) g = 255;
62   if (b < 0) b = 0; else if (b > 255) b = 255;
63   if (radius > 255) radius = 255;
64   return (r<<24)|(g<<16)|(b<<8)|radius;
68 uint packLightColorless (int intens, int radius) {
69   if (radius < 4 || intens < 1) return 0;
70   if (intens > 255) intens = 255;
71   if (radius > 255) radius = 255;
72   return (intens<<24)|(0<<16)|(1<<8)|radius;
76 public void attachedLightRGBX (Actor me, int r, int g, int b, int radius) {
77   me.attLightRGBX = packLightRGBX(r, g, b, radius);
80 public void attachedLightColorless (Actor me, int intens, int radius) {
81   me.attLightRGBX = packLightColorless(intens, radius);
84 // monster state names
85 public const MNST_SLEEP  = "sleep";  // ÔÕÐÉÔ
86 public const MNST_GO     = "go";     // Õ×ÉÄÅÌ ÄÏÌÂÏ£ÂÁ, ÁÔÁËÕÅÔ
87 public const MNST_RUN    = "run";    // ÔÕÐÏ ÂÅÖÉÔ
88 public const MNST_CLIMB  = "climb";  // × ÐÒÙÖËÅ(?)
89 public const MNST_DIE    = "die";    // ÐÏÄÙÈÁÅÔ
90 public const MNST_DEAD   = "dead";   // ÐÏÄÏÈ
91 public const MNST_ATTACK = "attack"; // ÁÔÁËÕÅÔ ÒÕËÏÎÏÇÏÚÕÂÏÍ
92 public const MNST_SHOOT  = "shoot";  // ÓÔÒÅÌÑÅÔ
93 public const MNST_PAIN   = "pain";   // ËÏÎÞÁÅÔ ÏÔ ÂÏÌÉ
94 public const MNST_WAIT   = "wait";   // ÔÕÐÏ ÎÉÞÅÇÏ ÎÅ ÄÅÌÁÅÔ ×ÏÏÂÝÅ, ÏÖÉÄÁÑ ÈÕÊ ÚÎÁÅÔ ÞÅÇÏ 4 ÔÉËÁ
95 public const MNST_REVIVE = "revive"; // ÏÖÉ×ÁÅÔ
96 public const MNST_RUNOUT = "runout"; // Õ£ÂÙ×ÁÅÔ × ÔÕÍÁÎ
98 // player states
99 public const PLST_STAND = 0;
100 public const PLST_GO    = 1;
101 public const PLST_DIE   = 2;
102 public const PLST_SLOP  = 3;
103 public const PLST_DEAD  = 4;
104 public const PLST_MESS  = 5;
105 public const PLST_PLOUT = 6;
106 public const PLST_FALL  = 7;
108 // player keys
109 public const PLK_UP    = BIT(0);
110 public const PLK_DOWN  = BIT(1);
111 public const PLK_LEFT  = BIT(2);
112 public const PLK_RIGHT = BIT(3);
113 public const PLK_FIRE  = BIT(4);
114 public const PLK_JUMP  = BIT(5);
115 public const PLK_USE   = BIT(6);
117 public extern uint getPlayerButtons (uint pidx) pure;
119 // animation sequences
120 public const ACTOR_DIR_LEFT  = 0;
121 public const ACTOR_DIR_RIGHT = 1;
123 public extern void animClearFrames (string classtype, string classname, string state);
124 public extern void animAddFrame (string classtype, string classname, string state, uint dir, string sprname);
126 public extern void actorSetAnimation (Actor me, string state);
128 // note that spawned actor will not "think" in this turn
129 public extern Actor actorSpawn (string classtype, string classname, int x, int y, uint dir);
130 // flags: SWITCH_*
131 public extern Actor actorSpawnVanillaSwitch (string classname, int x, int y, uint flags, int tilex, int tiley);
134 public extern Actor getPlayerCount () pure;
135 //public extern Actor getPlayer () pure; // current player (if it's player script) or 0
136 public extern Actor getPlayerActor (uint pnum) pure;
138 public extern int isPlayer (Actor a) pure;
140 public extern uint actorMove (Actor a);
141 public extern uint actorPressSwitches (Actor a);
142 public extern uint actorFallen (Actor a);
144 public const Z_HITWALL  = BIT(0);
145 public const Z_HITCEIL  = BIT(1);
146 public const Z_HITLAND  = BIT(2);
147 public const Z_FALLOUT  = BIT(3);
148 public const Z_INWATER  = BIT(4);
149 public const Z_HITWATER = BIT(5);
150 public const Z_HITAIR   = BIT(6);
151 public const Z_BLOCK    = BIT(7);
154 public extern uint gameMode () pure;
155 // game modes
156 public const GM_NOTPLAYING = 0;
157 public const GM_SINGLE     = 1;
158 public const GM_COOP       = 2;
159 public const GM_DEATHMATCH = 3;
162 // actor flags
163 public const AF_NOCOLLISION = BIT(0);
164 public const AF_NOGRAVITY   = BIT(1);
165 public const AF_NOTHINK     = BIT(2);
166 public const AF_NOONTOUCH   = BIT(3); // `onTouch` will never be called with `me` for this actor
167 public const AF_NODRAW      = BIT(4); // don't draw sprite
168 public const AF_NOLIGHT     = BIT(5); // no attached light
169 public const AF_NOANIMATE   = BIT(6); // don't do animation
172 public extern int actorsOverlap (Actor a, Actor b) pure;
174 /// remove actor from scene immediately
175 public extern void actorRemove (Actor me);
176 //TODO: actormarkdead
179 // return number of items in touchlist
180 //public extern int actorSetupPossibleTouchList (Actor me);
182 // continue until actor is valid, i.e. `if (!act) break;`
183 public extern void rewindTouchList ();
184 public extern Actor getNextTouchListItem ();
186 // note that current actor is not on grid when it's `think()` is called,
187 // so it won't go in any touchlist at all
191 public extern int getCheatNoDoors ();