One half of "swinger" recoil system added.

This commit is contained in:
Marisa the Magician 2018-09-15 14:14:34 +02:00
commit c15847a10a
7 changed files with 141 additions and 5 deletions

View file

@ -662,8 +662,13 @@ Class BioRifle : UTWeapon
{
p = Spawn("BioGlob",origin);
p.A_SetScale(1.0+invoker.charge*0.8);
UTMainHandler.DoSwing(self,(FRandom[GES](-0.6,-1.3),FRandom[GES](-0.9,-0.2)),1+invoker.charge*0.3,-0.1,3,SWING_Spring2,3);
}
else
{
p = Spawn("BioGel",origin);
UTMainHandler.DoSwing(self,(FRandom[GES](-0.6,-1.3),FRandom[GES](-0.9,-0.2)),2,-0.5,2,SWING_Spring2,2);
}
else p = Spawn("BioGel",origin);
p.angle = angle;
p.pitch = BulletSlope();
p.vel = (cos(p.angle)*cos(p.pitch),sin(p.angle)*cos(p.pitch),-sin(p.pitch))*p.speed;
@ -692,6 +697,7 @@ Class BioRifle : UTWeapon
{
Weapon weap = Weapon(invoker);
if ( !weap ) return;
UTMainHandler.DoSwing(self,(FRandom[GES](-1,1),FRandom[GES](-1,1)),0.02*invoker.charge,0,5,SWING_Spring2);
if ( invoker.charge >= 5.1 ) return;
if ( weap.Ammo1.Amount <= 0 ) return;
if ( !weap.DepleteAmmo(weap.bAltFire,true,1) ) return;

View file

@ -46,6 +46,7 @@ Class UTChainsaw : UTWeapon
action void A_SawHit()
{
A_QuakeEx(2,2,2,2,0,1,"",QF_RELATIVE,rollIntensity:0.15);
UTMainHandler.DoSwing(self,(FRandom[Chainsaw](-1,1),FRandom[Chainsaw](-1,1)),0.6,-0.2,2,SWING_Spring);
invoker.sawcnt += 1./TICRATE;
if ( invoker.sawcnt < 0.15 ) return;
invoker.sawcnt = 0;
@ -86,6 +87,7 @@ Class UTChainsaw : UTWeapon
action void A_SawSwipe( bool initial = false )
{
A_QuakeEx(2,2,2,3,0,1,"",QF_RELATIVE,rollIntensity:0.15);
UTMainHandler.DoSwing(self,(FRandom[Chainsaw](-1,1),FRandom[Chainsaw](-1,1)),0.6,-0.2,2,SWING_Spring);
if ( initial ) invoker.FireEffect();
A_AlertMonsters();
Vector3 x, y, z;
@ -136,6 +138,7 @@ Class UTChainsaw : UTWeapon
A_AlertMonsters();
if ( bAlt ) A_QuakeEx(1,1,1,3,0,1,"",QF_RELATIVE,rollIntensity:0.4);
else A_QuakeEx(0,0,0,2,0,1,"",QF_RELATIVE,rollIntensity:0.2);
UTMainHandler.DoSwing(self,(FRandom[Chainsaw](-1,1),FRandom[Chainsaw](-1,1)),0.25,-0.1,2,SWING_Spring);
if ( bAlt || Random[Chainsaw](0,2) ) return;
Vector3 x, y, z;
[x, y, z] = Matrix4.GetAxes(pitch,angle,roll);
@ -232,9 +235,17 @@ Class UTChainsaw : UTWeapon
CSWJ FEDCBA 1 A_Vibrate();
Goto Idle;
AltFire:
CSWA A 0 A_PlaySound("chainsaw/fire",CHAN_6);
CSWA A 0
{
A_PlaySound("chainsaw/fire",CHAN_6);
UTMainHandler.DoSwing(self,(FRandom[Chainsaw](-0.8,-1.2),FRandom[Chainsaw](-0.4,-0.7)),0,1,5,SWING_Spring2,6);
}
CSWA ABCDE 2 A_Vibrate(true);
CSWA F 2 A_Overlay(PSP_WEAPON+1,"AltFireSwipes");
CSWA F 2
{
A_Overlay(PSP_WEAPON+1,"AltFireSwipes");
UTMainHandler.DoSwing(self,(FRandom[Chainsaw](0.8,1.2),FRandom[Chainsaw](0,0)),0,2,6,SWING_Spring2);
}
CSWA GHIJ 2;
CSWA K 2 A_Vibrate(true);
CSWA K 0 A_PlaySound("chainsaw/idle",CHAN_6,looping:true);

View file

@ -291,6 +291,7 @@ Class Enforcer : UTWeapon
else A_Overlay(-3,"LeftMuzzleFlash");
A_OverlayFlags(-3,PSPF_RENDERSTYLE|PSPF_FORCESTYLE,true);
A_OverlayRenderstyle(-3,STYLE_Add);
UTMainHandler.DoSwing(self,(FRandom[Enforcer](0.5,0.2),FRandom[Enforcer](-0.3,0.2)),2,0,1,SWING_Spring2);
}
else
{
@ -298,6 +299,7 @@ Class Enforcer : UTWeapon
else A_Overlay(-2,"MuzzleFlash");
A_OverlayFlags(-2,PSPF_RENDERSTYLE|PSPF_FORCESTYLE,true);
A_OverlayRenderstyle(-2,STYLE_Add);
UTMainHandler.DoSwing(self,(FRandom[Enforcer](-0.2,-0.5),FRandom[Enforcer](-0.3,0.2)),2,0,1,SWING_Spring2);
}
Vector3 x, y, z, x2, y2, z2;
[x, y, z] = Matrix4.GetAxes(pitch,angle,roll);

View file

@ -59,6 +59,7 @@ Class ImpactHammer : UTWeapon
A_AlertMonsters();
}
A_QuakeEx(clamp(int(invoker.chargesize*3),0,3),clamp(int(invoker.chargesize*3),0,3),clamp(int(invoker.chargesize*3),0,3),amt+1,0,96,"",QF_RELATIVE,rollIntensity:clamp(invoker.chargesize*0.3,0,0.3));
UTMainHandler.DoSwing(self,(FRandom[Impact](-1,1),FRandom[Impact](-1,1)),invoker.chargesize*0.1,0,1,SWING_Spring);
}
action void A_FireBlast()
{
@ -66,6 +67,7 @@ Class ImpactHammer : UTWeapon
if ( !weap ) return;
A_PlaySound("impact/release",CHAN_WEAPON);
invoker.FireEffect();
UTMainHandler.DoSwing(self,(FRandom[Impact](-0.3,-1.5),FRandom[Impact](-1.2,-0.4)),3,-0.8,3,SWING_Spring2,3);
A_AlertMonsters();
Vector3 x, y, z;
[x, y, z] = Matrix4.GetAxes(pitch,angle,roll);
@ -127,6 +129,7 @@ Class ImpactHammer : UTWeapon
if ( !weap ) return;
A_PlaySound("impact/fire",CHAN_WEAPON);
invoker.FireEffect();
UTMainHandler.DoSwing(self,(FRandom[Impact](-0.3,-1.5),FRandom[Impact](-1.2,-0.4)),2,-0.6,2,SWING_Spring2,1);
A_AlertMonsters();
A_QuakeEx(2,2,2,6,0,1,"",QF_RELATIVE|QF_SCALEDOWN,rollIntensity:0.1);
Vector3 x, y, z;

View file

@ -559,6 +559,7 @@ Class PulseGun : UTWeapon
if ( !CVar.GetCVar('flak_pulsereload').GetBool() && (invoker.clipcount <= 0) ) invoker.clipcount = (weap.Ammo1.Amount>0)?Min(50,weap.Ammo1.Amount):50;
invoker.FireEffect();
UTMainHandler.DoFlash(self,Color(32,128,255,128),1);
UTMainHandler.DoSwing(self,(FRandom[Pulse](-1,-1),FRandom[Pulse](-1,1)),0.1,-0.02,3,SWING_Spring2);
A_AlertMonsters();
Vector3 x, y, z;
[x, y, z] = Matrix4.GetAxes(pitch,angle,roll);
@ -619,6 +620,7 @@ Class PulseGun : UTWeapon
if ( !CVar.GetCVar('flak_pulsereload').GetBool() && (invoker.clipcount <=0) ) invoker.clipcount = (weap.Ammo1.Amount>0)?Min(50,weap.Ammo1.Amount):50;
invoker.FireEffect();
UTMainHandler.DoFlash(self,Color(32,128,255,128),1);
UTMainHandler.DoSwing(self,(FRandom[Pulse](-1,-1),FRandom[Pulse](-1,1)),0.3,-0.1,2,SWING_Spring3);
A_AlertMonsters();
A_QuakeEx(1,1,1,2,0,1,"",QF_RELATIVE|QF_SCALEDOWN,rollIntensity:0.05);
A_Overlay(-2,"MuzzleFlash");

View file

@ -334,7 +334,11 @@ Class ShockBeam : Actor
ExplodeMissile(null,t.Results.HitActor);
if ( t.Results.HitActor is 'ShockHitbox' )
{
if ( target ) target.TakeInventory('ShockAmmo',2);
if ( target )
{
target.TakeInventory('ShockAmmo',2);
UTMainHandler.DoSwing(target,(FRandom[ASMD](-0.1,-0.6),FRandom[ASMD](-0.1,0.5)),5,-1,3,SWING_Spring2,2);
}
let b = t.Results.HitActor.target;
UTMainHandler.DoBlast(b,250,70000);
b.ExplodeMissile(null,self);
@ -557,7 +561,11 @@ Class SuperShockBeam : Actor
ExplodeMissile(null,t.Results.HitActor);
if ( t.Results.HitActor is 'ShockHitbox' )
{
if ( target ) target.TakeInventory('EnhancedShockAmmo',1);
if ( target )
{
target.TakeInventory('EnhancedShockAmmo',1);
UTMainHandler.DoSwing(target,(FRandom[ASMD](-0.1,-0.6),FRandom[ASMD](-0.1,0.5)),10,-2,3,SWING_Spring2,2);
}
let b = t.Results.HitActor.target;
UTMainHandler.DoBlast(b,400,70000);
b.ExplodeMissile(null,self);
@ -996,6 +1004,7 @@ Class ShockRifle : UTWeapon
A_PlaySound("shock/fire",CHAN_WEAPON);
invoker.FireEffect();
UTMainHandler.DoFlash(self,Color(128,128,0,255),1);
UTMainHandler.DoSwing(self,(FRandom[ASMD](-0.1,-0.6),FRandom[ASMD](-0.1,0.5)),2,-0.3,3,SWING_Spring3);
A_AlertMonsters();
A_QuakeEx(2,2,2,4,0,1,"",QF_RELATIVE|QF_SCALEDOWN,rollIntensity:0.1);
Vector3 x, y, z;
@ -1033,6 +1042,7 @@ Class ShockRifle : UTWeapon
A_PlaySound("shock/altfire",CHAN_WEAPON);
invoker.FireEffect();
UTMainHandler.DoFlash(self,Color(128,128,0,255),1);
UTMainHandler.DoSwing(self,(FRandom[ASMD](-0.1,-0.6),FRandom[ASMD](-0.1,0.5)),3,-0.4,3,SWING_Spring3);
A_AlertMonsters();
A_QuakeEx(2,2,2,8,0,1,"",QF_RELATIVE|QF_SCALEDOWN,rollIntensity:0.1);
Vector3 x, y, z;
@ -1177,6 +1187,7 @@ Class EnhancedShockRifle : UTWeapon
A_PlaySound("shock/fire",CHAN_WEAPON);
invoker.FireEffect();
UTMainHandler.DoFlash(self,Color(128,255,128,0),1);
UTMainHandler.DoSwing(self,(FRandom[ASMD](-0.1,-0.6),FRandom[ASMD](-0.1,0.5)),4,-0.6,3,SWING_Spring3);
A_AlertMonsters();
A_QuakeEx(3,3,3,4,0,1,"",QF_RELATIVE|QF_SCALEDOWN,rollIntensity:0.15);
Vector3 x, y, z;
@ -1214,6 +1225,7 @@ Class EnhancedShockRifle : UTWeapon
A_PlaySound("shock/altfire",CHAN_WEAPON);
invoker.FireEffect();
UTMainHandler.DoFlash(self,Color(128,255,128,0),1);
UTMainHandler.DoSwing(self,(FRandom[ASMD](-0.1,-0.6),FRandom[ASMD](-0.1,0.5)),6,-0.8,3,SWING_Spring3);
A_AlertMonsters();
A_QuakeEx(3,3,3,4,0,1,"",QF_RELATIVE|QF_SCALEDOWN,rollIntensity:0.15);
Vector3 x, y, z;

View file

@ -1156,6 +1156,90 @@ Class ShredCorpseHitbox : Actor
}
}
Enum ESwingMode
{
SWING_Straight, // constant increment
SWING_Spring, // bounces back after a delay
SWING_Spring2, // ... returning at half speed
SWING_Spring3, // ... returning at third speed
};
Class Swinger : Thinker
{
Actor target;
Vector2 dir;
double inc;
int steps, mode, delay;
double str, tstr;
int cnt, cstate;
Enum ESwingerState
{
STATE_Initial,
STATE_Wait,
STATE_Return,
STATE_ReturnSlow,
STATE_ReturnSlower,
};
override void Tick()
{
if ( !target ) cstate = -1;
switch ( cstate )
{
case STATE_Initial:
target.A_SetAngle(target.angle+dir.x*str,SPF_INTERPOLATE);
target.A_SetPitch(target.pitch+dir.y*str,SPF_INTERPOLATE);
str += inc;
if ( ++cnt >= steps )
{
cnt = 0;
str = tstr/steps;
cstate = (mode==SWING_Straight)?(-1):(delay>0)?STATE_Wait:(mode==SWING_Spring3)?STATE_ReturnSlower:(mode==SWING_Spring2)?STATE_ReturnSlow:STATE_Return;
}
else tstr += str;
break;
case STATE_Wait:
if ( ++cnt >= delay )
{
cnt = 0;
cstate = (mode==SWING_Spring3)?STATE_ReturnSlower:(mode==SWING_Spring2)?STATE_ReturnSlow:STATE_Return;
}
break;
case STATE_Return:
target.A_SetAngle(target.angle-dir.x*str,SPF_INTERPOLATE);
target.A_SetPitch(target.pitch-dir.y*str,SPF_INTERPOLATE);
if ( ++cnt >= steps )
{
cnt = 0;
cstate = -1;
}
break;
case STATE_ReturnSlow:
target.A_SetAngle(target.angle-dir.x*str/2.,SPF_INTERPOLATE);
target.A_SetPitch(target.pitch-dir.y*str/2.,SPF_INTERPOLATE);
if ( ++cnt >= steps*2 )
{
cnt = 0;
cstate = -1;
}
break;
case STATE_ReturnSlower:
target.A_SetAngle(target.angle-dir.x*str/3.,SPF_INTERPOLATE);
target.A_SetPitch(target.pitch-dir.y*str/3.,SPF_INTERPOLATE);
if ( ++cnt >= steps*3 )
{
cnt = 0;
cstate = -1;
}
break;
default:
Destroy();
return;
}
}
}
Class GenericFlash : HUDMessageBase
{
Color col;
@ -1555,4 +1639,20 @@ Class UTMainHandler : StaticEventHandler
if ( !Victim ) return;
Victim.vel += HitDirection*(MomentumTransfer/(Thinker.TICRATE*Victim.Mass));
}
static void DoSwing( Actor target, Vector2 dir, double initial, double inc, int steps, int mode = 0, int delay = 0 )
{
let s = new("Swinger");
s.ChangeStatNum(Thinker.STAT_USER);
s.target = target;
s.dir = dir;
s.inc = inc;
s.steps = steps;
s.mode = mode;
s.delay = delay;
s.cnt = 0;
s.cstate = 0;
s.str = initial;
s.tstr = initial;
}
}