• 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.

Unit Abilities | Item Abilities

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
How can we differentiate these 2 types of execution in a trigger ?
I mean, how can we check if a spell is cast, either it is from Unit, or from an Item ?

Aside from Unit - A unit Uses an item, how can we differentiate types of spell from this Event;
  • Unit - A unit Starts the effect of an ability
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Is this for a public system or for personal use?

If it's for personal use: you can make the raw ID of all item abilities begin with a lower-case letter ('test') and all regular abilities with an upper-case letter ('Test') or number ('7est').
Then you can set an integer variable to the raw ID of the casted spell, if that integer is lower than 1627389952, it must be a regular ability.
If it is higher or equal to that number, it's an item ability.
At least, that is the theory :p (I also tested this to double-check, seems to work nicely).
This will save you (as well as the code) the pain of setting all abilities in a table, but it doesn't really work for public resources :/

Edit:
JASS:
if GetSpellAbilityId() < 1627389952 then
    // Unit Ability
else
    // Item Ability
endif
(For clarification)
endedit

There must be an easier way though. I tried checking for several things, but without much result (stupid ability level :p).
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Is this for a public system or for personal use?

If it's for personal use: you can make the raw ID of all item abilities begin with a lower-case letter ('test') and all regular abilities with an upper-case letter ('Test') or number ('7est').
Then you can set an integer variable to the raw ID of the casted spell, if that integer is lower than 1627389952, it must be a regular ability.
If it is higher or equal to that number, it's an item ability.
At least, that is the theory :p (I also tested this to double-check, seems to work nicely).
This will save you (as well as the code) the pain of setting all abilities in a table, but it doesn't really work for public resources :/

Edit:
JASS:
if GetSpellAbilityId() < 1627389952 then
    // Unit Ability
else
    // Item Ability
endif
(For clarification)
endedit

There must be an easier way though. I tried checking for several things, but without much result (stupid ability level :p).

Neat, but also a lot of work :/
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
I've thought of something - you know how item abilities are always instant? You can check the delay between Begins casting a spell and Stars the effect of an ability.

No. There are many more abilities which are "instant" (= dont use the units cast point).

@ap0calypse: As you said, your method has some problems. It would require a definition which characters may be used as first one to make it work, as the whole range of Ascii characters can be used.

The following should work nice:

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
  • Actions
    • Custom script: if (GetUnitCurrentOrder(GetTriggerUnit())>=852008 and GetUnitCurrentOrder(GetTriggerUnit())<=852013) then
    • Game - Display to (All players) the text: Item Ability!
    • Custom script: else
    • Game - Display to (All players) the text: Nonitem Ability!
    • Custom script: endif
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
No. There are many more abilities which are "instant" (= dont use the units cast point).

@ap0calypse: As you said, your method has some problems. It would require a definition which characters may be used as first one to make it work, as the whole range of Ascii characters can be used.

The following should work nice:

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
  • Actions
    • Custom script: if (GetUnitCurrentOrder(GetTriggerUnit())>=852008 and GetUnitCurrentOrder(GetTriggerUnit())<=852013) then
    • Game - Display to (All players) the text: Item Ability!
    • Custom script: else
    • Game - Display to (All players) the text: Nonitem Ability!
    • Custom script: endif
Yes, that's why I picked lower-case. It's basically the last thing people use (nobody really uses {} or extended ASCII codes in their ID's).
Nonetheless, I had already accepted the flaw in that.

Your method seems like a really nice idea and it does indeed work as intended. Nice find there.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I can only imagine that you store all either unit or item abilities in a hashtable/array.
You're joking right, lol, 23235353 abilities, naah.

If it's for personal use: you can make the raw ID of all item abilities begin with a lower-case letter ('test') and all regular abilities with an upper-case letter ('Test') or number ('7est').
Then you can set an integer variable to the raw ID of the casted spell, if that integer is lower than 1627389952, it must be a regular ability.
If it is higher or equal to that number, it's an item ability.
At least, that is the theory :p (I also tested this to double-check, seems to work nicely).
This will save you (as well as the code) the pain of setting all abilities in a table, but it doesn't really work for public resources :/
Your suggestion is the same as ruler, I might as well save all abilities in a hashtable.

No. There are many more abilities which are "instant" (= dont use the units cast point).

@ap0calypse: As you said, your method has some problems. It would require a definition which characters may be used as first one to make it work, as the whole range of Ascii characters can be used.

The following should work nice:

  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
  • Actions
    • Custom script: if (GetUnitCurrentOrder(GetTriggerUnit())>=852008 and GetUnitCurrentOrder(GetTriggerUnit())<=852013) then
    • Game - Display to (All players) the text: Item Ability!
    • Custom script: else
    • Game - Display to (All players) the text: Nonitem Ability!
    • Custom script: endif

Ah, is that an order of 'useslot' ? Or something like that.
xxxxx8 ~ xxxx13 is the slot item, is it ?

Will try this (I bet this works nicely as intended), CLOSED.
 
Status
Not open for further replies.
Top