diff --git a/language.version b/language.version index d1d0ecf6d..582324591 100644 --- a/language.version +++ b/language.version @@ -1,2 +1,2 @@ [default] -SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.8b r557 \cu(Thu 24 Sep 14:05:04 CEST 2020)"; +SWWM_MODVER="\chSWWM \czGZ\c- \cw0.9.9b r558 \cu(Thu 24 Sep 21:14:06 CEST 2020)"; diff --git a/zscript/swwm_deathlydeathcannon.zsc b/zscript/swwm_deathlydeathcannon.zsc index 982bcb2bd..260a8fb1a 100644 --- a/zscript/swwm_deathlydeathcannon.zsc +++ b/zscript/swwm_deathlydeathcannon.zsc @@ -329,20 +329,12 @@ Class YnykronImpact : Actor void FlashPlayer( int str, double rad ) { - double vfov = CVar.GetCVar('fov',players[consoleplayer]).GetFloat()*0.5; - double hfov = atan(Screen.GetAspectRatio()*tan(vfov)); - let mo = players[consoleplayer].camera; - Vector3 pp; - if ( !CheckSight(mo) ) return; - if ( mo is 'PlayerPawn' ) pp = mo.Vec2OffsetZ(0,0,PlayerPawn(mo).player.viewz); - else pp = mo.Vec3Offset(0,0,mo.CameraHeight); - Vector3 sc = level.SphericalCoords(pp,pos,(mo.angle,mo.pitch)); - if ( (abs(sc.x) < hfov) && (abs(sc.y) < vfov) && (sc.z < rad) ) - { - str = int(str*(1.-(sc.z/rad))); - SWWMHandler.DoFlash(mo,Color(str,255,255,255),2); - SWWMHandler.DoFlash(mo,Color(str/2,255,255,255),10); - } + if ( !SWWMUtility.InPlayerFOV(players[consoleplayer],self,rad) ) return; + let mo = players[consoleplayer].Camera; + double dist = Distance3D(mo); + str = int(str*(1.-(dist/rad))); + SWWMHandler.DoFlash(mo,Color(str,255,255,255),2); + SWWMHandler.DoFlash(mo,Color(str/2,255,255,255),10); } override void PostBeginPlay() { @@ -997,20 +989,12 @@ Class YnykronShot : Actor } void FlashPlayer( int str, double rad ) { - double vfov = CVar.GetCVar('fov',players[consoleplayer]).GetFloat()*0.5; - double hfov = atan(Screen.GetAspectRatio()*tan(vfov)); - let mo = players[consoleplayer].camera; - Vector3 pp; - if ( !CheckSight(mo) ) return; - if ( mo is 'PlayerPawn' ) pp = mo.Vec2OffsetZ(0,0,PlayerPawn(mo).player.viewz); - else pp = mo.Vec3Offset(0,0,mo.CameraHeight); - Vector3 sc = level.SphericalCoords(pp,pos,(mo.angle,mo.pitch)); - if ( (abs(sc.x) < hfov) && (abs(sc.y) < vfov) && (sc.z < rad) ) - { - str = int(str*(1.-(sc.z/rad))); - SWWMHandler.DoFlash(mo,Color(str,255,255,255),3); - SWWMHandler.DoFlash(mo,Color(str/2,255,255,255),30); - } + if ( !SWWMUtility.InPlayerFOV(players[consoleplayer],self,rad) ) return; + let mo = players[consoleplayer].Camera; + double dist = Distance3D(mo); + str = int(str*(1.-(dist/rad))); + SWWMHandler.DoFlash(mo,Color(str,255,255,255),3); + SWWMHandler.DoFlash(mo,Color(str/2,255,255,255),30); } override void PostBeginPlay() { @@ -1731,20 +1715,12 @@ Class YnykronCloud : Actor void FlashPlayer( int str, double rad ) { - double vfov = CVar.GetCVar('fov',players[consoleplayer]).GetFloat()*0.5; - double hfov = atan(Screen.GetAspectRatio()*tan(vfov)); - let mo = players[consoleplayer].camera; - Vector3 pp; - if ( !CheckSight(mo) ) return; - if ( mo is 'PlayerPawn' ) pp = mo.Vec2OffsetZ(0,0,PlayerPawn(mo).player.viewz); - else pp = mo.Vec3Offset(0,0,mo.CameraHeight); - Vector3 sc = level.SphericalCoords(pp,pos,(mo.angle,mo.pitch)); - if ( (abs(sc.x) < hfov) && (abs(sc.y) < vfov) && (sc.z < rad) ) - { - str = int(str*(1.-(sc.z/rad))); - SWWMHandler.DoFlash(mo,Color(str,255,255,255),1); - SWWMHandler.DoFlash(mo,Color(str/2,240,224,255),10); - } + if ( !SWWMUtility.InPlayerFOV(players[consoleplayer],self,rad) ) return; + let mo = players[consoleplayer].Camera; + double dist = Distance3D(mo); + str = int(str*(1.-(dist/rad))); + SWWMHandler.DoFlash(mo,Color(str,255,255,255),1); + SWWMHandler.DoFlash(mo,Color(str/2,240,224,255),10); } override void PostBeginPlay() @@ -2386,20 +2362,12 @@ Class YnykronSingularity : Actor void FlashPlayer( int str, double rad ) { - double vfov = CVar.GetCVar('fov',players[consoleplayer]).GetFloat()*0.5; - double hfov = atan(Screen.GetAspectRatio()*tan(vfov)); - let mo = players[consoleplayer].camera; - Vector3 pp; - if ( !CheckSight(mo) ) return; - if ( mo is 'PlayerPawn' ) pp = mo.Vec2OffsetZ(0,0,PlayerPawn(mo).player.viewz); - else pp = mo.Vec3Offset(0,0,mo.CameraHeight); - Vector3 sc = level.SphericalCoords(pp,pos,(mo.angle,mo.pitch)); - if ( (abs(sc.x) < hfov) && (abs(sc.y) < vfov) && (sc.z < rad) ) - { - str = int(str*(1.-(sc.z/rad))); - SWWMHandler.DoFlash(mo,Color(str,255,255,255),3); - SWWMHandler.DoFlash(mo,Color(str/2,240,224,255),30); - } + if ( !SWWMUtility.InPlayerFOV(players[consoleplayer],self,rad) ) return; + let mo = players[consoleplayer].Camera; + double dist = Distance3D(mo); + str = int(str*(1.-(dist/rad))); + SWWMHandler.DoFlash(mo,Color(str,255,255,255),3); + SWWMHandler.DoFlash(mo,Color(str/2,240,224,255),30); } void A_SingularityBlast() { @@ -2441,7 +2409,7 @@ Class YnykronSingularity : Actor double factor = (60-special1)/60.; double invfct = 1.-factor; SWWMUtility.DoExplosion(self,0,-50000*factor,4000*invfct); - FlashPlayer(int(100*factor),10000); + FlashPlayer(int(min(100*factor,250)),10000); FLineTraceData d; Vector3 HitNormal; Vector3 origin; @@ -2706,20 +2674,12 @@ Class YnykronAltShot : Actor } void FlashPlayer( int str, double rad ) { - double vfov = CVar.GetCVar('fov',players[consoleplayer]).GetFloat()*0.5; - double hfov = atan(Screen.GetAspectRatio()*tan(vfov)); - let mo = players[consoleplayer].camera; - Vector3 pp; - if ( !CheckSight(mo) ) return; - if ( mo is 'PlayerPawn' ) pp = mo.Vec2OffsetZ(0,0,PlayerPawn(mo).player.viewz); - else pp = mo.Vec3Offset(0,0,mo.CameraHeight); - Vector3 sc = level.SphericalCoords(pp,pos,(mo.angle,mo.pitch)); - if ( (abs(sc.x) < hfov) && (abs(sc.y) < vfov) && (sc.z < rad) ) - { - str = int(str*(1.-(sc.z/rad))); - SWWMHandler.DoFlash(mo,Color(str,255,255,255),5); - SWWMHandler.DoFlash(mo,Color(str/2,0,0,0),15); - } + if ( !SWWMUtility.InPlayerFOV(players[consoleplayer],self,rad) ) return; + let mo = players[consoleplayer].Camera; + double dist = Distance3D(mo); + str = int(str*(1.-(dist/rad))); + SWWMHandler.DoFlash(mo,Color(str,255,255,255),5); + SWWMHandler.DoFlash(mo,Color(str/2,0,0,0),15); } override void PostBeginPlay() { diff --git a/zscript/swwm_handler.zsc b/zscript/swwm_handler.zsc index 0a8cc7623..a6d7356be 100644 --- a/zscript/swwm_handler.zsc +++ b/zscript/swwm_handler.zsc @@ -800,10 +800,9 @@ Class SWWMHandler : EventHandler if ( (a is 'RatBuddy') || (a is 'Peasant') || (a is 'Beggar') ) continue; // [Strife] ignore Oracle's spectre while it's inactive if ( (a is 'AlienSpectre3') && a.InStateSequence(a.CurState,a.FindState("Spawn")) ) continue; - // ignore if not targetted or either actor can't see the other + // ignore if not targetted or player can't see it if ( (a.target != players[consoleplayer].mo) - || !a.CheckSight(players[consoleplayer].mo) - || !players[consoleplayer].mo.CheckSight(a) ) continue; + || !SWWMUtility.InPlayerFOV(players[consoleplayer],a) ) continue; // is it already in? bool addme = true; for ( int i=0; i a, int l, int h ) + { + SWWMLore pv = a[h]; + int i = (l-1); + for ( int j=l; j<=(h-1); j++ ) + { + if ( StringTable.Localize(pv.tag) > StringTable.Localize(a[j].tag) ) + { + i++; + SWWMLore tmp = a[j]; + a[j] = a[i]; + a[i] = tmp; + } + } + SWWMLore tmp = a[h]; + a[h] = a[i+1]; + a[i+1] = tmp; + return i+1; + } + private void qsort_lore( Array a, int l, int h ) + { + if ( l >= h ) return; + int p = partition_lore(a,l,h); + qsort_lore(a,l,p-1); + qsort_lore(a,p+1,h); + } + override void Ticker() { Super.Ticker(); @@ -1808,6 +1835,8 @@ Class SWWMKnowledgeBaseMenu : GenericMenu if ( lorelib.ent[i].tab != sel1 ) continue; lorelist.Push(lorelib.ent[i]); } + // sort + qsort_lore(lorelist,0,lorelist.Size()-1); // readjust if ( oldone && (lorelist.Size() != oldsiz) ) { diff --git a/zscript/swwm_player.zsc b/zscript/swwm_player.zsc index 7c2bfdba8..d52e16239 100644 --- a/zscript/swwm_player.zsc +++ b/zscript/swwm_player.zsc @@ -357,7 +357,7 @@ Class Demolitionist : PlayerPawn { let i = Inventory(bt.Thing); if ( !i || i.bINVISIBLE || !i.bSPECIAL || i.Owner || !SWWMUtility.SphereIntersect(i,pos,800) ) continue; - if ( !thesight && !CheckSight(i) ) continue; + if ( !thesight && !CheckSight(i,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) ) continue; SWWMItemSense.Spawn(self,i); } } diff --git a/zscript/swwm_powerup.zsc b/zscript/swwm_powerup.zsc index fef2940ac..41e026cb4 100644 --- a/zscript/swwm_powerup.zsc +++ b/zscript/swwm_powerup.zsc @@ -746,8 +746,8 @@ Class RageSnd : Actor Class RagekitPower : Powerup { Actor l, snd; - int lasteffect, lastrage; - transient int lastpulse; + int lasteffect; + transient int lastpulse, lastrage; override double GetSpeedFactor() { @@ -1030,7 +1030,7 @@ Class LampMoth : Actor if ( !bi.Thing || !(bi.Thing is 'CompanionLamp') ) continue; Actor a = bi.Thing; double dist = Distance3D(a); - if ( (a.frame == 0) || (dist > mindist) && !CheckSight(a) ) continue; + if ( (a.frame == 0) || (dist > mindist) && !CheckSight(a,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) ) continue; mindist = dist; lamp = a; master = a.target; @@ -1040,7 +1040,7 @@ Class LampMoth : Actor else bFRIENDLY = false; } } - if ( !lamp || (lamp.frame == 0) || (Distance3D(lamp) > 250) || !CheckSight(lamp) ) return false; + if ( !lamp || (lamp.frame == 0) || (Distance3D(lamp) > 250) || !CheckSight(lamp,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) ) return false; return true; } void A_SmoothWander() diff --git a/zscript/swwm_shot.zsc b/zscript/swwm_shot.zsc index 6c49453c6..ea20dbe96 100644 --- a/zscript/swwm_shot.zsc +++ b/zscript/swwm_shot.zsc @@ -917,7 +917,7 @@ Class OnFire : Actor while ( bt.Next() ) { let t = bt.Thing; - if ( !t || !t.bSHOOTABLE || (t.Health <= 0) || (t == victim) || ((t == instigator) && (delay > 0)) || (victim.Distance3D(t) > victim.radius+t.radius+40) || !victim.CheckSight(t) ) continue; + if ( !t || !t.bSHOOTABLE || (t.Health <= 0) || (t == victim) || ((t == instigator) && (delay > 0)) || (victim.Distance3D(t) > victim.radius+t.radius+40) || !victim.CheckSight(t,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) ) continue; int amt = max(1,amount/10); OnFire of = IsOnFire(t); if ( of ) diff --git a/zscript/swwm_sparkyboi.zsc b/zscript/swwm_sparkyboi.zsc index 0a105e811..77de1afdd 100644 --- a/zscript/swwm_sparkyboi.zsc +++ b/zscript/swwm_sparkyboi.zsc @@ -888,22 +888,14 @@ Class BiosparkComboImpact : Actor } void FlashPlayer( int str, double rad ) { - double vfov = CVar.GetCVar('fov',players[consoleplayer]).GetFloat()*0.5; - double hfov = atan(Screen.GetAspectRatio()*tan(vfov)); - let mo = players[consoleplayer].camera; - Vector3 pp; - if ( !CheckSight(mo,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) ) return; - if ( mo is 'PlayerPawn' ) pp = mo.Vec2OffsetZ(0,0,PlayerPawn(mo).player.viewz); - else pp = mo.Vec3Offset(0,0,mo.CameraHeight); - Vector3 sc = level.SphericalCoords(pp,pos,(mo.angle,mo.pitch)); - if ( (abs(sc.x) < hfov) && (abs(sc.y) < vfov) && (sc.z < rad) ) - { - str = min(int(str*(1.-(sc.z/rad))),255); - SWWMHandler.DoFlash(mo,Color(str,248,255,240),10); - SWWMHandler.DoFlash(mo,Color(str,248,255,240),20); - SWWMHandler.DoFlash(mo,Color(str/2,192,255,160),30); - SWWMHandler.DoFlash(mo,Color(str/2,192,255,160),50); - } + if ( !SWWMUtility.InPlayerFOV(players[consoleplayer],self,rad) ) return; + let mo = players[consoleplayer].Camera; + double dist = Distance3D(mo); + str = min(int(str*(1.-(dist/rad))),255); + SWWMHandler.DoFlash(mo,Color(str,248,255,240),10); + SWWMHandler.DoFlash(mo,Color(str,248,255,240),20); + SWWMHandler.DoFlash(mo,Color(str/2,192,255,160),30); + SWWMHandler.DoFlash(mo,Color(str/2,192,255,160),50); } override void PostBeginPlay() { diff --git a/zscript/swwm_tastytreat.zsc b/zscript/swwm_tastytreat.zsc index 780d7e116..ec46691e6 100644 --- a/zscript/swwm_tastytreat.zsc +++ b/zscript/swwm_tastytreat.zsc @@ -230,20 +230,12 @@ Class CandyPop : Actor } void FlashPlayer( int str, double rad ) { - double vfov = CVar.GetCVar('fov',players[consoleplayer]).GetFloat()*0.5; - double hfov = atan(Screen.GetAspectRatio()*tan(vfov)); - let mo = players[consoleplayer].camera; - Vector3 pp; - if ( !CheckSight(mo) ) return; - if ( mo is 'PlayerPawn' ) pp = mo.Vec2OffsetZ(0,0,PlayerPawn(mo).player.viewz); - else pp = mo.Vec3Offset(0,0,mo.CameraHeight); - Vector3 sc = level.SphericalCoords(pp,pos,(mo.angle,mo.pitch)); - if ( (abs(sc.x) < hfov) && (abs(sc.y) < vfov) && (sc.z < rad) ) - { - str = int(str*(1.-(sc.z/rad))); - SWWMHandler.DoFlash(mo,Color(str,250,240,255),1); - SWWMHandler.DoFlash(mo,Color(str,224,0,255),3); - } + if ( !SWWMUtility.InPlayerFOV(players[consoleplayer],self,rad) ) return; + let mo = players[consoleplayer].Camera; + double dist = Distance3D(mo); + str = int(str*(1.-(dist/rad))); + SWWMHandler.DoFlash(mo,Color(str,250,240,255),1); + SWWMHandler.DoFlash(mo,Color(str,224,0,255),3); } override void Tick() { diff --git a/zscript/swwm_thinkers.zsc b/zscript/swwm_thinkers.zsc index 1ef565663..506a9b33d 100644 --- a/zscript/swwm_thinkers.zsc +++ b/zscript/swwm_thinkers.zsc @@ -348,7 +348,8 @@ Class SWWMLoreLibrary : Thinker if ( !c || (c == 'SWWMCollectable') ) continue; let def = GetDefaultByType(c); // skip if we match and it's not for this game - if ( (c.GetClassName() != ref) && !(gameinfo.gametype&def.avail) ) return true; + if ( (c.GetClassName() == ref) && !(gameinfo.gametype&def.avail) ) + return true; } ref = ref.MakeUpper(); String tag = String.Format("SWWM_LORETAG_%s",ref); @@ -449,17 +450,6 @@ Class SWWMLoreLibrary : Thinker if ( (level.maptime > 0) && (gametic > lastaddtic) && (myplayer == players[consoleplayer]) && (!menuactive || (menuactive == Menu.OnNoPause)) && (myplayer.mo is 'Demolitionist') ) Console.Printf(StringTable.Localize("$SWWM_NEWLORE")); lastaddtic = gametic; - // sorted add - String loca = StringTable.Localize(e.tag), locb; - int cpa, cpb; - for ( int i=0; i 0) && (mytarget.target.player == players[consoleplayer]) && (mytarget.Vec3To(mytarget.target).length() < 2000) && mytarget.CheckSight(mytarget.target) ) updated = level.maptime+70; + if ( !straifu && mytarget.target && (mytarget.target.Health > 0) && (mytarget.target.player == players[consoleplayer]) && (mytarget.Vec3To(mytarget.target).length() < 2000) && mytarget.CheckSight(mytarget.target,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) ) updated = level.maptime+70; // players (but not voodoo dolls), always visible in sp/coop if ( !deathmatch && mytarget.player && (mytarget.player.mo == mytarget) ) updated = level.maptime+35; // any visible enemies within 600mu - if ( (mytarget.Vec3To(players[consoleplayer].mo).length() < 600) && players[consoleplayer].mo.CheckSight(mytarget) ) updated = level.maptime; + if ( (mytarget.Vec3To(players[consoleplayer].mo).length() < 600) && players[consoleplayer].mo.CheckSight(mytarget,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) ) updated = level.maptime; } else if ( mytarget is 'BossBrain' ) { // teh romero, only if visible - if ( (mytarget.Vec3To(players[consoleplayer].mo).length() < 600) && players[consoleplayer].mo.CheckSight(mytarget) ) updated = level.maptime; + if ( (mytarget.Vec3To(players[consoleplayer].mo).length() < 600) && players[consoleplayer].mo.CheckSight(mytarget,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) ) updated = level.maptime; } } } diff --git a/zscript/swwm_utility.zsc b/zscript/swwm_utility.zsc index f4313a5c4..0ff9aff26 100644 --- a/zscript/swwm_utility.zsc +++ b/zscript/swwm_utility.zsc @@ -677,6 +677,21 @@ Class SWWMUtility } // TODO destructible geometry support } + + static play bool InPlayerFOV( PlayerInfo p, Actor a, double maxdist = 0. ) + { + double vfov = CVar.GetCVar('fov',p).GetFloat()*0.5; + double hfov = atan(Screen.GetAspectRatio()*tan(vfov)); + let mo = p.camera; + Vector3 pp; + if ( !mo.CheckSight(a,SF_IGNOREVISIBILITY|SF_IGNOREWATERBOUNDARY) ) return false; + if ( mo is 'PlayerPawn' ) pp = mo.Vec2OffsetZ(0,0,PlayerPawn(mo).player.viewz); + else pp = mo.Vec3Offset(0,0,mo.CameraHeight); + Vector3 sc = level.SphericalCoords(pp,a.pos,(mo.angle,mo.pitch)); + if ( (abs(sc.x) > hfov) && (abs(sc.y) > vfov) ) return false; + if ( (maxdist > 0.) && (sc.z < maxdist) ) return false; + return true; + } } Class RadiusDebugSphere : Actor diff --git a/zscript/swwm_vanillaboss.zsc b/zscript/swwm_vanillaboss.zsc index 6e70d047a..c1dd2a2b5 100644 --- a/zscript/swwm_vanillaboss.zsc +++ b/zscript/swwm_vanillaboss.zsc @@ -257,7 +257,7 @@ Class SWWMVanillaBossHandler : EventHandler for ( int i=0; i