Periodic spawning problem

Solu9

You can change this now in User CP.
Reaction score
216
This is probably an easy to solve problem. Nevertheless I can't figure out what to do.

Trigger:
  • Spawn trigger
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Item - Pick every item in Spawn <gen> and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Item-type of (Picked item)) Equal to Sword +1
                  • (Item-type of (Picked item)) Equal to Sword +2
                  • (Item-type of (Picked item)) Equal to Sword +3
            • Then - Actions
              • Do nothing
            • Else - Actions
              • Item - Create Random_Sword[(Random integer number between 1 and 3)] at (Random point in Spawn <gen>)


No item is spawning. I figure is has something to do with the "Pick every item" action. If there are no items I guess it can't pick any, thus the trigger fails.

Random_Sword is a Item(array) variable. And works as it should.
 

Solu9

You can change this now in User CP.
Reaction score
216
what exactly do you want for this trigger to do.

There is an item in the "Spawn" zone. If the player pick up that item the game will automatically create a new item. If the player has not picked up the item, the game will do nothing.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
So you want to detect whether there is an item in ther region or not?

In that case do it like this:

Code:
set Temp_Integer = 0
pick every item in REGION{
 set Temp_Integer = Temp_Integer + 1 }
if Temp_Integer > 0{
 Create Item in REGION}
This is of course pseudo-code and i hope you can understand how this is supposed to work. We pick all items and count them with an integer variable, then, we check how many we have got.
 

Inflicted

Currently inactive
Reaction score
63
Just btw, this leaks:
Item - Create Random_Sword[(Random integer number between 1 and 3)] at (Random point in Spawn <gen>)

There is an item in the "Spawn" zone. If the player pick up that item the game will automatically create a new item. If the player has not picked up the item, the game will do nothing.
This confuses me slightly, what you have done is a periodic replacement instead of an individual item acquirement. Why not just have a trigger that checks when a unit picks up an item, if that unit is in the particular region and their are no nearby items of that type. Or simply check if the item is the specific one, or specific player. (I'm assuming you want that it to be dependent on a player or some sort due to you saying: "If the player has not picked up the item...")

My reasoning is that periodic's apparently use more memory or process power (something like that) because the trigger is run every few seconds. This only operates when an Item is Picked Up. Although this might run more often if you have a large amount of these items/spots in your map. So your method should be dependent on your need, in this case.

There is an event for an item being acquired. You can easily check if the unit is within a region as the default GUI editor has a function for that.

Please let us know if there is any step you cannot complete.
 

Solu9

You can change this now in User CP.
Reaction score
216
This is of course pseudo-code and i hope you can understand how this is supposed to work. We pick all items and count them with an integer variable, then, we check how many we have got.

The problem with this, I guess, is if the players leaves an item in the region and leaves. Thereby the trigger counts the item and does not spawn a new of the right type.

Please let us know if there is any step you cannot complete.

I'll let you know. Thanks.
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Of course you can do whatever "If/Then/Else" comparison within the loop you like, that doesnt matter. I just wanted to give you the basic outline of the trigger, you have to add the details yourself.
 

Kayoss666

Member
Reaction score
7
This is probably an easy to solve problem. Nevertheless I can't figure out what to do.

Trigger:
  • Spawn trigger
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Item - Pick every item in Spawn &lt;gen&gt; and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Item-type of (Picked item)) Equal to Sword +1
                  • (Item-type of (Picked item)) Equal to Sword +2
                  • (Item-type of (Picked item)) Equal to Sword +3
            • Then - Actions
              • Do nothing
            • Else - Actions
              • Item - Create Random_Sword[(Random integer number between 1 and 3)] at (Random point in Spawn &lt;gen&gt;)


No item is spawning. I figure is has something to do with the "Pick every item" action. If there are no items I guess it can't pick any, thus the trigger fails.

Random_Sword is a Item(array) variable. And works as it should.

you say the random_sword item(array) works cuz that is the only problem i see besides the event really should be
Trigger:
  • Unit - A unit Acquires an item
and the condition
Trigger:
  • ((Spawn &lt;gen&gt;) contains (Hero manipulating item)) Equal to True
should be added. does your trigger know that Random_Sword[(1)] = sword +1, Random_Sword[(2)] = sword +2, and Random_Sword[(3)] = sword +3?
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
The intent of your trigger still eludes me. Do you want to immediately spawn a new item whenever the old one is picked up? Periodically create new items if there aren't any in the region? Or something else?
 

Solu9

You can change this now in User CP.
Reaction score
216
Does your trigger know that Random_Sword[(1)] = sword +1, Random_Sword[(2)] = sword +2, and Random_Sword[(3)] = sword +3?

Trigger:
  • Set Random Sword
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Random_Sword[1] = Sword +1
      • Set Random_Sword[2] = Sword +2
      • Set Random_Sword[3] = Sword +3


Yeah I believe it does.

The intent of your trigger still eludes me. Do you want to immediately spawn a new item whenever the old one is picked up? Periodically create new items if there aren't any in the region? Or something else?

Periodically spawn. Lets say every 5 minutes. I must admit I don't see why this trigger does not work.
 

Chewbalka

New Member
Reaction score
14
Just add a if/then/else to the beginning.

if
(Random item in Spawn <gen>) Equal to No item
then
Item - Create Random_Sword[(Random integer number between 1 and 3)] at (Random point in Spawn <gen>)
skip remaining actions
else
The rest of the current code


There's no need for a variable or the loop when there is no item in the region. Just re-create the above in GUI at the top of the trigger.

You should also change that "do nothing" to "skip remaining actions"
Because if i place a item that is not a sword, the loop will pick it, find its not a sword and then spawn a item even if there are other swords within the region. (the loop does the actions for each item as a individual.)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top