Unit[A][1] checks which player has triggered this and the 1 is the unit that has the spell. Problem is, the computer never does anything in-game. I really have no idea what I'm doing wrong here. Any help is appreciated! Thank You!
Try removing (Status of player A) == Unused first.
I have a feeling that having a Computer slot is considered a Used slot.
Try that first.
EDIT:
Also, you don't have to make Target Unit and Target Location variables into arrays if you're not going to use them with arrays. Although if you have a reason to having them as variables with array, then go ahead, I highly recommend you to use them.
I removed that Condition and the computer still didn't do anything. I'm pretty sure I used the Target Unit and Target Location arrays the wrong way. Since there can be up to 5 computers in the map, I didn't want all of them to have the same target.
Thanks for helping with the arrays. I changed the code to what you wrote but the computer still won't do anything. I'm pretty sure they have the energy to cast the storm, as I gave the units 500 energy to start with.
Thank You, but there are some problems with that. When you move 1 step in-game; the game takes over your unit and makes you cast a spell even when you're not idle. I was also hoping this would continuously loop for the computer. Meaning, once they cast the spell, they either keep attacking that same unit or go to a different one right away. Right now, they use the spell and then just stop until the next unit that goes idle. Also, they only move 1 at a time instead of every computer always moving around.
I tried it with the loop again with the condition, so only computer players end up moving, but that loop just seems to not do anything.
Adding the if statement made the units not do anything again. It seems whenever the condition Computer[#] == True is added, they don't do anything. So I'm guessing the computers aren't being set properly?
----------
EDIT: I figured it out. I had to use (Status of Player A) == Unused because it wasn't recognizing the computers any other way from all the tests I ran. It runs pretty good now, but there is 1 problem. Lets say the Zealot is told to cast PSI Storm. Instead of casting it on the unit, it will go to the last known position the unit was at and cast it there. I can't figure out how to fix this. I'm sure it has something to do with "Random Living unit etc..." variable. Here's the code:
I'm having trouble in coding the A.I to use skills on a random unit in the map. First, I check if they're any computer players by:
After this I make my attack trigger for the computer:
Unit[A][1] checks which player has triggered this and the 1 is the unit that has the spell. Problem is, the computer never does anything in-game. I really have no idea what I'm doing wrong here. Any help is appreciated! Thank You!
Try removing (Status of player A) == Unused first.
I have a feeling that having a Computer slot is considered a Used slot.
Try that first.
EDIT:
Also, you don't have to make Target Unit and Target Location variables into arrays if you're not going to use them with arrays. Although if you have a reason to having them as variables with array, then go ahead, I highly recommend you to use them.
Member since 2010. Made the -The Thing- [Revival] game. Nostalgic of the WC3 days.
I removed that Condition and the computer still didn't do anything. I'm pretty sure I used the Target Unit and Target Location arrays the wrong way. Since there can be up to 5 computers in the map, I didn't want all of them to have the same target.
Thanks for the response!
@Layola: Go
Yeah, you're using arrays wrong. Also take out the status = unused just because it's pointless.
Revision:
Thanks for helping with the arrays. I changed the code to what you wrote but the computer still won't do anything. I'm pretty sure they have the energy to cast the storm, as I gave the units 500 energy to start with.
@Layola: Go
The units also have to have the ability you're trying to make them cast.
If you upload the map I'll take a look.
I did give them the skills as I can cast them myself. Map attached below.
Key:
Main is where computer players are determined and Attack under the folder Computer is the trigger to make them attack.
Right & Left click casts your spells.
WSAD moves your unit.
Thank You!
The loop was unnecessary. This works:
Thank You, but there are some problems with that. When you move 1 step in-game; the game takes over your unit and makes you cast a spell even when you're not idle. I was also hoping this would continuously loop for the computer. Meaning, once they cast the spell, they either keep attacking that same unit or go to a different one right away. Right now, they use the spell and then just stop until the next unit that goes idle. Also, they only move 1 at a time instead of every computer always moving around.
I tried it with the loop again with the condition, so only computer players end up moving, but that loop just seems to not do anything.
@Layola: Go
Oops, I forgot to re-add the if statement.
Adding the if statement made the units not do anything again. It seems whenever the condition Computer[#] == True is added, they don't do anything. So I'm guessing the computers aren't being set properly?
----------EDIT: I figured it out. I had to use (Status of Player A) == Unused because it wasn't recognizing the computers any other way from all the tests I ran. It runs pretty good now, but there is 1 problem. Lets say the Zealot is told to cast PSI Storm. Instead of casting it on the unit, it will go to the last known position the unit was at and cast it there. I can't figure out how to fix this. I'm sure it has something to do with "Random Living unit etc..." variable. Here's the code:
Hopefully, I'm not being annoying with all these questions ;o! Thank You!