swwmgz_m/zscript/hud/swwm_hud_messages.zsc

388 lines
13 KiB
Text

// messages (notifications, chat, pickups, midprint...)
extend Class SWWMStatusBar
{
override void FlushNotify()
{
if ( level.maptime <= 1 )
{
// flush ALL messages
MainQueue.Clear();
PickupQueue.Clear();
midstr = "";
midtic = 0;
ntagstr = "";
ntagtic = 0;
return;
}
// flush non-chat messages and nametag
for ( int i=0; i<MainQueue.Size(); i++ )
{
if ( MainQueue[i].type >= PRINT_CHAT ) continue;
MainQueue.Delete(i);
i--;
}
ntagstr = "";
ntagtic = 0;
}
override bool ProcessMidPrint( Font fnt, String msg, bool bold )
{
// check for Korax lines, add them to chat (and reply to some of them)
bool koraxline = false;
if ( msg == StringTable.Localize("$TXT_ACS_MAP02_9_GREET") )
koraxline = true;
else if ( msg == StringTable.Localize("$TXT_ACS_MAP02_11_AREYO") )
{
EventHandler.SendNetworkEvent("swwmkoraxline",0,consoleplayer);
koraxline = true;
SWWMDialogues.StartSeq("GREET");
}
else if ( msg == StringTable.Localize("$TXT_ACS_MAP13_11_MYSER") )
{
EventHandler.SendNetworkEvent("swwmkoraxline",1,consoleplayer);
koraxline = true;
SWWMDialogues.StartSeq("BLOOD");
}
else if ( msg == StringTable.Localize("$TXT_ACS_MAP22_27_YOUHA") )
koraxline = true;
else if ( msg == StringTable.Localize("$TXT_ACS_MAP22_29_ITHIN") )
{
EventHandler.SendNetworkEvent("swwmkoraxline",2,consoleplayer);
koraxline = true;
SWWMDialogues.StartSeq("GAME");
}
else if ( msg == StringTable.Localize("$TXT_ACS_MAP27_8_WORSH") )
koraxline = true;
else if ( msg == StringTable.Localize("$TXT_ACS_MAP27_10_THENA") )
{
EventHandler.SendNetworkEvent("swwmkoraxline",3,consoleplayer);
koraxline = true;
SWWMDialogues.StartSeq("WORSHIP");
}
else if ( msg == StringTable.Localize("$TXT_ACS_MAP35_12_AREYO") )
koraxline = true;
else if ( msg == StringTable.Localize("$TXT_ACS_MAP35_14_TOFAC") )
{
EventHandler.SendNetworkEvent("swwmkoraxline",4,consoleplayer);
koraxline = true;
SWWMDialogues.StartSeq("MASTERS");
}
if ( koraxline )
{
Console.PrintfEx(PRINT_CHAT,"\cmKorax\c*: "..msg.."\c*");
return true;
}
bool ispuzzle = false;
let s = SWWMStats.Find(players[consoleplayer]);
if ( s )
{
puzzlecnt = s.puzzlecnt;
realpuzzlecnt = s.realpuzzlecnt;
}
// check for puzzle solving lines (oh god why), and increment the achievement
if ( ((level.mapname ~== "MAP04") || (level.mapname ~== "MAP05"))
&& ((msg == StringTable.Localize("$TXT_ACS_MAP04_9_ONEHA"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP04_11_ONETH"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP05_6_ONETH"))) )
{
if ( puzzlecnt >= 4 ) puzzlecnt = 0;
puzzlecnt++;
realpuzzlecnt++;
ispuzzle = true;
}
else if ( ((level.mapname ~== "MAP08") || (level.mapname ~== "MAP09") || (level.mapname ~== "MAP10"))
&& ((msg == StringTable.Localize("$TXT_ACS_MAP08_6_ONESI"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP09_6_ONESI"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP10_6_ONESI"))) )
{
if ( (puzzlecnt < 4) || (puzzlecnt >= 10) ) puzzlecnt = 4;
puzzlecnt++;
realpuzzlecnt++;
ispuzzle = true;
}
else if ( ((level.mapname ~== "MAP28") || (level.mapname ~== "MAP30") || (level.mapname ~== "MAP34"))
&& ((msg == StringTable.Localize("$TXT_ACS_MAP28_6_ONENI"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP30_6_ONENI"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP34_1_ONENI"))) )
{
if ( (puzzlecnt < 10) || (puzzlecnt >= 19) ) puzzlecnt = 10;
puzzlecnt++;
realpuzzlecnt++;
ispuzzle = true;
}
// deathkings
else if ( ((level.mapname ~== "MAP44") || (level.mapname ~== "MAP46"))
&& ((msg == StringTable.Localize("$TXT_ACS_MAP44_1_THREE"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP44_2_TWOMO"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP44_3_ONEMO"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP44_4_THEPU"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP44_10_ONETH"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP44_11_TWOTH"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP46_8_ONEFO"))) )
{
if ( (puzzlecnt < 19) || (puzzlecnt >= 30) ) puzzlecnt = 19;
puzzlecnt++;
realpuzzlecnt++;
ispuzzle = true;
}
else if ( (level.mapname ~== "MAP51")
&& ((msg == StringTable.Localize("$TXT_ACS_MAP51_8_ONETH"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP51_9_TWOTH"))
|| (msg == StringTable.Localize("$TXT_ACS_MAP51_10_THECR"))) )
{
if ( (puzzlecnt < 30) || (puzzlecnt >= 34) ) puzzlecnt = 30;
puzzlecnt++;
realpuzzlecnt++;
ispuzzle = true;
}
if ( ispuzzle )
{
EventHandler.SendNetworkEvent("swwmstorepuzzlecnt",consoleplayer,puzzlecnt,realpuzzlecnt);
int tpuz = SWWMUtility.IsDeathkings()?15:19;
if ( realpuzzlecnt >= tpuz ) SWWMUtility.MarkAchievement("puzzle",players[consoleplayer]);
if ( !swwm_nomapmsg )
{
switch ( puzzlecnt )
{
case 1:
SWWMDialogues.StartSeq("PUZZLE1");
break;
case 2:
SWWMDialogues.StartSeq("PUZZLE2");
break;
case 3:
SWWMDialogues.StartSeq("PUZZLE3");
break;
case 5:
SWWMDialogues.StartSeq("PUZZLE4");
break;
case 8:
SWWMDialogues.StartSeq("PUZZLE5");
break;
case 11:
SWWMDialogues.StartSeq("PUZZLE6");
break;
case 20:
SWWMDialogues.StartSeq("PUZZLE7");
break;
case 30:
SWWMDialogues.StartSeq("PUZZLE8");
break;
case 31:
SWWMDialogues.StartSeq("PUZZLE9");
break;
}
}
}
// rampancy fun stuff
bool mainframeline = false;
if ( (msg == StringTable.Localize("$AISPAWN_TEXT1"))
|| (msg == StringTable.Localize("$AISPAWN_TEXT2"))
|| (msg == StringTable.Localize("$AISEE_TEXT"))
|| (msg == StringTable.Localize("$AIACTIVE_TEXT1"))
|| (msg == StringTable.Localize("$AIACTIVE_TEXT2"))
|| (msg == StringTable.Localize("$AIPAIN_TEXT1"))
|| (msg == StringTable.Localize("$AIPAIN_TEXT2"))
|| (msg == StringTable.Localize("$AIPAIN_TEXT3"))
|| (msg == StringTable.Localize("$AIPAIN_TEXT4"))
|| (msg == StringTable.Localize("$AIPAIN_TEXT5"))
|| (msg == StringTable.Localize("$AIPAIN_TEXT6"))
|| (msg == StringTable.Localize("$AIPAIN_TEXT7")) )
mainframeline = true;
if ( mainframeline )
{
Console.PrintfEx(PRINT_CHAT,"\cmAI Mainframe\c*: "..msg.."\c*");
return true;
}
if ( !fnt || (fnt == smallfont) )
{
midstr = msg;
midtic = level.totaltime;
midtype = bold?2:0;
return true;
}
if ( (fnt == bigfont) || (fnt == originalbigfont) )
{
midstr = msg;
midtic = level.totaltime;
midtype = bold?3:1;
return true;
}
return false;
}
override bool ProcessNotify( EPrintLevel printlevel, String outline )
{
// ignore outside of levels
if ( gamestate != GS_LEVEL ) return false;
int rprintlevel = printlevel&PRINT_TYPES;
// treat any unrecognized levels as critical messages
// note that checking for PRINT_LOG isn't needed as those are skipped early in the C++ side
if ( (rprintlevel < PRINT_LOW) || (rprintlevel > PRINT_TEAMCHAT) ) rprintlevel = PRINT_HIGH;
// strip trailing newline (all Printf type messages have this)
outline.DeleteLastCharacter();
let m = new("MsgLine");
m.str = outline;
m.type = rprintlevel;
m.tic = level.totaltime;
m.rep = 1;
if ( rprintlevel == PRINT_LOW )
{
// check if repeated
for ( int i=0; i<PickupQueue.Size(); i++ )
{
if ( PickupQueue[i].str != m.str ) continue;
// delete old one and add its repeats
m.rep += PickupQueue[i].rep;
PickupQueue.Delete(i);
break;
}
m.UpdateText(int(ss.x*.75));
PickupQueue.Push(m);
}
else
{
// check if repeated
for ( int i=0; i<MainQueue.Size(); i++ )
{
if ( MainQueue[i].str != m.str ) continue;
// delete old one and add its repeats
m.rep += MainQueue[i].rep;
MainQueue.Delete(i);
break;
}
m.UpdateText();
MainQueue.Push(m);
}
return true;
}
private void TickMessages()
{
// prune old messages
for ( int i=0; i<PickupQueue.Size(); i++ )
{
if ( level.totaltime < (PickupQueue[i].tic+GameTicRate*PICKDURATION) ) continue;
PickupQueue.Delete(i);
i--;
}
for ( int i=0; i<MainQueue.Size(); i++ )
{
if ( (MainQueue[i].type <= PRINT_HIGH) && (level.totaltime < (MainQueue[i].tic+GameTicRate*MSGDURATION)) ) continue;
else if ( (MainQueue[i].type > PRINT_HIGH) && (level.totaltime < (MainQueue[i].tic+GameTicRate*CHATDURATION)) ) continue;
MainQueue.Delete(i);
i--;
}
}
private void DrawPickups()
{
int h = mSmallFont.GetHeight();
// draw nametags below them
double yy;
double nalph = 0.;
double tagtime = (ntagtic+70)-(level.totaltime+fractic);
if ( (ntagstr != "") && (tagtime > 0) )
{
nalph = clamp(tagtime/20.,0.,1.);
yy = ss.y-(margin+50);
// shift up if boss healthbar is present
if ( hnd && (hnd.bossalpha > 0.) ) yy -= int(40*clamp(hnd.bossalpha*2.,0.,1.));
int len = mSmallFont.StringWidth(ntagstr);
double xx = (ss.x-len)/2.;
Screen.Dim("Black",.8*nalph,int((xx-6)*hs),int(yy*hs),int((len+12)*hs),int((h+4)*hs));
Screen.DrawText(mSmallFont,ntagcol,int(xx),yy+2,ntagstr,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,nalph);
}
if ( PickupQueue.Size() <= 0 ) return;
// reverse order since they're drawn bottom to top
int mend = max(0,PickupQueue.Size()-MAXPICKUP);
yy = ss.y-(margin+50);
// shift up if boss healthbar is present
if ( hnd && (hnd.bossalpha > 0.) ) yy -= int(40*clamp(hnd.bossalpha*2.,0.,1.));
// shift up again if nametag is present
if ( nalph > 0. ) yy -= int((mSmallFont.GetHeight()+6)*clamp(nalph*2.,0.,1.));
for ( int i=PickupQueue.Size()-1; i>=mend; i-- )
{
PickupQueue[i].UpdateText(int(ss.x*.75));
double curtime = (PickupQueue[i].tic+GameTicRate*PICKDURATION)-(level.totaltime+fractic);
double alph = clamp(curtime/20.,0.,1.);
let l = PickupQueue[i].l;
int maxlen = 0;
for ( int j=0; j<l.Count(); j++ )
{
int len = mSmallFont.StringWidth(l.StringAt(j));
if ( len > maxlen ) maxlen = len;
}
double xx = (ss.x-maxlen)/2.;
Screen.Dim("Black",.8*alph,int((xx-6)*hs),int((yy-h*(l.Count()-1))*hs),int((maxlen+12)*hs),int((h*l.Count()+4)*hs));
for ( int j=l.Count()-1; j>=0; j-- )
{
int len = mSmallFont.StringWidth(l.StringAt(j));
xx = int((ss.x-len)/2.);
Screen.DrawText(mSmallFont,msg0color,xx,yy+2,l.StringAt(j),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph);
yy -= h;
}
yy -= 6;
}
}
private void DrawMessages( double boxalph = 1. )
{
double xx, yy;
if ( midstr != "" )
{
double ssp = (midtype&1)?.5:1.;
double hsp = (midtype&1)?2.:1.;
int col = (midtype&2)?msgmidcolor2:msgmidcolor;
double curtime = (midtic+int(GameTicRate*con_midtime))-(level.totaltime+fractic);
double alph = clamp(curtime/20.,0.,1.);
if ( !midl || (midsz != int(ss.x*ssp)) )
{
if ( midl ) midl.Destroy();
midl = mSmallFont.BreakLines(midstr,int(ss.x*ssp));
}
int h = mSmallFont.GetHeight();
int maxlen = 0;
for ( int i=0; i<midl.Count(); i++ ) maxlen = max(maxlen,mSmallFont.StringWidth(midl.StringAt(i)));
xx = int((ss.x*ssp-maxlen)/2.);
yy = int(ss.y*ssp*.375);
yy -= (h*midl.Count()+4)/2; // center
Screen.Dim("Black",.8*alph,int((xx-6)*hs*hsp),int(yy*hs*hsp),int((maxlen+12)*hs*hsp),int((h*midl.Count()+4)*hs*hsp));
for ( int i=0; i<midl.Count(); i++ )
{
int len = mSmallFont.StringWidth(midl.StringAt(i));
xx = int((ss.x*ssp-len)/2.);
Screen.DrawText(mSmallFont,col,int(xx),yy+2,midl.StringAt(i),DTA_VirtualWidthF,ss.x*ssp,DTA_VirtualHeightF,ss.y*ssp,DTA_KeepRatio,true,DTA_Alpha,alph);
yy += h;
}
}
if ( MainQueue.Size() <= 0 ) return;
int mstart = max(0,MainQueue.Size()-((chatopen>=gametic)?MAXSHOWNBIG:MAXSHOWN));
xx = margin;
yy = margin;
bool smol = (ss.x<640);
Screen.DrawTexture(ChatTex[smol?3:0],false,xx,yy,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,boxalph);
yy += 2;
for ( int i=mstart; i<MainQueue.Size(); i++ )
{
int col = msg2color;
if ( MainQueue[i].type == PRINT_MEDIUM ) col = msg1color;
else if ( MainQueue[i].type == PRINT_CHAT ) col = msg3color;
else if ( MainQueue[i].type == PRINT_TEAMCHAT ) col = msg4color;
MainQueue[i].UpdateText();
let l = smol?MainQueue[i].ls:MainQueue[i].l;
double curtime = MainQueue[i].tic-(level.totaltime+fractic);
if ( MainQueue[i].type < PRINT_CHAT ) curtime += GameTicRate*MSGDURATION;
else curtime += GameTicRate*CHATDURATION;
double alph = clamp(curtime/20.,0.,1.);
for ( int j=0; j<l.Count(); j++ )
{
Screen.DrawTexture(ChatTex[smol?4:1],false,xx,yy,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,boxalph);
Screen.DrawText(mSmallFont,col,xx+4,yy,l.StringAt(j),DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,alph);
yy += 13;
}
}
Screen.DrawTexture(ChatTex[smol?5:2],false,xx,yy,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_Alpha,boxalph);
}
}