How do I shorten this and make it more implementable

XxShadyxX

I abused the rep system.
Reaction score
81
This is from my weapon wielding system and I want to make it more efficient and shorter and easier to implement. Can anyone tell me what to do instead of what im doing now to make the code more shorter and easier to implement.
Thank you and +rep of course

Trigger:
  • Map Int
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Armor Unequip <gen> the event (Player - (Picked player) types a chat message containing -unequip armor as An exact match)

Map int. Must have!!

Armor Equip

Trigger:
  • Armor Equip
    • Events
      • Unit - A unit Uses an item
    • Conditions
    • Actions
      • -------- Begginers Armor --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff00ffffArmor|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
            • Else - Actions
              • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
              • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
              • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
              • Game - Display to (All players) the text: ((Name of (Item being manipulated)) + has been equiped.)
              • Item - Remove (Item being manipulated)
        • Else - Actions
      • -------- Leather Armor --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff008000Armor|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
            • Else - Actions
              • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
              • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
              • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
              • Unit - Add Item Armor Bonus (+1) to (Triggering unit)
              • Set Armor_Ability1[(Player number of (Owner of (Triggering unit)))] = Item Armor Bonus (+1)
              • Game - Display to (Player group((Owner of (Triggering unit)))) the text: ((Name of (Item being manipulated)) + has been equiped.)
              • Item - Remove (Item being manipulated)
        • Else - Actions
      • -------- Bronze Armor --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff008000Armor|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of (Triggering unit)) Less than or equal to 3
                • Then - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You Do not meet the...
                • Else - Actions
                  • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
                  • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
                  • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
                  • Unit - Add Item Armor Bonus (+2) to (Triggering unit)
                  • Set Armor_Ability1[(Player number of (Owner of (Triggering unit)))] = Item Armor Bonus (+2)
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: ((Name of (Item being manipulated)) + has been equiped.)
                  • Item - Remove (Item being manipulated)
        • Else - Actions
      • -------- Iron Armor --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff008000Armor|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of (Triggering unit)) Less than or equal to 4
                • Then - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You Do not meet the...
                • Else - Actions
                  • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
                  • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
                  • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
                  • Unit - Add Item Armor Bonus (+3) to (Triggering unit)
                  • Set Armor_Ability1[(Player number of (Owner of (Triggering unit)))] = Item Armor Bonus (+3)
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: ((Name of (Item being manipulated)) + has been equiped.)
                  • Item - Remove (Item being manipulated)
        • Else - Actions
      • -------- Steel Armor --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff008000Armor|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of (Triggering unit)) Less than or equal to 4
                • Then - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You Do not meet the...
                • Else - Actions
                  • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
                  • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
                  • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
                  • Unit - Add Item Armor Bonus (+5) to (Triggering unit)
                  • Set Armor_Ability1[(Player number of (Owner of (Triggering unit)))] = Item Armor Bonus (+5)
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: ((Name of (Item being manipulated)) + has been equiped.)
                  • Item - Remove (Item being manipulated)
        • Else - Actions
      • -------- Dark Armor --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff008000Armor|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of (Triggering unit)) Less than or equal to 4
                • Then - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You Do not meet the...
                • Else - Actions
                  • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
                  • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
                  • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
                  • Unit - Add Item Armor Bonus (+6) to (Triggering unit)
                  • Set Armor_Ability1[(Player number of (Owner of (Triggering unit)))] = Item Armor Bonus (+6)
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: ((Name of (Item being manipulated)) + has been equiped.)
                  • Item - Remove (Item being manipulated)
        • Else - Actions
      • -------- Half Plate Armor --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff008000Armor|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of (Triggering unit)) Less than or equal to 5
                • Then - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You Do not meet the...
                • Else - Actions
                  • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
                  • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
                  • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
                  • Unit - Add Item Armor Bonus (+7) to (Triggering unit)
                  • Set Armor_Ability1[(Player number of (Owner of (Triggering unit)))] = Item Armor Bonus (+7)
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: ((Name of (Item being manipulated)) + has been equiped.)
                  • Item - Remove (Item being manipulated)
        • Else - Actions
      • -------- Plate --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff008000Armor|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of (Triggering unit)) Less than or equal to 5
                • Then - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You Do not meet the...
                • Else - Actions
                  • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
                  • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
                  • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
                  • Unit - Add Item Armor Bonus (+8) to (Triggering unit)
                  • Set Armor_Ability1[(Player number of (Owner of (Triggering unit)))] = Item Armor Bonus (+8)
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: ((Name of (Item being manipulated)) + has been equiped.)
                  • Item - Remove (Item being manipulated)
        • Else - Actions
      • -------- Double Plate --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff008000Armor|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of (Triggering unit)) Less than or equal to 8
                • Then - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You Do not meet the...
                • Else - Actions
                  • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
                  • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
                  • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
                  • Unit - Add Item Armor Bonus (+9) to (Triggering unit)
                  • Set Armor_Ability1[(Player number of (Owner of (Triggering unit)))] = Item Armor Bonus (+9)
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: ((Name of (Item being manipulated)) + has been equiped.)
                  • Item - Remove (Item being manipulated)
        • Else - Actions
      • -------- Gold Armor --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cff008000Armor|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of (Triggering unit)) Less than or equal to 9
                • Then - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You Do not meet the...
                • Else - Actions
                  • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
                  • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
                  • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
                  • Unit - Add Item Armor Bonus (+10) to (Triggering unit)
                  • Set Armor_Ability1[(Player number of (Owner of (Triggering unit)))] = Item Armor Bonus (+10)
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: ((Name of (Item being manipulated)) + has been equiped.)
                  • Item - Remove (Item being manipulated)
        • Else - Actions
      • -------- Bone Armor --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Item being manipulated)) Equal to |cffff80ffArmor|r
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of (Triggering unit)) Less than or equal to 11
                • Then - Actions
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You Do not meet the...
                • Else - Actions
                  • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
                  • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
                  • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
                  • Unit - Add Item Armor Bonus (+12) to (Triggering unit)
                  • Set Armor_Ability1[(Player number of (Owner of (Triggering unit)))] = Item Armor Bonus (+12)
                  • Game - Display to (Player group((Owner of (Triggering unit)))) the text: ((Name of (Item being manipulated)) + has been equiped.)
                  • Item - Remove (Item being manipulated)
        • Else - Actions

Trigger:
  • Armor Unequip
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Wielding_Armor[(Player number of (Triggering player))] Equal to True
        • Then - Actions
          • Set Wielding_Armor[(Player number of (Triggering player))] = False
          • Hero - Create Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] and give it to Equiping_Unit[(Player number of (Triggering player))]
          • Game - Display to (All players) the text: You have unequiped ...
          • Unit - Remove Armor_Ability[(Player number of (Triggering player))] from Equiping_Unit[(Player number of (Triggering player))]
        • Else - Actions
          • Game - Display to (Player group((Triggering player))) the text: You are not wearing...
 

Exide

I am amazingly focused right now!
Reaction score
448
The bad thing is that most of the items don't use the same condition. (For example, it would be easy if everyone had a Level condition (with different level, of course.))

You could set each item's hp to 'Level requirement' (If level requirement = 5 - set that item's hp to 5) in the Object Editor.

You could also use different Classifications, i.e Artifact = Armor, Permanent = Weapon, Campaign = Shield, and so on..
(Example: http://www.thehelper.net/forums/showthread.php?p=981266#post981266)

These things will help you optimize your code.
 

XxShadyxX

I abused the rep system.
Reaction score
81
Thank you about the level requirment thing. but i don't think that will make a huge difference
Is there anyway that I can make this into a loop?
 

XxShadyxX

I abused the rep system.
Reaction score
81
Ugh,
How Do I Shorten This Code And Make It Easier Implement Into A Map And Make More Items And Not Have to Make A Super Long Code For Each Item. This Code Would Be A Pain If I have 100 Items. So I Need To Make It More Short!
 

Defi4nc3

Developer of DORPG
Reaction score
20
Read my post.

You won't have to make another Trigger for each item. You just add the item to the Condition. Nothing more.

You need to have more control of your system, by using more variables.

As it stands now... For each item you add your gonna have to adjust a lot of code to add stats... Where as I adjust like 2 variables...

Your making a HERO INVENTORY SYSTEM so no matter what its gonna get pretty big, your not gonna be able to squish this all into one trigger unless you want it to look like crap.
 

Drakethos

Preordered Sc2 ftw!
Reaction score
56
you could probally make a trigger with just variable declarations of each item. So ie:
Trigger:
  • set armor[1] = Leather Armor
    • Set armor[2] = Beginers armor.

then action:
Trigger:
  • loop 1 to 10
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Item-type of (Item being manipulated)) Equal to armor[a]
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Wielding_Armor[(Player number of (Owner of (Triggering unit)))] Equal to True
            • Then - Actions
              • Game - Display to (All players) the text: You are already wea...
              • Hero - Create (Item-type of (Item being manipulated)) and give it to (Triggering unit)
              • Item - Remove (Item being manipulated)
              • Else - Actions
                • Set Equiping_Unit[(Player number of (Owner of (Triggering unit)))] = (Hero manipulating item)
                  • Set Wielding_Armor[(Player number of (Owner of (Triggering unit)))] = True
                  • Set Item_Type_Armor[(Player number of (Owner of (Triggering unit)))] = (Item-type of (Item being manipulated))
                • Game - Display to (All players) the text: ((Name of (Item being manipulated)) + has been equiped.)
                • Item - Remove (Item being manipulated)
        • Else - Actions
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top