Rather large project

Get help using Construct 2

Post » Sun Feb 09, 2014 3:46 pm

Hi guys!

I've been working on a project for the last couple of weeks, and recently created an AI system for 4 cpu players, however, I later decided to expand it slightly, and so I am going through the code and fixing things here and there so I can use as many ai players as I want.

However, I've hit a snag. For some reason my ai stop fighting (both each other and human players) seemingly randomly upon a spawn.

Not sure why, and that's why I'm here.

I have tried recreating it as a smaller file, but there's something in my code that is causing a conflict. I was wondering if some kind person out there might be interested in giving my code a quick debug. It still has a couple of glitches, but that's because I haven't finished updating it all to the new system. I just want to know why they stop fighting.

In any case, if you think you're good enough with C" to help me out, please let me know and I will PM you the code. The file is quite small (under 2mb) but it does have over 300 events. Many are not important, and I think I'm close to figuring out the problem.

Anyway, hope someone out there can help!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sun Feb 09, 2014 6:55 pm

Ok, $50 if someone can help!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sun Feb 09, 2014 8:49 pm

Just want to start by saying im not here to offer to debug your code :D

But what you could do, as I find very useful, when I run into stuff like you have here, and uncertain what is going on, is to make a list. That visually keep track of everything about the object causing problem.

In my current project for instant I have objects with 76 variables, that are manually added, so something is bound to go wrong at some point. But having a list to where I can add those variables and keep track of those, that might cause problem is a really big help.

In your case you could make it so it constantly keep track of the enemy.UID, Target.UID, etc.

If you know that each enemy should keep track of its target. Then at some point. It might loose target and the target.UID might show something strange.

Another way is to simply add a text object and simply set it to "Check" when the "code reader" gets to it. And then you just move it around to the places where you suspect things might go wrong.

Anyway good luck finding the problem :D nimos1002014-02-09 20:50:41
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Sun Feb 09, 2014 8:56 pm

YAY! I was able to replicate the issue!

https://copy.com/mTfTkCSikS1vrcrN

For some reason, if both ships (as shown in the attached example) do not have their booleans set to true to fire at the same time, neither ship will fire. I find this odd, personally, as I thought family only checked which was true. If I remove the 'Trigger once' command, it works, but it's constant.

Very strange. I fixed this by using a global variable that is changing, rather than an instance variable, but I'd be interested in knowing what exactly I'm doing wrong here...
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sun Feb 09, 2014 9:56 pm

Trigger once shouldn't be used in situations like this with multiple instances and for each loops. In your example, there is always instances that have laserleft equaling true and false, which means that both the trigger once events run every tick - meaning they only shoot once. Trigger once needs to not run in order to reset itself. If both ships are set to true, that means the trigger once events don't run every other tick, and therefore it works.

Here's an example of how to do it better: http://www.amirai.net/forums/StopsShooting2.zip

At least, that's what I thought you were basically trying to achieve. This way, it doesn't matter how many instances you have or what the other instances are doing.

Is that $50 - or some of the $50 since you isolated it - still up for grabs? ^^ I could really use it...
Arima2014-02-09 22:38:47
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744

Post » Mon Feb 10, 2014 9:29 am

Thanks Arima. The $50 was for someone to actually go through my 300+ event capx and figure out the problem. That was to save me from 5+ hours of tweaking. Sadly nobody seemed interested so I ended up finding the problem and coming up with a solution on my own.

It's appreciated though, and I will PM you directly if I get stuck again with my code as a whole with a cash incentive.
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Mon Feb 10, 2014 7:14 pm

Yeah, that's what I thought, thought it was worth asking though just in case.

Cheers to keeping me in mind for any future debugging needs. :)
Moderator
B
94
S
33
G
33
Posts: 3,006
Reputation: 27,744


Return to How do I....?

Who is online

Users browsing this forum: Malhog and 19 guests