Various improvements, fixes and rebalances that I'm too tired to list through.
This commit is contained in:
parent
1b7a288bf5
commit
a99c38fd75
13 changed files with 260 additions and 74 deletions
|
|
@ -5,14 +5,18 @@ Class UTPlayer : DoomPlayer
|
|||
transient CVar footsteps, utmovement, doomspeed, doomaircontrol, nowalkdrop;
|
||||
Vector2 acceleration;
|
||||
Vector3 acceleration3;
|
||||
int last_fm_tap, last_sm_tap;
|
||||
int last_fm, last_sm;
|
||||
int last_fm_tap, last_sm_tap;
|
||||
int last_tap_fm, last_tap_sm;
|
||||
int last_jump_held;
|
||||
|
||||
const groundspeed = 400.;
|
||||
const accelrate = 2048.;
|
||||
const walkfactor = 0.3;
|
||||
const utaircontrol = 0.35;
|
||||
const groundspeed_doomish = 600.;
|
||||
const fluidfriction = 1.2;
|
||||
const terminalvelocity = 2500.;
|
||||
|
||||
Default
|
||||
{
|
||||
|
|
@ -184,6 +188,7 @@ Class UTPlayer : DoomPlayer
|
|||
bool forcefootstep = false;
|
||||
if ( player.onground && !bNoGravity && !lastground && (waterlevel < 3) )
|
||||
{
|
||||
player.jumptics = 0;
|
||||
if ( lastvelz < -4 )
|
||||
{
|
||||
double vol = clamp((-lastvelz-4)*0.05,0.01,1.0);
|
||||
|
|
@ -240,38 +245,83 @@ Class UTPlayer : DoomPlayer
|
|||
else fs *= max(abs(cmd.forwardmove/12800.),abs(cmd.sidemove/10240.));
|
||||
if ( CanCrouch() && (player.crouchfactor != -1) ) fs *= player.crouchfactor;
|
||||
acceleration = rotatevector((cmd.forwardmove,-cmd.sidemove),angle);
|
||||
Vector2 dodge = (0,0);
|
||||
int fm = cmd.forwardmove;
|
||||
int sm = cmd.sidemove;
|
||||
if ( fm )
|
||||
{
|
||||
int clk = abs(gametic-last_fm_tap);
|
||||
if ( (clk < 8) && (last_fm*fm == 0) && (last_tap_fm*fm>0) )
|
||||
dodge += RotateVector((fm,0),angle).unit();
|
||||
if ( !last_fm && (last_jump_held < gametic-1) )
|
||||
{
|
||||
last_fm_tap = gametic;
|
||||
last_tap_fm = fm;
|
||||
}
|
||||
}
|
||||
last_fm = fm;
|
||||
if ( sm )
|
||||
{
|
||||
int clk = abs(gametic-last_sm_tap);
|
||||
if ( (clk < 8) && (last_sm*sm == 0) && (last_tap_sm*sm>0) )
|
||||
dodge += RotateVector((0,-sm),angle).unit();
|
||||
if ( !last_sm && (last_jump_held < gametic-1) )
|
||||
{
|
||||
last_sm_tap = gametic;
|
||||
last_tap_sm = sm;
|
||||
}
|
||||
}
|
||||
last_sm = sm;
|
||||
if ( player.onground )
|
||||
{
|
||||
if ( nowalkdrop.GetBool() )
|
||||
bNODROPOFF = ((acceleration.length() > double.epsilon) && (cmd.buttons&BT_SPEED));
|
||||
// Hook in Unreal physics
|
||||
Vector2 dir = (0,0);
|
||||
if ( vel.xy.length() > double.epsilon ) dir = vel.xy.unit();
|
||||
if ( acceleration.length() <= double.epsilon )
|
||||
if ( !bNoGravity && !waterlevel && (dodge.length() > 0) )
|
||||
{
|
||||
Vector2 oldvel = vel.xy;
|
||||
vel.xy = vel.xy - (2 * dir) * vel.xy.length() * friction/TICRATE;
|
||||
if ( oldvel dot vel.xy < 0.0 ) vel.xy *= 0;
|
||||
if ( doomspeed.GetBool() ) vel += dodge.unit()*(groundspeed_doomish*1.5)/TICRATE;
|
||||
else vel += dodge.unit()*(groundspeed*1.5)/TICRATE;
|
||||
vel.z += jumpz*0.5;
|
||||
bOnMobj = false;
|
||||
if ( !(player.cheats&CF_PREDICTING) )
|
||||
A_PlaySound("*jump",CHAN_BODY);
|
||||
if ( player.cheats & CF_REVERTPLEASE )
|
||||
{
|
||||
player.cheats &= ~CF_REVERTPLEASE;
|
||||
player.camera = player.mo;
|
||||
}
|
||||
player.vel *= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 acceldir = acceleration.unit();
|
||||
acceleration = acceldir * Min(acceleration.length(), accelrate/TICRATE);
|
||||
vel.xy = vel.xy - (dir - acceldir) * vel.xy.length() * friction/TICRATE;
|
||||
if ( nowalkdrop.GetBool() )
|
||||
bNODROPOFF = ((acceleration.length() > double.epsilon) && (cmd.buttons&BT_SPEED));
|
||||
// Hook in Unreal physics
|
||||
Vector2 dir = (0,0);
|
||||
if ( vel.xy.length() > double.epsilon ) dir = vel.xy.unit();
|
||||
if ( acceleration.length() <= double.epsilon )
|
||||
{
|
||||
Vector2 oldvel = vel.xy;
|
||||
vel.xy = vel.xy - (2 * dir) * vel.xy.length() * friction/TICRATE;
|
||||
if ( oldvel dot vel.xy < 0.0 ) vel.xy *= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 acceldir = acceleration.unit();
|
||||
acceleration = acceldir * Min(acceleration.length(), accelrate/TICRATE);
|
||||
vel.xy = vel.xy - (dir - acceldir) * vel.xy.length() * friction/TICRATE;
|
||||
}
|
||||
vel.xy = vel.xy + acceleration/TICRATE;
|
||||
double maxvel;
|
||||
if ( doomspeed.GetBool() ) maxvel = (groundspeed_doomish*fs)/TICRATE;
|
||||
else maxvel = (groundspeed*fs)/TICRATE;
|
||||
double doomfriction = clamp(GetFriction()/ORIG_FRICTION,0.0,1.0);
|
||||
maxvel *= doomfriction;
|
||||
if ( vel.xy.length() > maxvel ) vel.xy = vel.xy.unit()*maxvel;
|
||||
if ( !(player.cheats & CF_PREDICTING) )
|
||||
{
|
||||
if ( acceleration.length() <= double.epsilon ) PlayIdle();
|
||||
else PlayRunning();
|
||||
}
|
||||
player.vel = vel.xy;
|
||||
}
|
||||
vel.xy = vel.xy + acceleration * (1./TICRATE);
|
||||
double maxvel;
|
||||
if ( doomspeed.GetBool() ) maxvel = (groundspeed_doomish*fs)/TICRATE;
|
||||
else maxvel = (groundspeed*fs)/TICRATE;
|
||||
double doomfriction = clamp(GetFriction()/ORIG_FRICTION,0.0,1.0);
|
||||
maxvel *= doomfriction;
|
||||
if ( vel.xy.length() > maxvel ) vel.xy = vel.xy.unit()*maxvel;
|
||||
if ( !(player.cheats & CF_PREDICTING) )
|
||||
{
|
||||
if ( acceleration.length() <= double.epsilon ) PlayIdle();
|
||||
else PlayRunning();
|
||||
}
|
||||
player.vel = vel.xy;
|
||||
}
|
||||
else if ( !bNoGravity && !waterlevel )
|
||||
{
|
||||
|
|
@ -281,8 +331,23 @@ Class UTPlayer : DoomPlayer
|
|||
maxaccel += (40.-vel.xy.length())/TICRATE;
|
||||
if ( acceleration.length() > maxaccel )
|
||||
acceleration = acceleration.unit()*maxaccel;
|
||||
acceleration *= doomaircontrol.GetBool()?level.aircontrol:0.35;
|
||||
vel.xy += acceleration/TICRATE;
|
||||
Vector2 dir = (0,0);
|
||||
if ( vel.xy.length() > double.epsilon ) dir = vel.xy.unit();
|
||||
if ( acceleration.length() <= double.epsilon )
|
||||
{
|
||||
Vector2 oldvel = vel.xy;
|
||||
vel.xy = vel.xy - (2 * dir) * vel.xy.length() * fluidfriction/TICRATE;
|
||||
if ( oldvel dot vel.xy < 0.0 ) vel.xy *= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 acceldir = acceleration.unit();
|
||||
acceleration = acceldir * Min(acceleration.length(), accelrate/TICRATE);
|
||||
vel.xy = vel.xy - (dir - acceldir) * vel.xy.length() * fluidfriction/TICRATE;
|
||||
}
|
||||
acceleration *= doomaircontrol.GetBool()?level.aircontrol:utaircontrol;
|
||||
vel.xy = vel.xy + acceleration/TICRATE;
|
||||
if ( vel.length() > terminalvelocity/TICRATE ) vel = vel.unit()*(terminalvelocity/TICRATE);
|
||||
player.vel *= 0;
|
||||
}
|
||||
else
|
||||
|
|
@ -327,44 +392,41 @@ Class UTPlayer : DoomPlayer
|
|||
player.camera = player.mo;
|
||||
}
|
||||
}
|
||||
|
||||
override void CheckJump()
|
||||
{
|
||||
if ( !utmovement ) utmovement = CVar.GetCVar('flak_utmovement');
|
||||
if ( !doomspeed ) doomspeed = CVar.GetCVar('flak_doomspeed');
|
||||
if ( utmovement.GetBool() && player.onground && !bNoGravity && !waterlevel && (player.jumptics == 0) && (player.cmd.forwardmove || player.cmd.sidemove) )
|
||||
if ( !utmovement.GetBool() )
|
||||
{
|
||||
int fm = player.cmd.forwardmove;
|
||||
int sm = player.cmd.sidemove;
|
||||
Vector2 dodge = (0,0);
|
||||
if ( fm )
|
||||
Super.CheckJump();
|
||||
return;
|
||||
}
|
||||
if ( player.cmd.buttons&BT_JUMP )
|
||||
{
|
||||
if ( player.crouchoffset ) player.crouching = 1;
|
||||
else if ( waterlevel >= 2 ) Vel.z = 4*Speed;
|
||||
else if ( bNoGravity ) Vel.z = 3.;
|
||||
else if ( level.IsJumpingAllowed() && player.onground && (player.jumpTics == 0) && (last_jump_held < gametic-1) )
|
||||
{
|
||||
int clk = abs(gametic-last_fm_tap);
|
||||
if ( (clk < 5) && (clk > 1) && (last_fm*fm>0) )
|
||||
dodge += RotateVector((fm,0),angle).unit();
|
||||
last_fm_tap = gametic;
|
||||
last_fm = fm;
|
||||
}
|
||||
if ( sm )
|
||||
{
|
||||
int clk = abs(gametic-last_sm_tap);
|
||||
if ( (clk < 5) && (clk > 1) && (last_sm*sm>0) )
|
||||
dodge += RotateVector((0,-sm),angle).unit();
|
||||
last_sm_tap = gametic;
|
||||
last_sm = sm;
|
||||
}
|
||||
if ( dodge.length() > 0 )
|
||||
{
|
||||
if ( doomspeed.GetBool() ) vel += dodge.unit()*(groundspeed_doomish*1.5)/TICRATE;
|
||||
else vel += dodge.unit()*(groundspeed*1.5)/TICRATE;
|
||||
vel.z += jumpz*0.5;
|
||||
double jumpvelz = JumpZ;
|
||||
double jumpfac = 0;
|
||||
for ( let p = Inv; p != null; p = p.Inv )
|
||||
{
|
||||
let pp = PowerHighJump(p);
|
||||
if ( !pp ) continue;
|
||||
double f = pp.Strength;
|
||||
if ( f > jumpfac ) jumpfac = f;
|
||||
}
|
||||
if ( jumpfac > 0 ) jumpvelz *= jumpfac;
|
||||
Vel.z += jumpvelz;
|
||||
bOnMobj = false;
|
||||
player.jumpTics = -1;
|
||||
if ( !(player.cheats&CF_PREDICTING) )
|
||||
A_PlaySound("*jump",CHAN_BODY);
|
||||
}
|
||||
last_jump_held = gametic;
|
||||
}
|
||||
Super.CheckJump();
|
||||
if ( !player.onground || player.jumptics )
|
||||
last_jump_held = gametic;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -388,6 +450,7 @@ Class RandomSpawner2 : RandomSpawner
|
|||
Class UTWeapon : Weapon
|
||||
{
|
||||
int DropAmmo;
|
||||
bool bExtraPickup;
|
||||
|
||||
Property DropAmmo: DropAmmo;
|
||||
|
||||
|
|
@ -434,6 +497,79 @@ Class UTWeapon : Weapon
|
|||
A_ClearRefire();
|
||||
}
|
||||
|
||||
override bool HandlePickup( Inventory item )
|
||||
{
|
||||
if (item.GetClass() == GetClass())
|
||||
{
|
||||
if ( Weapon(item).PickupForAmmo(self) )
|
||||
item.bPickupGood = true;
|
||||
if ( (MaxAmount > 1) || bALWAYSPICKUP )
|
||||
return Inventory.HandlePickup(item);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
override bool ShouldStay()
|
||||
{
|
||||
if ( ((multiplayer && (!deathmatch && !alwaysapplydmflags)) || sv_weaponstay) && !bDropped )
|
||||
return (!bExtraPickup && !bALWAYSPICKUP);
|
||||
return false;
|
||||
}
|
||||
override bool TryPickup( in out Actor toucher )
|
||||
{
|
||||
if ( !bExtraPickup ) bExtraPickup = ((MaxAmount > 1) && (toucher.CountInv(GetClass()) < MaxAmount));
|
||||
return Super.TryPickup(toucher);
|
||||
}
|
||||
|
||||
// Whole chain of function rewrites because of some stupid hardcoded deathmatch ammo multiplier
|
||||
override bool TryPickupRestricted( in out Actor toucher )
|
||||
{
|
||||
if ( ShouldStay() ) return false;
|
||||
bExtraPickup = false;
|
||||
bool gaveSome = !!(NonIdioticAddAmmo(toucher,AmmoType1,AmmoGive1));
|
||||
gaveSome |= !!(NonIdioticAddAmmo(toucher,AmmoType2,AmmoGive2));
|
||||
if ( gaveSome ) GoAwayAndDie();
|
||||
return gaveSome;
|
||||
}
|
||||
override void AttachToOwner( Actor other )
|
||||
{
|
||||
bExtraPickup = false;
|
||||
Inventory.AttachToOwner(other);
|
||||
Ammo1 = NonIdioticAddAmmo(Owner,AmmoType1,AmmoGive1);
|
||||
Ammo2 = NonIdioticAddAmmo(Owner,AmmoType2,AmmoGive2);
|
||||
SisterWeapon = AddWeapon(SisterWeaponType);
|
||||
if ( Owner.player )
|
||||
{
|
||||
if ( !Owner.player.GetNeverSwitch() && !bNo_Auto_Switch )
|
||||
Owner.player.PendingWeapon = self;
|
||||
if ( Owner.player.mo == players[consoleplayer].camera )
|
||||
StatusBar.ReceivedWeapon(self);
|
||||
}
|
||||
GivenAsMorphWeapon = false;
|
||||
}
|
||||
|
||||
// rewrite of AddAmmo without stupid hardcoded 2.5x ammo multiplier
|
||||
protected Ammo NonIdioticAddAmmo( Actor other, Class<Ammo> ammotype, int amount )
|
||||
{
|
||||
if ( !ammotype ) return null;
|
||||
Ammo ammoitem;
|
||||
if ( !bIgnoreSkill ) amount = int(amount*G_SkillPropertyFloat(SKILLP_AmmoFactor));
|
||||
ammoitem = Ammo(other.FindInventory(ammotype));
|
||||
if ( !ammoitem )
|
||||
{
|
||||
ammoitem = Ammo(Spawn(ammotype));
|
||||
ammoitem.Amount = min(amount,ammoitem.MaxAmount);
|
||||
ammoitem.AttachToOwner(other);
|
||||
}
|
||||
else if ( ammoitem.Amount < ammoitem.MaxAmount )
|
||||
{
|
||||
ammoitem.Amount += amount;
|
||||
if ( ammoitem.Amount > ammoitem.MaxAmount )
|
||||
ammoitem.Amount = ammoitem.MaxAmount;
|
||||
}
|
||||
return ammoitem;
|
||||
}
|
||||
|
||||
Default
|
||||
{
|
||||
Weapon.BobStyle "Smooth";
|
||||
|
|
@ -1022,7 +1158,9 @@ Class UTMainHandler : StaticEventHandler
|
|||
|
||||
ui void StartMenu()
|
||||
{
|
||||
int proto = CVar.GetCVar('flak_protomenu',players[consoleplayer]).GetInt();
|
||||
CVar protomenu = CVar.GetCVar('flak_protomenu',players[consoleplayer]);
|
||||
if ( !protomenu ) return; // this can happen
|
||||
int proto = protomenu.GetInt();
|
||||
if ( proto )
|
||||
{
|
||||
tex = TexMan.CheckForTexture("protobg",TexMan.Type_Any);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue