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

[Trigger] Problem with triggers related to the specific item

Status
Not open for further replies.
Level 6
Joined
Jul 22, 2021
Messages
50
Hello Hiveworkshoppers,

I have two problems with triggers that revolve around (custom) items.
  1. I want to trigger "Quest Discovered" action upon picking a specific item. Been trying to put various conditions etc. but can't quite match it. What I achieved so far, was picking any item that triggers the quest discovery.
  2. Change Quest Description by setting variable, arithmetic integer +1. What happens here is that I should use the specific item on certain units. I can make the item apply a debuff on these units if it would make things easier.
    • But again, I'm not quite sure how to make things work. In this case, I created triggers based on this tutorial - which specifically showcases a quest with killing units. The only difference I want to make is using the item on units instead of killing them.
Thank you greatly for any help!

UPDATE:
Fixed the first problem by using Item-type of (Item being manipulated) Equal to Item X
 
Last edited:
Level 6
Joined
Jul 22, 2021
Messages
50
Please show your code, otherwise it seems you're just asking aomeone to implement a solution for you
You can find the attachment below. Don't know how to transfer this into a more readable format here on the forum.

Screenshot_1.png
 
First off: How To Post Your Trigger
So, you want to update text with the value of the integer?
On the string that is "Pesants Beaten X/5", should use:
Concatinate String(Concatinate String("Pessants Beaten ", integer to string(PessantsBeaten)), "/5").

Did this solve your problem? I'm not sure if I understood correctly
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
So the Event "A unit uses an item" is a little weird, it doesn't really provide you with much control. (Triggering unit) in this case is the unit that used the item which conflicts with your Event.

The Event you're looking for is this:
  • Unit - A unit starts the effect of an ability

Then you can use these Event Responses: Casting unit/Triggering unit (Item user), Target unit of ability being cast (Target of item), Target point of ability being cast (For abilities like Shockwave)

Here's a triggered example:
  • Example 1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to YourItemAbility
      • (Unit-type of (Triggering unit)) Equal to Footman Scout
      • (Unit-type of (Target unit of ability being cast)) Equal to Peasant
    • Actions
      • Set VariableSet PeasantBeaten = (PeasantBeaten + 1)
      • Quest - Change the description of LazyPeasants to (Peasants Beaten: + ((String(PeasantBeaten)) + /5))

This one allows you to do something if the Conditions fail. In this case that'd be if the caster wasn't a Footman Scout and/or the target wasn't a Peasant.
  • Example 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to YourItemAbility
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Footman Scout
          • (Unit-type of (Target unit of ability being cast)) Equal to Peasant
        • Then - Actions
          • Set VariableSet PeasantBeaten = (PeasantBeaten + 1)
          • Quest - Change the description of LazyPeasants to (Peasants Beaten: + ((String(PeasantBeaten)) + /5))
        • Else - Actions
          • -------- Maybe you want something to happen if you targeted the wrong thing? --------


Looking at your original trigger, here's some other things you were doing wrong.
First, you're using the And Condition which is unnecessary. By default ALL Conditions need to be met, so using this is redundant. In other words, this:
  • Conditions
    • And - All (Conditions) are true
      • Conditions
        • (Triggering unit) Equal to Peasant 0036 <gen>
        • (Triggering unit) Equal to Peasant 0037 <gen>
        • (Triggering unit) Equal to Peasant 0038 <gen>
Is exactly the same as this:
  • Conditions
    • (Triggering unit) Equal to Peasant 0036 <gen>
    • (Triggering unit) Equal to Peasant 0037 <gen>
    • (Triggering unit) Equal to Peasant 0038 <gen>

But there's an issue with this logic. How can the (Triggering unit) be equal to multiple different units at a time? It can't of course, these Conditions are impossible to meet and the trigger will never work. Again, by default ALL Conditions NEED to be met.

If you wanted this type of logic to work you would use the OR condition:
  • Conditions
    • Or - Any (Conditions) are true
      • Conditions
        • (Triggering unit) Equal to Peasant 0036 <gen>
        • (Triggering unit) Equal to Peasant 0037 <gen>
        • (Triggering unit) Equal to Peasant 0038 <gen>
This reads that as long as the (Triggering unit) is one of those three units then it will work. With And, it would check if the (Triggering unit) was ALL 3 of them, which is impossible.
 
Last edited:
Level 6
Joined
Jul 22, 2021
Messages
50
Thank you guys so much for your replies.
I'm a bit tired today and gotta go sleep very soon.
Nevertheless, I tried to mess around a bit.
On the string that is "Pesants Beaten X/5", should use:
Concatinate String(Concatinate String("Pessants Beaten ", integer to string(PessantsBeaten)), "/5").
How do I even get there? You meant "contaminate"?
Can't find which stuff exactly should I click to get to that point...

if.gif
(Unit-type of (Target unit of ability being cast)) Equal to Peasant
Same as above, can't quite find the route to create this condition.

Other than that I've encountered a problem with my item. I made an item based on Healing Salve, which should apply specific debuff and even though I changed buffs and item abilities to the desired ones it still triggers default Regeneration buff.
Should I use a different item as a template?
What I basically want to achieve with the item is that upon using it on a unit it should apply the custom debuff. Bonus points if it can be used only on specific units.

Will come back tomorrow with more (good) discoveries I hope!
Good night :)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Usually the first word or two in the Event/Condition/Action will tell you what it's called.
  • (Unit-type of (Target unit of ability being cast)) Equal to Peasant)
^This is a Unit-Type condition.

Remember, you can use Search For Text to find these things if you're having trouble. See the attached picture.

The Healing Salve thing sounds like a bug or you messed something up, I would try using Inner Fire instead.

Also, when it comes to the Targets Allowed field on abilities you're rather limited in what you can do. If you wanted to exclude specific unit-types like Footman for example, you would need to use triggers. What people do here is either catch the Order Event -> A unit is issued an order targeting an object OR catch the pre-cast Event -> A unit Begins casting an ability. Then after checking the unit-type of the targeted unit in the Conditions (or whatever conditions they want) they either allow the ability to continue casting or they interrupt the caster by issuing a "Stop" order. Sometimes you need to use other tricks as well to interrupt the caster, it can be a little finicky.

The problem here is that the ability comes from an item which means that it's going to be cast instantly. This means that the pre-cast Event probably won't do you any good. I'm not 100% sure about interrupting the issued order either, I'd have to test it out. What you could probably do is Remove the Healing Salve/Inner Fire buff from the wrong target immediately after applying it, and maybe reset the ability cooldown so the player isn't punished for targeting the wrong thing.
 

Attachments

  • exa.png
    exa.png
    65.7 KB · Views: 15
Last edited:
Level 6
Joined
Jul 22, 2021
Messages
50
Thank you @Uncle it actually works!
The problem I encountered now is that I can abuse using the item on one peasant and it will count the number up.
Should I simply create a new trigger for each peasant + add Trigger - Turn Off action at the end of each?

Another issue is about the item and it's a whole another topic I guess. I tried to base the ability on Item Silence, Transmute, etc. and every time it doesn't work the way I want it to. It always does the same stuff as the base ability and I don't know how to change that.
Because of that, I ended up using Healing Salve for testing purposes.
Please find in the attachment below the screenshots of one of my few approaches to the matter. It's not the final version by any means, just a mockup.
What I intend to do though, is that I want the item to remove the "Sleep" debuff that I will place on the peasants.

In the spoiler below you can find how my trigger looks like.
  • LazyPeasants
    • Events
      • Unit - Footman Scout 0104 <gen> Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Healing Salve
      • (Unit-type of (Triggering unit)) Equal to Footman Scout
      • (Unit-type of (Target unit of ability being cast)) Equal to Peasant
      • Or - Any (Conditions) are true
        • Conditions
          • (Target unit of ability being cast) Equal to Peasant 0046 <gen>
          • (Target unit of ability being cast) Equal to Peasant 0007 <gen>
          • (Target unit of ability being cast) Equal to Peasant 0040 <gen>
          • (Target unit of ability being cast) Equal to Peasant 0047 <gen>
    • Actions
      • Set VariableSet PeasantBeaten = (PeasantBeaten + 1)
      • Quest - Change the description of LazyPeasants to (Peasants Beaten: + ((String(PeasantBeaten)) + /5))
 

Attachments

  • Screenshot_1.png
    Screenshot_1.png
    36.8 KB · Views: 11
  • Screenshot_2.png
    Screenshot_2.png
    38.9 KB · Views: 12

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
So since your Event is a specific unit event and not a generic one this means that you don't need to check the unit-type of the caster. We already know the casting unit is Footman Scout 0104 based on the Event. Also, since you check if the targets of the ability are one of those 4 Peasants, you don't need to check their Unit-types either. So you can delete these two conditions:
  • (Unit-type of (Triggering unit)) Equal to Footman Scout
  • (Unit-type of (Target unit of ability being cast)) Equal to Peasant
The Unit-type conditions are more useful in generic situations where you don't need specific units but rather types of units.


But now that I realize how you want everything to work this changes the trigger even more. Since you want these units to only be targetable once then you should contain them inside of a Unit Group and remove them from it once targeted:
  • Example
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to YourItemAbility
      • ((Target unit of ability being cast) is in LazyPeasantsGroup.) Equal to True
    • Actions
      • Unit Group - Remove (Target unit of ability being cast) from LazyPeasantsGroup.
      • Set VariableSet PeasantBeaten = (PeasantBeaten + 1)
      • Quest - Change the description of LazyPeasants to (Peasants Beaten: + ((String(PeasantBeaten)) + /5))
The Condition used here is a Boolean Comparison.

But first, we need to add these units to the Unit Group before the game starts:
  • Add Peasants To Group
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit Group - Add Peasant 0046 <gen> to LazyPeasantsGroup
      • Unit Group - Add Peasant 0007 <gen> to LazyPeasantsGroup
      • Unit Group - Add Peasant 0040 <gen> to LazyPeasantsGroup
      • Unit Group - Add Peasant 0047 <gen> to LazyPeasantsGroup


Regarding your items and buffs, here's two things that are important to understand:
1) Buffs generally need to be equal to the original buff that the ability used or a COPY of it. Leaving a buff field empty can have weird results as well.
2) You probably need to give your item a Cooldown Group instead of Unknown.
 
Last edited:
Level 6
Joined
Jul 22, 2021
Messages
50
Okay, it makes all perfect sense now to me and it does work!
Thank you again @Uncle :)

Actually, I did something similar with groups already on the map I'm working on. Too bad I forgot about it :D

I took care of the rest and made the whole quest work as intended! Except for the item part, for now. Will try to figure it out.

Beginning to understand the logic of all these triggers a bit better thanks to you guys.
 
Status
Not open for further replies.
Top