diff --git a/language.version b/language.version index a2c19c6fc..fb9e4ef0b 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r677 \cu(Sat 10 Dec 12:59:40 CET 2022)\c-"; -SWWM_SHORTVER="\cw1.3pre r677 \cu(2022-12-10 12:59:40)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r678 \cu(Sat 10 Dec 22:17:06 CET 2022)\c-"; +SWWM_SHORTVER="\cw1.3pre r678 \cu(2022-12-10 22:17:06)\c-"; diff --git a/zscript/dlc1/swwm_hammertime.zsc b/zscript/dlc1/swwm_hammertime.zsc index 1223fa920..d5e8aa2e2 100644 --- a/zscript/dlc1/swwm_hammertime.zsc +++ b/zscript/dlc1/swwm_hammertime.zsc @@ -267,14 +267,14 @@ Class ItamexHammer : SWWMWeapon Wait; AltRelease: XZW4 V 1 A_AltRelease(); - XZW4 WXYZ 1 A_BumpPitch(2.); - XZW5 A 1 A_BumpPitch(3.); + XZW4 WXYZ 1 A_BumpView(2.); + XZW5 A 1 A_BumpView(3.); XZW5 B 1 { - A_BumpPitch(3.); + A_BumpView(3.); A_HammerAltHit(); } - XZW5 CD 1 A_BumpPitch(4.); + XZW5 CD 1 A_BumpView(4.); XZW5 E 1 A_AltHit(); XZW5 FGHIJKLMN 2; XZW5 O 2 A_StartSound("itamex/meleeend",CHAN_WEAPON,CHANF_OVERLAP); @@ -283,13 +283,17 @@ Class ItamexHammer : SWWMWeapon Goto Ready; Zoom: XZW2 A 2 A_StartSound("itamex/meleestart",CHAN_WEAPON,CHANF_OVERLAP); - XZW5 XYZ 2; + XZW5 XYZ 2 A_BumpAngle(-5); XZW6 ABCDEF 1 A_ChargeUp(); XZW6 G 0 A_SpinReact(); XZW6 G 1 A_SpinMove(); Wait; ZoomEnd: - XZW6 GHIJ 1 A_ChargeDown(); + XZW6 GHIJ 1 + { + A_ChargeDown(); + A_BumpAngle(10); + } XZW6 K 1 { A_ChargeDown(); diff --git a/zscript/dlc1/swwm_heavymahsheengun.zsc b/zscript/dlc1/swwm_heavymahsheengun.zsc index 9754363a0..e5467c21e 100644 --- a/zscript/dlc1/swwm_heavymahsheengun.zsc +++ b/zscript/dlc1/swwm_heavymahsheengun.zsc @@ -82,8 +82,8 @@ Class HeavyMahSheenGun : SWWMWeapon action void A_DropCasing() { Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),4*x+8*y-12*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,4,8,-12); let c = Spawn("SheenCasing",origin); c.angle = angle; c.pitch = pitch; @@ -102,9 +102,8 @@ Class HeavyMahSheenGun : SWWMWeapon invoker.stopfire = ((invoker.Ammo1.Amount<=1)||!(player.cmd.buttons&BT_ATTACK)||(player.Health<=0)); invoker.barrelheat = invoker.barrelheat*(1.025-invoker.firespeed*.008)+3.-(invoker.firespeed**.8)*1.35; invoker.aimerror = min(1.,invoker.aimerror*1.01+.01+invoker.firespeed*.01); - Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x-4*z); + Vector3 x = SWWMUtility.GetPlayerViewDir(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,0,-4); SWWMHandler.DoFlash(self,Color(32,255,224,64),3); A_SWWMFlash(); if ( invoker.firespeed == 1 ) @@ -147,7 +146,7 @@ Class HeavyMahSheenGun : SWWMWeapon invoker.fired = gametic; // dakka dakka dakka Vector3 x2, y2, z2; - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); double a = FRandom[Sheen](0,360), s = FRandom[Sheen](.002,.02)*spreadfct; Vector3 dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); if ( !invoker.st ) invoker.st = new("PiercingTracer"); diff --git a/zscript/dlc1/swwm_mister.zsc b/zscript/dlc1/swwm_mister.zsc index eb4168b6b..6e998557f 100644 --- a/zscript/dlc1/swwm_mister.zsc +++ b/zscript/dlc1/swwm_mister.zsc @@ -352,8 +352,8 @@ Class MisterRifle : SWWMWeapon if ( !invoker.waschambered ) return; // brass it up (though it's not made of brass) Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),2*x+3*y-18*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,2,3,-18); let c = Spawn("MisterCasing",origin); c.angle = angle; c.pitch = pitch; @@ -397,8 +397,8 @@ Class MisterRifle : SWWMWeapon if ( swwm_nomagdrop ) return; // drop it Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),6*x+3*y-18*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,6,3,-18); let c = Spawn("MisterMag",origin); c.angle = angle; c.pitch = pitch; @@ -464,9 +464,8 @@ Class MisterRifle : SWWMWeapon return ResolveState("FireStream"); } SWWMHandler.DoFlash(self,Color(48,64,224,255),3); - Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+2.8*y-2.4*z); + Vector3 x = SWWMUtility.GetPlayerViewDir(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,2.8,-2.4); if ( invoker.firemode == 1 ) { // cluster shot @@ -485,7 +484,7 @@ Class MisterRifle : SWWMWeapon s.SetShade(Color(0,3,4)*Random[ExploS](48,63)); } Vector3 x2, y2, z2; - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); double a, s; Vector3 dir; for ( int i=0; i<8; i++ ) @@ -570,7 +569,7 @@ Class MisterRifle : SWWMWeapon s.vel += vel*.5+x*FRandom[Mister](1.,2.); s.SetShade(Color(0,3,4)*Random[ExploS](48,63)); } - Vector3 dir = SWWMUtility.Vec3FromAngles(angle,BulletSlope()); + Vector3 dir = SWWMUtility.GetPlayerAimDir(self); FLineTraceData d; LineTrace(atan2(dir.y,dir.x),10000,asin(-dir.z),TRF_ABSPOSITION|TRF_NOSKY,origin.z,origin.x,origin.y,d); SWWMBulletTrail.DoTrail(self,origin,dir,10000,2); @@ -630,9 +629,8 @@ Class MisterRifle : SWWMWeapon SWWMHandler.DoFlash(self,Color(32,64,224,255),2); A_SWWMFlash("FastFlash"); } - Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+2.8*y-2.4*z); + Vector3 x = SWWMUtility.GetPlayerViewDir(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,2.8,-2.4); SWWMUtility.DoKnockback(self,-x,5000.); A_QuakeEx(3,3,3,5,0,10,"",QF_RELATIVE|QF_SCALEDOWN|QF_3D,rollIntensity:.4); A_BumpFOV(.97); @@ -647,7 +645,7 @@ Class MisterRifle : SWWMWeapon s.SetShade(Color(0,3,4)*Random[ExploS](48,63)); } Vector3 x2, y2, z2; - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); static const double spd[] = {.00,.01,.03,.06,.10}; double a = FRandom[Mister](0,360), s = FRandom[Mister](spd[index],spd[index+1]); Vector3 dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); @@ -750,9 +748,8 @@ Class MisterRifle : SWWMWeapon invoker.prefirecnt = 0; A_StopSound(CHAN_WEAPONEXTRA); A_PlayerFire(); - Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+2.8*y-2.4*z); + Vector3 x = SWWMUtility.GetPlayerViewDir(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,2.8,-2.4); SWWMHandler.DoFlash(self,Color(64,64,224,255),9); A_SWWMFlash(); invoker.fired = true; @@ -770,7 +767,7 @@ Class MisterRifle : SWWMWeapon s.SetShade(Color(0,3,4)*Random[ExploS](48,63)); } Vector3 dir, startdir; - startdir = dir = SWWMUtility.Vec3FromAngles(angle,BulletSlope()); + startdir = dir = SWWMUtility.GetPlayerAimDir(self); let mrt = new("MisterRailTracer"); // I pity the fool mrt.ignoreme = self; mrt.hitlist.Clear(); @@ -1108,9 +1105,8 @@ Class MisterRifle : SWWMWeapon action void A_MisterFireGrenade() { A_PlayerFire(); - Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+2.8*y-4.*z); + Vector3 x = SWWMUtility.GetPlayerViewDir(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,2.8,-4); SWWMHandler.DoFlash(self,Color(64,64,224,255),3); A_SWWMFlash("AltFlash"); invoker.gfired = true; @@ -1127,7 +1123,7 @@ Class MisterRifle : SWWMWeapon s.vel += vel*.5+x*FRandom[Mister](1.,4.); s.SetShade(Color(0,3,4)*Random[ExploS](48,63)); } - Vector3 dir = SWWMUtility.Vec3FromAngles(angle,BulletSlope()); + Vector3 dir = SWWMUtility.GetPlayerAimDir(self); let p = Spawn("MisterGrenade",origin); p.target = self; p.angle = atan2(dir.y,dir.x); @@ -1165,8 +1161,8 @@ Class MisterRifle : SWWMWeapon if ( !invoker.wasgchambered ) return; // droppage Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),8*x+3*y-18*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,8,3,-18); let c = Spawn("MisterGCasing",origin); c.angle = angle; c.pitch = pitch; diff --git a/zscript/dlc1/swwm_notashotgun.zsc b/zscript/dlc1/swwm_notashotgun.zsc index e0b6894af..9715bdc51 100644 --- a/zscript/dlc1/swwm_notashotgun.zsc +++ b/zscript/dlc1/swwm_notashotgun.zsc @@ -49,10 +49,10 @@ Class Quadravol : SWWMWeapon A_StartSound("quadshot/fire"..BaseNum[idx],CHAN_WEAPON,CHANF_OVERLAP); A_PlayerFire(); Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); double offy = invoker.onehand?3.5:3; - double offz = invoker.onehand?2:2.5; - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+offy*y-offz*z); + double offz = invoker.onehand?-2:-2.5; + Vector3 origin = SWWMUtility.GetFireOffset(self,10,offy,offz); bool pointblank = false; int rings = 1; Vector3 dir; @@ -78,7 +78,7 @@ Class Quadravol : SWWMWeapon if ( bMelee && fool ) SWWMUtility.AchievementProgressInc("roast",1,player); if ( bMelee || fool || (idx>=4) ) A_StartSound("quadshot/pointblank",CHAN_WEAPON,CHANF_OVERLAP,.6+idx*.1,.4-idx*.05,1.2-idx*.05); Vector3 x2, y2, z2; - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); double a, s; Actor p; bool bExtra = ((idx>=4)&&invoker.chambered&&!invoker.charged); @@ -301,8 +301,8 @@ Class Quadravol : SWWMWeapon action void A_DropCasing() { Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),-8*x+8*y-16*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,-8,8,-16); if ( invoker.wascharged ) { let c = Spawn("QuadravolCasing",origin); diff --git a/zscript/swwm_gesture.zsc b/zscript/swwm_gesture.zsc index 455ff7723..8d17490fc 100644 --- a/zscript/swwm_gesture.zsc +++ b/zscript/swwm_gesture.zsc @@ -270,11 +270,10 @@ Class SWWMGesture : SWWMWeapon { let weap = Weapon(invoker); if ( !weap ) return; - Vector3 x, y, z, x2, y2, z2; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x-2*y-3*z); + Vector3 x2, y2, z2; + Vector3 origin = SWWMUtility.GetFireOffset(self,10,-2,-3); double a = FRandom[Spread](0,360), s = FRandom[Spread](0,.005); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); Vector3 dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); let p = Spawn("ExplodiumMagProj",origin); p.special1 = 7; @@ -293,11 +292,9 @@ Class SWWMGesture : SWWMWeapon { let weap = Weapon(invoker); if ( !weap ) return false; - Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,0,0); FLineTraceData d; - LineTrace(angle,DEFMELEERANGE*1.5,pitch,TRF_ABSPOSITION|TRF_THRUACTORS|TRF_NOSKY,origin.z,origin.x,origin.y,d); + LineTrace(angle+viewangle,DEFMELEERANGE*1.5,pitch+viewpitch,TRF_ABSPOSITION|TRF_THRUACTORS|TRF_NOSKY,origin.z,origin.x,origin.y,d); return (d.HitType != TRACE_HitNone); } @@ -305,9 +302,8 @@ Class SWWMGesture : SWWMWeapon { let weap = Weapon(invoker); if ( !weap ) return; - Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x); + Vector3 x = SWWMUtility.GetPlayerViewDir(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,0,0); let p = Spawn("ExplodiumMagAttach",origin); p.special1 = 7; p.target = self; @@ -328,16 +324,15 @@ Class SWWMGesture : SWWMWeapon A_StartSound("demolitionist/blowkiss",CHAN_DEMOVOICE,CHANF_OVERLAP,.4); let weap = Weapon(invoker); if ( !weap ) return; - Vector3 x, y, z, x2, y2, z2, dir; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x-1*z); + Vector3 x2, y2, z2, dir; + Vector3 origin = SWWMUtility.GetFireOffset(self,10,0,-1); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); let p = Spawn("LoveHeart",origin); p.target = self; - p.angle = angle; - p.pitch = BulletSlope(); - p.vel = SWWMUtility.Vec3FromAngles(p.angle,p.pitch)*p.speed; + p.angle = atan2(x2.y,x2.x); + p.pitch = asin(-x2.z); + p.vel = x2*p.speed; // try to catch target in cone of vision - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); Array hits; hits.Clear(); int rings = 1; diff --git a/zscript/swwm_player.zsc b/zscript/swwm_player.zsc index 324e82cf1..53c918e2a 100644 --- a/zscript/swwm_player.zsc +++ b/zscript/swwm_player.zsc @@ -45,7 +45,7 @@ Class Demolitionist : PlayerPawn double guideangle, guidepitch, guideroll; // for weapon bobbing stuff - Array bumpvelz, bumppitch; + double bumpvelz, bumpangle, bumppitch, bumproll; double oldangle, oldpitch; double oldlagangle, oldlagpitch, oldlagready; Vector3 oldlagvel; @@ -616,6 +616,28 @@ Class Demolitionist : PlayerPawn if ( !EventHandler.Find("SWWMHandler") || !StaticEventHandler.Find("SWWMStaticHandler") ) ThrowAbortException("Panic! SWWM event handlers not detected!"); } + void BumpView( double str, Vector3 dir = (0,0,0) ) + { + double dirlen = dir.length(); + if ( dirlen < double.epsilon ) + { + bumppitch += str; + return; + } + dir /= dirlen; + Vector3 x, y; + Quat r = Quat.FromAngles(angle+viewangle,pitch+viewpitch,roll+viewroll); + x = r*(1,0,0); + y = r*(0,-1,0); + double sx = dir dot x; + double sy = dir dot y; + if ( !sx && !sy ) bumppitch += str; + else + { + bumppitch += str*sx; + bumproll += str*sy; + } + } void A_Dash() { vel += dashdir*dashboost*clamp(dashfuel/20.,0.,1.); @@ -851,8 +873,8 @@ Class Demolitionist : PlayerPawn return; if ( !itrace ) itrace = new("SWWMItemTracer"); Vector3 x, y, z, dir; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = Vec2OffsetZ(0,0,player.viewz); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetPlayerEye(self); Sector os = level.PointInSector(origin.xy); int rings = 1; Array ignoreme; @@ -1245,15 +1267,15 @@ Class Demolitionist : PlayerPawn if ( player.onground && !bNoGravity && !lastground ) { // bump down weapon - bumpvelz.Push(-lastvelz); - double bpitch = min(-lastvelz/10.,20); + bumpvelz -= lastvelz; + BumpView(min(-lastvelz/10.,20),vel); if ( lastvelz < -25 ) { let s = Spawn("DemolitionistShockwave",pos); s.target = self; s.special1 = int(-lastvelz); A_AlertMonsters(swwm_uncapalert?0:2500); - bpitch = min(bpitch+30,60); + bumppitch = min(bumppitch+30,60); lastbump *= 1.3; if ( FindInventory("RagekitPower") ) { @@ -1274,13 +1296,8 @@ Class Demolitionist : PlayerPawn } mystats.stompcount++; } - double newp = min(90,pitch+bpitch); - bumppitch.Push(newp-pitch); - A_SetPitch(newp,SPF_INTERPOLATE); if ( lastvelz < -10 ) - { A_StartSound("demolitionist/runstop",CHAN_FOOTSTEP,CHANF_OVERLAP); - } if ( (lastvelz < -gruntspeed) && (swwm_mutevoice < 4) && (health > 0) ) { int loudlv = swwm_voiceamp; @@ -1363,20 +1380,30 @@ Class Demolitionist : PlayerPawn } } } - for ( int i=0; i double.epsilon ) { - lagvel.z += bumpvelz[i]*.2; - bumpvelz[i] *= .8; - if ( abs(bumpvelz[i]) > double.epsilon ) continue; - bumpvelz.Delete(i--); + lagvel.z += bumpvelz*.2; + bumpvelz *= .8; } - for ( int i=0; i double.epsilon ) { - A_SetPitch(pitch-bumppitch[i]/5.,SPF_INTERPOLATE); - bumppitch[i] *= .8; - if ( abs(bumppitch[i]) > double.epsilon ) continue; - bumppitch.Delete(i--); + ViewAngle += bumpangle*.5; + bumpangle *= .8; } + if ( abs(bumppitch) > double.epsilon ) + { + ViewPitch += bumppitch*.5; + bumppitch *= .8; + } + if ( abs(bumproll) > double.epsilon ) + { + ViewRoll += bumproll*.5; + bumproll *= .8; + } + // stabilize view angles + ViewAngle *= .8; + ViewPitch *= .8; + ViewRoll *= .8; if ( player.onground && !lastground ) landvelz = lastvelz; else if ( !player.onground && lastground ) landvelz = 0; else if ( player.onground && lastground ) landvelz *= .9; @@ -2289,9 +2316,7 @@ Class Demolitionist : PlayerPawn A_StartSound("demolitionist/jet",CHAN_JETPACK,CHANF_LOOP); lastbump *= .95; mystats.dashcount++; - double newp = min(90.,pitch+5.); - bumppitch.Push(newp-pitch); - A_SetPitch(newp,SPF_INTERPOLATE); + BumpView(5.,vel); } } override void CheckJump() @@ -2453,19 +2478,13 @@ Class Demolitionist : PlayerPawn lastbump *= .95; mystats.boostcount++; last_boost = level.maptime+1; - double newp = min(90.,pitch+3.); - bumppitch.Push(newp-pitch); - A_SetPitch(newp,SPF_INTERPOLATE); + BumpView(3.,vel); SetStateLabel("Boost"); } else { A_StartSound(walljump?"demolitionist/kick":"demolitionist/runstart",CHAN_FOOTSTEP,CHANF_OVERLAP); dashboost = 0.; - double bpitch = clamp((vel.length()-10)/5.,0.,20.); - double newp = min(90.,pitch+bpitch); - bumppitch.Push(newp-pitch); - A_SetPitch(newp,SPF_INTERPOLATE); // bunnyhop time if ( !walljump && !wallclimb ) { @@ -2496,6 +2515,7 @@ Class Demolitionist : PlayerPawn vel.xy += (RotateVector(NormalizedMove(),angle)/1500.)*(raging?2.:1.)*TweakSpeed(); } } + BumpView(clamp((vel.length()-10)/8.,1.,20.),vel); if ( swwm_mutevoice < 4 ) { int loudlv = swwm_voiceamp; diff --git a/zscript/swwm_utility.zsc b/zscript/swwm_utility.zsc index 4abddf6f1..c76c03add 100644 --- a/zscript/swwm_utility.zsc +++ b/zscript/swwm_utility.zsc @@ -257,6 +257,51 @@ Class SWWMUtility return r*x,r*y,r*z; } + // for aiming and shooting + static clearscope Vector3 GetPlayerViewDir( Actor player ) + { + Quat r = Quat.FromAngles(player.angle+player.viewangle,player.pitch+player.viewpitch,player.roll+player.viewroll); + return r*(1,0,0); + } + static play Vector3 GetPlayerAimDir( Actor player ) + { + FTranslatedLineTarget t; + double pitch = player.BulletSlope(t); + Quat r; + if ( !t.linetarget ) r = Quat.FromAngles(player.angle+player.viewangle,player.pitch+player.viewpitch,player.roll+player.viewroll); + else r = Quat.FromAngles(player.angle+player.viewangle,pitch,player.roll+player.viewroll); + return r*(1,0,0); + } + static clearscope Vector3, Vector3, Vector3 GetPlayerAxes( Actor player ) + { + return GetAxes(player.angle+player.viewangle,player.pitch+player.viewpitch,player.roll+player.viewroll); + } + static play Vector3, Vector3, Vector3 GetPlayerAxesAutoAimed( Actor player ) + { + FTranslatedLineTarget t; + double pitch = player.BulletSlope(t); + if ( !t.linetarget ) return GetAxes(player.angle+player.viewangle,player.pitch+player.viewpitch,player.roll+player.viewroll); + return GetAxes(player.angle+player.viewangle,pitch,player.roll+player.viewroll); + } + static clearscope Vector3 GetPlayerEye( Actor player ) + { + if ( !player.viewpos ) + return player.Vec2OffsetZ(0,0,player.player.viewz); + if ( player.viewpos.flags&VPSF_ABSOLUTEPOS ) + return player.viewpos.offset; + Vector3 origin = player.Vec2OffsetZ(0,0,player.player.viewz); + if ( player.viewpos.flags&VPSF_ABSOLUTEOFFSET ) + return level.Vec3Offset(origin,player.viewpos.offset); + Quat r = Quat.FromAngles(player.angle,player.pitch,player.roll); // viewangles are not used + return level.Vec3Offset(origin,r*player.viewpos.offset); + } + static clearscope Vector3 GetFireOffset( Actor player, double x, double y, double z ) + { + Vector3 origin = GetPlayerEye(player); + Quat r = Quat.FromAngles(player.angle+player.viewangle,player.pitch+player.viewpitch,player.roll+player.viewroll); + return level.Vec3Offset(origin,r*(x,-y,z)); + } + // thanks zscript static clearscope double fract( double a ) { diff --git a/zscript/weapons/swwm_baseweapon.zsc b/zscript/weapons/swwm_baseweapon.zsc index d8060f072..dc035537e 100644 --- a/zscript/weapons/swwm_baseweapon.zsc +++ b/zscript/weapons/swwm_baseweapon.zsc @@ -183,11 +183,15 @@ Class SWWMWeapon : Weapon abstract Demolitionist(self).lastbump *= factor; } - action void A_BumpPitch( double factor ) + action void A_BumpView( double factor, Vector3 dir = (0,0,0) ) { if ( !(self is 'Demolitionist') ) return; - Demolitionist(self).bumppitch.Push(factor); - A_SetPitch(pitch+factor,SPF_INTERPOLATE); + Demolitionist(self).BumpView(factor,dir); + } + action void A_BumpAngle( double factor ) + { + if ( !(self is 'Demolitionist') ) return; + Demolitionist(self).bumpangle += factor; } // subtracts given ammo from price, drops excess diff --git a/zscript/weapons/swwm_baseweapon_fx.zsc b/zscript/weapons/swwm_baseweapon_fx.zsc index 187778cf9..e11a9025b 100644 --- a/zscript/weapons/swwm_baseweapon_fx.zsc +++ b/zscript/weapons/swwm_baseweapon_fx.zsc @@ -163,14 +163,8 @@ Class SWWMWeaponLight : DynamicLight Destroy(); return; } - if ( target.player ) - { - Vector3 x, y, z, origin; - [x, y, z] = SWWMUtility.GetAxes(target.angle,target.pitch,target.roll); - origin = level.Vec3Offset(target.Vec2OffsetZ(0,0,target.player.viewz),x*12); - SetOrigin(origin,true); - } - else SetOrigin(target.pos,true); + if ( target.player ) SetOrigin(SWWMUtility.GetFireOffset(target,10,0,0),true); + else SetOrigin(target.Vec3Angle(10,target.angle,target.missileheight),true); if ( cnt++ > 2 ) Destroy(); } } diff --git a/zscript/weapons/swwm_baseweapon_melee.zsc b/zscript/weapons/swwm_baseweapon_melee.zsc index d8d651fbc..23363c276 100644 --- a/zscript/weapons/swwm_baseweapon_melee.zsc +++ b/zscript/weapons/swwm_baseweapon_melee.zsc @@ -109,10 +109,7 @@ Class ParryField : SWWMNonInteractiveActor Destroy(); return; } - Vector3 x, y, z, origin; - [x, y, z] = SWWMUtility.GetAxes(master.angle,master.pitch,master.roll); - origin = level.Vec3Offset(master.Vec2OffsetZ(0,0,master.player.viewz),x*20); - SetOrigin(origin,false); + SetOrigin(SWWMUtility.GetFireOffset(master,20,0,0),false); let raging = RagekitPower(master.FindInventory("RagekitPower")); let s = Demolitionist(master).mystats; // check for projectiles to deflect @@ -361,11 +358,8 @@ extend Class SWWMWeapon action void A_Parry( int duration ) { - Vector3 x, y, z, origin; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),x*20-(0,0,20)); if ( invoker.pfield ) invoker.pfield.Destroy(); - invoker.pfield = Spawn("ParryField",origin); + invoker.pfield = Spawn("ParryField",SWWMUtility.GetFireOffset(self,20,0,0)); invoker.pfield.master = self; invoker.pfield.special1 = duration; invoker.pfield.special2 = duration; @@ -376,8 +370,8 @@ extend Class SWWMWeapon private action bool TryMelee( double spread, int dmg, String hitsound, double rangemul, double kickmul, int flags, Class impactclass ) { Vector3 x, y, z, dir; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = Vec2OffsetZ(0,0,player.viewz); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetPlayerEye(self); if ( !invoker.mt ) invoker.mt = new("MeleeTracer"); let mt = invoker.mt; // for convenience mt.ignoreme = self; diff --git a/zscript/weapons/swwm_blazeit.zsc b/zscript/weapons/swwm_blazeit.zsc index 7574d769b..b17cbd42d 100644 --- a/zscript/weapons/swwm_blazeit.zsc +++ b/zscript/weapons/swwm_blazeit.zsc @@ -68,10 +68,10 @@ Class Hellblazer : SWWMWeapon invoker.spinskipped++; Vector3 x, y, z, x2, y2, z2, dir, origin; double a, s; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); SWWMUtility.DoKnockback(self,-x,bAlt?22000.:32000.); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); - origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+3.5*y-5*z); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); + origin = SWWMUtility.GetFireOffset(self,10,3.5,-5); a = FRandom[Hellblazer](0,360); s = FRandom[Hellblazer](0,bAlt?.02:.005); dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); @@ -215,10 +215,10 @@ Class Hellblazer : SWWMWeapon action void A_CheckLockOn() { if ( invoker.seekcnt > invoker.preload ) return; - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*SWWMUtility.Vec3FromAngles(angle,pitch)); + Vector3 origin = SWWMUtility.GetPlayerEye(self); // try to catch target in cone of vision Vector3 x, y, z, dir; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); Array hits; hits.Clear(); int rings = 1; diff --git a/zscript/weapons/swwm_cbt.zsc b/zscript/weapons/swwm_cbt.zsc index b6e83b8ae..9af57963d 100644 --- a/zscript/weapons/swwm_cbt.zsc +++ b/zscript/weapons/swwm_cbt.zsc @@ -195,8 +195,8 @@ Class Wallbuster : SWWMWeapon } Vector3 x, y, z, origin, x2, y2, z2, dir; double a, s; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); int flashstr = 0; int alertness = 0; // second pass, play the fire effects @@ -248,7 +248,7 @@ Class Wallbuster : SWWMWeapon l.target = self; } // third pass, actually fire them - Vector3 base = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+3.5*y-6*z); + Vector3 base = SWWMUtility.GetFireOffset(self,10,3.5,-6); SpreadgunTracer st; for ( int i=0; i list; @@ -265,12 +264,12 @@ Class DeepImpact : SWWMWeapon A_AlertMonsters(swwm_uncapalert?0:8000); A_PlayerFire(); invoker.clipcount = 0; - Vector3 x, y, z, x2, y2, z2; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); + Vector3 x, x2, y2, z2; + x = SWWMUtility.GetPlayerViewDir(self); SWWMUtility.DoKnockback(self,-x,42000.); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+2*y-3*z); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,2,-3); double a = FRandom[Spread](0,360), s = FRandom[Spread](0,.002); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); Vector3 dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); let p = Spawn("AirBullet",origin); p.target = self; diff --git a/zscript/weapons/swwm_shot.zsc b/zscript/weapons/swwm_shot.zsc index 11312c21f..475988b7a 100644 --- a/zscript/weapons/swwm_shot.zsc +++ b/zscript/weapons/swwm_shot.zsc @@ -142,8 +142,8 @@ Class Spreadgun : SWWMWeapon return; } Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x-10*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,0,-10); let c = Spawn(invoker.wasgold?"GoldShellCasing":"RedShellCasing",origin); c.angle = angle; c.pitch = pitch; @@ -250,10 +250,10 @@ Class Spreadgun : SWWMWeapon } A_PlayerFire(); Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+2*y-2*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,2,-2); Vector3 x2, y2, z2; - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); double a, s; Vector3 dir; if ( invoker.goldload ) diff --git a/zscript/weapons/swwm_sparkyboi.zsc b/zscript/weapons/swwm_sparkyboi.zsc index 585000f2d..f14bf532b 100644 --- a/zscript/weapons/swwm_sparkyboi.zsc +++ b/zscript/weapons/swwm_sparkyboi.zsc @@ -38,9 +38,10 @@ Class Sparkster : SWWMWeapon else invoker.clipcount = 0; } else invoker.clipcount = max(0,invoker.clipcount-1); - Vector3 x, y, z, x2, y2, z2, dir; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+4.5*y-5*z); + Vector3 x, x2, y2, z2, dir; + x = SWWMUtility.GetPlayerViewDir(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,4.5,-5); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); double a, s; Actor p; switch ( mode ) @@ -56,7 +57,6 @@ Class Sparkster : SWWMWeapon A_PlayerFire(); a = FRandom[Spread](0,360); s = FRandom[Spread](0,.007); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); p = Spawn("BiosparkBall",origin); p.target = self; @@ -76,7 +76,6 @@ Class Sparkster : SWWMWeapon A_PlayerFire(); a = FRandom[Spread](0,360); s = FRandom[Spread](0,.003); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); p = Spawn("BiosparkBeam",origin); p.target = self; @@ -95,7 +94,6 @@ Class Sparkster : SWWMWeapon SWWMUtility.DoKnockback(self,-x,2500.); a = FRandom[Spread](0,360); s = FRandom[Spread](0,.012); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); p = Spawn("BiosparkCore",origin); p.target = self; @@ -117,15 +115,15 @@ Class Sparkster : SWWMWeapon { if ( swwm_nomagdrop ) return; Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x-2*y-10*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,-2,-10); let c = Spawn("SparksterMag",origin); c.angle = angle; c.pitch = pitch; c.vel = x*FRandom[Junk](-.5,.5)+y*FRandom[Junk](-1.2,.3)-(0,0,FRandom[Junk](2,3)); c.vel += vel*.5; if ( !stacc ) return; - origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),8*x-2*y-12*z); + origin = SWWMUtility.GetFireOffset(self,8,-2,-12); c = Spawn("SparksterMag",origin); c.angle = angle; c.pitch = pitch; diff --git a/zscript/weapons/swwm_splode.zsc b/zscript/weapons/swwm_splode.zsc index d0a745ba4..f90ac9b59 100644 --- a/zscript/weapons/swwm_splode.zsc +++ b/zscript/weapons/swwm_splode.zsc @@ -84,12 +84,12 @@ Class ExplodiumGun : SWWMWeapon SWWMHandler.DoFlash(self,Color(64,255,224,64),3); A_AlertMonsters(swwm_uncapalert?0:5000); A_PlayerFire(); - Vector3 x, y, z, x2, y2, z2; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); + Vector3 x, x2, y2, z2; + x = SWWMUtility.GetPlayerViewDir(self); SWWMUtility.DoKnockback(self,-x,4000.); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+3*y-2*z); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,3,-2); double a = FRandom[Spread](0,360), s = FRandom[Spread](0,.002); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); Vector3 dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); FLineTraceData d; LineTrace(atan2(dir.y,dir.x),10000,asin(-dir.z),TRF_ABSPOSITION|TRF_NOSKY,origin.z,origin.x,origin.y,d); @@ -170,11 +170,10 @@ Class ExplodiumGun : SWWMWeapon invoker.deadeyecnt = 0; let weap = Weapon(invoker); if ( !weap ) return; - Vector3 x, y, z, x2, y2, z2; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x-2*y-3*z); + Vector3 x2, y2, z2; + Vector3 origin = SWWMUtility.GetFireOffset(self,10,-2,-3); double a = FRandom[Spread](0,360), s = FRandom[Spread](0,.005); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); Vector3 dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); let p = Spawn("ExplodiumMagProj",origin); p.special1 = invoker.special1; @@ -196,8 +195,8 @@ Class ExplodiumGun : SWWMWeapon invoker.deadeyecnt = 0; if ( swwm_nomagdrop ) return; Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x-2*y-10*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,-2,-10); let c = Spawn("ExplodiumMag",origin); c.angle = angle; c.pitch = pitch; @@ -208,8 +207,8 @@ Class ExplodiumGun : SWWMWeapon action void A_DropCasing() { Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+8*y-10*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,8,-10); let c = Spawn("ExplodiumCasing",origin); c.angle = angle; c.pitch = pitch; @@ -621,12 +620,12 @@ Class DualExplodiumGun : SWWMWeapon SWWMHandler.DoFlash(self,Color(64,255,224,64),3); A_AlertMonsters(swwm_uncapalert?0:5000); A_PlayerFire(); - Vector3 x, y, z, x2, y2, z2; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); + Vector3 x, x2, y2, z2; + x = SWWMUtility.GetPlayerViewDir(self); SWWMUtility.DoKnockback(self,-x,4000.); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+3.5*side*y-2*z); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,3.5*side,-2); double a = FRandom[Spread](0,360), s = FRandom[Spread](0,.002); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); Vector3 dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); FLineTraceData d; LineTrace(atan2(dir.y,dir.x),10000,asin(-dir.z),TRF_ABSPOSITION|TRF_NOSKY,origin.z,origin.x,origin.y,d); @@ -707,8 +706,8 @@ Class DualExplodiumGun : SWWMWeapon ExplodiumGun(invoker.SisterWeapon).deadeyecnt = 0; if ( swwm_nomagdrop ) return; Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x-2*side*y-10*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,-2*side,-10); let c = Spawn("ExplodiumMag",origin); c.angle = angle; c.pitch = pitch; @@ -719,8 +718,8 @@ Class DualExplodiumGun : SWWMWeapon action void A_DropCasing( int side = 1 ) { Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+8*side*y-10*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,8*side,-10); let c = Spawn("ExplodiumCasing",origin); c.angle = angle; c.pitch = pitch; diff --git a/zscript/weapons/swwm_tastytreat.zsc b/zscript/weapons/swwm_tastytreat.zsc index 8a5556409..479f5493d 100644 --- a/zscript/weapons/swwm_tastytreat.zsc +++ b/zscript/weapons/swwm_tastytreat.zsc @@ -131,12 +131,12 @@ Class CandyGun : SWWMWeapon SWWMHandler.DoFlash(self,Color(64,224,64,255),5); A_AlertMonsters(swwm_uncapalert?0:9000); A_PlayerFire(); - Vector3 x, y, z, x2, y2, z2; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); + Vector3 x, x2, y2, z2; + x = SWWMUtility.GetPlayerViewDir(self); SWWMUtility.DoKnockback(self,-x,18000.); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+3*y-2*z); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,3,-2); double a = FRandom[Spread](0,360), s = FRandom[Spread](0,.005); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); Vector3 dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); FLineTraceData d; LineTrace(atan2(dir.y,dir.x),10000,asin(-dir.z),TRF_ABSPOSITION|TRF_NOSKY,origin.z,origin.x,origin.y,d); @@ -209,11 +209,10 @@ Class CandyGun : SWWMWeapon { let weap = Weapon(invoker); if ( !weap ) return; - Vector3 x, y, z, x2, y2, z2; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x-2*y-3*z); + Vector3 x2, y2, z2; + Vector3 origin = SWWMUtility.GetFireOffset(self,10,-2,-3); double a = FRandom[Spread](0,360), s = FRandom[Spread](0,.01); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); Vector3 dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); let p = Spawn("CandyMagProj",origin); p.special1 = invoker.special1; @@ -235,11 +234,10 @@ Class CandyGun : SWWMWeapon if ( weap.Ammo2.Amount <= 0 ) weap.Amount = 0; weap.Ammo2.Amount = max(0,weap.Ammo2.Amount-1); } - Vector3 x, y, z, x2, y2, z2; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x-2*y-3*z); + Vector3 x2, y2, z2; + Vector3 origin = SWWMUtility.GetFireOffset(self,10,-2,-3); double a = FRandom[Spread](0,360), s = FRandom[Spread](0,.015); - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); Vector3 dir = SWWMUtility.ConeSpread(x2,y2,z2,a,s); let p = Spawn("CandyGunProj",origin); p.special1 = invoker.clipcount+invoker.chambered; @@ -257,8 +255,8 @@ Class CandyGun : SWWMWeapon { if ( swwm_nomagdrop ) return; Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x-2*y-10*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,-2,-10); let c = Spawn("CandyMag",origin); c.angle = angle; c.pitch = pitch; @@ -309,8 +307,8 @@ Class CandyGun : SWWMWeapon action void A_DropCasing() { Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+8*y-10*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,8,-10); let c = Spawn("CandyCasing",origin); c.special1 = special1; c.angle = angle; diff --git a/zscript/weapons/swwm_thiccboolet.zsc b/zscript/weapons/swwm_thiccboolet.zsc index 46362fba4..e7790c8d6 100644 --- a/zscript/weapons/swwm_thiccboolet.zsc +++ b/zscript/weapons/swwm_thiccboolet.zsc @@ -496,11 +496,12 @@ Class SilverBullet : SWWMWeapon A_PlayerFire(); SWWMHandler.DoFlash(self,Color(110,255,192,80),8); Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = Vec2OffsetZ(0,0,player.viewz); - if ( !invoker.zoomed ) origin = level.Vec3Offset(origin,10*x+1*y-1*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin; + if ( !invoker.zoomed ) origin = SWWMUtility.GetFireOffset(self,10,1,-1); + else origin = SWWMUtility.GetPlayerEye(self); Vector3 x2, y2, z2; - [x2, y2, z2] = SWWMUtility.GetAxes(angle,BulletSlope(),roll); + [x2, y2, z2] = SWWMUtility.GetPlayerAxesAutoAimed(self); SilverBulletTracer sst = new("SilverBulletTracer"); sst.ignoreme = self; sst.penetration = invoker.proneme?1200.:1000.; @@ -555,8 +556,8 @@ Class SilverBullet : SWWMWeapon action void A_DropCasing() { Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+10*y-8*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,10,-8); let c = Spawn("SilverBulletCasing",origin); c.angle = angle; c.pitch = pitch; @@ -566,8 +567,8 @@ Class SilverBullet : SWWMWeapon action void A_DropBullet() { Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),10*x+10*y-8*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,10,10,-8); MagAmmo ma = MagAmmo(FindInventory("SilverBullets")); if ( !ma ) { @@ -616,8 +617,8 @@ Class SilverBullet : SWWMWeapon invoker.ClipCount = 0; if ( swwm_nomagdrop ) return; Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),6*x-15*z); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); + Vector3 origin = SWWMUtility.GetFireOffset(self,6,0,-15); let c = Spawn("SilverBulletMag",origin); c.angle = angle; c.pitch = pitch; @@ -628,12 +629,12 @@ Class SilverBullet : SWWMWeapon { invoker.specialf1 -= .06; Vector3 x, y, z; - [x, y, z] = SWWMUtility.GetAxes(angle,pitch,roll); + [x, y, z] = SWWMUtility.GetPlayerAxes(self); vel += x*min(1.,invoker.specialf1)*(600./Mass); A_OverlayAlpha(PSP_WEAPON+1,clamp(invoker.specialf1*3.,0.,1.)); if ( Random[SilverBullet](0,int(invoker.specialf1*2)) ) self.DamageMobj(invoker,self,1,'jet'); - Vector3 origin = level.Vec3Offset(Vec2OffsetZ(0,0,player.viewz),-x*10-z*10); + Vector3 origin = SWWMUtility.GetFireOffset(self,-10,0,-10); for ( int i=0; i<4; i++ ) { let s = Spawn("SWWMSmoke",origin);