• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[AI] making computer pick up items

Status
Not open for further replies.
Level 3
Joined
Feb 13, 2008
Messages
65
This should work:

  • Events -
    • Time - Every 5.00 seconds of game time
  • Conditions
  • Actions -
    • Unit Group - Pick every unit in (Units within 400.00 of (Position of Itemyouwant) matching ((( Owner of (Matching unit) controller) Equal to Computer)) and do (Actions)
      • Loop - Actions
        • Unit - Order (Picked Unit) to Move To ItemYouWant
        • Unit - Order (Picked Unit) to Right-Click ItemYouWant
and here is a test map I made that demonstrates this trigger:
 

Attachments

  • TestingComputerItems.w3x
    16.8 KB · Views: 72
Level 6
Joined
Sep 13, 2008
Messages
261
This trigger will work and is already configured just replace the first condition in the loop with condition defining your item.

  • pickup
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Item - Pick every item in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Item-type of (Picked item)) is A powerup) Equal to True
            • Then - Actions
              • Set TempPoint[1] = (Position of (Picked item))
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 512.00 of TempPoint[1]) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Owner of (Picked unit)) controller) Equal to Computer
                    • Then - Actions
                      • Unit - Order (Picked unit) to Right-Click (Picked item)
                    • Else - Actions
            • Else - Actions
      • Custom script: call RemoveLocation(udg_TempPoint[1])
Playable map area may leak I don't know I've never used it.
 
Last edited:
Level 6
Joined
Sep 5, 2007
Messages
264
Just an idea here:

For speed reasons, I think that it'd be best just to add created/dropped items into a group (when one is picked up, remove it from group) and scan through THAT group instead of "pick all items in area/range".

I personally avoid "pick all items/units/etc." because they tend to leak, also using JASS instead of GUI is much more efficient if you're unit/item picking.
 
Level 6
Joined
Sep 13, 2008
Messages
261
Just an idea here:

For speed reasons, I think that it'd be best just to add created/dropped items into a group (when one is picked up, remove it from group) and scan through THAT group instead of "pick all items in area/range".

I personally avoid "pick all items/units/etc." because they tend to leak, also using JASS instead of GUI is much more efficient if you're unit/item picking.

That is a good idea he should add them to group, but without the spawn item trigger I couldn't write a pick item trigger. So PrisonLove my code will work, but it you do what he said your map will run better.
 
This trigger will work and is already configured just replace the first condition in the loop with condition defining your item.

  • pickup
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Item - Pick every item in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Item-type of (Picked item)) is A powerup) Equal to True
            • Then - Actions
              • Set TempPoint[1] = (Position of (Picked item))
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 512.00 of TempPoint[1]) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Owner of (Picked unit)) controller) Equal to Computer
                    • Then - Actions
                      • Unit - Order (Picked unit) to Right-Click (Picked item)
                    • Else - Actions
            • Else - Actions
      • Custom script: call RemoveLocation(udg_TempPoint[1])
Playable map area may leak I don't know I've never used it.

I believe (Playable map area) does leak. :p
.
Better safe than sorry, put it into a variable and remove it via JASS
 
Status
Not open for further replies.
Top