2018-01-26 23:29:08 +01:00
|
|
|
/*
|
|
|
|
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 "weaponPickup.h"
|
|
|
|
|
|
|
|
static void (*itemTick)(void);
|
|
|
|
static void tick(void);
|
|
|
|
static void touch(Entity *other);
|
|
|
|
|
2018-01-28 17:33:37 +01:00
|
|
|
static char *description[WPN_ANY] = {
|
2018-01-26 23:29:08 +01:00
|
|
|
"Pistol",
|
|
|
|
"Plasma Rifle",
|
|
|
|
"Spread Gun",
|
|
|
|
"Laser Cannon",
|
|
|
|
"Grenades"
|
|
|
|
};
|
|
|
|
|
|
|
|
void initWeaponPickup(Entity *e)
|
|
|
|
{
|
2018-01-28 09:30:53 +01:00
|
|
|
Item *i;
|
|
|
|
|
2018-01-26 23:29:08 +01:00
|
|
|
initConsumable(e);
|
2018-01-28 09:30:53 +01:00
|
|
|
|
|
|
|
i = (Item*)e;
|
2018-01-26 23:29:08 +01:00
|
|
|
|
2018-01-28 09:30:53 +01:00
|
|
|
i->weaponType = WPN_PISTOL;
|
2018-01-26 23:29:08 +01:00
|
|
|
|
2018-01-28 09:30:53 +01:00
|
|
|
i->sprite[0] = i->sprite[1] = i->sprite[2] = getSpriteIndex("Weapon");
|
|
|
|
i->spriteFrame = i->weaponType;
|
|
|
|
i->spriteTime = -1;
|
2018-01-26 23:29:08 +01:00
|
|
|
|
|
|
|
setEntitySize(e);
|
|
|
|
|
2018-01-28 09:30:53 +01:00
|
|
|
if (i->provided)
|
2018-01-26 23:29:08 +01:00
|
|
|
{
|
2018-01-28 09:30:53 +01:00
|
|
|
i->health = 9999;
|
2018-01-26 23:29:08 +01:00
|
|
|
}
|
|
|
|
|
2018-01-28 09:30:53 +01:00
|
|
|
itemTick = i->tick;
|
2018-01-26 23:29:08 +01:00
|
|
|
|
2018-01-28 09:30:53 +01:00
|
|
|
i->tick = tick;
|
|
|
|
i->touch = touch;
|
2018-01-26 23:29:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void tick(void)
|
|
|
|
{
|
2018-01-28 09:30:53 +01:00
|
|
|
Item *i;
|
|
|
|
|
|
|
|
i = (Item*)self;
|
|
|
|
|
2018-01-26 23:29:08 +01:00
|
|
|
itemTick();
|
|
|
|
|
2018-01-28 09:30:53 +01:00
|
|
|
if (i->provided && i->alive == ALIVE_ALIVE)
|
2018-01-26 23:29:08 +01:00
|
|
|
{
|
2018-01-28 09:30:53 +01:00
|
|
|
i->health = 9999;
|
2018-01-26 23:29:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void touch(Entity *other)
|
|
|
|
{
|
2018-01-28 09:30:53 +01:00
|
|
|
Item *i;
|
|
|
|
|
|
|
|
i = (Item*)self;
|
|
|
|
|
2018-01-26 23:29:08 +01:00
|
|
|
if (touchedPlayer(other))
|
|
|
|
{
|
2018-01-28 09:30:53 +01:00
|
|
|
world.bob->weaponType = i->weaponType;
|
2018-01-26 23:29:08 +01:00
|
|
|
|
2018-01-28 09:30:53 +01:00
|
|
|
switch (i->weaponType)
|
2018-01-26 23:29:08 +01:00
|
|
|
{
|
|
|
|
case WPN_GRENADES:
|
2018-01-28 17:33:37 +01:00
|
|
|
setGameplayMessage(MSG_STANDARD, _("Got some Grenades"));
|
2018-01-26 23:29:08 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-01-28 17:33:37 +01:00
|
|
|
setGameplayMessage(MSG_STANDARD, _("Picked up a %s"), _(description[i->weaponType]));
|
2018-01-26 23:29:08 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pickupItem();
|
|
|
|
|
|
|
|
playSound(SND_WEAPON, CH_ITEM);
|
|
|
|
}
|
|
|
|
}
|