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

Help, pick every item region < 5 then spawn item.

Status
Not open for further replies.
Level 2
Joined
Dec 4, 2014
Messages
10
Help, pick every item region < 5 then spawn item.(unsolved)

Hello, i would like to;

1. Count every item in a region.
2. If the number of items is less than or equal to 5, spawn an item Region1 random.


My problem is my trigger condition will spawn 5 items, i collect them and it doesn't respawn again when below 5. Not sure if its counting items already picked, for example; like a dead unit that needs subtracted. Im trying to spawn collectible items like rocks,twigs, and berries that respawn when they fall below a certain limit, or reach a certain life over time. Could this system also be done when item picked, wait, create item? Here is what i have so far;

  • itemSpawn
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Item - Pick every item in Region1 <gen> 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 Less than or equal to 5
            • Then - Actions
              • Item - Create Tome of Experience at (Random point in Region1 <gen>)
            • Else - Actions
 
Last edited:
Level 25
Joined
May 11, 2007
Messages
4,651
http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
Read that.

Trigger (without proper trigger tags cuz not at an editor)

  • Events
    • Time - Every 2.00 seconds of game time
  • Conditions
  • Actions
  • set itemCount = 0;
    • Item - Pick every item in Region1 <gen> and do (Actions)
      • Loop - Actions
        • Set itemCount = (itemCount + 1)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • itemCount Less than or equal to 5
    • Then - Actions
      • set tempPoint1 = random point in Region1
        • Item - Create Tome of Experience at tempPoint1
  • Custom script: call RemoveLocation(udg_tempPoint1)
    • Else - Actions

EDIT: Yeah, no proper trigger tags but u can see what I mean.
 
Level 2
Joined
Dec 4, 2014
Messages
10
Hey im still having the same problem, the map starts, respawns 10 items, i collect them, then they never respawn again. No clue what's wrong, i tried setting the integer to 0 after creating item, no luck.

  • itemSpawn
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • Set itemCount = 0
      • Item - Pick every item in Region1 <gen> and do (Actions)
        • Loop - Actions
          • Set itemCount = (itemCount + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • itemCount Less than or equal to 10
        • Then - Actions
          • Set tempPoint1 = (Random point in Region1 <gen>)
          • Item - Create Tome of Experience at tempPoint1
          • Custom script: call RemoveLocation(udg_tempPoint1)
        • Else - Actions
 
Level 2
Joined
Dec 4, 2014
Messages
10
Ive been trying nearly everything i can think of, its almost like the item count is only running once even though its an event every 3 seconds. Any help or alternative methods to achieve this system would be greatly appreciated. I tried randomly reducing the life of a set item in a region, but thats would delete player items :(.
 
Level 2
Joined
Dec 4, 2014
Messages
10
Thank you for the item cleanup suggestions, i switched tomes to shimmering weed/claws and ran item cleanup; still same result no items spawning after i pick them. I even started with a fresh map and shimmer weeds, still i pick the item once and it never respawns again.

my map file is attached if anyone wants to try, and here is another copy of my trigger;
**EDIT; i'm going to replace the random point with a script/point after the basic system works/spawns. Im also wondering if this type of system would be better with desctructibles and revive.

  • spawnr1
    • Events
      • Time - Every 3.00 seconds of game time
    • Conditions
    • Actions
      • Item - Pick every item in Region1 <gen> and do (Actions)
        • Loop - Actions
          • Set IntegerVariable = (IntegerVariable + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IntegerVariable Less than or equal to 8
        • Then - Actions
          • Item - Create Shimmerweed at (Random point in Region1 <gen>)
          • Set IntegerVariable = 0
        • Else - Actions
 

Attachments

  • regionSpawn.w3x
    16.6 KB · Views: 52
Last edited:
Level 25
Joined
May 11, 2007
Messages
4,651
This works.
  • spawnr1
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set IntegerVariable = 0
      • Item - Pick every item in Region1 <gen> and do (Actions)
        • Loop - Actions
          • Set IntegerVariable = (IntegerVariable + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IntegerVariable Less than or equal to 8
        • Then - Actions
          • Item - Create Spiked Collar at (Random point in Region1 <gen>)
        • Else - Actions
Your previous trigger ran like:
First time:

8 items, set it to 0.
Next time, you pick up an item, tempInt is currently at 7, the trigger checks how many items there are: 7, set tempInt + 7, it will never go into the if then else.
Next run, setTempInt + 7, tempInt = 14 and so on :)

Also pretty sure that shimmerweed works like a tome, it being a powerup.
 
Level 2
Joined
Dec 4, 2014
Messages
10
This works.
Your previous trigger ran like:
First time:

8 items, set it to 0.
Next time, you pick up an item, tempInt is currently at 7, the trigger checks how many items there are: 7, set tempInt + 7, it will never go into the if then else.
Next run, setTempInt + 7, tempInt = 14 and so on :)

Also pretty sure that shimmerweed works like a tome, it being a powerup.

Thank you so much LordDz! it works perfectly, note you were absolutely correct about the shimmerweed being considered a powerup. One last question, can i change the time to "every 30 to 60 seconds of game" to give it some randomness? ive believe i did this once but cant find it for the life of me. Thanks again. **with the leak point script
spawnr1
  • Events
    • Time - Every 30.00 seconds of game time
  • Conditions
  • Actions
    • Set IntegerVariable = 0
    • Item - Pick every item in Region1 <gen> and do (Actions)
      • Loop - Actions
        • Set IntegerVariable = (IntegerVariable + 1)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • IntegerVariable Less than or equal to 8
      • Then - Actions
        • Set tempPoint1 = (Random point in Region1 <gen>)
        • Item - Create Claws of Attack +15 at tempPoint1
        • Custom script: call RemoveLocation(udg_tempPoint1)
      • Else - Actions
 
Level 2
Joined
Dec 4, 2014
Messages
10
  • Time - Every 2.00 seconds of game time
I dont see any option in the GUI to set "every 30.00 seconds - 60.00 seconds of game time" is this possible when creating a new time event. Im trying to randomize the time when this trigger is called. Thank you in advance for helping.
 
Level 25
Joined
May 11, 2007
Messages
4,651
Click on the 2.00, click on the arithmetic tag, press M.
  • Awesomesauce
    • Events
      • Time - Every (Random real number between 1.00 and 1337.00) seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Happytiems!
 
Level 2
Joined
Dec 4, 2014
Messages
10
Click on the 2.00, click on the arithmetic tag, press M.
  • Awesomesauce
    • Events
      • Time - Every (Random real number between 1.00 and 1337.00) seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) the text: Happytiems!

wow you are the best!! thanks for helping me out.
 
Level 25
Joined
Sep 26, 2009
Messages
2,378
I'm not sure what you try to achieve, but the trigger posted by LordDz will select one random time only the very first time it runs and then it will use that very time for the remainder of the game.
It works like this:
Trigger Starts for the first time -> Select random time between 1.00 and 1337.00 -> let's say a time 3.50 was chosen -> next time is once again 3.50 -> all subsequent times are 3.50 until the end of the map.

It definitely doesn't do this:
Trigger Starts for the first time -> Select random time (e.g. 2.50) -> Trigger starts again -> Select new random time (e.g. 5.70) -> etc.
That does not happen.

If what you want is just randomly selected time for this trigger at the start of map, then ok.
However if you want random time each time this trigger fires, you will need to use Timers.
 
Level 2
Joined
Dec 4, 2014
Messages
10
I'm not sure what you try to achieve, but the trigger posted by LordDz will select one random time only the very first time it runs and then it will use that very time for the remainder of the game.
It works like this:
Trigger Starts for the first time -> Select random time between 1.00 and 1337.00 -> let's say a time 3.50 was chosen -> next time is once again 3.50 -> all subsequent times are 3.50 until the end of the map.

It definitely doesn't do this:
Trigger Starts for the first time -> Select random time (e.g. 2.50) -> Trigger starts again -> Select new random time (e.g. 5.70) -> etc.
That does not happen.

If what you want is just randomly selected time for this trigger at the start of map, then ok.
However if you want random time each time this trigger fires, you will need to use Timers.

You are correct Nichilus, i'm reading about timers now. I've run into an even larger problem with this system, that if a player drops his inventory items it will count them and not spawn items in the region. not sure how to move forward, i don't want to remove items from the floor during game. I would like to spawn items players can collect. ie beach region; shells, crabs etc.

If i cannot fix being able to drop inventory items, i'm going to read more about destructibles with revive and create trees/ore veins? not sure really, any suggestions welcome. Thank you.
 
Level 2
Joined
Dec 4, 2014
Messages
10
You could use Item - Set Custom Value to 1 of items that are created,
and add if (item custom value != 1) set tempInteger = tempInteger + 1 in your item creation trigger.

Fantastic idea, however if the player decides to drop the custom item with a value of 1, will it not count that item. In return not spawning any more of that similar item. I've noticed counting items in a region has allot of inventory issues with players dropping items. I'm new to the editor :) so finding alternative methods to creating systems is a learning progress. I thank you very much for the help with this trigger.

I have seen a few different maps use similar systems to this, like wilderness survival and jungle trolls, i understand these are most likely made with jass? Monday i am going to try different methods with the GUI to achieve destructible's; respawning ore/tree/fruit systems etc. thank you guys. Have a good weekend.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Wait a sec....
I stopped using every ... seconds of gametime for any amount except 0.03 because there is one thing that I disliked: The actual gametime.
If you make one that calls every 40 seconds and you turn that trigger on or call it after 20 seconds of gametime. It will run 20 seconds after that and then continues with 40 seconds intervals.

But if you randomize that amount. Do you make a real at the initialization of the map that will be used the entire game or does it calls it every possible number between those or does it actually do a random interval each time?

Sorry, I haven't got any avaiable WE atm.
 
Status
Not open for further replies.
Top