switched to GPLv3 ONLY, because i don't trust FSF anymore
[knightmare.git] / data / mes / enemies / skeleton.mes
blob16cdf1661c7f03a5c61500812894b6c07a81c4d5
1 /* coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
2  * Understanding is not required. Only obedience.
3  *
4  * Based on the DOS Knightmare source code by Andrew Zabolotny
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, version 3 of the License ONLY.
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 // ////////////////////////////////////////////////////////////////////////// //
19 // EnemySkeleton : BaseMovable
20 field int NumR, DX, State, DistX, DistY, DDY;
22 method(EnemySkeleton) void ctor (int apower) {
23   hitTint = -1;
24   MyX = SpawnRandom(288)+16;
25   MyY = -15;
26   MyW = 14;
27   MyH = 12;
28   MyDW = 1;
29   MyState = Klass.IAmBadGuy;
30   Power = apower;
31   MyStepX = 1;
32   MyStepY = 1;
33   DistX = 0;
34   DistY = 0;
35   DDY = -5;
36   if (MyX > 156) DX = -SpawnRandom(2); else DX = SpawnRandom(2);
37   NumR = 3;
38   State = 1;
39   MyPrice = 500;
41   onDraw = &draw;
42   onTick = &tick;
46 method(EnemySkeleton) void draw () {
47   if (State == 1) {
48     putSprite("spr16x24_", 16+((TCount>>2)&1), MyX, MyY);
49   } else {
50     putSprite("spr16x16_", 24, MyX-DistX, MyY);
51     putSprite("spr16x16_", 25, MyX+DistX, MyY);
52   }
56 method(EnemySkeleton) void tick () {
57   if (MyY > 184) { NeedToDie = true; return; }
58   if (State == 1) {
59     if (TimeStop == 0) {
60       if (MyX < 4 || MyX > 320-16-4) DX = -DX;
61       MyX += DX;
62       ++MyY;
63       Fire(48);
64     }
65     CheckBalls(Klass.IAmShooted);
66     if (Damaged) {
67       Damaged = false;
68       --NumR;
69       Sound(32, MyX);
70       if (NumR > 0) {
71         State = 2;
72       } else {
73         NeedToDie = true;
74         new ObjectFire(this);
75         Sound(21, MyX);
76       }
77     }
78     return;
79   }
80   if (State == 2) {
81     ++DistX;
82     MyY += DDY;
83     ++DDY;
84     if (DDY >= 8) { State = 3; DDY = 15; }
85     return;
86   }
87   if (State == 3) {
88     --DDY;
89     if (DDY == 0) { State = 4; DDY = -5; }
90     return;
91   }
92   if (State == 4) {
93     --DistX;
94     MyY += DDY;
95     ++DDY;
96     if (DDY >= 6) { State = 1; DDY = -5; }
97     return;
98   }