• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

trigger condition prblem

Status
Not open for further replies.
Level 4
Joined
Apr 23, 2011
Messages
42
hi guys

when i add this condition.. my trigger don't work..why?

p7c8_1.jpg


help me please..i waiting
 
Level 5
Joined
Aug 8, 2019
Messages
113
I think it would work if you would relocate this third condition right next to the first two, it might be a time lag thing that prevents it from working. Another solution would be to set variable X as being the sold unit at the start of the trigger and then to check the unit type of variable X, then you dont have to worry about any time lag.
 
Try this
• Right Click Condition, and find And - Multiple Conditions
• Put all the conditions inside the And - Multiple Conditions like this

  • Untitled Trigger 001
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Owner of (Sold unit)) Equal to Player 1 (Red)
          • ((Sold unit) is A Hero) Equal to True
          • (Unit-type of (Sold unit)) Equal to Footman
    • Actions
      • -------- Your actions here --------
 
Level 13
Joined
May 10, 2009
Messages
868
Based on the information given, we can't really help you out. The trigger itself should work as long as your conditions do meet. Check if the sold unit is really a hero in object editor, or if the buyer is player 1 red; I tried to reproduce that bug, but it works fine for me. Another thing, as mentioned above, you don't need that extra if statement at all, unless you want to use the "else" block for some other unit type. Also, the block "and - all conditions are true" is useless for this case.
 
Level 4
Joined
Apr 23, 2011
Messages
42
hi guys.. thanks for answers

I understood

when i sold hero.. hero removed and other hero replaced it

That's why condition don't work ..But works on the removed hero

srry for my bad english .. you can see on my file . i upload this map here

i just want use custom spell for selected heroes..Is there a better way?
 

Attachments

  • 111111.w3x
    19.3 KB · Views: 15
Level 1
Joined
Aug 13, 2019
Messages
3
If a unit gets removed and replaced, then I would suggest to use a unit variable. But to be honest, I don't really get to see, what you're trying to do in the end.
 
Level 13
Joined
May 10, 2009
Messages
868
Well, if I'm not mistaken, you want to sell abilities. In that case, you could simply sell items instead of units/heroes. For example, create a new item in object editor based on a tome of agility, which means the item can be bought while the inventory is full. Now, add it to a shop. In the trigger editor, add an event which detects when an item is sold, then remove the sold item - because they are useless by now - and add the corresponding ability to the buying unit. Of course, you'll have to distinguish your custom item from any other item, because the event will fire once ANY item is sold by a shop.

If that's not what you want. Please, explain to us thoroughly what you're trying to accomplish.
 
Level 4
Joined
Apr 23, 2011
Messages
42
hi again...thanks for your helps

i want add "next page" for my select hero ability

when i remove condition.. when i chose it ability .. The ability is added to the new hero

but when i use this condition ..The ability is added to the removed hero

how can i fix this?

i want The ability is added to the new hero with condition (condition image in first post or in my uploaded file)


Simply put:::

when i chose paladin and then avatar ability.. Added the ability of the avatar to my hero

can u fix in my uploaded file?
 
Level 20
Joined
Feb 23, 2014
Messages
1,265
The language barrier is a bit of an issue here, but the way I understand your problem is that you want to:

1. Buy a hero from the first Arcane Vault.
2. Have the ability you selected from the second Arcane Vault be added to the hero you bought in step 1.

If so:

1. Bind the hero you bought in step 1 to a unit variable in the first trigger like this:
  • Set <YourUnitVariable> = (Sold unit)
2. In the second trigger, use if/then/else to check which ability was bought and then add the ability to the unit bound to your previously set unit variable by using the action "Unit - Add Ability". Something like this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Unit-type of (Sold unit)) Equal to Avatar
    • Then - Actions
      • Unit - Add Avatar to <YourUnitVariable>
    • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Unit-type of (Sold unit)) Equal to Banish
    • Then - Actions
      • Unit - Add Banish to <YourUnitVariable>
    • Else - Actions
---

P.S. I've taken a quick look at your triggers and... they're a bit of a mess.

1. If you're going to post a map for people to take a look at, make sure that triggers have proper titles and trigger comments where needed instead of something like this <TriggerName> and <TriggerName Copy> and <TriggerName Copy Copy>, etc. It will only take you a few seconds to change the names of a couple of triggers, but it might make it a lot easier for someone who looks at your code to figure out the logic behind your code.

2. Your code contains leaks. Guides on what leaks are and how to deal with them:
Memory Leaks
Things That Leak

3. I don't think using a hero unit as a dummy to buy abilities is a smart choice. Instead you can for example go with an item (like suggested above), a regular unit with no soundset, dummy abilities, etc.

4. You can add the first Arcane Vault that you create to a variable - this will allow you to more easily reference it in the future, make the code a bit more optimized and replace the list of sold heroes with abilities without having to remove the first Arcane Vault and spawn the second one.

5. Also - I don't really see a point in all the Wait actions you have in your code. Not only will it work completely fine without them, but it will also feel smoother.

---

P.P.S. While I could easily fix all the above issues for you, I think it will be better if you try to take our tips and try to figure it out yourself, so that you can learn something in the process. If you experience any further issues, do not hesitate to ask :) Cheers.
 
Last edited:
Level 20
Joined
Feb 23, 2014
Messages
1,265
First of all, good job on naming your triggers :) Everything is much easier to understand now.

Secondly, this is the problem:

  • Variables Unit Sold
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set unit = (Sold unit)
Are you sure that this is the right place to put this action? What do you think is the value of (Sold unit) when this trigger runs? :)

Try finding a better place for that action. If it fails, the answer is below:

You need to put this action (i.e. set the variable) in a trigger that fires when the hero is sold ("Hero And Ability Select"). Then the value of (Sold unit) equals the hero that was purchased and thus the hero will be bound to a variable.

And here's a working version: Map | HIVE

P.S. The way your triggers are structured is still messy and might potentially cause a lot of bugs. I've listed some of the causes in my previous post.
 
Last edited:
Status
Not open for further replies.
Top