Having Trouble with cloned enemy actors...

Game Editor comments and discussion.

Having Trouble with cloned enemy actors...

Postby RippeR7420 » Fri Dec 09, 2011 6:30 pm

So, I have my enemy set up like this;

Enemy->Create->Script->

Code: Select all
Enemy.textNumber=3;


Enemy->Draw->Script->

Code: Select all
if(Enemy.textNumber==0)
{
DestroyActor"Enemy";
}


and on my Character;

Collision->AnySide->Enemy->Script->

Code: Select all
Enemy.textNumber=Enemy.textNumber-1;


now my problem is, if I clone the enemy, every Enemy dies when the textNumber=0;...

sorta like this I guess;

Code: Select all
EventActor.textNumber=3;

if(EventActor.textNumber==0)
{
DestroyActor"EventActor";
}


Is there a way I can set up a form of "EventActor" only on the Enemy that my Character is colliding with?
I've tried a few things, but nothing has worked yet...
+1 to whom who helps :)
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob: (On the back burner)

-StickMcGee - Blast to the Future http://game-editor.com/forum/viewtopic.php?f=4&t=13660
User avatar
RippeR7420
 
Posts: 391
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 23 Give a positive score

Re: Having Trouble with cloned enemy actors...

Postby Hblade » Fri Dec 09, 2011 8:27 pm

Just remove "EventActor." XD All you need is "textNumber" instead of "EventActor.textNumber"
Code: Select all
textNumber=3;

if(textNumber==0)
{
DestroyActor("EventActor");
}
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Having Trouble with cloned enemy actors...

Postby RippeR7420 » Fri Dec 09, 2011 10:43 pm

I tried that and it didn't work... :(
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob: (On the back burner)

-StickMcGee - Blast to the Future http://game-editor.com/forum/viewtopic.php?f=4&t=13660
User avatar
RippeR7420
 
Posts: 391
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 23 Give a positive score

Re: Having Trouble with cloned enemy actors...

Postby RippeR7420 » Fri Dec 09, 2011 10:46 pm

would I put both codes in the CreateActor Event?
Because I have it set up as just the;

textNumber=3;

in CreateActor, and the;

if(textNumber==0)
{
DestroyActor"Enemy"
}

.in DrawActor?..
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob: (On the back burner)

-StickMcGee - Blast to the Future http://game-editor.com/forum/viewtopic.php?f=4&t=13660
User avatar
RippeR7420
 
Posts: 391
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 23 Give a positive score

Re: Having Trouble with cloned enemy actors...

Postby skydereign » Fri Dec 09, 2011 11:29 pm

So, when addressing the event actor's variables, don't append the actor's name before it.
Enemy -> Create Actor -> Script Editor
Code: Select all
textNumber=3; // this will set the event actor's textNumber to 3
Enemy.textNumber=3; // this will set the Enemy with the lowest cloneindex's textNumber to 3

So, when you want to access the event actor's variables just use the variable, since using the actor's name will access the lowest indexed actor.

Also a word of warning, you shouldn't use textNumber for actors that aren't text actors. Also, you shouldn't use textNumbers like that. textNumbers have been known to behave oddly when you use them like a normal variables. You should only use them for displaying text, like this.
text_actor -> Draw Actor -> Script Editor
Code: Select all
textNumber=score;


Now, another thing that Hblade corrected for you, but you haven't fixed is the DestroyActor. DestroyActor is a function, so you have to use the (), instead of what you were using DestroyActor"Enemy";.
Code: Select all
DestroyActor("Event Actor");

And like using Enemy.textNumber, you can't use DestroyActor("Enemy") as that will destroy all Enemy actors. It isn't what you call clone specific. You need to destroy the "Event Actor".
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Having Trouble with cloned enemy actors...

Postby RippeR7420 » Sat Dec 10, 2011 12:40 am

@Sky: I know the DestroyActor Function... I was just quickly typing real quick haha.. and I am not even using Destroy Actor..

I tried to use a variable also, but when I clone the enemy the variable is cloned also...
How would I do what I am trying to do?
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob: (On the back burner)

-StickMcGee - Blast to the Future http://game-editor.com/forum/viewtopic.php?f=4&t=13660
User avatar
RippeR7420
 
Posts: 391
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 23 Give a positive score

Re: Having Trouble with cloned enemy actors...

Postby skydereign » Sat Dec 10, 2011 12:47 am

Well what you're really doing is creating an hp system. So, don't use textNumber, create an actor variable called hp. Since the collision event belongs to the player, and collides with the enemy, you can use collide.hp to access the colliding Enemy actor's hp.
Enemy -> Create Actor -> Script Editor
Code: Select all
hp=3;

Player -> Collision with Any Side of Enemy -> Script Editor
Code: Select all
collide.hp--;

And last you have your DestroyActor check in the Enemy's draw actor event, though you could put it in the collision if you wanted.
Enemy -> Draw Actor -> Script Editor
Code: Select all
if(hp==0)
{
    DestroyActor("Event Actor");
}


That's pretty much what you had, but you were using textNumber, and you didn't use collide.var.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Having Trouble with cloned enemy actors...

Postby RippeR7420 » Sat Dec 10, 2011 3:31 pm

Ahh! Sky you're a genius!! haha, I forgot I had to make my variable an "Actor" variable and not a "Global" haha.
Thank you! +1!
CURRENT PROJECTS:

-Olo: The Sword Shaman http://game-editor.com/forum/viewtopic.php?f=4&t=12919

-The Wrath of Blob: (On the back burner)

-StickMcGee - Blast to the Future http://game-editor.com/forum/viewtopic.php?f=4&t=13660
User avatar
RippeR7420
 
Posts: 391
Joined: Mon Apr 27, 2009 4:16 pm
Location: Salt Lake City, Utah.
Score: 23 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest