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

Trigger of Custom Hero Survival

Level 3
Joined
Jan 7, 2023
Messages
12
Hello guy.
I'm making a map with the idea of buying Skills like the Custom Hero Survival map.
Can you guide me to create a trigger that limits each Hero to only be able to buy a maximum of 7 Skills-types like the Custom Hero Survival map.
I only know how to buy Skills in the shop but don't know how to limit them so 1 Hero can buy a lot of Passive Skills.

Thanks guy.
 

Uncle

Warcraft Moderator
Level 67
Joined
Aug 10, 2018
Messages
6,906
It sounds like you want to use variables to keep track of how many Skills the Hero has. This can be done in many ways. You can attach data to Units, which is useful if you want things to work for every single Unit. OR, you can attach data to Players, which is easier but more limited since it may not work for multiple Units at once. Which of these methods you use depends on how your map works and the situation at hand.

I'm going to assume that your map only has ONE hero per Player. If this is true, then we're in luck because we can use the easier Player method.

So let's use Player Indexing, a method where you use a Player's player number as the [index] in an Array variable.

Step 1:
Create a new Integer variable. Check the Array box to turn it into an Array. Name it something related like Hero_Skill_Count.

Step 2:
Create a new Integer variable. This is NOT an Array. Name it Hero_PN which will be short for Player Number.

Step 3:
Find your trigger which runs when a Hero buys a Skill. In this trigger, track Hero_Skill_Count and prevent the Actions from running once it reaches it's limit:
  • Actions
    • Set Variable Hero_PN = (Player number of (Owner of (Triggering unit)))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Hero_Skill_Count[Hero_PN] Equal to 7
      • Then - Actions
        • Skip remaining actions
      • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Level of Your_Ability for (Triggering unit)) Equal to 0
      • Then - Actions
        • Set Variable Hero_Skill_Count[Hero_PN] = (Hero_Skill_Count[Hero_PN] + 1)
      • Else - Actions
That's the basic idea, I'd have to know how your triggers work exactly to give you a better example.

So if the Player's Hero_Skill_Count is already Equal to 7 then we should Skip the rest of the trigger. You can also refund the gold/lumber before skipping if you want. Then if the Ability we're going to Add to the Hero is Equal to 0 we know that it doesn't have this Ability yet so it's a NEW ability and we can increase Hero_Skill_Count by 1. This way we're tracking whenever a NEW ability is learned.

You would put these Actions at the start of your Buy Skill trigger.
 
Level 3
Joined
Jan 7, 2023
Messages
12
It sounds like you want to use variables to keep track of how many Skills the Hero has. This can be done in many ways. You can attach data to Units, which is useful if you want things to work for every single Unit. OR, you can attach data to Players, which is easier but more limited since it may not work for multiple Units at once. Which of these methods you use depends on how your map works and the situation at hand.

I'm going to assume that your map only has ONE hero per Player. If this is true, then we're in luck because we can use the easier Player method.

So let's use Player Indexing, a method where you use a Player's player number as the [index] in an Array variable.

Step 1:
Create a new Integer variable. Check the Array box to turn it into an Array. Name it something related like Hero_Skill_Count.

Step 2:
Create a new Integer variable. This is NOT an Array. Name it Hero_PN which will be short for Player Number.

Step 3:
Find your trigger which runs when a Hero buys a Skill. In this trigger, track Hero_Skill_Count and prevent the Actions from running once it reaches it's limit:
  • Actions
    • Set Variable Hero_PN = (Player number of (Owner of (Triggering unit)))
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Hero_Skill_Count[Hero_PN] Equal to 7
      • Then - Actions
        • Skip remaining actions
      • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Level of Your_Ability for (Triggering unit)) Equal to 0
      • Then - Actions
        • Set Variable Hero_Skill_Count[Hero_PN] = (Hero_Skill_Count[Hero_PN] + 1)
      • Else - Actions
That's the basic idea, I'd have to know how your triggers work exactly to give you a better example.

So if the Player's Hero_Skill_Count is already Equal to 7 then we should Skip the rest of the trigger. You can also refund the gold/lumber before skipping if you want. Then if the Ability we're going to Add to the Hero is Equal to 0 we know that it doesn't have this Ability yet so it's a NEW ability and we can increase Hero_Skill_Count by 1. This way we're tracking whenever a NEW ability is learned.

You would put these Actions at the start of your Buy Skill trigger.
Thank you so much
 
Level 3
Joined
Jan 7, 2023
Messages
12
hello @Uncle
Sorry, i'm noob.
I don't understand this:
if.gif
(Level of Your_Ability for (Triggering unit)) Equal to 0
_Your_Ability = skill ( Varible Ability code [Array] )
_So what should I do with the red area?
if.gif
(Level of skill [Index] for (Triggering unit)) Equal to 0

Explain: I created quite a few triggers as shown. Each ability is a trigger.
 

Attachments

  • Untitled.png
    Untitled.png
    184.4 KB · Views: 8
  • Untitledaaa.png
    Untitledaaa.png
    127.8 KB · Views: 11

Uncle

Warcraft Moderator
Level 67
Joined
Aug 10, 2018
Messages
6,906

Hey, so I figured I'd show you how to do this in a really smart and efficient way. The attached map has an item skill system that makes it so you only need one trigger for all of your different abilities. I take advantage of a Hashtable and some variables to store all of the data about the Items and their Abilities including important information like: Ability max level, Item gold cost, and Item lumber cost.

Here's the only trigger that you NEED to customize yourself:
  • ISS Configure
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --------
      • -------- WARNING: Don't change these few Actions: --------
      • Hashtable - Create a hashtable
      • Set VariableSet ISS_Hashtable = (Last created hashtable)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) controller) Equal to User
            • Then - Actions
              • Player Group - Add (Picked player) to ISS_Player_Group[(Player number of (Picked player))]
            • Else - Actions
      • -------- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --------
      • -------- --------
      • -------- Now you need to add all of your Items/Abilities to the Item Skill System: --------
      • -------- Note: If Gold or Lumber is equal to 0 then you don't have to Set it's variable. --------
      • -------- --------
      • -------- First item... --------
      • Set VariableSet ISS_Item_Type = Endurance Aura
      • Set VariableSet ISS_Item_Ability = Endurance Aura (ISS - Ability)
      • Set VariableSet ISS_Item_Gold_Cost = 50
      • Set VariableSet ISS_Item_Lumber_Cost = 50
      • Set VariableSet ISS_Item_Ability_Max_Level = 5
      • Trigger - Run ISS Add Item To System <gen> (ignoring conditions)
      • -------- --------
      • -------- Next item... --------
      • Set VariableSet ISS_Item_Type = Flame Strike
      • Set VariableSet ISS_Item_Ability = Flame Strike (ISS - Ability)
      • Set VariableSet ISS_Item_Lumber_Cost = 100
      • Set VariableSet ISS_Item_Ability_Max_Level = 5
      • Trigger - Run ISS Add Item To System <gen> (ignoring conditions)
      • -------- --------
      • -------- Next item... --------
Follow my examples for Endurance Aura and Flame Strike and add all of your different Items/Abilities to the system this way. Don't mess with the Actions in the !!! WARNING !!! section. You can delete my two example Items and replace them with your own.

You may also want to customize the Text Messages in the ISS Buy Item trigger:
  • Game - Display to ISS_Player_Group[ISS_PN] for 5.00 seconds the text: You can only have u...
  • Game - Display to ISS_Player_Group[ISS_PN] for 5.00 seconds the text: This ability is alr...
There's also a Special Effect that you can customize or delete:
  • Special Effect - Create a special effect attached to the origin of ISS_Hero using Abilities\Spells\Items\AIlm\AIlmTarget.mdl
This system uses my suggested Hero_Skill_Limit stuff so you don't have to worry about that.
 

Attachments

  • Item Skill System 1.w3m
    23.5 KB · Views: 3
Last edited:
Level 3
Joined
Jan 7, 2023
Messages
12

Hey, so I figured I'd show you how to do this in a really smart and efficient way. The attached map has an item skill system that makes it so you only need one trigger for all of your different abilities. I take advantage of a Hashtable and some variables to store all of the data about the Items and their Abilities including important information like: Ability max level, Item gold cost, and Item lumber cost.

Here's the only trigger that you NEED to customize yourself:
  • ISS Configure
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --------
      • -------- WARNING: Don't change these few Actions: --------
      • Hashtable - Create a hashtable
      • Set VariableSet ISS_Hashtable = (Last created hashtable)
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) controller) Equal to User
            • Then - Actions
              • Player Group - Add (Picked player) to ISS_Player_Group[(Player number of (Picked player))]
            • Else - Actions
      • -------- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --------
      • -------- --------
      • -------- Now you need to add all of your Items/Abilities to the Item Skill System: --------
      • -------- Note: If Gold or Lumber is equal to 0 then you don't have to Set it's variable. --------
      • -------- --------
      • -------- First item... --------
      • Set VariableSet ISS_Item_Type = Endurance Aura
      • Set VariableSet ISS_Item_Ability = Endurance Aura (ISS - Ability)
      • Set VariableSet ISS_Item_Gold_Cost = 50
      • Set VariableSet ISS_Item_Lumber_Cost = 50
      • Set VariableSet ISS_Item_Ability_Max_Level = 5
      • Trigger - Run ISS Add Item To System <gen> (ignoring conditions)
      • -------- --------
      • -------- Next item... --------
      • Set VariableSet ISS_Item_Type = Flame Strike
      • Set VariableSet ISS_Item_Ability = Flame Strike (ISS - Ability)
      • Set VariableSet ISS_Item_Lumber_Cost = 100
      • Set VariableSet ISS_Item_Ability_Max_Level = 5
      • Trigger - Run ISS Add Item To System <gen> (ignoring conditions)
      • -------- --------
      • -------- Next item... --------
Follow my examples for Endurance Aura and Flame Strike and add all of your different Items/Abilities to the system this way. Don't mess with the Actions in the !!! WARNING !!! section. You can delete my two example Items and replace them with your own.

You may also want to customize the Text Messages in the ISS Buy Item trigger:
  • Game - Display to ISS_Player_Group[ISS_PN] for 5.00 seconds the text: You can only have u...
  • Game - Display to ISS_Player_Group[ISS_PN] for 5.00 seconds the text: This ability is alr...
There's also a Special Effect that you can customize or delete:
  • Special Effect - Create a special effect attached to the origin of ISS_Hero using Abilities\Spells\Items\AIlm\AIlmTarget.mdl
This system uses my suggested Hero_Skill_Limit stuff so you don't have to worry about that.
Thank you. I'm learning about it.
It seems to be starting to be difficult for me.
 

Uncle

Warcraft Moderator
Level 67
Joined
Aug 10, 2018
Messages
6,906
Thank you. I'm learning about it.
It seems to be starting to be difficult for me.
It's definitely a more advanced design.

It should be very easy to use it though. All you have to do is Add your Items/Abilities to the ISS Configure trigger:
  • -------- Next item... --------
  • Set VariableSet ISS_Item_Type = Blizzard
  • Set VariableSet ISS_Item_Ability = Blizzard (ISS - Ability)
  • Set VariableSet ISS_Item_Lumber_Cost = 250
  • Set VariableSet ISS_Item_Ability_Max_Level = 5
  • Trigger - Run ISS Add Item To System <gen> (ignoring conditions)
  • -------- --------
  • -------- Next item... --------
Just copy and paste these few Actions and change their values to work for your own Items/Abilities.

The system will do the rest for you. You don't have to look at or touch the other triggers.
 
Last edited:
Level 3
Joined
Jan 7, 2023
Messages
12
It's definitely a more advanced design.

It should be very easy to use it though. All you have to do is Add your Items/Abilities to the ISS Configure trigger:
  • -------- Next item... --------
  • Set VariableSet ISS_Item_Type = Blizzard
  • Set VariableSet ISS_Item_Ability = Blizzard (ISS - Ability)
  • Set VariableSet ISS_Item_Lumber_Cost = 250
  • Set VariableSet ISS_Item_Ability_Max_Level = 5
  • Trigger - Run ISS Add Item To System <gen> (ignoring conditions)
  • -------- --------
  • -------- Next item... --------
Just copy and paste the variables and change their values to whatever you want.

The system will do the rest for you. You don't have to look at or touch the other triggers.
I mean I don't think there are many problems that arise when doing BUY ABILITIES

Here: When Hero has 7 different ABILITIES at Level 1. Hero will not be able to buy old ABILITIES to level 2.
 

Uncle

Warcraft Moderator
Level 67
Joined
Aug 10, 2018
Messages
6,906
I mean I don't think there are many problems that arise when doing BUY ABILITIES

Here: When Hero has 7 different ABILITIES at Level 1. Hero will not be able to buy old ABILITIES to level 2.
Good catch, I didn't test it enough to find that bug.

I fixed it:
  • ISS Buy Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Item being manipulated) is A powerup.) Equal to True
    • Actions
      • -------- Set the ISS variables for this item: --------
      • Set VariableSet ISS_Item = (Item being manipulated)
      • Trigger - Run ISS Get Item From System <gen> (ignoring conditions)
      • -------- --------
      • -------- If Max_Level is 0 then we know that this Item isn't used by the ISS System: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ISS_Item_Ability_Max_Level Equal to 0
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • -------- If we've made it this far then we know it's an ISS Item. --------
      • -------- --------
      • Set VariableSet ISS_Hero = (Triggering unit)
      • Set VariableSet ISS_Player = (Owner of ISS_Hero)
      • Set VariableSet ISS_PN = (Player number of ISS_Player)
      • Set VariableSet ISS_Ability_Current_Level = (Level of ISS_Item_Ability for ISS_Hero)
      • -------- --------
      • -------- Let's check the level of the ability: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ISS_Ability_Current_Level Greater than or equal to ISS_Item_Ability_Max_Level
        • Then - Actions
          • -------- Refund: --------
          • Player - Add ISS_Item_Gold_Cost to ISS_Player.Current gold
          • Player - Add ISS_Item_Lumber_Cost to ISS_Player.Current lumber
          • Game - Display to ISS_Player_Group[ISS_PN] for 5.00 seconds the text: This ability is alr...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • -------- Increase or Add the ability: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ISS_Ability_Current_Level Greater than 0
        • Then - Actions
          • Unit - Increase level of ISS_Item_Ability for ISS_Hero
        • Else - Actions
          • -------- Let's check if they're at the ability limit: --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ISS_Ability_Count[ISS_PN] Greater than or equal to 7
            • Then - Actions
              • -------- Refund: --------
              • Player - Add ISS_Item_Gold_Cost to ISS_Player.Current gold
              • Player - Add ISS_Item_Lumber_Cost to ISS_Player.Current lumber
              • Game - Display to ISS_Player_Group[ISS_PN] for 5.00 seconds the text: You can only have u...
              • Skip remaining actions
            • Else - Actions
          • -------- --------
          • Unit - Add ISS_Item_Ability to ISS_Hero
          • Set VariableSet ISS_Ability_Count[ISS_PN] = (ISS_Ability_Count[ISS_PN] + 1)
      • -------- --------
      • -------- Optional special effect: --------
      • Special Effect - Create a special effect attached to the origin of ISS_Hero using Abilities\Spells\Items\AIlm\AIlmTarget.mdl
      • Special Effect - Destroy (Last created special effect)
All you have to do is update the ISS Buy Item trigger to this new design.
 

Attachments

  • Item Skill System 2.w3m
    23.5 KB · Views: 5
Level 3
Joined
Jan 7, 2023
Messages
12
Good catch, I didn't test it enough to find that bug.

I fixed it:
  • ISS Buy Item
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • ((Item being manipulated) is A powerup.) Equal to True
    • Actions
      • -------- Set the ISS variables for this item: --------
      • Set VariableSet ISS_Item = (Item being manipulated)
      • Trigger - Run ISS Get Item From System <gen> (ignoring conditions)
      • -------- --------
      • -------- If Max_Level is 0 then we know that this Item isn't used by the ISS System: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ISS_Item_Ability_Max_Level Equal to 0
        • Then - Actions
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • -------- If we've made it this far then we know it's an ISS Item. --------
      • -------- --------
      • Set VariableSet ISS_Hero = (Triggering unit)
      • Set VariableSet ISS_Player = (Owner of ISS_Hero)
      • Set VariableSet ISS_PN = (Player number of ISS_Player)
      • Set VariableSet ISS_Ability_Current_Level = (Level of ISS_Item_Ability for ISS_Hero)
      • -------- --------
      • -------- Let's check the level of the ability: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ISS_Ability_Current_Level Greater than or equal to ISS_Item_Ability_Max_Level
        • Then - Actions
          • -------- Refund: --------
          • Player - Add ISS_Item_Gold_Cost to ISS_Player.Current gold
          • Player - Add ISS_Item_Lumber_Cost to ISS_Player.Current lumber
          • Game - Display to ISS_Player_Group[ISS_PN] for 5.00 seconds the text: This ability is alr...
          • Skip remaining actions
        • Else - Actions
      • -------- --------
      • -------- Increase or Add the ability: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ISS_Ability_Current_Level Greater than 0
        • Then - Actions
          • Unit - Increase level of ISS_Item_Ability for ISS_Hero
        • Else - Actions
          • -------- Let's check if they're at the ability limit: --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ISS_Ability_Count[ISS_PN] Greater than or equal to 7
            • Then - Actions
              • -------- Refund: --------
              • Player - Add ISS_Item_Gold_Cost to ISS_Player.Current gold
              • Player - Add ISS_Item_Lumber_Cost to ISS_Player.Current lumber
              • Game - Display to ISS_Player_Group[ISS_PN] for 5.00 seconds the text: You can only have u...
              • Skip remaining actions
            • Else - Actions
          • -------- --------
          • Unit - Add ISS_Item_Ability to ISS_Hero
          • Set VariableSet ISS_Ability_Count[ISS_PN] = (ISS_Ability_Count[ISS_PN] + 1)
      • -------- --------
      • -------- Optional special effect: --------
      • Special Effect - Create a special effect attached to the origin of ISS_Hero using Abilities\Spells\Items\AIlm\AIlmTarget.mdl
      • Special Effect - Destroy (Last created special effect)
All you have to do is update the ISS Buy Item trigger to this new design.
Wow, my difficult problems are easy for you.

Thank you.

I don't know about IT, I often have difficulty with Real and Integer triggers.
I have to learn more about it.
 
Top