Add item sparkles.

Tweak Omnisight pickup behavior (shared in mp).
This commit is contained in:
Mari the Deer 2021-02-22 17:01:58 +01:00
commit 06f79726a8
13 changed files with 83 additions and 10 deletions

View file

@ -3293,6 +3293,7 @@ Class SWWMHandler : EventHandler
Console.Printf("Bundle: %d",Random2[Bundle]());
Console.Printf("Candy: %d",Random2[Candy]());
Console.Printf("Chancebox: %d",Random2[Chancebox]());
Console.Printf("ClientSparkles: %d",Random2[ClientSparkles]());
Console.Printf("Corrode: %d",Random2[Corrode]());
Console.Printf("DemoLines: %d",Random2[DemoLines]());
Console.Printf("DoBlast: %d",Random2[DoBlast]());

View file

@ -675,6 +675,36 @@ Class Demolitionist : PlayerPawn
SWWMGesture.SetGesture(self,GS_EmptyMelee);
}
}
void NearbyItemSparkles()
{
if ( (player != players[consoleplayer]) || !swwm_itemsparkles ) return;
let bt = BlockThingsIterator.Create(self,500);
while ( bt.Next() )
{
let t = bt.Thing;
if ( !t || !(t is 'Inventory') || !t.bSPECIAL || t.bINVISIBLE || Inventory(t).Owner || !SWWMUtility.SphereIntersect(t,pos,500) )
continue;
Vector3 bpos = (0,0,16);
if ( t.bFLOATBOB ) bpos.z += BobSin(t.FloatBobPhase)*t.FloatBobStrength;
double alph = clamp((500.-Distance3D(t))/500.,0.,1.);
Color pcol = "Gold";
if ( Inventory(t).PickupFlash is 'SWWMPickupFlash' )
{
let def = GetDefaultByType(Inventory(t).PickupFlash);
pcol = Color(def.Args[1]*85,def.Args[2]*85,def.Args[3]*85);
}
int numpt = clamp(int(max(t.radius,t.height-16)/4),1,8);
for ( int i=0; i<numpt; i++ )
{
double ang = FRandom[ClientSparkles](0,360);
double pt = FRandom[ClientSparkles](0,360);
double dst = FRandom[ClientSparkles](.5,1.25)*max(t.radius,t.height-16);
Vector3 dir = (cos(ang)*cos(pt),sin(ang)*cos(pt),-sin(pt));
Vector3 ppos = bpos+dir*dst;
t.A_SpawnParticle(pcol,SPF_FULLBRIGHT,30,2.,0,ppos.x,ppos.y,ppos.z,dir.x*.2,dir.y*.2,dir.z*.2,0,0,.05,alph,-1,-2./30.);
}
}
}
override void Tick()
{
Vector3 oldpos = pos;
@ -690,6 +720,7 @@ Class Demolitionist : PlayerPawn
selflight.Tick();
}
if ( !player || (player.mo != self) ) return;
NearbyItemSparkles();
// double-check that we have these
if ( !FindInventory("AlmasteelPlating") )
{

View file

@ -1087,10 +1087,28 @@ Class Omnisight : Inventory
{
if ( !level.allmap )
{
Owner.A_StartSound("powerup/omnisight",CHAN_ITEMEXTRA);
if ( Owner.player == players[consoleplayer] )
{
Owner.A_StartSound("powerup/omnisight",CHAN_ITEMEXTRA);
// automatically zoom out so the player can know how far this goes
CVar.FindCVar('swwm_minimapzoom').SetFloat(2.);
}
level.allmap = true;
// automatically zoom out so the player can know how far this goes
CVar.FindCVar('swwm_minimapzoom').SetFloat(2.);
}
// spread to all players
for ( int i=0; i<MAXPLAYERS; i++ )
{
if ( !playeringame[i] || !players[i].mo || players[i].mo.FindInventory(GetClass()) ) continue;
let o = Inventory(Spawn(GetClass()));
o.ClearCounters();
o.AttachToOwner(players[i].mo);
if ( i == consoleplayer )
{
Console.Printf(StringTable.Localize("$D_OMNISHARE"),Owner.player.GetUserName());
players[i].mo.A_StartSound("powerup/omnisight",CHAN_ITEMEXTRA);
// 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;

View file

@ -185,9 +185,12 @@ Class SWWMUtility
{
// must be two-sided and crossable
if ( !l.sidedef[1] || !(l.Activation&(SPAC_Cross|SPAC_MCross|SPAC_PCross|SPAC_AnyCross)) ) return false;
// filter lines that aren't player-activated (unless checking all)
if ( !all && !(l.Activation&SPAC_PlayerActivate) ) return false;
// typical teleports
if ( (l.special == Teleport) || (l.special == Teleport_NoStop) )
return true;
// also include sneaky teleports
// if checking all, also include sneaky teleports
if ( all && ((l.special == Teleport_Line) || (l.special == Teleport_NoFog)) )
return true;
// exits are included too