• 🏆 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!

Ai Hero Help

Status
Not open for further replies.
Level 1
Joined
Sep 22, 2009
Messages
2
. please, i want to make a map with ai-controlled opponent.. it's concept is like a battle arena.. can you please teach me how to make the ai..
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
sorry hehe im just trying to help ^^ :goblin_good_job:
And that's much appreciated! :D

I'm just trying to say that you could greatly improve that system :)
I'll post a few examples.

When I said "You will also need dozens of triggers for the items alone", I meant you could easily combine them like this:

This sets up the items:


  • Setup Items
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- --------
      • Set AIItemCount = (AIItemCount + 1)
      • Set AIItemPrice[AIItemCount] = 900
      • Set AIItemType[AIItemCount] = Boots of Quel'Thalas +6
      • -------- --------
      • Set AIItemCount = (AIItemCount + 1)
      • Set AIItemPrice[AIItemCount] = 5000
      • Set AIItemType[AIItemCount] = Crown of Kings +5
      • -------- --------
      • Set AIItemCount = (AIItemCount + 1)
      • Set AIItemPrice[AIItemCount] = 2500
      • Set AIItemType[AIItemCount] = Orb of Frost
      • -------- --------
      • Set AIItemCount = (AIItemCount + 1)
      • Set AIItemPrice[AIItemCount] = 150
      • Set AIItemType[AIItemCount] = Gauntlets of Ogre Strength +3

This activates when a computer player enters the base:


  • AI Buy Item
    • Events
      • Unit - A unit enters Human Base <gen>
      • Unit - A unit enters Orc Base <gen>
      • Unit - A unit enters Undead Base <gen>
      • Unit - A unit enters Night Elf Base <gen>
    • Conditions
      • ((Owner of (Triggering unit)) controller) Equal to Computer
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • For each (Integer A) from 1 to AIItemCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Owner of (Triggering unit)) Current gold) Greater than or equal to AIItemPrice[(Integer A)]
            • Then - Actions
              • -------- Computer Player has enough gold --> Buy item --------
              • Hero - Create AIItemType[(Integer A)] and give it to (Triggering unit)
              • Player - Add (-1 x AIItemPrice[(Integer A)]) to (Owner of (Triggering unit)) Current gold
              • -------- Go back to area - removed location leak --------
              • Set loc = (Center of Mid <gen>)
              • Unit - Order (Triggering unit) to Attack-Move To loc
              • Custom script: call RemoveLocation(udg_loc)
            • Else - Actions
Those two triggers are all you need for all items.
You can even improve the AI like this:


  • Setup Items
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- --------
      • Set AIItemCount = (AIItemCount + 1)
      • Set AIItemPrice[AIItemCount] = 900
      • Set AIItemType[AIItemCount] = Boots of Quel'Thalas +6
      • Set AIItemHeroClass[AIItemCount] = agility
      • Set AIItemMinLevel[AIItemCount] = 2
      • -------- --------
      • Set AIItemCount = (AIItemCount + 1)
      • Set AIItemPrice[AIItemCount] = 5000
      • Set AIItemType[AIItemCount] = Crown of Kings +5
      • Set AIItemHeroClass[AIItemCount] = all
      • Set AIItemMinLevel[AIItemCount] = 6
      • -------- --------
      • Set AIItemCount = (AIItemCount + 1)
      • Set AIItemPrice[AIItemCount] = 2500
      • Set AIItemType[AIItemCount] = Orb of Frost
      • Set AIItemHeroClass[AIItemCount] = intel
      • Set AIItemMinLevel[AIItemCount] = 4
      • -------- --------
      • Set AIItemCount = (AIItemCount + 1)
      • Set AIItemPrice[AIItemCount] = 150
      • Set AIItemType[AIItemCount] = Gauntlets of Ogre Strength +3
      • Set AIItemHeroClass[AIItemCount] = strength
      • Set AIItemMinLevel[AIItemCount] = 1
By adding some conditions in the other trigger, the AI now not only buys items, they also buy items for their corresponding class.
That's the first step to a more intelligent AI ^^
You can also make heroes run when below X% HP (and check whether their resurrection is still in cooldown, or if they still have an ankh, or pehaps a heal-spell).
Your spells are completely random right now, which is really a disadvantage.


A more advanced step is aligning the skills the hero chooses with the items it buys - this requires a very flexible system and is a lot harder, but might be worth it.

In either case: if you at least remove the leaks and make a few triggers more efficient as shown above, then the system is acceptable.
But an AI which leaks just isn't good (we don't want AI's to cause lag, do we?)
 
Level 8
Joined
Dec 12, 2010
Messages
280
Here's some triggers you could use that aren't as complicated as Ap0poo's triggers. I think this is what your lookin for not a complex item system.

Here's your AI movement trigger

  • Move Ai
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • Set Random_Loc = (Random point in (Playable map area))
      • Unit Group - Pick every unit in Ai_Units and do (Actions)
        • Loop - Actions
          • Unit - Order (Picked unit) to Attack-Move To Random_Loc
      • Custom script: call RemoveLocation(udg_Random_Loc)

Here's a revive trigger for the AI

  • Revive Ai
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in Ai_Units) Equal to True
      • ((Triggering unit) is Summoned) Equal to False
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of items carried by (Triggering unit)) Greater than 5
        • Then - Actions
          • Hero - Drop (Item carried by (Triggering unit) in slot (Random integer number between 1 and 6)) from (Triggering unit)
        • Else - Actions
      • Wait 20.00 seconds
      • Set AITempLoc = ((Owner of (Triggering unit)) start location)
      • Hero - Instantly revive (Triggering unit) at AITempLoc, Show revival graphics
      • Custom script: call RemoveLocation(udg_AITempLoc)
And here's a simple item trigger for the AI although apO's is much better

  • Give item Ai
    • Events
      • Unit - A unit Finishes reviving
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • ((Triggering unit) is in Ai_Units) Equal to True
          • (Number of items carried by (Triggering unit)) Less than 6
          • (Random integer number between 1 and 2) Equal to 1
    • Actions
      • Hero - Create (Random level (Random integer number between 1 and 7) item-type) and give it to (Triggering unit)

And here's a simple way to make the AI learn spells


  • SkillsArchimond
    • Events
      • Unit - Archimonde 0107 <gen> Gains a level
    • Conditions
    • Actions
      • Hero - Learn skill for (Leveling Hero): Dark Portal (Archimonde)
      • Hero - Learn skill for (Leveling Hero): Finger of Death (Archimonde)
      • Hero - Learn skill for (Leveling Hero): Bash
      • Hero - Learn skill for (Leveling Hero): Rain of Chaos (Archimonde)
Here's a trigger to force the AI to cast certain spells but its not needed.

  • Archimonde
    • Events
      • Unit - Archimonde 0107 <gen> Takes damage
    • Conditions
      • (Damage taken) Greater than or equal to 25.00
      • A1Castspell of (Damage source))
      • Set DS_Unit = (Damage source)
      • If (All Conditions are Equal to True
    • Actions
      • Set A1Castspell = False
      • Set SourceLoc = (Position True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Dark Portal (Archimonde) for Archimonde 0107 <gen>) Greater than or equal to 1
          • (Damage taken) Less than or equal to 75.00
        • Then - Actions
          • Unit - Order Archimonde 0107 <gen> to Special Archimonde - Dark Portal SourceLoc
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Rain of Chaos (Archimonde) for Archimonde 0107 <gen>) Greater than or equal to 1
              • (Damage taken) Greater than 125.00
            • Then - Actions
              • Unit - Order Archimonde 0107 <gen> to Special Archimonde - Rain Of Chaos SourceLoc
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Finger of Death (Archimonde) for Archimonde 0107 <gen>) Greater than or equal to 1
                • Then - Actions
                  • Unit - Order Archimonde 0107 <gen> to Special Archimonde - Finger Of Death DS_Unit
                • Else - Actions
                  • Unit - Order Archimonde 0107 <gen> to Attack DS_Unit
              • Set DS_Unit = No unit
      • Custom script: call RemoveLocation(udg_SourceLoc)
      • Wait 30.00 seconds
      • Set A1Castspell = True
 
Status
Not open for further replies.
Top