• 🏆 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] Melee/Ranged Isnt Working

Status
Not open for further replies.
Level 5
Joined
Feb 5, 2021
Messages
89
Hello Community that has helped me understand so many things in the WE! #MuchAppreciation!

I am having trouble with yet another situation here as i have googled and searched through here for answers on switching from Melee -> Ranged and keeping spells and all of that is cool.

The problem is, all of this is triggered like this

Item has "Ranged" ability which is essentially "Bear Form" altered and then i have 2 units, 1 for melee and 1 for ranged.

then the trigger looks like this

  • StarterBow
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Hero manipulating item) is A Hero) Equal to True
          • ((Owner of (Hero manipulating item)) slot status) Equal to Is playing
          • (Item-type of (Item being manipulated)) Equal to Starter Bow
        • Then - Actions
          • Hero - Order (Hero manipulating item) to use (Item being manipulated)
        • Else - Actions
Which works fine but if the hero then picks up "Cracked Bow" which has the same type of trigger that would turn the hero into a "ranged" type, then he just "reverts" to his Melee "unit" again.

Extra Question: As my Hero is transformed into the "Ranged" form he does not change his primary stat even though i change it in OE, any ideas?

FYI: My bear forms Alternate and Normal units are BOTH the "Ranged" unit so either way it triggers it should make the "user" into a ranged unit (in my logic atleast ;) )

Anyone has any ideas on how to improve on this? :|
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Check if the Hero is already in ranged form before you order it to use the item. Also, disable the item after you use it.

  • Acquire Bow
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is A melee attacker) Equal to True
        • Then - Actions
          • Hero - Order (Triggering unit) to use (Item being manipulated)
        • Else - Actions
      • Item - Set Item: (Item being manipulated)'s Boolean Field: Actively Used ('iusa') to Value: False

Then when the hero loses the item make it usable again:
  • Lose Bow
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • Check if the item is a bow
    • Actions
      • Item - Set Item: (Item being manipulated)'s Boolean Field: Actively Used ('iusa') to Value: True
This way if you drop the item on the ground it'll reset it's state to being usable again. So if you pick it up again it'll be usable (if you're in melee form).
 
Level 5
Joined
Feb 5, 2021
Messages
89
Check if the Hero is already in ranged form before you order it to use the item. Also, disable the item after you use it.

  • Acquire Bow
    • Events
      • Unit - A unit Acquires an item
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is A melee attacker) Equal to True
        • Then - Actions
          • Hero - Order (Triggering unit) to use (Item being manipulated)
        • Else - Actions
      • Item - Set Item: (Item being manipulated)'s Boolean Field: Actively Used ('iusa') to Value: False

Then when the hero loses the item make it usable again:
  • Lose Bow
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • Check if the item is a bow
    • Actions
      • Item - Set Item: (Item being manipulated)'s Boolean Field: Actively Used ('iusa') to Value: True
This way if you drop the item on the ground it'll reset it's state to being usable again. So if you pick it up again it'll be usable (if you're in melee form).
Thank you for the try, but none the less it made everything worse so i just kept it as i have right now, as i have it right now it does switch between the stances, the problem comes arond when he is carrying more than 1 of the items, like, ill make an example :p
Items: Bow1, Bow2, Bow3

Hero Picks up Bow1, kills a mob, picks up Bow2 (which is better) and then drops/Sells Bow1, then he reverts back to Melee even though he is still carrying Bow2 and then that item becomes unuseable so it has to be dropped and picked up again.

As long as the hero is holding the initial item for the change, there is no problem :/

I feel inclined to just go from Item Changes to changes purely from hero spell, i'd just really like to have all "open slots" on hero for spells :/
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Can I see your triggers that you attempted to do it with?

Although, I personally didn't test this but theoretically it should work just fine. One issue that comes to mind is that Ordering the unit to use the item and then disabling the item immediately after could interrupt the order. Not sure if an Item Use order is instant or not, that and the Transforming skills often have delays. That being said, you could delay the disabling of the item if this happened to be the case.

Also, you don't necessarily have to use Bear Form/Transforming skills to change a unit from melee to ranged. On the more recent patches we have a lot more options available and can adjust a unit's weapon type, attack type, attack range, projectile art/speed/arc, etc. through triggers.
 
Level 5
Joined
Feb 5, 2021
Messages
89
Of course, i actually sent it in my very first post, thats the trigger that i use right now and then as said the item has the shapeshift ability on it, but if you can show me another way of making my unit ranged that would probably be much better and easier!

The only stats i really need to change are:
1. Attack Range
2. Projectile Art
3. Primary Attribute

If we can just change these 3 through triggers that would probably be ideal :D
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
I meant show me your trigger using the method I suggested with setting the item's Actively Used field to False/True.

Anyway, look into the Weapon field functions. You should see Weapon Boolean, Weapon Integer, Weapon Real, etc.

You can change all 3 of those things through triggers. Don't forget that Acquisition Range is tied to Attack Range and limits Attack Range.

Primary Attribute would be a Unit field function.
  • Unit - Set Unit: (Triggering unit)'s Integer Field: Primary Attribute ('upra') to Value: 1
Try Values between 0-3 for Strength/Agility/Intelligence.

Also, an important thing to note is that these functions are indexed starting at 0 which means that you sometimes need to subtract 1 the fields that take integers. For example, if you're editing a unit's weapons, then Weapon 1 is index 0 and Weapon 2 is index 1. For abilities, if you reference their level then Level 1 = 0, Level 2 = 1, etc.
 
Last edited:
Level 5
Joined
Feb 5, 2021
Messages
89
I meant show me your trigger using the method I suggested with setting the item's Actively Used field to False/True.

Anyway, look into the Weapon field functions. You should see Weapon Boolean, Weapon Integer, Weapon Real, etc.

You can change all 3 of those things through triggers. Don't forget that Acquisition Range is tied to Attack Range and limits Attack Range.

Primary Attribute would be a Unit field function.
  • Unit - Set Unit: (Triggering unit)'s Integer Field: Primary Attribute ('upra') to Value: 1
Try Values between 0-3 for Strength/Agility/Intelligence.

Also, an important thing to note is that these functions are indexed starting at 0 which means that you sometimes need to subtract 1 the fields that take integers. For example, if you're editing a unit's weapons, then Weapon 1 is index 0 and Weapon 2 is index 1. For abilities, if you reference their level then Level 1 = 0, Level 2 = 1, etc.
Ohh i just copied what you had written :p everything matching but i think this trigger change will be where i switch my focucs since i believe that would be way more reliable, atleast in my head, now i just need to make them actually change stuff, and i need to learn indexes, hadn't gotten to that point yet though in my learning! :D

Thank you so much for all your help in getting me through this!

You wouldnt happen to know a thing or two about indexes to explain real quick? :p
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
I think you'll understand what I mean when you see the Weapon field actions (or functions as I called them). They'll ask for an Index which represents the weapon number you want to change. Units can only have up to 2 Weapons, Weapon 1 and Weapon 2, so you're choosing between one of those.

But it's tricky because Blizzard started the Weapon's indexes at 0. So if you want to edit Weapon 1, you write 0 as your weapon index. People get confused by this and often post on Hive asking why these triggers won't work, and a lot of the times it's because their Index value is 1 unit too high.
  • Actions
    • // Here I'm changing the values of the unit's Weapon 1
    • Unit - Set Unit: (Triggering unit)'s Weapon Real Field: Attack Range ('ua1m')at Index:0 to Value: 600.00
    • Unit - Set Unit: (Triggering unit)'s Weapon String Field: Attack Projectile Art ('ua1m')at Index:0 to Value: Abilities\Weapons\SorceressMissile\SorceressMissile.mdl

Also, I should've been more clear before but those Item triggers I posted left out some of the Conditions/Actions that you had in your original triggers. Maybe that's why it didn't work for you.
 
Last edited:
Level 5
Joined
Feb 5, 2021
Messages
89
Yes after reading this then yes it makes perfect sense though i cannot for the life of me get that trigger to work :eek:


Ahh, the "previous" trigger yes that would maybe be it, i did also try and incorporate it into my existing trigger, couldnt make it work, though after this new revelation of having just one unit type i am determined to make that work! :D

  • GetRanged
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Hero manipulating item)) Equal to Melee Adventurer
    • Actions
      • Unit - Set Unit: (Hero manipulating item)'s Weapon Real Field: Attack Range ('ua1m')at Index:0 to Value: 500.00
      • Unit - Set Unit: (Hero manipulating item)'s Weapon String Field: Attack Projectile Art ('ua1m')at Index:0 to Value: Abilities\Weapons\Arrow\ArrowMissile.mdl
Edit: Thought it might be good to type in the trigger im trying at the moment! :D
 
Last edited:
Level 5
Joined
Feb 5, 2021
Messages
89
Does that GetRanged trigger not work? Remember that Acquisition Range is tied to Attack Range so that could limit it.

It should work though, I've used those Actions before without any issues.
Sadly no it does not work, i have tried making that specific change (only the art and the range) in the OE and that works, so somehow when it triggers it doesnt do anything, i tried adding that "Game - Text" thing and that procs alright so i know it triggers, it just doesnt change anything sadly :/

And just to be safe i double checked everything when you mentioned the acquisition range and its all good, as said, if i do the change in OE, no probs :(
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
I'll test it out. Maybe it needs to be a ranged unit to have these fields adjusted but I doubt it.

Edit:
So it's really buggy. You can add attack range to a melee unit but the value you put in needs to be 400 more than what you wanted (at least when I tested with the Paladin). So if you change the Paladin's attack range to 600, you need to set your range value to 1000. Also, you need to do this for BOTH weapon indexes.
  • Unit - Set Unit: (Hero manipulating item)'s Weapon Real Field: Attack Range ('ua1m')at Index:0 to Value: 1000.00
  • Unit - Set Unit: (Hero manipulating item)'s Weapon Real Field: Attack Range ('ua1m')at Index:1 to Value: 1000.00
Unfortunately, there's no way to change a unit's Weapon Type through triggers, so you can't change the hero's weapon from Normal to Missile. This means that you'll end up with a Melee unit with a long range melee attack.

However, I messed around with "Attacks Enabled" and found that this works but with some issues:
  • Unit - Set Unit: (Triggering unit)'s Weapon Boolean Field: Attacks Enabled ('uaen')at Index:0 to Value: False
  • Unit - Set Unit: (Triggering unit)'s Weapon Boolean Field: Attacks Enabled ('uaen')at Index:1 to Value: True
It'll disable the unit's Weapon 1 and enable Weapon 2, which you can setup to be a ranged Weapon in the Object Editor, but for some reason it hides the Weapon UI (Attack damage numbers). You'd think you could just unhide it using the "Show Attacks" action but it won't work for some odd reason. Chalk it up to the devs giving up on this game.
 
Last edited:
Level 5
Joined
Feb 5, 2021
Messages
89
I'll test it out. Maybe it needs to be a ranged unit to have these fields adjusted but I doubt it.

Edit:
So it's really buggy. You can add attack range to a melee unit but the value you put in needs to 400 more than what you wanted (at least when I tested with the Paladin). So if you change the Paladin's attack range to 600, you need to set your range value to 1000. Also, you need to do this for BOTH weapon indexes.
  • Unit - Set Unit: (Hero manipulating item)'s Weapon Real Field: Attack Range ('ua1m')at Index:0 to Value: 1000.00
  • Unit - Set Unit: (Hero manipulating item)'s Weapon Real Field: Attack Range ('ua1m')at Index:1 to Value: 1000.00
Unfortunately, there's no way to change a unit's Weapon Type through triggers, so you can't change the hero's weapon from Normal to Missile. This means that you'll end up with a Melee unit with a long range melee attack.

However, I messed around with "Attacks Enabled" and found that this works but with some issues:
  • Unit - Set Unit: (Triggering unit)'s Weapon Boolean Field: Attacks Enabled ('uaen')at Index:0 to Value: False
  • Unit - Set Unit: (Triggering unit)'s Weapon Boolean Field: Attacks Enabled ('uaen')at Index:1 to Value: True
It'll disable the unit's Weapon 1 and enable Weapon 2, which you can setup to be a ranged Weapon in the Object Editor, but for some reason it hides the Weapon UI (Attack damage numbers). You'd think you could just unhide it using the "Show Attacks" action but it won't work for some odd reason. Chalk it up to the devs giving up on this game.
Oh my lord! this is perfect! mine sets it off by 425, this is indeed really weird but alas it will work! as long as i know how to "use" the bug, it is still to my favor, i can make the weapon type into missile by default as there is not gonna be anything different from missile to normal in my map!

I am very appreciative for your help and your time in testing this out! i can finally make this work in a favorable way! now i just need to figure out how to change the primary attribute and im all set! (i cant get the values for primary to work) :D
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
I remember now. You can GET the primary attribute of a unit and reference it, but changing it probably doesn't work. Sorry about that!

Another thing you can mess around with is the Set Unit Skin action, this one offers some pretty cool possibilities. Again though, it's rather buggy and can have some unwanted outcomes.
 
Status
Not open for further replies.
Top