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

[Trigger] making units pick up spawned items

Status
Not open for further replies.
Level 10
Joined
Sep 29, 2006
Messages
447
im trying to make a trigger in which if a unit comes within X range of a power up item, it will pick it up. I do not want to do this with a periodic trigger because then it interferes with another trigger that is in place. so far i have come up with this but it doesnt work (and i know why)

  • pick up item
    • Events
    • Conditions
    • Actions
      • Unit - Order (Picked unit) to Right-Click (Picked item)
  • pick up item add event
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set PlayableMapRegionVar = (Playable map area)
      • 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-class of (Picked item)) Equal to Powerup
            • Then - Actions
              • Trigger - Add to pick up item <gen> the event (Unit - A unit comes within 400.00 of (Picked unit))
            • Else - Actions
      • Custom script: call RemoveRect(udg_PlayableMapRegionVar)
now i know that a unit comes within 400 of picked unit will not work. i need to know what to set this to so that it will work. I can't find a Unit comes with X of Item function. If this needs to be done in JASS thats fine, but i would like someone to help me out with that, since im not the most experienced JASSer.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
You can do this:
  • Pick Items
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set Group = (Units in (Playable map area))
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Set Unit = (Picked unit)
          • Set Point = (Position of Unit)
          • Set Rect = (Region centered at Point with size (400.00, 400.00))
          • Item - Pick every item in Rect and do (Actions)
            • Loop - Actions
              • Set Item = (Picked item)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Item-class of Item) Equal to Powerup
                • Then - Actions
                  • Unit - Order Unit to Right-Click Item
                • Else - Actions
              • Custom script: set udg_Item = null
          • Custom script: call RemoveRect(udg_Rect)
          • Custom script: call RemoveLocation(udg_Point)
          • Custom script: set udg_Unit = null
      • Custom script: call DestroyGroup(udg_Group)
And this won't interfere with anything else.
 
Level 10
Joined
Sep 29, 2006
Messages
447
actually that will interfere with this trigger:

  • attack nether ball position
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set TempPoint = (Position of NetherBallCarrier)
      • Unit Group - Pick every unit in AIGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Not equal to NetherBallCarrier
            • Then - Actions
              • Unit - Order (Picked unit) to Attack-Move To TempPoint
            • Else - Actions
      • Custom script: call RemoveLocation(udg_TempPoint)
This is the the most important ai trigger so i need nothing to interfere with this one. i cant have a periodic trigger for this, is there any way to do it without a periodic?



EDIT: actually, after looking at that trigger more carefully it may just work. I'll be trying after class. thank you.


EDIT2: This worked, thanks a lot!
 
Last edited:
Status
Not open for further replies.
Top