// Handler responsible for item replacements and whatever else // most of the code is split up to make it easier to navigate Class SWWMHandler : EventHandler { transient int lastlock; transient int lastpickuptic[MAXPLAYERS]; SWWMCombatTracker trackers; SWWMScoreObj scorenums, damnums; SWWMInterest intpoints; int trackers_cnt, scorenums_cnt, damnums_cnt, intpoints_cnt; transient int slotstrictwarn; // optimization OnFire fires; int fires_cnt; // stuff to reduce worldthingspawned overhead int bossmap; int iwantdie; int indoomvacation; // for checkreplacement bool hasdrlamonsters; override void OnRegister() { // oneliner RNG must be relative to consoleplayer SetRandomSeed[DemoLines](Random[DemoLines]()+consoleplayer+MSTime()); // "uninitialize" some vars iwantdie = -1; bossmap = -1; indoomvacation = -1; // this one can be initialized here easily for ( int i=0; i= 5) ) { mnotify = true; let ti = ThinkerIterator.Create("SWWMStats",Thinker.STAT_STATIC); SWWMStats s; while ( s = SWWMStats(ti.Next()) ) { if ( !SWWMUtility.IsKnownMap() ) break; if ( s.myplayer != players[consoleplayer] ) continue; int clust = level.cluster; if ( SWWMUtility.IsEviternity() ) { // we have to do some heavy lifting here because episodes don't match clusters if ( level.levelnum <= 5 ) clust = 1; else if ( level.levelnum <= 10 ) clust = 2; else if ( level.levelnum <= 15 ) clust = 3; else if ( level.levelnum <= 20 ) clust = 4; else if ( level.levelnum <= 25 ) clust = 5; else if ( level.levelnum <= 30 ) clust = 6; else if ( level.levelnum <= 31 ) clust = 7; else if ( level.levelnum <= 32 ) clust = 8; } int csiz = s.clustervisit.Size(); if ( (csiz > 0) && (s.clustervisit[csiz-1] != clust) ) Console.Printf(StringTable.Localize("$SWWM_NEWMISSION")); } } OnelinerTick(); FlashTick(); ItemCountTrack(); CombatTrack(); OneHundredPercentCheck(); SimpleTracking(); VanillaBossTick(); } override void PostUiTick() { OnelinerUITick(); FlashUITick(); VanillaBossUITick(); } override void WorldLinePreActivated( WorldEvent e ) { // oneliner on locked doors if ( !e.Thing ) return; int locknum = SWWMUtility.GetLineLock(e.ActivatedLine); if ( (locknum < 1) || (locknum > 255) ) return; if ( e.Thing.CheckLocalView() && !e.Thing.CheckKeys(locknum,false,true) ) { if ( !lastlock || (gametic > lastlock+20) ) { if ( SWWMUtility.IsValidLockNum(locknum) ) lastlock = AddOneliner("locked",2); else lastlock = AddOneliner("jammed",2); } } } override void WorldLineActivated( WorldEvent e ) { if ( !(e.ActivationType&SPAC_Use) ) return; if ( !e.Thing || !e.Thing.player ) return; let w = SWWMWeapon(e.Thing.player.ReadyWeapon); if ( !w || !w.wallponch ) return; let s = SWWMStats.Find(e.Thing.player); if ( s ) s.wponch++; } // stuff for hud override void RenderUnderlay( RenderEvent e ) { // armor/health flashes FlashRender(e); if ( slotstrictwarn && (gametic < slotstrictwarn) ) { String str = StringTable.Localize("$SWWM_SETSLOTSTRICT"); double t = (slotstrictwarn-(gametic+e.FracTic))/20.; double alph = clamp(t,0.,1.); BrokenLines l = newsmallfont.BreakLines(str,300); double yy = (200-l.Count()*newsmallfont.GetHeight())/2; for ( int i=0; i