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 "p_pspr.h"
|
|
|
|
#include "gstrings.h"
|
|
|
|
#include "a_hexenglobal.h"
|
2008-08-08 10:24:08 +00:00
|
|
|
#include "a_weaponpiece.h"
|
|
|
|
#include "thingdef/thingdef.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_quietusdrop ("QuietusDrop");
|
|
|
|
static FRandom pr_fswordflame ("FSwordFlame");
|
|
|
|
|
2006-06-17 20:29:41 +00:00
|
|
|
//==========================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-08 10:24:08 +00:00
|
|
|
class AFighterWeaponPiece : public AWeaponPiece
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-08 10:24:08 +00:00
|
|
|
DECLARE_CLASS (AFighterWeaponPiece, AWeaponPiece)
|
2006-02-24 04:48:15 +00:00
|
|
|
protected:
|
2008-09-13 22:08:41 +00:00
|
|
|
bool TryPickup (AActor *&toucher);
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-08-08 07:40:41 +00:00
|
|
|
IMPLEMENT_CLASS (AFighterWeaponPiece)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-09-13 22:08:41 +00:00
|
|
|
bool AFighterWeaponPiece::TryPickup (AActor *&toucher)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-08 10:24:08 +00:00
|
|
|
if (!toucher->IsKindOf (PClass::FindClass(NAME_ClericPlayer)) &&
|
|
|
|
!toucher->IsKindOf (PClass::FindClass(NAME_MagePlayer)))
|
|
|
|
{
|
|
|
|
return Super::TryPickup(toucher);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Wrong class, but try to pick up for ammo
|
|
|
|
if (ShouldStay())
|
|
|
|
{
|
|
|
|
// Can't pick up weapons for other classes in coop netplay
|
|
|
|
return false;
|
|
|
|
}
|
2006-06-17 20:29:41 +00:00
|
|
|
|
2008-08-08 10:24:08 +00:00
|
|
|
AWeapon * Defaults=(AWeapon*)GetDefaultByType(WeaponClass);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-08 10:24:08 +00:00
|
|
|
bool gaveSome = !!(toucher->GiveAmmo (Defaults->AmmoType1, Defaults->AmmoGive1) +
|
|
|
|
toucher->GiveAmmo (Defaults->AmmoType2, Defaults->AmmoGive2));
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-08 10:24:08 +00:00
|
|
|
if (gaveSome)
|
|
|
|
{
|
|
|
|
GoAwayAndDie ();
|
|
|
|
}
|
|
|
|
return gaveSome;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-08 10:24:08 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_DropQuietusPieces
|
|
|
|
//
|
|
|
|
//============================================================================
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-12 14:30:07 +00:00
|
|
|
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropWeaponPieces)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
PARAM_CLASS(p1, AActor);
|
|
|
|
PARAM_CLASS(p2, AActor);
|
|
|
|
PARAM_CLASS(p3, AActor);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-08 10:24:08 +00:00
|
|
|
for (int i = 0, j = 0, fineang = 0; i < 3; ++i)
|
|
|
|
{
|
2008-08-13 22:54:24 +00:00
|
|
|
const PClass *cls = j==0? p1 : j==1? p2 : p3;
|
2008-08-08 10:24:08 +00:00
|
|
|
if (cls)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
AActor *piece = Spawn (cls, self->x, self->y, self->z, ALLOW_REPLACE);
|
2008-08-08 10:24:08 +00:00
|
|
|
if (piece != NULL)
|
|
|
|
{
|
2009-06-30 20:57:51 +00:00
|
|
|
piece->velx = self->velx + finecosine[fineang];
|
|
|
|
piece->vely = self->vely + finesine[fineang];
|
|
|
|
piece->velz = self->velz;
|
2008-08-08 10:24:08 +00:00
|
|
|
piece->flags |= MF_DROPPED;
|
|
|
|
fineang += FINEANGLES/3;
|
|
|
|
j = (j == 0) ? (pr_quietusdrop() & 1) + 1 : 3-j;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fighter Sword Missile ----------------------------------------------------
|
|
|
|
|
|
|
|
class AFSwordMissile : public AActor
|
|
|
|
{
|
2008-08-08 07:40:41 +00:00
|
|
|
DECLARE_CLASS (AFSwordMissile, AActor)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
2007-10-29 20:27:40 +00:00
|
|
|
int DoSpecialDamage(AActor *victim, AActor *source, int damage);
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
2008-08-08 07:40:41 +00:00
|
|
|
IMPLEMENT_CLASS (AFSwordMissile)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2007-10-29 20:27:40 +00:00
|
|
|
int AFSwordMissile::DoSpecialDamage(AActor *victim, AActor *source, int damage)
|
|
|
|
{
|
|
|
|
if (victim->player)
|
|
|
|
{
|
|
|
|
damage -= damage >> 2;
|
|
|
|
}
|
|
|
|
return damage;
|
|
|
|
}
|
|
|
|
|
2006-06-17 20:29:41 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FSwordAttack
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FSwordAttack)
|
2006-06-17 20:29:41 +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
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapon->DepleteAmmo (weapon->bAltFire))
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
P_SpawnPlayerMissile (self, 0, 0, -10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle+ANGLE_45/4);
|
|
|
|
P_SpawnPlayerMissile (self, 0, 0, -5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle+ANGLE_45/8);
|
|
|
|
P_SpawnPlayerMissile (self, 0, 0, 0, RUNTIME_CLASS(AFSwordMissile), self->angle);
|
|
|
|
P_SpawnPlayerMissile (self, 0, 0, 5*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle-ANGLE_45/8);
|
|
|
|
P_SpawnPlayerMissile (self, 0, 0, 10*FRACUNIT, RUNTIME_CLASS(AFSwordMissile), self->angle-ANGLE_45/4);
|
|
|
|
S_Sound (self, CHAN_WEAPON, "FighterSwordFire", 1, ATTN_NORM);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-06-17 20:29:41 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FSwordFlames
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FSwordFlames)
|
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
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 1+(pr_fswordflame()&3); i; i--)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
fixed_t x = self->x+((pr_fswordflame()-128)<<12);
|
|
|
|
fixed_t y = self->y+((pr_fswordflame()-128)<<12);
|
|
|
|
fixed_t z = self->z+((pr_fswordflame()-128)<<11);
|
2008-08-08 07:40:41 +00:00
|
|
|
Spawn ("FSwordFlame", x, y, z, ALLOW_REPLACE);
|
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
|
|
|
}
|
|
|
|
|
2008-08-03 16:13:23 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_FighterAttack
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_FighterAttack)
|
2008-08-03 16:13:23 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
|
|
|
if (!self->target) return 0;
|
2008-08-03 16:13:23 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
angle_t angle = self->angle;
|
2008-08-03 16:13:23 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_SpawnMissileAngle (self, RUNTIME_CLASS(AFSwordMissile), angle+ANG45/4, 0);
|
|
|
|
P_SpawnMissileAngle (self, RUNTIME_CLASS(AFSwordMissile), angle+ANG45/8, 0);
|
|
|
|
P_SpawnMissileAngle (self, RUNTIME_CLASS(AFSwordMissile), angle, 0);
|
|
|
|
P_SpawnMissileAngle (self, RUNTIME_CLASS(AFSwordMissile), angle-ANG45/8, 0);
|
|
|
|
P_SpawnMissileAngle (self, RUNTIME_CLASS(AFSwordMissile), angle-ANG45/4, 0);
|
|
|
|
S_Sound (self, CHAN_WEAPON, "FighterSwordFire", 1, ATTN_NORM);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2008-08-03 16:13:23 +00:00
|
|
|
}
|
|
|
|
|