Looking at the game. I need more information on what is suppose to be happening. The interactions...
Do the soldiers acquire targets automatically, or are targets assigned to the soldiers by the player?
In which case, it would be good to have a canvas set up over the view and on mouse click of solider change animation to highlight the solider, then on mouse click of target draw line from solider to target.
Then make actor variables as such:
int HP
int Damg
int Target
Then on click assign values to each soldier based on the target ID.
Each actor will have the same variables. So you can assign each target an ID when you create it through:
CreateActor("p_target", "1", "(none)", "(none)", -325+130*i, 120, true)->Target = i;
Then when you click on the target after clicking on the solider you can get the value of the target clicked and assign it to the soliders target variable.
Then when you click the shoot button make a global int variable called OnShoot.
Then make a Timer event for the solider
( DO NOT USE: Draw Actor -> Script Editor -> )
Timer-> Script Editor
- Code: Select all
if(OnShoot) {
char buffer[15];
sprintf(buffer, "p_target.%i", Target);
getclone(buffer)->HP = HP-Damg;
}
Also since you are using create actor-> script editor to create the texts you can do this
CreateActor("t_target_HP", "icon", "Event Actor", "(none)", 10, 20, false)->Target = Target;
That assigns the target value of the target to the target text.
But then you have to do all the other stuff like updating the text of each t_target_HP through another Timer actor event like.
Timer-> Script Editor ->
- Code: Select all
char buffer[15];
sprintf(buffer, "p_target.%i", Target);
sprintf(text, "%i", getclone(buffer)->HP);
that gets the HP value of the target and updates it.
But then you need to create a conditional event for each target.
- Code: Select all
if(HP <= 0)
{
char buffer[15];
sprintf(buffer, "t_target_HP.%i", Target);
DestoryActor("buffer"); // Destroy the text first to avoid errors
DestroyActor("Event Actor");
}
But if you want each solider to just look for an open target then you have to check to see how many clones are left and assign the Target value on the Solider accordingly.
EDIT:
The only thing you need to do is make a timer for all the actors, Which you can do on create actor. You want their timers started when they are created. But if you can make all the events occur on one timer that's optimal.
Using for loops to iterate through your clones and updating there variables is the best way.