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 "a_pickups.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "a_sharedglobal.h"
|
|
|
|
#include "p_enemy.h"
|
|
|
|
#include "d_event.h"
|
|
|
|
#include "gstrings.h"
|
2008-08-10 20:48:55 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_snoutattack ("SnoutAttack");
|
|
|
|
static FRandom pr_pigattack ("PigAttack");
|
|
|
|
static FRandom pr_pigplayerthink ("PigPlayerThink");
|
|
|
|
|
2008-04-10 14:38:43 +00:00
|
|
|
extern void AdjustPlayerAngle (AActor *, AActor *);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Pig player ---------------------------------------------------------------
|
|
|
|
|
|
|
|
class APigPlayer : public APlayerPawn
|
|
|
|
{
|
2008-08-09 11:35:42 +00:00
|
|
|
DECLARE_CLASS (APigPlayer, APlayerPawn)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
void MorphPlayerThink ();
|
|
|
|
};
|
|
|
|
|
2008-08-09 11:35:42 +00:00
|
|
|
IMPLEMENT_CLASS (APigPlayer)
|
2008-02-05 23:32:49 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
void APigPlayer::MorphPlayerThink ()
|
|
|
|
{
|
2008-04-08 08:53:42 +00:00
|
|
|
if (player->morphTics & 15)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(!(momx | momy) && pr_pigplayerthink() < 64)
|
|
|
|
{ // Snout sniff
|
2006-10-31 14:53:21 +00:00
|
|
|
if (player->ReadyWeapon != NULL)
|
|
|
|
{
|
2008-08-11 19:18:48 +00:00
|
|
|
P_SetPsprite(player, ps_weapon, player->ReadyWeapon->FindState("Grunt"));
|
2006-10-31 14:53:21 +00:00
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
S_Sound (this, CHAN_VOICE, "PigActive1", 1, ATTN_NORM); // snort
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (pr_pigplayerthink() < 48)
|
|
|
|
{
|
|
|
|
S_Sound (this, CHAN_VOICE, "PigActive", 1, ATTN_NORM);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-17 20:29:41 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_SnoutAttack
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack)
|
2006-06-17 20:29:41 +00:00
|
|
|
{
|
|
|
|
angle_t angle;
|
|
|
|
int damage;
|
|
|
|
int slope;
|
2006-02-24 04:48:15 +00:00
|
|
|
player_t *player;
|
2008-02-12 05:54:03 +00:00
|
|
|
AActor *puff;
|
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;
|
|
|
|
}
|
2006-06-17 20:29:41 +00:00
|
|
|
|
|
|
|
damage = 3+(pr_snoutattack()&3);
|
|
|
|
angle = player->mo->angle;
|
2008-04-10 14:38:43 +00:00
|
|
|
slope = P_AimLineAttack(player->mo, angle, MELEERANGE, &linetarget);
|
2008-08-09 11:35:42 +00:00
|
|
|
puff = P_LineAttack(player->mo, angle, MELEERANGE, slope, damage, NAME_Melee, "SnoutPuff", true);
|
2006-06-17 20:29:41 +00:00
|
|
|
S_Sound(player->mo, CHAN_VOICE, "PigActive", 1, ATTN_NORM);
|
|
|
|
if(linetarget)
|
|
|
|
{
|
2008-04-10 14:38:43 +00:00
|
|
|
AdjustPlayerAngle(player->mo, linetarget);
|
2008-02-12 05:54:03 +00:00
|
|
|
if(puff != NULL)
|
2006-06-17 20:29:41 +00:00
|
|
|
{ // Bit something
|
|
|
|
S_Sound(player->mo, CHAN_VOICE, "PigAttack", 1, ATTN_NORM);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_PigPain
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_PigPain)
|
2006-06-17 20:29:41 +00:00
|
|
|
{
|
2008-08-10 22:48:37 +00:00
|
|
|
CALL_ACTION(A_Pain, self);
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->z <= self->floorz)
|
2006-06-17 20:29:41 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->momz = FRACUNIT*7/2;
|
2006-06-17 20:29:41 +00:00
|
|
|
}
|
|
|
|
}
|