Page 1 of 1

Bad Revolt bug

PostPosted: Thu Mar 13, 2014 9:49 pm
by CrackedP0t
A vicious bug in my game for last month's tournament.
Once the "Again!" button's been pushed, the autocatchers only target where I placed the enemy in the editor, despite the fact that I set it to not create in the beginning.
Here's the code:

Re: Bad Revolt bug

PostPosted: Thu Mar 13, 2014 11:47 pm
by lcl
I found the problem and created a fix.

The problem is that somehow GE doesn't always determine actor pointers to destroyed actors as NULL's, but actually points to the data the already destroyed actor had.
So, to avoid that I made an actor variable called exist and set that to 1 on every badshot actor's create actor event.

Then, where ever you used to check if (clone != NULL) or if (closestshot != NULL) just check if (clone->exist) and if (closestshot->exist).
You can also remove the check for if (clone->x != 0) and if (clone->y != 0)

Then, for the case when the actor can't find any clone that's free to start chasing on, you have to do something or it'll just continue with the previous direction and velocity and drift away from screen.
One way is to have an else statement and set it's directional_velocity to 0 there.

The other one is to have walls surrounding the game area and then adding PhysicalResponse between the actor and the walls, or a code to change it's angle to the opposite direction or something else.
EDIT: For example you could just throw a
Code: Select all
angle -= 180;

to the actor's Out of Vision -event. I tested it, and it works even when the value would go to negatives. If the angle is 45 and this code triggers, the angle gets set to 225 instead of -135. It's a noobish way to code it, but GE seems to be made to support it so I guess it's "legal" to do so. :)
--- EDIT ENDS ---

Then another problem is that GE's clone numbering isn't the clearest one possible.
I noticed that your for loop goes from bottombadshot to badshots, with bottombadshots being the number of the lowest indexed clone.
However, it was coded in a way that allowed that number to be wrong. And also, GE resets the clonenumbers to 0 if all clones get destroyed.
So I recommend you to just loop from 0 to badshots.

I hope this helps. If you need my fixed version ged, I can send it to you, but these instructions should be enough to help you fix it by yourself. :)

Re: Bad Revolt bug

PostPosted: Fri Mar 14, 2014 12:49 am
by CrackedP0t
OK, it seems fixed to me.
But would you mind checking it over?

Re: Bad Revolt bug

PostPosted: Fri Mar 14, 2014 2:13 am
by lcl
I can't check it right now, I'm going to sleep. But I'll check it tomorrow.
However, if you need me to check if it is fixed, it sounds like there's something that doesn't work as you'd like it to, am I right? :D

Re: Bad Revolt bug

PostPosted: Fri Mar 14, 2014 6:36 pm
by lcl
I took a look at it and noticed one thing missing. But that was because I forgot to mention adding it xD

You have to add a destroy actor event to the badshot actor where you set its exist = 0.
Otherwise it looks basically the same as my version did.