Boss updates.

This commit is contained in:
Steve 2018-02-24 15:58:14 +00:00
parent 258afd624d
commit 0d08f6096f
13 changed files with 101 additions and 43 deletions

View File

@ -20,13 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "blaze.h"
void initBlaze(Entity *e)
Entity *initBlaze(void)
{
Boss *b;
b = (Boss*)e;
initBlobBoss(b);
b = initBlobBoss();
b->weakAgainst = ENV_WATER;
@ -35,4 +33,6 @@ void initBlaze(Entity *e)
b->sprite[FACING_LEFT] = getSprite("BlazeLeft");
b->sprite[FACING_RIGHT] = getSprite("BlazeRight");
b->sprite[FACING_DIE] = getSprite("BlazeSpin");
return (Entity*)b;
}

View File

@ -20,5 +20,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initBlobBoss(Boss *b);
extern Boss *initBlobBoss(void);
extern Sprite *getSprite(char *name);

View File

@ -37,13 +37,11 @@ static void (*superAnimate)(void);
static Sprite *aimedSprite;
void initBlobBoss(Entity *e)
Boss *initBlobBoss(void)
{
Boss *b;
initBoss(e);
b = (Boss*)e;
b = initBoss();
b->flags |= EF_HALT_AT_EDGE;
@ -54,6 +52,7 @@ void initBlobBoss(Entity *e)
superAnimate = b->animate;
b->activate = activate;
b->action = walk;
b->walk = walk;
b->tick = tick;
b->changeEnvironment = changeEnvironment;
@ -63,6 +62,8 @@ void initBlobBoss(Entity *e)
b->die = die1;
aimedSprite = getSprite("AimedShot");
return b;
}
static void activate(int activate)
@ -94,6 +95,11 @@ static void tick(void)
b->health -= 2;
world.boss = b;
if (b->stunTimer == 0)
{
teleport();
}
}
if (b->stunTimer == 0)
@ -177,15 +183,18 @@ static void die1(void)
static SDL_Rect *getCurrentSprite(void)
{
Boss *b;
Sprite *s;
b = (Boss*)self;
if (b->stunTimer > 0 || b->health <= 0)
s = (b->stunTimer > 0 || b->health <= 0) ? b->sprite[FACING_DIE] : b->sprite[b->facing];
if (self->spriteFrame >= s->numFrames)
{
return &b->sprite[FACING_DIE]->frames[self->spriteFrame]->rect;
self->spriteFrame = 0;
}
return &b->sprite[b->facing]->frames[self->spriteFrame]->rect;
return &s->frames[self->spriteFrame]->rect;
}
static void animate(void)
@ -194,7 +203,13 @@ static void animate(void)
b = (Boss*)self;
if (b->dx != 0 || b->health <= 0 || b->stunTimer > 0)
if (b->alive != ALIVE_ALIVE || b->stunTimer > 0)
{
b->facing = FACING_DIE;
superAnimate();
}
else if (b->dx != 0)
{
superAnimate();
}
@ -255,7 +270,7 @@ static void moveTowardsPlayer(void)
}
}
if (b->stunTimer == 0 && b->teleportTimer == 0)
if (rand() % 10 == 0 && b->stunTimer == 0 && b->teleportTimer == 0)
{
teleport();
@ -358,6 +373,8 @@ static void applyDamage(int amount)
}
static void teleport(void)
{
if (self->health > 0)
{
self->action = reappear;
self->flags |= EF_GONE;
@ -365,6 +382,7 @@ static void teleport(void)
addTeleportStars(self);
playSound(SND_APPEAR, CH_ANY);
}
}
static void die2(void)
{
@ -380,7 +398,8 @@ static void die2(void)
playSound(SND_APPEAR, CH_ANY);
b->alive = ALIVE_DEAD;
/* don't die! */
b->flags |= EF_GONE;
updateObjective(b->name);
@ -392,5 +411,7 @@ static void die2(void)
{
awardTrophy("BLAZE_FROST");
}
b->action = entityIdle;
}
}

View File

@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initBoss(Entity *e);
extern Boss *initBoss(void);
extern int rrnd(int low, int high);
extern void addTeleportStars(Entity *e);
extern void playMusic(char *filename, int loop);
@ -35,6 +35,7 @@ extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
extern int enemyCanSeePlayer(Entity *e);
extern void updateObjective(char *targetName);
extern void awardTrophy(char *id);
extern void entityIdle(void);
extern Entity *self;
extern Game game;

View File

@ -20,15 +20,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "boss.h"
static void lookForPlayer(void);
static void load(cJSON *root);
static void save(cJSON *root);
static void init(void);
void initBoss(Entity *e)
Boss *initBoss(void)
{
Boss *b;
initEntity(e);
b = malloc(sizeof(Boss));
memset(b, 0, sizeof(Boss));
b = (Boss*)e;
initEntity((Entity*)b);
b->type = ET_BOSS;
@ -36,16 +39,32 @@ void initBoss(Entity *e)
b->isMissionTarget = 1;
b->action = lookForPlayer;
b->spriteFrame = 0;
b->spriteTime = 0;
world.boss = b;
b->flags |= EF_ALWAYS_PROCESS | EF_BOMB_SHIELD | EF_GONE;
b->init = init;
b->load = load;
b->save = save;
return b;
}
static void lookForPlayer(void)
void bossIdle(void)
{
}
static void init(void)
{
}
static void load(cJSON *root)
{
}
static void save(cJSON *root)
{
}

View File

@ -372,7 +372,8 @@ static void die2()
playSound(SND_APPEAR, CH_ANY);
b->alive = ALIVE_DEAD;
/* don't die! */
b->flags |= EF_GONE;
updateObjective(b->name);
@ -381,15 +382,21 @@ static void die2()
awardTrophy("EYEDROID_COMMANDER");
game.stats[STAT_ENEMIES_KILLED]++;
b->action = entityIdle;
}
}
static SDL_Rect *getCurrentSprite(void)
{
if (self->health <= 0)
Sprite *s;
s = (self->alive == ALIVE_ALIVE) ? self->sprite[self->facing] : self->sprite[FACING_DIE];
if (self->spriteFrame >= s->numFrames)
{
return &self->sprite[FACING_DIE]->frames[self->spriteFrame]->rect;
self->spriteFrame = 0;
}
return &self->sprite[self->facing]->frames[self->spriteFrame]->rect;
return &s->frames[self->spriteFrame]->rect;
}

View File

@ -36,6 +36,7 @@ extern Bullet *createBaseBullet(Unit *owner);
extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
extern void addExplosion(float x, float y, int radius, Entity *owner);
extern void awardTrophy(char *id);
extern void entityIdle(void);
extern Entity *self;
extern Game game;

View File

@ -20,13 +20,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "frost.h"
void initFrost(Entity *e)
Entity *initFrost(void)
{
Boss *b;
initBlobBoss(e);
b = (Boss*)e;
b = initBlobBoss();
b->weakAgainst = ENV_LAVA;
@ -35,4 +33,6 @@ void initFrost(Entity *e)
b->sprite[FACING_LEFT] = getSprite("FrostLeft");
b->sprite[FACING_RIGHT] = getSprite("FrostRight");
b->sprite[FACING_DIE] = getSprite("FrostSpin");
return (Entity*)b;
}

View File

@ -20,5 +20,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h"
extern void initBlobBoss(Entity *e);
extern Boss *initBlobBoss(void);
extern Sprite *getSprite(char *name);

View File

@ -64,8 +64,6 @@ void initTankCommander(Entity *e)
brakingTimer = 0;
world.boss = b;
aimedSprite = getSprite("AimedShot");
missileSprite[0] = getSprite("MissileRight");
@ -326,7 +324,9 @@ static void die2(void)
playSound(SND_APPEAR, CH_ANY);
b->alive = tankTrack->alive = ALIVE_DEAD;
/* don't die! */
b->flags |= EF_GONE;
tankTrack->alive |= EF_GONE;
updateObjective(b->name);
@ -335,6 +335,8 @@ static void die2(void)
awardTrophy("TANK_COMMANDER");
game.stats[STAT_ENEMIES_KILLED]++;
b->action = entityIdle;
}
}

View File

@ -36,6 +36,7 @@ extern void addExplosion(float x, float y, int radius, Entity *owner);
extern void addScorchDecal(int x, int y);
extern void initTankTrack(Entity *e);
extern void awardTrophy(char *id);
extern void entityIdle(void);
extern Entity *self;
extern Game game;

View File

@ -50,6 +50,8 @@ void initEntityFactory(void)
addEntityDef("PlasmaEyeDroid", initPlasmaDroid);
addEntityDef("PlasmaBlob", initPlasmaBlob);
addEntityDef("Cannon", initCannon);
addEntityDef("Blaze", initBlaze);
addEntityDef("Frost", initFrost);
addEntityDef("Bob", initBob);
addEntityDef("MIA", initMIA);
@ -64,6 +66,7 @@ void initEntityFactory(void)
addEntityDef("RedKeycard", initRedKeycard);
addEntityDef("YellowKeycard", initYellowKeycard);
addEntityDef("WhiteKeycard", initWhiteKeycard);
addEntityDef("WeaponPickup", initWeaponPickup);
addEntityDef("Cell", initCell);
addEntityDef("Heart", initHeart);

View File

@ -68,5 +68,8 @@ extern Entity *initTeeka(void);
extern Entity *initDestructable(void);
extern Entity *initCannon(void);
extern Entity *initItemPad(void);
extern Entity *initWeaponPickup(void);
extern Entity *initBlaze(void);
extern Entity *initFrost(void);
extern World world;