swwmgz_m/zscript/utility/swwm_utility.zsc
Marisa the Magician 80db58b0d0 Bump zscript ver to 4.14.1, plus a whole lot of stuff.
- Try to get rid of all implicit casts from string to name, color or class.
 - Use FindClass where needed.
 - Used a map in a case where a dictionary was unneeded.
 - Use new bounce flags where needed.
 - Replace Legacy of Rust weapons/ammo.
2025-03-13 14:50:58 +01:00

124 lines
3.5 KiB
Text

// Misc. Utility code
Class SWWMUtility
{
// gets the names of all mod cvars
static void GetCVars( Array<String> &cvarlist )
{
cvarlist.Clear();
let lmp = Wads.CheckNumForFullname("cvarinfo.base");
if ( lmp == -1 ) ThrowAbortException("'cvarinfo.base' not found");
String dat = Wads.ReadLump(lmp);
Array<String> list, ln;
// Windows pls
dat.Replace("\r","");
list.Clear();
dat.Split(list,"\n");
foreach ( l:list )
{
if ( (l.Length() == 0) || (l.Left(2) == "//") || (l.Left(1) == "") )
continue;
int eq = l.IndexOf("=");
if ( eq == -1 ) continue;
l.Truncate(eq);
ln.Clear();
l.Split(ln," ",0);
foreach ( w:ln )
{
if ( (w.Left(5) != "swwm_") ) continue;
cvarlist.Push(w);
}
}
}
// sends
static void SendTooltip( Class<SWWMWeapon> which )
{
if ( !swwm_weapontooltips ) return;
CVar v = CVar.FindCVar('swwm_tooltipshown');
String tt = v.GetString();
Array<String> wpn;
tt.Split(wpn,",");
foreach ( w:wpn )
{
if ( w == which.GetClassName() ) return;
}
if ( tt == "" ) tt = which.GetClassName();
else tt = tt..","..which.GetClassName();
v.SetString(tt);
EventHandler.SendInterfaceEvent(consoleplayer,"swwmwpntooltip."..which.GetClassName());
v = CVar.FindCVar('swwm_tooltipnote');
if ( v.GetBool() ) return;
v.SetBool(true);
Console.Printf(StringTable.Localize("$SWWM_TTNOTE"));
}
static bool CheatsDisabled( int p = -1 )
{
if ( cl_blockcheats || ((G_SkillPropertyInt(SKILLP_DisableCheats) || netgame || deathmatch) && !sv_cheats) )
{
if ( (p != -1) && (p == consoleplayer) )
{
Console.Printf("\cxSORRY NOTHING\c-");
S_StartSound("misc/trombone",CHAN_VOICE,CHANF_UI);
}
return true;
}
return false;
}
}
Class EnvmapDebugSphere : Actor
{
override bool Used( Actor user )
{
if ( CurState.NextState )
SetState(CurState.NextState);
else SetState(SpawnState);
return true;
}
override void Tick() {}
Default
{
RenderStyle 'Normal';
Radius 16;
Height 48;
}
States
{
Spawn:
XZW1 A -1 NoDelay A_SetRenderStyle(1.,STYLE_Normal);
XZW1 B -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 C -1 A_SetRenderStyle(1.,STYLE_Add);
XZW1 D -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 E -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 F -1 A_SetRenderStyle(1.,STYLE_Add);
XZW1 G -1 A_SetRenderStyle(1.,STYLE_Add);
XZW1 H -1 A_SetRenderStyle(1.,STYLE_Add);
XZW1 I -1 A_SetRenderStyle(1.,STYLE_Add);
XZW1 J -1 A_SetRenderStyle(1.,STYLE_Add);
XZW1 K -1 A_SetRenderStyle(1.,STYLE_Add);
XZW1 L -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 M -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 N -1 A_SetRenderStyle(1.,STYLE_Add);
XZW1 O -1 Bright A_SetRenderStyle(1.,STYLE_Normal);
XZW1 P -1 Bright A_SetRenderStyle(1.,STYLE_Normal);
XZW1 Q -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 R -1 Bright A_SetRenderStyle(1.,STYLE_Normal);
XZW1 S -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 T -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 U -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 V -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 W -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 X -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 Y -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW1 Z -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW2 A -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW2 B -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW2 C -1 A_SetRenderStyle(1.,STYLE_Normal);
XZW2 D -1 A_SetRenderStyle(1.,STYLE_Add);
XZW2 E -1 Bright A_SetRenderStyle(1.,STYLE_Normal);
XZW2 F -1 Bright A_SetRenderStyle(1.,STYLE_Add);
Loop;
}
}