Multiplayer end of support. Simplify for ease of maintenance.
This commit is contained in:
parent
1c1dcc00cb
commit
33f8e060b7
19 changed files with 32 additions and 271 deletions
|
|
@ -433,103 +433,6 @@ extend Class SWWMHandler
|
|||
players[e.Args[0]].mo.TakeInventory(item,amt);
|
||||
SWWMCredits.Give(players[e.Args[0]],e.Args[1]);
|
||||
}
|
||||
else if ( e.Name.Left(10) ~== "swwmtrade." )
|
||||
{
|
||||
Class<Inventory> item = e.Name.Mid(10);
|
||||
if ( !item ) return;
|
||||
let def = GetDefaultByType(item);
|
||||
int amt = def.Amount;
|
||||
// if it's an ammo, check the largest unit givable
|
||||
if ( item is 'Ammo' )
|
||||
{
|
||||
for ( int i=0; i<AllActorClasses.Size(); i++ )
|
||||
{
|
||||
let a = (Class<Ammo>)(AllActorClasses[i]);
|
||||
if ( !a || (a.GetParentClass() != item) || (GetDefaultByType(a).Amount < amt) ) continue;
|
||||
amt = GetDefaultByType(a).Amount;
|
||||
}
|
||||
}
|
||||
if ( item is 'MagAmmo' )
|
||||
{
|
||||
for ( int i=0; i<AllActorClasses.Size(); i++ )
|
||||
{
|
||||
let a = (Class<MagAmmo>)(AllActorClasses[i]);
|
||||
if ( !a || (a.GetParentClass() != item) || (GetDefaultByType(a).Amount < amt) ) continue;
|
||||
amt = GetDefaultByType(a).Amount;
|
||||
}
|
||||
}
|
||||
Inventory ritm = players[e.Args[1]].mo.FindInventory(item);
|
||||
if ( ritm )
|
||||
{
|
||||
int maxgive = ritm.MaxAmount-ritm.Amount;
|
||||
if ( amt > maxgive ) amt = maxgive;
|
||||
}
|
||||
else if ( amt > def.MaxAmount ) amt = def.MaxAmount;
|
||||
bool rslt = false;
|
||||
Class<Inventory> giveitem = item;
|
||||
if ( item is 'HammerspaceEmbiggener' ) giveitem = 'TradedHammerspaceEmbiggener';
|
||||
if ( (amt > 0) && players[e.Args[1]].mo.GiveInventory(giveitem,amt,true) )
|
||||
{
|
||||
// if player currently has the dual wield weapon selected, switch over
|
||||
if ( item is 'SWWMWeapon' )
|
||||
{
|
||||
let c = Weapon(players[e.Args[0]].mo.FindInventory(item));
|
||||
if ( c.SisterWeapon && (players[e.Args[0]].ReadyWeapon == c.SisterWeapon) )
|
||||
{
|
||||
players[e.Args[0]].ReadyWeapon = c;
|
||||
players[e.Args[0]].SetPSprite(PSP_WEAPON,c.FindState("Ready"));
|
||||
players[e.Args[0]].SetPSprite(PSP_WEAPON+1,null); // delete left weapon psprite
|
||||
}
|
||||
}
|
||||
// if we're trading an embiggener, we need to readjust ammo
|
||||
if ( item is 'HammerspaceEmbiggener' )
|
||||
{
|
||||
let ritm = players[e.Args[0]].mo.FindInventory(item);
|
||||
for ( Inventory i=players[e.Args[0]].mo.Inv; i; i=i.Inv )
|
||||
{
|
||||
if ( !(i is 'Ammo') ) continue;
|
||||
if ( Ammo(i).BackpackMaxAmount > 0 )
|
||||
{
|
||||
double factor = (Ammo(i).BackpackMaxAmount-i.default.MaxAmount)/double(ritm.MaxAmount);
|
||||
i.MaxAmount = int(i.default.MaxAmount+(ritm.Amount-amt)*factor);
|
||||
}
|
||||
// drop excess ammo
|
||||
int excess = i.Amount-i.MaxAmount;
|
||||
if ( excess > 0 ) i.CreateTossable(excess);
|
||||
}
|
||||
}
|
||||
if ( item is 'CandyGun' )
|
||||
{
|
||||
// see if we can take a fully loaded spare from us instead
|
||||
int n = players[e.Args[0]].mo.CountInv('CandyGunSpares');
|
||||
int na = players[e.Args[0]].mo.CountInv('CandyGunAmmo');
|
||||
if ( (n >= amt) && (na >= amt) )
|
||||
{
|
||||
players[e.Args[0]].mo.TakeInventory('CandyGunSpares',amt);
|
||||
players[e.Args[0]].mo.TakeInventory('CandyGunAmmo',amt);
|
||||
}
|
||||
else players[e.Args[0]].mo.TakeInventory('CandyGun',amt);
|
||||
}
|
||||
else players[e.Args[0]].mo.TakeInventory(item,amt);
|
||||
// add to history
|
||||
SWWMTradeHistory.RegisterSend(players[e.Args[0]],players[e.Args[1]],item,amt);
|
||||
SWWMTradeHistory.RegisterReceive(players[e.Args[1]],players[e.Args[0]],item,amt);
|
||||
// add messages
|
||||
if ( e.Args[0] == consoleplayer ) Console.Printf(StringTable.Localize("$SWWM_MSGSENT"),amt,def.GetTag(),players[e.Args[1]].GetUserName());
|
||||
if ( e.Args[1] == consoleplayer ) Console.Printf(StringTable.Localize("$SWWM_MSGRECV"),players[e.Args[0]].GetUserName(),amt,def.GetTag());
|
||||
rslt = true;
|
||||
}
|
||||
if ( e.Args[0] == consoleplayer )
|
||||
{
|
||||
let t = new("MenuTransaction");
|
||||
t.uid = e.Args[2];
|
||||
t.type = MenuTransaction.TT_ITEMSEND;
|
||||
t.result = rslt;
|
||||
t.used = item;
|
||||
t.usedup = (players[e.Args[1]].mo.CountInv(item)<=0);
|
||||
checklist.Push(t);
|
||||
}
|
||||
}
|
||||
else if ( e.Name.Left(17) ~== "swwmmarkloreread." )
|
||||
{
|
||||
let l = SWWMLoreLibrary.Find(players[e.Args[0]]);
|
||||
|
|
@ -633,14 +536,12 @@ extend Class SWWMHandler
|
|||
else if ( e.Name.Left(16) ~== "swwmremoteliner." )
|
||||
{
|
||||
if ( consoleplayer == e.Args[0] ) return;
|
||||
if ( !swwm_othervoice ) return;
|
||||
if ( swwm_mutevoice >= e.Args[1] ) return;
|
||||
players[e.Args[0]].mo.A_StartSound(e.Name.Mid(16),CHAN_DEMOVOICE,attenuation:.5);
|
||||
}
|
||||
else if ( e.Name.Left(19) ~== "swwmremotelinertxt." )
|
||||
{
|
||||
if ( consoleplayer == e.Args[0] ) return;
|
||||
if ( !swwm_othervoice ) return;
|
||||
if ( swwm_mutevoice >= e.Args[1] ) return;
|
||||
double dist = players[consoleplayer].Camera.Distance3D(players[e.Args[0]].mo);
|
||||
if ( dist < 2000 )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue