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

[General] How do i make a trigger to kill or obtain Massive amounts of items or units ?

Status
Not open for further replies.
Level 2
Joined
Jan 29, 2018
Messages
11
I'm in the process of making a campaign, and im working now on a level with a quest that requires to kill like a large amount of units (50+ or more)

My problem is that im having a hard time getting the units killed to sync with the quest objective. ( Killed Bandits 1/50)

Event - A unit dies

Conditions - (If Any or all Conditions are true) Then do these actions (Else do these actions)

Triggering Unit - equal to Bandit (Example)

Actions - Bandit Counter = Bandit Counter + 1

lead.gif
Quest - Display to (All players) the Quest Update message: You have killed a Bandit... 1/50 ... 2/50... 3/50...

So far i understand i need to use Bandit Counter = Bandit Counter + 1 after every time i wish to update the quest objective per bandit kill.

Problem is 50 bandits is a long list, and the trigger is giving me errors...

I tried to divide all the 50 kills to 5x10 triggers, (Bandit kills 1 - 10) Bandit Kills 10 - 20... and that partially worked, but that displays the ( Killed Bandits 1/50) incorrectly,

Sometimes its just skipping kills... killed like 5 bandits and it tells me i killed 3...

I'm trying to use this same concept for items as well... like gather 50x of a specific item...

I'm sure i got something wrong.
 
Level 20
Joined
Feb 23, 2014
Messages
1,264
If I understod what you're trying to do, the trigger should look like this:

  • Events
    • Unit - A unit Dies
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to <Unit-Type>
  • Actions
    • Set BanditCounter = (BanditCounter + 1)
    • Quest - Display to (All players) the Quest Update message: (You have killed a bandit - + ((String(BanditCounter)) + /50))

If you're confused about that last part, this should help clear it up:

w3 trig.jpg


The "Concatenate Strings" function allows you to add strings (text) together. The String(BanditCounter) part is achieved by using a function that converts an integer to a string (it's in the same drop down menu: Conversion - Convert Integer to String). As a result, we're adding 3 strings together:

1. "You have killed a bandit - " (note the empty space left at the end of the string)
2. The value of our BanditCounter integer converted into a string
3. "/50"

Thus we get the message: "You have killed a bandit - x/50" with x being the value of our BanditCounter integer variable. As this value goes up (i.e. each time this trigger passes the condition), the x value in the message is going to automatically change to reflect that. So, if BanditCounter = 1, then the message will be: "You have killed a bandit - 1/50", if BanditCounter = 2, then the message will be: "You have killed a bandit - 2/50". And so on.

I've given it a quick test and it works as intended. If you don't understand how I did something, feel free to ask and if you're curious and want me to diagnose what went wrong in your trigger, please post it in its entirety using this: How To Post Your Trigger
 
Last edited:
Level 2
Joined
Jan 29, 2018
Messages
11
If I understod what you're trying to do, the trigger should look like this:

  • Events
    • Unit - A unit Dies
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to <Unit-Type>
  • Actions
    • Set BanditCounter = (BanditCounter + 1)
    • Quest - Display to (All players) the Quest Update message: (You have killed a bandit - + ((String(BanditCounter)) + /50))

If you're confused about that last part, this should help clear it up:

View attachment 395026

The "Concatenate Strings" function allows you to add strings (text) together. The String(BanditCounter) part is achieved by using a function that converts an integer to a string (it's in the same drop down menu: Conversion - Convert Integer to String). As a result, we're adding 3 strings together:

1. "You have killed a bandit - " (note the empty space left at the end of the string)
2. The value of our BanditCounter integer converted into a string
3. "/50"

Thus we get the message: "You have killed a bandit - x/50" with x being the value of our BanditCounter integer variable. As this value goes up (i.e. each time this trigger passes the condition), the x value in the message is going to automatically change to reflect that. So, if BanditCounter = 1, then the message will be: "You have killed a bandit - 1/50", if BanditCounter = 2, then the message will be: "You have killed a bandit - 2/50". And so on.

I've given it a quick test and it works as intended. If you don't understand how I did something, feel free to ask and if you're curious and want me to diagnose what went wrong in your trigger, please post it in its entirety using this: How To Post Your Trigger
MasterBlaster, I really appreciate your help. Can i ask, how did you add the /50 after the bandit counter ?
  • Quest Test 1
    • Events
      • Unit - A unit owned by Player 2 (Blue) Acquires an item
    • Conditions
      • (Item-type of (Matching item)) Equal to Crystal Shard
    • Actions
      • Set CrystalShardCounter = (CrystalShardCounter + 1)
      • Quest - Display to Player Group - Player 2 (Blue) the Quest Update message: (Crystal Shards Collected 0/100 - + / 50)
This is one of the triggers im working on, its just the same concept of my bandit trigger before just with an item called Crystal Shards.

These shards are gonna be used for in game currency.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,558
Look at the picture MasterBlaster posted showing Concatenate Strings, find that function and use it to combine strings together. You often have to use it multiple times to fit everything you want into one string.

Example:
"Bandits Killed" + String(KillCounter) + "/50"

In the above example there's 2 uses of the Concatenate Strings function and 3 separate Strings.
1st string: "Bandits killed"
2nd string: String(KillCounter)
3rd string: "/50"

MasterBlaster touched on everything you need to know, just mess with it a bit and I'm sure you'll figure it out. I think you're not understanding the idea of using Concatenate Strings more than once.
 
Level 20
Joined
Feb 23, 2014
Messages
1,264
Uncle already covered it, but just to be sure.

When you use a Concatenate Strings function, you're going to get two fields representing the strings you want to "add": "String A" + "String B".

If you want to add more than 2 strings together, you click on either one of these fields and replace it with another Concatenate Strings function, getting something like this: "String A" + ("String B" + "String C"). The "/50" part in the example above is simply the value of "String C".

  • Quest Test 1
    • Events
      • Unit - A unit owned by Player 2 (Blue) Acquires an item
    • Conditions
      • (Item-type of (Matching item)) Equal to Crystal Shard
    • Actions
      • Set CrystalShardCounter = (CrystalShardCounter + 1)
      • Quest - Display to Player Group - Player 2 (Blue) the Quest Update message: (Crystal Shards Collected 0/100 - + / 50)

As for this, I think the message looks weird (see above), but regardless - if you find this not working, the issue is that you've used a wrong condition.

What you need is this:

  • Conditions
    • (Item-type of (Item being manipulated)) Equal to <item type>

The reason is that in your condition there's no item being matched, so you're comparing nothing to some value - that comparison will always fail, so the condition will not be met and the trigger will stop there. Meanwhile, the condition above refers to the item that is being aquired, which is what you want.
 
Last edited:
Level 2
Joined
Jan 29, 2018
Messages
11
  • Quest Test 1
    • Events
      • Unit - A unit owned by Player 2 (Blue) Acquires an item
    • Conditions
      • (Item-type of (Matching item)) Equal to Crystal Shard
    • Actions
      • Set CrystalShardCounter = (CrystalShardCounter + 1)
      • Quest - Display to Player Group - Player 2 (Blue) the Quest Update message: ((Crystal Shards Collected 0/100 - + (String(CrystalShardCounter))) + /50)
Ok, i was able to get it exactly like you described in your first example, problem is this still is not working for me, When my hero picks up the Crystal Shard items the counter still doesn't register them.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,558
  • Quest Test 1
    • Events
      • Unit - A unit owned by Player 2 (Blue) Acquires an item
    • Conditions
      • (Item-type of (Matching item)) Equal to Crystal Shard
    • Actions
      • Set CrystalShardCounter = (CrystalShardCounter + 1)
      • Quest - Display to Player Group - Player 2 (Blue) the Quest Update message: ((Crystal Shards Collected 0/100 - + (String(CrystalShardCounter))) + /50)
Ok, i was able to get it exactly like you described in your first example, problem is this still is not working for me, When my hero picks up the Crystal Shard items the counter still doesn't register them.
There is no (Matching item) in your Trigger. You're using the wrong function in your Conditions.

The Matching function is reserved for enumerating over Units/Items/Players, for example:
  • Set Variable FootmanGroup = Units in (Playable map area) matching Unit-type of (Matching unit) Equal to Footman

You need to use the functions that are associated with whatever it is you're doing. In this case you want (Item being manipulated):
  • (Item-type of (Item being manipulated)) Equal to Crystal Shard

Again, MasterBlaster covered this pretty clearly :p Make sure you read carefully because one little mistake will mess up everything.
 
Last edited:
Level 2
Joined
Jan 29, 2018
Messages
11
  • Quest Test 1
    • Events
      • Unit - A unit owned by Player 2 (Blue) Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Crystal Shard
    • Actions
      • Set CrystalShardCounter = (CrystalShardCounter + 1)
      • Quest - Display to Player Group - Player 2 (Blue) the Quest Update message: ((Crystal Shards Collected + (String(CrystalShardCounter))) + /50)
I Thank you Both for your aid, MasterBlaster-San and Uncle-San, Im still in my learning stage with these triggers 😅... There is some news, I been playing around with some testing and when i removed the condition
(Item-type of (Item being manipulated)) Equal to Crystal Shard ( i actually need it ). The trigger partially works but it doesn't display properly,

It just jumping around in stacks of 10+.

It starts from Crystals Shards Collected 0/10010 to 0/10020... 0/10030, Im really not sure why ?

I need it to be... Crystal Shards Collected 0/100... 1/100... 2/100...3/100 etc...
 
Level 20
Joined
Feb 23, 2014
Messages
1,264
I'm honestly confused by this, because I just tested an exact same trigger using Gold Coins as the item:

  • Test
    • Events
      • Unit - A unit owned by Player 1 (Red) Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Gold Coins
    • Actions
      • Set ItemCounter = (ItemCounter + 1)
      • Quest - Display to Player Group - Player 1 (Red) the Quest Update message: ((Gold Coins collected: + (String(ItemCounter))) + /50)

I've thought that maybe both me and Uncle are missing something silly, but nope - everything works as intended. I have double or even triple checked this trigger with the one you posted and functionally they're identical, so my diagnosis is that the issues you're having have nothing to do with the trigger.

Moreover, the issues you have seem to prove my diagnosis. For starters, there's no way in hell that the trigger you posted would display a message like that. The string just doesn't match - simply using the variable elswhere wouldn't explain the "/50" string being turned to "/100" and the counter string moving from before that string to after it. You must have another trigger that sends this message, while the one you showed us doesn't execute at all.

As for why that might be - perhaps you have some other trigger that turns this one off or you manually turned it off or the hero that picks up the items simply doesn't belong to Player(2). Or something else. Sadly, I can't tell you what it is since I can't see your other triggers, so it's up to you to check them.
 
Level 2
Joined
Jan 29, 2018
Messages
11
I'm honestly confused by this, because I just tested an exact same trigger using Gold Coins as the item:

  • Test
    • Events
      • Unit - A unit owned by Player 1 (Red) Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Gold Coins
    • Actions
      • Set ItemCounter = (ItemCounter + 1)
      • Quest - Display to Player Group - Player 1 (Red) the Quest Update message: ((Gold Coins collected: + (String(ItemCounter))) + /50)

I've thought that maybe both me and Uncle are missing something silly, but nope - everything works as intended. I have double or even triple checked this trigger with the one you posted and functionally they're identical, so my diagnosis is that the issues you're having have nothing to do with the trigger.

Moreover, the issues you have seem to prove my diagnosis. For starters, there's no way in hell that the trigger you posted would display a message like that. The string just doesn't match - simply using the variable elswhere wouldn't explain the "/50" string being turned to "/100" and the counter string moving from before that string to after it. You must have another trigger that sends this message, while the one you showed us doesn't execute at all.

As for why that might be - perhaps you have some other trigger that turns this one off or you manually turned it off or the hero that picks up the items simply doesn't belong to Player(2). Or something else. Sadly, I can't tell you what it is since I can't see your other triggers, so it's up to you to check them.
Both of you are 100% correct, i just tested again those same triggers on a different test map and they indeed work, at least i know they are working...

I guess i messed something up in the map im working on, ill look into it... The undead are always prone to get something wrong 😂

Anyways i really appreciate your help, Thanks A whole lot guys... Ill be happy to credit you both in the campaign im working on.
 
Last edited:
Status
Not open for further replies.
Top