Unpredictable script behavior.

Non-platform specific questions.

Unpredictable script behavior.

Postby SockOfOdin » Thu Jul 21, 2011 11:58 pm

Hello all.

I have been working on some scripts to handle collision type events in a platform game I have been making for the last couple of months and have been experiencing intermittent problems with the script. That is to say when I run the game sometimes one of two will manifest themselves and other times the game will run absolutely perfectly.

As you can imagine this is making debugging difficult as the problems are seeming fixed and reappearing on me so I was wondering if some of the experience people of the bored might have had similar problems themselves and would know what kind of things can cause unpredictable behavior.

Specifically can multiple conditions within one conditional statements - 4 in this case cause misreads, or would it be more likely due to a function being too long? As I say it doesn't seem to be a problem with the logic as 50% of the time it ass works perfectly.

Also has anyone had problems with filled regions not running create actor scripts on game load?
SockOfOdin
 
Posts: 4
Joined: Thu Jul 21, 2011 12:28 pm
Score: 1 Give a positive score

Re: Unpredictable script behavior.

Postby skydereign » Fri Jul 22, 2011 6:08 am

If it is working 50% of the time, it might be something that you are counting on that gE has problems with, but it could still be a problem with the code. I'd have to see it to help much, but the number of conditions in a statement shouldn't be a problem, though it does make it more likely to be messed up. Same goes for functions.

And for the last one, no, I've never had problems with the create of filled regions. Do you have an example of it not working?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Unpredictable script behavior.

Postby SockOfOdin » Fri Jul 22, 2011 12:47 pm

The code section from my shooting function run in the draw of the view actor bellow is the one that appears to be causing the trouble. Bullets hit objects that aren't there and characters die when not being shot. I will put up the ged tonight once I'm back from work.

Code: Select all
for(wallNum=0; wallNum < tcPop+1; wallNum++)//loop for bullet/ character collisions
{
cAct=getclone(charIn[wallNum]);// selects character actor from array
if(cAct->side != bAct->side){  //checks bullet and character are on different sides
collX = bAct->collw + cAct->collw - distance(bAct->x, bAct->y, cAct->x, bAct->y); //checks for X axis overlap
collY = bAct->collw + cAct->collh - distance(bAct->x, bAct->y, bAct->x, cAct->y); //checks for Y axis overlap
if(collX >0 && collY >0){ //finds if colliding
bAct->canjump=1; //destroys bullets (can jump variable somewhat changed its use)
cAct->health=cAct->health- 10;} //takes health away from hit character
}
}
}


As for the filled regions I have multiple clones of an actor running a script to register themselves to an index so I can use them in my collision script. Of the 3 I have in one test level at the moment every so often one of them seems to drop the script and not register with the index.
SockOfOdin
 
Posts: 4
Joined: Thu Jul 21, 2011 12:28 pm
Score: 1 Give a positive score

Re: Unpredictable script behavior.

Postby SockOfOdin » Mon Jul 25, 2011 2:41 pm

SockOfOdin
 
Posts: 4
Joined: Thu Jul 21, 2011 12:28 pm
Score: 1 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest