From aa2e786f48c8168461f3342b4c18bbffb0954129 Mon Sep 17 00:00:00 2001 From: Marisa the Magician Date: Sun, 7 Aug 2022 22:47:32 +0200 Subject: [PATCH] Less repetition in oneliners. --- language.version | 4 +- zscript/handler/swwm_handler_oneliners.zsc | 69 +++++++++++++++------- zscript/swwm_thinkers.zsc | 9 +++ 3 files changed, 58 insertions(+), 24 deletions(-) diff --git a/language.version b/language.version index a70a6a5bf..cc445b980 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r271 \cu(Sun 7 Aug 20:19:27 CEST 2022)\c-"; -SWWM_SHORTVER="\cw1.3pre r271 \cu(2022-08-07 20:19:27)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r272 \cu(Sun 7 Aug 22:47:32 CEST 2022)\c-"; +SWWM_SHORTVER="\cw1.3pre r272 \cu(2022-08-07 22:47:32)\c-"; diff --git a/zscript/handler/swwm_handler_oneliners.zsc b/zscript/handler/swwm_handler_oneliners.zsc index 52913690b..529bd0a7e 100644 --- a/zscript/handler/swwm_handler_oneliners.zsc +++ b/zscript/handler/swwm_handler_oneliners.zsc @@ -10,7 +10,6 @@ extend Class SWWMHandler { transient String oneliner, onelinersnd, onelinertype; transient int onelinertic, onelinerspan, onelinerlevel; - transient Array lastlines; static int AddOneliner( String type, int level, int delay = 5 ) { @@ -22,6 +21,12 @@ extend Class SWWMHandler 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; + // suppress beep-boop lines if voice channel already in use + if ( (type == "buttonpush") + && players[consoleplayer].mo.IsActorPlayingSound(CHAN_DEMOVOICE) + && !players[consoleplayer].mo.IsActorPlayingSound(CHAN_DEMOVOICE,"voice/default/buttonpush1") + && !players[consoleplayer].mo.IsActorPlayingSound(CHAN_DEMOVOICE,"voice/default/buttonpush2") + && !players[consoleplayer].mo.IsActorPlayingSound(CHAN_DEMOVOICE,"voice/default/buttonpush3") ) 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); @@ -46,30 +51,50 @@ extend Class SWWMHandler } 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 0 ) - { - whichline = Random[DemoLines](1,countem-1); - if ( whichline >= last ) whichline++; - hnd.lastlines[ent].lineno = whichline; - } + if ( countem == 1 ) whichline = 1; // ez else { - whichline = Random[DemoLines](1,countem); - let lst = new("LastLine"); - lst.type = type; - lst.lineno = whichline; - hnd.lastlines.Push(lst); + bool addme = true; + int idx = -1; + for ( int i=0; i candidates; + for ( int i=1; i<=countem; i++ ) + { + if ( hnd.gdat.lastlines[idx].lines.Find(i) < hnd.gdat.lastlines[idx].lines.Size() ) + continue; + candidates.Push(i); + } + if ( candidates.Size() > 0 ) + { + whichline = candidates[Random[DemoLines](0,candidates.Size()-1)]; + hnd.gdat.lastlines[idx].lines.Push(whichline); + } + else + { + // clear history and go directly to the "easy" option + hnd.gdat.lastlines[idx].lines.Clear(); + addme = true; + } + } + if ( addme ) + { + // ez + whichline = Random[DemoLines](1,countem); + let lst = new("OnelinerHistory"); + lst.type = type; + lst.lines.Push(whichline); + hnd.gdat.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); diff --git a/zscript/swwm_thinkers.zsc b/zscript/swwm_thinkers.zsc index 92504be3a..936472b1f 100644 --- a/zscript/swwm_thinkers.zsc +++ b/zscript/swwm_thinkers.zsc @@ -299,11 +299,20 @@ Class SWWMCorpseCleaner : Thinker } } +Class OnelinerHistory +{ + String type; + Array lines; +} + Class SWWMGlobals : SWWMStaticThinker { // set so these messages only happen once bool ccstartonce, cclilithonce; + // for oneliners + Array lastlines; + static play SWWMGlobals Get() { let ti = ThinkerIterator.Create("SWWMGlobals",STAT_STATIC);