diff --git a/src/combat/weapons.c b/src/combat/weapons.c index 49d52bc..9151082 100644 --- a/src/combat/weapons.c +++ b/src/combat/weapons.c @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "weapons.h" -Entity *createBaseBullet(Entity *owner); +Bullet *createBaseBullet(Entity *owner); static int bulletSprite[2]; static int plasmaSprite[2]; @@ -60,7 +60,7 @@ void initWeapons(void) void firePistol(Entity *owner) { - Entity *bullet; + Bullet *bullet; bullet = createBaseBullet(owner); bullet->weaponType = WPN_PISTOL; @@ -77,7 +77,7 @@ void fireAimedShot(Entity *owner) { int x, y; float dx, dy; - Entity *bullet; + Bullet *bullet; x = (int) (world.bob->x + rrnd(-8, 24)); y = (int) (world.bob->y + rrnd(-8, 24)); @@ -98,7 +98,7 @@ void fireAimedShot(Entity *owner) void fireMachineGun(Entity *owner) { - Entity *bullet; + Bullet *bullet; bullet = createBaseBullet(owner); bullet->weaponType = WPN_MACHINE_GUN; @@ -111,7 +111,7 @@ void fireMachineGun(Entity *owner) void firePlasma(Entity *owner) { - Entity *bullet; + Bullet *bullet; bullet = createBaseBullet(owner); bullet->weaponType = WPN_PLASMA; @@ -126,7 +126,7 @@ void firePlasma(Entity *owner) void fireSpread(Entity *owner, int numberOfShots) { - Entity *bullet; + Bullet *bullet; int i; float dy; @@ -150,7 +150,7 @@ void fireSpread(Entity *owner, int numberOfShots) void fireLaser(Entity *owner) { - Entity *laser; + Bullet *laser; laser = createBaseBullet(owner); laser->x = owner->x + owner->w / 2; @@ -168,7 +168,7 @@ void fireLaser(Entity *owner) void fireGrenade(Entity *owner) { - Entity *grenade; + Bullet *grenade; grenade = createBaseBullet(owner); grenade->x = owner->x + owner->w / 2; @@ -190,7 +190,7 @@ void fireShotgun(Entity *owner) { int i; float dx, dy; - Entity *bullet; + Bullet *bullet; for (i = 0 ; i < 8 ; i++) { @@ -213,7 +213,7 @@ void fireShotgun(Entity *owner) void fireMissile(Entity *owner) { - Entity *missile; + Bullet *missile; missile = createBaseBullet(owner); missile->x = owner->x + owner->w / 2; @@ -230,11 +230,15 @@ void fireMissile(Entity *owner) playSound(SND_MISSILE, CH_WEAPON); } -Entity *createBaseBullet(Entity *owner) +Bullet *createBaseBullet(Entity *owner) { - Entity *bullet; + Bullet *bullet; + + bullet = malloc(sizeof(Bullet)); + memset(bullet, 0, sizeof(Bullet)); + world.bulletTail->next = bullet; + world.bulletTail = bullet; - bullet = createEntity(); bullet->x = (owner->x + owner->w / 2); bullet->y = (owner->y + owner->h / 2) - 3; bullet->dx = owner->facing == FACING_RIGHT ? 15 : -15; diff --git a/src/structs.h b/src/structs.h index 2547932..b69d360 100644 --- a/src/structs.h +++ b/src/structs.h @@ -31,6 +31,7 @@ typedef struct Tuple Tuple; typedef struct HubMission HubMission; typedef struct Widget Widget; typedef struct Atlas Atlas; +typedef struct Bullet Bullet; typedef struct { int debug; @@ -333,13 +334,25 @@ struct Particle { Particle *next; }; +struct Bullet { + int x; + int y; + int facing; + int damage; + int health; + int weaponType; + float dx; + float dy; + int sprite[2]; + Entity *owner; + Bullet *next; +}; + typedef struct { char id[MAX_NAME_LENGTH]; int state; Entity *bob, *boss; Map map; - Entity entityHead, *entityTail; - Particle particleHead, *particleTail; int allObjectivesComplete; int frameCounter; int currentStatus; @@ -348,6 +361,9 @@ typedef struct { int isOutpostMission; PointF checkpoints[MAX_CHECKPOINTS]; Quadtree quadtree; + Entity entityHead, *entityTail; + Particle particleHead, *particleTail; + Bullet bulletHead, *bulletTail; Objective objectiveHead, *objectiveTail; Trigger triggerHead, *triggerTail; } World; diff --git a/src/world/entities/blobs/teeka.c b/src/world/entities/blobs/teeka.c index deb53c5..5f768e4 100644 --- a/src/world/entities/blobs/teeka.c +++ b/src/world/entities/blobs/teeka.c @@ -139,7 +139,7 @@ static void preFire(void) static void attack(void) { - Entity *bullet; + Bullet *bullet; float dx, dy; getSlope(target->x, target->y, self->x, self->y, &dx, &dy); diff --git a/src/world/entities/blobs/teeka.h b/src/world/entities/blobs/teeka.h index 6977187..b501ed5 100644 --- a/src/world/entities/blobs/teeka.h +++ b/src/world/entities/blobs/teeka.h @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern void unitTick(void); extern int getSpriteIndex(char *name); extern int rrnd(int low, int high); -extern Entity *createBaseBullet(Entity *owner); +extern Bullet *createBaseBullet(Entity *owner); extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy); extern int getDistance(int x1, int y1, int x2, int y2); extern int hasLineOfSight(Entity *src, Entity *dest); diff --git a/src/world/entities/boss/blobBoss.c b/src/world/entities/boss/blobBoss.c index b837d08..88eb0d6 100644 --- a/src/world/entities/boss/blobBoss.c +++ b/src/world/entities/boss/blobBoss.c @@ -247,7 +247,7 @@ static void preFire(void) static void attack(void) { - Entity *bullet; + Bullet *bullet; float dx, dy; int bx, by; diff --git a/src/world/entities/boss/blobBoss.h b/src/world/entities/boss/blobBoss.h index 0bdbcc0..df15c2b 100644 --- a/src/world/entities/boss/blobBoss.h +++ b/src/world/entities/boss/blobBoss.h @@ -29,7 +29,7 @@ extern float limit(float i, float a, float b); extern double randF(void); extern void playSound(int snd, int ch); extern void animateEntity(Entity *e); -extern Entity *createBaseBullet(Entity *owner); +extern Bullet *createBaseBullet(Entity *owner); extern int getSpriteIndex(char *name); extern int getDistance(int x1, int y1, int x2, int y2); extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy); diff --git a/src/world/entities/boss/eyeDroidCommander.c b/src/world/entities/boss/eyeDroidCommander.c index d000d6f..2a2ff1b 100644 --- a/src/world/entities/boss/eyeDroidCommander.c +++ b/src/world/entities/boss/eyeDroidCommander.c @@ -228,7 +228,7 @@ static void attackPistol(void) { int bx, by; float dx, dy; - Entity *bullet; + Bullet *bullet; bx = world.bob->x + rrnd(-8, 24); by = world.bob->y + rrnd(-8, 24); @@ -254,7 +254,7 @@ static void attackPistol(void) static void attackPlasma(void) { - Entity *bullet; + Bullet *bullet; bullet = createBaseBullet(self); bullet->x = (self->x + self->w / 2); @@ -276,7 +276,7 @@ static void attackPlasma(void) static void attackMissile(void) { - Entity *missile; + Bullet *missile; missile = createBaseBullet(self); missile->x = self->x + self->w / 2; diff --git a/src/world/entities/boss/eyeDroidCommander.h b/src/world/entities/boss/eyeDroidCommander.h index 9e310ad..91acc5a 100644 --- a/src/world/entities/boss/eyeDroidCommander.h +++ b/src/world/entities/boss/eyeDroidCommander.h @@ -33,7 +33,7 @@ extern void addDefeatedTarget(char *name); extern void updateObjective(char *targetName); extern double randF(void); extern void playSound(int snd, int ch); -extern Entity *createBaseBullet(Entity *owner); +extern Bullet *createBaseBullet(Entity *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); diff --git a/src/world/entities/boss/tankCommander.c b/src/world/entities/boss/tankCommander.c index 03b9992..9e3bcf9 100644 --- a/src/world/entities/boss/tankCommander.c +++ b/src/world/entities/boss/tankCommander.c @@ -208,7 +208,7 @@ static void attackPistol(void) { int bx, by; float dx, dy; - Entity *bullet; + Bullet *bullet; bx = world.bob->x + rrnd(-8, 24); by = world.bob->y + rrnd(-8, 24); @@ -234,7 +234,7 @@ static void attackPistol(void) static void attackMissile(void) { - Entity *missile; + Bullet *missile; missile = createBaseBullet(self); missile->x = self->x + self->w / 2; diff --git a/src/world/entities/boss/tankCommander.h b/src/world/entities/boss/tankCommander.h index 81fde53..623ca75 100644 --- a/src/world/entities/boss/tankCommander.h +++ b/src/world/entities/boss/tankCommander.h @@ -31,7 +31,7 @@ extern int enemyCanSeePlayer(Entity *e); extern void addDefeatedTarget(char *name); extern void updateObjective(char *targetName); extern void playSound(int snd, int ch); -extern Entity *createBaseBullet(Entity *owner); +extern Bullet *createBaseBullet(Entity *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 addScorchDecal(int x, int y);