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

[JASS] Get Ability ID from Ability?

Status
Not open for further replies.
Level 3
Joined
Jun 25, 2011
Messages
39
Majestic Hivemind!

Humble me are here before your majestic presence to take a bite of your wisdom.

I am currently working on a custom map, where similar to custom hero survival, I get to build my hero by buying abilities.

I figured out, that if I make the buy-able abilities actual items, which have the replacement ability (which converts the placeholder to the actual ability, engineering upgrade, I know that sort of stuff).
I can get it with the get item ability by id function (so its the first ability the item has, by the index of 0).
But when I have to add the ability to the actual unit, I have the problem, that the function (sorry, action) waits for rawcode while the get ability actually gets the ability (I suppose the reference or pointer).

  • SkillPicking
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
      • (Unit-type of (Selling unit)) Equal to Skill Shop (Normal)
    • Actions
      • Set VariableSet AbilityToBuy = (Item: (Last created item)'s Ability at index: 0)
      • Set VariableSet AbilityString = ???
      • Set VariableSet AbilityIntegerID = (Integer(AbilityString))

My question is, that How can I get the RAWCODE of an ability, by knowing only the 'ability'?
I learn programming it's not a problem for me to learn JASS, I searched for a documentation, but I haven't found anything particularly useful.

Thank you,
Sarungard
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,517
Alright, so I looked into and I don't think there's any way to convert an Ability into an Ability Code.

That being said, I found a nice solution that does basically the same thing:

After copying this system into your map: [Snippet] Ascii

Your trigger will look like this:
  • Test
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
    • Actions
      • Set VariableSet TempString = (Description of (Sold Item))
      • Custom script: set udg_TempAbility = S2A( udg_TempString )
      • Unit - Add TempAbility to (Buying unit)
Variables:
TempString = String
TempAbility = Ability Code

So as you can see I'm using the Description of the Item to get the rawcode of the ability. See my attached picture for an example. I put the rawcode of Berserk (Absk) into the Item Description and that's how the trigger gets the ability.

The Ascii system allows you to convert String2Ability and Ability2String but I couldn't get it to work with GetItemAbilityByIndex. Luckily, this alternate approach worked just fine.
 

Attachments

  • example.png
    example.png
    54.1 KB · Views: 74
  • Get Item Ability example.w3m
    22.7 KB · Views: 25
Level 3
Joined
Jun 25, 2011
Messages
39
Alright, so I looked into and I don't think there's any way to convert an Ability into an Ability Code.

That being said, I found a nice solution that does basically the same thing:

After copying this system into your map: [Snippet] Ascii

Your trigger will look like this:
  • Test
    • Events
      • Unit - A unit Sells an item (from shop)
    • Conditions
    • Actions
      • Set VariableSet TempString = (Description of (Sold Item))
      • Custom script: set udg_TempAbility = S2A( udg_TempString )
      • Unit - Add TempAbility to (Buying unit)
Variables:
TempString = String
TempAbility = Ability Code

So as you can see I'm using the Description of the Item to get the rawcode of the ability. See my attached picture for an example. I put the rawcode of Berserk (Absk) into the Item Description and that's how the trigger gets the ability.

The Ascii system allows you to convert String2Ability and Ability2String but I couldn't get it to work with GetItemAbilityByIndex. Luckily, this alternate approach worked just fine.
Oh yes, that definitely worked just like charm!
My next problem is that this method somehow switches the ability icon into a question mark without description, keeps the manacost, the targeting abilities and hotkey, however it just deals damage, but no effect. In comparison, if I just add and remove the same skill, it works perfectly fine.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,517
That's odd, I didn't have that issue o_O

You wouldn't happen to be using the Engineering Upgrade ability, would you? It's currently buggy.

Maybe you can send me the map or an example of it.

Edit: Attached an updated version, I didn't fix your issue because I'm not experiencing it but I did give the option to increase the level of the purchased ability and refund gold cost for purchases that would try to go above max level.
 

Attachments

  • Get Item Ability example 2.w3m
    24.1 KB · Views: 27
Last edited:
Level 3
Joined
Jun 25, 2011
Messages
39
That's odd, I didn't have that issue o_O

You wouldn't happen to be using the Engineering Upgrade ability, would you? It's currently buggy.

Maybe you can send me the map or an example of it.

Edit: Attached an updated version, I didn't fix your issue because I'm not experiencing it but I did give the option to increase the level of the purchased ability and refund gold cost for purchases that would try to go above max level.

Yes, I tried to work with the Engineering Upgrade. Craps.
What do you think, will it ever get fixed or shall I give up?

p.s.: Thx for the help, I attach my map for investigation

edit: I was lazy to initialize the map properly, so you should use greedisgood :D

edit2: I was thinking on a workaround, which involves a bit more triggering: the hero will have learnable skills which will increase stats or whatever and as he levels up, you can increase your different skills level by repurchasing the skill again or with another method? Would it be enjoyable?
 

Attachments

  • MrVeryMap.w3m
    141.4 KB · Views: 17
Last edited:
Status
Not open for further replies.
Top