Generalized hitnormal functions (where possible).
This commit is contained in:
parent
1d759a109a
commit
b1683dae8e
24 changed files with 206 additions and 785 deletions
|
|
@ -202,28 +202,13 @@ Class HeavyMahSheenGun : SWWMWeapon
|
|||
}
|
||||
if ( (st.Results.HitType != TRACE_HitNone) && (st.Results.HitType != TRACE_HasHitSky) && (st.Results.HitType != TRACE_HitActor) )
|
||||
{
|
||||
Vector3 hitnormal = -st.Results.HitVector;
|
||||
if ( st.Results.HitType == TRACE_HitFloor )
|
||||
{
|
||||
if ( st.Results.FFloor ) hitnormal = -st.Results.FFloor.top.Normal;
|
||||
else hitnormal = st.Results.HitSector.floorplane.Normal;
|
||||
}
|
||||
else if ( st.Results.HitType == TRACE_HitCeiling )
|
||||
{
|
||||
if ( st.Results.FFloor ) hitnormal = -st.Results.FFloor.bottom.Normal;
|
||||
else hitnormal = st.Results.HitSector.ceilingplane.Normal;
|
||||
}
|
||||
else if ( st.Results.HitType == TRACE_HitWall )
|
||||
{
|
||||
hitnormal = (-st.Results.HitLine.delta.y,st.Results.HitLine.delta.x,0).unit();
|
||||
if ( !st.Results.Side ) hitnormal *= -1;
|
||||
}
|
||||
Vector3 hitnormal = SWWMUtility.GetLineTracerHitNormal(st.Results);
|
||||
let p = Spawn("SWWMBulletImpact",st.Results.HitPos+hitnormal*4);
|
||||
p.angle = atan2(hitnormal.y,hitnormal.x);
|
||||
p.pitch = asin(-hitnormal.z);
|
||||
p.target = self;
|
||||
if ( st.Results.HitType == TRACE_HitFloor ) p.CheckSplash(40);
|
||||
if ( st.Results.HitLine ) st.Results.HitLine.RemoteActivate(self,st.Results.Side,SPAC_Impact,st.Results.HitPos);
|
||||
else if ( st.Results.HitType == TRACE_HitWall ) st.Results.HitLine.RemoteActivate(self,st.Results.Side,SPAC_Impact,st.Results.HitPos);
|
||||
}
|
||||
for ( int i=0; i<(5-invoker.firespeed); i++ )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -523,27 +523,12 @@ Class MisterRifle : SWWMWeapon
|
|||
}
|
||||
else if ( d.HitType != TRACE_HitNone )
|
||||
{
|
||||
Vector3 hitnormal = -d.HitDir;
|
||||
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();
|
||||
if ( !d.LineSide ) hitnormal *= -1;
|
||||
}
|
||||
Vector3 hitnormal = SWWMUtility.GetLineTraceHitNormal(d);
|
||||
let p = Spawn("SpreadImpact",d.HitLocation+hitnormal*0.01);
|
||||
p.angle = atan2(hitnormal.y,hitnormal.x);
|
||||
p.pitch = asin(-hitnormal.z);
|
||||
p.target = self;
|
||||
if ( d.HitLine ) d.HitLine.RemoteActivate(self,d.LineSide,SPAC_Impact,d.HitLocation);
|
||||
if ( d.HitType == TRACE_HitWall ) d.HitLine.RemoteActivate(self,d.LineSide,SPAC_Impact,d.HitLocation);
|
||||
let b = Spawn("MisterBuckshotImpact",d.HitLocation+hitnormal*4.);
|
||||
b.angle = atan2(hitnormal.y,hitnormal.x);
|
||||
b.pitch = asin(-hitnormal.z);
|
||||
|
|
@ -590,27 +575,12 @@ Class MisterRifle : SWWMWeapon
|
|||
}
|
||||
else if ( d.HitType != TRACE_HitNone )
|
||||
{
|
||||
Vector3 hitnormal = -d.HitDir;
|
||||
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();
|
||||
if ( !d.LineSide ) hitnormal *= -1;
|
||||
}
|
||||
Vector3 hitnormal = SWWMUtility.GetLineTraceHitNormal(d);
|
||||
let p = Spawn("SWWMBulletImpact",d.HitLocation+hitnormal*0.01);
|
||||
p.angle = atan2(hitnormal.y,hitnormal.x);
|
||||
p.pitch = asin(-hitnormal.z);
|
||||
p.target = self;
|
||||
if ( d.HitLine ) d.HitLine.RemoteActivate(self,d.LineSide,SPAC_Impact,d.HitLocation);
|
||||
if ( d.HitType == TRACE_HitWall ) d.HitLine.RemoteActivate(self,d.LineSide,SPAC_Impact,d.HitLocation);
|
||||
let b = Spawn("MisterBulletImpact",d.HitLocation+hitnormal*4.);
|
||||
b.angle = atan2(hitnormal.y,hitnormal.x);
|
||||
b.pitch = asin(-hitnormal.z);
|
||||
|
|
@ -669,27 +639,12 @@ Class MisterRifle : SWWMWeapon
|
|||
}
|
||||
else if ( d.HitType != TRACE_HitNone )
|
||||
{
|
||||
Vector3 hitnormal = -d.HitDir;
|
||||
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();
|
||||
if ( !d.LineSide ) hitnormal *= -1;
|
||||
}
|
||||
Vector3 hitnormal = SWWMUtility.GetLineTraceHitNormal(d);
|
||||
let p = Spawn("SWWMBulletImpact",d.HitLocation+hitnormal*0.01);
|
||||
p.angle = atan2(hitnormal.y,hitnormal.x);
|
||||
p.pitch = asin(-hitnormal.z);
|
||||
p.target = self;
|
||||
if ( d.HitLine ) d.HitLine.RemoteActivate(self,d.LineSide,SPAC_Impact,d.HitLocation);
|
||||
if ( d.HitType == TRACE_HitWall ) d.HitLine.RemoteActivate(self,d.LineSide,SPAC_Impact,d.HitLocation);
|
||||
let b = Spawn("MisterStreamImpact",d.HitLocation+hitnormal*4.);
|
||||
b.angle = atan2(hitnormal.y,hitnormal.x);
|
||||
b.pitch = asin(-hitnormal.z);
|
||||
|
|
@ -963,22 +918,7 @@ Class MisterRifle : SWWMWeapon
|
|||
}
|
||||
if ( (mrt.Results.HitType != TRACE_HitNone) && (mrt.Results.HitType != TRACE_HasHitSky) && (mrt.Results.HitType != TRACE_HitActor) )
|
||||
{
|
||||
Vector3 hitnormal = -mrt.Results.HitVector;
|
||||
if ( mrt.Results.HitType == TRACE_HitFloor )
|
||||
{
|
||||
if ( mrt.Results.FFloor ) hitnormal = -mrt.Results.FFloor.top.Normal;
|
||||
else hitnormal = mrt.Results.HitSector.floorplane.Normal;
|
||||
}
|
||||
else if ( mrt.Results.HitType == TRACE_HitCeiling )
|
||||
{
|
||||
if ( mrt.Results.FFloor ) hitnormal = -mrt.Results.FFloor.bottom.Normal;
|
||||
else hitnormal = mrt.Results.HitSector.ceilingplane.Normal;
|
||||
}
|
||||
else if ( mrt.Results.HitType == TRACE_HitWall )
|
||||
{
|
||||
hitnormal = (-mrt.Results.HitLine.delta.y,mrt.Results.HitLine.delta.x,0).unit();
|
||||
if ( !mrt.Results.Side ) hitnormal *= -1;
|
||||
}
|
||||
Vector3 hitnormal = SWWMUtility.GetLineTracerHitNormal(mrt.Results);
|
||||
let b = MisterBulletImpact(Spawn("MisterRailEntryImpact",mrt.Results.HitPos+hitnormal*4.));
|
||||
b.angle = atan2(hitnormal.y,hitnormal.x);
|
||||
b.pitch = asin(-hitnormal.z);
|
||||
|
|
|
|||
|
|
@ -233,24 +233,9 @@ Class MisterFuzzy : SWWMNonInteractiveActor
|
|||
double ang = atan2(dir.y,dir.x);
|
||||
double pt = asin(-dir.z);
|
||||
LineTrace(ang,dist,pt,TRF_THRUACTORS|TRF_THRUHITSCAN|TRF_ABSPOSITION,newpos.z,newpos.x,newpos.y,d);
|
||||
Vector3 hitnormal = -d.HitDir;
|
||||
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();
|
||||
if ( !d.LineSide ) hitnormal *= -1;
|
||||
}
|
||||
if ( d.HitType != TRACE_HitNone )
|
||||
{
|
||||
Vector3 hitnormal = SWWMUtility.GetLineTraceHitNormal(d);
|
||||
dist -= d.Distance;
|
||||
// should only happen if we bounced
|
||||
dir = d.HitDir-(FRandom[Puff](1.5,2.)*hitnormal*(d.HitDir dot hitnormal));
|
||||
|
|
@ -1007,45 +992,7 @@ Class MisterGrenade : Actor
|
|||
|
||||
virtual void A_HandleBounce()
|
||||
{
|
||||
Vector3 HitNormal = -vel.unit();
|
||||
F3DFloor ff;
|
||||
if ( BlockingFloor )
|
||||
{
|
||||
// find closest 3d floor for its normal
|
||||
for ( int i=0; i<BlockingFloor.Get3DFloorCount(); i++ )
|
||||
{
|
||||
if ( !(BlockingFloor.Get3DFloor(i).flags&F3DFloor.FF_SOLID) ) continue;
|
||||
if ( !(BlockingFloor.Get3DFloor(i).top.ZAtPoint(pos.xy) ~== floorz) ) continue;
|
||||
ff = BlockingFloor.Get3DFloor(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<BlockingCeiling.Get3DFloorCount(); i++ )
|
||||
{
|
||||
if ( !(BlockingCeiling.Get3DFloor(i).flags&F3DFloor.FF_SOLID) ) continue;
|
||||
if ( !(BlockingCeiling.Get3DFloor(i).bottom.ZAtPoint(pos.xy) ~== ceilingz) ) continue;
|
||||
ff = BlockingCeiling.Get3DFloor(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 ( !SWWMUtility.PointOnLineSide(pos.xy,BlockingLine) )
|
||||
HitNormal *= -1;
|
||||
}
|
||||
else if ( BlockingMobj )
|
||||
{
|
||||
Vector3 diff = level.Vec3Diff(BlockingMobj.Vec3Offset(0,0,BlockingMobj.Height/2),pos);
|
||||
HitNormal = diff.unit();
|
||||
}
|
||||
Vector3 HitNormal = SWWMUtility.GetActorHitNormal(self);
|
||||
// undo the bounce, we need to hook in our own
|
||||
vel = oldvel;
|
||||
// re-do the bounce with our formula
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue