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
|
|
|
|
|
|
|
static FRandom pr_staffcheck ("CStaffCheck");
|
|
|
|
static FRandom pr_blink ("CStaffBlink");
|
|
|
|
|
|
|
|
// Serpent Staff Missile ----------------------------------------------------
|
|
|
|
|
|
|
|
class ACStaffMissile : public AActor
|
|
|
|
{
|
2008-08-05 16:04:37 +00:00
|
|
|
DECLARE_CLASS (ACStaffMissile, AActor)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
int DoSpecialDamage (AActor *target, int damage);
|
|
|
|
};
|
|
|
|
|
2008-08-05 16:04:37 +00:00
|
|
|
IMPLEMENT_CLASS (ACStaffMissile)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
int ACStaffMissile::DoSpecialDamage (AActor *target, int damage)
|
|
|
|
{
|
|
|
|
// Cleric Serpent Staff does poison damage
|
|
|
|
if (target->player)
|
|
|
|
{
|
|
|
|
P_PoisonPlayer (target->player, this, this->target, 20);
|
|
|
|
damage >>= 1;
|
|
|
|
}
|
|
|
|
return damage;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CStaffCheck
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheck)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-09-25 03:07:20 +00:00
|
|
|
APlayerPawn *pmo;
|
2006-02-24 04:48:15 +00:00
|
|
|
int damage;
|
2009-09-25 03:07:20 +00:00
|
|
|
int newLife, max;
|
2006-02-24 04:48:15 +00:00
|
|
|
angle_t angle;
|
|
|
|
int slope;
|
|
|
|
int i;
|
|
|
|
player_t *player;
|
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;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
AWeapon *weapon = self->player->ReadyWeapon;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
pmo = player->mo;
|
|
|
|
damage = 20+(pr_staffcheck()&15);
|
2009-09-25 03:07:20 +00:00
|
|
|
max = pmo->GetMaxHealth();
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
|
|
|
{
|
|
|
|
angle = pmo->angle+i*(ANG45/16);
|
2008-12-30 23:27:27 +00:00
|
|
|
slope = P_AimLineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, false, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (linetarget)
|
|
|
|
{
|
2008-08-05 16:04:37 +00:00
|
|
|
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"));
|
2006-02-24 04:48:15 +00:00
|
|
|
pmo->angle = R_PointToAngle2 (pmo->x, pmo->y,
|
|
|
|
linetarget->x, linetarget->y);
|
2008-12-16 01:23:44 +00:00
|
|
|
if (((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0))|| linetarget->flags3&MF3_ISMONSTER)
|
2006-02-24 04:48:15 +00:00
|
|
|
&& (!(linetarget->flags2&(MF2_DORMANT+MF2_INVULNERABLE))))
|
|
|
|
{
|
|
|
|
newLife = player->health+(damage>>3);
|
2009-09-25 03:07:20 +00:00
|
|
|
newLife = newLife > max ? max : newLife;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (newLife > player->health)
|
|
|
|
{
|
|
|
|
pmo->health = player->health = newLife;
|
|
|
|
}
|
2008-08-05 16:04:37 +00:00
|
|
|
P_SetPsprite (player, ps_weapon, weapon->FindState ("Drain"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
if (weapon != NULL)
|
|
|
|
{
|
|
|
|
weapon->DepleteAmmo (weapon->bAltFire, false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
angle = pmo->angle-i*(ANG45/16);
|
2008-12-30 23:27:27 +00:00
|
|
|
slope = P_AimLineAttack (player->mo, angle, fixed_t(1.5*MELEERANGE), &linetarget, 0, false, true);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (linetarget)
|
|
|
|
{
|
2008-08-05 16:04:37 +00:00
|
|
|
P_LineAttack (pmo, angle, fixed_t(1.5*MELEERANGE), slope, damage, NAME_Melee, PClass::FindClass ("CStaffPuff"));
|
2006-02-24 04:48:15 +00:00
|
|
|
pmo->angle = R_PointToAngle2 (pmo->x, pmo->y,
|
|
|
|
linetarget->x, linetarget->y);
|
2008-12-16 01:23:44 +00:00
|
|
|
if ((linetarget->player && (!linetarget->IsTeammate (pmo) || level.teamdamage != 0)) || linetarget->flags3&MF3_ISMONSTER)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
newLife = player->health+(damage>>4);
|
2009-09-25 03:07:20 +00:00
|
|
|
newLife = newLife > max ? max : newLife;
|
2006-02-24 04:48:15 +00:00
|
|
|
pmo->health = player->health = newLife;
|
2008-08-05 16:04:37 +00:00
|
|
|
P_SetPsprite (player, ps_weapon, weapon->FindState ("Drain"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
weapon->DepleteAmmo (weapon->bAltFire, false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CStaffAttack
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CStaffAttack)
|
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
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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))
|
|
|
|
return;
|
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACStaffMissile), self->angle-(ANG45/15));
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
2009-12-25 00:19:28 +00:00
|
|
|
mo->WeaveIndexXY = 32;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = P_SpawnPlayerMissile (self, RUNTIME_CLASS(ACStaffMissile), self->angle+(ANG45/15));
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
2009-12-25 00:19:28 +00:00
|
|
|
mo->WeaveIndexXY = 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, "ClericCStaffFire", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CStaffMissileSlither
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CStaffMissileSlither)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2009-12-25 11:09:56 +00:00
|
|
|
A_Weave(self, 3, 0, FRACUNIT, 0);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CStaffInitBlink
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CStaffInitBlink)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special1 = (pr_blink()>>1)+20;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_CStaffCheckBlink
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CStaffCheckBlink)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-12 23:00:48 +00:00
|
|
|
if (self->player && self->player->ReadyWeapon)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-12 23:00:48 +00:00
|
|
|
if (!--self->special1)
|
|
|
|
{
|
|
|
|
P_SetPsprite (self->player, ps_weapon, self->player->ReadyWeapon->FindState ("Blink"));
|
|
|
|
self->special1 = (pr_blink()+50)>>2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-16 22:40:04 +00:00
|
|
|
DoReadyWeapon(self);
|
2008-08-12 23:00:48 +00:00
|
|
|
}
|
2006-04-10 21:54:50 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|