- scriptified the Fighter's axe.

This commit is contained in:
Christoph Oelckers 2016-11-26 21:03:00 +01:00
parent e541c27622
commit bdad526f62
4 changed files with 182 additions and 254 deletions

View File

@ -855,7 +855,6 @@ set( NOT_COMPILED_SOURCE_FILES
${OTHER_SYSTEM_SOURCES} ${OTHER_SYSTEM_SOURCES}
sc_man_scanner.h sc_man_scanner.h
sc_man_scanner.re sc_man_scanner.re
g_hexen/a_fighteraxe.cpp
g_hexen/a_fighterhammer.cpp g_hexen/a_fighterhammer.cpp
g_hexen/a_fighterplayer.cpp g_hexen/a_fighterplayer.cpp
g_hexen/a_fighterquietus.cpp g_hexen/a_fighterquietus.cpp

View File

@ -1,245 +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 "p_pspr.h"
#include "gstrings.h"
#include "a_hexenglobal.h"
#include "vm.h"
*/
DECLARE_ACTION(A_Raise)
#define AXERANGE (2.25 * MELEERANGE)
static FRandom pr_axeatk ("FAxeAtk");
// The Fighter's Axe --------------------------------------------------------
//============================================================================
//
// A_FAxeCheckReady
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReady)
{
PARAM_ACTION_PROLOGUE(AActor);
player_t *player;
if (nullptr == (player = self->player))
{
return 0;
}
if (player->ReadyWeapon->Ammo1->Amount)
{
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("ReadyGlow"));
}
else
{
DoReadyWeapon(self);
}
return 0;
}
//============================================================================
//
// A_FAxeCheckReadyG
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckReadyG)
{
PARAM_ACTION_PROLOGUE(AActor);
player_t *player;
if (nullptr == (player = self->player))
{
return 0;
}
if (player->ReadyWeapon->Ammo1->Amount <= 0)
{
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Ready"));
}
else
{
DoReadyWeapon(self);
}
return 0;
}
//============================================================================
//
// A_FAxeCheckUp
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUp)
{
PARAM_ACTION_PROLOGUE(AActor);
player_t *player;
if (nullptr == (player = self->player))
{
return 0;
}
if (player->ReadyWeapon->Ammo1->Amount)
{
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("SelectGlow"));
}
else
{
CALL_ACTION(A_Raise, self);
}
return 0;
}
//============================================================================
//
// A_FAxeCheckUpG
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckUpG)
{
PARAM_ACTION_PROLOGUE(AActor);
player_t *player;
if (nullptr == (player = self->player))
{
return 0;
}
if (player->ReadyWeapon->Ammo1->Amount <= 0)
{
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Select"));
}
else
{
CALL_ACTION(A_Raise, self);
}
return 0;
}
//============================================================================
//
// A_FAxeCheckAtk
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_FAxeCheckAtk)
{
PARAM_ACTION_PROLOGUE(AActor);
player_t *player;
if (nullptr == (player = self->player))
{
return 0;
}
if (player->ReadyWeapon->Ammo1->Amount)
{
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("FireGlow"));
}
return 0;
}
//============================================================================
//
// A_FAxeAttack
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_FAxeAttack)
{
PARAM_ACTION_PROLOGUE(AActor);
DAngle angle;
int power;
int damage;
DAngle slope;
int i;
int useMana;
player_t *player;
AWeapon *weapon;
PClassActor *pufftype;
FTranslatedLineTarget t;
if (nullptr == (player = self->player))
{
return 0;
}
AActor *pmo=player->mo;
damage = 40+(pr_axeatk()&15);
damage += pr_axeatk()&7;
power = 0;
weapon = player->ReadyWeapon;
if (player->ReadyWeapon->Ammo1->Amount > 0)
{
damage <<= 1;
power = 6;
pufftype = PClass::FindActor ("AxePuffGlow");
useMana = 1;
}
else
{
pufftype = PClass::FindActor ("AxePuff");
useMana = 0;
}
for (i = 0; i < 16; i++)
{
for (int j = 1; j >= -1; j -= 2)
{
angle = pmo->Angles.Yaw + j*i*(45. / 16);
slope = P_AimLineAttack(pmo, angle, AXERANGE, &t);
if (t.linetarget)
{
P_LineAttack(pmo, angle, AXERANGE, slope, damage, NAME_Melee, pufftype, true, &t);
if (t.linetarget != nullptr)
{
if (t.linetarget->flags3&MF3_ISMONSTER || t.linetarget->player)
{
t.linetarget->Thrust(t.angleFromSource, power);
}
AdjustPlayerAngle(pmo, &t);
useMana++;
goto axedone;
}
}
}
}
// didn't find any creatures, so try to strike any walls
pmo->weaponspecial = 0;
angle = pmo->Angles.Yaw;
slope = P_AimLineAttack (pmo, angle, MELEERANGE);
P_LineAttack (pmo, angle, MELEERANGE, slope, damage, NAME_Melee, pufftype, true);
axedone:
if (useMana == 2)
{
AWeapon *weapon = player->ReadyWeapon;
if (weapon != nullptr)
{
weapon->DepleteAmmo (weapon->bAltFire, false);
if ((weapon->Ammo1 == nullptr || weapon->Ammo1->Amount == 0) &&
(!(weapon->WeaponFlags & WIF_PRIMARY_USES_BOTH) ||
weapon->Ammo2 == nullptr || weapon->Ammo2->Amount == 0))
{
P_SetPsprite(player, PSP_WEAPON, player->ReadyWeapon->FindState ("Fire") + 5);
}
}
}
return 0;
}

View File

@ -24,7 +24,6 @@
#include "serializer.h" #include "serializer.h"
// Include all the Hexen stuff here to reduce compile time // Include all the Hexen stuff here to reduce compile time
#include "a_fighteraxe.cpp"
#include "a_fighterhammer.cpp" #include "a_fighterhammer.cpp"
#include "a_fighterplayer.cpp" #include "a_fighterplayer.cpp"
#include "a_fighterquietus.cpp" #include "a_fighterquietus.cpp"

View File

@ -3,6 +3,8 @@
class FWeapAxe : FighterWeapon class FWeapAxe : FighterWeapon
{ {
const AXERANGE = (2.25 * MELEERANGE);
Default Default
{ {
Weapon.SelectionOrder 1500; Weapon.SelectionOrder 1500;
@ -17,13 +19,6 @@ class FWeapAxe : FighterWeapon
Tag "$TAG_FWEAPAXE"; Tag "$TAG_FWEAPAXE";
} }
action native void A_FAxeCheckUp();
action native void A_FAxeCheckReady();
action native void A_FAxeCheckAtk();
action native void A_FAxeAttack();
action native void A_FAxeCheckUpG();
action native void A_FAxeCheckReadyG();
States States
{ {
Spawn: Spawn:
@ -45,6 +40,7 @@ class FWeapAxe : FighterWeapon
FAXE D 1 Offset (-5, 70) A_FAxeAttack; FAXE D 1 Offset (-5, 70) A_FAxeAttack;
FAXE D 2 Offset (-25, 90); FAXE D 2 Offset (-25, 90);
FAXE E 1 Offset (15, 32); FAXE E 1 Offset (15, 32);
EndAttack:
FAXE E 2 Offset (10, 54); FAXE E 2 Offset (10, 54);
FAXE E 7 Offset (10, 150); FAXE E 7 Offset (10, 150);
FAXE A 1 Offset (0, 60) A_ReFire; FAXE A 1 Offset (0, 60) A_ReFire;
@ -101,6 +97,185 @@ class FWeapAxe : FighterWeapon
} }
//============================================================================
//
// A_FAxeCheckReady
//
//============================================================================
action void A_FAxeCheckReady()
{
if (player == null)
{
return;
}
Weapon w = player.ReadyWeapon;
if (w.Ammo1 && w.Ammo1.Amount > 0)
{
player.SetPsprite(PSP_WEAPON, w.FindState("ReadyGlow"));
}
else
{
A_WeaponReady();
}
}
//============================================================================
//
// A_FAxeCheckReadyG
//
//============================================================================
action void A_FAxeCheckReadyG()
{
if (player == null)
{
return;
}
Weapon w = player.ReadyWeapon;
if (!w.Ammo1 || w.Ammo1.Amount <= 0)
{
player.SetPsprite(PSP_WEAPON, w.FindState("Ready"));
}
else
{
A_WeaponReady();
}
}
//============================================================================
//
// A_FAxeCheckUp
//
//============================================================================
action void A_FAxeCheckUp()
{
if (player == null)
{
return;
}
Weapon w = player.ReadyWeapon;
if (w.Ammo1 && w.Ammo1.Amount > 0)
{
player.SetPsprite(PSP_WEAPON, w.FindState("SelectGlow"));
}
else
{
A_Raise();
}
}
//============================================================================
//
// A_FAxeCheckUpG
//
//============================================================================
action void A_FAxeCheckUpG()
{
if (player == null)
{
return;
}
Weapon w = player.ReadyWeapon;
if (!w.Ammo1 || w.Ammo1.Amount <= 0)
{
player.SetPsprite(PSP_WEAPON, w.FindState("Select"));
}
else
{
A_Raise();
}
}
//============================================================================
//
// A_FAxeCheckAtk
//
//============================================================================
action void A_FAxeCheckAtk()
{
if (player == null)
{
return;
}
Weapon w = player.ReadyWeapon;
if (w.Ammo1 && w.Ammo1.Amount > 0)
{
player.SetPsprite(PSP_WEAPON, w.FindState("FireGlow"));
}
}
//============================================================================
//
// A_FAxeAttack
//
//============================================================================
action void A_FAxeAttack()
{
FTranslatedLineTarget t;
if (player == null)
{
return;
}
int damage = 40+(random[AxeAtk]() & 15);
damage += random[AxeAtk]() & 7;
int power = 0;
Weapon weapon = player.ReadyWeapon;
class<Actor> pufftype;
int usemana;
if ((usemana = (weapon.Ammo1 && weapon.Ammo1.Amount > 0)))
{
damage <<= 1;
power = 6;
pufftype = "AxePuffGlow";
}
else
{
pufftype = "AxePuff";
}
for (int i = 0; i < 16; i++)
{
for (int j = 1; j >= -1; j -= 2)
{
double ang = angle + j*i*(45. / 16);
double slope = AimLineAttack(ang, AXERANGE, t);
if (t.linetarget)
{
LineAttack(ang, AXERANGE, slope, damage, 'Melee', pufftype, true, t);
if (t.linetarget != null)
{
if (t.linetarget.bIsMonster || t.linetarget.player)
{
t.linetarget.Thrust(power, t.angleFromSource);
}
AdjustPlayerAngle(t);
weapon.DepleteAmmo (weapon.bAltFire, false);
if ((weapon.Ammo1 == null || weapon.Ammo1.Amount == 0) &&
(!(weapon.bPrimary_Uses_Both) ||
weapon.Ammo2 == null || weapon.Ammo2.Amount == 0))
{
player.SetPsprite(PSP_WEAPON, weapon.FindState("EndAttack"));
}
return;
}
}
}
}
// didn't find any creatures, so try to strike any walls
self.weaponspecial = 0;
double slope = AimLineAttack (angle, MELEERANGE);
LineAttack (angle, MELEERANGE, slope, damage, 'Melee', pufftype, true);
}
} }
// Axe Puff ----------------------------------------------------------------- // Axe Puff -----------------------------------------------------------------