• 🏆 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] Global stat gain

Status
Not open for further replies.
Level 2
Joined
Oct 13, 2014
Messages
8
Please, someone help, i need a trigger for my map that give to all owned heroes by a player bonus stat when any hero from this player pick up a tome (tome of agility, etc...).

I made 3 trigger to do that but they don't work ! :

1st :

Event :
A unit enters playable area
Condition :
Owner of triggering unit = Player 1
Triggering unit is a hero = True
Action :
Add triggering unit in (unit group)


2nd :

Event :
A unit acquires an item
Condition :
None
Action :
If :
-Triggering unit is a hero
-Owner of triggering unit = Player 1
-Item beeing manipulated is Tome of Agility
> Pick every unit in (unit group) and do add 1 agility to picked unit


3rd Trigger :


Event :
A unit leaves playable area
Condition :
Owner of triggering unit = Player 1
Triggering unit is a hero = True
Action :
Remove triggering unit in (unit group)
 
Level 22
Joined
Aug 27, 2013
Messages
3,973
It should be like this in my opinion.

  • Events
    • Unit - A unit Acquires an item
  • Conditions
    • Or - Any (Conditions) are true
      • Conditions
        • (Item-type of (Item being manipulated)) Equal to Tome of Agility
        • (Item-type of (Item being manipulated)) Equal to Tome of Intelligence
        • (Item-type of (Item being manipulated)) Equal to Tome of Strength
        • (Item-type of (Item being manipulated)) Equal to Tome of Knowledge
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Owner of (Triggering unit)) Equal to Player 1 (Red)
      • Then - Actions
        • Custom script: set bj_wantDestroyGroup = true
        • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Owner of (Matching unit)) Equal to Player 1 (Red)) and ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to (Triggering unit))))) and do (Actions)
        • Loop - Actions
          • Hero - Create (Item-type of (Item being manipulated)) and give it to (Picked unit)
      • Else - Actions

Though my method isn't the best, you can always try another way. But I'm sure this will work well for you.
 
Level 2
Joined
Oct 13, 2014
Messages
8
my map is a Pokemon map, at the start you pick a hero (Pokemon), and then you capture more (up to 6) and lvl them up.

the Tomes in the game are set to auto consume = False
but i got a trigger that use them automatically when acquired by a hero (to prevent game crash)
 
So, you use more triggers with event "A unit quires an item"? And in one of them you remove/use it instantly?
How can this prevent game crash?

So probably if this "Item use" trigger runs before, then this trigger that you posted, can't check for correct ItemType anymore -> won't do actions. You can test it with printing a message of name of item being manipulated in your trigger.
 
Level 2
Joined
Oct 13, 2014
Messages
8
i use alot of trigger like (a unit acquires an item) yes, something like 60

here is the trigger to auto consume tomes (i use it to prevent non-hero units to consume the tomes and make the game crash instantally) :

1607042_4678542299274_8293105683938612646_n.jpg
 
Level 2
Joined
Oct 13, 2014
Messages
8
I believe you can't refer to the item anymore after you make this action: "Hero - Use Item".

Also your condition is " TriggeringUnit Equals Hero == True". So this would not prevent anything for non-heroes.

I only have 1 unit in my map as a non-hero unit, and he has a full 6 inventory slot at the start, it cannot pick up any item, but can still consume when the "auto-consume = True". That make any map crash.
 
Sorry, but do you even read what I write to you?

1. Read this: http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/how-easily-post-triggers-163285/
2. If you use "Hero - Use ItemBeingManipulated" before in an other trigger, I don't think you can refer anymore to this item in any other trigger.
3. Make a debug message to ensure the trigger gets fired or not.


Edit:
I only have 1 unit in my map as a non-hero unit, and he has a full 6 inventory slot at the start, it cannot pick up any item, but can still consume when the "auto-consume = True". That make any map crash.
If it helps, you also can modify the unit's inventory ability, that it can't activly use items. -> can't use tomes anymore. -> you can turn on "Automatically consume" for tomes.
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
That trigger will create an endless loop anyway.
Creating an item for unit causes the event "Unit Acquires an item" to fire as well. Plainly said, the event "Unit Acquire an item" really fires whenever a unit "acquires"/"gains" an item and it doesn't matter if it was via picking that item up, or if it was via trigger or some other way.

So Unit_A picks an item -> event fires -> the trigger gives the same item to Unit_B and Unit_C => event fire for both Unit_B and Unit_C, causing Unit_B to give item to Unit_A and Unit_C and so on, resulting in crash.
You may want to turn off the trigger when you're about to pick all allied heroes of said player, give them the item and then turn it back on.

That being said, this simple trigger works for me:
  • Acquire
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Tome of Agility +2
          • (Item-type of (Item being manipulated)) Equal to Tome of Intelligence +2
          • (Item-type of (Item being manipulated)) Equal to Tome of Strength +2
    • Actions
      • Trigger - Turn off (This trigger)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area) matching (((Owner of (Matching unit)) Equal to Player 1 (Red)) and ((((Matching unit) is A Hero) Equal to True) and ((Matching unit) Not equal to (Triggering unit))))) and do (Actions)
        • Loop - Actions
          • Hero - Create (Item-type of (Item being manipulated)) and give it to (Picked unit)
      • Trigger - Turn on (This trigger)
It may really be that some other trigger(s) interfere(s) with your trigger. You should try placing debug messages in your trigger to for example write down name of Acquired Item, name of picked unit, etc.
 
Level 6
Joined
Nov 24, 2012
Messages
218
I'm sure everyone else helped but this works best with your settings (Use Automatically When Acquired: False):


  • ConsumeTomes
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Tome of Agility
          • (Item-type of (Item being manipulated)) Equal to Tome of Agility +2
    • Actions
      • Trigger - Turn off (This trigger)
      • Set ItemType = (Item-type of (Item being manipulated))
      • Item - Remove (Item being manipulated)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by (Owner of (Triggering unit)) matching (((Matching unit) is A Hero) Equal to True)) and do (Actions)
        • Loop - Actions
          • Hero - Create ItemType and give it to (Picked unit)
          • Hero - Order (Picked unit) to use (Last created item)
      • Trigger - Turn on (This trigger)
Turn off/on will make the trigger not infinitely loop.
Remove item will make it so the hero picking up will not be double-tomed (Nichilus's method works too, if you check his double condition in pick Unit Group)
To avoid crash, you also need a trigger to make non-hero units drop the tome item if they try to pick it up, if you don't already have that.
The downside of your setting is that all of your heroes will stop to use the tome (order interrupted).
Another complex method is making your own tomes (based off any item such as claws of attack, change item model, edit hero stat and play special effect by trigger).
Good luck making your Pokemon map :)
 
Last edited:
Status
Not open for further replies.
Top