Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-27-2005, 05:16 PM   #1
Will126
neon Creative Studios
 
Will126's Avatar
 
Join Date: Mar 2005
Posts: 12
Send a message via MSN to Will126
Exclamation FPS game

I have a gun which moves when the cursor moves. The gun fires when it is pressed and this gun is automatic. Ammo goes down each time a shot is fired and when the ammo runs out the gun automaticly reloads....guuud so far...

However I have 2 problems:

1. Each time the gun fires a script is run, the gun fires aprox. 5 times every second, the script is run each time the play-head runs over it which I hear is processor eating. The script decreases the ammo by 1, checks that the ammo is above 0 and duplicates the bullet symbol. I think I should use actionscript to set an interval of 0.25 seconds instead. The script:

ActionScript Code:
_root.ammo--; _root.ammobar._xscale = _root.ammo; if (_root.ammo < 1) _parent.nextFrame();     _root.hit.duplicateMovieClip("newhit"); _root["newhit"]._x = _root._xmouse; _root["newhit"]._y = _root._ymouse;


2. The enemies. The enemies are chavs. At the moment I've only attempted the kind which dive in doing a kind of combat roll. I have a hit test target on their head and body, you hit them in the head it will play "die2" where their head explodes, you hit them in the chest and plays "die1" where no head explodes they just die. This works fine...

But I wish to make it so that after the chav has been killed, if you carry on shooting them more blood will come out and they'll keep flinching lol (I hope you don't mind cartoon gore). I need another hit test for this and...it just doesn't work at all and I have no idea why.

The graphics, effects and people arn't finished but that's cause I thought I better resolve issues before I began the final game...by all means download the .fla from here....

Thanks in advance dudes!
Will126 is offline   Reply With Quote
Old 07-27-2005, 05:38 PM   #2
Dylan Marvin
Dylan
 
Join Date: Jun 2005
Posts: 379
Default

Would love to help, but your file is MX 2004, or at least I'm having trouble opening it in MX.
(Can you save it as an MX file and attach? Is your code MX compatible? If not you should post this in the MX 2004 forum.)
__________________
my art
Dylan Marvin is offline   Reply With Quote
Old 07-27-2005, 06:43 PM   #3
Will126
neon Creative Studios
 
Will126's Avatar
 
Join Date: Mar 2005
Posts: 12
Send a message via MSN to Will126
Default

Thanks for your interest and quick reply Dylan, I have now uploaded a Flash MX version along side the Flash MX 2004 version

http://wiki.anou.org/FlashMx

Hope you can help
Will126 is offline   Reply With Quote
Old 07-27-2005, 08:14 PM   #4
Dylan Marvin
Dylan
 
Join Date: Jun 2005
Posts: 379
Default

Okay. Works.
First, in the "Shoot Animation" with the above code you have a 5 frame timeline, with a "gotoAndPlay(2)" in the last frame, therefore giving you a 4 frame loop. Using _root.ammo-- in one frame of that loop, and considering you're working with an ambitious 40 f/s, you're shooting 10 times a second. Therefore, if you wanted to shoot once every .25 seconds, or 4 times a second, make your loop 10 frames (just add 6 more frames before the "gotoAndPlay(2)".)
The second issue... Well, you've got quite a lot of code in a lot of places, and it might be easier to discern with some little code hints (trust me, they make your job easier as well) Run a trace to test whether it's registering a hit at all first, then go from there. I'll have to look harder later...
__________________
my art
Dylan Marvin is offline   Reply With Quote
Old 07-27-2005, 09:15 PM   #5
Will126
neon Creative Studios
 
Will126's Avatar
 
Join Date: Mar 2005
Posts: 12
Send a message via MSN to Will126
Default

Well fps was originaly 30fps but I changed it to 40fps today because the game ran faster at that speed...game slows down when you have more than one chav instance on the stange you see lol

I tried the trace and nope hit test just didn't work for it. The problem could be with the dodgy script I have for moving the bullets around...I adapted it from here somehow http://www.video-animation.com/flash_32.shtml
Will126 is offline   Reply With Quote
Old 07-27-2005, 11:14 PM   #6
Dylan Marvin
Dylan
 
Join Date: Jun 2005
Posts: 379
Default

Tell me exactly where to find the code in question in your game please.
__________________
my art
Dylan Marvin is offline   Reply With Quote
Old 07-28-2005, 10:42 AM   #7
Will126
neon Creative Studios
 
Will126's Avatar
 
Join Date: Mar 2005
Posts: 12
Send a message via MSN to Will126
Default

OK I suppose I should, I have tonnes of MCs lol.

I have the GP rifle and the MP5 weapon in the game currently, loads more weapons will be added into the game later.

Bullets script
From the main timeline double-click: MP5 weapon > Shoot animation > script on frame 3 of the Script layer.

Chav hittests
From the main timeline double-click: 1 Townie_mc > 1 Extra > 1 Movement copy > then.....the following MCs hold the hittest
Layer: Target 1, target head (if hit 4 times will goto "die2")
Layer: Target 2, target body (if hit 3 times will goto "die1")
Layer: Target 4, target body 2 (experimental, would like townie to be able to fire at once he's dead for more effects, would like it to goto "die11" when hit)
I removed Target 3 just messing around with this thing trying to get it to work but it was going to be used for killing the townie when the townie is kneeling rather than diving through the air. I hope all of this makes sense but if it doesn't just ask, I could explain myself in a flash animation maybe
Will126 is offline   Reply With Quote
Old 07-28-2005, 02:27 PM   #8
Dylan Marvin
Dylan
 
Join Date: Jun 2005
Posts: 379
Default

This is the script in question, right? :
ActionScript Code:
onClipEvent (enterFrame) {     if (_root.bodyhit2, hitTest(_root.newhit.hit2)) {         this.play();     } }
And the first part of the problem is it's not registering a hit, right? I'm having trouble locating where to find "bodyhit2" on the _root, among other things. Is it loaded there by another bit of actionscript on another movieClip?

You might have to do a "save as" and stip your project down to the very very bare essentials, it will make it easier for you and for others to help. (A trap to get caught in is spreading so much code throughout a game that it becomes "dirty", and you start writing code after code to fix bugs and small glitches get lost in the mix, like adding parts to a broken car engine instead of just replacing the whole engine.)

What might be easier in the long run is to revamp the whole process by which you determine hits and goto's. If anything, use the "target 2" to determine the "dead" hits with a second condition and variable that determines if the character is dead or not, that says in effect "if hit && alive, goto frame ___, else if hit && dead, goto frame ____".
__________________
my art
Dylan Marvin is offline   Reply With Quote
Old 07-28-2005, 04:27 PM   #9
Will126
neon Creative Studios
 
Will126's Avatar
 
Join Date: Mar 2005
Posts: 12
Send a message via MSN to Will126
Default

bodyhit2 isn't on the _root but it seems to work. I'm almost definitely positive it is a problem with the bullets.

With the bullets I had a problem which I eventually sorted out by messing around with it, if you open the MC hit which is the blob on the _root at the top left. This is what causes the collision. The problem I had was when the bullet was fired it wouldn't disappear and so would be causing lots of collisions... to fix it I made the hit MC so it would.


I have stripped the whole flash document down to the basics with a stick man and realised that if you remove the stop(); command from the hit MC the rest ofthe hittests work. Please help me out I'm terrible with actionscript
Will126 is offline   Reply With Quote
Old 07-28-2005, 06:02 PM   #10
Dylan Marvin
Dylan
 
Join Date: Jun 2005
Posts: 379
Default

It's hard to tell what your problem is now... Is the hitTest working now or what? Can you upload your new file? I don't have too much time to rebuild, but I think that's what you may need done. I think a little more research could solve your problems; finding more tutorials and games flas that involve hitTests. Try to get more of your code on the _root as possible, you'll have much better luck debugging that way. A work around that is to pass variables around. Instead of having hitTests and such embedded and embedded withing clips, let the _root check and give boolean values to things like "hitOnce = false" and then have your movieClip timeline react to those variables
ActionScript Code:
if(_root.hitOnce == true){ _root.clipName.gotoAndPlay("frame"); } if(_root.hitOnce == true && _root.hitTwice == true){ _root.clipName.gotoAndPlay("frame2"); }...etc
__________________
my art
Dylan Marvin is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:02 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.