Also made voice files a tad bit louder in general. Made Demoslayer mod also give armor nuggets.
127 lines
4.3 KiB
Text
127 lines
4.3 KiB
Text
// oneliner handling
|
|
|
|
Class LastLine
|
|
{
|
|
String type;
|
|
int lineno;
|
|
}
|
|
|
|
extend Class SWWMHandler
|
|
{
|
|
transient String oneliner, onelinersnd, onelinertype;
|
|
transient int onelinertic, onelinerspan, onelinerlevel;
|
|
transient Array<LastLine> lastlines;
|
|
|
|
static int AddOneliner( String type, int level, int delay = 5 )
|
|
{
|
|
// only Demolitionist can play voice lines
|
|
if ( !(players[consoleplayer].mo is 'Demolitionist') )
|
|
return 0;
|
|
let hnd = SWWMHandler(EventHandler.Find("SWWMHandler"));
|
|
if ( !hnd ) return 0;
|
|
String voicetype = CVar.FindCVar('swwm_voicetype').GetString();
|
|
// suppress non-rage comments when ragekit is active, only screaming allowed
|
|
if ( players[consoleplayer].mo.FindInventory("RagekitPower") && (type != "ragekit") ) return 0;
|
|
// check first if it's a multiple option line type
|
|
String testme = String.Format("SWWM_SUBS_%s_N%s",voicetype.MakeUpper(),type.MakeUpper());
|
|
String locme = StringTable.Localize(testme,false);
|
|
if ( testme == locme )
|
|
{
|
|
// it might be a single option line type
|
|
testme = String.Format("SWWM_SUBS_%s_%s",voicetype.MakeUpper(),type.MakeUpper());
|
|
locme = StringTable.Localize(testme,false);
|
|
if ( testme == locme ) return 0; // nope, the voicepack doesn't have it
|
|
hnd.oneliner = String.Format("$SWWM_SUBS_%s_%s",voicetype.MakeUpper(),type.MakeUpper());
|
|
hnd.onelinersnd = String.Format("voice/%s/%s",voicetype,type);
|
|
hnd.onelinertic = gametic+delay;
|
|
hnd.onelinertype = type;
|
|
hnd.onelinerspan = int(S_GetLength(hnd.onelinersnd)*GameTicRate);
|
|
if ( hnd.onelinerspan == 0 )
|
|
{
|
|
if ( developer >= 2 ) Console.Printf("No sound for voice line '%s'",type);
|
|
hnd.onelinerspan = 35;
|
|
}
|
|
hnd.onelinerlevel = level;
|
|
return hnd.onelinertic+hnd.onelinerspan;
|
|
}
|
|
int countem = locme.ToInt();
|
|
if ( countem == 0 ) return 0; // voicepack doesn't have this
|
|
// check last line so we don't repeat
|
|
int last = 0, ent;
|
|
for ( int i=0; i<hnd.lastlines.Size(); i++ )
|
|
{
|
|
if ( hnd.lastlines[i].type != type ) continue;
|
|
last = hnd.lastlines[i].lineno;
|
|
ent = i;
|
|
break;
|
|
}
|
|
int whichline;
|
|
if ( countem == 1 ) whichline = 1;
|
|
else if ( last > 0 )
|
|
{
|
|
whichline = Random[DemoLines](1,countem-1);
|
|
if ( whichline >= last ) whichline++;
|
|
hnd.lastlines[ent].lineno = whichline;
|
|
}
|
|
else
|
|
{
|
|
whichline = Random[DemoLines](1,countem);
|
|
let lst = new("LastLine");
|
|
lst.type = type;
|
|
lst.lineno = whichline;
|
|
hnd.lastlines.Push(lst);
|
|
}
|
|
hnd.oneliner = String.Format("$SWWM_SUBS_%s_%s%d",voicetype.MakeUpper(),type.MakeUpper(),whichline);
|
|
hnd.onelinersnd = String.Format("voice/%s/%s%d",voicetype,type,whichline);
|
|
hnd.onelinertic = gametic+delay;
|
|
hnd.onelinerspan = int(S_GetLength(hnd.onelinersnd)*GameTicRate);
|
|
hnd.onelinertype = type;
|
|
if ( hnd.onelinerspan == 0 )
|
|
{
|
|
if ( developer >= 2 ) Console.Printf("No sound for voice line '%s%d'",type,whichline);
|
|
hnd.onelinerspan = 35;
|
|
}
|
|
hnd.onelinerlevel = level;
|
|
return hnd.onelinertic+hnd.onelinerspan;
|
|
}
|
|
|
|
static void CancelOneliner( String type )
|
|
{
|
|
let hnd = SWWMHandler(EventHandler.Find("SWWMHandler"));
|
|
if ( !hnd ) return;
|
|
if ( (hnd.onelinertype != type) || (hnd.onelinertic < gametic) ) return;
|
|
hnd.onelinertic = 0;
|
|
hnd.onelinerspan = 0;
|
|
}
|
|
|
|
private void OnelinerTick()
|
|
{
|
|
if ( !onelinertic || (onelinertic >= gametic) ) return;
|
|
if ( players[consoleplayer].health > 0 )
|
|
{
|
|
if ( onelinerlevel > swwm_mutevoice )
|
|
{
|
|
int loudlv = swwm_voiceamp;
|
|
players[consoleplayer].mo.A_StartSound(onelinersnd,CHAN_DEMOVOICE,CHANF_DEFAULT,1.,ATTN_NONE);
|
|
if ( loudlv > 1 ) players[consoleplayer].mo.A_StartSound(onelinersnd,CHAN_DEMOVOICEAUX,CHANF_DEFAULT,1.,ATTN_NONE);
|
|
if ( loudlv > 2 ) players[consoleplayer].mo.A_StartSound(onelinersnd,CHAN_DEMOVOICEAUX2,CHANF_DEFAULT,1.,ATTN_NONE);
|
|
if ( loudlv > 3 ) players[consoleplayer].mo.A_StartSound(onelinersnd,CHAN_DEMOVOICEAUX3,CHANF_DEFAULT,1.,ATTN_NONE);
|
|
}
|
|
SendNetworkEvent("swwmremoteliner."..onelinersnd,consoleplayer,onelinerlevel);
|
|
}
|
|
onelinertic = 0;
|
|
onelinerspan = 0;
|
|
}
|
|
|
|
private ui void OnelinerUITick()
|
|
{
|
|
if ( (gametic != onelinertic) || (oneliner == "") || (players[consoleplayer].health <= 0) )
|
|
return;
|
|
if ( onelinerlevel > swwm_mutevoice )
|
|
{
|
|
let l = SWWMOneLiner.Make(oneliner,onelinerspan);
|
|
StatusBar.AttachMessage(l,-3473);
|
|
}
|
|
SendNetworkEvent("swwmremotelinertxt."..oneliner,consoleplayer,onelinerlevel);
|
|
}
|
|
}
|