- scriptified the Cleric's flame weapon. Also fixed the angle calculations for the circle flame.

This commit is contained in:
Christoph Oelckers 2016-11-26 10:30:41 +01:00
parent f508a57bb8
commit bc1e4eff72
4 changed files with 94 additions and 147 deletions

View file

@ -855,7 +855,6 @@ set( NOT_COMPILED_SOURCE_FILES
${OTHER_SYSTEM_SOURCES}
sc_man_scanner.h
sc_man_scanner.re
g_hexen/a_clericflame.cpp
g_hexen/a_clericholy.cpp
g_hexen/a_clericmace.cpp
g_hexen/a_clericstaff.cpp

View file

@ -1,138 +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"
*/
const double FLAMESPEED = 0.45;
const double FLAMEROTSPEED = 2.;
static FRandom pr_missile ("CFlameMissile");
void A_CFlameAttack (AActor *);
void A_CFlameRotate (AActor *);
void A_CFlamePuff (AActor *);
void A_CFlameMissile (AActor *);
// Flame Missile ------------------------------------------------------------
//============================================================================
//
// A_CFlameAttack
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_CFlameAttack)
{
PARAM_ACTION_PROLOGUE(AActor);
player_t *player;
if (NULL == (player = self->player))
{
return 0;
}
AWeapon *weapon = self->player->ReadyWeapon;
if (weapon != NULL)
{
if (!weapon->DepleteAmmo (weapon->bAltFire))
return 0;
}
P_SpawnPlayerMissile (self, PClass::FindActor("CFlameMissile"));
S_Sound (self, CHAN_WEAPON, "ClericFlameFire", 1, ATTN_NORM);
return 0;
}
//============================================================================
//
// A_CFlamePuff
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_CFlamePuff)
{
PARAM_SELF_PROLOGUE(AActor);
self->renderflags &= ~RF_INVISIBLE;
self->Vel.Zero();
S_Sound (self, CHAN_BODY, "ClericFlameExplode", 1, ATTN_NORM);
return 0;
}
//============================================================================
//
// A_CFlameMissile
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile)
{
PARAM_SELF_PROLOGUE(AActor);
int i;
DAngle an;
double dist;
AActor *mo;
self->renderflags &= ~RF_INVISIBLE;
S_Sound (self, CHAN_BODY, "ClericFlameExplode", 1, ATTN_NORM);
AActor *BlockingMobj = self->BlockingMobj;
if (BlockingMobj && BlockingMobj->flags&MF_SHOOTABLE)
{ // Hit something, so spawn the flame circle around the thing
dist = BlockingMobj->radius + 18;
for (i = 0; i < 4; i++)
{
an = i*45.;
mo = Spawn ("CircleFlame", BlockingMobj->Vec3Angle(dist, an, 5), ALLOW_REPLACE);
if (mo)
{
mo->Angles.Yaw = an;
mo->target = self->target;
mo->VelFromAngle(FLAMESPEED);
mo->specialf1 = mo->Vel.X;
mo->specialf2 = mo->Vel.Y;
mo->tics -= pr_missile()&3;
}
mo = Spawn("CircleFlame", BlockingMobj->Vec3Angle(dist, an, 5), ALLOW_REPLACE);
if(mo)
{
mo->Angles.Yaw = an + 180.;
mo->target = self->target;
mo->VelFromAngle(-FLAMESPEED);
mo->specialf1 = mo->Vel.X;
mo->specialf2 = mo->Vel.Y;
mo->tics -= pr_missile()&3;
}
}
self->SetState (self->SpawnState);
}
return 0;
}
//============================================================================
//
// A_CFlameRotate
//
//============================================================================
DEFINE_ACTION_FUNCTION(AActor, A_CFlameRotate)
{
PARAM_SELF_PROLOGUE(AActor);
DAngle an = self->Angles.Yaw + 90.;
self->VelFromAngle(FLAMEROTSPEED, an);
self->Vel += DVector2(self->specialf1, self->specialf2);
self->Angles.Yaw += 6.;
return 0;
}

View file

@ -24,7 +24,6 @@
#include "serializer.h"
// Include all the Hexen stuff here to reduce compile time
#include "a_clericflame.cpp"
#include "a_clericholy.cpp"
#include "a_clericmace.cpp"
#include "a_clericstaff.cpp"

View file

@ -16,8 +16,6 @@ class CWeapFlame : ClericWeapon
Tag "$TAG_CWEAPFLAME";
}
action native void A_CFlameAttack();
States
{
Spawn:
@ -43,6 +41,29 @@ class CWeapFlame : ClericWeapon
CFLM G 2;
Goto Ready;
}
//============================================================================
//
// A_CFlameAttack
//
//============================================================================
action void A_CFlameAttack()
{
if (player == null)
{
return;
}
Weapon weapon = player.ReadyWeapon;
if (weapon != null)
{
if (!weapon.DepleteAmmo (weapon.bAltFire))
return;
}
SpawnPlayerMissile ("CFlameMissile");
A_PlaySound ("ClericFlameFire", CHAN_WEAPON);
}
}
// Floor Flame --------------------------------------------------------------
@ -127,6 +148,9 @@ class FlamePuff2 : FlamePuff
class CircleFlame : Actor
{
const FLAMESPEED = 0.45;
const FLAMEROTSPEED = 2.;
Default
{
Radius 6;
@ -140,8 +164,6 @@ class CircleFlame : Actor
Obituary "$OB_MPCWEAPFLAME";
}
native void A_CFlameRotate();
States
{
Spawn:
@ -166,6 +188,20 @@ class CircleFlame : Actor
CFCF TUVWXYZ 3 Bright;
Stop;
}
//============================================================================
//
// A_CFlameRotate
//
//============================================================================
void A_CFlameRotate()
{
double an = Angle + 90.;
VelFromAngle(FLAMEROTSPEED, an);
Vel.XY += (specialf1, specialf2);
Angle += 6;
}
}
// Flame Missile ------------------------------------------------------------
@ -184,9 +220,6 @@ class CFlameMissile : FastProjectile
Obituary "$OB_MPCWEAPFLAME";
}
native void A_CFlamePuff();
native void A_CFlameMissile();
States
{
Spawn:
@ -232,4 +265,58 @@ class CFlameMissile : FastProjectile
}
}
//============================================================================
//
// A_CFlamePuff
//
//============================================================================
void A_CFlamePuff()
{
bInvisible = false;
Vel = (0,0,0);
A_PlaySound ("ClericFlameExplode", CHAN_BODY);
}
//============================================================================
//
// A_CFlameMissile
//
//============================================================================
void A_CFlameMissile()
{
bInvisible = false;
A_PlaySound ("ClericFlameExplode", CHAN_BODY);
if (BlockingMobj && BlockingMobj.bShootable)
{ // Hit something, so spawn the flame circle around the thing
double dist = BlockingMobj.radius + 18;
for (int i = 0; i < 4; i++)
{
double an = i*45.;
Actor mo = Spawn ("CircleFlame", BlockingMobj.Vec3Angle(dist, an, 5), ALLOW_REPLACE);
if (mo)
{
mo.angle = an;
mo.target = target;
mo.VelFromAngle(CircleFlame.FLAMESPEED);
mo.specialf1 = mo.Vel.X;
mo.specialf2 = mo.Vel.Y;
mo.tics -= random[FlameMissile]()&3;
}
an += 180;
mo = Spawn("CircleFlame", BlockingMobj.Vec3Angle(dist, an, 5), ALLOW_REPLACE);
if(mo)
{
mo.angle = an;
mo.target = target;
mo.VelFromAngle(-CircleFlame.FLAMESPEED);
mo.specialf1 = mo.Vel.X;
mo.specialf2 = mo.Vel.Y;
mo.tics -= random[FlameMissile]()&3;
}
}
SetState (SpawnState);
}
}
}