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

[Trigger] *HELP* Need help creating items in a region when less than "X" exist in that region

Status
Not open for further replies.
Here is exactly what I want to do

Event - Every 30 seconds
Action(s)

If [number of items in region > 4]
Then [Create an item]
Else [do nothing]

I didnt wrap this in trigger code because there aren't exact triggers that deal with items in regions.
Any suggestions?
I have to do this with 67 regions so try and make it short please.
THANKS IN ADVANCE FOR THE HELP!
 
Level 22
Joined
Feb 26, 2008
Messages
891
Create an integer variable.

Then:

  • Items
    • Events
    • Conditions
    • Actions
      • Set SomeInt = 0
      • Item - Pick every item in (Playable map area) and do (Actions)
        • Loop - Actions
          • Set SomeInt = (SomeInt + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SomeInt Greater than or equal to 4
        • Then - Actions
        • Else - Actions
Does that help?
 
Create an integer variable.

Then:

  • Items
    • Events
    • Conditions
    • Actions
      • Set SomeInt = 0
      • Item - Pick every item in (Playable map area) and do (Actions)
        • Loop - Actions
          • Set SomeInt = (SomeInt + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SomeInt Greater than or equal to 4
        • Then - Actions
        • Else - Actions
Does that help?

Lol thanks, i cant believe i didnt think of that. Oooh well guess i better get started. THanks
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
No need to spam actions, use a loop like this.

Variables used:

Item_Regions - Region variable, arrayed.
Integer - Integer variable, not arrayed, initial value 0.
Point - Point variable, not arrayed.

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Item_Regions[1] = Region1
      • Set Item_Regions[2] = Regiog2
      • Set Item_Regions[3] = Region3
      • Set Item_Regions[4] = Region4
      • Set Item_Regions[5] = Region5
      • Set Item_Regions[6] = Region6
      • continue this with all your item regions
  • Looping
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Item - Pick every item in Item_Regions[(Integer A)] and do (Actions)
            • Loop - Actions
              • Set Integer = (Integer + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Integer Greater than or equal to 4
            • Then - Actions
              • Set Point = (Random point in Item_Regions[(Integer A)])
              • Item - Create Tome of Experience at Point
              • Custom script: call RemoveLocation( udg_Point )
            • Else - Actions
 
No need to spam actions, use a loop like this.

Variables used:

Item_Regions - Region variable, arrayed.
Integer - Integer variable, not arrayed, initial value 0.
Point - Point variable, not arrayed.

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Item_Regions[1] = Region1
      • Set Item_Regions[2] = Regiog2
      • Set Item_Regions[3] = Region3
      • Set Item_Regions[4] = Region4
      • Set Item_Regions[5] = Region5
      • Set Item_Regions[6] = Region6
      • continue this with all your item regions
  • Looping
    • Events
      • Time - Every 30.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Item - Pick every item in Item_Regions[(Integer A)] and do (Actions)
            • Loop - Actions
              • Set Integer = (Integer + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Integer Greater than or equal to 4
            • Then - Actions
              • Set Point = (Random point in Item_Regions[(Integer A)])
              • Item - Create Tome of Experience at Point
              • Custom script: call RemoveLocation( udg_Point )
            • Else - Actions
Oh and is it really necessary to have the "Point"?
If not I won't have to even use the call function.

It could just be a random point in the region without the required amount of items. But if I did need it, wouldnt it have to be arrayed? Because if it wasn't, wouldnt it be like setting a single variable (Point) to 67 different regions?
 
Level 3
Joined
Dec 22, 2007
Messages
35
Oh and is it really necessary to have the "Point"?
If not I won't have to even use the call function.

It could just be a random point in the region without the required amount of items. But if I did need it, wouldnt it have to be arrayed? Because if it wasn't, wouldnt it be like setting a single variable (Point) to 67 different regions?

I dont understand your question, can you rephrase that?
 
Level 22
Joined
Feb 26, 2008
Messages
891
> Oh and is it really necessary to have the "Point"?

> wouldnt it have to be arrayed?

Yes, and no.

You need it to eliminate the memory leak that is there. It works non-arrayed because it is overwritten each time you use it after you take care of one region and used for the next one. There should be no confusion.
 
Status
Not open for further replies.
Top