mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
- scriptified the fighter's fist.
This commit is contained in:
parent
178db4bb09
commit
80f233cd0b
9 changed files with 129 additions and 169 deletions
|
@ -855,7 +855,6 @@ set( NOT_COMPILED_SOURCE_FILES
|
|||
${OTHER_SYSTEM_SOURCES}
|
||||
sc_man_scanner.h
|
||||
sc_man_scanner.re
|
||||
g_hexen/a_fighterplayer.cpp
|
||||
g_hexen/a_fighterquietus.cpp
|
||||
g_hexen/a_flechette.cpp
|
||||
g_hexen/a_flies.cpp
|
||||
|
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
#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 "a_hexenglobal.h"
|
||||
#include "vm.h"
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(AFighterWeapon, false, false)
|
||||
IMPLEMENT_CLASS(AClericWeapon, false, false)
|
||||
IMPLEMENT_CLASS(AMageWeapon, false, false)
|
||||
|
||||
static FRandom pr_fpatk ("FPunchAttack");
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// AdjustPlayerAngle
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
#define MAX_ANGLE_ADJUST (5.)
|
||||
|
||||
void AdjustPlayerAngle (AActor *pmo, FTranslatedLineTarget *t)
|
||||
{
|
||||
// normally this will adjust relative to the actual direction to the target,
|
||||
// but with arbitrary portals that cannot be calculated so using the actual
|
||||
// attack angle is the only option.
|
||||
DAngle atkangle = t->unlinked ? t->angleFromSource : pmo->AngleTo(t->linetarget);
|
||||
DAngle difference = deltaangle(pmo->Angles.Yaw, atkangle);
|
||||
if (fabs(difference) > MAX_ANGLE_ADJUST)
|
||||
{
|
||||
if (difference > 0)
|
||||
{
|
||||
pmo->Angles.Yaw += MAX_ANGLE_ADJUST;
|
||||
}
|
||||
else
|
||||
{
|
||||
pmo->Angles.Yaw -= MAX_ANGLE_ADJUST;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pmo->Angles.Yaw = t->angleFromSource;
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, AdjustPlayerAngle)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
PARAM_POINTER(t, FTranslatedLineTarget);
|
||||
AdjustPlayerAngle(self, t);
|
||||
return 0;
|
||||
}
|
||||
//============================================================================
|
||||
//
|
||||
// TryPunch
|
||||
//
|
||||
// Returns true if an actor was punched, false if not.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
static bool TryPunch(APlayerPawn *pmo, DAngle angle, int damage, int power)
|
||||
{
|
||||
PClassActor *pufftype;
|
||||
FTranslatedLineTarget t;
|
||||
DAngle slope;
|
||||
|
||||
slope = P_AimLineAttack (pmo, angle, 2*MELEERANGE, &t);
|
||||
if (t.linetarget != NULL)
|
||||
{
|
||||
if (++pmo->weaponspecial >= 3)
|
||||
{
|
||||
damage <<= 1;
|
||||
power *= 3;
|
||||
pufftype = PClass::FindActor("HammerPuff");
|
||||
}
|
||||
else
|
||||
{
|
||||
pufftype = PClass::FindActor("PunchPuff");
|
||||
}
|
||||
P_LineAttack (pmo, angle, 2*MELEERANGE, slope, damage, NAME_Melee, pufftype, true, &t);
|
||||
if (t.linetarget != NULL)
|
||||
{
|
||||
if (t.linetarget->player != NULL ||
|
||||
(t.linetarget->Mass != INT_MAX && (t.linetarget->flags3 & MF3_ISMONSTER)))
|
||||
{
|
||||
t.linetarget->Thrust(t.angleFromSource, power);
|
||||
}
|
||||
AdjustPlayerAngle (pmo, &t);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// A_FPunchAttack
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
DEFINE_ACTION_FUNCTION(AActor, A_FPunchAttack)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE(AActor);
|
||||
|
||||
int damage;
|
||||
int i;
|
||||
player_t *player;
|
||||
|
||||
if (nullptr == (player = self->player))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
APlayerPawn *pmo = player->mo;
|
||||
|
||||
damage = 40+(pr_fpatk()&15);
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
if (TryPunch(pmo, pmo->Angles.Yaw + i*(45./16), damage, 2) ||
|
||||
TryPunch(pmo, pmo->Angles.Yaw - i*(45./16), damage, 2))
|
||||
{ // hit something
|
||||
if (pmo->weaponspecial >= 3)
|
||||
{
|
||||
pmo->weaponspecial = 0;
|
||||
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState("Fire2"));
|
||||
S_Sound (pmo, CHAN_VOICE, "*fistgrunt", 1, ATTN_NORM);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// didn't find any creatures, so try to strike any walls
|
||||
pmo->weaponspecial = 0;
|
||||
|
||||
DAngle slope = P_AimLineAttack (pmo, pmo->Angles.Yaw, MELEERANGE);
|
||||
P_LineAttack (pmo, pmo->Angles.Yaw, MELEERANGE, slope, damage, NAME_Melee, PClass::FindActor("PunchPuff"), true);
|
||||
return 0;
|
||||
}
|
|
@ -3,26 +3,6 @@
|
|||
|
||||
#include "d_player.h"
|
||||
|
||||
void AdjustPlayerAngle(AActor *pmo, FTranslatedLineTarget *t);
|
||||
|
||||
class AFighterWeapon : public AWeapon
|
||||
{
|
||||
DECLARE_CLASS (AFighterWeapon, AWeapon);
|
||||
public:
|
||||
};
|
||||
|
||||
class AClericWeapon : public AWeapon
|
||||
{
|
||||
DECLARE_CLASS (AClericWeapon, AWeapon);
|
||||
public:
|
||||
};
|
||||
|
||||
class AMageWeapon : public AWeapon
|
||||
{
|
||||
DECLARE_CLASS (AMageWeapon, AWeapon);
|
||||
public:
|
||||
};
|
||||
|
||||
class AArtiPoisonBag : public AInventory
|
||||
{
|
||||
DECLARE_CLASS (AArtiPoisonBag, AInventory)
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "serializer.h"
|
||||
|
||||
// Include all the Hexen stuff here to reduce compile time
|
||||
#include "a_fighterplayer.cpp"
|
||||
#include "a_fighterquietus.cpp"
|
||||
#include "a_flechette.cpp"
|
||||
#include "a_flies.cpp"
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
#include "doomstat.h"
|
||||
*/
|
||||
|
||||
class AMageWeapon : public AWeapon
|
||||
{
|
||||
DECLARE_CLASS (AMageWeapon, AWeapon);
|
||||
public:
|
||||
};
|
||||
|
||||
IMPLEMENT_CLASS(AMageWeapon, false, false)
|
||||
|
||||
static FRandom pr_mstafftrack ("MStaffTrack");
|
||||
static FRandom pr_bloodscourgedrop ("BloodScourgeDrop");
|
||||
|
||||
|
|
|
@ -838,6 +838,7 @@ FState *AWeapon::GetUpState ()
|
|||
stack.Call(func, params, 1, &ret, 1, nullptr);
|
||||
return retval;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -858,6 +859,7 @@ FState *AWeapon::GetDownState ()
|
|||
stack.Call(func, params, 1, &ret, 1, nullptr);
|
||||
return retval;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -878,6 +880,7 @@ FState *AWeapon::GetReadyState ()
|
|||
stack.Call(func, params, 1, &ret, 1, nullptr);
|
||||
return retval;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -898,6 +901,7 @@ FState *AWeapon::GetAtkState (bool hold)
|
|||
stack.Call(func, params, 2, &ret, 1, nullptr);
|
||||
return retval;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -918,6 +922,7 @@ FState *AWeapon::GetAltAtkState (bool hold)
|
|||
stack.Call(func, params, 2, &ret, 1, nullptr);
|
||||
return retval;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -268,7 +268,6 @@ class Actor : Thinker native
|
|||
virtual native bool SpecialBlastHandling (Actor source, double strength);
|
||||
|
||||
|
||||
native void AdjustPlayerAngle(FTranslatedLineTarget t);
|
||||
native static readonly<Actor> GetDefaultByType(class<Actor> cls);
|
||||
native static double GetDefaultSpeed(class<Actor> type);
|
||||
native void RemoveFromHash();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// The Doom and Heretic players are not excluded from pickup in case
|
||||
// somebody wants to use these weapons with either of those games.
|
||||
|
||||
class FighterWeapon : Weapon native
|
||||
class FighterWeapon : Weapon
|
||||
{
|
||||
Default
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ class FighterWeapon : Weapon native
|
|||
}
|
||||
}
|
||||
|
||||
class ClericWeapon : Weapon native
|
||||
class ClericWeapon : Weapon
|
||||
{
|
||||
Default
|
||||
{
|
||||
|
@ -27,3 +27,38 @@ class MageWeapon : Weapon native
|
|||
Inventory.ForbiddenTo "FighterPlayer", "ClericPlayer";
|
||||
}
|
||||
}
|
||||
|
||||
extend class Actor
|
||||
{
|
||||
//============================================================================
|
||||
//
|
||||
// AdjustPlayerAngle
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
const MAX_ANGLE_ADJUST = (5.);
|
||||
|
||||
void AdjustPlayerAngle(FTranslatedLineTarget t)
|
||||
{
|
||||
// normally this will adjust relative to the actual direction to the target,
|
||||
// but with arbitrary portals that cannot be calculated so using the actual
|
||||
// attack angle is the only option.
|
||||
double atkangle = t.unlinked ? t.angleFromSource : AngleTo(t.linetarget);
|
||||
double difference = deltaangle(Angle, atkangle);
|
||||
if (abs(difference) > MAX_ANGLE_ADJUST)
|
||||
{
|
||||
if (difference > 0)
|
||||
{
|
||||
angle += MAX_ANGLE_ADJUST;
|
||||
}
|
||||
else
|
||||
{
|
||||
angle -= MAX_ANGLE_ADJUST;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
angle = t.angleFromSource;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,8 +13,6 @@ class FWeapFist : FighterWeapon
|
|||
Tag "$TAG_FWEAPFIST";
|
||||
}
|
||||
|
||||
action native void A_FPunchAttack();
|
||||
|
||||
States
|
||||
{
|
||||
Select:
|
||||
|
@ -44,6 +42,85 @@ class FWeapFist : FighterWeapon
|
|||
FPCH E 10 Offset (0, 150);
|
||||
Goto Ready;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// TryPunch
|
||||
//
|
||||
// Returns true if an actor was punched, false if not.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
private action bool TryPunch(double angle, int damage, int power)
|
||||
{
|
||||
Class<Actor> pufftype;
|
||||
FTranslatedLineTarget t;
|
||||
|
||||
double slope = AimLineAttack (angle, 2*MELEERANGE, t);
|
||||
if (t.linetarget != null)
|
||||
{
|
||||
if (++weaponspecial >= 3)
|
||||
{
|
||||
damage <<= 1;
|
||||
power *= 3;
|
||||
pufftype = "HammerPuff";
|
||||
}
|
||||
else
|
||||
{
|
||||
pufftype = "PunchPuff";
|
||||
}
|
||||
LineAttack (angle, 2*MELEERANGE, slope, damage, 'Melee', pufftype, true, t);
|
||||
if (t.linetarget != null)
|
||||
{
|
||||
// The mass threshold has been changed to CommanderKeen's value which has been used most often for 'unmovable' stuff.
|
||||
if (t.linetarget.player != null ||
|
||||
(t.linetarget.Mass < 10000000 && (t.linetarget.bIsMonster)))
|
||||
{
|
||||
if (!t.linetarget.bDontThrust)
|
||||
t.linetarget.Thrust(power, t.angleFromSource);
|
||||
}
|
||||
AdjustPlayerAngle(t);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// A_FPunchAttack
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
action void A_FPunchAttack()
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int damage = 40 + (random[FighterAtk]() & 15);
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
if (TryPunch(angle + i*(45./16), damage, 2) ||
|
||||
TryPunch(angle - i*(45./16), damage, 2))
|
||||
{ // hit something
|
||||
if (weaponspecial >= 3)
|
||||
{
|
||||
weaponspecial = 0;
|
||||
player.SetPsprite(PSP_WEAPON, player.ReadyWeapon.FindState("Fire2"));
|
||||
A_PlaySound ("*fistgrunt", CHAN_VOICE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
// didn't find any creatures, so try to strike any walls
|
||||
weaponspecial = 0;
|
||||
|
||||
double slope = AimLineAttack (angle, MELEERANGE);
|
||||
LineAttack (angle, MELEERANGE, slope, damage, 'Melee', "PunchPuff", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Punch puff ---------------------------------------------------------------
|
||||
|
|
Loading…
Reference in a new issue