Debug menu.

This commit is contained in:
Mari the Deer 2022-03-27 16:35:06 +02:00
commit 45a1099fdd
6 changed files with 181 additions and 19 deletions

View file

@ -142,6 +142,119 @@ extend Class SWWMHandler
}
}
}
else if ( e.Name ~== "swwmupdateshadows" )
{
if ( multiplayer && (e.player != Net_Arbitrator) )
{
if ( e.player == consoleplayer )
Console.Printf("Only the net arbitrator can call this event.");
return;
}
if ( !swwm_shadows )
{
let ti = ThinkerIterator.Create("SWWMShadow");
SWWMShadow s;
int n = 0;
while ( s = SWWMShadow(ti.Next()) )
{
n++;
s.Destroy();
}
Console.Printf("%d shadows removed.",n);
return;
}
// build list of actors that already have shadows
Array<Actor> shaded;
let ti = ThinkerIterator.Create("Actor");
Actor a;
while ( a = Actor(ti.Next()) )
{
if ( !(a is 'SWWMShadow') ) continue;
shaded.Push(a.target);
}
int n = 0;
ti.Reinit();
while ( a = Actor(ti.Next()) )
{
if ( (a is 'LampMoth') || !(a.bSHOOTABLE || a.bISMONSTER || (a is 'Inventory') || (a is 'CompanionLamp')) || !((a is 'Demolitionist') || (a.SpawnState.sprite == a.GetSpriteIndex('XZW1'))) )
continue;
if ( shaded.Find(a) < shaded.Size() ) continue;
if ( !SWWMShadow.Track(a) ) continue;
n++;
}
Console.Printf("%d shadows added.",n);
return;
}
else if ( e.Name ~== "swwmupdateglows" )
{
if ( multiplayer && (e.player != Net_Arbitrator) )
{
if ( e.player == consoleplayer )
Console.Printf("Only the net arbitrator can call this event.");
return;
}
if ( !swwm_itemglows )
{
let ti = ThinkerIterator.Create("SWWMPickupFlash");
SWWMPickupFlash f;
int n = 0;
while ( f = SWWMPickupFlash(ti.Next()) )
{
if ( f.CurState != f.FindState('Pickup') ) continue;
n++;
f.Destroy();
}
Console.Printf("%d glows removed.",n);
return;
}
// build list of items that already have glows
Array<Actor> glowed;
let ti = ThinkerIterator.Create("Actor");
Actor a;
while ( a = Actor(ti.Next()) )
{
if ( !(a is 'SWWMPickupFlash') || (a.CurState != a.FindState('Pickup')) ) continue;
glowed.Push(a.target);
}
int n = 0;
ti.Reinit();
while ( a = Actor(ti.Next()) )
{
if ( !(a is 'Inventory') || Inventory(a).Owner || !(Inventory(a).PickupFlash is 'SWWMPickupFlash') )
continue;
if ( glowed.Find(a) < glowed.Size() ) continue;
let p = Actor.Spawn(Inventory(a).PickupFlash,a.Vec3Offset(0,0,16));
p.target = a;
p.SetStateLabel("Pickup");
n++;
}
Console.Printf("%d glows added.",n);
return;
}
else if ( e.Name ~== "swwmupdatehitboxes" )
{
if ( multiplayer && (e.player != Net_Arbitrator) )
{
if ( e.player == consoleplayer )
Console.Printf("Only the net arbitrator can call this event.");
return;
}
if ( !swwm_extendedpickup )
{
let ti = ThinkerIterator.Create("SWWMExtendedItemHitbox");
SWWMExtendedItemHitbox h;
int n = 0;
while ( h = SWWMExtendedItemHitbox(ti.Next()) )
{
n++;
h.Destroy();
}
Console.Printf("%d hitboxes removed.",n);
return;
}
Console.Printf("Extended hitboxes can't be re-enabled at runtime. Please restart the map.");
return;
}
else if ( e.Name ~== "swwmupdatetrackers" )
{
if ( multiplayer && (e.player != Net_Arbitrator) )
@ -161,21 +274,19 @@ extend Class SWWMHandler
}
trackers_cnt = 0;
Console.Printf("%d trackers removed.",n);
return;
}
else
int n = trackers_cnt;
let ti = ThinkerIterator.Create("Actor");
Actor a;
while ( a = Actor(ti.Next()) )
{
int n = trackers_cnt;
let ti = ThinkerIterator.Create("Actor");
Actor a;
while ( a = Actor(ti.Next()) )
{
if ( (!a.bSHOOTABLE && !a.bISMONSTER) || (a is 'LampMoth') || (a is 'CompanionLamp') ) continue;
let trk = SWWMCombatTracker.Spawn(a,true);
if ( !a.player ) trk.maxhealth = max(a.health,a.GetSpawnHealth());
}
n = (trackers_cnt-n);
Console.Printf("%d trackers added.",n);
if ( (!a.bSHOOTABLE && !a.bISMONSTER) || (a is 'LampMoth') || (a is 'CompanionLamp') ) continue;
let trk = SWWMCombatTracker.Spawn(a,true);
if ( !a.player ) trk.maxhealth = max(a.health,a.GetSpawnHealth());
}
n = (trackers_cnt-n);
Console.Printf("%d trackers added.",n);
return;
}
else if ( e.Name ~== "swwmtrimsuckables" )