Implemented trading tab.
Added hitscan parrying (not that it's very useful). Various fixes to some timing stuff. Added "F to pay respects" when in death screen. Added money cheat, figure out the key combination yourself. Changed score interpolator so it goes faster with huge score gains.
This commit is contained in:
parent
f4a7ab4b19
commit
aad61ba649
8 changed files with 491 additions and 39 deletions
|
|
@ -36,6 +36,7 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
Array<int> storeunits;
|
||||
// trading
|
||||
SWWMTradeHistory tradelib;
|
||||
Array<int> playerlist;
|
||||
// chat history total line count (includes breaks)
|
||||
int chatlines;
|
||||
// temporary bottom messages, such as "not enough money"
|
||||
|
|
@ -51,6 +52,7 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
int lastuseamt;
|
||||
int checkuse;
|
||||
int checkdrop;
|
||||
int checksend;
|
||||
// seeeeecret
|
||||
int kcode;
|
||||
|
||||
|
|
@ -91,9 +93,10 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
tcol = CVar.GetCVar("msg4color",players[consoleplayer]);
|
||||
lorelib = SWWMLoreLibrary.Find(players[consoleplayer]);
|
||||
oldloresiz = lorelib.ent.Size();
|
||||
tradelib = SWWMTradeHistory.Find(players[consoleplayer]);
|
||||
stats = SWWMStats.Find(players[consoleplayer]);
|
||||
tmsg = "$SWWM_MAINCONTROLS";
|
||||
tmsgtic = gametic+70;
|
||||
tmsgtic = gametic+140;
|
||||
}
|
||||
|
||||
override bool MenuEvent( int mkey, bool fromcontroller )
|
||||
|
|
@ -150,6 +153,7 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
lorelist.Clear();
|
||||
storelist.Clear();
|
||||
storeunits.Clear();
|
||||
playerlist.Clear();
|
||||
return true;
|
||||
case MKEY_PAGEDOWN:
|
||||
MenuSound("menu/demotab");
|
||||
|
|
@ -162,6 +166,7 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
lorelist.Clear();
|
||||
storelist.Clear();
|
||||
storeunits.Clear();
|
||||
playerlist.Clear();
|
||||
return true;
|
||||
case MKEY_DOWN:
|
||||
if ( curtab == TAB_HELP )
|
||||
|
|
@ -231,6 +236,34 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
if ( sel0 >= storelist.Size() )
|
||||
sel0 = 0;
|
||||
}
|
||||
else if ( curtab == TAB_TRADING )
|
||||
{
|
||||
if ( !sub && (playerlist.Size() > 1) )
|
||||
{
|
||||
// scroll through player list
|
||||
MenuSound("menu/demoscroll");
|
||||
sel0++;
|
||||
if ( sel0 >= playerlist.Size() )
|
||||
sel0 = 0;
|
||||
}
|
||||
else if ( sub )
|
||||
{
|
||||
if ( (sel0 == -1) && (sel1 < tradelib.ent.Size()-28) )
|
||||
{
|
||||
// scroll through trading history
|
||||
MenuSound("menu/demoscroll");
|
||||
sel1++;
|
||||
}
|
||||
else if ( invlist.Size() > 1 )
|
||||
{
|
||||
// scroll through inventory
|
||||
MenuSound("menu/demoscroll");
|
||||
sel1++;
|
||||
if ( sel1 >= invlist.Size() )
|
||||
sel1 = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case MKEY_UP:
|
||||
if ( curtab == TAB_HELP )
|
||||
|
|
@ -286,6 +319,34 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
if ( sel0 < 0 )
|
||||
sel0 = storelist.Size()-1;
|
||||
}
|
||||
else if ( curtab == TAB_TRADING )
|
||||
{
|
||||
if ( !sub && (playerlist.Size() > 1) )
|
||||
{
|
||||
// scroll through player list
|
||||
MenuSound("menu/demoscroll");
|
||||
sel0--;
|
||||
if ( sel0 < 0 )
|
||||
sel0 = playerlist.Size()-1;
|
||||
}
|
||||
else if ( sub )
|
||||
{
|
||||
if ( (sel0 == -1) && (sel1 > 0) )
|
||||
{
|
||||
// scroll through trading history
|
||||
MenuSound("menu/demoscroll");
|
||||
sel1--;
|
||||
}
|
||||
else if ( invlist.Size() > 1 )
|
||||
{
|
||||
// scroll through inventory
|
||||
MenuSound("menu/demoscroll");
|
||||
sel1--;
|
||||
if ( sel1 < 0 )
|
||||
sel1 = invlist.Size()-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case MKEY_RIGHT:
|
||||
if ( ((curtab == TAB_INVENTORY) || (curtab == TAB_KEYS)) && (invlist.Size() > 21) )
|
||||
|
|
@ -311,6 +372,23 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
if ( sel1 > LORE_LORE )
|
||||
sel1 = LORE_ITEM;
|
||||
}
|
||||
else if ( curtab == TAB_TRADING )
|
||||
{
|
||||
if ( !sub && (playerlist.Size() > 21) ) // lol is this ever going to happen
|
||||
{
|
||||
int oldsel = sel0;
|
||||
sel0 += 22;
|
||||
if ( sel0 >= playerlist.Size() ) sel0 = playerlist.Size()-1;
|
||||
if ( sel0 != oldsel ) MenuSound("menu/demoscroll");
|
||||
}
|
||||
else if ( sub && (sel0 != -1) )
|
||||
{
|
||||
int oldsel = sel1;
|
||||
sel1 += 22;
|
||||
if ( sel1 >= invlist.Size() ) sel1 = invlist.Size()-1;
|
||||
if ( sel1 != oldsel ) MenuSound("menu/demoscroll");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case MKEY_LEFT:
|
||||
if ( ((curtab == TAB_INVENTORY) || (curtab == TAB_KEYS)) && (invlist.Size() > 21) )
|
||||
|
|
@ -338,6 +416,25 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
if ( sel1 < LORE_ITEM )
|
||||
sel1 = LORE_LORE;
|
||||
}
|
||||
else if ( curtab == TAB_TRADING )
|
||||
{
|
||||
if ( !sub && (playerlist.Size() > 21) ) // lol is this ever going to happen
|
||||
{
|
||||
if ( sel0-22 >= 0 )
|
||||
{
|
||||
sel0 -= 22;
|
||||
MenuSound("menu/demoscroll");
|
||||
}
|
||||
}
|
||||
else if ( sub && (sel0 != -1) )
|
||||
{
|
||||
if ( sel1-22 >= 0 )
|
||||
{
|
||||
sel1 -= 22;
|
||||
MenuSound("menu/demoscroll");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case MKEY_ENTER:
|
||||
if ( (curtab == TAB_INVENTORY) && (invlist.Size() > 0) && (sel0 < invlist.Size()) )
|
||||
|
|
@ -348,7 +445,7 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
lastuseamt = invlist[sel0].Amount;
|
||||
// don't check weapons (or the lamp)
|
||||
if ( !(invlist[sel0] is 'Weapon') && !(invlist[sel0] is 'SWWMLamp') )
|
||||
checkuse = gametic+1;
|
||||
checkuse = gametic+(multiplayer?5:1);
|
||||
EventHandler.SendNetworkEvent(String.Format("swwmuseitem.%s",invlist[sel0].GetClassName()),consoleplayer);
|
||||
}
|
||||
else if ( (curtab == TAB_STORE) && (storelist.Size() > 0) && (sel0 < storelist.Size()) )
|
||||
|
|
@ -361,7 +458,7 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
{
|
||||
MenuSound("menu/noinvuse");
|
||||
tmsg = StringTable.Localize("$SWWM_STOREMUNS");
|
||||
tmsgtic = gametic+35;
|
||||
tmsgtic = gametic+70;
|
||||
return true;
|
||||
}
|
||||
let cur = players[consoleplayer].mo.FindInventory(storelist[sel0]);
|
||||
|
|
@ -380,10 +477,11 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
{
|
||||
MenuSound("menu/noinvuse");
|
||||
tmsg = StringTable.Localize("$SWWM_STOREFULL");
|
||||
tmsgtic = gametic+35;
|
||||
tmsgtic = gametic+70;
|
||||
return true;
|
||||
}
|
||||
EventHandler.SendNetworkEvent(String.Format("swwmstoregive.%s",storelist[sel0].GetClassName()),consoleplayer,price,amt);
|
||||
if ( (camt+amt) >= max ) sel0 = max(0,sel0-1);
|
||||
MenuSound("menu/buyinv");
|
||||
}
|
||||
else if ( curtab == TAB_LIBRARY )
|
||||
|
|
@ -403,13 +501,31 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
sel2 = 0;
|
||||
}
|
||||
}
|
||||
else if ( curtab == TAB_TRADING )
|
||||
{
|
||||
if ( !sub && (playerlist.Size() > 0) )
|
||||
{
|
||||
// pick a player
|
||||
MenuSound("menu/demosel");
|
||||
sub = true;
|
||||
sel1 = 0;
|
||||
}
|
||||
else if ( sub && (sel0 != -1) && (invlist.Size() > 0) )
|
||||
{
|
||||
// trade item
|
||||
lastuse = invlist[sel1].GetClass();
|
||||
lastuseamt = invlist[sel1].Amount;
|
||||
checksend = gametic+(multiplayer?5:1);
|
||||
EventHandler.SendNetworkEvent(String.Format("swwmtrade.%s",invlist[sel1].GetClassName()),consoleplayer,playerlist[sel0]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
case MKEY_CLEAR:
|
||||
if ( (curtab == TAB_INVENTORY) && (invlist.Size() > 0) )
|
||||
{
|
||||
lastuse = invlist[sel0].GetClass();
|
||||
lastuseamt = invlist[sel0].Amount;
|
||||
checkdrop = gametic+1;
|
||||
checkdrop = gametic+(multiplayer?5:1);
|
||||
EventHandler.SendNetworkEvent(String.Format("swwmdropitem.%s",invlist[sel0].GetClassName()),consoleplayer);
|
||||
}
|
||||
else if ( (curtab == TAB_LIBRARY) && sub )
|
||||
|
|
@ -417,6 +533,24 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
MenuSound("menu/democlose");
|
||||
sub = false;
|
||||
}
|
||||
else if ( curtab == TAB_TRADING )
|
||||
{
|
||||
if ( !sub )
|
||||
{
|
||||
// open trading history
|
||||
MenuSound("menu/demosel");
|
||||
sub = true;
|
||||
sel0 = -1;
|
||||
sel1 = 0;
|
||||
}
|
||||
else if ( sub )
|
||||
{
|
||||
// go back
|
||||
MenuSound("menu/democlose");
|
||||
sub = false;
|
||||
sel0 = 0;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return Super.MenuEvent(mkey,fromcontroller);
|
||||
|
|
@ -647,10 +781,59 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
if ( lorelib.ent.Size() != oldloresiz )
|
||||
{
|
||||
tmsg = StringTable.Localize("$SWWM_NEWLORE");
|
||||
tmsgtic = gametic+35;
|
||||
tmsgtic = gametic+70;
|
||||
}
|
||||
oldloresiz = lorelib.ent.Size();
|
||||
}
|
||||
else if ( curtab == TAB_TRADING )
|
||||
{
|
||||
// build player list
|
||||
playerlist.Clear();
|
||||
for ( int i=0; i<MAXPLAYERS; i++ )
|
||||
{
|
||||
if ( !playeringame[i] || (i==consoleplayer) ) continue;
|
||||
playerlist.Push(i);
|
||||
}
|
||||
// build inventory list if open
|
||||
if ( sub && (sel0 != -1) )
|
||||
{
|
||||
invlist.Clear();
|
||||
// alphabetically sorted inventory
|
||||
for ( Inventory inv=players[consoleplayer].mo.Inv; inv; inv=inv.Inv )
|
||||
{
|
||||
if ( (inv.Amount <= 0) || !inv.SpawnState.ValidateSpriteFrame() || (inv is 'Key') || (inv is 'BasicArmor') || (inv is 'HexenArmor') || (inv is 'Powerup') || (inv is 'SWWMArmor') || (!(inv is 'Ammo') && !(inv is 'Weapon') && !inv.bINVBAR) && !(inv is 'HammerspaceEmbiggener') && !(inv is 'SWWMCollectable') ) continue;
|
||||
String tag = inv.GetTag();
|
||||
bool greater = false;
|
||||
for ( int i=0; i<invlist.Size(); i++ )
|
||||
{
|
||||
String tag2 = invlist[i].GetTag();
|
||||
if ( tag > tag2 ) continue;
|
||||
greater = true;
|
||||
invlist.Insert(i,inv);
|
||||
break;
|
||||
}
|
||||
if ( greater ) continue;
|
||||
invlist.Push(inv);
|
||||
}
|
||||
// re-sort by category
|
||||
for ( int i=0; i<invlist.Size(); i++ )
|
||||
{
|
||||
int j = 1;
|
||||
while ( j < invlist.Size() )
|
||||
{
|
||||
int k = j;
|
||||
while ( (k > 0) && CmpInventory(invlist[k-1],invlist[k]) )
|
||||
{
|
||||
Inventory tmp = invlist[k];
|
||||
invlist[k] = invlist[k-1];
|
||||
invlist[k-1] = tmp;
|
||||
k--;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if use succeeded
|
||||
if ( checkuse && (gametic > checkuse) )
|
||||
{
|
||||
|
|
@ -659,7 +842,7 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
if ( amt == lastuseamt )
|
||||
{
|
||||
tmsg = StringTable.Localize("$SWWM_INVFAIL");
|
||||
tmsgtic = gametic+35;
|
||||
tmsgtic = gametic+70;
|
||||
MenuSound("menu/noinvuse");
|
||||
}
|
||||
else
|
||||
|
|
@ -677,12 +860,30 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
if ( amt == lastuseamt )
|
||||
{
|
||||
tmsg = StringTable.Localize("$SWWM_INVNDROP");
|
||||
tmsgtic = gametic+35;
|
||||
tmsgtic = gametic+70;
|
||||
MenuSound("menu/noinvuse");
|
||||
}
|
||||
else if ( (amt == 0) && (sel0 >= invlist.Size()) )
|
||||
sel0 = max(0,sel0-1);
|
||||
}
|
||||
// check if trade succeeded
|
||||
if ( checksend && (gametic > checksend) )
|
||||
{
|
||||
checksend = 0;
|
||||
int amt = players[consoleplayer].mo.CountInv(lastuse);
|
||||
if ( amt == lastuseamt )
|
||||
{
|
||||
tmsg = StringTable.Localize("$SWWM_TRADEFULL");
|
||||
tmsgtic = gametic+70;
|
||||
MenuSound("menu/noinvuse");
|
||||
}
|
||||
else
|
||||
{
|
||||
MenuSound("menu/demosel");
|
||||
if ( (amt == 0) && (sel1 >= invlist.Size()) )
|
||||
sel1 = max(0,sel1-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override bool OnUiEvent( UIEvent ev )
|
||||
|
|
@ -1117,8 +1318,109 @@ Class SWWMKnowledgeBaseMenu : GenericMenu
|
|||
}
|
||||
else if ( curtab == TAB_TRADING )
|
||||
{
|
||||
str = StringTable.Localize("$SWWM_COMINGSOON");
|
||||
Screen.DrawText(fnt,Font.CR_FIRE,(ss.x-fnt.StringWidth(str))/2.,(ss.y-fnt.GetHeight())/2.,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
|
||||
if ( !sub )
|
||||
{
|
||||
xx = 9;
|
||||
yy = 23;
|
||||
int longest = 0, len;
|
||||
int ofs = int(floor(max(0,sel0-44)/22.)*22);
|
||||
int cols = 1;
|
||||
for ( int i=ofs; i<playerlist.Size(); i++ )
|
||||
{
|
||||
str = players[playerlist[i]].GetUserName();
|
||||
len = fnt.StringWidth(str);
|
||||
if ( len > longest ) longest = len;
|
||||
Screen.DrawText(fnt,Font.CR_WHITE,origin.x+xx,origin.y+yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_ColorOverlay,(i!=sel0)?Color(128,0,0,0):Color(0,0,0,0));
|
||||
yy += 16;
|
||||
if ( yy >= 370 )
|
||||
{
|
||||
xx += longest+24;
|
||||
yy = 23;
|
||||
longest = 0;
|
||||
cols++;
|
||||
if ( cols > 3 ) break;
|
||||
}
|
||||
}
|
||||
if ( playerlist.Size() > 65 )
|
||||
{
|
||||
// draw scrollbar
|
||||
int szr = (playerlist.Size()/22)-2;
|
||||
xx = floor((ofs/22)*(630./szr))+2;
|
||||
Screen.DrawText(TewiFont,Font.CR_FIRE,origin.x+xx,origin.y+373,"▬",DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
|
||||
Screen.DrawTexture(WindowSeparatorH,false,origin.x,origin.y+377,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
|
||||
}
|
||||
}
|
||||
else if ( sub )
|
||||
{
|
||||
if ( sel0 == -1 )
|
||||
{
|
||||
xx = 6;
|
||||
yy = 17;
|
||||
int ofs = clamp(sel1,0,max(0,tradelib.ent.Size()-28));
|
||||
for ( int i=ofs; i<tradelib.ent.Size(); i++ )
|
||||
{
|
||||
if ( yy >= 370 ) break;
|
||||
let ent = tradelib.ent[tradelib.ent.Size()-(i+1)];
|
||||
int thour = (ent.timestamp/(3600*Thinker.TICRATE));
|
||||
int tmin = (ent.timestamp/(60*Thinker.TICRATE))%60;
|
||||
int tsec = (ent.timestamp/Thinker.TICRATE)%60;
|
||||
str = String.Format("\cu[\cc%02d\cu:\cc%02d\cu:\cc%02d\cu]\c- ",thour,tmin,tsec);
|
||||
str.AppendFormat("\cd%s %s\cd: \cj%dx \cf%s\c-",ent.type?StringTable.Localize("$SWWM_TRADEFROM"):StringTable.Localize("$SWWM_TRADETO"),ent.other,ent.amt,GetDefaultByType(ent.what).GetTag());
|
||||
Screen.DrawText(fnt,Font.CR_WHITE,origin.x+xx,origin.y+yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
|
||||
yy += 13;
|
||||
}
|
||||
// scrollbar
|
||||
if ( tradelib.ent.Size() > 28 )
|
||||
{
|
||||
Screen.DrawTexture(WindowSeparator,false,origin.x+631,origin.y+14,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
|
||||
xx = 634;
|
||||
int szr = tradelib.ent.Size()-28;
|
||||
yy = floor(ofs*(353./szr))+17;
|
||||
Screen.DrawText(TewiFont,Font.CR_FIRE,origin.x+xx,origin.y+yy,"▮",DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xx = 9;
|
||||
yy = 23;
|
||||
int longest = 0, len;
|
||||
int ofs = int(floor(max(0,sel1-44)/22.)*22);
|
||||
int cols = 1;
|
||||
for ( int i=ofs; i<invlist.Size(); i++ )
|
||||
{
|
||||
if ( !invlist[i] ) continue;
|
||||
if ( (invlist[i] is 'Ammo') || (invlist[i].Amount > 1) || (!(invlist[i] is 'PuzzleItem') && (invlist[i].MaxAmount > 1)) ) str = String.Format("%dx %s",invlist[i].Amount,invlist[i].GetTag());
|
||||
else str = invlist[i].GetTag();
|
||||
len = fnt.StringWidth(str);
|
||||
if ( len > longest ) longest = len;
|
||||
int clscol = Font.CR_WHITE;
|
||||
if ( invlist[i] is 'Weapon' ) clscol = Font.CR_GOLD;
|
||||
else if ( (invlist[i] is 'Ammo') || (invlist[i] is 'BackpackItem') || (invlist[i] is 'HammerspaceEmbiggener') ) clscol = Font.CR_BROWN;
|
||||
else if ( (invlist[i] is 'PowerupGiver') || (invlist[i] is 'AmmoFabricator') || invlist[i].bBIGPOWERUP ) clscol = Font.CR_PURPLE;
|
||||
else if ( (invlist[i] is 'Health') || (invlist[i] is 'HealthPickup') || (invlist[i] is 'SWWMHealth') ) clscol = Font.CR_RED;
|
||||
else if ( (invlist[i] is 'Armor') || (invlist[i] is 'SWWMSpareArmor') ) clscol = Font.CR_GREEN;
|
||||
else if ( invlist[i] is 'PuzzleItem' ) clscol = Font.CR_LIGHTBLUE;
|
||||
Screen.DrawText(fnt,clscol,origin.x+xx,origin.y+yy,str,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true,DTA_ColorOverlay,(i!=sel1)?Color(128,0,0,0):Color(0,0,0,0));
|
||||
yy += 16;
|
||||
if ( yy >= 370 )
|
||||
{
|
||||
xx += longest+24;
|
||||
yy = 23;
|
||||
longest = 0;
|
||||
cols++;
|
||||
if ( cols > 3 ) break;
|
||||
}
|
||||
}
|
||||
if ( invlist.Size() > 65 )
|
||||
{
|
||||
// draw scrollbar
|
||||
int szr = (invlist.Size()/22)-2;
|
||||
xx = floor((ofs/22)*(630./szr))+2;
|
||||
Screen.DrawText(TewiFont,Font.CR_FIRE,origin.x+xx,origin.y+373,"▬",DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
|
||||
Screen.DrawTexture(WindowSeparatorH,false,origin.x,origin.y+377,DTA_VirtualWidthF,ss.x,DTA_VirtualHeightF,ss.y,DTA_KeepRatio,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( curtab == TAB_CHAT )
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue