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

Detecting item ability type

Status
Not open for further replies.
Level 9
Joined
Sep 20, 2015
Messages
385
Hello,

I need help for my map. Basically in this map every player controls a hero with 0 abilities. With an RNG system whenever the heroes pick up a specific object they learn 1 random ability. After they cast the ability it disappear. A hero can use an ability one time. I'm using this trigger to remove the ability after the cast :

  • Events
    • Units - A unit finishes casting an ability
  • Conditions
    • Actions
      • Set CastedAbility (PlayerNumberOf (owner of (Casting unit))) = (Ability being cast)
      • Unit - Remove CastedAbility (PlayerNumberOf (owner of (Casting unit))) from (Casting unit)
It works well BUT in this map there are items, and every time a hero uses an item it count as an ability and if the item has charges or it's a usable item (like Kil'jaden dagger) it bugs out and can't be used again.

So my question is there is a way to detect when an ability is casted with an item??
I tried disabling the triggers whenever a hero used an item, but didn't work as well.
Please tell me i dnt have to check for all abilities type one by one.

Thanks in advance
 
  • ItemUse
    • Events
      • Unit - A unit Uses an item
    • Conditions
    • Actions
      • Set isItemused = True
      • Game - Display to (All players) the text: item used
      • Custom script: call StartTimerBJ( udg_timer, false, 0.0001 )
      • (turn this off) Countdown Timer - Start timer as a One-shot timer that will expire in 0.01 seconds
Try this. It seems there is some delay introduced when my code is ported to a map with more timers and stuff, however this should fix it, see if it works consistently now.
 
Level 9
Joined
Sep 20, 2015
Messages
385
I tired (took me a while before getting a channeled spell) with blizzard and after the first wave the ability is removed from the unit and it stops. That's why i used - A unit finishes casting an ability. If i used - A unit finishes casting an ability - you can cast it then immediatly order the unit to move and the ability isn't removed because the hero didn't finished casting it.
 
Still, though, why are you even using the same abilities for items and unit abilities? Some do not even have a tooltip.

If you are using only default wc3 abilities, there is a very simple way to figure out if an ITEM ABILITY is used, but not whether it comes from an item.

  • SpellEffect
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set spellunit = (Triggering unit)
      • Set spell = (Ability being cast)
      • Custom script: if udg_spell >= 'AI00' and udg_spell < 'AJ00' then
      • Game - Display to (All players) the text: ITEM ABIL
      • Custom script: else
      • Game - Display to (All players) the text: UNIT ABIL
      • Custom script: endif
This checks whether the item ability is used with 100% accuracy if you are only using default wc3 item abilities and ON ITEMS. Don't use item abilities on units.
 
Last edited:
Just for the record, now you need only one trigger.
  • SpellEffect
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
    • Actions
      • Set spell = (Ability being cast)
      • Custom script: if udg_spell >= 'AI00' and udg_spell < 'AJ00' then
      • Game - Display to (All players) the text: ITEM ABIL
      • Custom script: else
      • Game - Display to (All players) the text: UNIT ABIL
      • Custom script: endif
 
Status
Not open for further replies.
Top