AI Behaviors not working correctly?

For questions about using Classic.

Post » Sun May 01, 2011 7:27 am

Recently I have been working on a game that is a lot more complex then most of my previous ones, and I have hit a large problem concerning AI behaviors not functioning correctly.

What I am trying to achieve is a top down space game where there is three factions, Alliance, Pirates and Empire each with at least three different types of ships. I wanted each ship, once it had become into a certain range of an enemy (LOS behavior) to periodically launch fighters, smaller objects with the turret and bullet behavior. I had each races ships entered into a family, "Alliance", "pirates" etc which I was hoping would prevent me having to create events for each ship object. BUT, then when one ship from one family found and enemy and launched its fighters, the rest of the objects in that family also did. I fixed the problem as in the CAP below by having a much more lengthy event sheet with lots of ORs for individual objects, if that makes sense.

I have posted a CAP below of my game because it has a lot of events that may have caused the problem, and I am hoping someone with more experience with Construct can go through it and explain how to fix the problem. The CAP is my entire game, which has a lot of events and stuff already in it as I wasn't sure how to replicate the problem in a simpler CAP. I have all the events in groups, which should make it easier to navigate. The last two are the ones I am having problems with.

The current problem is that the Pirate faction ships (rusty coloured, spawn at random planets every 15 seconds) work correctly, they launch fighters and the fighters attack the correct targets, most of the time. But the Alliance ships often do not at all, or launch a fighter that ignores its turret behavior events and flies straight. It all seems very random, sometimes they work and sometimes they dont... :?

I hope that wasn't too lengthy, I hope the CAP make sense as there is a fair bit more in the CAP then just the fighter spawning, but that all works correctly. Thanks in advance! :D

CAP:
http://www.mediafire.com/?0g8oeugsx3dj4q9
B
8
S
2
G
2
Posts: 144
Reputation: 1,588

Post » Sun May 01, 2011 8:13 am

Hmmm, its kinda funny how the Pirates seem to follow strategic plans while the Alliance will strike and bash with it all its got on 1 enemy it finds. You have an interesting game there, however I can't check the CAP for now due to work. :P
B
10
S
5
G
8
Posts: 203
Reputation: 4,395

Post » Sun May 01, 2011 12:51 pm

Actually, most of that isn't intentional :) One of the problems is that although the Pirate fighters turret behavior tells it to attack the closest, it often doesn't, and just goes after anything it wants. Which isn't necessarily a bad thing, if it works like you said ;)
B
8
S
2
G
2
Posts: 144
Reputation: 1,588

Post » Mon May 02, 2011 1:12 am

The LOS behavior has been known to be buggy. I was trying to use it in some of the online games and the monsters didn't seem to chase the right players.

Hopefully, somebody else here had better ideas. Don't have time now, but if I get a chance I'll look at your cap..
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Mon May 02, 2011 11:55 am

Maybe use an instant hit bullet behaviour instead, when it hits a solid, destroy it, but if it hits an object you want to track, track the object. If you fire it every 500ms or so it shouldn't slow the game down too much..hopefully.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Mon May 02, 2011 12:22 pm

But wouldn't it only fire in a single direction? That would mean they would only detect another ship, say, if it was right in front of the ship? I am not sure if that's what you mean though :)

Also, would it happen to have anything to do with families? Maybe Construct gets objects within families when there is multiple instances of them mixed up? Also, to anybody that has looked through the CAP, the Pirate ships work exactly how they should, but the Alliance does not. I find this odd as the events are nearly identical. :S
B
8
S
2
G
2
Posts: 144
Reputation: 1,588

Post » Mon May 02, 2011 5:25 pm

For each object that is within X distance to turret, fire a "check bullet" at it to check if it can see the object, if it can, turn the gun to face the object and start firing real bullets at it.

Sadly, families could take some of the blame, they're alot better than they were, but still buggy sometimes.
"Construct 4 lets YOU make advanced games! (maybe)" Construct Classic - Examples Kit
B
86
S
28
G
13
Posts: 2,092
Reputation: 15,009

Post » Tue May 03, 2011 7:26 am

I see what you mean, but it still seems to have the same problem, the ship still seems to ignore the other ships sometimes while other times it doesn't... I guess the problem is with families then. Oh well, thanks for the help though! :D
B
8
S
2
G
2
Posts: 144
Reputation: 1,588


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests