Clone Help Variables

Non-platform specific questions.

Clone Help Variables

Postby skydereign » Tue Aug 12, 2008 7:09 pm

I'm working on a turnbased strategy game and I have built some successful units. The problem is, when I clone the actor more than 3 times, only half of the clones will do what I want. Is there a reason for this? I think the code is right, as some of my actors will work. The error that occurs happens when I move one unit. The unit that I previously selected has the move range around it, and when I move try to move it , the previous actor moves, but only some do this. Others will create the move range and move as I want, then stop and disable till next turn. The error makes it look like a miss of global and actor variables but I can't find it.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Clone Help Variables

Postby feral » Wed Aug 13, 2008 4:17 am

how are you referencing your clones ? by clone index number ?
this has problems if you are destroying and recreating clones, as the numbers keep changing..just a thought..

I think we need more detail..

any chance of a small demo version of the problem.. it does not need to be the full game, just enough of it to reproduce the problem..
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: Clone Help Variables

Postby skydereign » Wed Aug 13, 2008 4:51 am

I'm not, I don't think. The actor itself should turn off through a variable activating when I click on a wait box which then sets an actor specific variable to shut the actor down, resetting the off variable. Ultimately, I want to be able to make a factory for the units by making a clone. Right now, I am just testing if the units I have work. An example being:
2 actors for the red team; they both work together (can move attack and then shut down till next red turn)
1 actor for the blue team; works the same way
Next red turn they still work
When I make clones of one of the red actors, some of the clones do act the same way as the original actor, while others do not. The error usually is, the move range appears around a recently moved actor that should be shutdown. When I press up or down, the actor with the move range around it moves and not the one selected.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Clone Help Variables

Postby feral » Wed Aug 13, 2008 5:01 am

ok.. sounds more like a coding problem... any chance of a demo version ? and i can check it for you.
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: Clone Help Variables

Postby skydereign » Thu Aug 14, 2008 5:36 am

This is kind of it. It is not as functional as it was. Sometime yesterday I forgot what I changed and saved over the original. I have been working on a redo, trying to find the problem while removing some of my redundant code. In game mode, the spriteless actors are the ones I am trying to fix. The actors are not renewed upon there turn though. If you click on the actor blah and move it then click wait, that should stop the actor. Move to the next and so on, you should see the problem.
Attachments
tbs.zip
(158.86 KiB) Downloaded 142 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Clone Help Variables

Postby skydereign » Thu Aug 14, 2008 5:59 am

Even more mysterious, I have isolated a working and not working example while remaking it. If you select the units in this ged and click on wait, left to right (clones 0,1,2) the third clone will make the move range around (clone.1). Any other order works, I think. I don't see a reason for this. Is there?
Attachments
TBS.zip
(141.89 KiB) Downloaded 152 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Clone Help Variables

Postby feral » Thu Aug 14, 2008 6:05 am

I downloaded it ok, and I can see the problem as you describe... I may not get to look at it till tomorrow tho..
i think you are right tho, it initially looks like some confusion between actor variables, and global vars.. I will need some time to check them all..
cheers
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: Clone Help Variables

Postby feral » Fri Aug 15, 2008 12:08 am

ok, i think I found the problem..

when you are setting all the global flags etc to activate certain events during the clone draw event, you are not telling any of the cloned actors which one of them should activate the event, so basically what is happening is..

the very first clone that is drawn that also matches all the criteria will be the one doing the actions, even if it is not the correct clone..

I suggest creating a new a actor variable called something like selected_clone, then on the mouse down event (when selecting the clone to move/attack) set this to 1.
eg:
selected_clone=1;

now... when all the clones are going through all the actions, you can tell them only to do what is needed.. IF they are the "selected clone"... otherwise ignore

if (selected_clone==1)
{
do all this code.. otherwise ignore..
}

or you can use it on individual actions like

Code: Select all
if (move_select==1 && selected_clone==1) //only do this if I am the right clone to do it..
     {
//insert code here
     }


then at the end of the clone draw script ( or wherever works best) turn off the flag

selected_clone=0;

and none of the actions will occur on that clone until it is reselected..

hope that helps
feral
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: Clone Help Variables

Postby feral » Fri Aug 15, 2008 12:17 am

skydereign wrote:Even more mysterious, I have isolated a working and not working example while remaking it. If you select the units in this ged and click on wait, left to right (clones 0,1,2) the third clone will make the move range around (clone.1). Any other order works, I think. I don't see a reason for this. Is there?


BTW, the reasons there seems to be an order to the problem in these cases, is that.. usually the lowest indexed clone is drawn first... then going up
( I believe)

which means depending on the coding/formula etc some actions will occur correctly.. providing you are selecting clones in order from bottom to top.. or vice versa in some instances.. but as soon as you change the order... things will go funny because lower order clones will do the actions meant for higher orders ( and or vice versa)
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: Clone Help Variables

Postby skydereign » Fri Aug 15, 2008 7:58 am

I'm not completely following. You are saying that I should put an actor specific variable, (selected_clone), in and have it initiated when the clone is clicked? Then in the clone's draw script, make it so the clone does the moving/attacking actions only when this variable is turned on. Upon clicking the wait button, the variable for the clone should then be shut off so the actions cannot occur.
If this is, I thought I did that with the (Selected) variable. It is an actor specific variable that turns on when clicked, signifying that this is the currently selected clone. Then in my draw script, after saying that it must be red's turn, I say that the actor must be selected;

if (Selected==1)
{
<Here is where all of the moving commands and what not are, including the creation of the move range>;
}
Then in the draw script, upon clicking the WAIT button, deselect the clone.
if ( Disable_Unit_G==1 && Selected==1) // Disable_Unit_G is triggered by clicking the wait button
{
Disable_Unit_A=1;
}
if (Disable_Unit_A=1)
{
Selected=0;
And other shutting off functions.
}

I believe this is what you are talking about. If not, can you please explain where the variable is triggered and stopped. Unless there is need of two actor selected variables. On the second version, I got rid of some variables, which might have been what you are talking about... I don't know.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Clone Help Variables

Postby skydereign » Fri Aug 15, 2008 8:06 am

Concerning the three actors sometimes working in some orders but not others, I am not sure your explanation fits, or maybe I just don't understand your answer. The only time I can get it to fail with three actors is if I go from the first, clone.0 -> clone.1 -> clone.2. With more, I have no idea what goes on, but usually half of the actors work. Is this due to the non (select_clone) activation or the drawing order?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Clone Help Variables

Postby feral » Fri Aug 15, 2008 8:42 am

skydereign wrote:I'm not completely following.


I will post an example file in the morning, sorry my explanation wasn't clear, i have a bad habit of over explaining things :(

BTW the game idea itself, looks really promising, will talk to you soon..
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: Clone Help Variables

Postby feral » Sat Aug 16, 2008 12:10 am

skydereign wrote:Even more mysterious, I have isolated a working and not working example while remaking it. If you select the units in this ged and click on wait, left to right (clones 0,1,2) the third clone will make the move range around (clone.1). Any other order works, I think. I don't see a reason for this. Is there?


Ok, your newer version was bit easier to follow :D and, you seem to have fixed the "Selected" variables OK.. so, you no longer need my solution above..

but, I think I may have found the new problem here, in the draw event of the tanks - the actor variable Disable_Unit_A does not appear to be disabled after action ?


if (Disable_Unit_A==1)
{
Disable_Unit_G=0;
Selected=0;
Stopped=1;
Disable_Unit_A=0; <------------------------------------ missing flag ??
EventDisable("Event Actor", EVENTALL);
}

or at least I hope that is it... sorry for taking so long with this... :?

I also added some debugging code that may be useful.. they will follow the tanks around and you can change what they show in the draw tank event.

TBS.zip
(262.4 KiB) Downloaded 141 times
User avatar
feral
 
Posts: 308
Joined: Sun Mar 16, 2008 6:27 am
Score: 47 Give a positive score

Re: Clone Help Variables

Postby skydereign » Sat Aug 16, 2008 12:43 am

Thanks a lot. It works now, but I am not exactly sure why. The changes to make it work were to reset the (Disable_Unit_A) variable, and to reset the (Stop_Move) variable. But why would this prevent the previous clone from creating the move range actor? I understand why the moving works again but the creation of the move range on the right clone I don't. Regardless, thanks for the fix and the debugging system.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Clone Help Variables

Postby skydereign » Sat Aug 16, 2008 8:02 am

The moving now works but I have now implemented the attacking and the actual health to the new version but the animpos.* does not register change in the (HP) variable I have set. The health goes down when attacking, shown by the debugging numbers, but the actual animation does not change. Do you know what is causing this? Only the last actor remaining will show the change.

-Edit
Do I need to use (Selected) for distinguishing which clone gets dealt damage? Or a similar concept. Now and then, when attacking, the wrong clone changes animation. Or should I just use numbers for health. Though I don't like the idea of me giving up and letting the clones beat me. I have tried making a variable (sub_select) that is 1 when the mouse is over the actor. This should signify the same as (Selected) without the moving features.
If you are attacking, the range pops up. If (sub_select==1) and you click on it then lower health. But this still has problems defining which clone.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron