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

Create a new item in a region every X second + can't go beyond a certain number.

Status
Not open for further replies.
Think my title says it!

I'm trying to replace the Building=goldmines as the gold income in a survival type of game. What I'm trying to create is = force player to explore the cave in search for rocks which would then give them gold once used. (Variations of the item Gold coins)

So here's the step by step of what I'm trying to accomplish with my poor knowledge of triggers.

Step 1 =
Every 20 seconds, create a (Gold coins) item in a (random spot in region)

Step 2 = (which is what I can't acheive on my own) I don't want the number of that item to go beyond 30. (So basically i want the loop to stop after the number of (Gold coins) reached 30.

Step 3 = if the player picks a few of these (Gold coins), I want the trigger to start producing the item once again..... until it reaches 30 again.)


So basically, the map will always rebalance itself and if you pick too much gold right away, you'll lack the ressources for awhile.
savy? :goblin_good_job:
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
  • Create Item In Rect
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set temp_item_count = 0
      • Item - Pick every item in Item Region <gen> 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)) Equal to Tome of Experience
            • Then - Actions
              • Set temp_item_count = (temp_item_count + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • temp_item_count Less than 20
        • Then - Actions
          • Item - Create Tome of Experience at (Center of Item Region <gen>)
        • Else - Actions
Note there is a location leak. I did not fix because I am lazy.
 
  • Create Item In Rect
    • Events
      • Time - Every 60.00 seconds of game time
    • Conditions
    • Actions
      • Set temp_item_count = 0
      • Item - Pick every item in Item Region <gen> 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)) Equal to Tome of Experience
            • Then - Actions
              • Set temp_item_count = (temp_item_count + 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • temp_item_count Less than 20
        • Then - Actions
          • Item - Create Tome of Experience at (Center of Item Region <gen>)
        • Else - Actions
Note there is a location leak. I did not fix because I am lazy.

Geez thanks! Most of my problem is fixed now! Although, once the items are picked, they don't start respawning.:goblin_cry:
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
Ended up turning into a "request" over chat. Only supports one region + item. Also will only work under the assumption that the item can only disappear when a unit/Hero picks it up (and not killed):

  • GIS Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set GIS_SpawnRegion = Gold Spawn <gen>
      • Set GIS_GoldItem = Gold Coin
      • Set GIS_SpawnTimer = 5.00
      • Set GIS_MaxNumber = 30
      • Set GIS_SpawnSFX = Abilities\Spells\Other\Transmute\GoldBottleMissile.mdl
      • -------- --------
      • Set GIS_PeriodicTimer = 1.00
      • Trigger - Add to GIS Loop <gen> the event (Time - Every GIS_PeriodicTimer seconds of game time)
      • For each (Integer GIS_LoopInt) from 1 to GIS_MaxNumber, do (Actions)
        • Loop - Actions
          • Set GIS_TempLoc = (Random point in GIS_SpawnRegion)
          • Item - Create GIS_GoldItem at GIS_TempLoc
          • Custom script: call RemoveLocation(udg_GIS_TempLoc)

  • GIS Start
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to GIS_GoldItem
    • Actions
      • Set GIS_TempItem = (Item being manipulated)
      • Item - Remove GIS_TempItem
      • -------- --------
      • Set GIS_Count = (GIS_Count + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GIS_Count Equal to 1
        • Then - Actions
          • Trigger - Turn on GIS Loop <gen>
        • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • GIS_RecycledSize Equal to 0
        • Then - Actions
          • Set GIS_MaxIndex = (GIS_MaxIndex + 1)
          • Set GIS_ID = GIS_MaxIndex
        • Else - Actions
          • Set GIS_RecycledSize = (GIS_RecycledSize - 1)
          • Set GIS_ID = GIS_RecycledStack[GIS_RecycledSize]
      • Set GIS_NodeNext[GIS_ID] = 0
      • Set GIS_NodeNext[GIS_NodePrev[0]] = GIS_ID
      • Set GIS_NodePrev[GIS_ID] = GIS_NodePrev[0]
      • Set GIS_NodePrev[0] = GIS_ID
      • -------- --------
      • Set GIS_Counter[GIS_ID] = 0.00

  • GIS Loop
    • Events
    • Conditions
    • Actions
      • Set GIS_ID = 0
      • For each (Integer GIS_LoopInt) from 1 to GIS_Count, do (Actions)
        • Loop - Actions
          • Set GIS_ID = GIS_NodeNext[GIS_ID]
          • Set GIS_Counter[GIS_ID] = (GIS_Counter[GIS_ID] + GIS_PeriodicTimer)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • GIS_Counter[GIS_ID] Greater than or equal to GIS_SpawnTimer
            • Then - Actions
              • Set GIS_TempLoc = (Random point in GIS_SpawnRegion)
              • Item - Create GIS_GoldItem at GIS_TempLoc
              • Special Effect - Create a special effect at GIS_TempLoc using GIS_SpawnSFX
              • Special Effect - Destroy (Last created special effect)
              • Custom script: call RemoveLocation(udg_GIS_TempLoc)
              • -------- --------
              • Set GIS_RecycledStack[GIS_RecycledSize] = GIS_ID
              • Set GIS_RecycledSize = (GIS_RecycledSize + 1)
              • Set GIS_NodeNext[GIS_NodePrev[GIS_ID]] = GIS_NodeNext[GIS_ID]
              • Set GIS_NodePrev[GIS_NodeNext[GIS_ID]] = GIS_NodePrev[GIS_ID]
              • -------- --------
              • Set GIS_Count = (GIS_Count - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • GIS_Count Equal to 0
                • Then - Actions
                  • Trigger - Turn off GIS Loop <gen>
                • Else - Actions
            • Else - Actions
 

Attachments

  • Gold Item System.w3x
    19.8 KB · Views: 24

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
EDIT:

Here a fully functional data fed system which does what you want. The core system is standard JASS but the data setup is done in fully GUI making it very easy to use (no need to touch the JASS). Will be publishing it to spell section tomorrow.
 

Attachments

  • MrGoblin_Trigger_20160418_2.w3x
    18.5 KB · Views: 22
  • Resource Spawn System_MrGoblin_v2.1.w3x
    17.4 KB · Views: 63
Last edited:
Status
Not open for further replies.
Top