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

[Trigger] Unit Group Problem maybe?

Status
Not open for further replies.
Level 6
Joined
Jul 23, 2018
Messages
243
Hello everyone,

Thank you for reading this thread and helping me with my problems for the past few months and today. I made 2 triggers, one for adding units taking damage to the group when the damage source carries Deathblade. The second trigger adds damage to the item carrier when the units taking damage in the group die. However, the unit group didn't have any unit at all. Can anyone please explain why? I'm currently using Bribe's GUI Unit Event v2.5.2.0 and Damage Engine 3A.0.0.0 and 3.8.0.0
  • Deathblade Buff
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource has an item of type Deathblade) Equal to True
    • Actions
      • -------- This trigger is for identifying the enemy who has taken damage from the damage source --------
      • Set CV = (Custom value of DamageEventSource)
      • -------- The unit group array is for adding who takes damage to the group for each item carrier --------
      • Unit Group - Add DamageEventTarget to DeathBladeGroup[CV]
      • -------- This buff is for iddentifying who takes damage --------
      • Unit - Add Deathblade (Buff) to DamageEventTarget
      • Game - Display to (All players) the text: (Number of units in Deathblade group is + (String((Number of units in DeathBladeGroup[CV]))))
  • Deathblade Gain
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Level of Deathblade (Buff) for (Dying unit)) Equal to 0
    • Actions
      • Set CV = (Custom value of (Killing unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) is in DeathBladeGroup[CV]) Equal to True
        • Then - Actions
          • Item - Set charges remaining in (Item carried by (Killing unit) of type Deathblade) to ((Charges remaining in (Item carried by (Killing unit) of type Deathblade)) + 20)
          • Game - Display to (All players) the text: (Give 20 more attack damage to + (Name of (Killing unit)))
          • Unit Group - Remove (Dying unit) from DeathBladeGroup[CV]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in DeathBladeGroup[CV]) Equal to 0
            • Then - Actions
              • Custom script: call DestroyGroup(udg_DeathBladeGroup[udg_CV])
            • Else - Actions
        • Else - Actions
          • Game - Display to (All players) the text: fail
I did some research around Hive Workshop and found out unit group array with " size 1" default will cause problems. However, the way for fixing is by using jass and I do quite poorly with jass, so I posted this thread for help. All helps are appreciate.
 
Last edited:
Level 24
Joined
Jun 26, 2020
Messages
1,852
You must create the group when the hero carries that item, but you have to create another group for the carries to not overwrite it, like this:
  • Trigger 1
    • Events
      • Unit - A unit adquires an item
    • Conditions
      • (Item of type (Item being manipulated)) Equal to Deathblade
      • ((Triggering unit) is in "Your group") Equal to False
    • Actions
      • Custom script: set udg_DeathBladeGroup[GetUnitUserData(GetTriggerUnit())]=CreateGroup()
      • Unit Group - Add (Triggering unit) to "Your group"
And not destroying it when the unit group is empty, just when the carry disapear:
  • Trigger 2
    • Events
      • Game - UnitIndexEvent becomes Equal to 2.00
    • Conditions
      • (UDexUnits[UDex] is in "Your group") Equal to True
    • Actions
      • Custom script: call DestroyGroup(udg_DeathBladeGroup[udg_UDex])
      • Unit Group - Remove UDexUnits[UDex] from "Your group"
 
Level 6
Joined
Jul 23, 2018
Messages
243
You must create the group when the hero carries that item, but you have to create another group for the carries to not overwrite it, like this:
  • Trigger 1
    • Events
      • Unit - A unit adquires an item
    • Conditions
      • (Item of type (Item being manipulated)) Equal to Deathblade
      • ((Triggering unit) is in "Your group") Equal to False
    • Actions
      • Custom script: set udg_DeathBladeGroup[GetUnitUserData(GetTriggerUnit())]=CreateGroup()
      • Unit Group - Add (Triggering unit) to "Your group"
And not destroying it when the unit group is empty, just when the carry disapear:
  • Trigger 2
    • Events
      • Game - UnitIndexEvent becomes Equal to 2.00
    • Conditions
      • (UDexUnits[UDex] is in "Your group") Equal to True
    • Actions
      • Custom script: call DestroyGroup(udg_DeathBladeGroup[udg_UDex])
      • Unit Group - Remove UDexUnits[UDex] from "Your group"
The units that are added to DeathBladeGroup are not the item carriers, but the units take damage from those item carriers. When they die from being killed by either which unit, not necessarily the item carrier, the item carrier gain bonus damage. I used unit group array to identify which unit has taken damage from which item carrier
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
The units that are added to DeathBladeGroup are not the item carriers, but the units take damage from those item carriers. When they die from being killed by either which unit, not necessarily the item carrier, the item carrier gain bonus damage. I used unit group array to identify which unit has taken damage from which item carrier
I didn't say that, I said you must create ANOTHER group to the carries to not overwrite the groups, because imagine when the carry leaves the item and then pick it again and the first trigger fires again and overwrite the current group with another new group.
 
Level 6
Joined
Jul 23, 2018
Messages
243
Can you show all the triggers?
These are all the triggers I got. Two of them are yours I just added in.
  • Deathblade Carry
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Deathblade
      • ((Triggering unit) is in DeathBladeGroup[(Custom value of (Triggering unit))]) Equal to False
    • Actions
      • Custom script: set udg_DeathBladeGroup[GetUnitUserData(GetTriggerUnit())]=CreateGroup()
      • Unit Group - Add (Triggering unit) to DeathBladeGroup[(Custom value of (Triggering unit))]
  • Deathblade Buff
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource has an item of type Deathblade) Equal to True
    • Actions
      • -------- This trigger is for identifying the enemy who has taken damage from the damage source --------
      • Set CV = (Custom value of DamageEventSource)
      • -------- The unit group array is for adding who takes damage to the group for each item carrier --------
      • Unit Group - Add DamageEventTarget to DeathBladeGroup[CV]
      • -------- This buff is for iddentifying who takes damage --------
      • Unit - Add Deathblade (Buff) to DamageEventTarget
      • Game - Display to (All players) the text: (Number of units in Deathblade group is + (String((Number of units in DeathBladeGroup[CV]))))
  • Deathblade Gain
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Level of Deathblade (Buff) for (Dying unit)) Greater than 0
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) is in DeathBladeGroup[(Custom value of (Killing unit))]) Equal to True
        • Then - Actions
          • Item - Set charges remaining in (Item carried by (Killing unit) of type Deathblade) to ((Charges remaining in (Item carried by (Killing unit) of type Deathblade)) + 20)
          • Game - Display to (All players) the text: (Give 20 more attack damage to + (Name of (Killing unit)))
          • Unit Group - Remove (Dying unit) from DeathBladeGroup[(Custom value of (Killing unit))]
        • Else - Actions
          • Game - Display to (All players) the text: fail
  • Deathblade Gone
    • Events
      • Game - UnitIndexEvent becomes Equal to 2.00
    • Conditions
      • (UDexUnits[UDex] is in DeathBladeGroup[UDex]) Equal to True
    • Actions
      • Custom script: call DestroyGroup(udg_DeathBladeGroup[udg_UDex])
      • Unit Group - Remove UDexUnits[UDex] from DeathBladeGroup[UDex]
I found it hard to add damage bonus to item carrier when unit is killed by another damage source instead of the item carrier that deal damage to the unit before it is killed by another source
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
These are all the triggers I got. Two of them are yours I just added in.
  • Deathblade Carry
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Deathblade
      • ((Triggering unit) is in DeathBladeGroup[(Custom value of (Triggering unit))]) Equal to False
    • Actions
      • Custom script: set udg_DeathBladeGroup[GetUnitUserData(GetTriggerUnit())]=CreateGroup()
      • Unit Group - Add (Triggering unit) to DeathBladeGroup[(Custom value of (Triggering unit))]
  • Deathblade Buff
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource has an item of type Deathblade) Equal to True
    • Actions
      • -------- This trigger is for identifying the enemy who has taken damage from the damage source --------
      • Set CV = (Custom value of DamageEventSource)
      • -------- The unit group array is for adding who takes damage to the group for each item carrier --------
      • Unit Group - Add DamageEventTarget to DeathBladeGroup[CV]
      • -------- This buff is for iddentifying who takes damage --------
      • Unit - Add Deathblade (Buff) to DamageEventTarget
      • Game - Display to (All players) the text: (Number of units in Deathblade group is + (String((Number of units in DeathBladeGroup[CV]))))
  • Deathblade Gain
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Level of Deathblade (Buff) for (Dying unit)) Greater than 0
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Dying unit) is in DeathBladeGroup[(Custom value of (Killing unit))]) Equal to True
        • Then - Actions
          • Item - Set charges remaining in (Item carried by (Killing unit) of type Deathblade) to ((Charges remaining in (Item carried by (Killing unit) of type Deathblade)) + 20)
          • Game - Display to (All players) the text: (Give 20 more attack damage to + (Name of (Killing unit)))
          • Unit Group - Remove (Dying unit) from DeathBladeGroup[(Custom value of (Killing unit))]
        • Else - Actions
          • Game - Display to (All players) the text: fail
  • Deathblade Gone
    • Events
      • Game - UnitIndexEvent becomes Equal to 2.00
    • Conditions
      • (UDexUnits[UDex] is in DeathBladeGroup[UDex]) Equal to True
    • Actions
      • Custom script: call DestroyGroup(udg_DeathBladeGroup[udg_UDex])
      • Unit Group - Remove UDexUnits[UDex] from DeathBladeGroup[UDex]
I found it hard to add damage bonus to item carrier when unit is killed by another damage source instead of the item carrier that deal damage to the unit before it is killed by another source
Ayayay
I didn't say that, I said you must create ANOTHER group to the carries to not overwrite the groups, because imagine when the carry leaves the item and then pick it again and the first trigger fires again and overwrite the current group with another new group.
Look my triggers again, you can see I am using "Your group" and "DeathBladeGroup[UDex]" in them at the same time, so you must understand when I said "Your group" I mean ANOTHER group than that you used.
 
Level 6
Joined
Jul 23, 2018
Messages
243
Sorry for the late response, but I think I'm trying to do is making an assist system, and I never made one before, but just simple triggers, but my intention is focusing on the one who has damaged the target and the target. I think what I'm struggling here is how do I refer to the unit group of the item carries. And I think I have found a way but it may create too many groups at a time. I'm not very used to advanced triggering.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
So if I understand correctly, when a unit equipped with Deathblade deals damage to a target, that target becomes "marked" until it dies. A unit can be marked by different owners of Deathblades, so a unit could be marked by Player 1's Deathblade AND Player 2's Deathblade. Furthermore, it doesn't need to be a different player, two different Heroes owned by Player 1 could mark the same unit. Finally, when a marked unit dies, all of the Deathblade owners that marked it gain +20 charges.

If that's the case, I believe all you would need to do is add the Owner of the Deathblade to a Unit Group that's linked to the Damaged unit's custom value. This way when the Damaged unit (marked unit) dies you can get access to all of the Deathblade units that damaged it.

For example:

A unit takes damage -> DamageSource has Deathblade = True -> Set cv = Custom value of DamageTarget -> If DBGroup[cv] doesn't exist yet then create it -> If DamageSource is in DBGroup[cv] = False -> Add DamageSource to DBGroup[cv]

A unit dies -> Set cv = Custom value of dying unit -> If DBGroup[cv] exists -> Pick every unit in DBGroup[cv] and Add 20 charges to their Deathblade -> Destroy DBGroup[cv]


Some important questions are still left though. How many Deathblades can a unit equip at a time? Can the Item be dropped? What happens if the Item is dropped? What happens if the Item carrier dies?


Also, here's a way of doing it without any Unit Groups:
  • DB Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set VariableSet DB_Hash = (Last created hashtable)
  • DB Damage Taken
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource has an item of type Deathblade) Equal to True
    • Actions
      • Custom script: set udg_DB_Source = udg_DamageEventSource
      • Custom script: set udg_DB_Target = udg_DamageEventTarget
      • Set VariableSet DB_IsInHash = False
      • Set VariableSet DB_Size = (Load 0 of (Key DB_Target.) from DB_Hash.)
      • -------- --------
      • For each (Integer DB_Loop) from 1 to DB_Size, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DamageEventSource Equal to (Load DB_Loop of (Key DB_Target.) in DB_Hash.)
              • DB_IsInHash Equal to False
            • Then - Actions
              • Set VariableSet DB_IsInHash = True
            • Else - Actions
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DB_IsInHash Equal to False
        • Then - Actions
          • Set VariableSet DB_Size = (DB_Size + 1)
          • Hashtable - Save DB_Size as 0 of (Key DB_Target.) in DB_Hash.
          • Hashtable - Save Handle OfDamageEventSource as DB_Size of (Key DB_Target.) in DB_Hash.
        • Else - Actions
  • DB Death
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set VariableSet DB_Source = (Triggering unit)
      • Set VariableSet DB_Size = (Load 0 of (Key DB_Source.) from DB_Hash.)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DB_Size Greater than 0
        • Then - Actions
          • For each (Integer DB_Loop) from 1 to DB_Size, do (Actions)
            • Loop - Actions
              • Set VariableSet DB_Carrier = (Load DB_Loop of (Key DB_Source.) in DB_Hash.)
              • Set VariableSet DB_Item = (Item carried by DB_Carrier of type Deathblade)
              • Set VariableSet DB_Charges = ((Charges remaining in DB_Item) + 20)
              • Item - Set charges remaining in DB_Item to DB_Charges
          • Hashtable - Clear all child hashtables of child (Key DB_Source.) in DB_Hash.
        • Else - Actions
Variables:
DB_Hash = Hashtable
DB_Loop = Integer
DB_Size = Integer
DB_Charges = Integer
DB_Carrier = Unit
DB_Source = Handle
DB_Target = Handle
DB_Item = Item
DB_IsInHash = Boolean
Attached map requires the latest patch to open!
 

Attachments

  • Deathblade Example.w3m
    58.1 KB · Views: 15
Last edited:
Level 6
Joined
Jul 23, 2018
Messages
243
Some important questions are still left though. How many Deathblades can a unit equip at a time? Can the Item be dropped? What happens if the Item is dropped? What happens if the Item carrier dies?
- Units can carry 3 Deathblade items at most
- Item can be dropped
- If drop, the charge will reset
- When the carrier dies, the item stays and the charge remains with the carrier

By the way, I never thought of using hashtable. I only know they work like Unit Indexer
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Did you get it working with my example? I don't think the Hashtable method is necessary if the Unit Group one works.

Here are the actual triggers:
  • DB Damage Taken unit group
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource has an item of type Deathblade) Equal to True
    • Actions
      • Set VariableSet cv = (Custom value of DamageEventTarget)
      • Custom script: if udg_DB_Group[udg_cv] == null then
      • Custom script: set udg_DB_Group[udg_cv] = CreateGroup()
      • Custom script: endif
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DamageEventSource is in DB_Group[cv].) Equal to False
        • Then - Actions
          • Unit Group - Add DamageEventSource to DB_Group[cv]
        • Else - Actions
  • DB Death unit group
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set VariableSet cv = (Custom value of (Triggering unit))
      • Custom script: if udg_DB_Group[udg_cv] != null then
      • Unit Group - Pick every unit in DB_Group[cv] and do (Actions)
        • Loop - Actions
          • Set VariableSet DB_Carrier = (Picked unit)
          • Set VariableSet DB_Item = (Item carried by DB_Carrier of type Deathblade)
          • Set VariableSet DB_Charges = ((Charges remaining in DB_Item) + 20)
          • Item - Set charges remaining in DB_Item to DB_Charges
      • Custom script: call DestroyGroup (udg_DB_Group[udg_cv])
      • Custom script: set udg_DB_Group[udg_cv] = null
      • Custom script: endif
Using Custom Script (Jass) we can check if a Variable is null or not, which tells us whether it exists or not. This is useful since DB_Group[cv] doesn't exist UNTIL we create it, so it will be considered "null" until that happens.

This is done to prevent us from creating more than 1 Unit Group per unit. Then when our unit dies and we destroy it's Unit Group, we have to null the Unit Group, this way it's considered null again and can be recreated in the future.
 
Last edited:
Level 6
Joined
Jul 23, 2018
Messages
243
Did you get it working with my example? I don't think the Hashtable method is necessary if the Unit Group one works.

Here are the triggers:
  • DB Damage Taken unit group
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource has an item of type Deathblade) Equal to True
    • Actions
      • Set VariableSet cv = (Custom value of DamageEventTarget)
      • Custom script: if udg_DB_Group[udg_cv] == null then
      • Custom script: set udg_DB_Group[udg_cv] = CreateGroup()
      • Custom script: endif
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DamageEventSource is in DB_Group[cv].) Equal to False
        • Then - Actions
          • Unit Group - Add DamageEventSource to DB_Group[cv]
        • Else - Actions
  • DB Death unit group
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set VariableSet cv = (Custom value of (Triggering unit))
      • Custom script: if udg_DB_Group[udg_cv] != null then
      • Unit Group - Pick every unit in DB_Group[cv] and do (Actions)
        • Loop - Actions
          • Set VariableSet DB_Carrier = (Picked unit)
          • Set VariableSet DB_Item = (Item carried by DB_Carrier of type Deathblade)
          • Set VariableSet DB_Charges = ((Charges remaining in DB_Item) + 20)
          • Item - Set charges remaining in DB_Item to DB_Charges
      • Custom script: call DestroyGroup (udg_DB_Group[udg_cv])
      • Custom script: set udg_DB_Group[udg_cv] = null
      • Custom script: endif
Using Custom Script (Jass) we can check if a Variable is null or not, which tells us whether it exists or not. This is useful since DB_Group[cv] doesn't exist UNTIL we create it, so it will be considered "null" until that happens.

This is done to prevent us from creating more than 1 Unit Group per unit. Then when our unit dies and we destroy it's Unit Group, we have to null the Unit Group, this way it's considered null again and can be recreated in the future.
So the group will be overwritten despite a unit group of the same array already exists?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
Did you get it to work? The Unit Group triggers worked for me.

And to answer your question:

Unit Groups are never overwritten. When you Set a Unit Group variable, a new Unit Group is created and that variable, DB_Group[cv] for example, is assigned to it. It acts as a reference, pointing to the new Unit Group.

So you're creating a new Unit Group whenever you do this:
  • Set Variable TempGroup = Units matching blah blah blah...
Any previous Unit Groups that DB_Group[cv] created will still exist (unless you already destroyed them). This is where memory leaks come into play. You need to make sure that you clean up (destroy/remove) unneeded memory while you still have reference to it, otherwise you will create a memory leak. Remember that you can't destroy something that you no longer have reference to, that's why you always Destroy your Unit Groups before Setting them again.

The exception to this is if you wanted to create a Unit Group that will exist throughout the entire game. You don't have to worry about memory leaks in this case since it's only being Set (created) once.
 
Last edited:
Level 6
Joined
Jul 23, 2018
Messages
243
Did you get it to work? The Unit Group triggers worked for me.

And to answer your question:

Unit Groups are never overwritten. When you Set a Unit Group variable, a new Unit Group is created and that variable, DB_Group[cv] for example, is assigned to it. It acts as a reference, pointing to the new Unit Group.

So you're creating a new Unit Group whenever you do this:
  • Set Variable TempGroup = Units matching blah blah blah...
Any previous Unit Groups that DB_Group[cv] created will still exist (unless you already destroyed them). This is where memory leaks come into play. You need to make sure that you clean up (destroy/remove) unneeded memory while you still have reference to it, otherwise you will create a memory leak. Remember that you can't destroy something that you no longer have reference to, that's why you always Destroy your Unit Groups before Setting them again.

The exception to this is if you wanted to create a Unit Group that will exist throughout the entire game. You don't have to worry about memory leaks in this case since it's only being Set (created) once.
Both trigger work, so thanks a lot.
The only problem I have now is changing Deathblade charges because the hero can equip more than one Deathblade items, I tried using For Loop Integer but it didn't work as the Deathblade on slot 2 didn't gain any charge but Deathblade on slot 1 did. Although the hero did gain damage bonus after units die but he gains like 3 stack for all three item even though he only has 2 deathblade on him
  • DB Death
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set DB_Source = (Triggering unit)
      • Set DB_Size = (Load 0 of (Key DB_Source) from DB_Hash)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DB_Size Greater than 0
        • Then - Actions
          • For each (Integer DB_Loop) from 1 to DB_Size, do (Actions)
            • Loop - Actions
              • Set DB_Carrier = (Load DB_Loop of (Key DB_Source) in DB_Hash)
              • Set DB_Item = (Item carried by DB_Carrier of type Deathblade)
              • Set DB_Charges = ((Charges remaining in DB_Item) + 15)
              • For each (Integer A) from 1 to 3, do (Actions)
                • Loop - Actions
                  • Item - Set charges remaining in DB_Item to DB_Charges
                  • Unit - Increase level of Item Damage Bonus (Deathblade) for DB_Carrier
          • Hashtable - Clear all child hashtables of child (Key DB_Source) in DB_Hash
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
See this:
  • Item - Set charges remaining in DB_Item to DB_Charges
That SETS the item's charges to the value of DB_Charges. So let's say DB_Charges is 15, it's going to set the Item's charges to 15, three times. This is different than ADDING the charges.

What you'd want to do is Loop through each Inventory Slot and check if there's a Deathblade there. If you find one, increase it's Charges.
  • For each Integer DB_Loop2 from 1 to 6 do (Actions)
    • Set DB_Item = (Item carried by DB_Carrier in Inventory Slot DB_Loop2)
    • If Item-Type of DB_Item Equal to Deathblade then:
      • Set DB_Charges = ((Charges remaining in DB_Item) + 15)
      • Item - Set charges remaining in DB_Item to DB_Charges
      • Unit - Increase level of Item Damage Bonus (Deathblade) for DB_Carrier
DB_Loop2 is a new Integer variable. It's good practice to you create new Integers for your Loops instead of using IntegerA/B.
 
Last edited:
Level 6
Joined
Jul 23, 2018
Messages
243
The trigger works now, not sure why I keep putting DB_Item variable before the second loop rather than inside it
  • DB Death
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set DB_Source = (Triggering unit)
      • Set DB_Size = (Load 0 of (Key DB_Source) from DB_Hash)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DB_Size Greater than 0
        • Then - Actions
          • For each (Integer DB_Loop) from 1 to DB_Size, do (Actions)
            • Loop - Actions
              • Set DB_Carrier = (Load DB_Loop of (Key DB_Source) in DB_Hash)
              • For each (Integer DB_Loop2) from 1 to 3, do (Actions)
                • Loop - Actions
                  • Set DB_Item = (Item carried by DB_Carrier in slot DB_Loop2)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Item-type of DB_Item) Equal to Deathblade
                    • Then - Actions
                      • Set DB_Charges = ((Charges remaining in DB_Item) + 15)
                      • Item - Set charges remaining in DB_Item to DB_Charges
                      • Unit - Increase level of Item Damage Bonus (Deathblade) for DB_Carrier
                    • Else - Actions
          • Hashtable - Clear all child hashtables of child (Key DB_Source) in DB_Hash
        • Else - Actions
 
Status
Not open for further replies.
Top