• 🏆 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] very basic AI question

Status
Not open for further replies.
Level 4
Joined
Oct 5, 2012
Messages
52
I want to make an AI that attack-moves like all 30 seconds to a point in the map area (let's just say random for this purpose). But the unit he has is undefined (he get's a random hero at start of game time). I want it to buy items, move arround, heal himself usw. I know how to manage this all with triggers, but not how to reference to this random-hero-unit in triggers. Thanks for help :)! (I tested it with "all units owned by player (1)", but game crashed after unit started moving.
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
  • Trigger
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) controller) Equal to Computer
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • Set tempPoint = (Random point in (Playable map area))
              • Unit - Order heroes[(Integer A)] to Attack-Move To tempPoint
              • Custom script: call RemoveLocation(udg_tempPoint)
            • Else - Actions
Every 30 seconds, it checks if each player is a computer and is playing. If the player matches these conditions, it orders their hero to attack-move to a random point on the map.
 
Level 4
Joined
Oct 5, 2012
Messages
52
-

Um I'd like to have it player per player (so the triggers are disconnected) this is because I want some to move every 30, others any 60 seconds.
 
Level 5
Joined
Aug 27, 2010
Messages
79
  • MoveHeroInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set PlayerHash = (Last created hashtable)
      • For each (Integer A) from 0 to 15, do (Actions)
        • Loop - Actions
          • Set PickedPlayer = (Player((Integer A)))
          • Set PickedPlayerNum = (Player number of PickedPlayer)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (PickedPlayer controller) Equal to Computer
              • (PickedPlayer slot status) Equal to Is playing
            • Then - Actions
              • Set CompPlayers[NoOfCompPlayers] = PickedPlayerNum
              • Set NoOfCompPlayers = (NoOfCompPlayers + 1)
              • Hashtable - Save 30.00 as PickedPlayerNum of 0 in PlayerHash
              • Hashtable - Save 30.00 as PickedPlayerNum of 1 in PlayerHash
            • Else - Actions
  • MoveHero
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer MoveHeroIter) from 0 to (NoOfCompPlayers - 1), do (Actions)
        • Loop - Actions
          • Set MoveHeroDur = (Load CompPlayers[MoveHeroIter] of 0 from PlayerHash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • -1.00 Not equal to MoveHeroDur
            • Then - Actions
              • Set MoveHeroDur = (MoveHeroDur - 0.03)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • 0.00 Greater than or equal to MoveHeroDur
                • Then - Actions
                  • Set somePoint = (Random point in (Playable map area))
                  • Unit - Order (Load CompPlayers[MoveHeroIter] of 2 in PlayerHash) to Move To somePoint
                  • Custom script: call RemoveLocation(udg_somePoint)
                  • Hashtable - Save (Load CompPlayers[MoveHeroIter] of 1 from PlayerHash) as CompPlayers[MoveHeroIter] of 0 in PlayerHash
                • Else - Actions
                  • Hashtable - Save MoveHeroDur as CompPlayers[MoveHeroIter] of 0 in PlayerHash
            • Else - Actions
save the hero to PlayerNumber(player) (parent key), 2 (child key) of PlayerHash,

save the variable to child key 1...if you want to disable the moving, save -1 to child key 0...
 
Level 4
Joined
Oct 5, 2012
Messages
52
sry, I think you understood me wrong. This seems way to complicated to me, and not the thing I want. So here is an example:
- Player 2 has 1 hero
- It's a random hero, but the randomization happened at the map initialization (so there is no random choosing needed afterwards, i triggered this allready, that's not the problem)
- The hero from player 2 should move to random area

That's all. Just basics. But it doesn't work with the triggers I tried.
 
Level 5
Joined
Aug 27, 2010
Messages
79
if it only 1 player and you know which one (like player 2) the just use mr_beans's trigger without the loop...

what my trigger does is, it looks for all computer players and moves the hero controlled by them to random locations at every 30 secs (can be changed)

when u select a random hero for them, save it to PlayerNumber(player) (parent key), 2 (child key) of PlayerHash...
 
Status
Not open for further replies.
Top