Health with cloned actors

Non-platform specific questions.

Health with cloned actors

Postby Zehper48 » Thu Nov 23, 2006 2:13 am

Hey is there an easy way or even a way at all to make a healthbar spawn for and enemy clone actor for example, if i have a smiley actor called creator that creates actor enemy,but i want the enemy to only be destoryed after 5 hits from actor bullet, can i do that
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby makslane » Thu Nov 23, 2006 12:28 pm

Create a variable lives (Actor, integer).
Actor variables are not global, so, if you have a clone with lives = 3, you can have other with lives = 1.
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Zehper48 » Thu Nov 23, 2006 11:14 pm

do variables work like textNumbers
whats the code to make a variable go down if a bullet hits it
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby makslane » Thu Nov 23, 2006 11:39 pm

In a Collision event, put a script like this:

Code: Select all
lives--;
if(lives <= 0)
{
   //You are dead!
}
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby Zehper48 » Fri Nov 24, 2006 2:47 pm

im trying to make a bad guy that i can clone but im not used to useing variables.
on actor "badguy" i added this to draw actor
Code: Select all
if(badguylives <=-1)
{
   DestroyActor("Event Actor");
}


then on collison with actor "redassultleft"
Code: Select all
badguylives - 1;
but actor "badguy" wont die
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby Hedfone » Fri Nov 24, 2006 6:19 pm

try, on create actor of enemy, something like:

Code: Select all
badguylives = //the desired number of shots to kill;


this might work but I'm god awful with coding so I'm not sure :D
User avatar
Hedfone
 
Posts: 174
Joined: Mon Jul 31, 2006 9:47 pm
Score: 2 Give a positive score

Postby Zehper48 » Fri Nov 24, 2006 8:38 pm

ok i added that too but the bad guy wont be destroyed! i dont know what to do
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby Hedfone » Fri Nov 24, 2006 9:10 pm

think I found it,
on collision with redassaultleft the code SHOULD be
Code: Select all
badguylives -=1//updates every shot
or
Code: Select all
badguylives=badguylives-1;//updates every shot


not

Code: Select all
badguylives = -1;//simply tells the comp the value


the first and second one will update the health every shot. the third one tells the comp that you want the lives of the enemy to be -1 when the enemy collides on the bullet
and on that draw actor event, change

Code: Select all
if (badguylives <=-1)

to
Code: Select all
if (badguylives <=0)


REALLY hope this has helped. good luck :D
User avatar
Hedfone
 
Posts: 174
Joined: Mon Jul 31, 2006 9:47 pm
Score: 2 Give a positive score

Postby Zehper48 » Sat Nov 25, 2006 2:42 am

yes i got it working the bad guy dies! Thanks man for helping me you deserve a medal!!!!!
i changed the code from badguylives-1; to badguylives=badguylives-1; and it worked, now i can continue my game
I like score
User avatar
Zehper48
 
Posts: 241
Joined: Sun Jun 11, 2006 1:34 am
Location: Advanced Noob
Score: 4 Give a positive score

Postby Hedfone » Sat Nov 25, 2006 5:11 pm

Great :D
I'm happy I could help
User avatar
Hedfone
 
Posts: 174
Joined: Mon Jul 31, 2006 9:47 pm
Score: 2 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest