Using Tables for Enemies
indoorperson
Member Posts: 2
I am creating a tower defense styled game. I would like to have each individual enemy to have their own healthbar. I want to use the same actor sprite instead of having to create multiple actors each with their own healthbar. I think this can be done by using the tables system.
I created a table to experiment with and added 2 rows and 2 columns. The first column is an integar set at 1 and will be my temporary healthbar. The second column is text, labelled one and two.
I also created a global attribute called Monsters as an integer with a value of zero.
I then created an ingame object and set it to spawn two actors in random positions on the map changing the tables 2nd columns values to "Monster1" and :"Monster2". It would also change the global attribute "Monsters" to 2.
Then, on my monster actor, I added an text attribute labelled "zero". From here I planned to add a rule that, when the 1st row and second column contains "Monster1" and the global attribute is 2, to change its text attribute to Monster1. There would be an "else" statement saying that if 1st row second column contains "Monster2" and global attribute is 1 to change its text attribute to Monster2. Then when they get hit by a projectile thrown by the hero Monster1 would change the 1st column table value to zero and if its hit again it would destroy. The second monster would do the same.
Im not sure if I explained this correctly its rather complicated, however if there is a way to do something like this or something even simpler please let me know.
I wasnt able to find a way for the Monster actor to check the values of the table using the "if _Attribute_" condition. And there dont seem to be any other conditions that let me start an "if" statement.
I created a table to experiment with and added 2 rows and 2 columns. The first column is an integar set at 1 and will be my temporary healthbar. The second column is text, labelled one and two.
I also created a global attribute called Monsters as an integer with a value of zero.
I then created an ingame object and set it to spawn two actors in random positions on the map changing the tables 2nd columns values to "Monster1" and :"Monster2". It would also change the global attribute "Monsters" to 2.
Then, on my monster actor, I added an text attribute labelled "zero". From here I planned to add a rule that, when the 1st row and second column contains "Monster1" and the global attribute is 2, to change its text attribute to Monster1. There would be an "else" statement saying that if 1st row second column contains "Monster2" and global attribute is 1 to change its text attribute to Monster2. Then when they get hit by a projectile thrown by the hero Monster1 would change the 1st column table value to zero and if its hit again it would destroy. The second monster would do the same.
Im not sure if I explained this correctly its rather complicated, however if there is a way to do something like this or something even simpler please let me know.
I wasnt able to find a way for the Monster actor to check the values of the table using the "if _Attribute_" condition. And there dont seem to be any other conditions that let me start an "if" statement.
Comments
I should have a demo in a bit for you.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
In case it's helpful, here it is slightly different (tap the enemies to injure them):
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I think the only problem is that if you open a Mac Creator project file in Windows Creator, every index attribute is blank where the name of the attribute would be.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User