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 "p_pspr.h"
|
|
|
|
#include "gstrings.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
|
|
|
|
|
|
|
#define AXERANGE ((fixed_t)(2.25*MELEERANGE))
|
|
|
|
|
2008-09-15 14:11:05 +00:00
|
|
|
static FRandom pr_axeatk ("FAxeAtk");
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void A_FAxeCheckReady (AActor *actor);
|
|
|
|
void A_FAxeCheckUp (AActor *actor);
|
|
|
|
void A_FAxeCheckAtk (AActor *actor);
|
|
|
|
void A_FAxeCheckReadyG (AActor *actor);
|
|
|
|
void A_FAxeCheckUpG (AActor *actor);
|
|
|
|
void A_FAxeAttack (AActor *actor);
|
|
|
|
|
2008-04-10 14:38:43 +00:00
|
|
|
extern void AdjustPlayerAngle (AActor *pmo, AActor *linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
EXTERN_CVAR (Int, cl_bloodtype)
|
|
|
|
|
|
|
|
// The Fighter's Axe --------------------------------------------------------
|
|
|
|
|
|
|
|
class AFWeapAxe : public AFighterWeapon
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
DECLARE_CLASS (AFWeapAxe, AFighterWeapon)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
FState *GetUpState ();
|
|
|
|
FState *GetDownState ();
|
|
|
|
FState *GetReadyState ();
|
2006-10-31 14:53:21 +00:00
|
|
|
FState *GetAtkState (bool hold);
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-08-08 07:40:41 +00:00
|
|
|
IMPLEMENT_CLASS (AFWeapAxe)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
FState *AFWeapAxe::GetUpState ()
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
return Ammo1->Amount ? FindState ("SelectGlow") : Super::GetUpState();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FState *AFWeapAxe::GetDownState ()
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
return Ammo1->Amount ? FindState ("DeselectGlow") : Super::GetDownState();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FState *AFWeapAxe::GetReadyState ()
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
return Ammo1->Amount ? FindState ("ReadyGlow") : Super::GetReadyState();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2006-10-31 14:53:21 +00:00
|
|
|
FState *AFWeapAxe::GetAtkState (bool hold)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
return Ammo1->Amount ? FindState ("FireGlow") : Super::GetAtkState(hold);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeCheckReady
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReady)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount)
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("ReadyGlow"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-16 22:40:04 +00:00
|
|
|
DoReadyWeapon(self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeCheckReadyG
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReadyG)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount <= 0)
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("Ready"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-16 22:40:04 +00:00
|
|
|
DoReadyWeapon(self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeCheckUp
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUp)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount)
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("ReadyGlow"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-10 22:48:37 +00:00
|
|
|
CALL_ACTION(A_Raise, self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeCheckUpG
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUpG)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount <= 0)
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("Select"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-10 22:48:37 +00:00
|
|
|
CALL_ACTION(A_Raise, self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeCheckAtk
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckAtk)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *player;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (NULL == (player = self->player))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount)
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("FireGlow"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeAttack
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
angle_t angle;
|
|
|
|
fixed_t power;
|
|
|
|
int damage;
|
|
|
|
int slope;
|
|
|
|
int i;
|
|
|
|
int useMana;
|
|
|
|
player_t *player;
|
|
|
|
AWeapon *weapon;
|
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;
|
|
|
|
}
|
|
|
|
AActor *pmo=player->mo;
|
|
|
|
|
2008-09-15 14:11:05 +00:00
|
|
|
damage = 40+(pr_axeatk()&15);
|
|
|
|
damage += pr_axeatk()&7;
|
2006-02-24 04:48:15 +00:00
|
|
|
power = 0;
|
|
|
|
weapon = player->ReadyWeapon;
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount > 0)
|
|
|
|
{
|
|
|
|
damage <<= 1;
|
|
|
|
power = 6*FRACUNIT;
|
2008-08-08 07:40:41 +00:00
|
|
|
pufftype = PClass::FindClass ("AxePuffGlow");
|
2006-02-24 04:48:15 +00:00
|
|
|
useMana = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
pufftype = PClass::FindClass ("AxePuff");
|
2006-02-24 04:48:15 +00:00
|
|
|
useMana = 0;
|
|
|
|
}
|
|
|
|
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, AXERANGE, &linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (linetarget)
|
|
|
|
{
|
2010-06-13 11:14:01 +00:00
|
|
|
P_LineAttack (pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
|
2010-07-08 21:16:01 +00:00
|
|
|
if (linetarget != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-07-08 21:16:01 +00:00
|
|
|
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
|
|
|
|
{
|
|
|
|
P_ThrustMobj (linetarget, angle, power);
|
|
|
|
}
|
|
|
|
AdjustPlayerAngle (pmo, linetarget);
|
|
|
|
useMana++;
|
|
|
|
goto axedone;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
angle = pmo->angle-i*(ANG45/16);
|
2008-04-10 14:38:43 +00:00
|
|
|
slope = P_AimLineAttack (pmo, angle, AXERANGE, &linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (linetarget)
|
|
|
|
{
|
2010-06-13 11:14:01 +00:00
|
|
|
P_LineAttack (pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &linetarget);
|
2010-07-08 21:16:01 +00:00
|
|
|
if (linetarget != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-07-08 21:16:01 +00:00
|
|
|
if (linetarget->flags3&MF3_ISMONSTER)
|
|
|
|
{
|
|
|
|
P_ThrustMobj (linetarget, angle, power);
|
|
|
|
}
|
|
|
|
AdjustPlayerAngle (pmo, linetarget);
|
|
|
|
useMana++;
|
|
|
|
goto axedone;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 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
|
|
|
|
|
|
|
axedone:
|
|
|
|
if (useMana == 2)
|
|
|
|
{
|
|
|
|
AWeapon *weapon = player->ReadyWeapon;
|
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
weapon->DepleteAmmo (weapon->bAltFire, false);
|
|
|
|
|
|
|
|
if ((weapon->Ammo1 == NULL || weapon->Ammo1->Amount == 0) &&
|
|
|
|
(!(weapon->WeaponFlags & WIF_PRIMARY_USES_BOTH) ||
|
|
|
|
weapon->Ammo2 == NULL || weapon->Ammo2->Amount == 0))
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("Fire") + 5);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|