• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[General] handle type is pointerlike?

Status
Not open for further replies.
Level 3
Joined
Mar 10, 2019
Messages
32
Hey Guys,

I found out that the "handle" type is the parent type of the variables you define in the Trigger Editor GUI.

JASS Manual: Types

It is also some kind of "pointer".

So I thought nice gonna use it like in C++ then:
Defined a variable with type ability (derived from: <-agent<-handle) and call
<udg_ability_variable>.levels or <udg_ability_variable>->levels
(max level property name in editor on CTRL + D)

But both do not work. So how can I get the properties of such "struct like" objects? Or are they all private?


If this functionality is not there yet it would be so awesome to have a generic function to search on such kind of handle object if the property exsist and return the value if it does.

something like:
Code:
getPropertyOfObject(handle type, string o, string expectedTypeT) returns expectedTypeT
found type.o
   if expectedTypeT == type.o.type
    return type.o.value
   else
    return type.null
else return type.null

where "expectedTypeT" can be a basic type: integer, string, raw and so on...
 
Level 3
Joined
Mar 10, 2019
Messages
32
What I try to achieve works fine only the maximum level of a skill is not "generic" enough maybe you have an idea? :)

Custom script: set udg_CurrentLearningAbilityMaxLvl = udg_CurrentlyLearningSpell.levels // is not working ofc!

  • LearnSpells
    • Events
      • Unit - A unit Uses an item
    • Conditions
      • (Substring((Name of (Item being manipulated)), 1, 5)) Equal to Learn
    • Actions
      • Set CurrentlyLearningBook = (Item being manipulated)
      • Set CurrentlyLearningAbilityName = (Substring((Name of (Item being manipulated)), 17, ((Length of (Name of (Item being manipulated))) - 2)))
      • For each (Integer A) from 0 to MaxAbilitiesCount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CustomAbilitiesTableName[(Integer A)] Equal to CurrentlyLearningAbilityName
            • Then - Actions
              • Set CurrentlyLearningSpell = CustomAbilitiesTableValue[(Integer A)]
              • Set CurrentLearningAbilityMaxLvl = (Mana cost of CurrentlyLearningSpell, Level 1)
              • Custom script: set udg_CurrentLearningAbilityMaxLvl = udg_CurrentlyLearningSpell.levels
              • Custom script: set udg_CurrentLearningAbilityMaxLvl = 5
              • Custom script: exitwhen true
            • Else - Actions
              • Do nothing
      • Game - Display to (All allies of (Owner of (Triggering unit))) the text: ((Name of (Triggering player)) + ( learned: + (Name of CurrentlyLearningSpell)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of CurrentlyLearningSpell for (Triggering unit)) Less than CurrentLearningAbilityMaxLvl
          • (Level of CurrentlyLearningSpell for (Triggering unit)) Greater than or equal to 1
        • Then - Actions
          • Unit - Increase level of CurrentlyLearningSpell for (Triggering unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of CurrentlyLearningSpell for (Triggering unit)) Greater than or equal to CurrentLearningAbilityMaxLvl
            • Then - Actions
              • Hero - Create (Item-type of CurrentlyLearningBook) and give it to (Triggering unit)
            • Else - Actions
              • Unit - Add CurrentlyLearningSpell to (Triggering unit)
 
Level 7
Joined
Apr 17, 2017
Messages
316
A handle is anything that is not boolean integer string or real. For example Units, locations, destructibles even triggers etc are all handles. And all handles have unique handleid that returns integer when you set them like this: set int = GetHandleId(GetTriggerUnit()). What you can do with this information ? Well, you can create spells, systems, that is up to your imagination. So an ability variable is just an integer with rawcodes like 'Anab' or 'Aloc' .

Information about type ability

This type was deprecated by blizzard and you should let it rest in peace, use integers for representing abilityids instead.
 
Level 3
Joined
Mar 10, 2019
Messages
32
A handle is anything that is not boolean integer string or real. For example Units, locations, destructibles even triggers etc are all handles. And all handles have unique handleid that returns integer when you set them like this: set int = GetHandleId(GetTriggerUnit()). What you can do with this information ? Well, you can create spells, systems, that is up to your imagination. So an ability variable is just an integer with rawcodes like 'Anab' or 'Aloc' .
So can i create a ability from the id and then get the .levels property from it?
 
Level 7
Joined
Apr 17, 2017
Messages
316
I am afraid not. Blizzard has a strict rule when it comes to editing object data. But you can add an ability to a unit,remove or get the level of an ability for a specific unit (as an integer) if that's what you want.
 
Level 41
Joined
Feb 27, 2007
Messages
5,184
No. They are only pointers in that they have a HandleID which in theory points somewhere to memory. JASS is not an oop language so there is no . syntax anywhere in it. vJASS added pseudo-oop structure to JASS but not in the way you'd like to do since that information isn't available from the game. Perhaps with a memory hack you could achieve this functionality. The next best solution is to do/use something like this to read OE fields, but it doesn't work on all fields and I'm not sure if level is one of them: Dynamically Retrieve Object Editor Fields Beyond that you could precache all of the data you want into some arrays or hashtables; with a hashtable you could actually use the abilityid (as an integer) as one of your keys (the number would be outside JASS array bounds).

The ability type, sadly, has almost no functionality in wc3.
 
Level 3
Joined
Mar 10, 2019
Messages
32
Thanks! I will look into it and update this post if I find a solution. A generic "Learn a skill" trigger is benefitial for all I guess. Copy pasting triggers for specific spells is a pain in the but.
 
Level 3
Joined
Mar 10, 2019
Messages
32
I get an Error:
undecleared function: GetObjectFieldInteger

Is this some kind of special jass functionality I have to add?
 
TriggerHappy's jass code needs to be ported into your map. For making jass functions being call-able from other jass codes you may need to put it additionaly into a library.

When you have his code imported, and put in an library you should be able to call it. : ) I believe, too, that Pyro is right, it should probably work with the little script.
 
Level 3
Joined
Mar 10, 2019
Messages
32
TriggerHappy's jass code needs to be ported into your map. For making jass functions being call-able from other jass codes you may need to put it additionaly into a library.

When you have his code imported, and put in an library you should be able to call it. : ) I believe, too, that Pyro is right, it should probably work with the little script.
Thanks as soon as I have time I will try that out.
 
Status
Not open for further replies.
Top