Experimental changes for F3DFloor export.

Requires GZDoom PR (coelckers/gzdoom#732).
This commit is contained in:
Marisa the Magician 2019-02-08 14:12:16 +01:00
commit 65222b474c
12 changed files with 157 additions and 31 deletions

View file

@ -1,8 +1,8 @@
version "3.7"
version "3.8"
#include "zscript/mk_matrix.zsc"
#include "zscript/mk_coordutil.zsc"
#include "zscript/mk_quaternion.zsc"
#include "zscript/dt_matrix.zsc"
#include "zscript/dt_coordutil.zsc"
#include "zscript/dt_quaternion.zsc"
#include "zscript/utgore.zsc"
#include "zscript/utcommon.zsc"
#include "zscript/impacthammer.zsc"

View file

@ -264,10 +264,10 @@ Class BioGel : Actor
for ( int i=0; i<numpt; i++ )
{
Vector3 pvel = (FRandom[GES](-1,1),FRandom[GES](-1,1),FRandom[GES](-1,1)).unit()*FRandom[GES](1,3);
Vector3 spos = pos;
if ( atplane == 1 ) spos += Normal*2;
Vector3 spos = pos+normal*2*scale.x;
let s = Spawn("BioSpark",spos);
s.vel = pvel;
if ( normal != (0,0,0) ) s.vel += normal*2;
}
}
if ( deadtimer <= -1 ) return;
@ -286,6 +286,7 @@ Class BioGel : Actor
// align self to what surface was hit, currently does not support 3d floors + slopes properly
virtual void AlignSelf()
{
F3DFloor ff;
bINTERPOLATEANGLES = false;
bHITOWNER = true;
A_NoGravity();
@ -397,9 +398,17 @@ Class BioGel : Actor
}
else if ( BlockingFloor )
{
// find closest 3d floor for its normal
for ( int i=0; i<CurSector.e.ffloors.Size(); i++ )
{
if ( !(CurSector.e.ffloors[i].top.ZAtPoint(pos.xy) ~== floorz) ) continue;
ff = CurSector.e.ffloors[i];
break;
}
if ( ff ) normal = -ff.top.Normal;
else normal = BlockingFloor.floorplane.Normal;
atsector = BlockingFloor;
atplane = 0;
normal = BlockingFloor.floorplane.Normal;
pitch = asin(-normal.z);
angle = atan2(normal.y,normal.x);
roll = FRandom[GES](0,360);
@ -409,9 +418,17 @@ Class BioGel : Actor
}
else if ( BlockingCeiling )
{
// find closest 3d floor for its normal
for ( int i=0; i<CurSector.e.ffloors.Size(); i++ )
{
if ( !(CurSector.e.ffloors[i].bottom.ZAtPoint(pos.xy) ~== ceilingz) ) continue;
ff = CurSector.e.ffloors[i];
break;
}
if ( ff ) normal = -ff.bottom.Normal;
else normal = BlockingCeiling.ceilingplane.Normal;
atsector = BlockingCeiling;
atplane = 1;
normal = BlockingCeiling.ceilingplane.Normal;
pitch = asin(-normal.z);
angle = atan2(normal.y,normal.x);
roll = FRandom[GES](0,360);

View file

@ -306,6 +306,13 @@ Class UTRocketLauncher : UTWeapon
{
Super.Tick();
if ( !Owner ) return;
if ( Owner.Health <= 0 )
{
LockedTarget = null;
LockedOn = false;
crosshair = 0;
return;
}
if ( LockedOn && (!LockedTarget || (LockedTarget.Health <= 0) || !LockedTarget.bIsMonster || LockedTarget.bKilled || LockedTarget.bCorpse || !LockedTarget.bShootable) )
{
LockedTarget = null;

View file

@ -355,8 +355,16 @@ Class Enforcer : UTWeapon
else if ( d.HitType != TRACE_HitNone )
{
Vector3 hitnormal = -d.HitDir;
if ( d.HitType == TRACE_HitFloor ) hitnormal = d.HitSector.floorplane.Normal;
else if ( d.HitType == TRACE_HitCeiling ) hitnormal = d.HitSector.ceilingplane.Normal;
if ( d.HitType == TRACE_HitFloor )
{
if ( d.Hit3DFloor ) hitnormal = -d.Hit3DFloor.top.Normal;
else hitnormal = d.HitSector.floorplane.Normal;
}
else if ( d.HitType == TRACE_HitCeiling )
{
if ( d.Hit3DFloor ) hitnormal = -d.Hit3DFloor.bottom.Normal;
else hitnormal = d.HitSector.ceilingplane.Normal;
}
else if ( d.HitType == TRACE_HitWall )
{
hitnormal = (-d.HitLine.delta.y,d.HitLine.delta.x,0).unit();

View file

@ -158,6 +158,7 @@ Class FlakChunk : Actor
double rollvel, pitchvel, yawvel;
double lifetime, lifespeed;
int lifetics;
Vector3 oldvel;
Default
{
Obituary "%o was ripped to shreds by %k's Flak Cannon.";
@ -167,13 +168,14 @@ Class FlakChunk : Actor
DamageFunction Random[Flak](15,20);
DamageType 'Shredded';
BounceType "Hexen";
BounceFactor 0.8;
WallBounceFactor 0.8;
BounceFactor 1.0;
WallBounceFactor 1.0;
PROJECTILE;
+USEBOUNCESTATE;
+CANBOUNCEWATER;
+SKYEXPLODE;
+INTERPOLATEANGLES;
+HITTRACER;
Scale 0.3;
}
override void PostBeginPlay()
@ -192,6 +194,7 @@ Class FlakChunk : Actor
}
override void Tick()
{
oldvel = vel;
Super.Tick();
if ( globalfreeze || level.frozen ) return;
if ( waterlevel > 0 )
@ -228,8 +231,62 @@ Class FlakChunk : Actor
pitch += pitchvel;
angle += pitchvel;
}
action void A_HandleBounce()
void A_HandleBounce()
{
// chunks in vanilla have a special variation on the standard reflect formula that causes them to bounce differently when hitting a surface head-on
// (0.5 to 0.8 reduction perpendicular to the surface normal, to be specific)
Vector3 HitNormal = -vel.unit();
F3DFloor ff;
if ( BlockingFloor )
{
// find closest 3d floor for its normal
for ( int i=0; i<CurSector.e.ffloors.Size(); i++ )
{
if ( !(CurSector.e.ffloors[i].top.ZAtPoint(pos.xy) ~== floorz) ) continue;
ff = CurSector.e.ffloors[i];
break;
}
if ( ff ) HitNormal = -ff.top.Normal;
else HitNormal = BlockingFloor.floorplane.Normal;
}
else if ( BlockingCeiling )
{
// find closest 3d floor for its normal
for ( int i=0; i<CurSector.e.ffloors.Size(); i++ )
{
if ( !(CurSector.e.ffloors[i].bottom.ZAtPoint(pos.xy) ~== ceilingz) ) continue;
ff = CurSector.e.ffloors[i];
break;
}
if ( ff ) HitNormal = -ff.bottom.Normal;
else HitNormal = BlockingCeiling.ceilingplane.Normal;
}
else if ( BlockingLine )
{
HitNormal = (-BlockingLine.delta.y,BlockingLine.delta.x,0).unit();
if ( !BlockingLine.sidedef[1] || (CurSector == BlockingLine.frontsector) )
HitNormal *= -1;
}
else if ( BlockingMobj )
{
Vector3 diff = level.Vec3Diff(pos,BlockingMobj.pos);
if ( (pos.x+radius) <= (BlockingMobj.pos.x-BlockingMobj.radius) )
HitNormal = (-1,0,0);
else if ( (pos.x-radius) >= (BlockingMobj.pos.x+BlockingMobj.radius) )
HitNormal = (1,0,0);
else if ( (pos.y+radius) <= (BlockingMobj.pos.y-BlockingMobj.radius) )
HitNormal = (0,-1,0);
else if ( (pos.y-radius) >= (BlockingMobj.pos.y+BlockingMobj.radius) )
HitNormal = (0,1,0);
else if ( pos.z >= (BlockingMobj.pos.z+BlockingMobj.height) )
HitNormal = (0,0,1);
else if ( (pos.z+height) <= BlockingMobj.pos.z )
HitNormal = (0,0,-1);
}
// undo the bounce, we need to hook in our own
vel = oldvel;
// re-do the bounce with our formula
vel = 0.8*((vel dot HitNormal)*HitNormal*(-1.8+FRandom[Flak](0.0,0.8))+vel);
bHITOWNER = true;
int numpt = Random[Flak](2,3);
if ( (frame < 10) && Random[Flak](0,1) )
@ -244,13 +301,9 @@ Class FlakChunk : Actor
else A_SprayDecal("WallCrack",-8);
A_Gravity();
gravity = 0.35;
invoker.rollvel = FRandom[Flak](50,100)*RandomPick[Flak](-1,1)*(vel.length()/speed);
invoker.pitchvel = FRandom[Flak](50,100)*RandomPick[Flak](-1,1)*(vel.length()/speed);
invoker.yawvel = FRandom[Flak](50,100)*RandomPick[Flak](-1,1)*(vel.length()/speed);
vel = (vel.unit()+(FRandom[Flak](-0.2,0.2),FRandom[Flak](-0.2,0.2),FRandom[Flak](-0.2,0.2))).unit()*vel.length();
// TODO chunks in vanilla have a special variation on the standard reflect formula that causes them to bounce differently when hitting a surface head-on
// (0.5 to 0.8 reduction perpendicular to the surface normal, to be specific)
// I have no idea how I'll even implement this reduction reliably
rollvel = FRandom[Flak](50,100)*RandomPick[Flak](-1,1)*(vel.length()/speed);
pitchvel = FRandom[Flak](50,100)*RandomPick[Flak](-1,1)*(vel.length()/speed);
yawvel = FRandom[Flak](50,100)*RandomPick[Flak](-1,1)*(vel.length()/speed);
A_PlaySound("flak/bounce",volume:0.3);
A_AlertMonsters();
if ( vel.length() < 5.0 ) ExplodeMissile();
@ -302,7 +355,12 @@ Class FlakChunk : Actor
Crash:
TNT1 A 0
{
Spawn("BulletPuff",pos);
let l = Spawn("BulletImpact",pos);
Vector3 dir;
if ( tracer ) dir = level.Vec3Diff(pos,tracer.Vec3Offset(0,0,tracer.height/2)).unit();
else dir = vel.unit();
l.angle = atan2(dir.y,dir.x);
l.pitch = asin(-dir.z);
A_PlaySound("flak/hit",volume:0.3);
A_AlertMonsters();
}

View file

@ -131,8 +131,16 @@ Class Minigun : UTWeapon
else if ( d.HitType != TRACE_HitNone )
{
Vector3 hitnormal = -d.HitDir;
if ( d.HitType == TRACE_HitFloor ) hitnormal = d.HitSector.floorplane.Normal;
else if ( d.HitType == TRACE_HitCeiling ) hitnormal = d.HitSector.ceilingplane.Normal;
if ( d.HitType == TRACE_HitFloor )
{
if ( d.Hit3DFloor ) hitnormal = -d.Hit3DFloor.top.Normal;
else hitnormal = d.HitSector.floorplane.Normal;
}
else if ( d.HitType == TRACE_HitCeiling )
{
if ( d.Hit3DFloor ) hitnormal = -d.Hit3DFloor.bottom.Normal;
else hitnormal = d.HitSector.ceilingplane.Normal;
}
else if ( d.HitType == TRACE_HitWall )
{
hitnormal = (-d.HitLine.delta.y,d.HitLine.delta.x,0).unit();

View file

@ -397,8 +397,16 @@ Class PulseBolt : Actor
if ( t.Results.Side ) norm *= -1;
t.Results.HitLine.RemoteActivate(tracer,t.Results.Side,SPAC_Impact,t.Results.HitPos);
}
else if ( t.Results.HitType == TRACE_HitFloor ) norm = t.Results.HitSector.floorplane.Normal;
else if ( t.Results.HitType == TRACE_HitCeiling ) norm = t.Results.HitSector.ceilingplane.Normal;
else if ( t.Results.HitType == TRACE_HitFloor )
{
if ( t.Results.ffloor ) norm = -t.Results.ffloor.top.Normal;
else norm = t.Results.HitSector.floorplane.Normal;
}
else if ( t.Results.HitType == TRACE_HitCeiling )
{
if ( t.Results.ffloor ) norm = -t.Results.ffloor.bottom.Normal;
else norm = t.Results.HitSector.ceilingplane.Normal;
}
int numpt = Random[Pulse](10,20)*!Random[Pulse](0,2);
for ( int i=0; i<numpt; i++ )
{

View file

@ -386,9 +386,15 @@ Class ShockBeam : Actor
if ( t.Results.Side == 0 ) HitNormal *= -1;
}
else if ( t.Results.HitType == TRACE_HitFloor )
HitNormal = t.Results.HitSector.floorplane.Normal;
{
if ( t.Results.ffloor ) HitNormal = -t.Results.ffloor.top.Normal;
else HitNormal = t.Results.HitSector.floorplane.Normal;
}
else if ( t.Results.HitType == TRACE_HitCeiling )
HitNormal = t.Results.HitSector.ceilingplane.Normal;
{
if ( t.Results.ffloor ) HitNormal = -t.Results.ffloor.bottom.Normal;
else HitNormal = t.Results.HitSector.ceilingplane.Normal;
}
let r = Spawn("ShockBeamRing",pos);
r.angle = atan2(HitNormal.y,HitNormal.x);
r.pitch = asin(-HitNormal.z);
@ -618,9 +624,15 @@ Class SuperShockBeam : Actor
if ( t.Results.Side == 1 ) HitNormal *= -1;
}
else if ( t.Results.HitType == TRACE_HitFloor )
HitNormal = t.Results.HitSector.floorplane.Normal;
{
if ( t.Results.ffloor ) HitNormal = -t.Results.ffloor.top.Normal;
else HitNormal = t.Results.HitSector.floorplane.Normal;
}
else if ( t.Results.HitType == TRACE_HitCeiling )
HitNormal = t.Results.HitSector.ceilingplane.Normal;
{
if ( t.Results.ffloor ) HitNormal = -t.Results.ffloor.bottom.Normal;
else HitNormal = t.Results.HitSector.ceilingplane.Normal;
}
let r = Spawn("SuperShockBeamRing",pos);
r.angle = atan2(HitNormal.y,HitNormal.x);
r.pitch = asin(-HitNormal.z);

View file

@ -129,8 +129,16 @@ Class SniperRifle : UTWeapon
else if ( d.HitType != TRACE_HitNone )
{
Vector3 hitnormal = -d.HitDir;
if ( d.HitType == TRACE_HitFloor ) hitnormal = d.HitSector.floorplane.Normal;
else if ( d.HitType == TRACE_HitCeiling ) hitnormal = d.HitSector.ceilingplane.Normal;
if ( d.HitType == TRACE_HitFloor )
{
if ( d.Hit3DFloor ) hitnormal = -d.Hit3DFloor.top.Normal;
else hitnormal = d.HitSector.floorplane.Normal;
}
else if ( d.HitType == TRACE_HitCeiling )
{
if ( d.Hit3DFloor ) hitnormal = -d.Hit3DFloor.bottom.Normal;
else hitnormal = d.HitSector.ceilingplane.Normal;
}
else if ( d.HitType == TRACE_HitWall )
{
hitnormal = (-d.HitLine.delta.y,d.HitLine.delta.x,0).unit();