2008-09-15 14:11:05 +00:00
|
|
|
/*
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "gi.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "d_player.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "a_hexenglobal.h"
|
2008-08-10 20:48:55 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-11-07 10:20:09 +00:00
|
|
|
// Fighter Weapon Base Class ------------------------------------------------
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (AFighterWeapon)
|
|
|
|
IMPLEMENT_CLASS (AClericWeapon)
|
|
|
|
IMPLEMENT_CLASS (AMageWeapon)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-09-13 22:08:41 +00:00
|
|
|
bool AFighterWeapon::TryPickup (AActor *&toucher)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-11-07 10:20:09 +00:00
|
|
|
// The Doom and Hexen players are not excluded from pickup in case
|
|
|
|
// somebody wants to use these weapons with either of those games.
|
|
|
|
if (toucher->IsKindOf (PClass::FindClass(NAME_ClericPlayer)) ||
|
|
|
|
toucher->IsKindOf (PClass::FindClass(NAME_MagePlayer)))
|
|
|
|
{ // Wrong class, but try to pick up for mana
|
|
|
|
if (ShouldStay())
|
|
|
|
{ // Can't pick up weapons for other classes in coop netplay
|
|
|
|
return false;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-11-07 10:20:09 +00:00
|
|
|
bool gaveSome = (NULL != AddAmmo (toucher, AmmoType1, AmmoGive1));
|
|
|
|
gaveSome |= (NULL != AddAmmo (toucher, AmmoType2, AmmoGive2));
|
|
|
|
if (gaveSome)
|
|
|
|
{
|
|
|
|
GoAwayAndDie ();
|
|
|
|
}
|
|
|
|
return gaveSome;
|
|
|
|
}
|
|
|
|
return Super::TryPickup (toucher);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cleric Weapon Base Class -------------------------------------------------
|
|
|
|
|
2008-09-13 22:08:41 +00:00
|
|
|
bool AClericWeapon::TryPickup (AActor *&toucher)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-11-07 10:20:09 +00:00
|
|
|
// The Doom and Hexen players are not excluded from pickup in case
|
|
|
|
// somebody wants to use these weapons with either of those games.
|
|
|
|
if (toucher->IsKindOf (PClass::FindClass(NAME_FighterPlayer)) ||
|
|
|
|
toucher->IsKindOf (PClass::FindClass(NAME_MagePlayer)))
|
|
|
|
{ // Wrong class, but try to pick up for mana
|
|
|
|
if (ShouldStay())
|
|
|
|
{ // Can't pick up weapons for other classes in coop netplay
|
|
|
|
return false;
|
|
|
|
}
|
2006-07-13 10:17:56 +00:00
|
|
|
|
2006-11-07 10:20:09 +00:00
|
|
|
bool gaveSome = (NULL != AddAmmo (toucher, AmmoType1, AmmoGive1));
|
|
|
|
gaveSome |= (NULL != AddAmmo (toucher, AmmoType2, AmmoGive2));
|
|
|
|
if (gaveSome)
|
|
|
|
{
|
|
|
|
GoAwayAndDie ();
|
|
|
|
}
|
|
|
|
return gaveSome;
|
2006-07-13 10:17:56 +00:00
|
|
|
}
|
2006-11-07 10:20:09 +00:00
|
|
|
return Super::TryPickup (toucher);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mage Weapon Base Class ---------------------------------------------------
|
|
|
|
|
2008-09-13 22:08:41 +00:00
|
|
|
bool AMageWeapon::TryPickup (AActor *&toucher)
|
2006-11-07 10:20:09 +00:00
|
|
|
{
|
|
|
|
// The Doom and Hexen players are not excluded from pickup in case
|
|
|
|
// somebody wants to use these weapons with either of those games.
|
|
|
|
if (toucher->IsKindOf (PClass::FindClass(NAME_FighterPlayer)) ||
|
|
|
|
toucher->IsKindOf (PClass::FindClass(NAME_ClericPlayer)))
|
|
|
|
{ // Wrong class, but try to pick up for mana
|
|
|
|
if (ShouldStay())
|
|
|
|
{ // Can't pick up weapons for other classes in coop netplay
|
|
|
|
return false;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-11-07 10:20:09 +00:00
|
|
|
bool gaveSome = (NULL != AddAmmo (toucher, AmmoType1, AmmoGive1));
|
|
|
|
gaveSome |= (NULL != AddAmmo (toucher, AmmoType2, AmmoGive2));
|
|
|
|
if (gaveSome)
|
|
|
|
{
|
|
|
|
GoAwayAndDie ();
|
|
|
|
}
|
|
|
|
return gaveSome;
|
|
|
|
}
|
|
|
|
return Super::TryPickup (toucher);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-11-07 10:20:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
static FRandom pr_fpatk ("FPunchAttack");
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// AdjustPlayerAngle
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#define MAX_ANGLE_ADJUST (5*ANGLE_1)
|
|
|
|
|
2008-04-10 14:38:43 +00:00
|
|
|
void AdjustPlayerAngle (AActor *pmo, AActor *linetarget)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
angle_t angle;
|
|
|
|
int difference;
|
|
|
|
|
|
|
|
angle = R_PointToAngle2 (pmo->x, pmo->y, linetarget->x, linetarget->y);
|
|
|
|
difference = (int)angle - (int)pmo->angle;
|
|
|
|
if (abs(difference) > MAX_ANGLE_ADJUST)
|
|
|
|
{
|
|
|
|
if (difference > 0)
|
|
|
|
{
|
|
|
|
pmo->angle += MAX_ANGLE_ADJUST;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pmo->angle -= MAX_ANGLE_ADJUST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pmo->angle = angle;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FPunchAttack
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
angle_t angle;
|
|
|
|
int damage;
|
|
|
|
int slope;
|
|
|
|
fixed_t power;
|
|
|
|
int i;
|
|
|
|
player_t *player;
|
2006-05-10 02:40:43 +00:00
|
|
|
const PClass *pufftype;
|
2008-04-10 14:38:43 +00:00
|
|
|
AActor *linetarget;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
APlayerPawn *pmo = player->mo;
|
|
|
|
|
|
|
|
damage = 40+(pr_fpatk()&15);
|
|
|
|
power = 2*FRACUNIT;
|
2008-08-08 07:40:41 +00:00
|
|
|
pufftype = PClass::FindClass ("PunchPuff");
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
angle = pmo->angle + i*(ANG45/16);
|
2008-04-10 14:38:43 +00:00
|
|
|
slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE, &linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (linetarget)
|
|
|
|
{
|
|
|
|
pmo->special1++;
|
|
|
|
if (pmo->special1 == 3)
|
|
|
|
{
|
|
|
|
damage <<= 1;
|
|
|
|
power = 6*FRACUNIT;
|
2008-08-08 07:40:41 +00:00
|
|
|
pufftype = PClass::FindClass ("HammerPuff");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-04-04 14:31:20 +00:00
|
|
|
P_LineAttack (pmo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, pufftype, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
|
|
|
|
{
|
|
|
|
P_ThrustMobj (linetarget, angle, power);
|
|
|
|
}
|
2008-04-10 14:38:43 +00:00
|
|
|
AdjustPlayerAngle (pmo, linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
goto punchdone;
|
|
|
|
}
|
|
|
|
angle = pmo->angle-i * (ANG45/16);
|
2008-04-10 14:38:43 +00:00
|
|
|
slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE, &linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (linetarget)
|
|
|
|
{
|
|
|
|
pmo->special1++;
|
|
|
|
if (pmo->special1 == 3)
|
|
|
|
{
|
|
|
|
damage <<= 1;
|
|
|
|
power = 6*FRACUNIT;
|
2008-08-08 07:40:41 +00:00
|
|
|
pufftype = PClass::FindClass ("HammerPuff");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-04-04 14:31:20 +00:00
|
|
|
P_LineAttack (pmo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, pufftype, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
|
|
|
|
{
|
|
|
|
P_ThrustMobj (linetarget, angle, power);
|
|
|
|
}
|
2008-04-10 14:38:43 +00:00
|
|
|
AdjustPlayerAngle (pmo, linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
goto punchdone;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// didn't find any creatures, so try to strike any walls
|
|
|
|
pmo->special1 = 0;
|
|
|
|
|
|
|
|
angle = pmo->angle;
|
2008-04-10 14:38:43 +00:00
|
|
|
slope = P_AimLineAttack (pmo, angle, MELEERANGE, &linetarget);
|
2008-04-04 14:31:20 +00:00
|
|
|
P_LineAttack (pmo, angle, MELEERANGE, slope, damage, NAME_Melee, pufftype, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
punchdone:
|
|
|
|
if (pmo->special1 == 3)
|
|
|
|
{
|
|
|
|
pmo->special1 = 0;
|
2008-08-08 07:40:41 +00:00
|
|
|
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("Fire2"));
|
2006-02-24 04:48:15 +00:00
|
|
|
S_Sound (pmo, CHAN_VOICE, "*fistgrunt", 1, ATTN_NORM);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|