Skip to content

Commit

Permalink
Paladin: Fix numerous bugs with Vorpal Sword, Fix Axe projectiles
Browse files Browse the repository at this point in the history
Added LemonUtil Velocity to Eular Angles to properly update facing for MD3s in real time
  • Loading branch information
Lemon-King committed Oct 24, 2023
1 parent 59338e0 commit b347f65
Show file tree
Hide file tree
Showing 7 changed files with 228 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SpriteFXParticle: ActorParticle {
#include "zscript/actors/hxdd/hexen2/spritefx/acidexplosion2.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/acidmuzzleflash.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/bigexplosion.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/blueexplosion.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/fireboom.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/firecircle.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/firewall1.zs"
Expand All @@ -51,6 +52,7 @@ class SpriteFXParticle: ActorParticle {
#include "zscript/actors/hxdd/hexen2/spritefx/firewall5.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/flamestream.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/pow.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/smallblueflash.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/smallexplosion.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/smallwhiteflash.zs"
#include "zscript/actors/hxdd/hexen2/spritefx/sparks.zs"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class BlueExplosion : SpriteFX {
Default {
RenderStyle "Add";
Alpha 0.5;
}

States {
Spawn:
BLU3 A 2 Bright;
BLU3 BCDEFGHI 2 Bright;
Stop;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class SmallBlueFlash : SpriteFX {
Default {
RenderStyle "Add";
Alpha 0.75;
}

States {
Spawn:
SMBL ABC 2 Bright;
Stop;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@

class SmallExplosion: SpriteFX {
Default {
RenderStyle "Add";
Alpha 0.75;
}

States {
Spawn:
SMEX ABCDEFGHIJKL 3 Bright;
Expand Down
74 changes: 52 additions & 22 deletions resources/assets/zscript/actors/hxdd/hexen2/weapons/paladinaxe.zs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// Paladin Weapon: Axe
// ref: https://github.com/videogamepreservation/hexen2/blob/master/H2MP/hcode/axe.hc

class PWeapAxe : PaladinWeapon {
Default {
Weapon.SelectionOrder 1000;
Expand Down Expand Up @@ -79,7 +81,7 @@ class PWeapAxe : PaladinWeapon {
PWeapVorpalSword_MissileWave(SpawnPlayerMissile("PWeapAxe_BladeProjectilePower", angle + angOff, 0, 10, 12));
} else {
A_StartSound("hexen2/paladin/axgen");
PWeapVorpalSword_MissileWave(SpawnPlayerMissile("PWeapAxe_BladeProjectile", angle, 0, 10, 12));
PWeapAxe_BladeProjectilePower projAxe = PWeapAxe_BladeProjectilePower(SpawnFirstPerson("PWeapAxe_BladeProjectile", angle, 1, -7, true));
}
}

Expand Down Expand Up @@ -146,11 +148,15 @@ class PWeapAxe_BladeProjectileTail: Actor {
States {
Spawn:
TAIL AB 2;
Stop;
Loop;
}

override void Tick() {
Super.Tick();

if (!self.target) {
self.Destroy();
}
}
}

Expand Down Expand Up @@ -205,6 +211,14 @@ class PWeapAxe_BladeProjectilePower : PWeapAxe_BladeProjectile {
Default {
RenderStyle "Add";
}

override void BeginPlay() {
self.A_ChangeModel(self.GetClassName(),
modelindex: 0, modelpath: "models/", model: "axblade.md3",
skinindex: 0, skinpath: "models/", "axblade_skin1",
generatorindex: 0
);
}
}
class PWeapAxe_BladeProjectile : Hexen2Projectile {

Expand Down Expand Up @@ -261,23 +275,32 @@ class PWeapAxe_BladeProjectile : Hexen2Projectile {
Stop;
}

override void PostBeginPlay() {
Super.PostBeginPlay();
PWeapAxe_BladeProjectileTail tail = PWeapAxe_BladeProjectileTail(Spawn("PWeapAxe_BladeProjectileTail"));
if (tail) {
tail.target = self;
tail.angle = self.angle;
tail.pitch = self.pitch;
tail.roll = self.roll;
tail.SetOrigin(self.pos, false);
self.attachedTail = tail;
}
}

override void Tick() {
Super.Tick();

if (attachedTail) {
attachedTail.angle = self.angle;
attachedTail.pitch = self.pitch;
attachedTail.roll = self.roll;
attachedTail.SetOrigin(self.pos, true);
} else {
PWeapAxe_BladeProjectileTail tail = PWeapAxe_BladeProjectileTail(Spawn("PWeapAxe_BladeProjectileTail"));
if (tail) {
tail.angle = self.angle;
tail.pitch = self.pitch;
tail.roll = self.roll;
tail.SetOrigin(self.pos, false);
attachedTail = tail;
}
Vector3 facing = LemonUtil.GetEularFromVelocity(self.vel);
self.angle = facing.x;
self.pitch = facing.y;
self.roll = facing.z;

if (self.attachedTail) {
self.attachedTail.angle = self.angle;
self.attachedTail.pitch = self.pitch;
self.attachedTail.roll = self.roll;
self.attachedTail.SetOrigin(self.pos, true);
}

if (tickDuration <= 0) {
Expand All @@ -288,26 +311,28 @@ class PWeapAxe_BladeProjectile : Hexen2Projectile {
}

void A_OnBounce() {
// use lightbringer code for adjustment!

Actor fxHit;
A_StartSound("hexen2/weapons/explode", CHAN_WEAPON, CHANF_OVERLAP);
if (self is "PWeapAxe_BladeProjectilePower") {
fxHit = Actor(Spawn("PWeapAxe_BladeProjectileExplodePowerHit"));
fxHit = Actor(Spawn("BlueExplosion"));
} else {
fxHit = Actor(Spawn("PWeapAxe_BladeProjectileExplodeHit"));
fxHit = Actor(Spawn("SmallExplosion"));
}
if (fxHit) {
fxHit.SetOrigin(self.pos, false);
}

bounces++;
self.bounces++;
if (tracer && (tracer.bIsMonster || tracer.bShootable)) {
bounces++;
self.bounces++; // doubled on monster hit
if (self is "PWeapAxe_BladeProjectilePower") {
A_DamageRadius();
}
A_DamageHit();
}
if (bounces >= 4) {
if (self.bounces >= 4) {
A_DestroySelf();
}
}
Expand All @@ -329,7 +354,12 @@ class PWeapAxe_BladeProjectile : Hexen2Projectile {
}

void A_DestroySelf() {
Actor fxFade = Actor(Spawn("PWeapAxe_BladeProjectileFade"));
Actor fxFade;
if (self is "PWeapAxe_BladeProjectilePower") {
fxFade = Actor(Spawn("SmallWhiteFlash"));
} else {
fxFade = Actor(Spawn("SmallBlueFlash"));
}
if (fxFade) {
fxFade.SetOrigin(self.pos, false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,11 @@ class PWeapPurifier_Missile: Actor {
return;
}

Vector3 facing = LemonUtil.GetEularFromVelocity(self.vel);
self.angle = facing.x;
self.pitch = facing.y;
self.roll = facing.z;

self.tickDuration -= 1;
if (self.tickDuration <= 0) {
self.Destroy();
Expand Down Expand Up @@ -310,6 +315,11 @@ class PWeapPurifier_DragonBall: Actor {
if (InStateSequence(CurState, self.Findstate("Death"))) {
return;
}

Vector3 facing = LemonUtil.GetEularFromVelocity(self.vel);
self.angle = facing.x;
self.pitch = facing.y;
self.roll = facing.z;

self.tickDuration -= 1;
if (self.tickDuration <= 0) {
Expand Down
Loading

0 comments on commit b347f65

Please sign in to comment.