From 9c06e76acd64f5fd81473702172fff5e9cb0fdcc Mon Sep 17 00:00:00 2001 From: Marisa Kirisame Date: Sun, 15 Mar 2020 01:05:53 +0100 Subject: [PATCH] Enhanced weapon bobbing. Rebalanced Explodium Gun damages, more reasonable for a starter weapon. Fixed ammo checks for various weapons. Also fixes Eviscerator "one in the chamber" function not working. --- zscript/swwm_danmaku.zsc | 33 +++++++++++++++-- zscript/swwm_inventory.zsc | 6 ---- zscript/swwm_player.zsc | 70 +++++++++++++++++++++++++++++++++++++ zscript/swwm_shot.zsc | 2 ++ zscript/swwm_splode.zsc | 6 ++-- zscript/swwm_tastytreat.zsc | 4 ++- 6 files changed, 108 insertions(+), 13 deletions(-) diff --git a/zscript/swwm_danmaku.zsc b/zscript/swwm_danmaku.zsc index c1afa8565..33b8a6dec 100644 --- a/zscript/swwm_danmaku.zsc +++ b/zscript/swwm_danmaku.zsc @@ -390,6 +390,7 @@ Class EvisceratorProj : Actor s.vel = pvel; s.scale *= FRandom[Eviscerator](0.9,1.8); } + Spawn("EvisceratorRing",pos); } action void A_SubExpl() { @@ -470,6 +471,27 @@ Class EvisceratorSubExpl : Actor } } +Class EvisceratorRing : Actor +{ + Default + { + RenderStyle "Add"; + Scale 4.; + Radius 0.1; + Height 0; + +NOGRAVITY; + +NOBLOCKMAP; + +FORCEXYBILLBOARD; + +NOTELEPORT; + } + States + { + Spawn: + XRG3 ABCDEFGHIJKLMNOPQRSTUVWX 1 Bright A_SetScale(scale.x*1.01); + Stop; + } +} + Class EvisceratorCasing : SWWMCasing { Default @@ -546,10 +568,13 @@ Class Eviscerator : SWWMWeapon if ( (loadtics == 9) && Owner && Owner.player && (Owner.player.ReadyWeapon == self) ) { Owner.A_StartSound("eviscerator/load",CHAN_WEAPON,CHANF_OVERLAP); + } + if ( loadtics > 20 ) + { + pendingload = false; if ( !sv_infiniteammo && !Owner.FindInventory('PowerInfiniteAmmo',true) ) Ammo1.Amount = max(0,Ammo1.Amount-1); } - if ( loadtics > 20 ) pendingload = false; } action void A_EvisceratorFire() @@ -734,8 +759,9 @@ Class Eviscerator : SWWMWeapon invoker.isfiring = false; int flg = WRF_ALLOWRELOAD|WRF_ALLOWZOOM|WRF_ALLOWUSER1; if ( invoker.pendingload ) flg |= WRF_NOFIRE; - A_CheckReload(); A_WeaponReady(flg); + if ( player.cmd.buttons&(BT_ATTACK|BT_ALTATTACK) ) + invoker.CheckAmmo(EitherFire,true); } Wait; ReadyExt: @@ -744,8 +770,9 @@ Class Eviscerator : SWWMWeapon invoker.isfiring = false; int flg = WRF_ALLOWRELOAD|WRF_ALLOWZOOM|WRF_ALLOWUSER1; if ( invoker.pendingload ) flg |= WRF_NOFIRE; - A_CheckReload(); A_WeaponReady(flg); + if ( player.cmd.buttons&(BT_ATTACK|BT_ALTATTACK) ) + invoker.CheckAmmo(EitherFire,true); } Wait; Fire: diff --git a/zscript/swwm_inventory.zsc b/zscript/swwm_inventory.zsc index 66dc296fc..76fae6375 100644 --- a/zscript/swwm_inventory.zsc +++ b/zscript/swwm_inventory.zsc @@ -661,12 +661,6 @@ Class SWWMWeapon : Weapon abstract if ( (AmmoGive2 <= 0) && (default.AmmoGive2 > 0) ) AmmoGive2 = 1; } - override void DoEffect() - { - Super.DoEffect(); - if ( Owner && Owner.player && (Owner.player.ReadyWeapon == self) ) - Owner.player.WeaponState |= WF_WEAPONBOBBING; // always bob - } Default { Weapon.BobStyle "Alpha"; diff --git a/zscript/swwm_player.zsc b/zscript/swwm_player.zsc index 33f234beb..7d39badf1 100644 --- a/zscript/swwm_player.zsc +++ b/zscript/swwm_player.zsc @@ -25,6 +25,15 @@ Class Demolitionist : PlayerPawn double guideangle, guidepitch, guideroll; + // for weapon bobbing stuff + bool bumpdown; + double bumpvelz; + double oldangle, oldpitch; + double oldlagangle, oldlagpitch, oldlagready; + Vector3 oldlagvel; + double lagangle, lagpitch, lagready; + Vector3 lagvel; + enum EUnderType { UNDER_NONE, @@ -376,10 +385,62 @@ Class Demolitionist : PlayerPawn A_SoundVolume(CHAN_AMBEXTRA,(players[consoleplayer].Camera==self)?1.:0.); lastunder = curunder; } + override Vector2 BobWeapon( double ticfrac ) + { + bool oldbob = !!(player.WeaponState&WF_WEAPONBOBBING); + player.WeaponState |= WF_WEAPONBOBBING; // always bob + Vector2 cur = Super.BobWeapon(ticfrac); + if ( !oldbob ) player.WeaponState &= ~WF_WEAPONBOBBING; + double diffang = (oldangle*(1.-ticfrac)+angle*ticfrac)-(oldlagangle*(1.-ticfrac)+lagangle*ticfrac); + double diffpitch = (oldpitch*(1.-ticfrac)+pitch*ticfrac)-(oldlagpitch*(1.-ticfrac)+lagpitch*ticfrac); + if ( abs(diffang) > 1. ) + { + int sgn = (diffang>0)?1:-1; + diffang = abs(diffang)**.7*sgn; + } + if ( abs(diffpitch) > 1. ) + { + int sgn = (diffpitch>0)?1:-1; + diffpitch = abs(diffpitch)**.7*sgn; + } + cur.x += diffang; + cur.y -= diffpitch; + Vector3 diffvel = oldlagvel*(1.-ticfrac)+lagvel*ticfrac; + double diffx = diffvel dot (cos(angle+90),sin(angle+90),0); + double diffy = diffvel dot (0,0,1); + if ( abs(diffx) > 1. ) + { + int sgn = (diffx>0)?1:-1; + diffx = abs(diffx)**.5*sgn; + } + if ( abs(diffy) > 1. ) + { + int sgn = (diffy>0)?1:-1; + diffy = abs(diffy)**.5*sgn; + } + cur.x += diffx*4.; + cur.y += diffy*4.; + return cur*(oldlagready*(1.-ticfrac)+lagready*ticfrac); + } + override void PlayerThink() + { + oldangle = angle; + oldpitch = pitch; + Super.PlayerThink(); + } override void Tick() { Super.Tick(); if ( !player ) return; + oldlagangle = lagangle; + oldlagpitch = lagpitch; + oldlagready = lagready; + oldlagvel = lagvel; + lagangle = lagangle*.8+angle*.2; + lagpitch = lagpitch*.8+pitch*.2; + if ( player.weaponstate&WF_WEAPONBOBBING ) lagready = lagready*.9+.1; + else lagready = lagready*.4; + lagvel = lagvel*.8+vel*.2; double traveldist = level.Vec3Diff(prev,pos).length(); if ( waterlevel < 2 ) { @@ -401,6 +462,9 @@ Class Demolitionist : PlayerPawn if ( !mute ) mute = CVar.GetCVar('swwm_mutevoice',player); if ( player.onground && !bNoGravity && !lastground && (waterlevel < 2) && (health > 0) ) { + // bump down weapon + bumpdown = true; + bumpvelz = -lastvelz; if ( lastvelz < -30 ) { let s = Spawn("DemolitionistShockwave",pos); @@ -423,6 +487,12 @@ Class Demolitionist : PlayerPawn if ( lastvelz < -1 ) A_Footstep(0,true,clamp(-lastvelz*0.05,0.0,1.0)); } + if ( bumpdown ) + { + lagvel.z += bumpvelz*.2; + bumpvelz *= .8; + if ( bumpvelz < double.epsilon ) bumpdown = false; + } lastground = player.onground; lastvelz = prevvelz; prevvelz = vel.z; diff --git a/zscript/swwm_shot.zsc b/zscript/swwm_shot.zsc index 1e869f024..6cca5b18c 100644 --- a/zscript/swwm_shot.zsc +++ b/zscript/swwm_shot.zsc @@ -2517,6 +2517,8 @@ Class Spreadgun : SWWMWeapon flg |= WRF_ALLOWRELOAD; else flg |= WRF_NOPRIMARY; A_WeaponReady(flg); + if ( player.cmd.buttons&(BT_ATTACK|BT_ALTATTACK) ) + invoker.CheckAmmo(EitherFire,true); } Wait; Fire: diff --git a/zscript/swwm_splode.zsc b/zscript/swwm_splode.zsc index 34f14ff3f..9620dec7b 100644 --- a/zscript/swwm_splode.zsc +++ b/zscript/swwm_splode.zsc @@ -136,7 +136,7 @@ Class ExplodiumMagProj : Actor Scale *= 2.+.2*special1; A_AlertMonsters(); SWWMHandler.DoBlast(self,120+30*special1,80000+8000*special1); - A_Explode(30+20*special1,120+30*special1); + A_Explode(20+15*special1,120+30*special1); A_QuakeEx(9,9,9,30,0,400+80*special1,"",QF_RELATIVE|QF_SCALEDOWN,falloff:300,rollintensity:2.); A_StartSound("explodium/maghit",CHAN_VOICE,attenuation:.35); A_StartSound("explodium/maghit",CHAN_WEAPON,attenuation:.2); @@ -229,7 +229,7 @@ Class ExplodiumBulletImpact : Actor Super.PostBeginPlay(); A_AlertMonsters(); SWWMHandler.DoBlast(self,120,80000); - A_Explode(50,120); + A_Explode(25,120); A_QuakeEx(4,4,4,10,0,250,"",QF_RELATIVE|QF_SCALEDOWN,falloff:150,rollintensity:0.2); A_StartSound("explodium/hit",CHAN_VOICE,attenuation:.6); A_StartSound("explodium/hit",CHAN_WEAPON,attenuation:.3); @@ -315,7 +315,7 @@ Class ExplodiumGun : SWWMWeapon SWWMBulletTrail.DoTrail(self,origin,dir,10000,2); if ( d.HitType == TRACE_HitActor ) { - int dmg = 40; + int dmg = 25; SWWMHandler.DoKnockback(d.HitActor,d.HitDir,48000); dmg = d.HitActor.DamageMobj(invoker,self,dmg,'Explodium',DMG_USEANGLE|DMG_THRUSTLESS,atan2(d.HitDir.y,d.HitDir.x)); if ( d.HitActor.bNOBLOOD || d.HitActor.bINVULNERABLE ) diff --git a/zscript/swwm_tastytreat.zsc b/zscript/swwm_tastytreat.zsc index 42c5a9e61..b2ca71b56 100644 --- a/zscript/swwm_tastytreat.zsc +++ b/zscript/swwm_tastytreat.zsc @@ -974,6 +974,7 @@ Class CandyGun : SWWMWeapon Weapon.AmmoType2 "CandyGunSpares"; Weapon.AmmoGive1 1; Weapon.AmmoGive2 1; + Weapon.AmmoUse2 0; CandyGun.ClipCount 7; +SWWMWEAPON.NOFIRSTGIVE; } @@ -989,7 +990,6 @@ Class CandyGun : SWWMWeapon Ready: XZW2 A 1 { - invoker.CheckAmmo(EitherFire,true); if ( (invoker.clipcount <= 0) && !invoker.chambered && (invoker.Ammo1.Amount > 0) ) player.SetPSprite(PSP_WEAPON,ResolveState("Reload")); else if ( (invoker.clipcount > 0) && !invoker.chambered ) player.SetPSprite(PSP_WEAPON,ResolveState("Slide")); else @@ -998,6 +998,8 @@ Class CandyGun : SWWMWeapon if ( sv_infiniteammo || FindInventory('PowerInfiniteAmmo',true) || (invoker.Ammo1.Amount > 0) || invoker.chambered ) flg |= WRF_ALLOWRELOAD; if ( (invoker.Ammo1.Amount <= 0) && !sv_infiniteammo && !FindInventory('PowerInfiniteAmmo',true) ) flg |= WRF_NOSECONDARY; A_WeaponReady(flg); + if ( player.cmd.buttons&(BT_ATTACK|BT_ALTATTACK) ) + invoker.CheckAmmo(EitherFire,true); } } Wait;