• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Spellcasting AI problem

Status
Not open for further replies.
Level 11
Joined
Sep 14, 2009
Messages
284
Sometimes when computer units are ordered to use spells, they just freeze and do nothing until they are killed. This happens about 1/10 times. How can I prevent this?

Here are the two triggers that the problem most often occurs in:

  • TrollPriestHealUse
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Troll Priest - Heal for (Attacking unit)) Equal to (==) 1
      • (Mana of (Attacking unit)) Greater than or equal to (>=) 20.00
    • Actions
      • Set TempGroupA = (Units in CombatRect matching ((((Matching unit) belongs to an ally of (Owner of (Attacking unit))) Equal to (==) True) and (((Life of (Matching unit)) Less than (<) (Max life of (Matching unit))) and ((Level of Dummy Unit for (Matching unit)) Not equal to (
      • Unit - Order (Attacking unit) to Orc Shadow Hunter - Healing Wave (Random unit from TempGroupA)
      • Custom script: call DestroyGroup(udg_TempGroupA)
  • IceWaveUse
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Frozen Colossus - Ice Wave for (Attacking unit)) Greater than or equal to (>=) 1
      • (Mana of (Attacking unit)) Greater than or equal to (>=) 40.00
    • Actions
      • Set TempPointA = (Position of (Attacking unit))
      • Unit - Order (Attacking unit) to Undead Dreadlord - Carrion Swarm TempPointA
      • Custom script: call RemoveLocation(udg_TempPointA)
"CombatRect" in trigger 1 is a region where all the fighting takes place.
 
Level 25
Joined
May 11, 2007
Messages
4,651
Well it could be that they're attacked, going to cast the spell, then they're attacked and they're going to cast the spell and then they're attacked and then they're going to cast the spell..
Add a trigger - turn off
wait 2 seconds (or the cooldown time)
trigger turn on

Also as your spells are based off warcraft 3 spells, just go to player properties -> custom abilites and hit "allow custom abilites" and your computer players should cast them too.
 
Level 25
Joined
May 11, 2007
Messages
4,651
This option is called "allow custom forces" and does a completely different thing. Abilities based on the usual ones work anyway.
Bitch please.
54394d1242202263-how-change-race-player-image.jpg


Hit the "Abilites tab", reply again.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Messed up with the naming, but your statement is still wrong. The one in the ability menu does not do this. It decides which ones of the original abilities are enabled(like can be done with triggers).
Years of experience tell me that custom abilities based on the normal ones are handled just like the normal ones for the sake of AI.
 
Level 11
Joined
Sep 14, 2009
Messages
284
Well it could be that they're attacked, going to cast the spell, then they're attacked and they're going to cast the spell and then they're attacked and then they're going to cast the spell..
Add a trigger - turn off
wait 2 seconds (or the cooldown time)
trigger turn on

Also as your spells are based off warcraft 3 spells, just go to player properties -> custom abilites and hit "allow custom abilites" and your computer players should cast them too.


You are a little wrong, it's the attacking unit that is the caster, not the attacked. Therefore only when the unit attacks (which occurs less frequently than being attacked) it is ordered to use it's abilities.

However your idea is good and I'm going to try it, hoefully it might fix the problem nonetheless. I'll report back after some testing.

EDIT: LordDz, your method didn't work. Still looking for solutions for the problem.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
You are sending them a null order. If the filter fails to find a unit it still calls the issue order action except targeting null (which is probably bad!). The solution is to determine your order target and only issue the order if it actually has a target (not null).

In GUI "null" for units is "No Unit".

IceWaveUse is casting at the itself. This will cause all kinds of nonsense since there is no distinct facing angle to cast the carrion swarm. Instead you want it to cast at the attacked unit position so that the wave goes in that direction.
 
Level 11
Joined
Sep 14, 2009
Messages
284
You are sending them a null order. If the filter fails to find a unit it still calls the issue order action except targeting null (which is probably bad!). The solution is to determine your order target and only issue the order if it actually has a target (not null).

In GUI "null" for units is "No Unit".

Something like this?

  • TrollPriestHealUse
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Level of Troll Priest - Heal for (Attacking unit)) Equal to (==) 1
      • (Mana of (Attacking unit)) Greater than or equal to (>=) 20.00
    • Actions
      • Set TempGroupA = (Units in CombatRect matching ((((Matching unit) belongs to an ally of (Owner of (Attacking unit))) Equal to (==) True) and (((Life of (Matching unit)) Less than (<) (Max life of (Matching unit))) and ((Level of Dummy Unit for (Matching unit)) Not equal to (
      • Set TempUnitA = (Random unit from TempGroupA)
      • Custom script: call DestroyGroup(udg_TempGroupA)
      • If (TempUnitA Equal to (==) No unit) then do (Do nothing) else do (Unit - Order (Attacking unit) to Orc Shadow Hunter - Healing Wave TempUnitA)
How can I check for null with target point abilities?

EDIT: I believe I found a solution for target point abilities. If I replace them with target unit abilities and pick units within X range of the target unit instead it could work as a way around the problem. However, if there is a way to check for null with target point abilities I'd still like to know.

IceWaveUse is casting at the itself. This will cause all kinds of nonsense since there is no distinct facing angle to cast the carrion swarm. Instead you want it to cast at the attacked unit position so that the wave goes in that direction.

Yes I noticed this as well. Small mistake.
 

sentrywiz

S

sentrywiz

((Level of Dummy Unit for (Matching unit)) Not equal to (

What is this for in the conditions? Is it cut out when you pasted the trigger text or is this how it is in the triggers? If its like this in the triggers, because you put an "and" it might not work because of that.

Alternatively, check the spell targets allowed in the spells you use. Maybe they cannot cast the spells.

Also check the allies tab like suggested above to check if they are considered allies.

Lastly, make one unit for yourself to see if you can cast the spell manually.
 
Status
Not open for further replies.
Top