Power up fixes.
This commit is contained in:
parent
89b4b05a11
commit
e70966e35d
|
@ -20,19 +20,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "battery.h"
|
||||
|
||||
void initBattery(Entity *e)
|
||||
static void touch(Entity *other);
|
||||
|
||||
Item *initBattery(void)
|
||||
{
|
||||
Item *i;
|
||||
|
||||
initConsumable(e);
|
||||
i = initConsumable();
|
||||
|
||||
i = (Item*)e;
|
||||
|
||||
i->spriteFrame = 0;
|
||||
i->spriteTime = -1;
|
||||
|
||||
i->touch = touch;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void touch(Entity *other)
|
||||
static void touch(Entity *other)
|
||||
{
|
||||
Item *i;
|
||||
|
||||
|
|
|
@ -20,10 +20,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "../../common.h"
|
||||
|
||||
extern Item *initConsumable(void);
|
||||
extern void playSound(int snd, int ch);
|
||||
extern void pickupItem(void);
|
||||
extern void setGameplayMessage(int type, char *format, ...);
|
||||
extern void initConsumable(Entity *e);
|
||||
extern int touchedPlayer(Entity *e);
|
||||
|
||||
extern Entity *self;
|
||||
|
|
|
@ -22,11 +22,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
static void touch(Entity *other);
|
||||
|
||||
void initCherry(Entity *e)
|
||||
Item *initCherry(void)
|
||||
{
|
||||
initConsumable(e);
|
||||
Item *i;
|
||||
|
||||
e->touch = touch;
|
||||
i = initConsumable();
|
||||
|
||||
i->touch = touch;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static void touch(Entity *other)
|
||||
|
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "../../common.h"
|
||||
|
||||
extern void initConsumable(Entity *e);
|
||||
extern Item *initConsumable(void);
|
||||
extern void setGameplayMessage(int type, char *format, ...);
|
||||
extern void playSound(int snd, int ch);
|
||||
extern int touchedPlayer(Entity *other);
|
||||
|
|
|
@ -23,18 +23,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
static void tick(void);
|
||||
static void die(void);
|
||||
|
||||
void initConsumable(Entity *e)
|
||||
Item *initConsumable(void)
|
||||
{
|
||||
initEntity(e);
|
||||
Item *i;
|
||||
|
||||
e->type = ET_CONSUMABLE;
|
||||
i = malloc(sizeof(Item));
|
||||
memset(i, 0, sizeof(Item));
|
||||
|
||||
e->flags |= EF_IGNORE_BULLETS;
|
||||
initEntity((Entity*)i);
|
||||
|
||||
i->type = ET_CONSUMABLE;
|
||||
|
||||
i->flags |= EF_IGNORE_BULLETS;
|
||||
|
||||
e->health = FPS * 10;
|
||||
i->health = FPS * 10;
|
||||
|
||||
e->tick = tick;
|
||||
e->die = die;
|
||||
i->tick = tick;
|
||||
i->die = die;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static void tick(void)
|
||||
|
|
|
@ -20,20 +20,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "weaponPickup.h"
|
||||
|
||||
static void (*itemTick)(void);
|
||||
static void (*superTick)(void);
|
||||
static void init(void);
|
||||
static void tick(void);
|
||||
static void touch(Entity *other);
|
||||
|
||||
void initWeaponPickup(Entity *e)
|
||||
Entity *initWeaponPickup(void)
|
||||
{
|
||||
Item *i;
|
||||
|
||||
initConsumable(e);
|
||||
|
||||
i = (Item*)e;
|
||||
i = (Item*)initConsumable();
|
||||
|
||||
i->weaponType = WPN_PISTOL;
|
||||
|
||||
superTick = i->tick;
|
||||
|
||||
i->init = init;
|
||||
i->tick = tick;
|
||||
i->touch = touch;
|
||||
|
||||
return (Entity*)i;
|
||||
}
|
||||
|
||||
static void init(void)
|
||||
{
|
||||
Item *i;
|
||||
|
||||
i = (Item*)self;
|
||||
|
||||
i->sprite[0] = i->sprite[1] = i->sprite[2] = getSprite("Weapon");
|
||||
i->spriteFrame = i->weaponType;
|
||||
i->spriteTime = -1;
|
||||
|
@ -42,11 +56,6 @@ void initWeaponPickup(Entity *e)
|
|||
{
|
||||
i->health = 9999;
|
||||
}
|
||||
|
||||
itemTick = i->tick;
|
||||
|
||||
i->tick = tick;
|
||||
i->touch = touch;
|
||||
}
|
||||
|
||||
static void tick(void)
|
||||
|
@ -55,7 +64,7 @@ static void tick(void)
|
|||
|
||||
i = (Item*)self;
|
||||
|
||||
itemTick();
|
||||
superTick();
|
||||
|
||||
if (i->provided && i->alive == ALIVE_ALIVE)
|
||||
{
|
||||
|
|
|
@ -22,11 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
extern void playSound(int snd, int ch);
|
||||
extern void setGameplayMessage(int type, char *format, ...);
|
||||
extern void initConsumable(Entity *e);
|
||||
extern Sprite *getSprite(char *name);
|
||||
extern void pickupItem(void);
|
||||
extern int touchedPlayer(Entity *e);
|
||||
extern const char *getWeaponName(int i);
|
||||
extern Entity *initConsumable(void);
|
||||
|
||||
extern Entity *self;
|
||||
extern World world;
|
||||
|
|
|
@ -231,7 +231,7 @@ void drawEntities(int plane)
|
|||
|
||||
for (i = 0, self = candidates[i] ; self != NULL ; self = candidates[++i])
|
||||
{
|
||||
draw = !(self->flags & EF_GONE) && self->plane == plane;
|
||||
draw = self->isOnScreen && !(self->flags & EF_GONE) && self->plane == plane;
|
||||
|
||||
if (draw)
|
||||
{
|
||||
|
|
|
@ -39,34 +39,22 @@ void initItems(void)
|
|||
|
||||
void addRandomWeapon(float x, float y)
|
||||
{
|
||||
Item *wpn;
|
||||
Item *i;
|
||||
int type;
|
||||
|
||||
wpn = malloc(sizeof(Item));
|
||||
memset(wpn, 0, sizeof(Item));
|
||||
world.entityTail->next = (Entity*)wpn;
|
||||
world.entityTail = (Entity*)wpn;
|
||||
|
||||
wpn->x = x;
|
||||
wpn->y = y;
|
||||
|
||||
type = getRandomPlayerWeaponAt(wpn->x, wpn->y);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
wpn->touch = NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
wpn->sprite[0] = wpn->sprite[1] = wpn->sprite[2] = wpnIconSprite;
|
||||
wpn->spriteFrame = type;
|
||||
wpn->spriteTime = -1;
|
||||
|
||||
throwItem(wpn);
|
||||
i = initWeaponPickup();
|
||||
|
||||
i->x = x;
|
||||
i->y = y;
|
||||
|
||||
type = getRandomPlayerWeaponAt(i->x, i->y);
|
||||
|
||||
i->weaponType = type;
|
||||
i->sprite[0] = i->sprite[1] = i->sprite[2] = wpnIconSprite;
|
||||
i->spriteFrame = type;
|
||||
i->spriteTime = -1;
|
||||
|
||||
throwItem(i);
|
||||
}
|
||||
|
||||
static int getRandomPlayerWeaponAt(int x, int y)
|
||||
|
@ -79,7 +67,7 @@ static int getRandomPlayerWeaponAt(int x, int y)
|
|||
{
|
||||
type = WPN_PISTOL;
|
||||
}
|
||||
else if (type == WPN_PISTOL && rand() < 0.25)
|
||||
else if (type == WPN_PISTOL && rand() % 100 < 25)
|
||||
{
|
||||
type = getRandomPlayerWeapon(world.isBossMission);
|
||||
}
|
||||
|
@ -92,34 +80,32 @@ void dropRandomCherry(float x, float y)
|
|||
Item *i;
|
||||
int r;
|
||||
|
||||
i = malloc(sizeof(Item));
|
||||
memset(i, 0, sizeof(Item));
|
||||
world.entityTail->next = (Entity*)i;
|
||||
world.entityTail = (Entity*)i;
|
||||
i = initCherry();
|
||||
|
||||
r = rand() % 100;
|
||||
|
||||
if (r < 1)
|
||||
{
|
||||
STRNCPY(i->name, "bunch of cherries", MAX_NAME_LENGTH);
|
||||
STRNCPY(i->name, _("bunch of cherries"), MAX_NAME_LENGTH);
|
||||
i->value = 10;
|
||||
i->sprite[0] = i->sprite[1] = i->sprite[2] = cherrySprite[2];
|
||||
}
|
||||
else if (r < 10)
|
||||
{
|
||||
STRNCPY(i->name, "pair of cherries", MAX_NAME_LENGTH);
|
||||
STRNCPY(i->name, _("pair of cherries"), MAX_NAME_LENGTH);
|
||||
i->value = 3;
|
||||
i->sprite[0] = i->sprite[1] = i->sprite[2] = cherrySprite[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
STRNCPY(i->name, "small cherry", MAX_NAME_LENGTH);
|
||||
STRNCPY(i->name, _("small cherry"), MAX_NAME_LENGTH);
|
||||
i->value = 1;
|
||||
i->sprite[0] = i->sprite[1] = i->sprite[2] = cherrySprite[0];
|
||||
}
|
||||
|
||||
i->x = x;
|
||||
i->y = y;
|
||||
i->spriteFrame = 0;
|
||||
|
||||
throwItem(i);
|
||||
}
|
||||
|
@ -128,32 +114,29 @@ void dropBattery(float x, float y)
|
|||
{
|
||||
Item *i;
|
||||
int r;
|
||||
|
||||
i = malloc(sizeof(Item));
|
||||
memset(i, 0, sizeof(Item));
|
||||
world.entityTail->next = (Entity*)i;
|
||||
world.entityTail = (Entity*)i;
|
||||
|
||||
i = initBattery();
|
||||
|
||||
r = rand() % 100;
|
||||
|
||||
if (r < 1)
|
||||
{
|
||||
STRNCPY(i->name, "full battery", MAX_NAME_LENGTH);
|
||||
STRNCPY(i->name, _("full battery"), MAX_NAME_LENGTH);
|
||||
i->value = 4;
|
||||
}
|
||||
else if (r < 10)
|
||||
{
|
||||
STRNCPY(i->name, "battery", MAX_NAME_LENGTH);
|
||||
STRNCPY(i->name, _("battery"), MAX_NAME_LENGTH);
|
||||
i->value = 3;
|
||||
}
|
||||
else if (r < 25)
|
||||
{
|
||||
STRNCPY(i->name, "used battery", MAX_NAME_LENGTH);
|
||||
STRNCPY(i->name, _("used battery"), MAX_NAME_LENGTH);
|
||||
i->value = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
STRNCPY(i->name, "weak battery", MAX_NAME_LENGTH);
|
||||
STRNCPY(i->name, _("weak battery"), MAX_NAME_LENGTH);
|
||||
i->value = 1;
|
||||
}
|
||||
|
||||
|
@ -163,6 +146,8 @@ void dropBattery(float x, float y)
|
|||
|
||||
i->x = x;
|
||||
i->y = y;
|
||||
|
||||
i->animate();
|
||||
|
||||
throwItem(i);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "../common.h"
|
||||
|
||||
extern Entity *initItem(void);
|
||||
extern int rrnd(int low, int high);
|
||||
extern int getRandomPlayerWeapon(int excludeGrenades);
|
||||
extern Sprite *getSprite(char *name);
|
||||
extern void addRandomItems(float x, float y);
|
||||
extern Item *initBattery(void);
|
||||
extern Item *initCherry(void);
|
||||
extern Item * initWeaponPickup(void);
|
||||
|
||||
extern World world;
|
||||
|
|
Loading…
Reference in New Issue