• 🏆 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] What's worng with my AI triggers? +Rep

Status
Not open for further replies.
Level 14
Joined
Jul 25, 2011
Messages
1,065
I'm making an AI for my map. They move fine but they don't shoot. I made them press hot keys to shoot but they don't shoot please help me.
  • AI target move
    • Events
      • Time - Every 5.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
              • And - All (Conditions) are true
                • Conditions
                  • AITarget[(Integer A)] Equal to No unit
                  • ((Owner of Player[(Integer A)]) slot status) Equal to Is unused
            • Then - Actions
              • Set AITarget[(Integer A)] = Player[(Random integer number between 1 and 12)]
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Owner of Player[(Integer A)]) slot status) Equal to Is unused
            • Then - Actions
              • Set TP[16] = (Position of AITarget[(Integer A)])
              • Unit - Order Player[(Integer A)] to Move To TP[16]
              • Custom script: call RemoveLocation(udg_TP[16])
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Owner of Player[(Integer A)]) slot status) Equal to Is unused
            • Then - Actions
              • Set TP[18] = (Position of Player[(Integer A)])
              • Set TG4 = (Units within 1100.00 of TP[18])
              • Custom script: call RemoveLocation(udg_TP[18])
              • Unit Group - Pick every unit in TG4 and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • And - All (Conditions) are true
                        • Conditions
                          • ((Owner of (Picked unit)) is an enemy of (Owner of Player[(Integer A)])) Equal to True
                          • Or - Any (Conditions) are true
                            • Conditions
                              • (Unit-type of (Picked unit)) Not equal to Bullet
                              • (Unit-type of (Picked unit)) Not equal to Rocket
                    • Then - Actions
                      • Unit - Order Player[(Integer A)] to Stop
                      • Set AITarget[(Player number of (Owner of Player[(Integer A)]))] = Player[(Player number of (Owner of (Picked unit)))]
                      • Set TP[18] = (Position of Player[(Player number of (Owner of (Picked unit)))])
                      • Unit - Make Player[(Integer A)] face TP[18] over 0.00 seconds
                      • Custom script: call RemoveLocation(udg_TP[18])
                      • Wait 1.00 seconds
                      • Game - Force (Owner of Player[(Integer A)]) to press the key Z
                      • Wait 1.00 seconds
                      • Game - Force (Owner of Player[(Integer A)]) to press the key X
                      • Wait 1.00 seconds
                      • Game - Force (Owner of Player[(Integer A)]) to press the key C
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_TG4)
            • Else - Actions
  • AI Shoot
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Owner of (Triggering unit)) slot status) Equal to Is unused
    • Actions
      • Unit - Order Player[(Player number of (Owner of (Triggering unit)))] to Stop
      • Set AITarget[(Player number of (Owner of (Triggering unit)))] = Player[(Player number of (Owner of (Attacking unit)))]
      • Set TP[17] = (Position of Player[(Player number of (Owner of (Attacking unit)))])
      • Unit - Make (Triggering unit) face TP[17] over 0.00 seconds
      • Custom script: call RemoveLocation(udg_TP[17])
      • Wait 1.00 seconds
      • Game - Force (Owner of (Triggering unit)) to press the key Z
      • Wait 1.00 seconds
      • Game - Force (Owner of (Triggering unit)) to press the key X
      • Wait 1.00 seconds
      • Game - Force (Owner of (Triggering unit)) to press the key C
 
Level 14
Joined
Jul 25, 2011
Messages
1,065
It's not working because the AI isn't going to be selecting the unit ;)
Pressing the Hotkey isn't going to work, so you're going to have to order the unit to cast the spells.
OR, just clear the selection of the AI player, then make him select the hero so you can use the Hotkey method.

OK. I'll try that.

EDIT : Still doesn't work. Any ideas?
 

Cokemonkey11

Code Reviewer
Level 29
Joined
May 9, 2006
Messages
3,522
((Owner of Player[(Integer A)]) slot status) Equal to Is unused

This not what you want. You want to check that the player controller is a computer.

Slot status is unused means that the player slot (like Player(2)) does not have any other state (like SLOT_STATE_PLAYING)

This is a bit advanced because I didn't learn how to do this until I learned jass, so if someone could tell you the GUI equivalent that would be helpful.
 
Level 14
Joined
Jul 25, 2011
Messages
1,065
((Owner of Player[(Integer A)]) slot status) Equal to Is unused

This not what you want. You want to check that the player controller is a computer.

Slot status is unused means that the player slot (like Player(2)) does not have any other state (like SLOT_STATE_PLAYING)

This is a bit advanced because I didn't learn how to do this until I learned jass, so if someone could tell you the GUI equivalent that would be helpful.

I wanted it to be unused. Did you know that if you set it to computer, it will automatically use items and go back to base? I didn't want that so I'll leave a player slot open to make this work...
 
Status
Not open for further replies.
Top