• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

(item being manipulated) Equal to skill

Status
Not open for further replies.
Level 6
Joined
Apr 16, 2011
Messages
158
Hello I am using that system so that my heroes can their purchase magics (skill) the magic in subject is going to the level 5 put after arriving in this level you can still spend as money

summarizing:

Somebody could indicate myself a way to do a trigger so that when the magic in subject arrives at his/her maximum level (5) her more it cannot be bought.


is there some leak type in those triggers?



  • Skill Aerial shackles
  • Events
    • Unit - A Unit Acquires an item
  • Conditions
    • (item-type of (item being manipulated)) Equal to Aerial Shackles
  • Actions
    • Set skill(Player number of tiggering player))] = Aerial Shackles
    • Wait 0.20 seconds
    • if (all Conditions are true) then do (then Actions) else do (else Actions)
      • If - Conditions
        • (Level of skill(Player number of (Triggering player))] for (triggering unit) Less Than 1
          • Then - Actions
            • Unit - add Skill(Player number of (Triggering player))] to (triggering unit)
thank you
 
Last edited:
For nice, faster and smooth results, you will need a hashtable. You will create your items and save the corresponding ability to each of them. I have made a test map for you; in the test map, there are two items, "Robe of Infinity" and "Mask of Regeneration". Robe of Infinity gives Force of Nature skill, so we save it on this item via the hashtable with their raw id's. On the other hand, Mask of Regeneration supplies the hero with Brilliance Aura.

  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_I_Hash = InitHashtable()
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • -------- Robe of Infinity is supposed to give you the "Force of Nature" ability. --------
      • -------- Force of Nature's ability ID is 'A001' --------
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • Set Items[1] = Robe of Infinity
      • Custom script: call SaveInteger (udg_I_Hash, udg_Items[1], StringHash("ability"), 'A001')
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • -------- Mask of Regeneration is supposed to give you the "Brilliance Aura" ability. --------
      • -------- Brilliance Aura's ability ID is 'A000' --------
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • Set Items[2] = Mask of Regeneration
      • Custom script: call SaveInteger (udg_I_Hash, udg_Items[2], StringHash("ability"), 'A000')
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
  • Item Check
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to Mask of Regeneration
          • (Item-type of (Item being manipulated)) Equal to Robe of Infinity
    • Actions
      • Custom script: set udg_AbilityLoad = LoadInteger (udg_I_Hash, GetItemTypeId(GetManipulatedItem()), StringHash("ability"))
      • Custom script: if GetUnitAbilityLevel (GetTriggerUnit(), udg_AbilityLoad) == 0 then
      • Custom script: call UnitAddAbility (GetTriggerUnit(), udg_AbilityLoad)
      • Custom script: else
      • Custom script: if GetUnitAbilityLevel (GetTriggerUnit(), udg_AbilityLoad) < 5 then
      • Custom script: call SetUnitAbilityLevel (GetTriggerUnit(), udg_AbilityLoad, GetUnitAbilityLevel (GetTriggerUnit(), udg_AbilityLoad) + 1)
      • Custom script: else
      • Set TGr = (Player group((Triggering player)))
      • Game - Display to TGr for 1.35 seconds the text: ...
      • Custom script: call DestroyForce (udg_TGr)
      • Custom script: endif
      • Custom script: endif
      • Hero - Drop (Item being manipulated) from (Triggering unit)
      • Item - Remove (Last dropped item)
The trigger checks if the unit already has the ability of the said item; if it doesn't, it adds it on the hero. If it does, it increases its level, but it first of all checks whether the level of the ability is less than 5. If it is less than 5, it normally increases it, else, it displays an error message.

And no, there is no leak in your triggers. For more info:

http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/
http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 

Attachments

  • Maximum level of bought abilities.w3x
    18.7 KB · Views: 33
Level 6
Joined
Apr 16, 2011
Messages
158
Pharaoh_ scares me with that knowledge.
I understood what the triggers do.
but in this line it is where you save him/it number regarding ability ?
thank you
  • Set Items[1] = Robe of Infinity
    • Custom script: call SaveInteger (udg_I_Hash, udg_Items[1], StringHash("ability"), 'A001')
 
Yes, each object in the Object Editor is having an integer counterpart, internally. In order to retrieve each object's raw id, go to the Object Editor and hit "Ctrl + D" (or View menu -> Display values in raw data). So, the ability of Force of Nature is having the raw id of 'A001'. So, you will be using the same method for new items (of your own), just don't forget of switching the "Items[1]" to the new Items[] value, e.g. [3] in the list and the ability id, e.g. 'A001' to 'A003'.

There is another way to make it easier for you to handle, by using an extra variable of type "Ability" and then make the comparison (you won't even need hashtables for this, it was faster for me to create it though).
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,232
It could probably be improved by using the hashtable as the validation check as well instead of also doing O(n) comparisions and then a hashtable lookup.

Basically, item types with no ability attached to them in the hashtable will logically not result in false. Thus you could replace the entire codition with a O(1) hashtable lookup unless you use the hashtable for attaching other properties to different items.

additionally, StringHash("ability") could be made a constant for more efficency.
 
Status
Not open for further replies.
Top