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);
|
|
|
|
|
|
|
|
// 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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount)
|
|
|
|
{
|
2012-05-04 18:37:41 +00:00
|
|
|
P_SetPsprite (player, ps_weapon, player->ReadyWeapon->FindState ("SelectGlow"));
|
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
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
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;
|
2010-03-24 02:49:37 +00:00
|
|
|
PClassActor *pufftype;
|
2016-03-01 15:38:45 +00:00
|
|
|
FTranslatedLineTarget t;
|
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
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
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;
|
2010-03-24 02:49:37 +00:00
|
|
|
pufftype = PClass::FindActor ("AxePuffGlow");
|
2006-02-24 04:48:15 +00:00
|
|
|
useMana = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
pufftype = PClass::FindActor ("AxePuff");
|
2006-02-24 04:48:15 +00:00
|
|
|
useMana = 0;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
2016-02-28 15:06:48 +00:00
|
|
|
for (int j = 1; j >= -1; j -= 2)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2016-02-28 15:06:48 +00:00
|
|
|
angle = pmo->angle + j*i*(ANG45 / 16);
|
2016-03-01 15:38:45 +00:00
|
|
|
slope = P_AimLineAttack(pmo, angle, AXERANGE, &t);
|
|
|
|
if (t.linetarget)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2016-03-01 15:38:45 +00:00
|
|
|
P_LineAttack(pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &t);
|
|
|
|
if (t.linetarget != NULL)
|
2010-07-08 21:16:01 +00:00
|
|
|
{
|
2016-03-01 15:38:45 +00:00
|
|
|
if (t.linetarget->flags3&MF3_ISMONSTER || t.linetarget->player)
|
2016-02-28 15:06:48 +00:00
|
|
|
{
|
2016-03-01 15:38:45 +00:00
|
|
|
P_ThrustMobj(t.linetarget, t.hitangle, power);
|
2016-02-28 15:06:48 +00:00
|
|
|
}
|
2016-03-01 15:38:45 +00:00
|
|
|
AdjustPlayerAngle(pmo, &t);
|
2016-02-28 15:06:48 +00:00
|
|
|
useMana++;
|
|
|
|
goto axedone;
|
2010-07-08 21:16:01 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// didn't find any creatures, so try to strike any walls
|
2014-09-13 10:38:16 +00:00
|
|
|
pmo->weaponspecial = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
angle = pmo->angle;
|
2016-03-01 15:38:45 +00:00
|
|
|
slope = P_AimLineAttack (pmo, angle, MELEERANGE);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|