Connection ErrorBad RequestThis page went staleSession ExpiredSign in requiredForbiddenNot FoundToo Many RequestsServer ErrorBad GatewayService UnavailableGateway TimeoutHTTP Version Not Supported
Session Expired
Your session has expired. Please log in to continue.
Sign in required
You need an account to do that. Sign in or create one — it only takes a minute.
This page went stale
Your security token was rejected, usually because the page sat open too long or you signed in elsewhere. Nothing was saved. Reload the page and try again.
Request Failed
We encountered an issue while processing your request.
Please check your internet connection and try again.
Hello,
I have a couple of questions about your script: there cannot be a creature named "Priest" on the battlefield, just like there cannot be "Osillian" (if this is a variable that stores the correct name, then it's fine, but if you forgot the quotes, read on).
All creatures have a composite script name in the form "coordinates+ID+number," and this name is stored in the first argument of the hook. In your case, this is the "unit" variable. But "Priest" and "Osillian" are not on the battlefield.
Write a hook for the turn of the defending hero, and inside it, add a check:
```lua
for n, creature in GetDefenderCreatures() do
local id = GetCreatureType(creature)
if id == CREATURE_ARCHER then
local targets = GetAttackerCreatures()
chosen_target = targets[random(length(targets)+1]
-- actions with the archer creature and the chosen_target
end
end
```
You need to rewrite the "random" function because the standard one doesn't work. You can take the randomizer from Echoes of the Void by RedHeavenHero, if he doesn't mind, or write it yourself.