Picking Single Objects and Fast Loop Trouble
So, I have a game with a player and computer controlled allies that follow the player and assist in attacking enemies about the frame. I'm having a number of issues with getting this to work correctly, and I hope I can describe all of these things correctly so I won't have to upload the .mfa file. It's ... unfortunately much too big.
Through a fastloop, what the allies are meant to do is acquire the ID value of an enemy (basically just what their spread value is in an alterable value; I couldn't get fixed values to work right) that comes within their range and fire at the nearest enemy (Advanced Direction Object) then drop the ID value of the enemy if it kills that enemy or if the enemy is no longer in range.
It seems like they're acquiring enemies and firing at them when they want to. Sometimes it feels at random, which leads me to believe that they're being identified as a group instead of individually even though the events don't call for an object group (i.e. "Group.Good").
One part that I KNOW is identifying all of them at once is when they fire. Bullets will spawn from allies that are just in their Stopped sequence as well as those that are, rightfully, in their Shooting sequence, and the screen gets flooded with bullets flying all over the place. I'm not sure how to make only individuals fire. When all the alterable values line up, they all seem to go simultaneously, even if the event calls for only one with an ID equivalent to the Loop Index. And I think also the fact that they all fire has to do with why some of the bullets seem to glitch in the wrong direction. A good amount of them, 50% or so, seem to always fire directly to the right, like the Clickteam Movement Controller doesn't always catch them.
The last problem I have (again, probably a selecting problem, as it selects them as a group instead of individually) is when new enemies are created on the frame, the allies don't recognize them and won't attack them.
I'm sorry about this mouthfull, but this problem's drivin' me nuts. ><
Re: Picking Single Objects and Fast Loop Trouble
You will reall need to upload an MFA file showing this.
Try to strip out everything that we dont need so that it reduces size.
It is probably that your not using the right events to select the objects correctly. If you can upload I will check it out.
Re: Picking Single Objects and Fast Loop Trouble
Yes, it's a mouthful. In order to make it not a mouthful and so you don't have to post an MFA, how about you break down each problem and address them one by one?
There's no reason to address 3-4 different problems when they are probably all related to one another in some way. If you fix the first problem, you might eliminate other problems. So it's best to start at the beginning and work your way through it.
First, more details about how your allies are detecting the enemies... since you're saying you feel they are doing it at random.
Re: Picking Single Objects and Fast Loop Trouble
Well, I've managed to remove many of the elements that don't have anything to do with the addressed problem, but the file is still pretty big, too big to be uploaded here since it only allows a max of 1 mb.
Now that I think about it, this is potentially a kind of RTS type problem even though I wasn't intending on making an RTS. o.o
Here's a different link. Hope it works.
http://www.megaupload.com/?d=0K19AL9J
Re: Picking Single Objects and Fast Loop Trouble
Gonna have to narrow it down more than that if you want me to look at solving it... Can't speak for everyone else but I still think that it's way too much to sift through... Just recreate the stuff in a new App with just the bare bones needed. If that's too much work, then I think having you explain the events would be easier than trying to look through all of that.
Re: Picking Single Objects and Fast Loop Trouble
I've identified where the code is in bold red font comments on a black background. Should be pretty easy to find in the events.
Re: Picking Single Objects and Fast Loop Trouble
If its an RTS problem I can help you out with that. I will download and check it out.
EDIT: OK wow thats way to many events to go through to figure it out. If you want people to help you strip out all the code that is not relevant and repost it.
Re: Picking Single Objects and Fast Loop Trouble
-Sighs.- None of it is relevant because none of it's working right. All I'm tryin' to do is make individual soldiers acquire their own targets when they're near an enemy and fire at them while in that range, or to make it even simplier, just fire at whatever the nearest enemy is. I can't make any of it work because I can't figure out how to make the events target a single soldier instead of all of them.
I have a feeling every other problem is really just related to that. ><
Again, though, the only probs I'm havin' is where the red comments lead to (assuming that all the groups are closed, as it was how I saved the /mfa so that they can be found). Under "Game Controls," They're pointing to two groups, one called "Targetting Code" and one called "Soldier Machinegun." ><
Re: Picking Single Objects and Fast Loop Trouble
Here's how to properly do it. Then you'll have to figure out how to get it to work within your application.
Re: Picking Single Objects and Fast Loop Trouble
It sounds like your trying to do too much at one time. If you are having a problem with something, try to figure out a solution in a test application as Nifflas posted above. Once you figure it out you can then add it to your main game without worrying about changing it all the time trying to get it to work.
You can then save those test engines somewhere else for reference at a later date.
Re: Picking Single Objects and Fast Loop Trouble
Yep. I definitely needed to know how to properly do it. <3 Thanks, Nifflas! I'll tweak it later (I have to run for now) and see if I can get the stuffs to work. Although it was a bit daunting to look at what with the level of evilness coming from the GWARGHs.
Although, since I'm a bit clueless with that math >.>, is there a way to modify that event to have them target what's near them in kind of an oval shape as opposed to what's around them/ within their radius? Just for the sake of the isometric engine stuff.
Ironically though, bigredron, that -is- the test engine. ><
Re: Picking Single Objects and Fast Loop Trouble
A test engines with over 1000 events? You really need to look into optimizing your events more...
As for the oval shape, that certainly is possible. All you need to do is modify the x or y values in the triginomety. At the moment its a circle, if you say reduce the y value by half then that gives you an oval shape that is half the height than it is wide. If you google around you will see the formulas for both circles (which is what nifflas used) and ovals amongst other shapes.
Re: Picking Single Objects and Fast Loop Trouble
Alright. Thanks a ton to all of you for your help and patience! ^.^ It works now with a bit of tweaking with that code. <3 I'll try adding in the oval in a bit, but they're now all firing independantly of one another AND at what they're supposed to be attacking. And yup, it's got tons of events. o.o Guess I'm just not good at optimizing 'em.
Now, if only I knew which one of these many formulas I'm finding will work right in MMF2... x.x
--- Nevermind! Got it! Thanks again, all. =)