Page 1 of 1

In demo TileRange Boss, the boss suddenly disappears

PostPosted: Tue Jul 08, 2008 1:16 am
by desertgamer
In my demo, TileRange Boss, the boss ship can suddenly disappear randomly, and everything in my code doesn't cause this. So why is this? I spent loads of time trying to figure it out, and my only conclusion is that it has something to do with Game Editor -- but what is the real reason? Does it have something to do with initiating variables? I'm just clueless... Anyone up there know the solution?
:?

Re: In demo TileRange Boss, the boss suddenly disappears

PostPosted: Tue Jul 08, 2008 3:25 am
by DST
There are lots of things that can actually cause this, don't get too worried.
I'm not sure how your problem is working out - does the boss flicker, does he move far away and come back, does he hide behind the background?

The first one it to check your code for = errors. This one seems obvious but it happens a lot...Saying if(canjump=0) will MAKE canjump=0. Make sure there are no single ='s in if checks, and no double ='s in the rest of the code.
This can make it do something different than what you thought it was doing. == compares; = makes it so.

The second one is to remove any parent/child relationships the boss may have, and replace them with drawactor>x=boss.x, y=boss.y(-offset) of course. See if that makes the problem go away.

If you don't have child/parent, check your variables. (if you are using variables). Sometimes we end up asking for whole numbers when they are really decimal places, in that case we should use (round) or (float) to choose which. In that case, you can be asking ge to round up a number on its own that keeps changing while its doing it.

Also, check the ZDEPTH of the boss actor vs. the background, or anything else that could fight with him. Ge doesn't like it when two overlapping actors have the same zdepth.

If all that fails, and you're still stumped, post your files so someone who is experienced can take a look at them.
I made a similiar post a year ago, only in my case the boss came back after he was dead. I had nothing in the code that would make him do that. But there it was. So I decided it was a GE error, until a friend put me up to the challenge. He wanted me to prove it, so I removed every actor and script in the game except for the player, his weapons, the backgrounds, and the boss. And the problem didn't happen.

I went thru that code 300 times. There doesn't seem to be anything wrong. What happened, I think, is that something I didn't say in the code, that should have been said, that left the program trying to decide something that had no way to decide. The constant decision making was interpreted by windows as a buffer overflow, and the game crashed.

I never did fix it....i just went on to other games....which is why i'm so interested in your problem...i still want to make that game work.

Re: In demo TileRange Boss, the boss suddenly disappears

PostPosted: Wed Jul 09, 2008 4:12 am
by desertgamer
Thanks for your concern about some of my "problems" with the level. Actually, your explained situation would be quite similar to mine... indeed... going onto more games and living with these unexplainable (supposedly) errors. My TileRange boss demo is actually posted on the demos page, so if you would like to take a closer look at that file, feel free to do so. Most of the time the game does what I tell it, but randomly certain things can really malfunction!

I have an indication to where my boss goes (I use MoveTo events to teleport my player to the departed boss), but can't explain why it goes there. The boss is found directly at the game center. Nothing in it's code should do such a thing. My boss has no parents to any actors, nor other actors have a parent to it (except with the mega-lazer when it is fired, which is created individually through Script Editor and afterwards destroyed).

...Oh, I have an additional question. I use variables a lot, but I have no idea how to actually indicate and use "clone variables." In scripts, I assumed you would use the actor followed by the clone index and then the defined variable, such as 'myActor.1.myVariable', but that doesn't work. I really need an independent actor variable for each of the clones in the games I make. (I make Side-Scrolling levels that can require many different events for each clone... pushing a button there to trigger a different event, setting many actors to hold values, and such.) So just how to you define and use "clone variables?" That would really help...

Re: In demo TileRange Boss, the boss suddenly disappears

PostPosted: Wed Jul 09, 2008 9:39 am
by DST
You have to use the getclone or getclone2 function to access clone variables from another actor's script.

There is limited functionality to these functions, so I avoid them, by using relative names and timers.
relative names include:
collide
parent
creator

collide.transp, parent.y, creator.y etc. etc. Of course that only works if such a relationship exists with the clone.

So the other way is to call the clonenumber in the actor itself.

I use timers, say in a pinball game, there are all these lights, they are clones, and i want a certain set of lights to light up when something else happens, so i'd send a timer
CreateTimer("lights", "timername", timerlength);
This will create the timer for ALL lights.

Then on lights>timer i'd use a switch of cloneindex to determine which lights need to do what.
for a set of lights, you could use an if
if(cloneindex>5 && cloneindex<11){animpos=1;}

That script would cause lights 6-10 to light up.

Now the other part to this is reading a value from a clone, to affect something else. For instance, an actors event may depend upon a variable held by some clone; One quick method to this is not to use actor variables, but an array variable.

Lets say clone.damage, we change damage to be a global integer, array. Make the array size larger than the max clone number(to prevent writing out of the array).

Now instead of saying clone>createactor> damage=10;
You'd say clone>creatactor>damage[cloneindex]=10;

Then you could simply ask for damage[number] and it would return whatever value is stored there. And any time you referred to a clone variable, you'd say variable[cloneindex], or variable[n].

Between relative names, timers, and arrays, you should have no problems changing or accessing any variable for any clone.

Re: In demo TileRange Boss, the boss suddenly disappears

PostPosted: Wed Jul 09, 2008 10:25 pm
by desertgamer
Thanks for the reply! I have experimented with your details, and I have come to find a way of how to use the cloneindex variable with distant actors. I created a new variable -- a 'cloneindexEffect' variable, which is an actor variable. I used two actors. One was the test actor, and the other a button. The cloneindexEffect variable matches the value of the index of the clone that would be affected. In the test actor, I used Draw Actor to constantly check if the cloneindexEffect variable matches a value to trigger the clone's variable. So if I want a clone--the test actor in this case--to go a certain velocity, I could define that in it's Draw Actor. And sense yvelocity is constant, it won't be overlapped with other effects that cause different clones to move.

The button just triggers the cloneindeEffect on the test actor.
The test actor checks that incoming cloneindex effect and takes foreword the effect using the cloneindex to define the clone which is affected.

Here's the button script. When the player collides, this script is triggered:
test.cloneindexEffect=1; // The affected clone of test will be index 1.

This is the test actor's event of draw actor: The cloneindexEffect variable was defined by the button actor.
if(cloneindexEffect==1)
{
if(cloneindex==1)
{
yvelocity=+6; // Test.1 would have the velocity.
}
}

So cloneindexEffect causes the cloneindex to think it's active, and takes on the effect of that clone!

...Did I make much sense...? Thanks anyway... Wow ...you could do so much with Game Editor!

Re: In demo TileRange Boss, the boss suddenly disappears

PostPosted: Thu Jul 10, 2008 12:15 am
by DST
Hey that's a great solution!

You could use it to trigger any event...This may be the simplest way to send external commands to clones there ever was.....You could just make a list of events and now you have total control over your clone's behaviours.

You could expand it to three global variables (they don't have to be actor variables)

effect, type, and modify;
Have a case switch for the different types;
1=directional_velocity;
2=destroyactor;
3=transp;
4=ChangeAnimationDirection("Event Actor", FORWARD);
5=EventDisable etc. etc.

So you'd say
if(effect==cloneindex){
switch(type){
case 1:
directional_velocity=modify;
break;
case 2:
DestroyActor("Event Actor");
break;
case 3:
transp=modify;
break;
}
type=0;
effect=0;
modify=0;}

and so on

So now we can say
effect=14;
type=3;
modify=.5;

and clone number 14 will change its transparency to .5

effect=15;
type=1;
modify=12;

and clone number 15 will change its directional velocity to 12.
And after doing so, the numbers all get reset to 0 to wait for the next use! Of course this would affect clone 0, but nothing would happen to clone 0 because type and modify are 0 as well!

There's almost no limit to how many effects you could work into that, though animation names could be a pain, but you can't use those in getclone either! And i think feral found a way for us to sprintf animation names, so we could work that in to this method as well!

I think we've just made getclone and getclone2 obsolete!!!!

Re: In demo TileRange Boss, the boss suddenly disappears

PostPosted: Thu Jul 10, 2008 10:53 pm
by desertgamer
It's amazing what you could do with Game Editor! ...And what reliable discoveries you could make at the forum! I have no more to say...

Re: In demo TileRange Boss, the boss suddenly disappears

PostPosted: Fri Jul 11, 2008 1:59 am
by feral

There's almost no limit to how many effects you could work into that, though animation names could be a pain, but you can't use those in getclone either! And i think feral found a way for us to sprintf animation names, so we could work that in to this method as well!

I think we've just made getclone and getclone2 obsolete!!!!



sorry guys.. I see a major problem with this.. ( or i could be wrong)
it is a very useful tool i admit... but it takes a redraw to change ONE clone...
if you want to change 20 or so it would take 20 frames.. ????
or did I read it wrong ?

Re: In demo TileRange Boss, the boss suddenly disappears

PostPosted: Fri Jul 11, 2008 2:20 am
by DST
That all depends on how you write the events.

I think that's the point of this topic.

You could easily make your three variables arrays, and then write as many events at a time as you want.

Basically, in this case it would be,
if (effect[cloneindex]!=0){
do the aforementioned script(with the array value instead of the single variable value);
effect[cloneindex]=0; value[cloneindex]=0; modify[cloneindex]=0;
}

So that comes with an automatic reset, and everything. You can also, from the control actor, use cloneindex to send the command like
collision>
effect[collide.cloneindex]=blah blah blah

I also would send these as timers, rather than draw actor, but i am trying not to say too much in each post. Let people take it step by step.

Re: In demo TileRange Boss, the boss suddenly disappears

PostPosted: Fri Jul 11, 2008 2:31 am
by feral
this is the way i have alwasy done it..

mostly because i never understood getclone :(

for any actor variable I want to change in a clone I create an array

for example
in Global

float clonetransparency[200] // for max of 200 clones

then in each clone I add
transp=clonetransparency[cloneindex]; // each redraw check the array for current value and set transp..

for every clone i want to change the transparency on
from ANY actor

clonetransparency[3]=.5; //changes transparency of clone 3

or

for (i=3;i<7;i++) //change clones 3 through 6
{
clonetransparency[i]=.3;
}

feral

Re: In demo TileRange Boss, the boss suddenly disappears

PostPosted: Fri Jul 11, 2008 2:47 am
by feral
using my method above

changing animations (or any actor string variable)

create global user variable

name: cloneanimation //or whatever you like...
type: string
as: global
Array: yes
size: 200

next

set animation to change clone to using ANY actor

strcpy(cloneanimation[3],"dying"); // set animation for clone.3 to "dying"

in clone draw event

if (dead==1) // or whatever test you have
{
ChangeAnimation("Event Actor", cloneanimation[cloneindex], FORWARD);
}

works for all actor string variables

feral