Minimap zoom implemented.
Minimap now shows solid/shootable things. Newly visible things in minimap now fade in smoothly. Other small tweaks to minimap.
This commit is contained in:
parent
c517d7404e
commit
e0ad73305e
9 changed files with 94 additions and 45 deletions
|
|
@ -101,6 +101,7 @@ nosave int swwm_numcolor_hp = 7; // font color for health numbers (default: blu
|
|||
nosave int swwm_numcolor_ap = 3; // font color for armor numbers (default: green)
|
||||
server int swwm_drlaskill = 3; // [DRLA Monsters] skill setting for monster spawns
|
||||
nosave bool swwm_showminimap = false; // show a minimap below the score counter
|
||||
nosave noarchive float swwm_minimapzoom = 1; // zoom level of minimap
|
||||
|
||||
server noarchive bool swwm_iseriouslywanttoplaythiswithbd = false; // self-explanatory
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ addmenukey "$SWWM_GESTURE2" "netevent swwmgesture 1"
|
|||
addmenukey "$SWWM_GESTURE3" "netevent swwmgesture 2"
|
||||
addmenukey "$SWWM_GESTURE4" "netevent swwmgesture 3"
|
||||
addmenukey "$SWWM_KBASE" "event swwmdemomenu"
|
||||
addmenukey "$SWWM_MINIMAPIN" "event swwmzoomin"
|
||||
addmenukey "$SWWM_MINIMAPOUT" "event swwmzoomout"
|
||||
defaultbind "mouse1" "+attack"
|
||||
defaultbind "mouse2" "+altattack"
|
||||
defaultbind "r" "+reload"
|
||||
|
|
@ -25,3 +27,5 @@ defaultbind "j" "netevent swwmgesture 1"
|
|||
defaultbind "k" "netevent swwmgesture 2"
|
||||
defaultbind "l" "netevent swwmgesture 3"
|
||||
defaultbind "q" "event swwmdemomenu"
|
||||
defaultbind "kp+" "event swwmzoomin"
|
||||
defaultbind "kp-" "event swwmzoomout"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ SWWM_GESTURE2 = "Thumbs Up";
|
|||
SWWM_GESTURE3 = "Victory";
|
||||
SWWM_GESTURE4 = "Blow Kiss";
|
||||
SWWM_KBASE = "Demolitionist Menu";
|
||||
SWWM_MINIMAPIN = "Minimap Zoom In";
|
||||
SWWM_MINIMAPOUT = "Minimap Zoom Out";
|
||||
// skills
|
||||
SWWM_SKCHILL = "\cdJust Chillin'\c-";
|
||||
SWWM_SKEASY = "\ckTaking It Easy~\c-";
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ SWWM_GESTURE2 = "Pulgar Arriba";
|
|||
SWWM_GESTURE3 = "Victoria";
|
||||
SWWM_GESTURE4 = "Soplar Beso";
|
||||
SWWM_KBASE = "Menú de Demolicionista";
|
||||
SWWM_MINIMAPIN = "Acercar Zoom de Minimapa";
|
||||
SWWM_MINIMAPOUT = "Alejar Zoom de Minimapa";
|
||||
// skills
|
||||
SWWM_SKCHILL = "\cdDe Relax\c-";
|
||||
SWWM_SKEASY = "\ckCon Calmita~\c-";
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
[default]
|
||||
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r297 \cu(Mon 22 Feb 00:58:07 CET 2021)\c-";
|
||||
SWWM_SHORTVER="\cw0.9.11b-pre r297 \cu(2021-02-22 00:58:07)\c-";
|
||||
SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.11b-pre r298 \cu(Mon 22 Feb 12:49:57 CET 2021)\c-";
|
||||
SWWM_SHORTVER="\cw0.9.11b-pre r298 \cu(2021-02-22 12:49:57)\c-";
|
||||
|
|
|
|||
|
|
@ -1417,21 +1417,22 @@ Class SWWMHandler : EventHandler
|
|||
}
|
||||
// update trackers for anything around the player
|
||||
bool thesight = players[consoleplayer].mo.FindInventory("Omnisight");
|
||||
BlockThingsIterator bt = BlockThingsIterator.Create(players[consoleplayer].Camera,SWWMStatusBar.MAPVIEWDIST);
|
||||
double viewdist = SWWMStatusBar.MAPVIEWDIST*swwm_minimapzoom;
|
||||
BlockThingsIterator bt = BlockThingsIterator.Create(players[consoleplayer].Camera,viewdist);
|
||||
while ( bt.Next() )
|
||||
{
|
||||
let a = bt.Thing;
|
||||
if ( !a ) continue;
|
||||
Vector2 rv = a.pos.xy-players[consoleplayer].Camera.pos.xy;
|
||||
if ( max(abs(rv.x)-a.radius,abs(rv.y)-a.radius) > SWWMStatusBar.MAPVIEWDIST )
|
||||
if ( max(abs(rv.x)-a.radius,abs(rv.y)-a.radius) > viewdist )
|
||||
continue;
|
||||
if ( a == players[consoleplayer].Camera )
|
||||
continue;
|
||||
if ( !a.player && !a.bISMONSTER && !a.bFRIENDLY && !(a is 'Inventory') && !(a is 'Chancebox') )
|
||||
if ( !a.player && !a.bSOLID && !a.bSHOOTABLE && !a.bISMONSTER && !a.bFRIENDLY && !(a is 'Inventory') && !(a is 'Chancebox') )
|
||||
continue;
|
||||
if ( !thesight && !a.IsFriend(players[consoleplayer].mo) && !players[consoleplayer].Camera.CheckSight(a,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) )
|
||||
continue;
|
||||
if ( a.bKILLED )
|
||||
if ( a.bKILLED || (a.Health <= 0) )
|
||||
continue;
|
||||
if ( (a is 'Inventory') && (!a.bSPECIAL || Inventory(a).Owner) )
|
||||
continue;
|
||||
|
|
@ -1439,21 +1440,24 @@ Class SWWMHandler : EventHandler
|
|||
continue;
|
||||
SWWMSimpleTracker.Track(a);
|
||||
}
|
||||
// prune expired trackers
|
||||
SWWMSimpleTracker trk = strackers;
|
||||
while ( trk )
|
||||
{
|
||||
SWWMSimpleTracker next = trk.next;
|
||||
// reduce sight counter
|
||||
if ( trk.lastupdate < level.maptime )
|
||||
trk.sightcount = max(0,trk.sightcount-1);
|
||||
// minimize lifespan of destroyed targets
|
||||
if ( !trk.target ) trk.lastupdate = min(trk.lastupdate,level.maptime);
|
||||
else if ( !trk.expired )
|
||||
{
|
||||
// "last breath" update
|
||||
if ( trk.target.bKILLED
|
||||
if ( (trk.target.bKILLED || (trk.target.Health <= 0))
|
||||
|| ((trk.target is 'Inventory') && (!trk.target.bSPECIAL || Inventory(trk.target).Owner))
|
||||
|| ((trk.target is 'Chancebox') && (trk.target.CurState != trk.target.SpawnState)) )
|
||||
trk.Update();
|
||||
}
|
||||
// prune expired trackers
|
||||
if ( trk.lastupdate+140 < level.maptime )
|
||||
{
|
||||
if ( !trk.prev ) strackers = trk.next;
|
||||
|
|
@ -3106,6 +3110,21 @@ Class SWWMHandler : EventHandler
|
|||
return;
|
||||
Menu.SetMenu('DemolitionistMenu');
|
||||
}
|
||||
else if ( e.Name ~== "swwmzoomin" )
|
||||
{
|
||||
if ( (gamestate != GS_LEVEL) || (players[consoleplayer].Health <= 0) || !(players[consoleplayer].mo is 'Demolitionist') )
|
||||
return;
|
||||
double val = max(.5,swwm_minimapzoom/2.);
|
||||
CVar.FindCVar('swwm_minimapzoom').SetFloat(val);
|
||||
}
|
||||
else if ( e.Name ~== "swwmzoomout" )
|
||||
{
|
||||
if ( (gamestate != GS_LEVEL) || (players[consoleplayer].Health <= 0) || !(players[consoleplayer].mo is 'Demolitionist') )
|
||||
return;
|
||||
double maxval = players[consoleplayer].mo.FindInventory("Omnisight")?2.:1.;
|
||||
double val = min(maxval,swwm_minimapzoom*2.);
|
||||
CVar.FindCVar('swwm_minimapzoom').SetFloat(val);
|
||||
}
|
||||
}
|
||||
|
||||
override void NetworkProcess( ConsoleEvent e )
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
|
||||
bool koraxhack;
|
||||
|
||||
double minimapzoom, oldminimapzoom;
|
||||
// minimap constants
|
||||
const CLIPDIST = 800; // clip distance for minimap view, with rotation accounted
|
||||
const MAPVIEWDIST = 1132; // maximum distance for something to be considered visible (rounded up CLIPDIST*sqrt(2))
|
||||
|
|
@ -416,6 +417,15 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
if ( CPlayer.ReadyWeapon is 'SWWMWeapon' )
|
||||
SWWMWeapon(CPlayer.ReadyWeapon).HudTick();
|
||||
bool thesight = CPlayer.mo.FindInventory("Omnisight");
|
||||
double desiredzoom = clamp(swwm_minimapzoom,.5,thesight?2.:1.);
|
||||
if ( (minimapzoom != swwm_minimapzoom) || (oldminimapzoom != swwm_minimapzoom) )
|
||||
{
|
||||
oldminimapzoom = minimapzoom;
|
||||
double diff = .1*(desiredzoom-minimapzoom);
|
||||
minimapzoom += diff;
|
||||
if ( abs(minimapzoom-desiredzoom) <= double.epsilon )
|
||||
minimapzoom = desiredzoom;
|
||||
}
|
||||
let cam = players[consoleplayer].camera;
|
||||
Vector3 viewvec = (cos(viewrot.x)*cos(viewrot.y),sin(viewrot.x)*cos(viewrot.y),sin(-viewrot.y));
|
||||
int sz;
|
||||
|
|
@ -616,6 +626,7 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
GenericAmmoTex[1] = TexMan.CheckForTexture("graphics/HUD/GenericAmmoBoxM.png",TexMan.Type_Any);
|
||||
GenericAmmoTex[2] = TexMan.CheckForTexture("graphics/HUD/GenericAmmoBoxR.png",TexMan.Type_Any);
|
||||
MiniBox = TexMan.CheckForTexture("graphics/HUD/MinimapBox.png",TexMan.Type_Any);
|
||||
minimapzoom = oldminimapzoom = 1.;
|
||||
mTewiFont = HUDFont.Create("TewiShaded");
|
||||
mMiniwiFont = HUDFont.Create("MiniwiShaded");
|
||||
mMPlusFont = HUDFont.Create("MPlusShaded");
|
||||
|
|
@ -942,6 +953,8 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
|
||||
private void DrawMapLines( Vector2 basepos )
|
||||
{
|
||||
double zoomlevel = oldminimapzoom*(1.-FracTic)+minimapzoom*FracTic;
|
||||
double zoomview = MAPVIEWDIST*zoomlevel, zoomclip = CLIPDIST*zoomlevel;
|
||||
Vector2 cpos = CPlayer.Camera.prev.xy*(1.-FracTic)+CPlayer.Camera.pos.xy*FracTic;
|
||||
for ( int i=0; i<level.lines.Size(); i++ )
|
||||
{
|
||||
|
|
@ -950,7 +963,7 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
if ( (l.flags&Line.ML_DONTDRAW) && ((am_cheat == 0) || (am_cheat >= 4)) )
|
||||
continue;
|
||||
Vector2 rv1 = l.v1.p-cpos, rv2 = l.v2.p-cpos;
|
||||
if ( min(min(abs(rv1.x),abs(rv2.x)),min(abs(rv1.y),abs(rv2.y))) > MAPVIEWDIST )
|
||||
if ( min(min(abs(rv1.x),abs(rv2.x)),min(abs(rv1.y),abs(rv2.y))) > zoomview )
|
||||
continue;
|
||||
// flip Y
|
||||
rv1.y *= -1;
|
||||
|
|
@ -960,11 +973,11 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
rv2 = Actor.RotateVector(rv2,ViewRot.x-90);
|
||||
// clip to frame
|
||||
bool visible;
|
||||
[visible, rv1, rv2] = SWWMUtility.LiangBarsky((-1,-1)*CLIPDIST,(1,1)*CLIPDIST,rv1,rv2);
|
||||
[visible, rv1, rv2] = SWWMUtility.LiangBarsky((-1,-1)*zoomclip,(1,1)*zoomclip,rv1,rv2);
|
||||
if ( !visible ) continue;
|
||||
// scale to minimap frame
|
||||
rv1 *= (HALFMAPSIZE/double(CLIPDIST))*hs.x;
|
||||
rv2 *= (HALFMAPSIZE/double(CLIPDIST))*hs.x;
|
||||
rv1 *= (HALFMAPSIZE/zoomclip)*hs.x;
|
||||
rv2 *= (HALFMAPSIZE/zoomclip)*hs.x;
|
||||
// offset to minimap center
|
||||
rv1 += basepos;
|
||||
rv2 += basepos;
|
||||
|
|
@ -1018,11 +1031,14 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
private void DrawMapThings( Vector2 basepos )
|
||||
{
|
||||
bool thesight = !!CPlayer.mo.FindInventory("Omnisight");
|
||||
double zoomlevel = oldminimapzoom*(1.-FracTic)+minimapzoom*FracTic;
|
||||
double zoomview = MAPVIEWDIST*zoomlevel, zoomclip = CLIPDIST*zoomlevel;
|
||||
Vector2 cpos = CPlayer.Camera.prev.xy*(1.-FracTic)+CPlayer.Camera.pos.xy*FracTic;
|
||||
for ( SWWMSimpleTracker t=hnd.strackers; t; t=t.next )
|
||||
{
|
||||
Color col = am_thingcolor;
|
||||
bool isitem = false;
|
||||
bool plainactor = false;
|
||||
Vector2 pos;
|
||||
double angle;
|
||||
double radius;
|
||||
|
|
@ -1042,6 +1058,7 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
else if ( t.target.bFRIENDLY ) col = am_thingcolor_friend;
|
||||
else if ( t.target.bCOUNTKILL ) col = am_thingcolor_monster;
|
||||
else if ( t.target.bISMONSTER ) col = am_thingcolor_ncmonster;
|
||||
else plainactor = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1059,25 +1076,39 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
else if ( t.friendly ) col = am_thingcolor_friend;
|
||||
else if ( t.countkill ) col = am_thingcolor_monster;
|
||||
else if ( t.ismonster ) col = am_thingcolor_ncmonster;
|
||||
else plainactor = true;
|
||||
}
|
||||
int mtime = 35;
|
||||
if ( thesight && !t.expired && t.target ) mtime += 105;
|
||||
double alph = clamp(((t.lastupdate+mtime)-level.maptime)/35.,0.,1.);
|
||||
alph *= min(1.,t.sightcount/10.);
|
||||
if ( alph <= 0. ) continue;
|
||||
Vector2 rv = pos-cpos;
|
||||
if ( min(abs(rv.x)-radius,abs(rv.y)-radius) > MAPVIEWDIST ) continue;
|
||||
// get actor triangle
|
||||
if ( min(abs(rv.x)-radius,abs(rv.y)-radius) > zoomview )
|
||||
continue;
|
||||
Vector2 tv[4];
|
||||
int nidx = isitem?4:3;
|
||||
int nidx;
|
||||
if ( isitem )
|
||||
{
|
||||
tv[0] = rv+(-10,-10);
|
||||
tv[1] = rv+(10,10);
|
||||
tv[2] = rv+(10,-10);
|
||||
tv[3] = rv+(-10,10);
|
||||
// rhombus
|
||||
nidx = 4;
|
||||
double crad = min(radius,10);
|
||||
for ( int i=0; i<4; i++ )
|
||||
tv[i] = rv+Actor.RotateVector((crad,0),i*90);
|
||||
}
|
||||
else if ( plainactor )
|
||||
{
|
||||
// aabb box
|
||||
nidx = 4;
|
||||
tv[0] = rv+(-radius,-radius);
|
||||
tv[1] = rv+(radius,-radius);
|
||||
tv[2] = rv+(radius,radius);
|
||||
tv[3] = rv+(-radius,radius);
|
||||
}
|
||||
else
|
||||
{
|
||||
// oriented triangle
|
||||
nidx = 3;
|
||||
tv[0] = rv+Actor.RotateVector((radius,0),angle);
|
||||
tv[1] = rv+Actor.RotateVector((-radius,radius),angle);
|
||||
tv[2] = rv+Actor.RotateVector((-radius,-radius),angle);
|
||||
|
|
@ -1089,29 +1120,14 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
bool visible;
|
||||
Vector2 x0, x1;
|
||||
// clip to frame
|
||||
if ( isitem ) for ( int j=0; j<4; j+=2 )
|
||||
for ( int j=0; j<nidx; j++ )
|
||||
{
|
||||
[visible, x0, x1] = SWWMUtility.LiangBarsky((-1,-1)*CLIPDIST,(1,1)*CLIPDIST,tv[j],tv[j+1]);
|
||||
[visible, x0, x1] = SWWMUtility.LiangBarsky((-1,-1)*zoomclip,(1,1)*zoomclip,tv[j],tv[(j+1)%nidx]);
|
||||
if ( visible )
|
||||
{
|
||||
// scale to minimap frame
|
||||
x0 *= (HALFMAPSIZE/double(CLIPDIST))*hs.x;
|
||||
x1 *= (HALFMAPSIZE/double(CLIPDIST))*hs.x;
|
||||
// offset to minimap center
|
||||
x0 += basepos;
|
||||
x1 += basepos;
|
||||
// draw the line
|
||||
Screen.DrawThickLine(int(x0.x),int(x0.y),int(x1.x),int(x1.y),max(1.,hs.x*.5),col,int(alph*255));
|
||||
}
|
||||
}
|
||||
else for ( int j=0; j<3; j++ )
|
||||
{
|
||||
[visible, x0, x1] = SWWMUtility.LiangBarsky((-1,-1)*CLIPDIST,(1,1)*CLIPDIST,tv[j],tv[(j+1)%3]);
|
||||
if ( visible )
|
||||
{
|
||||
// scale to minimap frame
|
||||
x0 *= (HALFMAPSIZE/double(CLIPDIST))*hs.x;
|
||||
x1 *= (HALFMAPSIZE/double(CLIPDIST))*hs.x;
|
||||
x0 *= (HALFMAPSIZE/zoomclip)*hs.x;
|
||||
x1 *= (HALFMAPSIZE/zoomclip)*hs.x;
|
||||
// offset to minimap center
|
||||
x0 += basepos;
|
||||
x1 += basepos;
|
||||
|
|
@ -1142,9 +1158,10 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
// obviously, don't draw the minimap if the automap is open
|
||||
if ( !automapactive && swwm_showminimap )
|
||||
{
|
||||
xx = int(ss.x-(margin+84));
|
||||
xx = int(ss.x-(margin+(HALFMAPSIZE+2)*2));
|
||||
Screen.DrawTexture(MiniBox,false,xx,yy,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
|
||||
Vector2 basemappos = (xx+42,yy+42);
|
||||
Vector2 basemappos = (xx+HALFMAPSIZE+2,yy+HALFMAPSIZE+2);
|
||||
Screen.Dim(am_backcolor,.5,int((basemappos.x-HALFMAPSIZE)*hs.x),int((basemappos.y-HALFMAPSIZE)*hs.x),int(HALFMAPSIZE*2*hs.x),int(HALFMAPSIZE*2*hs.x));
|
||||
// draw dat stuff
|
||||
DrawMapLines(basemappos*hs.x);
|
||||
DrawMapThings(basemappos*hs.x);
|
||||
|
|
@ -1157,7 +1174,7 @@ Class SWWMStatusBar : BaseStatusBar
|
|||
Screen.DrawThickLine(x0,y0,x1,y1,max(1.,hs.x*.5),am_yourcolor);
|
||||
Screen.DrawThickLine(x1,y1,x2,y1,max(1.,hs.x*.5),am_yourcolor);
|
||||
Screen.DrawThickLine(x2,y1,x0,y0,max(1.,hs.x*.5),am_yourcolor);
|
||||
yy += 87;
|
||||
yy += ((HALFMAPSIZE+2)*2)+3;
|
||||
}
|
||||
// draw stats and timer when automap is open
|
||||
int fstats = swwm_forcestats;
|
||||
|
|
|
|||
|
|
@ -1089,6 +1089,8 @@ Class Omnisight : Inventory
|
|||
{
|
||||
Owner.A_StartSound("powerup/omnisight",CHAN_ITEMEXTRA);
|
||||
level.allmap = true;
|
||||
// automatically zoom out so the player can know how far this goes
|
||||
CVar.FindCVar('swwm_minimapzoom').SetFloat(2.);
|
||||
}
|
||||
// not used up, must be kept for the targetting features to work
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -1359,11 +1359,13 @@ Class SWWMSimpleTracker : Thinker
|
|||
bool vipitem;
|
||||
bool expired;
|
||||
int lastupdate;
|
||||
int sightcount;
|
||||
SWWMSimpleTracker prev, next;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if ( !target ) return;
|
||||
sightcount = min(20,sightcount+1);
|
||||
radius = target.radius;
|
||||
angle = target.angle;
|
||||
pos = target.pos;
|
||||
|
|
@ -1383,8 +1385,8 @@ Class SWWMSimpleTracker : Thinker
|
|||
else
|
||||
{
|
||||
expired = false;
|
||||
lastupdate += 70;
|
||||
if ( countitem ) lastupdate += 70;
|
||||
lastupdate += 35;
|
||||
if ( countitem ) lastupdate += 35;
|
||||
if ( vipitem ) lastupdate += 70;
|
||||
}
|
||||
}
|
||||
|
|
@ -1414,6 +1416,8 @@ Class SWWMSimpleTracker : Thinker
|
|||
lastupdate += 70;
|
||||
}
|
||||
}
|
||||
else if ( target.default.bSHOOTABLE )
|
||||
expired = (target.Health<=0);
|
||||
}
|
||||
|
||||
static SWWMSimpleTracker Track( Actor target )
|
||||
|
|
@ -1437,6 +1441,4 @@ Class SWWMSimpleTracker : Thinker
|
|||
hnd.strackers_cnt++;
|
||||
return t;
|
||||
}
|
||||
|
||||
// no OnDestroy pruning like the others, the cleanup is done manually by the handler
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue