View Full Version : Rapid Fire weapons
kingofnukes
July 7th, 2005, 08:30 PM
I'm amkin a first person shooter and I need help with rapid fire weapons. how can i change my code so it will work?
kingofnukes
July 7th, 2005, 08:34 PM
my fla. is too big to upload. you can download it at : http://www.geocities.com/swfkn/rapid.fla
Blackspirit
July 8th, 2005, 02:32 AM
On your gun put this code:
onClipEvent(load)
{
var shooting = false;
}
onClipEvent(enterFrame)
{
trace(this.shooting);
if(this.shooting && this._currentframe!=3)
{
this.gotoAndPlay(2);
}
}
on your crosshair put this code:
onClipEvent (enterFrame) {
Mouse.hide();
}
onClipEvent (load) {
startDrag("", true);
}
onClipEvent (mouseDown) {
_root.gun.shooting = true;
}
onClipEvent (mouseUp) {
_root.gun.shooting = false;;
}
And you fps should be around 25, 12 is a bit low :)
kingofnukes
July 8th, 2005, 05:17 PM
When I test the movie, the output panel comes up andsays flase ansd won't go a way, and when I published it the gun wouldn't stop shoting. Can you revise the code please. :tired: :book:
Blackspirit
July 8th, 2005, 11:01 PM
the output panel is caused by the trace command in the gun, just remove it. I had it there to test it out.
In your gun movieclip, on the third frame, put gotoAndPlay(1) instead of two. Forgot to mention that :P:D
kingofnukes
July 9th, 2005, 12:26 AM
That works, but the whole point was to make it effect the enemy. what can i do to the script on the enemy to make it get hurt after the gun shoots it.
Blackspirit
July 9th, 2005, 12:41 AM
well, all you have to do is use the crosshairs x/y as part of a hitTest.
something like if(enemy.hitTest(this._x,this._y, true))
They're tutorials somewhere on kirupa on hitTest, so take a look at them. :)
kingofnukes
July 9th, 2005, 02:31 AM
I made a hitTest code for the scope and the code I made makes the enemy loop the "hurt" frames and will only play the "death" animations if you rollOut of the enemy at the right time. I have updated the fla. I need it so that the death animation stops the gun from hurting it when dieing, but without stopping the gun's ablility to move on and hurt another enemy.:hitman:
kingofnukes
July 9th, 2005, 01:48 PM
Never mind. I found out that if I tld the scope o th hitTest to just make the health go down insted of playing the hurt frames, there is less looping and it is on the death animation anyway.
kingofnukes
July 9th, 2005, 06:10 PM
Now It is complete with one glitch, when the gun reloads, if use click the mouse it will start shooting again and stop the reload scene, stopping it from reloading and giving the player infinate ammo. I updated the download again, please help me.
Blackspirit
July 10th, 2005, 02:48 AM
ok, lets see.
We dont want it to fire while reloading. To control that we need a new variable called "reloading"
We initialize it to false in the onLoad of the gun.
In the enterFrame of the gun, we need to add a !reloading clause to the if statement that checks whether its ok to shoot.
Then in the gun, where the reloading animation starts we flag this.reloading = true;
And at the end of the reloading animation, we flag this.reloading = false;
So..
On the gun you should have:
onClipEvent (load) {
var shooting = false;
var reloading = false;
}
onClipEvent (enterFrame) {
if (this.shooting && this._currentframe != 3 &&!this.reloading) {
this.gotoAndPlay(2);
}
}
At the Start of the reloading animation, on layer three, you should have:
_root.scope.gotoAndStop(4);
shooting = false;
reloading = true;
and at the end of the reloading animation:
this.reloading = false;
That should all work hopefully. :D
kingofnukes
July 11th, 2005, 01:09 PM
thanx man your the best. Leaving you out off the creditz of my game would be immoral. :A+: :angel:
I'm also having trouble on a diffrent thred about a sniper rifle, if you have the time could you check it out? :puzzled:
Link: http://kirupa.com/forum/showthread.php?t=184015
kingofnukes
July 13th, 2005, 06:13 PM
Remember that plasma gun you helped me with? Well I'm trying to make that rapid fire too, but the heat won't go up with the codes from the scope and gun from my rapid.fla
What can I do to the code to make the haet go up with the rapid fire?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.