Alice Community On "if"s
 User Name Remember Me? Password

 Thread Tools Display Modes
 On "if"s
 Matchewawa Member   Status: Offline Posts: 32 Join Date: Feb 2011 On "if"s - 04-05-2011, 12:04 AM I wonder, is there a way to establish an amount of times that a function happens before the "then" happens in an "if, then". In other words, lets say that you are attacking an enemy. When you attack him, the "if" sees that you attacked him and runs the method for his immediate death, but could you set the function in the if so that if that happens so and so times (let's say three), then the death sequence happens? I've tried many things over the time that I've been using Alice. I did find one way, but it's tedious and inefficient for multiple enemies. I'm trying to establish hitpoints for enemies so that they don't just die the first time you hit them. Last edited by Matchewawa; 04-05-2011 at 12:22 AM.
 TheWhiteGuy Guest   Status: Posts: n/a 04-05-2011, 12:23 PM I guess what you can do is create a health bar that can or cant be seen.
nickster654
Senior Member

Status: Offline
Posts: 180
Join Date: Feb 2011
Location: nickster12345678@gmail.com
04-05-2011, 04:09 PM

Quote:
 Originally Posted by Matchewawa I wonder, is there a way to establish an amount of times that a function happens before the "then" happens in an "if, then". In other words, lets say that you are attacking an enemy. When you attack him, the "if" sees that you attacked him and runs the method for his immediate death, but could you set the function in the if so that if that happens so and so times (let's say three), then the death sequence happens? I've tried many things over the time that I've been using Alice. I did find one way, but it's tedious and inefficient for multiple enemies. I'm trying to establish hitpoints for enemies so that they don't just die the first time you hit them.
you could say if object is clicked on (or shot or whatever) increment number variable by 1

if number variable = 3
Object dies (or whatever)

 What??
 Matchewawa Member   Status: Offline Posts: 32 Join Date: Feb 2011 What?? - 04-05-2011, 04:16 PM I'm not sure I get that. Could you elaborate?
 Lordelwood Senior Member     Status: Offline Posts: 43 Join Date: Oct 2010 04-05-2011, 04:30 PM what hes saying is give each enemy a variable, then set the number to 3, 5 hoe ever many times you want them to be hit before they die, then in your code that hits them, have an if else statement saying, if zombie [health variable]>0, decrease health value by 1, else zombie dies... does that help any?
 Never Mind
 Matchewawa Member   Status: Offline Posts: 32 Join Date: Feb 2011 Never Mind - 04-05-2011, 04:34 PM Never mind, I get it. I was just reading it wrong. Working on it now. Thanks.
 Lordelwood Senior Member     Status: Offline Posts: 43 Join Date: Oct 2010 04-05-2011, 04:56 PM no problem, good luck
 Matchewawa Member   Status: Offline Posts: 32 Join Date: Feb 2011 04-05-2011, 09:54 PM I made the variable for the enemy's damage, set it to increment by one when you hit him, and then I set a seperate if saying that if the variable equals 3, then I set his visibility to false. (And thanks to something in his AI method, he will stop following me and get out of the way of the level) This makes perfect sense to me, but it's just NOT WORKING. I don't know why, but I've arranged it in like 10000 different ways and nothing seems to work. It seems that the "if KnightDamage == 3" is not reading the KnightDamage variable's value.
Lordelwood
Senior Member

Status: Offline
Posts: 43
Join Date: Oct 2010
04-05-2011, 10:05 PM

Quote:
 Originally Posted by Matchewawa I made the variable for the enemy's damage, set it to increment by one when you hit him, and then I set a seperate if saying that if the variable equals 3, then I set his visibility to false. (And thanks to something in his AI method, he will stop following me and get out of the way of the level) This makes perfect sense to me, but it's just NOT WORKING. I don't know why, but I've arranged it in like 10000 different ways and nothing seems to work. It seems that the "if KnightDamage == 3" is not reading the KnightDamage variable's value.
try the damage is >= 3
that way if the value goes over it will still register
umm, its really hard to say what the problem is without seeing it, if you wouldn't mind could you post it? so we can see where the issue is... i dont know if thats a fair question

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge