2016-03-01 15:47:10 +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"
|
|
|
|
#include "thingdef/thingdef.h"
|
|
|
|
*/
|
|
|
|
|
2016-03-17 10:38:56 +00:00
|
|
|
#define AXERANGE (2.25 * MELEERANGE)
|
2016-03-01 15:47:10 +00:00
|
|
|
|
|
|
|
static FRandom pr_axeatk ("FAxeAtk");
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
DECLARE_CLASS (AFWeapAxe, AFighterWeapon)
|
|
|
|
public:
|
|
|
|
FState *GetUpState ();
|
|
|
|
FState *GetDownState ();
|
|
|
|
FState *GetReadyState ();
|
|
|
|
FState *GetAtkState (bool hold);
|
|
|
|
};
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS (AFWeapAxe)
|
|
|
|
|
|
|
|
FState *AFWeapAxe::GetUpState ()
|
|
|
|
{
|
|
|
|
return Ammo1->Amount ? FindState ("SelectGlow") : Super::GetUpState();
|
|
|
|
}
|
|
|
|
|
|
|
|
FState *AFWeapAxe::GetDownState ()
|
|
|
|
{
|
|
|
|
return Ammo1->Amount ? FindState ("DeselectGlow") : Super::GetDownState();
|
|
|
|
}
|
|
|
|
|
|
|
|
FState *AFWeapAxe::GetReadyState ()
|
|
|
|
{
|
|
|
|
return Ammo1->Amount ? FindState ("ReadyGlow") : Super::GetReadyState();
|
|
|
|
}
|
|
|
|
|
|
|
|
FState *AFWeapAxe::GetAtkState (bool hold)
|
|
|
|
{
|
|
|
|
return Ammo1->Amount ? FindState ("FireGlow") : Super::GetAtkState(hold);
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeCheckReady
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReady)
|
|
|
|
{
|
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
|
|
|
player_t *player;
|
|
|
|
|
2016-05-09 18:03:47 +00:00
|
|
|
if (nullptr == (player = self->player))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount)
|
|
|
|
{
|
2016-05-27 17:01:03 +00:00
|
|
|
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("ReadyGlow"));
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DoReadyWeapon(self);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeCheckReadyG
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReadyG)
|
|
|
|
{
|
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
|
|
|
player_t *player;
|
|
|
|
|
2016-05-09 18:03:47 +00:00
|
|
|
if (nullptr == (player = self->player))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount <= 0)
|
|
|
|
{
|
2016-05-27 17:01:03 +00:00
|
|
|
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Ready"));
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DoReadyWeapon(self);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeCheckUp
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUp)
|
|
|
|
{
|
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
|
|
|
player_t *player;
|
|
|
|
|
2016-05-09 18:03:47 +00:00
|
|
|
if (nullptr == (player = self->player))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount)
|
|
|
|
{
|
2016-05-27 17:01:03 +00:00
|
|
|
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("SelectGlow"));
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CALL_ACTION(A_Raise, self);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeCheckUpG
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUpG)
|
|
|
|
{
|
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
|
|
|
player_t *player;
|
|
|
|
|
2016-05-09 18:03:47 +00:00
|
|
|
if (nullptr == (player = self->player))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount <= 0)
|
|
|
|
{
|
2016-05-27 17:01:03 +00:00
|
|
|
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Select"));
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CALL_ACTION(A_Raise, self);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeCheckAtk
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckAtk)
|
|
|
|
{
|
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
|
|
|
player_t *player;
|
|
|
|
|
2016-05-09 18:03:47 +00:00
|
|
|
if (nullptr == (player = self->player))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount)
|
|
|
|
{
|
2016-05-27 17:01:03 +00:00
|
|
|
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("FireGlow"));
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FAxeAttack
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
|
|
|
|
{
|
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2016-03-17 10:38:56 +00:00
|
|
|
DAngle angle;
|
2016-03-20 00:25:47 +00:00
|
|
|
int power;
|
2016-03-01 15:47:10 +00:00
|
|
|
int damage;
|
2016-03-17 10:38:56 +00:00
|
|
|
DAngle slope;
|
2016-03-01 15:47:10 +00:00
|
|
|
int i;
|
|
|
|
int useMana;
|
|
|
|
player_t *player;
|
|
|
|
AWeapon *weapon;
|
|
|
|
PClassActor *pufftype;
|
|
|
|
FTranslatedLineTarget t;
|
|
|
|
|
2016-05-09 18:03:47 +00:00
|
|
|
if (nullptr == (player = self->player))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
AActor *pmo=player->mo;
|
|
|
|
|
|
|
|
damage = 40+(pr_axeatk()&15);
|
|
|
|
damage += pr_axeatk()&7;
|
|
|
|
power = 0;
|
|
|
|
weapon = player->ReadyWeapon;
|
|
|
|
if (player->ReadyWeapon->Ammo1->Amount > 0)
|
|
|
|
{
|
|
|
|
damage <<= 1;
|
2016-03-20 00:25:47 +00:00
|
|
|
power = 6;
|
2016-03-01 15:47:10 +00:00
|
|
|
pufftype = PClass::FindActor ("AxePuffGlow");
|
|
|
|
useMana = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pufftype = PClass::FindActor ("AxePuff");
|
|
|
|
useMana = 0;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
for (int j = 1; j >= -1; j -= 2)
|
|
|
|
{
|
2016-03-17 10:38:56 +00:00
|
|
|
angle = pmo->Angles.Yaw + j*i*(45. / 16);
|
2016-03-01 15:47:10 +00:00
|
|
|
slope = P_AimLineAttack(pmo, angle, AXERANGE, &t);
|
|
|
|
if (t.linetarget)
|
|
|
|
{
|
|
|
|
P_LineAttack(pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &t);
|
2016-05-09 18:03:47 +00:00
|
|
|
if (t.linetarget != nullptr)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
if (t.linetarget->flags3&MF3_ISMONSTER || t.linetarget->player)
|
|
|
|
{
|
2016-03-20 00:25:47 +00:00
|
|
|
t.linetarget->Thrust(t.angleFromSource, power);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
AdjustPlayerAngle(pmo, &t);
|
|
|
|
useMana++;
|
|
|
|
goto axedone;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// didn't find any creatures, so try to strike any walls
|
|
|
|
pmo->weaponspecial = 0;
|
|
|
|
|
2016-03-17 10:38:56 +00:00
|
|
|
angle = pmo->Angles.Yaw;
|
2016-03-01 15:47:10 +00:00
|
|
|
slope = P_AimLineAttack (pmo, angle, MELEERANGE);
|
|
|
|
P_LineAttack (pmo, angle, MELEERANGE, slope, damage, NAME_Melee, pufftype, true);
|
|
|
|
|
|
|
|
axedone:
|
|
|
|
if (useMana == 2)
|
|
|
|
{
|
|
|
|
AWeapon *weapon = player->ReadyWeapon;
|
2016-05-09 18:03:47 +00:00
|
|
|
if (weapon != nullptr)
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
|
|
|
weapon->DepleteAmmo (weapon->bAltFire, false);
|
|
|
|
|
2016-05-09 18:03:47 +00:00
|
|
|
if ((weapon->Ammo1 == nullptr || weapon->Ammo1->Amount == 0) &&
|
2016-03-01 15:47:10 +00:00
|
|
|
(!(weapon->WeaponFlags & WIF_PRIMARY_USES_BOTH) ||
|
2016-05-09 18:03:47 +00:00
|
|
|
weapon->Ammo2 == nullptr || weapon->Ammo2->Amount == 0))
|
2016-03-01 15:47:10 +00:00
|
|
|
{
|
2016-05-27 17:01:03 +00:00
|
|
|
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Fire") + 5);
|
2016-03-01 15:47:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|