Difference between revisions of "Multiple firing modes on a weapon"
Jump to navigation
Jump to search
(Created page with '==Multiple firing modes on a weapon==') |
|||
Line 1: | Line 1: | ||
==Multiple firing modes on a weapon== | ==Multiple firing modes on a weapon== | ||
Right, I saw this requested on the forum, and being the good guy I am (He lied), I thought I'd help. | |||
Subclass the stinger and paste this code in. Hopefully, right-click should change between the projectiles and left-click will shoot them. | |||
Of course, if you are using a different weapon, you may need to make slight code adjustments for different animations and such. | |||
<pre> | |||
var int firingmode; // What firing mode we are in | |||
var float firespeed; // How fast we shoot | |||
function PlayFiring() | |||
{ | |||
local Vector Start; | |||
Start = Owner.Location + CalcDrawOffset(); | |||
switch (firingmode) | |||
{ | |||
case(1): | |||
projectileclass=Class'Dammo2'; // Dispersion ammo level 2 | |||
firespeed=0.15; // Pause time between each shot. A larger firespeed means a larger pause. | |||
AmmoType.ammoamount-=1; | |||
break; | |||
case(2): | |||
projectileclass=Class'dammo3'; // Dispersion ammo level 3 | |||
firespeed=0.2; // Pause time between each shot. A larger firespeed means a larger pause. | |||
AmmoType.ammoamount-=1; | |||
break; | |||
case(3): | |||
projectileclass=Class'dammo4'; // Dispersion ammo level 4 | |||
firespeed=0.25; // Pause time between each shot. A larger firespeed means a larger pause. | |||
AmmoType.ammoamount-=1; | |||
break; | |||
case(4): | |||
projectileclass=Class'dammo5'; // Dispersion ammo level 5 | |||
firespeed=0.3; // Pause time between each shot. A larger firespeed means a larger pause. | |||
AmmoType.ammoamount-=1; | |||
break; | |||
default: //breaks to the default firing mode | |||
projectileclass=Class'Dispersionammo'; // Dispersion ammo level 1 | |||
firespeed=0.1; // Pause time between each shot. A larger firespeed means a larger pause. | |||
firingmode=0; | |||
//AmmoType.ammoamount-=0; | |||
break; | |||
} | |||
if (Ammotype.Ammoamount<=0)Ammotype.Ammoamount=0; | |||
} | |||
function PlayAltFiring() // When we right click... | |||
{ | |||
local pawn p; | |||
p=PlayerPawn(Owner); | |||
firingmode++; // ...advance the firing mode | |||
AmmoType.Ammoamount++; | |||
switch (firingmode) | |||
{ | |||
case(1): | |||
p.clientmessage("Mode Set: Dammo2"); // Tells the player what projectile mode we are in | |||
break; | |||
case(2): | |||
p.clientmessage("Mode Set: Dammo3"); // Tells the player what projectile mode we are in | |||
break; | |||
case(3): | |||
p.clientmessage("Mode Set: Dammo4"); // Tells the player what projectile mode we are in | |||
break; | |||
case(4): | |||
p.clientmessage("Mode Set: Dammo5!"); // Tells the player what projectile mode we are in | |||
break; | |||
default: | |||
p.clientmessage("Mode Set: DispersionAmmo"); // Tells the player what projectile mode we are in | |||
firingmode=0; | |||
break; | |||
} | |||
} | |||
state AltFiring | |||
{ | |||
function Projectile ProjectileFire(class<projectile> ProjClass, float ProjSpeed, bool bWarn) | |||
{// Alt-Fire Does Nothing | |||
} | |||
Begin: | |||
FinishAnim(); | |||
PlayAnim('Still'); // Plays a simple still animation | |||
Sleep(0.4); | |||
Finish(); | |||
} | |||
state NormalFire | |||
{ | |||
function Tick( float DeltaTime ) | |||
{ | |||
} | |||
function EndState() | |||
{ | |||
} | |||
Begin: | |||
Sleep(firespeed); //The weapon will pause for a set amount of time after each shot. More powerful projectiles tend to have a larger firespeed number, as to avoid an unbalanced weapon. The exact opposite is true for weaker projectiles. the firespeed number is decreased. | |||
SetLocation(Owner.Location); | |||
Finish(); | |||
} | |||
</pre> |
Revision as of 23:28, 14 November 2009
Multiple firing modes on a weapon
Right, I saw this requested on the forum, and being the good guy I am (He lied), I thought I'd help. Subclass the stinger and paste this code in. Hopefully, right-click should change between the projectiles and left-click will shoot them. Of course, if you are using a different weapon, you may need to make slight code adjustments for different animations and such.
var int firingmode; // What firing mode we are in var float firespeed; // How fast we shoot function PlayFiring() { local Vector Start; Start = Owner.Location + CalcDrawOffset(); switch (firingmode) { case(1): projectileclass=Class'Dammo2'; // Dispersion ammo level 2 firespeed=0.15; // Pause time between each shot. A larger firespeed means a larger pause. AmmoType.ammoamount-=1; break; case(2): projectileclass=Class'dammo3'; // Dispersion ammo level 3 firespeed=0.2; // Pause time between each shot. A larger firespeed means a larger pause. AmmoType.ammoamount-=1; break; case(3): projectileclass=Class'dammo4'; // Dispersion ammo level 4 firespeed=0.25; // Pause time between each shot. A larger firespeed means a larger pause. AmmoType.ammoamount-=1; break; case(4): projectileclass=Class'dammo5'; // Dispersion ammo level 5 firespeed=0.3; // Pause time between each shot. A larger firespeed means a larger pause. AmmoType.ammoamount-=1; break; default: //breaks to the default firing mode projectileclass=Class'Dispersionammo'; // Dispersion ammo level 1 firespeed=0.1; // Pause time between each shot. A larger firespeed means a larger pause. firingmode=0; //AmmoType.ammoamount-=0; break; } if (Ammotype.Ammoamount<=0)Ammotype.Ammoamount=0; } function PlayAltFiring() // When we right click... { local pawn p; p=PlayerPawn(Owner); firingmode++; // ...advance the firing mode AmmoType.Ammoamount++; switch (firingmode) { case(1): p.clientmessage("Mode Set: Dammo2"); // Tells the player what projectile mode we are in break; case(2): p.clientmessage("Mode Set: Dammo3"); // Tells the player what projectile mode we are in break; case(3): p.clientmessage("Mode Set: Dammo4"); // Tells the player what projectile mode we are in break; case(4): p.clientmessage("Mode Set: Dammo5!"); // Tells the player what projectile mode we are in break; default: p.clientmessage("Mode Set: DispersionAmmo"); // Tells the player what projectile mode we are in firingmode=0; break; } } state AltFiring { function Projectile ProjectileFire(class<projectile> ProjClass, float ProjSpeed, bool bWarn) {// Alt-Fire Does Nothing } Begin: FinishAnim(); PlayAnim('Still'); // Plays a simple still animation Sleep(0.4); Finish(); } state NormalFire { function Tick( float DeltaTime ) { } function EndState() { } Begin: Sleep(firespeed); //The weapon will pause for a set amount of time after each shot. More powerful projectiles tend to have a larger firespeed number, as to avoid an unbalanced weapon. The exact opposite is true for weaker projectiles. the firespeed number is decreased. SetLocation(Owner.Location); Finish(); }