Added Translocator ammo feature from UT2k4.

Prefixed mk_math classes for cross-compat with any other mods that use them.
Fixed incorrect uses of gametic.
Fixed crash caused by incorrect ordering of PendingWeapon checks.
This commit is contained in:
Marisa the Magician 2018-12-17 16:32:15 +01:00
commit 931f89832c
23 changed files with 179 additions and 107 deletions

View file

@ -23,7 +23,7 @@ Class ViewTracer : LineTracer
Class UTHud : BaseStatusBar
{
TextureID AmmoBar, Boxes[4], Keys[5], BigNum[12], Flash, Slots[10], Icons[14], Uses[14], Man[5], Woman[5], WeaponBox;
TextureID AmmoBar, Boxes[4], Keys[5], BigNum[12], Flash, Slots[10], Icons[14], Uses[14], Man[5], Woman[5], WeaponBox, IconTloc2, UseTloc2;
Class<Weapon> IconClasses[14];
double HScale;
Color tintcolor, bgcolor;
@ -148,6 +148,8 @@ Class UTHud : BaseStatusBar
override void Draw( int state, double TicFrac )
{
Super.Draw(state,TicFrac);
if ( IconTloc2.IsNull() ) IconTloc2 = TexMan.CheckForTexture("IconTrn2",TexMan.Type_Any);
if ( UseTLoc2.IsNull() ) UseTloc2 = TexMan.CheckForTexture("UseTrn2",TexMan.Type_Any);
HScale = Screen.GetWidth()/1280.;
switch ( CVar.GetCVar('flak_colorprefs',CPlayer).GetInt() )
{
@ -223,8 +225,18 @@ Class UTHud : BaseStatusBar
{
Color halftint = Color(tintcolor.a,tintcolor.r/2,tintcolor.g/2,tintcolor.b/2);
if ( !(w is IconClasses[i]) ) continue;
if ( use ) UTDrawTintedTex(Uses[i],sx,opacity+7);
else UTDrawTintedTex(Icons[i],sx,opacity,halftint);
if ( use )
{
if ( (i == 11) && flak_transloc2k4 )
UTDrawTintedTex(UseTloc2,sx,opacity+7);
else UTDrawTintedTex(Uses[i],sx,opacity+7);
}
else
{
if ( (i == 11) && flak_transloc2k4 )
UTDrawTintedTex(IconTloc2,sx,opacity+7);
else UTDrawTintedTex(Icons[i],sx,opacity,halftint);
}
return true;
}
return false;
@ -265,11 +277,31 @@ Class UTHud : BaseStatusBar
CurX = showweapons?(Screen.GetWidth()-128*hudsize*HScale):(Screen.GetWidth()*0.5+128*hudsize*HScale);
CurY = Screen.GetHeight()-64*hudsize*HScale;
if ( showweapons && ((weaponsize*hudsize)>=1.0) ) CurY -= 64*hudsize*HScale;
double BaseX = CurX;
double BaseY = CurY;
UTDrawTintedTex(Boxes[0],hudsize);
CurX += 8*hudsize*HScale;
CurY += 14*hudsize*HScale;
DrawColor = WhiteColor;
if ( ammotype1 ) UTDrawBigNum(ammotype1.Amount,hudsize);
if ( ammotype1 )
{
UTDrawBigNum(ammotype1.Amount,hudsize);
let cw = CPlayer.ReadyWeapon;
if ( flak_transloc2k4 && (cw is 'Translocator') )
{
// draw ammo charge bar
double ch = Translocator(cw).ammocharge;
CurX = BaseX+6*hudsize*HScale;
CurY = BaseY+53*hudsize*HScale;
Vector2 ss = (0.54,0.3)*hudsize*HScale;
double dw = (Screen.GetWidth()/ss.x), dh = (Screen.GetHeight()/ss.y);
double dx = CurX/ss.x, dy = CurY/ss.y;
Vector2 bs = TexMan.GetScaledSize(AmmoBar);
double ddw = bs.x*ch;
double alpha = clamp((opacity+7)/15.,0.0,1.0);
Screen.DrawTexture(AmmoBar,false,dx,dy,DTA_VirtualWidthF,dw,DTA_VirtualHeightF,dh,DTA_KeepRatio,true,DTA_WindowRightF,ddw,DTA_Alpha,alpha);
}
}
if ( ammotype2 && (ammotype2 != ammotype1) )
{
CurX = showweapons?(Screen.GetWidth()-128*hudsize*HScale):((Screen.GetWidth()+256*hudsize*HScale)*0.5);
@ -352,7 +384,7 @@ Class UTHud : BaseStatusBar
if ( CPlayer.mo.Health < CPlayer.mo.SpawnHealth()/2 )
{
Color blinkcolor;
double blinky = ((gametic+fractic)/Thinker.TICRATE)*1.5;
double blinky = ((level.time+fractic)/Thinker.TICRATE)*1.5;
blinky = blinky-floor(blinky);
blinkcolor = LerpColor(tintcolor,WhiteColor,blinky);
UTDrawTintedTex(Boxes[2],hudsize,-1,blinkcolor);
@ -378,8 +410,6 @@ Class UTHud : BaseStatusBar
double WeaponOffset = 128*WeapScale;
let cw = CPlayer.ReadyWeapon;
int cwslot = -1;
let pw = CPlayer.PendingWeapon;
int pwslot = -1;
if ( cw && (cw.SlotNumber != -1) )
{
cwslot = cw.SlotNumber?(cw.SlotNumber-1):9;
@ -389,7 +419,9 @@ Class UTHud : BaseStatusBar
CurX = BaseX+cwslot*WeaponOffset;
CurY = BaseY;
}
if ( pw && (pw.SlotNumber != -1) && (pw != WP_NOCHANGE) )
let pw = CPlayer.PendingWeapon;
int pwslot = -1;
if ( pw && (pw != WP_NOCHANGE) && (pw.SlotNumber != -1) )
{
pwslot = pw.SlotNumber?(pw.SlotNumber-1):9;
CurX = BaseX+pwslot*WeaponOffset-64*WeapScale;
@ -468,7 +500,7 @@ Class UTHud : BaseStatusBar
CurY = Screen.GetHeight()-64*hudsize*HScale;
if ( showweapons && ((weaponsize*hudsize)>=1.0) ) CurY -= 64*hudsize*HScale;
DrawColor = tintcolor;
double whiten = ((gametic+fractic)-lastfrag)/Thinker.TICRATE;
double whiten = ((level.time+fractic)-lastfrag)/Thinker.TICRATE;
if ( whiten < 3.0 )
{
if ( tintcolor == GoldColor )
@ -490,7 +522,7 @@ Class UTHud : BaseStatusBar
}
private void DrawIdentifyInfo()
{
double lalpha = 2.0-((gametic+fractic)-lastseentic)/Thinker.TICRATE;
double lalpha = 2.0-((level.time+fractic)-lastseentic)/Thinker.TICRATE;
if ( !lastseen || (lalpha <= 0) ) return;
String cl1 = "Teal", cl2 = "Cyan";
if ( deathmatch && (lastseen.player.GetTeam() < teams.size()) )
@ -564,19 +596,19 @@ Class UTHud : BaseStatusBar
Super.Tick();
if ( deathmatch||teamplay )
{
if ( CPlayer.fragcount != lastfragcnt ) lastfrag = gametic;
if ( CPlayer.fragcount != lastfragcnt ) lastfrag = level.time;
lastfragcnt = CPlayer.fragcount;
}
else
{
if ( CPlayer.killcount != lastfragcnt ) lastfrag = gametic;
if ( CPlayer.killcount != lastfragcnt ) lastfrag = level.time;
lastfragcnt = CPlayer.killcount;
}
vtracer.ignore = CPlayer.mo;
vtracer.trace(CPlayer.mo.Vec2OffsetZ(0,0,CPlayer.viewz),CPlayer.mo.CurSector,(cos(CPlayer.mo.angle)*cos(CPlayer.mo.pitch),sin(CPlayer.mo.angle)*cos(CPlayer.mo.pitch),-sin(CPlayer.mo.pitch)),1000,0);
if ( vtracer.Results.HitType != TRACE_HitActor ) return;
lastseen = vtracer.Results.HitActor;
lastseentic = gametic;
lastseentic = level.time;
}
private void DrawUTHUD()