trap switches
[dd2d.git] / data / scripts / switch / trap.dacs
blobc54003c5dfea4edf2bca7d1ab2afb947ad21299e
1 module switchTrap is "switch" "Trap";
3 import apiActor;
4 import apiMap;
5 import apiMove;
6 import apiSwitch;
7 import stdlib;
10 // setup actor properties
11 public void initialize (Actor me) {
15 void doThink (Actor me) {
16   int d = me.switchGetD();
17   if (!d) return;
18   int a = me.switchGetA();
19   int b = me.switchGetB();
20   if (mapGetTypeTile(a, b) != TILE_DOORC) {
21     me.switchSetD(0);
22     return;
23   }
24   if (--d == 0) {
25     switchOpenDoor(me);
26     me.atm = 18;
27   }
28   me.switchSetD(d);
32 // thinker
33 public void think (Actor me) {
34   if (me.atm > 0) {
35     --me.atm;
36     return;
37   }
39   me.atm = 0; // just in case
40   doThink(me);
42   auto toucher = me.switchWhoTouched();
43   if (toucher) switchShutTrap(me);