2 Copyright (C) 2004-2011 Parallel Realities
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 void galdovCheckSplit();
28 (self->x < player.x) ? self->face = 0 : self->face = 1;
35 switch (Math::prand() % 5)
41 color = graphics.yellow;
44 color = graphics.green;
47 color = graphics.cyan;
50 color = graphics.white;
54 for (int i = 0 ; i < 20 ; i++)
56 dy = Math::rrand(-150, -50);
58 map.addParticle(self->x + (Math::prand() % self->width), self->y + (Math::prand() % self->height), dx, dy, Math::rrand(1, 60), color, NULL, PAR_WEIGHTLESS);
61 self->setThinkTime(1);
62 self->setActionFinished(1);
63 self->think = &splitParticles;
66 if (self->custom == 0)
68 self->setThinkTime(2);
69 self->setActionFinished(2);
70 self->think = &galdovAttack;
72 if (self == map.boss[0])
74 if ((Math::prand() % self->health) == 0)
76 self->think = &galdovCheckSplit;
85 self->setThinkTime(2);
86 self->setActionFinished(2);
88 int x = (int)player.x >> BRICKSHIFT;
89 int y = (int)player.y >> BRICKSHIFT;
90 x += Math::rrand(-10, 10);
91 y += Math::rrand(-10, 10);
93 Math::limitInt(&x, 1, 28);
94 Math::limitInt(&y, 259, 283);
96 if (map.data[x][y] == MAP_AIR)
102 addTeleportParticles(self->x + 10, self->y + 10, 50, SND_TELEPORT2);
103 self->think = &galdovAttack;
109 if (self->health < 0)
112 int r = Math::prand() % 10;
116 self->setThinkTime(2);
117 self->setActionFinished(2);
118 self->think = &galdovTeleport;
120 r = Math::prand() % 3;
124 self->setThinkTime(2);
125 self->setActionFinished(2);
126 self->think = &galdovCheckSplit;
131 void galdovSplit(int i)
133 audio.playSound(SND_BOSSCUSTOM1, CH_AMBIANCE);
135 map.boss[i]->active = true;
136 map.boss[i]->health = 4 * game.skill;
137 map.boss[i]->maxHealth = 4 * game.skill;
138 map.boss[i]->x = map.boss[0]->x;
139 map.boss[i]->y = map.boss[0]->y;
140 map.boss[i]->flags = map.boss[0]->flags;
141 map.boss[i]->think = &galdovAttack;
143 if ((Math::prand() % 2) == 0)
145 map.boss[i]->currentWeapon = getRandomAimedWeapon();
146 Math::addBit(&map.boss[i]->flags, ENT_AIMS);
150 map.boss[i]->currentWeapon = getRandomStraightWeapon();
151 Math::removeBit(&map.boss[i]->flags, ENT_AIMS);
154 if ((Math::prand() % 2) == 0)
156 map.boss[0]->dx = -.5;
158 map.boss[i]->dx = .5;
163 map.boss[0]->dx = .5;
165 map.boss[i]->dx = -.5;
169 map.boss[0]->think = &splitParticles;
170 map.boss[0]->setThinkTime(1);
171 map.boss[0]->setActionFinished(1);
172 map.boss[0]->custom = 60;
174 map.boss[i]->think = &splitParticles;
175 map.boss[i]->setThinkTime(1);
176 map.boss[i]->setActionFinished(1);
177 map.boss[i]->custom = 60;
180 void galdovCheckSplit()
182 for (int i = 1 ; i < 10 ; i++)
184 if (!map.boss[i]->active)
194 (self->x < player.x) ? self->face = 0 : self->face = 1;
196 self->setActionFinished(9);
197 self->setThinkTime(2);
198 self->think = &galdovFire;
200 if (hasClearShot(self))
202 self->flags & ENT_AIMS ? addBullet((Entity*)self, 0, 0) : addBullet((Entity*)self, self->currentWeapon->getSpeed(self->face), 0);
204 if (self->currentWeapon == &weapon[WP_ALIENSPREAD])
206 addBullet(self, self->currentWeapon->getSpeed(self->face), 2);
207 addBullet(self, self->currentWeapon->getSpeed(self->face), -2);
212 if (self->custom == 0)
214 self->think = &galdovAttack;
218 void galdovRocketAttack()
220 (self->x < player.x) ? self->face = 0 : self->face = 1;
222 if (!hasClearShot(self))
225 self->setActionFinished(5);
226 self->setThinkTime(2);
227 self->think = &galdovRocketAttack;
229 addBullet((Entity*)self, 0, 0);
233 if (self->custom == 0)
235 self->think = &galdovAttack;
236 self->currentWeapon = getRandomGaldovWeapon();
240 void galdovChasePlayer()
242 (self->x < player.x) ? self->face = 0 : self->face = 1;
246 Math::calculateSlope(player.x, player.y, self->x, self->y, &dx, &dy);
251 self->setThinkTime(10);
252 self->setActionFinished(10);
253 self->think = &galdovAttack;
256 void galdovMoveRandom()
258 self->think = &galdovAttack;
260 if (self->flags & ENT_FLIES)
262 self->dx = Math::rrand(-200, 200);
263 self->dy = Math::rrand(-200, 200);
268 self->setThinkTime(2);
269 self->setActionFinished(Math::rrand(60, 90));
273 self->dy = Math::rrand(-12, 0);
275 (player.x < self->x) ? self->dx = -3 : self->dx = 3;
277 self->think = &galdovAttack;
278 self->setActionFinished(45);
282 void galdovDoInvisible()
284 if ((Math::prand() % 2) == 0)
286 map.boss[0]->setSprites(graphics.getSprite("GaldovRight", true), graphics.getSprite("GaldovLeft", true), graphics.getSprite("GaldovLeft", true));
290 map.boss[0]->setSprites(graphics.getSprite("GaldovInvsRight", true), graphics.getSprite("GaldovInvsLeft", true), graphics.getSprite("GaldovInvsLeft", true));
293 self->setThinkTime(2);
294 self->setActionFinished(2);
295 self->think = &galdovAttack;
300 if (player.health < 1)
302 self->dx = self->dy = 0;
306 (self->x < player.x) ? self->face = 0 : self->face = 1;
308 self->think = &galdovAttack;
309 self->setThinkTime(2);
310 self->setActionFinished(2);
312 int r = Math::prand() % 100;
316 self->think = &galdovFire;
317 self->custom = Math::rrand(1, 8);
321 // Make sure only the real Galdov does this!
322 if (self == map.boss[0])
324 addTeleportParticles(self->x + 10, self->y + 10, 50, SND_TELEPORT2);
327 self->setActionFinished(120);
328 self->setThinkTime(2);
329 self->think = &galdovTeleport;
334 self->think = &galdovChasePlayer;
338 self->think = &galdovMoveRandom;
342 if ((self->flags & ENT_FLIES) && (Math::prand() % 5) == 0)
344 Math::removeBit(&self->flags, ENT_FLIES);
345 Math::removeBit(&self->flags, ENT_FIRETRAIL);
349 Math::addBit(&self->flags, ENT_FLIES);
350 Math::addBit(&self->flags, ENT_FIRETRAIL);
355 if (self == map.boss[0])
357 self->think = &galdovDoInvisible;
362 map.boss[0]->currentWeapon = getRandomGaldovWeapon();
366 // Make sure only the real Galdov does this!
367 if (self == map.boss[0])
369 self->custom = Math::rrand(4, 8);
370 self->currentWeapon = &weapon[WP_ROCKETS];
371 self->think = &galdovRocketAttack;
376 // Make sure only the real Galdov does this!
377 if (self == map.boss[0])
379 self->think = &galdovCheckSplit;
388 if (map.mainBossPart != NULL)
390 map.mainBossPart = NULL;
391 audio.playSound(SND_BOSSCUSTOM2, CH_AMBIANCE);
394 if ((self->health % 5) == 0)
396 self->setActionFinished(5);
397 self->setThinkTime(2);
399 self->dx = Math::rrand(-5, 5);
400 self->dy = Math::rrand(-5, 5);
402 addExplosion(self->x, self->y, 5, &player);
403 addSmokeAndFire(self, Math::rrand(-4, 4), Math::rrand(-4, 4), 2);
406 for (int i = 1 ; i < 10 ; i++)
408 if (map.boss[i]->health > -1)
410 map.boss[i]->health = -1;
414 if (self->health <= -100)
416 checkObjectives(self->name, false);
417 map.mainBossPart = NULL;
418 addTeleportParticles(self->x, self->y, 75, SND_TELEPORT3);
422 void dropItems(int x, int y)
426 for (int i = 0 ; i < 2 ; i++)
428 r = Math::rrand(ITEM_PISTOL, ITEM_DOUBLECHERRY);
430 // Grenades make this battle far too easy(!)
431 if (r == ITEM_GRENADES)
434 if ((Math::prand() % 10) == 0)
435 r = ITEM_TRIPLECHERRY;
437 addItem(defItem[r].id, defItem[r].name, x, y, defItem[r].sprite[0]->name, 240, defItem[r].value, ENT_DYING, true);
443 dropItems((int)self->x, (int)self->y);
445 addExplosion(self->x, self->y, 50, self);
446 self->setThinkTime(2);
447 self->setActionFinished(2);
448 self->active = false;
456 debug(("galdovInit\n"));
458 map.boss[0] = new Boss();
459 strlcpy(map.boss[0]->name, "Galdov", sizeof map.boss[0]->name);
460 map.boss[0]->health = 45 * game.skill;
461 map.boss[0]->maxHealth = 45 * game.skill;
462 map.boss[0]->setSprites(graphics.getSprite("GaldovRight", true), graphics.getSprite("GaldovLeft", true), graphics.getSprite("GaldovLeft", true));
463 map.boss[0]->currentWeapon = &weapon[WP_AIMEDPISTOL];
464 map.boss[0]->face = 0;
465 map.boss[0]->active = true;
466 map.boss[0]->x = 448;
467 map.boss[0]->y = 9024;
468 map.boss[0]->immune = 0;
469 map.boss[0]->setThinkTime(2);
470 map.boss[0]->setActionFinished(2);
471 map.boss[0]->think = &galdovCheckSplit;
472 map.boss[0]->react = &galdovReact;
473 map.boss[0]->die = &galdovDie;
475 Math::addBit(&map.boss[0]->flags, ENT_AIMS);
477 SDL_SetAlpha(graphics.getSprite("GaldovInvsLeft", true)->image[0], SDL_SRCALPHA|SDL_RLEACCEL, 100);
478 SDL_SetAlpha(graphics.getSprite("GaldovInvsRight", true)->image[0], SDL_SRCALPHA|SDL_RLEACCEL, 100);
480 for (int i = 1 ; i < 10 ; i++)
482 map.boss[i] = new Boss();
483 strlcpy(map.boss[i]->name, "Fake", sizeof map.boss[i]->name);
484 map.boss[i]->setSprites(graphics.getSprite("GaldovRight", true), graphics.getSprite("GaldovLeft", true), graphics.getSprite("GaldovLeft", true));
485 map.boss[i]->x = 9999;
486 map.boss[i]->y = 9999;
487 map.boss[i]->active = false;
488 map.boss[i]->think = &galdovAttack;
489 map.boss[i]->react = NULL;
490 map.boss[i]->die = &fakeDie;
493 map.setMainBossPart(map.boss[0]);
495 audio.loadSound(SND_BOSSCUSTOM1, "sound/galdovSplit");
496 audio.loadSound(SND_BOSSCUSTOM2, "sound/galdovPain");
498 debug(("galdovInit: Done\n"));