Finished biorifle, began work on pulsegun.

Added some extra particle effects just for kicks.
Made various actors freeze-aware.
Tweaked a couple things here and there.
This commit is contained in:
Marisa the Magician 2018-05-17 02:17:10 +02:00
commit 73e8e8ada9
96 changed files with 1437 additions and 133 deletions

316
zscript/pulsegun.zsc Normal file
View file

@ -0,0 +1,316 @@
Class PulseAmmo : Ammo
{
Default
{
Tag "Pulse Cell";
Inventory.PickupMessage "You picked up a Pulse Cell.";
Inventory.Amount 25;
Inventory.MaxAmount 200;
Ammo.BackpackAmount 50;
Ammo.BackpackMaxAmount 400;
Ammo.DropAmount 25;
}
States
{
Spawn:
PAMO A -1;
Stop;
}
}
Class PulseBall : Actor
{
Default
{
RenderStyle "Add";
PROJECTILE;
Scale 0.2;
Speed 30;
}
override void PostBeginPlay()
{
A_PlaySound("pulse/fly",CHAN_BODY,0.8,true,8.0);
}
action void A_BallExp()
{
A_SetScale(0.45);
A_PlaySound("pulse/hit",CHAN_BODY);
}
States
{
Spawn:
PBAL ABCDE 1 Bright;
Loop;
Death:
TNT1 A 0 A_BallExp();
PBAL ABCDE 3 Bright;
Stop;
}
}
Class PulseBolt : Actor
{
}
Class StarterBolt : PulseBolt
{
}
Class PulseGun : UTWeapon
{
int clipcount;
double sangle;
StarterBolt beam;
Property ClipCount : clipcount;
action void A_Reloading()
{
Weapon weap = Weapon(invoker);
if ( !weap ) return;
invoker.clipcount = Min(50,weap.Ammo1.Amount);
A_PlaySound("pulse/reload",CHAN_WEAPON);
}
action void A_DrainAmmo()
{
Weapon weap = Weapon(invoker);
if ( !weap ) return;
if ( weap.Ammo1.Amount <= 0 ) return;
if ( !weap.DepleteAmmo(weap.bAltFire,true,1) ) return;
invoker.clipcount--;
A_AlertMonsters();
Vector3 x, y, z;
[x, y, z] = Matrix4.GetAxes(pitch,angle,roll);
Vector3 origin = pos+(0,0,player.viewheight)+10.0*x+4.5*y-2.4*z;
int numpt = Random[Pulse](2,5);
for ( int i=0; i<numpt; i++ )
{
Vector3 pvel = (x+(FRandom[Pulse](-.5,.5),FRandom[Pulse](-.5,.5),FRandom[Pulse](-.5,.5))).unit()*FRandom[Pulse](2,4);
A_SpawnParticle("A0FFA0",SPF_FULLBRIGHT,Random[Pulse](10,20),FRandom[Pulse](1.2,2.4),0,origin.x-pos.x,origin.y-pos.y,origin.z-pos.z,pvel.x,pvel.y,pvel.z,0,0,0,1,-1,-0.1);
A_SpawnParticle("60C040",SPF_FULLBRIGHT,Random[Pulse](15,25),FRandom[Pulse](2.4,3.6),0,origin.x-pos.x,origin.y-pos.y,origin.z-pos.z,pvel.x,pvel.y,pvel.z,0,0,0,.5,-1,-0.1);
}
}
action void A_PulseRefire( statelabel flash = null )
{
Weapon weap = Weapon(invoker);
if ( !weap || !player ) return;
if ( (invoker.clipcount <= 0) || (weap.Ammo1.Amount <= 0) )
{
A_ClearRefire();
if ( weap.bAltFire ) player.setpsprite(PSP_WEAPON,weap.FindState("AltRelease"));
else player.setpsprite(PSP_WEAPON,weap.FindState("Release"));
return;
}
A_Refire(flash);
}
action void A_PulseFire()
{
Weapon weap = Weapon(invoker);
if ( !weap ) return;
if ( weap.Ammo1.Amount <= 0 ) return;
if ( !weap.DepleteAmmo(weap.bAltFire,true,1) ) return;
invoker.clipcount--;
A_AlertMonsters();
A_QuakeEx(1,1,1,2,0,64,"",QF_RELATIVE|QF_SCALEDOWN,rollIntensity:0.05);
A_Overlay(-2,"MuzzleFlash");
A_OverlayFlags(-2,PSPF_RENDERSTYLE|PSPF_FORCESTYLE,true);
A_OverlayRenderstyle(-2,STYLE_Add);
Vector3 x, y, z;
double a;
[x, y, z] = Matrix4.GetAxes(pitch,angle,roll);
Vector3 origin = pos+(0,0,player.viewheight)+10.0*x+4.0*y-2.0*z;
origin += y*cos(invoker.sangle)*4.0+z*sin(invoker.sangle)*4.0;
invoker.sangle += 100;
Actor p = Spawn("PulseBall",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;
p.target = self;
int numpt = Random[Pulse](2,5);
for ( int i=0; i<numpt; i++ )
{
Vector3 pvel = (x+(FRandom[Pulse](-.5,.5),FRandom[Pulse](-.5,.5),FRandom[Pulse](-.5,.5))).unit()*FRandom[Pulse](2,4);
A_SpawnParticle("A0FFA0",SPF_FULLBRIGHT,Random[Pulse](10,20),FRandom[Pulse](1.2,2.4),0,origin.x-pos.x,origin.y-pos.y,origin.z-pos.z,pvel.x,pvel.y,pvel.z,0,0,0,1,-1,-0.1);
A_SpawnParticle("60C040",SPF_FULLBRIGHT,Random[Pulse](15,25),FRandom[Pulse](2.4,3.6),0,origin.x-pos.x,origin.y-pos.y,origin.z-pos.z,pvel.x,pvel.y,pvel.z,0,0,0,.5,-1,-0.1);
}
}
action void A_StartBeam()
{
A_PlaySound("pulse/bolt",CHAN_WEAPON,1.0,true);
invoker.beam = StarterBolt(Spawn("StarterBolt",pos));
invoker.beam.target = self;
}
action void A_StopBeam()
{
A_StopSound(CHAN_WEAPON);
if ( invoker.beam ) invoker.beam.Destroy();
}
Default
{
Tag "Pulse Gun";
Inventory.PickupMessage "You got a Pulse Gun";
Weapon.UpSound "pulse/select";
Weapon.SlotNumber 5;
Weapon.AmmoType "PulseAmmo";
Weapon.AmmoUse 1;
Weapon.AmmoType2 "PulseAmmo";
Weapon.AmmoUse2 1;
Weapon.AmmoGive 60;
PulseGun.ClipCount 50;
}
States
{
Spawn:
PGNP A -1;
Stop;
PGNP B -1;
Stop;
Ready:
PGNS ABCDEFGHIJKLMNOPQRSTUVW 1;
Idle:
PGNI A 1
{
A_CheckReload();
if ( (invoker.clipcount <= 0) && (invoker.Ammo1.Amount > 0) ) return A_Jump(255,"Reload");
A_WeaponReady(WRF_ALLOWRELOAD);
return A_JumpIf(!Random[Pulse](0,300),1);
}
Wait;
PGNI ABCDEFGHIJKLMNOPQRSTUVWXYZ 1
{
A_CheckReload();
A_WeaponReady(WRF_ALLOWRELOAD);
}
Goto Idle;
Fire:
PGNI A 0 A_PlaySound("pulse/fire",CHAN_WEAPON,1.0,true);
Hold:
PGNF A 1 A_PulseFire();
PGNF B 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF C 1 A_PulseFire();
PGNF D 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF E 1 A_PulseFire();
PGNF F 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF G 1 A_PulseFire();
PGNF H 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF I 1 A_PulseFire();
PGNF J 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF K 1 A_PulseFire();
PGNF L 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF M 1 A_PulseFire();
PGNF N 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF O 1 A_PulseFire();
PGNF P 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF Q 1 A_PulseFire();
PGNF R 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF S 1 A_PulseFire();
PGNF T 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF U 1 A_PulseFire();
PGNF V 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF W 1 A_PulseFire();
PGNF X 1;
PGNF Y 0 A_PulseRefire(1);
Goto Release;
PGNF Y 1 A_PulseFire();
PGNF Z 1;
PGF2 A 0 A_PulseRefire(1);
Goto Release;
PGF2 A 1 A_PulseFire();
PGF2 B 1;
PGF2 C 0 A_PulseRefire(1);
Goto Release;
PGF2 C 1 A_PulseFire();
PGF2 D 1;
PGF2 E 0 A_PulseRefire(1);
Goto Release;
PGF2 E 1 A_PulseFire();
PGF2 F 1;
PGF2 G 0 A_PulseRefire(1);
Goto Release;
PGF2 G 1 A_PulseFire();
PGF2 H 1;
PGF2 I 0 A_PulseRefire(1);
Goto Release;
PGF2 I 1 A_PulseFire();
PGF2 J 1;
PGF2 K 0 A_PulseRefire(1);
Goto Release;
PGF2 K 1 A_PulseFire();
PGF2 L 1;
PGF2 M 0 A_PulseRefire(1);
Goto Release;
PGF2 M 1 A_PulseFire();
PGF2 N 1;
PGNF A 0 A_PulseRefire("Hold");
Release:
PGNC A 0 A_PlaySound("pulse/down",CHAN_WEAPON);
PGNC ABCDEFGHIJKLMNOPQRSTUVWXY 1;
PGNI A 1;
Goto Idle;
AltFire:
PGBS ABCDE 1;
PGBL A 0 A_StartBeam();
AltHold:
PGBL A 1 A_DrainAmmo();
PGBL B 1;
PGBL C 0 A_PulseRefire(1);
Goto AltRelease;
PGBL C 1 A_DrainAmmo();
PGBL D 1;
PGBL E 0 A_PulseRefire(1);
Goto AltRelease;
PGBL E 1 A_DrainAmmo();
PGBL F 1;
PGBL G 0 A_PulseRefire(1);
Goto AltRelease;
PGBL G 1 A_DrainAmmo();
PGBL H 1;
PGBL I 0 A_PulseRefire(1);
Goto AltRelease;
PGBL I 1 A_DrainAmmo();
PGBL J 1;
PGBL A 0 A_PulseRefire("AltHold");
AltRelease:
PGBE A 0 A_StopBeam();
PGBE ABCDE 1;
Goto Idle;
Reload:
PGNI A 1 A_JumpIf(invoker.clipcount >= 50,"Idle");
PGNR A 1 A_Reloading();
PGNR BCDEFGHIJKLMNOPQRSTUVWXYZ 1;
PGR2 ABCDEFGHIJKLMNOPQRSTUVWX 1;
Goto Idle;
Deselect:
PGNS WVUTSRQPONMLKJIHGFEDCBA 1;
PGNS A 1 A_Lower(int.max);
Wait;
Select:
PGNS A 1 A_Raise(int.max);
Wait;
MuzzleFlash:
PMUZ A 1 Bright;
Stop;
}
}