Added Shotgun Blob / Droid, and laser traps.

This commit is contained in:
Steve 2018-02-09 19:10:19 +00:00
parent acb00a7d95
commit 442f561f00
12 changed files with 126 additions and 13 deletions

View File

@ -46,7 +46,7 @@ OBJS += machineGunBlob.o main.o map.o maths.o mia.o missile.o
OBJS += objectives.o OBJS += objectives.o
OBJS += particles.o player.o pistolBlob.o pistolDroid.o powerPoint.o powerPool.o pressurePlate.o pushBlock.o OBJS += particles.o player.o pistolBlob.o pistolDroid.o powerPoint.o powerPool.o pressurePlate.o pushBlock.o
OBJS += quadtree.o OBJS += quadtree.o
OBJS += sound.o sprites.o structures.o OBJS += shotgunBlob.o shotgunDroid.o sound.o sprites.o structures.o
OBJS += tankCommander.o tankTrack.o teeka.o teleporter.o text.o textures.o title.o triggers.o OBJS += tankCommander.o tankTrack.o teeka.o teleporter.o text.o textures.o title.o triggers.o
OBJS += unit.o util.o OBJS += unit.o util.o
OBJS += weapons.o weaponPickup.o widgets.o world.o worldLoader.o OBJS += weapons.o weaponPickup.o widgets.o world.o worldLoader.o

View File

@ -40,6 +40,8 @@ void initEntityFactory(void)
addEntityDef("MachineGunBlob", initMachineGunBlob); addEntityDef("MachineGunBlob", initMachineGunBlob);
addEntityDef("GrenadeBlob", initGrenadeBlob); addEntityDef("GrenadeBlob", initGrenadeBlob);
addEntityDef("GrenadeEyeDroid", initGrenadeDroid); addEntityDef("GrenadeEyeDroid", initGrenadeDroid);
addEntityDef("ShotgunBlob", initShotgunBlob);
addEntityDef("ShotgunEyeDroid", initShotgunDroid);
addEntityDef("Bob", initBob); addEntityDef("Bob", initBob);
addEntityDef("MIA", initMIA); addEntityDef("MIA", initMIA);
@ -70,6 +72,8 @@ void initEntityFactory(void)
addEntityDef("GoldDoor", initGoldDoor); addEntityDef("GoldDoor", initGoldDoor);
addEntityDef("HorizontalDoor", initHorizontalDoor); addEntityDef("HorizontalDoor", initHorizontalDoor);
addEntityDef("CardReader", initCardReader); addEntityDef("CardReader", initCardReader);
addEntityDef("LaserTrap", initLaserTrap);
addEntityDef("HorizontalLaserTrap", initHorizontalLaserTrap);
} }
Entity *createEntity(char *name) Entity *createEntity(char *name)

View File

@ -26,6 +26,8 @@ extern Entity *initPistolBlob(void);
extern Entity *initPistolDroid(void); extern Entity *initPistolDroid(void);
extern Entity *initGrenadeDroid(void); extern Entity *initGrenadeDroid(void);
extern Entity *initGrenadeBlob(void); extern Entity *initGrenadeBlob(void);
extern Entity *initShotgunDroid(void);
extern Entity *initShotgunBlob(void);
extern Entity *initBob(void); extern Entity *initBob(void);
extern Entity *initExit(void); extern Entity *initExit(void);
extern Entity *initPowerPool(void); extern Entity *initPowerPool(void);
@ -52,5 +54,7 @@ extern Entity *initCardReader(void);
extern Entity *initBlueKeycard(void); extern Entity *initBlueKeycard(void);
extern Entity *initRedKeycard(void); extern Entity *initRedKeycard(void);
extern Entity *initYellowKeycard(void); extern Entity *initYellowKeycard(void);
extern Entity *initLaserTrap(void);
extern Entity *initHorizontalLaserTrap(void);
extern World world; extern World world;

View File

@ -22,10 +22,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static int canFire(Entity *target); static int canFire(Entity *target);
void initShotgunBlob(Unit *u) Entity *initShotgunBlob(void)
{ {
Unit *u;
u = createUnit();
initEvilBlob(u); initEvilBlob(u);
u->unitType = "ShotgunBlob";
u->sprite[FACING_LEFT] = getSprite("ShotgunBlobLeft"); u->sprite[FACING_LEFT] = getSprite("ShotgunBlobLeft");
u->sprite[FACING_RIGHT] = getSprite("ShotgunBlobRight"); u->sprite[FACING_RIGHT] = getSprite("ShotgunBlobRight");
u->sprite[FACING_DIE] = getSprite("ShotgunBlobSpin"); u->sprite[FACING_DIE] = getSprite("ShotgunBlobSpin");
@ -35,10 +41,12 @@ void initShotgunBlob(Unit *u)
u->maxShotsToFire = 2; u->maxShotsToFire = 2;
u->canFire = canFire; u->canFire = canFire;
return (Entity*)u;
} }
static int canFire(Entity *target) static int canFire(Entity *target)
{ {
return true; return 1;
} }

View File

@ -0,0 +1,27 @@
/*
Copyright (C) 2018 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../../common.h"
extern Unit *createUnit(void);
extern void initEvilBlob(Unit *u);
extern Sprite *getSprite(char *name);
extern Entity *self;

View File

@ -22,9 +22,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static int canFire(Entity *target); static int canFire(Entity *target);
void initShotgunDroid(Unit *u) Entity *initShotgunDroid(void)
{ {
Unit *u;
u = createUnit();
initEyeDroid(u); initEyeDroid(u);
u->unitType = "ShotgunEyeDroid";
u->sprite[FACING_LEFT] = getSprite("ShotgunDroidLeft"); u->sprite[FACING_LEFT] = getSprite("ShotgunDroidLeft");
u->sprite[FACING_RIGHT] = getSprite("ShotgunDroidRight"); u->sprite[FACING_RIGHT] = getSprite("ShotgunDroidRight");
@ -35,9 +41,11 @@ void initShotgunDroid(Unit *u)
u->maxShotsToFire = 2; u->maxShotsToFire = 2;
u->canFire = canFire; u->canFire = canFire;
return (Entity*)u;
} }
static int canFire(Entity *target) static int canFire(Entity *target)
{ {
return true; return 1;
} }

View File

@ -0,0 +1,25 @@
/*
Copyright (C) 2018 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../../common.h"
extern Unit *createUnit(void);
extern void initEyeDroid(Unit *u);
extern Sprite *getSprite(char *name);

View File

@ -21,4 +21,3 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "../../common.h" #include "../../common.h"
extern void initEntity(Entity *e); extern void initEntity(Entity *e);

View File

@ -20,11 +20,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "horizontalLaserTrap.h" #include "horizontalLaserTrap.h"
void initHorizontalLaserTrap(Entity *e) Entity *initHorizontalLaserTrap(void)
{ {
initLaserTrap(e); Entity *e;
e->type = ET_TRAP; e = initLaserTrap();
e->sprite[0] = e->sprite[1] = e->sprite[2] = getSprite("HorizontalLaserTrap"); e->sprite[0] = e->sprite[1] = e->sprite[2] = getSprite("HorizontalLaserTrap");
return e;
} }

View File

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

View File

@ -25,14 +25,17 @@ static void tick(void);
static void action(void); static void action(void);
static void touch(Entity *other); static void touch(Entity *other);
static void activate(int active); static void activate(int active);
static void load(cJSON *root);
static void save(cJSON *root);
void initLaserTrap(Entity *e) Entity *initLaserTrap(void)
{ {
Trap *t; Trap *t;
initEntity(e); t = malloc(sizeof(Trap));
memset(t, 0, sizeof(Trap));
t = (Trap*)e; initEntity((Entity*)t);
t->type = ET_TRAP; t->type = ET_TRAP;
@ -50,6 +53,10 @@ void initLaserTrap(Entity *e)
t->action = action; t->action = action;
t->touch = touch; t->touch = touch;
t->activate = activate; t->activate = activate;
t->load = load;
t->save = save;
return (Entity*)t;
} }
static void init(void) static void init(void)
@ -130,6 +137,8 @@ static void touch(Entity *other)
other->applyDamage((int) other->health); other->applyDamage((int) other->health);
swapSelf(other); swapSelf(other);
} }
playSound(SND_FLESH_HIT, CH_ANY);
} }
if (other == (Entity*)world.bob && world.bob->stunTimer == 0) if (other == (Entity*)world.bob && world.bob->stunTimer == 0)
@ -172,3 +181,28 @@ static void activate(int active)
} }
} }
} }
static void load(cJSON *root)
{
Trap *t;
t = (Trap*)self;
if (cJSON_GetObjectItem(root, "active"))
{
t->active = cJSON_GetObjectItem(root, "active")->valueint;
}
t->onTime = cJSON_GetObjectItem(root, "onTime")->valueint;
t->offTime = cJSON_GetObjectItem(root, "offTime")->valueint;
}
static void save(cJSON *root)
{
Trap *t;
t = (Trap*)self;
cJSON_AddNumberToObject(root, "active", t->active);
cJSON_AddNumberToObject(root, "onTime", t->onTime);
cJSON_AddNumberToObject(root, "offTime", t->offTime);
}

View File

@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include "../../common.h" #include "../../common.h"
#include "../../json/cJSON.h"
extern void initEntity(Entity *e); extern void initEntity(Entity *e);
extern void observeActivation(Entity *e); extern void observeActivation(Entity *e);
@ -30,6 +31,7 @@ extern void stunBob(void);
extern void addSparkParticles(float x, float y); extern void addSparkParticles(float x, float y);
extern void addSmallFleshChunk(float x, float y); extern void addSmallFleshChunk(float x, float y);
extern void swapSelf(Entity *e); extern void swapSelf(Entity *e);
extern void playSound(int snd, int ch);
extern Entity *self; extern Entity *self;
extern World world; extern World world;