• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Help needed for one trigger

Status
Not open for further replies.
Level 3
Joined
Jul 12, 2013
Messages
12
Dear All,

I was planning to use Lumber as Ammo for a TD map. For this I used the following triggers to pause and unpause the towers/units. Unfortunately the Unpause effect does not seem to be working. Please guide me in debugging the same.

  • Unit Array P1
  • Events
  • Unit - A unit enters (Entire map)
  • Conditions
  • (Owner of (Triggering unit)) Equal to Player 1 (Red)
  • Actions
  • Set P1 = (P1 + 1)
  • Set P1U[P1] = (Triggering unit)
  • Pause P1
  • Events
  • Player - Player 1 (Red)'s Current lumber becomes Less than or equal to 0.00
  • Conditions
  • Actions
  • For each (Integer Z) from 1 to 9999, do (Actions)
  • Loop - Actions
  • Set pp1 = (pp1 + 1)
  • Unit - Pause P1U[pp1]
  • Set pp1 = 0
  • Unpause P1
  • Events
  • Time - Every 0.50 seconds of game time
  • Conditions
  • And - All (Conditions) are true
  • Conditions
  • pp1 Equal to 0
  • (Player 1 (Red) Current lumber) Greater than or equal to 10
  • Actions
  • For each (Integer X) from 1 to 9999, do (Actions)
  • Loop - Actions
  • Set up1 = (up1 + 1)
  • Unit - Unpause P1U[up1]
  • Set pp1 = 1
  • Set up1 = 1
The initial (default) values of P1, pp1 and up1 are 1.

Thanks in advance.

Dread.

Ok i am not sure why it is looking like that in the trigger window but

Set pp1 = 0

and

Set pp1 = 1
Set up1 = 1

in the last 2 triggers respectively are not in the loop but out of the loop ie actions are after the loop is completed.

Dread.
 
Last edited by a moderator:
Level 25
Joined
Sep 26, 2009
Messages
2,387
It's quite hard to make sense of your triggers when you use code names for your variables without even explaining what each variable should represent.

This is my guess:
P1 - player1 index
P1U - player 1 unit
PP1 - Pause player1 index
UP1 - Unpause player 1 index

The question is - why do you need to index 1 unit 3 times?
In indexing, your start values should never be 1, because then you start from 2
Look at your first trigger:
it's P1 = P1 + 1; set P1U[P1] = unit.
So in number you have P1 = 1
Then when trigger fires, you set P1 = P1 + 1 => P1 = 1 + 1 => P1 = 2
Set P1U[2] = unit. Why start from number 2?

You incorrectly use integer loops. First, let me ask - why do you even have the loop run 9999 times? If you have 6 players who have no wood, then your upause loop will run a total of 59,994 times! (assuming you have same triggers for each player) every 0,5 second.
The logical thing should be: Can 1 player even have 9999 units?

The last thing - you don't even need to use integer loop, because you don't loop specific units, as I understand it, you either pause all player's towers, or unpause them, depending if player has no wood or has enough of it.

For that, you don't even need indexing in the first place - you can just use event "Player - Player 1 (Red)'s Current lumber becomes Less than or equal to 0.00" and pick all his units which equal to one of your many tower-types (or do not equal to specific unit type - like a unit which builds those towers, if there is any), and pause them.
When his wood is greater than 10, unpause them using the same method as when pausing.
 
Level 3
Joined
Jul 12, 2013
Messages
12
Point 1
This is my guess:
P1 - player1 index
P1U - player 1 unit
PP1 - Pause player1 index
UP1 - Unpause player 1 index

Point 2
The question is - why do you need to index 1 unit 3 times?

Point 3
In indexing, your start values should never be 1, because then you start from 2
Look at your first trigger:
it's P1 = P1 + 1; set P1U[P1] = unit.
So in number you have P1 = 1
Then when trigger fires, you set P1 = P1 + 1 => P1 = 1 + 1 => P1 = 2
Set P1U[2] = unit. Why start from number 2?

Point 4
The logical thing should be: Can 1 player even have 9999 units?


Point 5
The last thing - you don't even need to use integer loop, because you don't loop specific units, as I understand it, you either pause all player's towers, or unpause them, depending if player has no wood or has enough of it.

For that, you don't even need indexing in the first place - you can just use event "Player - Player 1 (Red)'s Current lumber becomes Less than or equal to 0.00" and pick all his units which equal to one of your many tower-types (or do not equal to specific unit type - like a unit which builds those towers, if there is any), and pause them.
When his wood is greater than 10, unpause them using the same method as when pausing.

Thanks Nichilus for your reply.

Let me reply point wise on why I did these triggers.

Point 1
All your assumptions on the abbreviations are true. :thumbs_up:

Point 2
I could have done with 2 indexes but chose 3 just to be sure. The Index P1 is an ongoing index which ensures all the units created / built / summoned are sitting in the Unit Array P1U. Hence that index is mandatory in my view. The pp1 and up1 can be clubbed for pausing / unpausing triggers.

Point 3
The reason I started with 1 was I wanted the Unpause loop to only trigger only if the Player has units that are paused. Hence at the end of the Pause loop I made pp1 = 0; which is one of the conditions for the unpause loop to trigger. While this will cause P1U array to start from 2 instead of 1 I believe that is a good trade off against triggering the Unpause loop every 0.5 secs. There could be more refined ways to handle this, but the above method has no major flaws in my opinion.

Point 4
TBH I am not sure how many towers are normally built. I can certainly reduce the number but do not know what should that be kept :wconfused:

Point 5
I searched the entire Action Commands available; there was no command to pause a specific Players units. The only 2 options I could see for Pause was Pause All units (which pauses units for all players) and Pause 1 unit (which is why I had to create the array). This was the whole purpose of creating the above triggers.

Anyways could you identify why the Unpause trigger does not work?

Thanks in advance.

Dread.
 
Level 25
Joined
Sep 26, 2009
Messages
2,387
I don't know why it doesn't work really. In your unpause trigger, are the last 2 actions ("Set pp1 = 1" and "Set up1 = 1") inside the integer loop or outside it?
--------

Point 5
I will start from this point, because I think this point is mandatory to the whole thing. What do you want to do when player 1 gets 0 lumber? Do you pause only some towers or do you pause all his towers? (Note, I am talking about towers or units which require the ammo!).

Point 2
You actually need only 1 index - and that is P1

Point 3
If I did it, I would instead set pp1 to -1 when I want to run unpause trigger (and unpause condition would also be to check if pp1 is -1, instead of 0). It should not be the problem, but it just makes sense when you get back to it later.

Point 4
This can be mathematically counted - but let me just say this: Each player would have like a max of 100-200 towers, he can't get more. More towers make no sense. However you don't really need an integer loop to be set to specific value. You can set the integer loop to run from 1 to P1. Because P1 keeps count of all your towers, then if you have 1 tower, loop will run from 1 to P1 (which is 1). If you have 50 towers, loop will run from 1 to 50 (= P1). This way the loop will not run more than necessary.
 
Level 3
Joined
Jul 12, 2013
Messages
12
I don't know why it doesn't work really. In your unpause trigger, are the last 2 actions ("Set pp1 = 1" and "Set up1 = 1") inside the integer loop or outside it?
--------

Point 5
I will start from this point, because I think this point is mandatory to the whole thing. What do you want to do when player 1 gets 0 lumber? Do you pause only some towers or do you pause all his towers? (Note, I am talking about towers or units which require the ammo!).

Point 2
You actually need only 1 index - and that is P1

Point 3
If I did it, I would instead set pp1 to -1 when I want to run unpause trigger (and unpause condition would also be to check if pp1 is -1, instead of 0). It should not be the problem, but it just makes sense when you get back to it later.

Point 4
This can be mathematically counted - but let me just say this: Each player would have like a max of 100-200 towers, he can't get more. More towers make no sense. However you don't really need an integer loop to be set to specific value. You can set the integer loop to run from 1 to P1. Because P1 keeps count of all your towers, then if you have 1 tower, loop will run from 1 to P1 (which is 1). If you have 50 towers, loop will run from 1 to 50 (= P1). This way the loop will not run more than necessary.


The ("Set pp1 = 1" and "Set up1 = 1") are outside the loop.

On point 5, I want all his towers/units to pause. But the units of other players must not pause.

On point 4; that is a superb solution!:thumbs_up: I will implement it right away. However this also means you will need atleast 2 indexes.

However the reason why Unpause does not work is still not clear. Is there anyway I can mail you the map so that you can perhaps find out the root cause?

Dread.
 
Level 25
Joined
Sep 26, 2009
Messages
2,387
You can attach the map into this thread through attachments. But I have better solution for pausing units than (de)indexing those towers.

  • Pause
    • Events
      • Player - Player 1 (Red)'s Current lumber becomes Less than or equal to 0.00
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by Player 1 (Red) matching ((Unit-type of (Matching unit)) Not Equal to Your_Worker_Unit)) and do (Actions)
        • Loop - Actions
          • Unit - Pause (Picked unit)
"Your_Worker_Unit" is a unit which builds your structures. You can set more units which should not be picked into this group.
The custom script is something you need to just copy and paste (it prevent memory leaks).

What the above trigger does is it picks all player 1 units which are not "Your_worker_unit" and pause them.
 
Have you tried adjusting the trigger events? For example you use a periodic event for one and a player/resource event for the other. Why not use the same type of event? I know they should both be working but sometimes you can fix things by attempting variations. Also, I don't know what all of your variables do, but you could try it without them and see if that works. Just use the condition player's lumber = 0 then pause and then player's lumber = greater than 0 unpause. If that works then your half way there. You can then either create new triggers for you variables or add them to the simple trigger I suggested. See if that doesn't help you find where the hang up is.
 
Status
Not open for further replies.
Top