From 65222b474cbe73df8bdafb0af8d8d745e508eb6b Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Fri, 8 Feb 2019 14:12:16 +0100 Subject: [PATCH] Experimental changes for F3DFloor export. Requires GZDoom PR (coelckers/gzdoom#732). --- zscript.txt | 8 +- zscript/biorifle.zsc | 25 +++++- .../{mk_coordutil.zsc => dt_coordutil.zsc} | 0 zscript/{mk_matrix.zsc => dt_matrix.zsc} | 0 .../{mk_quaternion.zsc => dt_quaternion.zsc} | 0 zscript/eightball.zsc | 7 ++ zscript/enforcer.zsc | 12 ++- zscript/flakcannon.zsc | 80 ++++++++++++++++--- zscript/minigun.zsc | 12 ++- zscript/pulsegun.zsc | 12 ++- zscript/shockrifle.zsc | 20 ++++- zscript/sniperrifle.zsc | 12 ++- 12 files changed, 157 insertions(+), 31 deletions(-) rename zscript/{mk_coordutil.zsc => dt_coordutil.zsc} (100%) rename zscript/{mk_matrix.zsc => dt_matrix.zsc} (100%) rename zscript/{mk_quaternion.zsc => dt_quaternion.zsc} (100%) diff --git a/zscript.txt b/zscript.txt index e2ceb1f..62a112f 100644 --- a/zscript.txt +++ b/zscript.txt @@ -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" diff --git a/zscript/biorifle.zsc b/zscript/biorifle.zsc index e13cf01..6538cb9 100644 --- a/zscript/biorifle.zsc +++ b/zscript/biorifle.zsc @@ -264,10 +264,10 @@ Class BioGel : Actor for ( int i=0; i 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= (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(); } diff --git a/zscript/minigun.zsc b/zscript/minigun.zsc index f58e761..e0db43e 100644 --- a/zscript/minigun.zsc +++ b/zscript/minigun.zsc @@ -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(); diff --git a/zscript/pulsegun.zsc b/zscript/pulsegun.zsc index 1af81a2..abcb7a2 100644 --- a/zscript/pulsegun.zsc +++ b/zscript/pulsegun.zsc @@ -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