1.3 update, cleaning up and GZDoom 4.11 features.

This commit is contained in:
Marisa the Magician 2023-08-25 23:45:52 +02:00
commit ac4c53b3ef
21 changed files with 279 additions and 351 deletions

View file

@ -83,6 +83,9 @@ Class UTPlayer : DoomPlayer
VOICE_Boss
};
double bobtime, oldbobtime, oldbob;
Vector3 oldwalkbob, walkbob;
const groundspeed = 400.;
const swimspeed = 200.;
const baseaccelrate = 2048.;
@ -353,87 +356,97 @@ Class UTPlayer : DoomPlayer
return 734.2969*fin*fin-1485.0868*fin+750.7899;
}
virtual clearscope Vector3 GetWeaponBob( double ticfrac )
{
Vector3 bob = (oldwalkbob*(1.-ticfrac)+walkbob*ticfrac);
double bobdamping = .95;
if ( player.ReadyWeapon is 'UTWeapon' )
bobdamping = UTWeapon(player.ReadyWeapon).bobdamping;
Vector3 weaponbob = bobdamping*bob;
return weaponbob;
}
override Vector3, Vector3 BobWeapon3D( double ticfrac )
{
Quat r = Quat.FromAngles(angle,pitch,roll);
r.xyz = -r.xyz;
Vector3 bob = r*GetWeaponBob(ticfrac);
return (bob.y,bob.z,bob.x), (0,0,0);
}
// we can't reproduce this 1:1 with unreal due to some math quirks between engines
virtual void CheckBob( double bob )
{
oldbobtime = bobtime;
double vel2d = vel.xy.length();
Vector3 x, y, z;
[x, y, z] = dt_Utility.GetPlayerAxes(self);
if ( vel2d < .25 ) bobtime += .2/GameTicRate;
else bobtime += (.3+.7*(vel2d/5.))/GameTicRate;
oldwalkbob = walkbob;
walkbob = y*sin(bobtime*180.)*bob*.2;
walkbob.z = sin(bobtime*360.)*bob*.15;
walkbob *= clamp(viewbob,0.,1.5);
SetViewPos(walkbob,VPSF_ABSOLUTEOFFSET);
}
override void CalcHeight()
{
if ( !flak_utmovement || !player || (player.mo != self) )
if ( !player || (player.mo != self) )
{
Super.CalcHeight();
return;
}
double angle, bob;
bool still = false;
// no bobbing while:
// - using noclip2 (equivalent to unreal's ghost cheat)
// - flying
// - swimming
// - falling
if ( !bNoGravity && player.onground && (waterlevel < 2) )
{
player.bob = player.Vel dot player.Vel;
if ( player.bob == 0 ) still = true;
else
{
player.bob *= player.GetMoveBob();
if ( player.bob > MAXBOB ) player.bob = MAXBOB;
}
}
double defviewh = viewheight+player.crouchviewdelta;
oldbob = player.bob;
if ( bFlyCheat || (player.cheats&CF_NOCLIP2) )
player.bob = 0.;
else
{
// this still doesn't help because fly bob is hardcoded
player.bob = 0;
}
double defaultviewheight = ViewHeight+player.crouchviewdelta;
player.bob = min((player.vel dot player.vel)*player.GetMoveBob(),MAXBOB);
if ( player.cheats&CF_NOVELOCITY )
{
player.viewz = pos.z+defaultviewheight;
if ( player.viewz > ceilingz-4 ) player.viewz = ceilingz-4;
player.viewz = pos.z+defviewh;
if ( player.viewz > ceilingz-4 )
player.viewz = ceilingz-4;
oldwalkbob = walkbob = (0,0,0);
SetViewPos((0,0,0),VPSF_ABSOLUTEOFFSET);
return;
}
if ( still )
{
if ( player.health > 0 )
{
angle = Level.maptime/(120*TICRATE/35.)*360.;
bob = player.GetStillBob()*sin(angle);
}
else bob = 0;
}
else
{
angle = Level.maptime/(20*TICRATE/35.)*360.;
bob = player.bob*sin(angle)*((waterlevel>1)?0.25:0.5);
}
// move viewheight
// adjust viewheight
if ( player.playerstate == PST_LIVE )
{
player.viewheight += player.deltaviewheight;
if ( player.viewheight > defaultviewheight )
if ( player.viewheight > defviewh )
{
player.viewheight = defaultviewheight;
player.deltaviewheight = 0;
player.viewheight = defviewh;
player.deltaviewheight = 0.;
}
else if ( player.viewheight < (defaultviewheight/2) )
else if ( player.viewheight < (defviewh/2.) )
{
player.viewheight = defaultviewheight/2;
if ( player.deltaviewheight <= 0 )
player.deltaviewheight = 1/65536.;
player.viewheight = defviewh/2.;
if ( player.deltaviewheight <= 0. )
player.deltaviewheight = 1./65536.;
}
if ( player.deltaviewheight )
{
player.deltaviewheight += 0.25;
player.deltaviewheight += .25;
if ( !player.deltaviewheight )
player.deltaviewheight = 1/65536.;
player.deltaviewheight = 1./65536.;
}
}
if ( player.morphTics ) bob = 0;
player.viewz = pos.z+player.viewheight+(bob*clamp(ViewBob,0.,1.5)); // [SP] Allow DECORATE changes to view bobbing speed.
// apply bobbing
CheckBob(player.morphtics?0.:player.bob);
// set up viewz
player.viewz = pos.z+player.viewheight;
// handle smooth step down (hacky but looks ok)
player.viewz += ssup;
ssup = max(0,(ssup*0.7)-0.25);
ssup = max(0,(ssup*.7)-.25);
if ( floorclip && (player.playerstate != PST_DEAD) && (pos.z <= floorz) )
player.viewz -= Floorclip;
if ( player.viewz > ceilingz-4 ) player.viewz = ceilingz-4;
if ( player.viewz < floorz+4 ) player.viewz = floorz+4;
player.viewz -= floorclip;
if ( player.viewz > ceilingz-4 )
player.viewz = ceilingz-4;
if ( player.viewz < floorz+4 )
player.viewz = floorz+4;
}
override void MovePlayer()
@ -533,7 +546,7 @@ Class UTPlayer : DoomPlayer
player.cheats &= ~CF_REVERTPLEASE;
player.camera = player.mo;
}
player.vel *= 0;
player.vel *= .8;
player.jumptics = -2;
}
else
@ -569,8 +582,8 @@ Class UTPlayer : DoomPlayer
if ( acceleration.length() <= double.epsilon ) PlayIdle();
else PlayRunning();
}
if ( tempslide ) player.vel *= 0;
else player.vel = vel.xy;
if ( tempslide ) player.vel *= .8;
else player.vel = player.vel*.8+vel.xy*.2;
}
}
else if ( !bNoGravity && (waterlevel < 1) )
@ -600,7 +613,7 @@ Class UTPlayer : DoomPlayer
}
else vel.xy = vel.xy+acceleration/TICRATE;
if ( vel.length() > terminalvelocity/TICRATE ) vel = vel.unit()*(terminalvelocity/TICRATE);
player.vel *= 0;
player.vel *= .8;
player.jumptics = -2;
if ( !(player.cheats & CF_PREDICTING) ) PlayIdle();
}
@ -627,7 +640,7 @@ Class UTPlayer : DoomPlayer
else maxvel = groundspeed/TICRATE;
maxvel *= fs;
if ( vel.length() > maxvel ) vel = vel.unit()*maxvel;
player.vel *= 0;
player.vel *= .8;
player.jumptics = -2;
if ( !(player.cheats & CF_PREDICTING) ) PlayIdle();
}
@ -669,7 +682,7 @@ Class UTPlayer : DoomPlayer
}
maxvel *= fs*doomfriction;
if ( vel.length() > maxvel ) vel = vel.unit()*maxvel;
player.vel = vel.xy;
player.vel = player.vel*.8+vel.xy*.2;
player.jumptics = -2;
if ( !(player.cheats & CF_PREDICTING) )
{
@ -1877,9 +1890,11 @@ Class UTWeapon : Weapon
bool bExtraPickup;
transient int lastnoammotic;
Color NameColor;
double bobdamping;
Property DropAmmo: DropAmmo;
Property NameColor: NameColor;
Property BobDamping: BobDamping;
// Drawstuffs under HUD
virtual ui void PreRender( double lbottom ) {}
@ -2025,7 +2040,7 @@ Class UTWeapon : Weapon
Vector2 hofs = RotateVector((dropper.radius,0),dropper.angle);
SetOrigin(dropper.Vec3Offset(hofs.x,hofs.y,dropper.height*0.5),false);
Vector3 x, y, z;
[x, y, z] = dt_Utility.GetAxes(dropper.angle,dropper.pitch,dropper.roll);
[x, y, z] = dt_Utility.GetPlayerAxes(dropper);
vel = x*12.0;
vel.z += 4.0;
angle = dropper.angle;
@ -2056,6 +2071,7 @@ Class UTWeapon : Weapon
Weapon.BobRangeY 0.4;
Weapon.YAdjust 0;
UTWeapon.NameColor "FF FF FF";
UTWeapon.BobDamping .96;
+WEAPON.NOALERT;
}
}
@ -2214,9 +2230,7 @@ Class UTViewSpark : UTSpark
Destroy();
return;
}
Vector3 x, y, z;
[x, y, z] = dt_Utility.GetAxes(target.angle,target.pitch,target.roll);
Vector3 origin = level.Vec3Offset(target.Vec2OffsetZ(0,0,target.player.viewz),x*ofs.x+y*ofs.y+z*ofs.z);
Vector3 origin = dt_Utility.GetFireOffset(target,ofs.x,ofs.y,ofs.z);
SetOrigin(origin,true);
bInvisible = (players[consoleplayer].camera != target);
if ( isFrozen() ) return;
@ -2461,9 +2475,7 @@ Class UTViewSmoke : UTSmoke
Destroy();
return;
}
Vector3 x, y, z;
[x, y, z] = dt_Utility.GetAxes(target.angle,target.pitch,target.roll);
Vector3 origin = level.Vec3Offset(target.Vec2OffsetZ(0,0,target.player.viewz),x*ofs.x+y*ofs.y+z*ofs.z);
Vector3 origin = dt_Utility.GetFireOffset(target,ofs.x,ofs.y,ofs.z);
SetOrigin(origin,true);
bInvisible = (players[consoleplayer].camera != target);
if ( isFrozen() ) return;