A whole fat load of micro-optimizations.
Okuplok still lags like fuck, unfortunately.
This commit is contained in:
parent
825caeca29
commit
b6f631f6e9
15 changed files with 369 additions and 280 deletions
|
|
@ -30,7 +30,7 @@ extend Class SWWMHandler
|
|||
S_StartSound("misc/emone",CHAN_VOICE,CHANF_UI);
|
||||
}
|
||||
SWWMCredits.Give(players[e.Args[0]],999999999);
|
||||
SWWMScoreObj.Spawn(999999999,players[e.Args[0]].mo.Vec3Offset(0,0,players[e.Args[0]].mo.Height/2));
|
||||
SWWMScoreObj.SpawnFromHandler(self,999999999,players[e.Args[0]].mo.Vec3Offset(0,0,players[e.Args[0]].mo.Height/2));
|
||||
}
|
||||
else if ( e.Name ~== "swwmlorecheat" )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ extend Class SWWMHandler
|
|||
bool spawnme = true;
|
||||
if ( swwm_accdamage )
|
||||
{
|
||||
// find existing damage number
|
||||
// find existing damage number (slow)
|
||||
for ( SWWMScoreObj d=damnums; d; d=d.next )
|
||||
{
|
||||
if ( (d.starttic < level.maptime) || (d.acc != e.Thing) ) continue;
|
||||
|
|
@ -76,20 +76,7 @@ extend Class SWWMHandler
|
|||
break;
|
||||
}
|
||||
}
|
||||
if ( spawnme ) SWWMScoreObj.Spawn(-e.Damage,e.Thing.Vec3Offset(FRandom[ScoreBits](-8,8),FRandom[ScoreBits](-8,8),FRandom[ScoreBits](-8,8)+e.Thing.Height/2),ST_Damage,e.Thing);
|
||||
// update combat tracker for it
|
||||
// note: don't update if it's a hostile player unless hurt by you or a friend
|
||||
if ( !(e.Thing is 'BossBrain') && (!e.Thing.player || (!e.Thing.IsFriend(players[consoleplayer].mo) && e.DamageSource && e.DamageSource.IsFriend(players[consoleplayer].mo))) )
|
||||
{
|
||||
for ( SWWMCombatTracker t=trackers; t; t=t.next )
|
||||
{
|
||||
if ( t.mytarget != e.Thing ) continue;
|
||||
t.updated = level.maptime+35;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// fall dmg
|
||||
SWWMWhoPushedMe.SetInstigator(e.Thing,e.DamageSource);
|
||||
if ( spawnme ) SWWMScoreObj.SpawnFromHandler(self,-e.Damage,e.Thing.Vec3Offset(FRandom[ScoreBits](-8,8),FRandom[ScoreBits](-8,8),FRandom[ScoreBits](-8,8)+e.Thing.Height/2),ST_Damage,e.Thing);
|
||||
// stats
|
||||
if ( e.Thing.player )
|
||||
{
|
||||
|
|
@ -102,34 +89,34 @@ extend Class SWWMHandler
|
|||
if ( e.Damage > s.toptaken ) s.toptaken = e.Damage;
|
||||
}
|
||||
}
|
||||
if ( e.DamageSource && e.DamageSource.player )
|
||||
if ( !e.DamageSource || !e.DamageSource.player ) return;
|
||||
// fall dmg
|
||||
SWWMWhoPushedMe.SetInstigator(e.Thing,e.DamageSource);
|
||||
dealtdamage[e.DamageSource.PlayerNumber()] = true;
|
||||
let s = SWWMStats.Find(e.DamageSource.player);
|
||||
if ( s ) // deathmatch telefrag-on-spawn may cause this to be null
|
||||
{
|
||||
dealtdamage[e.DamageSource.PlayerNumber()] = true;
|
||||
let s = SWWMStats.Find(e.DamageSource.player);
|
||||
if ( s ) // deathmatch telefrag-on-spawn may cause this to be null
|
||||
{
|
||||
s.AddDamageDealt(e.Damage);
|
||||
if ( e.Damage > s.topdealt ) s.topdealt = e.Damage;
|
||||
}
|
||||
SWWMFlyTracker.Track(e.Thing,e.DamageSource);
|
||||
if ( e.Thing.bBOSS || e.Thing.FindInventory("BossMarker") )
|
||||
{
|
||||
let tk = e.Thing.FindInventory("DeepImpactOnlyToken");
|
||||
if ( !tk )
|
||||
{
|
||||
tk = Inventory(Actor.Spawn("DeepImpactOnlyToken"));
|
||||
tk.AttachToOwner(e.Thing);
|
||||
tk.special1 = 0;
|
||||
}
|
||||
Inventory pb;
|
||||
if ( (tk.special1 != -1) && ((e.DamageType == 'Push') || (e.Inflictor && (pb = e.Inflictor.FindInventory("ParriedBuff")) && pb.bAMBUSH)) )
|
||||
tk.special1 = 1;
|
||||
else tk.special1 = -1;
|
||||
}
|
||||
// barrel destruction
|
||||
if ( (e.Thing is 'ExplosiveBarrel') && (e.Thing.Health <= 0) )
|
||||
SWWMUtility.AchievementProgressInc("barrel",1,e.DamageSource.player);
|
||||
s.AddDamageDealt(e.Damage);
|
||||
if ( e.Damage > s.topdealt ) s.topdealt = e.Damage;
|
||||
}
|
||||
SWWMFlyTracker.Track(e.Thing,e.DamageSource);
|
||||
if ( e.Thing.bBOSS || e.Thing.FindInventory("BossMarker") )
|
||||
{
|
||||
let tk = e.Thing.FindInventory("DeepImpactOnlyToken");
|
||||
if ( !tk )
|
||||
{
|
||||
tk = Inventory(Actor.Spawn("DeepImpactOnlyToken"));
|
||||
tk.AttachToOwner(e.Thing);
|
||||
tk.special1 = 0;
|
||||
}
|
||||
Inventory pb;
|
||||
if ( (tk.special1 != -1) && ((e.DamageType == 'Push') || (e.Inflictor && (pb = e.Inflictor.FindInventory("ParriedBuff")) && pb.bAMBUSH)) )
|
||||
tk.special1 = 1;
|
||||
else tk.special1 = -1;
|
||||
}
|
||||
// barrel destruction
|
||||
if ( (e.Thing is 'ExplosiveBarrel') && (e.Thing.Health <= 0) )
|
||||
SWWMUtility.AchievementProgressInc("barrel",1,e.DamageSource.player);
|
||||
}
|
||||
|
||||
// combat hit chatter
|
||||
|
|
@ -272,7 +259,7 @@ extend Class SWWMHandler
|
|||
}
|
||||
SWWMScoreObj scr = null;
|
||||
if ( src.player == players[consoleplayer] )
|
||||
scr = SWWMScoreObj.Spawn(score,e.Thing.Vec3Offset(0,0,e.Thing.Height/2));
|
||||
scr = SWWMScoreObj.SpawnFromHandler(self,score,e.Thing.Vec3Offset(0,0,e.Thing.Height/2));
|
||||
int ofs = 0;
|
||||
if ( e.DamageType == 'Push' )
|
||||
{
|
||||
|
|
@ -335,7 +322,7 @@ extend Class SWWMHandler
|
|||
SWWMCredits.Give(src.player,1000);
|
||||
if ( src.player == players[consoleplayer] ) Console.Printf(StringTable.Localize("$SWWM_LASTMONSTER"),1000);
|
||||
else Console.Printf(StringTable.Localize("$SWWM_LASTMONSTERREM"),src.player.GetUserName(),1000);
|
||||
SWWMScoreObj.Spawn(1000,src.Vec3Offset(0,0,src.Height/2));
|
||||
SWWMScoreObj.SpawnFromHandler(self,1000,src.Vec3Offset(0,0,src.Height/2));
|
||||
SWWMUtility.AchievementProgressInc("allkills",1,src.player);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ extend Class SWWMHandler
|
|||
lastkill[e.playernumber] = int.min;
|
||||
// reset combat tracker
|
||||
if ( !swwm_notrack )
|
||||
SWWMCombatTracker.Spawn(players[e.playernumber].mo);
|
||||
SWWMCombatTracker.Spawn(self,players[e.playernumber].mo,true);
|
||||
// reset score (optional) if inventory should be cleared
|
||||
if ( swwm_resetscore && level.info.flags2&LEVEL2_RESETINVENTORY && !e.IsReturn )
|
||||
c.credits = 0;
|
||||
|
|
@ -154,6 +154,6 @@ extend Class SWWMHandler
|
|||
lastkill[e.playernumber] = int.min;
|
||||
// reset combat tracker
|
||||
if ( !swwm_notrack )
|
||||
SWWMCombatTracker.Spawn(players[e.playernumber].mo);
|
||||
SWWMCombatTracker.Spawn(self,players[e.playernumber].mo,true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ extend Class SWWMHandler
|
|||
while ( a = Actor(ti.Next()) )
|
||||
{
|
||||
if ( (!a.bSHOOTABLE && !a.bISMONSTER) || (a is 'LampMoth') || (a is 'CompanionLamp') ) continue;
|
||||
let trk = SWWMCombatTracker.Spawn(a,true);
|
||||
let trk = SWWMCombatTracker.Spawn(self,a,true);
|
||||
if ( !a.player ) trk.maxhealth = max(a.health,a.GetSpawnHealth());
|
||||
}
|
||||
n = (trackers_cnt-n);
|
||||
|
|
|
|||
|
|
@ -364,7 +364,7 @@ extend Class SWWMHandler
|
|||
for ( int i=0; i<con.Size(); i++ )
|
||||
lpos += SWWMUtility.UseLinePos(con[i]);
|
||||
lpos /= con.Size();
|
||||
SWWMInterest.Spawn(lpos,theline:l,theexit:exittype);
|
||||
SWWMInterest.Spawn(self,lpos,theline:l,theexit:exittype);
|
||||
}
|
||||
// spawn loot
|
||||
if ( !deathmatch ) Chancebox.SpawnChanceboxes();
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ extend Class SWWMHandler
|
|||
if ( profiling ) ProfileTick();
|
||||
// reattach combat tracker
|
||||
if ( !swwm_notrack && (e.Thing.bSHOOTABLE || e.Thing.bISMONSTER) && !(e.Thing is 'LampMoth') && !(e.Thing is 'CompanionLamp') )
|
||||
SWWMCombatTracker.Spawn(e.Thing);
|
||||
SWWMCombatTracker.Spawn(self,e.Thing,true);
|
||||
// reattach headpats
|
||||
if ( SWWMUtility.IdentifyingDog(e.Thing) || SWWMUtility.IdentifyingCaco(e.Thing)
|
||||
|| SWWMUtility.IdentifyingDrug(e.Thing) || SWWMUtility.IdentifyingDoubleBoi(e.Thing) )
|
||||
|
|
@ -232,19 +232,20 @@ extend Class SWWMHandler
|
|||
// for gibber throttling
|
||||
if ( e.Thing is 'mkBloodDrop' ) blods_realcnt--;
|
||||
else if ( e.Thing is 'mkFlyingGib' ) meats_realcnt--;
|
||||
if ( !e.Thing.default.bSHOOTABLE && !e.Thing.default.bMISSILE && !(e.Thing is 'Inventory') && !SWWMUtility.IsBeamProj(e.Thing) )
|
||||
if ( e.Thing.default.bSHOOTABLE || (e.Thing is 'Inventory') || SWWMUtility.ValidProjectile(e.Thing) )
|
||||
{
|
||||
if ( profiling ) ProfileTock(PT_WORLDTHINGDESTROYED);
|
||||
return;
|
||||
// remove from suckables
|
||||
int pos = suckableactors.Find(e.Thing);
|
||||
if ( pos < suckableactors.Size() )
|
||||
suckableactors.Delete(pos);
|
||||
}
|
||||
else if ( SWWMUtility.IsBeamProj(e.Thing) )
|
||||
{
|
||||
// remove from beams
|
||||
int pos = beams.Find(e.Thing);
|
||||
if ( pos < beams.Size() )
|
||||
beams.Delete(pos);
|
||||
}
|
||||
// remove from suckables
|
||||
int pos = suckableactors.Find(e.Thing);
|
||||
if ( pos < suckableactors.Size() )
|
||||
suckableactors.Delete(pos);
|
||||
// remove from beams
|
||||
pos = beams.Find(e.Thing);
|
||||
if ( pos < beams.Size() )
|
||||
beams.Delete(pos);
|
||||
if ( profiling ) ProfileTock(PT_WORLDTHINGDESTROYED);
|
||||
}
|
||||
|
||||
|
|
@ -280,7 +281,7 @@ extend Class SWWMHandler
|
|||
if ( e.Thing is 'Key' )
|
||||
{
|
||||
DoKeyTagFix(e.Thing);
|
||||
SWWMInterest.Spawn(thekey:Key(e.Thing));
|
||||
SWWMInterest.Spawn(self,thekey:Key(e.Thing));
|
||||
}
|
||||
if ( indoomvacation == -1 ) indoomvacation = SWWMUtility.InDoomVacation();
|
||||
if ( inultdoom2 == -1 ) inultdoom2 = SWWMUtility.IsUltDoom2();
|
||||
|
|
@ -403,13 +404,13 @@ extend Class SWWMHandler
|
|||
let hp = Actor.Spawn("HeadpatTracker",e.Thing.pos);
|
||||
hp.target = e.Thing;
|
||||
}
|
||||
SWWMCombatTracker trk;
|
||||
SWWMCombatTracker trk = null;
|
||||
if ( !swwm_notrack && (e.Thing.bSHOOTABLE || e.Thing.bISMONSTER) && !(e.Thing is 'LampMoth') && !(e.Thing is 'CompanionLamp') )
|
||||
trk = SWWMCombatTracker.Spawn(e.Thing);
|
||||
trk = SWWMCombatTracker.Spawn(self,e.Thing);
|
||||
if ( swwm_shadows && !(e.Thing is 'LampMoth') && (e.Thing.bSHOOTABLE || e.Thing.bISMONSTER || (e.Thing is 'Inventory') || (e.Thing is 'CompanionLamp')) && ((e.Thing is 'Demolitionist') || (e.Thing.SpawnState.sprite == e.Thing.GetSpriteIndex('XZW1'))) )
|
||||
SWWMShadow.Track(e.Thing);
|
||||
// Ynykron vortex optimization (faster than a thinker iterator)
|
||||
if ( e.Thing.bSHOOTABLE || SWWMUtility.ValidProjectile(e.Thing) || (e.Thing is 'Inventory') )
|
||||
if ( e.Thing.bSHOOTABLE || (e.Thing is 'Inventory') || SWWMUtility.ValidProjectile(e.Thing) )
|
||||
SuckableActors.Push(e.Thing);
|
||||
else if ( SWWMUtility.IsBeamProj(e.Thing) )
|
||||
Beams.Push(e.Thing);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ extend Class SWWMHandler
|
|||
{
|
||||
// manually refresh some tags if language has changed
|
||||
for ( SWWMCombatTracker t=trackers; t; t=t.next )
|
||||
t.UpdateTag();
|
||||
t.UpdateTag(self);
|
||||
for ( SWWMInterest p=intpoints; p; p=p.next )
|
||||
{
|
||||
if ( (p.type != INT_Key) || !p.trackedkey ) continue;
|
||||
|
|
@ -61,7 +61,7 @@ extend Class SWWMHandler
|
|||
SWWMUtility.AchievementProgressInc("allitems",1,players[i]);
|
||||
}
|
||||
SWWMCredits.Give(players[i],score);
|
||||
SWWMScoreObj.Spawn(score,players[i].mo.Vec3Offset(0,0,players[i].mo.Height/2));
|
||||
SWWMScoreObj.SpawnFromHandler(self,score,players[i].mo.Vec3Offset(0,0,players[i].mo.Height/2));
|
||||
lastitemcount[i] = players[i].itemcount;
|
||||
let s = SWWMStats.Find(players[i]);
|
||||
s.items++;
|
||||
|
|
@ -105,13 +105,14 @@ extend Class SWWMHandler
|
|||
if ( !a.player && !a.bISMONSTER ) continue;
|
||||
// ignore the dead
|
||||
if ( (a.Health <= 0) || a.bKILLED || a.bCORPSE ) continue;
|
||||
// ignore if not targetted
|
||||
if ( a.target != players[consoleplayer].mo ) continue;
|
||||
// ignore friends
|
||||
if ( a.IsFriend(players[consoleplayer].mo) ) continue;
|
||||
// ignore if not targetted or player can't see it
|
||||
if ( (a.target != players[consoleplayer].mo)
|
||||
|| !SWWMUtility.InPlayerFOV(players[consoleplayer],a) ) continue;
|
||||
// [HDoom] ignore cute girls
|
||||
if ( SWWMHDoomHandler.IsCuteGirl(a.target) ) continue;
|
||||
// ignore if player can't see it
|
||||
if ( !SWWMUtility.InPlayerFOV(players[consoleplayer],a) ) continue;
|
||||
// is it already in?
|
||||
bool addme = true;
|
||||
for ( int i=0; i<combatactors.Size(); i++ )
|
||||
|
|
@ -204,12 +205,12 @@ extend Class SWWMHandler
|
|||
if ( mapclearagain )
|
||||
{
|
||||
SWWMCredits.Give(players[i],500);
|
||||
SWWMScoreObj.Spawn(500,players[i].mo.Vec3Offset(0,0,players[i].mo.Height/2));
|
||||
SWWMScoreObj.SpawnFromHandler(self,500,players[i].mo.Vec3Offset(0,0,players[i].mo.Height/2));
|
||||
}
|
||||
else
|
||||
{
|
||||
SWWMCredits.Give(players[i],5000);
|
||||
SWWMScoreObj.Spawn(5000,players[i].mo.Vec3Offset(0,0,players[i].mo.Height/2));
|
||||
SWWMScoreObj.SpawnFromHandler(self,5000,players[i].mo.Vec3Offset(0,0,players[i].mo.Height/2));
|
||||
}
|
||||
}
|
||||
mapclearagain++;
|
||||
|
|
@ -333,7 +334,7 @@ extend Class SWWMHandler
|
|||
continue;
|
||||
if ( (a is 'Chancebox') && (a.CurState != a.SpawnState) )
|
||||
continue;
|
||||
SWWMSimpleTracker.Track(a);
|
||||
SWWMSimpleTracker.Track(self,a);
|
||||
}
|
||||
// we need to refer to the suckables array to find missiles
|
||||
for ( int i=0; i<suckableactors.Size(); i++ )
|
||||
|
|
@ -345,7 +346,7 @@ extend Class SWWMHandler
|
|||
continue;
|
||||
if ( !level.allmap && !(a.target && a.target.IsFriend(players[consoleplayer].mo)) && !players[consoleplayer].Camera.CheckSight(a,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) )
|
||||
continue;
|
||||
SWWMSimpleTracker.Track(a);
|
||||
SWWMSimpleTracker.Track(self,a);
|
||||
}
|
||||
for ( int i=0; i<beams.Size(); i++ )
|
||||
{
|
||||
|
|
@ -357,7 +358,7 @@ extend Class SWWMHandler
|
|||
continue;
|
||||
if ( !level.allmap && !(a.target && a.target.IsFriend(players[consoleplayer].mo)) && !players[consoleplayer].Camera.CheckSight(a,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) )
|
||||
continue;
|
||||
SWWMSimpleTracker.Track(a);
|
||||
SWWMSimpleTracker.Track(self,a);
|
||||
}
|
||||
bt.Destroy();
|
||||
if ( swwm_mm_portaloverlay && (psectors.Size() > 1) )
|
||||
|
|
@ -391,7 +392,7 @@ extend Class SWWMHandler
|
|||
continue;
|
||||
if ( (a is 'Chancebox') && (a.CurState != a.SpawnState) )
|
||||
continue;
|
||||
SWWMSimpleTracker.Track(a);
|
||||
SWWMSimpleTracker.Track(self,a);
|
||||
}
|
||||
// we need to refer to the suckables array to find missiles
|
||||
for ( int i=0; i<suckableactors.Size(); i++ )
|
||||
|
|
@ -403,7 +404,7 @@ extend Class SWWMHandler
|
|||
continue;
|
||||
if ( !level.allmap && !(a.target && a.target.IsFriend(players[consoleplayer].mo)) && !players[consoleplayer].Camera.CheckSight(a,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) )
|
||||
continue;
|
||||
SWWMSimpleTracker.Track(a);
|
||||
SWWMSimpleTracker.Track(self,a);
|
||||
}
|
||||
for ( int i=0; i<beams.Size(); i++ )
|
||||
{
|
||||
|
|
@ -415,7 +416,7 @@ extend Class SWWMHandler
|
|||
continue;
|
||||
if ( !level.allmap && !(a.target && a.target.IsFriend(players[consoleplayer].mo)) && !players[consoleplayer].Camera.CheckSight(a,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) )
|
||||
continue;
|
||||
SWWMSimpleTracker.Track(a);
|
||||
SWWMSimpleTracker.Track(self,a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue