AI pick item/tomes when unit killed help

Status
Not open for further replies.
Level 8
Joined
Oct 6, 2022
Messages
185
Hello everyone, i would like to ask for your help if do you know how to make an AI pick a certain tome from the enemy hero they killed? thanks in advance
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
When you create the Tome do a search around it for Computer heroes and order them to Right click the Tome.

Create tome -> Pick every computer hero within 1000 range of last created item -> Order picked unit to Right-Click last created item

Or if the (Killing unit) was the enemy AI hero then forget the search and simply order it directly.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
should i also put "Time - periodic Event" ?
First you should clarify what this means:
how to make an AI pick a certain tome from the enemy hero they killed? thanks in advance
Because even though I gave you an answer, I made a lot of assumptions since you didn't really explain the situation.

It all depends on how your map works. But assuming I understand, you could periodically search around the Items for computer Heroes or vice versa.
 
Level 8
Joined
Oct 6, 2022
Messages
185
Soryy for the late Reply is this how i do it? i've also added some chances to it

  • Hero Killed Tomes bonus
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Killing unit) belongs to an enemy of (Owner of (Dying unit))) Equal to True
    • Actions
      • Set Killing_bonus_chance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Killing unit)) controller) Equal to Computer
          • ((Killing unit) is Stunned) Equal to False
          • Killing_bonus_chance Less than or equal to 75
        • Then - Actions
          • Item - Create Tome of Regeneration at (Position of (Killing unit))
          • Unit Group - Pick every unit in (Units within 400.00 of (Position of (Last created item)) matching ((((Matching unit) is paused) Equal to False) and ((((Matching unit) is Stunned) Equal to False) and ((((Matching unit) is an illusion) Equal to False) and ((((Matching unit) is alive) Equal t and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                • Then - Actions
                  • Wait until ((((Killing unit) is paused) Equal to False) or ((((Killing unit) is invulnerable) Equal to False) or (((Killing unit) is Stunned) Equal to False))), checking every 0.10 seconds
                  • Unit - Order (Picked unit) to Right-Click (Last created item)
                • Else - Actions
              • Unit - Order (Picked unit) to Right-Click (Last created item)
          • Unit - Order (Killing unit) to Right-Click (Last created item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Killing unit)) controller) Equal to User
          • Killing_bonus_chance Less than or equal to 35
        • Then - Actions
          • Item - Create Tome of Regeneration at (Position of (Dying unit))
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
That's the idea but some of your Matching conditions don't seem necessary. You could probably get away with simplifying it to this:
  • Hero Killed Tomes bonus
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • ((Killing unit) belongs to an enemy of (Owner of (Dying unit))) Equal to True
    • Actions
      • Set Killing_bonus_chance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Killing unit)) controller) Equal to Computer
          • Killing_bonus_chance Less than or equal to 75
        • Then - Actions
          • Item - Create Tome of Regeneration at (Position of (Killing unit))
          • Unit Group - Pick every unit in (Units within 400.00 of (Position of (Last created item)) matching ((((Matching unit) is a Hero) Equal to True and ((Owner of (Matching unit)) controller) Equal to Computer and do (Actions)
            • Loop - Actions
              • Unit - Order (Picked unit) to Right-Click (Last created item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Killing unit)) controller) Equal to User
          • Killing_bonus_chance Less than or equal to 35
        • Then - Actions
          • Item - Create Tome of Regeneration at (Position of (Dying unit))
        • Else - Actions
Now any computer Heroes within 400 range of the Tome will try to pick it up.

Note that this trigger has memory leaks, something you may want to look into.
 
Last edited:
Status
Not open for further replies.
Top