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
|
|
|
|
|
|
|
const fixed_t HAMMER_RANGE = MELEERANGE+MELEERANGE/2;
|
|
|
|
|
2008-09-15 14:11:05 +00:00
|
|
|
static FRandom pr_hammeratk ("FHammerAtk");
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-04-10 14:38:43 +00:00
|
|
|
extern void AdjustPlayerAngle (AActor *pmo, AActor *linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FHammerAttack
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FHammerAttack)
|
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;
|
|
|
|
int damage;
|
|
|
|
fixed_t power;
|
|
|
|
int slope;
|
|
|
|
int i;
|
|
|
|
player_t *player;
|
2008-04-10 14:38:43 +00:00
|
|
|
AActor *linetarget;
|
2010-03-24 02:49:37 +00:00
|
|
|
PClassActor *hammertime;
|
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 = 60+(pr_hammeratk()&63);
|
2006-02-24 04:48:15 +00:00
|
|
|
power = 10*FRACUNIT;
|
2010-03-24 02:49:37 +00:00
|
|
|
hammertime = PClass::FindActor("HammerPuff");
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
angle = pmo->angle + i*(ANG45/32);
|
2010-03-28 10:51:35 +00:00
|
|
|
slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (linetarget)
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, hammertime, true);
|
2008-04-10 14:38:43 +00:00
|
|
|
AdjustPlayerAngle(pmo, linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
|
|
|
|
{
|
|
|
|
P_ThrustMobj (linetarget, angle, power);
|
|
|
|
}
|
|
|
|
pmo->special1 = false; // Don't throw a hammer
|
|
|
|
goto hammerdone;
|
|
|
|
}
|
|
|
|
angle = pmo->angle-i*(ANG45/32);
|
2010-03-28 10:51:35 +00:00
|
|
|
slope = P_AimLineAttack(pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D);
|
2006-02-24 04:48:15 +00:00
|
|
|
if(linetarget)
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
P_LineAttack(pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, hammertime, true);
|
2008-04-10 14:38:43 +00:00
|
|
|
AdjustPlayerAngle(pmo, linetarget);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (linetarget->flags3&MF3_ISMONSTER || linetarget->player)
|
|
|
|
{
|
|
|
|
P_ThrustMobj(linetarget, angle, power);
|
|
|
|
}
|
|
|
|
pmo->special1 = false; // Don't throw a hammer
|
|
|
|
goto hammerdone;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// didn't find any targets in meleerange, so set to throw out a hammer
|
|
|
|
angle = pmo->angle;
|
2010-03-28 10:51:35 +00:00
|
|
|
slope = P_AimLineAttack (pmo, angle, HAMMER_RANGE, &linetarget, 0, ALF_CHECK3D);
|
2010-03-24 02:49:37 +00:00
|
|
|
if (P_LineAttack (pmo, angle, HAMMER_RANGE, slope, damage, NAME_Melee, hammertime, true) != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
pmo->special1 = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pmo->special1 = true;
|
|
|
|
}
|
|
|
|
hammerdone:
|
|
|
|
// Don't spawn a hammer if the player doesn't have enough mana
|
|
|
|
if (player->ReadyWeapon == NULL ||
|
|
|
|
!player->ReadyWeapon->CheckAmmo (player->ReadyWeapon->bAltFire ?
|
|
|
|
AWeapon::AltFire : AWeapon::PrimaryFire, false, true))
|
|
|
|
{
|
|
|
|
pmo->special1 = false;
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FHammerThrow
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FHammerThrow)
|
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
|
|
|
AActor *mo;
|
|
|
|
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->mo->special1)
|
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
AWeapon *weapon = player->ReadyWeapon;
|
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire, false))
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-03-25 20:38:00 +00:00
|
|
|
mo = P_SpawnPlayerMissile (player->mo, PClass::FindActor("HammerMissile"));
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
mo->special1 = 0;
|
2010-02-12 06:04:57 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|