diff --git a/common.mk b/common.mk index 615e23b..b6264f4 100644 --- a/common.mk +++ b/common.mk @@ -36,7 +36,7 @@ OBJS += camera.o cannon.o cardReader.o cell.o cherry.o combat.o controls.o consu OBJS += debris.o destructable.o door.o draw.o OBJS += effects.o ending.o entities.o entity.o entityFactory.o exit.o explosions.o eyeDroid.o eyeDroidCommander.o evilBlob.o OBJS += fleshChunk.o frost.o -OBJS += game.o grenade.o +OBJS += game.o grenade.o grenadeBlob.o grenadeDroid.o OBJS += heart.o horizontalDoor.o horizontalLaserTrap.o hub.o hud.o OBJS += i18n.o init.o infoPoint.o input.o io.o item.o items.o itemPad.o OBJS += cJSON.o diff --git a/src/entities/entityFactory.c b/src/entities/entityFactory.c index 1596e99..e18f4ab 100644 --- a/src/entities/entityFactory.c +++ b/src/entities/entityFactory.c @@ -38,6 +38,8 @@ void initEntityFactory(void) addEntityDef("GenericEvilBlob", initGenericEvilBlob); addEntityDef("GenericEyeDroid", initGenericEyeDroid); addEntityDef("MachineGunBlob", initMachineGunBlob); + addEntityDef("GrenadeBlob", initGrenadeBlob); + addEntityDef("GrenadeEyeDroid", initGrenadeDroid); addEntityDef("Bob", initBob); addEntityDef("MIA", initMIA); diff --git a/src/entities/entityFactory.h b/src/entities/entityFactory.h index cb178e8..bc32f27 100644 --- a/src/entities/entityFactory.h +++ b/src/entities/entityFactory.h @@ -24,6 +24,8 @@ extern Entity *initAquaBlob(void); extern Entity *initMachineGunBlob(void); extern Entity *initPistolBlob(void); extern Entity *initPistolDroid(void); +extern Entity *initGrenadeDroid(void); +extern Entity *initGrenadeBlob(void); extern Entity *initBob(void); extern Entity *initExit(void); extern Entity *initPowerPool(void); diff --git a/src/entities/evilBlobs/grenadeBlob.c b/src/entities/evilBlobs/grenadeBlob.c index 7ec6101..d36f74c 100644 --- a/src/entities/evilBlobs/grenadeBlob.c +++ b/src/entities/evilBlobs/grenadeBlob.c @@ -20,26 +20,41 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "grenadeBlob.h" -static void preFire2(void); +static void (*superPreFire)(void); +static void preFire(void); static int canFire(Entity *target); -void initGrenadeBlob(Unit *u) +Entity *initGrenadeBlob(void) { + Unit *u; + + u = createUnit(); + initEvilBlob(u); + + u->unitType = "GrenadeBlob"; u->sprite[FACING_LEFT] = getSprite("GrenadeBlobLeft"); u->sprite[FACING_RIGHT] = getSprite("GrenadeBlobRight"); u->sprite[FACING_DIE] = getSprite("GrenadeBlobSpin"); u->weaponType = WPN_GRENADES; + + superPreFire = u->preFire; - u->preFire = preFire2; + u->preFire = preFire; u->canFire = canFire; + + return (Entity*)u; } -static void preFire2(void) +static void preFire(void) { - preFire(this); + Unit *u; + + u = (Unit*)self; + + superPreFire(); if (u->shotsToFire == 0) { diff --git a/src/entities/evilBlobs/grenadeBlob.h b/src/entities/evilBlobs/grenadeBlob.h new file mode 100644 index 0000000..87bb9bc --- /dev/null +++ b/src/entities/evilBlobs/grenadeBlob.h @@ -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; diff --git a/src/entities/eyeDroids/grenadeDroid.c b/src/entities/eyeDroids/grenadeDroid.c index ed8ae8e..095674e 100644 --- a/src/entities/eyeDroids/grenadeDroid.c +++ b/src/entities/eyeDroids/grenadeDroid.c @@ -20,7 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "grenadeDroid.h" -static void preFire2(void); +static void (*superPreFire)(void); +static void preFire(void); static int canFire(Entity *target); void initGrenadeDroid(Unit *u) @@ -32,18 +33,20 @@ void initGrenadeDroid(Unit *u) u->sprite[FACING_DIE] = getSprite("GrenadeDroidDie"); u->weaponType = WPN_GRENADES; + + superPreFire = u->preFire; - u->preFire = preFire2; + u->preFire = preFire; u->canFire = canFire; } -static void preFire2(void) +static void preFire(void) { Unit *u; u = (Unit*)self; - preFire(self); + superPreFire(); if (u->shotsToFire == 0) { @@ -60,5 +63,5 @@ static void preFire2(void) static int canFire(Entity *target) { - return abs(target->y - y) <= MAP_TILE_SIZE * 2; + return abs(target->y - self->y) <= MAP_TILE_SIZE * 2; } diff --git a/src/entities/eyeDroids/grenadeDroid.h b/src/entities/eyeDroids/grenadeDroid.h new file mode 100644 index 0000000..b83685e --- /dev/null +++ b/src/entities/eyeDroids/grenadeDroid.h @@ -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 initEyeDroid(Unit *u); +extern Sprite *getSprite(char *name); + +extern Entity *self;