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

Damage Calculating System 1.3v [GUI]

This is a simple damage calculating system i have made. It basically calculates all the possible damage an unit can get. It is pretty accurate, it stores the damage in a variable. This happens instantly, which means that you can use the system to calculate the damage of a hero for a spell (like the example i have given in the test map). It's safe and it's GUI (only).

1.0v - the system is released
1.1v - the system is with hashtables now
1.2v - some optimization in the config and event triggers, example spell provided
1.3v - examples improved, the exact unit for the calculation can be set by the user


  • DCS Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set DCS_Hash = (Last created hashtable)
      • Set DCS_UnitInt = 0
      • Set DCS_ItemInt = 0
      • -------- Do not touch above! --------
      • -------- ----------------------- --------
      • Set DCS_AttackBounsFromAttribute = 1.50
      • -------- Set DCS_AttackBounsFromAttribute to be equal to the number of attack points given to the hero per primary attribute point. --------
      • -------- You can find this number in the Gameplay Constants within a field, called "Hero Attributes - Attack Bonus per Primary Att. Point" --------
      • -------- ----------------------- --------
      • -------- ------------------------------------------- HEROES HEROES HEROES ------------------------------------------- --------
      • -------- -------------------- Blademaster [EXAMPLE] -------------------- --------
      • Custom script: set udg_DCS_UnitInt = 'Obla'
      • -------- In the custom script above, change the "Obla" thing to be equal to the rawcode of the unit. You can see that rawcode --------
      • -------- by simply pressing Ctrl + D while in object editor. You are going to see four letters like those "Obla". In this case, "Obla" means --------
      • -------- "Blademaster". Do this for each unit that will use the system. --------
      • Set DCS_NumberOfDice = 2
      • -------- Set DCS_NumberOfDice to be equal to the Object Editor field "Combat - Attack X - Damage Number of Dice" of your unit. --------
      • Set DCS_SidesPerDie = 12
      • -------- Set DCS_SidesPerDie to be equal to the Object Editor field "Combat - Attack X - Damage Sides per Die" of your unit. --------
      • Set DCS_BaseDamage = 10
      • -------- Set DCS_BaseDamage to be equal to the Object Editor field "Combat - Attack X - Damage Base" of your unit. --------
      • Set DCS_PrimAttribute = 2
      • -------- Set DCS_PrimAttribute to be equal to the Primary Attribute of your hero. 1 = Strength, 2 = Agility, 3 = Intelligence. --------
      • Trigger - Run DCS Save values <gen> (ignoring conditions)
      • -------- -------------------- Blademaster [EXAMPLE] -------------------- --------
      • -------- ----------------------- --------
      • -------- -------------------- Tauren Chieftain -------------------- --------
      • Custom script: set udg_DCS_UnitInt = 'Otch'
      • Set DCS_NumberOfDice = 3
      • Set DCS_SidesPerDie = 6
      • Set DCS_BaseDamage = 20
      • Set DCS_PrimAttribute = 1
      • Trigger - Run DCS Save values <gen> (ignoring conditions)
      • -------- -------------------- Tauren Chieftain -------------------- --------
      • -------- -------------------- Shadow Hunter -------------------- --------
      • Custom script: set udg_DCS_UnitInt = 'Oshd'
      • Set DCS_NumberOfDice = 1
      • Set DCS_SidesPerDie = 8
      • Set DCS_BaseDamage = 5
      • Set DCS_PrimAttribute = 3
      • Trigger - Run DCS Save values <gen> (ignoring conditions)
      • -------- -------------------- Shadow Hunter -------------------- --------
      • -------- ------------------------------------------- HEROES HEROES HEROES ------------------------------------------- --------
      • -------- ----------------------- --------
      • -------- ------------------------------------------- UNITS UNITS UNITS ------------------------------------------- --------
      • -------- It's the same when setting the variables for units instead of heroes. You just set DCS_PrimAttribute to 0 --------
      • -------- because units don't have attributes. --------
      • -------- -------------------- Grunt -------------------- --------
      • Custom script: set udg_DCS_UnitInt = 'ogru'
      • Set DCS_NumberOfDice = 1
      • Set DCS_SidesPerDie = 4
      • Set DCS_BaseDamage = 17
      • Set DCS_PrimAttribute = 0
      • Trigger - Run DCS Save values <gen> (ignoring conditions)
      • -------- -------------------- Grunt -------------------- --------
      • -------- -------------------- Tauren -------------------- --------
      • Custom script: set udg_DCS_UnitInt = 'otau'
      • Set DCS_NumberOfDice = 11
      • Set DCS_SidesPerDie = 11
      • Set DCS_BaseDamage = 29
      • Set DCS_PrimAttribute = 0
      • Trigger - Run DCS Save values <gen> (ignoring conditions)
      • -------- -------------------- Tauren -------------------- --------
      • -------- -------------------- Troll Headhunter -------------------- --------
      • Custom script: set udg_DCS_UnitInt = 'ohun'
      • Set DCS_NumberOfDice = 15
      • Set DCS_SidesPerDie = 2
      • Set DCS_BaseDamage = 40
      • Set DCS_PrimAttribute = 0
      • Trigger - Run DCS Save values <gen> (ignoring conditions)
      • -------- -------------------- Troll Headhunter -------------------- --------
      • -------- -------------------- Priest -------------------- --------
      • Custom script: set udg_DCS_UnitInt = 'hmpr'
      • Set DCS_NumberOfDice = 1
      • Set DCS_SidesPerDie = 3
      • Set DCS_BaseDamage = 50
      • Set DCS_PrimAttribute = 0
      • Trigger - Run DCS Save values <gen> (ignoring conditions)
      • -------- -------------------- Priest -------------------- --------
      • -------- ------------------------------------------- UNITS UNITS UNITS ------------------------------------------- --------
      • -------- ----------------------- --------
      • -------- ------------------------------------------- ITEMS ITEMS ITEMS ------------------------------------------- --------
      • -------- -------------------- Claws Of Attack +15 -------------------- --------
      • Custom script: set udg_DCS_ItemInt = 'ratf'
      • -------- Set the custom script above to be equal to the rawcode of the item, this can be done the same way as it is done for units. --------
      • Set DCS_ItemDamageBonus = 15
      • Trigger - Run DCS Save item value <gen> (ignoring conditions)
      • -------- DCS_ItemDamageBonus sets the damage bonus that the item gives. --------
      • -------- -------------------- Claws Of Attack +15 -------------------- --------
      • -------- -------------------- Claws Of Attack +6 -------------------- --------
      • Custom script: set udg_DCS_ItemInt = 'rat6'
      • Set DCS_ItemDamageBonus = 6
      • Trigger - Run DCS Save item value <gen> (ignoring conditions)
      • -------- -------------------- Claws Of Attack +6 -------------------- --------
      • -------- -------------------- Claws Of Attack +12 -------------------- --------
      • Custom script: set udg_DCS_ItemInt = 'ratc'
      • Set DCS_ItemDamageBonus = 12
      • Trigger - Run DCS Save item value <gen> (ignoring conditions)
      • -------- -------------------- Claws Of Attack +12 -------------------- --------
      • -------- ------------------------------------------- ITEMS ITEMS ITEMS ------------------------------------------- --------
      • -------- ----------------------- --------
  • DCS Other Damage Sources
    • Events
    • Conditions
    • Actions
      • -------- If - Something is true... --------
      • -------- Then - set DCS_Damage = DCS_Damage + *your amount of given damage* --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DCS_Unit has buff Inner Fire) Equal to True
        • Then - Actions
          • Set DCS_Damage = (DCS_Damage + (DCS_Damage x 0.50))
        • Else - Actions
  • DCS Core
    • Events
    • Conditions
    • Actions
      • -------- The magic happens here. Don't touch anything. --------
      • Set DCS_AllItemDamage = 0.00
      • Set DCS_AllAttributeBonus = 0
      • Set DCS_Damage = 0.00
      • Custom script: set udg_DCS_UnitInt = GetUnitTypeId(udg_DCS_Unit)
      • Set DCS_NumberOfDice = (Load (Key NumberOfDice) of DCS_UnitInt from DCS_Hash)
      • Set DCS_SidesPerDie = (Load (Key SidesPerDie) of DCS_UnitInt from DCS_Hash)
      • Set DCS_BaseDamage = (Load (Key BaseDamage) of DCS_UnitInt from DCS_Hash)
      • Set DCS_Damage = (Random real number between ((Real(DCS_NumberOfDice)) + (Real(DCS_BaseDamage))) and (((Real(DCS_NumberOfDice)) x (Real(DCS_SidesPerDie))) + (Real(DCS_BaseDamage))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DCS_Unit is A Hero) Equal to True
        • Then - Actions
          • Set DCS_PrimAttribute = (Load (Key PrimAttribute) of DCS_UnitInt from DCS_Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DCS_PrimAttribute Equal to 1
            • Then - Actions
              • Set DCS_PrimAttributeCount = (Strength of DCS_Unit (Exclude bonuses))
              • Set DCS_AllAttributeBonus = ((Strength of DCS_Unit (Include bonuses)) - (Strength of DCS_Unit (Exclude bonuses)))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DCS_PrimAttribute Equal to 2
            • Then - Actions
              • Set DCS_PrimAttributeCount = (Agility of DCS_Unit (Exclude bonuses))
              • Set DCS_AllAttributeBonus = ((Agility of DCS_Unit (Include bonuses)) - (Agility of DCS_Unit (Exclude bonuses)))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DCS_PrimAttribute Equal to 3
            • Then - Actions
              • Set DCS_PrimAttributeCount = (Intelligence of DCS_Unit (Exclude bonuses))
              • Set DCS_AllAttributeBonus = ((Intelligence of DCS_Unit (Include bonuses)) - (Intelligence of DCS_Unit (Exclude bonuses)))
            • Else - Actions
          • Set DCS_Damage = (DCS_Damage + ((Real(DCS_PrimAttributeCount)) x DCS_AttackBounsFromAttribute))
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Set DCS_CarriedItem = (Item carried by DCS_Unit in slot (Integer A))
              • Custom script: set udg_DCS_ItemInt = GetItemTypeId(udg_DCS_CarriedItem)
              • Set DCS_ItemDamageBonus = (Load (Key ItemDamageBonus) of DCS_ItemInt from DCS_Hash)
              • Set DCS_AllItemDamage = (DCS_AllItemDamage + (Real(DCS_ItemDamageBonus)))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DCS_IncludeItemBonus Equal to True
        • Then - Actions
          • Set DCS_Damage = (DCS_Damage + DCS_AllItemDamage)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DCS_IncludeAttributeBonus Equal to True
        • Then - Actions
          • Set DCS_Damage = (DCS_Damage + ((Real(DCS_AllAttributeBonus)) x DCS_AttackBounsFromAttribute))
        • Else - Actions
      • -------- The magic happens here. Don't touch anything. --------
  • DCS Save values
    • Events
    • Conditions
    • Actions
      • Hashtable - Save DCS_NumberOfDice as (Key NumberOfDice) of DCS_UnitInt in DCS_Hash
      • Hashtable - Save DCS_SidesPerDie as (Key SidesPerDie) of DCS_UnitInt in DCS_Hash
      • Hashtable - Save DCS_BaseDamage as (Key BaseDamage) of DCS_UnitInt in DCS_Hash
      • Hashtable - Save DCS_PrimAttribute as (Key PrimAttribute) of DCS_UnitInt in DCS_Hash
  • DCS Save item value
    • Events
    • Conditions
    • Actions
      • Hashtable - Save DCS_ItemDamageBonus as (Key ItemDamageBonus) of DCS_ItemInt in DCS_Hash
There is some info in the test map under the form of a trigger comment.

Special thanks to Adiktuz - for showing me how hashtables work. I wouldn't have made this without his help, so make sure you give him credit too!

Please, RATE AND COMMENT ! =)

Keywords:
system, damage, get, calculate, spell, detect, calculating
Contents

Damage Calculating System (DCS) (Map)

Reviews
23rd September 2012 Magtheridon96: Approved and Recommended This system handles Damage amount computation in a user-friendly way, and it allows users to customize the computation to take into account other damage sources too, which is awesome...

Moderator

M

Moderator

23rd September 2012
Magtheridon96:

Approved and Recommended
This system handles Damage amount computation in a user-friendly way, and it allows users to customize the computation to take into account other damage sources too, which is awesome.

One nice improvement would be to have some constant variables set on map init before all the configuration to represent Strength, Agility and Intelligence. This makes it easier for users to add hero data to the system because they wouldn't have to use meaningless numbers, but comprehensible variables that make it all clear :D

  • Set Attribute_Strength = 1
  • Set Attribute_Agility = 2
  • Set Attribute_Intelligence = 3
 
Level 28
Joined
Oct 28, 2011
Messages
4,759
Here is your trigger sir, next time add it on your own:

  • DCS Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set DCS_AttackBounsFromAttribute = 1.50
      • -------- Set DCS_AttackBounsFromAttribute to be equal to the number of attack points given to the hero per primary attribute point. --------
      • -------- You can find this number in the Gameplay Constants within a field, called "Hero Attributes - Attack Bonus per Primary Att. Point" --------
  • DCS Event
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • Set DCS_Unit = (Triggering unit)
      • Trigger - Run DCS Unit Config <gen> (ignoring conditions)
      • Trigger - Run DCS Item Config <gen> (ignoring conditions)
      • Trigger - Run DCS Buff Config <gen> (ignoring conditions)
      • -------- From now on, the damage of the unit is calculated. It's ready for use! --------
      • Game - Display to (All players) the text: ((Name of DCS_Unit) + ('s + (damage : + (String((Integer(DCS_Damage)))))))
  • DCS Unit Config
    • Events
    • Conditions
    • Actions
      • -------- ---------------------------------------- HEROES ---------------------------------------- --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- Copy for each of your heroes from here --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of DCS_Unit) Equal to Blademaster
        • Then - Actions
          • Set DCS_NumberOfDice = 2
          • -------- Set DCS_NumberOfDice to be equal to the Object Editor field, called "Combat - Attack X - Damage Number of Dice" --------
          • Set DCS_SidesPerDie = 12
          • -------- Set DCS_SidesPerDie to be equal to the Object Editor field, called "Combat - Attack X - Damage Sides per Die" --------
          • Set DCS_BaseDamage = 10
          • -------- Set DCS_BaseDamage to be equal to the Object Editor field, called "Combat - Attack X - Damage Base" --------
          • Set DCS_PrimAttribute = 2
          • -------- Set DCS_PrimAttribute to be equal to the primary attribute of your hero. 1 = "Strength", 2 = "Agility", 3 = "Intelligence". --------
        • Else - Actions
      • -------- to here! --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of DCS_Unit) Equal to Tauren Chieftain
        • Then - Actions
          • Set DCS_NumberOfDice = 2
          • -------- Set DCS_NumberOfDice to be equal to the Object Editor field, called "Combat - Attack X - Damage Number of Dice" --------
          • Set DCS_SidesPerDie = 6
          • -------- Set DCS_SidesPerDie to be equal to the Object Editor field, called "Combat - Attack X - Damage Sides per Die" --------
          • Set DCS_BaseDamage = 20
          • -------- Set DCS_BaseDamage to be equal to the Object Editor field, called "Combat - Attack X - Damage Base" --------
          • Set DCS_PrimAttribute = 1
          • -------- Set DCS_PrimAttribute to be equal to the primary attribute of your hero. 1 = "Strength", 2 = "Agility", 3 = "Intelligence". --------
        • Else - Actions
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of DCS_Unit) Equal to Shadow Hunter
        • Then - Actions
          • Set DCS_NumberOfDice = 2
          • -------- Set DCS_NumberOfDice to be equal to the Object Editor field, called "Combat - Attack X - Damage Number of Dice" --------
          • Set DCS_SidesPerDie = 4
          • -------- Set DCS_SidesPerDie to be equal to the Object Editor field, called "Combat - Attack X - Damage Sides per Die" --------
          • Set DCS_BaseDamage = 5
          • -------- Set DCS_BaseDamage to be equal to the Object Editor field, called "Combat - Attack X - Damage Base" --------
          • Set DCS_PrimAttribute = 3
          • -------- Set DCS_PrimAttribute to be equal to the primary attribute of your hero. 1 = "Strength", 2 = "Agility", 3 = "Intelligence". --------
        • Else - Actions
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- ---------------------------------------- HEROES ---------------------------------------- --------
      • -------- ---------------------------------------- UNITS ---------------------------------------- --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- Copy for each of your units from here --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of DCS_Unit) Equal to Grunt
        • Then - Actions
          • Set DCS_NumberOfDice = 1
          • -------- Set DCS_NumberOfDice to be equal to the Object Editor field, called "Combat - Attack X - Damage Number of Dice" --------
          • Set DCS_SidesPerDie = 4
          • -------- Set DCS_SidesPerDie to be equal to the Object Editor field, called "Combat - Attack X - Damage Sides per Die" --------
          • Set DCS_BaseDamage = 17
          • -------- Set DCS_BaseDamage to be equal to the Object Editor field, called "Combat - Attack X - Damage Base" --------
        • Else - Actions
      • -------- to here! --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of DCS_Unit) Equal to Priest
        • Then - Actions
          • Set DCS_NumberOfDice = 1
          • -------- Set DCS_NumberOfDice to be equal to the Object Editor field, called "Combat - Attack X - Damage Number of Dice" --------
          • Set DCS_SidesPerDie = 2
          • -------- Set DCS_SidesPerDie to be equal to the Object Editor field, called "Combat - Attack X - Damage Sides per Die" --------
          • Set DCS_BaseDamage = 7
          • -------- Set DCS_BaseDamage to be equal to the Object Editor field, called "Combat - Attack X - Damage Base" --------
        • Else - Actions
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of DCS_Unit) Equal to Tauren
        • Then - Actions
          • Set DCS_NumberOfDice = 1
          • -------- Set DCS_NumberOfDice to be equal to the Object Editor field, called "Combat - Attack X - Damage Number of Dice" --------
          • Set DCS_SidesPerDie = 7
          • -------- Set DCS_SidesPerDie to be equal to the Object Editor field, called "Combat - Attack X - Damage Sides per Die" --------
          • Set DCS_BaseDamage = 29
          • -------- Set DCS_BaseDamage to be equal to the Object Editor field, called "Combat - Attack X - Damage Base" --------
        • Else - Actions
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of DCS_Unit) Equal to Troll Headhunter
        • Then - Actions
          • Set DCS_NumberOfDice = 1
          • -------- Set DCS_NumberOfDice to be equal to the Object Editor field, called "Combat - Attack X - Damage Number of Dice" --------
          • Set DCS_SidesPerDie = 5
          • -------- Set DCS_SidesPerDie to be equal to the Object Editor field, called "Combat - Attack X - Damage Sides per Die" --------
          • Set DCS_BaseDamage = 22
          • -------- Set DCS_BaseDamage to be equal to the Object Editor field, called "Combat - Attack X - Damage Base" --------
        • Else - Actions
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- ---------------------------------------- UNITS ---------------------------------------- --------
      • -------- DO NOT TOUCH ANYTHING BELOW! --------
      • Set DCS_Damage = (Random real number between ((Real(DCS_NumberOfDice)) + (Real(DCS_BaseDamage))) and (((Real(DCS_NumberOfDice)) x (Real(DCS_SidesPerDie))) + (Real(DCS_BaseDamage))))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DCS_Unit is A Hero) Equal to True
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DCS_PrimAttribute Equal to 1
            • Then - Actions
              • Set DCS_PrimAttributeCount = (Strength of DCS_Unit (Include bonuses))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DCS_PrimAttribute Equal to 2
            • Then - Actions
              • Set DCS_PrimAttributeCount = (Agility of DCS_Unit (Include bonuses))
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DCS_PrimAttribute Equal to 3
            • Then - Actions
              • Set DCS_PrimAttributeCount = (Intelligence of DCS_Unit (Include bonuses))
            • Else - Actions
          • Set DCS_Damage = (DCS_Damage + ((Real(DCS_PrimAttributeCount)) x DCS_AttackBounsFromAttribute))
        • Else - Actions
  • DCS Item Config
    • Events
    • Conditions
    • Actions
      • -------- Note : Add the actions below for each item that boosts DAMAGE, NOT the attribute of a hero (which will boost the damage, but only --------
      • -------- if the attribute is a primary. This damage is in the calculation, so don't worry ;) ) --------
      • -------- ---------------------------------------- ITEMS ---------------------------------------- --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- Copy for each item from here --------
      • Set DCS_ItemCount = 0
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by DCS_Unit in slot (Integer A))) Equal to Claws of Attack +15
            • Then - Actions
              • Set DCS_ItemCount = (DCS_ItemCount + 1)
              • -------- Don't touch the action above. --------
              • Set DCS_ItemAttackBonus = 15
              • -------- DCS_ItemAttackBonus sets the damage that is added from your item. --------
            • Else - Actions
      • Set DCS_Damage = (DCS_Damage + ((Real(DCS_ItemCount)) x (Real(DCS_ItemAttackBonus))))
      • -------- to here! --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • Set DCS_ItemCount = 0
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by DCS_Unit in slot (Integer A))) Equal to Claws of Attack +12
            • Then - Actions
              • Set DCS_ItemCount = (DCS_ItemCount + 1)
              • -------- Don't touch the action above. --------
              • Set DCS_ItemAttackBonus = 12
            • Else - Actions
      • Set DCS_Damage = (DCS_Damage + ((Real(DCS_ItemCount)) x (Real(DCS_ItemAttackBonus))))
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • Set DCS_ItemCount = 0
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by DCS_Unit in slot (Integer A))) Equal to Claws of Attack +6
            • Then - Actions
              • Set DCS_ItemCount = (DCS_ItemCount + 1)
              • -------- Don't touch the action above. --------
              • Set DCS_ItemAttackBonus = 6
            • Else - Actions
      • Set DCS_Damage = (DCS_Damage + ((Real(DCS_ItemCount)) x (Real(DCS_ItemAttackBonus))))
      • -------- ------- --------
      • -------- ------- --------
      • -------- ------- --------
      • -------- ---------------------------------------- ITEMS ---------------------------------------- --------
  • DCS Buff Config
    • Events
    • Conditions
    • Actions
      • -------- ---------------------------------------- BUFFS ---------------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DCS_Unit has buff Inner Fire) Equal to True
        • Then - Actions
          • Set DCS_Damage = (DCS_Damage + (DCS_Damage x 0.50))
        • Else - Actions
      • -------- ---------------------------------------- BUFFS ---------------------------------------- --------
 
Level 14
Joined
Aug 8, 2010
Messages
1,021
Thanks! I forgot it! Sorry...

And by the way - this system is very simple, yes, i know. But i thought it is useful as well, so that's why i have uploaded it! ;) I don't want comments like "Pfff... very simple... you suck!" because i personally think that usefulness is the most important thing when uploading a spell/system/template.
 
This is just too much work for the user so I cannot really call it useful as a resource [resources are meant to be easy to use and implement]...

but if you'll make it as a tutorial, yes it will be useful...

Also since the damage is calculated when you select a unit, it will not update if the unit is not reselected... so if I for example add something that increases damage while keeping the unit selected, then the additional damage won't be included on the calculated damage... though I see it that the event included can be just a very simple sample of how to use the "system"

You can skip everything above and just read this as I think this is the important part

Instead of if-then-elses, you better just use arrays or hashes [using the unittypeid/rawcode] as key or index so that you can directly retrieve the data for the Damage per die etc without having to check the unit over and over again until you find a match...

the same thing for the items... instead of checking each slot for each type of item, the data should already be saved in a hash where the itemtypeid/rawcode is the key...

doing that would save you from lots of useless if-then-elses... I know it would require you to register everything at map init but that is better than having all those if-then-elses run every time the system is to calculate damage...

For the buff part, what if the buff only increases the base damage? If I'm correct, things like command aura [when increasing damage by %] only takes into account only the base damage [base in the OE + increases due to main attribute] and does not include item damage bonuses...

with the current set-up that would take a lot of work, and a lot of if-then-elses, but if you'll use arrays or hashes, it would be easy to do that...



So, the moral of the lesson? Make the unit and item data registered into the system at maybe map init... then for the calculations, just retrieve the saved data so that you will reduce the number of actions run everytime the system calculates damage...

If you need an example, take this scenario:

I have 100 items in the OE that boosts damage

When I calculate damage, the system will check each slot from 1 to 6 for every item registered into the system. Since there were 100 items registered, it will do the check 600 times just to calculate the total damage bonus from items... it will always run the same number of times without regard to the number of items I have in the inventory...

Now If I registered them first into a hash or an array, I only need 1 action to obtain the damage value of 1 item in my inventory... so 6 actions maximum since you can only have 6 items...

If you don't know how to use hashes or arrays, then learn how to use them...



nonetheless, this is better off as a tutorial than a resource because most of the things here are to be done by the user and there's only a few lines that are actually part of the core [only the calculation part really, all settings etc are to be done by the user]... for systems, the core is the important thing because that is the one that is designed by the creator of the system...
 
Last edited:
Level 14
Joined
Aug 8, 2010
Messages
1,021
Some answers :
This is just too much work for the user so I cannot really call it useful as a resource [resources are meant to be easy to use and implement]...
Either way, the user must set some variables - for example, the system can't find the Sides per die and Roll dice of the unit if the user doesn't put them in the variables. The same thing is with primary attribute.
Also since the damage is calculated when you select a unit, it will not update if the unit is not reselected... so if I for example add something that increases damage while keeping the unit selected, then the additional damage won't be included on the calculated damage...
This is not actually my problem. The system does it's job - it calculates the damage instantly. If the user needs it MUI and/or DoT (Damage over Time), he has to make it (he just has to give the DCS_Damage variable an array if he uses Hanky's Dynamic Indexing System for example). At first, i made this system for those who want to calculate the damage (when the unit casts a spell for example) and use that damage for the spell.
Instead of if-then-elses, you better just use arrays or hashes [using the unittypeid/rawcode] as key or index so that you can directly retrieve the data for the Damage per die etc without having to check the unit over and over again until you find a match...
I will try to accomplish that in later updates of the system. :)
For the buff part, what if the buff only increases the base damage? If I'm correct, things like command aura [when increasing damage by %] only takes into account only the base damage [base in the OE + increases due to main attribute] and does not include item damage bonuses...
This could be done very easily... i will include this in later updates.

When I calculate damage, the system will check each slot from 1 to 6 for every item registered into the system. Since there were 100 items registered, it will do the check 600 times just to calculate the total damage bonus from items... it will always run the same number of times without regard to the number of items I have in the inventory...
This will be very hard, but as i said - i will try to accomplish it and learn hashtables.

Thank you, Adiktuz! :)
 
This is not actually my problem. The system does it's job - it calculates the damage instantly. If the user needs it MUI and/or DoT (Damage over Time), he has to make it (he just has to give the DCS_Damage variable an array if he uses Hanky's Dynamic Indexing System for example). At first, i made this system for those who want to calculate the damage (when the unit casts a spell for example) and use that damage for the spell.

->Maybe you could add an example on using it with a triggered spell, just for those who don't know how to do it... XD...

and no, you don't really need an array for the calculated damage to make it MUI... it is MUI as it is, as long as the user knows how to use it... the array should be up to the user to do if he ever needs it...

And replacing the if-then-elses with hashes will make this look more like a system where the config is separated from the core... because right now, the config part is mixed with the core... The users should never need to touch the core of a system just for settings to avoid possible accidents...
 
Level 14
Joined
Aug 8, 2010
Messages
1,021
->Maybe you could add an example on using it with a triggered spell, just for those who don't know how to do it... XD...
Hah! I will add an example! :DDD But basically, you only have to change the event... xD
And replacing the if-then-elses with hashes will make this look more like a system where the config is separated from the core... because right now, the config part is mixed with the core... The users should never need to touch the core of a system just for settings to avoid possible accidents...
I understand. But i need to learn how to do it... can you give me a link to a tutorial, maybe another spell/system/template made this way?
 
take a look at most of the approved gui spells/systems out there... most of them have a config part, though I guess most of them uses arrays...

sample

this will save the base damage of peasant and a custom hero
  • Events
    • Map Initialization
  • Actions
    • Hashtable - Create hashtable
    • Set ColdBoneHase = Last created hashtable
    • Custom script: set udg_TempInt = 'hpea'
    • Hashtable - Save 100 as Key(BaseDamage) of Key(TempInt) in ColdBoneHash
    • Custom script: set udg_TempInt = 'H001'
    • Hashtable - Save 200 as Key(BaseDamage) of Key(TempInt) in ColdBoneHash
retrieve base damage of any unit

  • Events
    • Unit - a unit is selected
  • Actions
    • Custom script: set udg_TempInt = GetUnitTypeId(GetTriggerUnit())
    • Set DCS_Damage = Load Key(BaseDamage) of Key(TempInt) in ColdBoneHash
It might take a while before you can finish updating the whole system... but the end product will run more smoothly [much fewer lines regardless of number of registered objects] and will be less prone to accidental trigger changes since the user won't be touching the core of the system anymore...

I also suggest combining the calculations into just one trigger for less trigger evaluations... once you've done the registry part, there will really be no point in keeping the calculations into separate triggs anymore...
 
yes, that is the base...

then you'll want to save the die too, and the damage per die etc... calculations will be done at the core as far as I'm concerned

the one I posted is just to give you a backbone, it is far from complete...

the idea is that the things that you placed on the if-then-elses should be saved into the hashtable on the config trigger so that you don't need to do the if-then-elses at the calculations anymore...
 
Level 14
Joined
Aug 8, 2010
Messages
1,021
*Updated*! I will recommend using Damage DETECTION System by Maker (i think), because it DETECTS the damage, it doesn't calculate it. Calculations can be wrong, detection will never be wrong. But the DDS is not instant (i think) and is Jass. So if you want to get the damage of a unit instantly or if you simply hate Jass, then the Damage Calculating System is your best alternative! :)

Enjoy!
 
Level 11
Joined
Nov 15, 2007
Messages
781
This doesn't feel very much like a system with all that needs configuring for it to work properly. Even in a melee map using only melee units, items and buffs, setting all the damage, unit, buff and item stats would be the vast majority of the work.

Also a few things that make it incomplete:

-System has no support/explanation of how to support permanent base damage increases. I.E., damage from upgrades, dice bonuses from upgrades, damage from Item Permanent Damage Increase.
-It calculates % damage increases from total damage, when % damage increases only increase base damage + primary attribute bonus.
-No support for units that have more than one attack index.
 
This doesn't feel very much like a system with all that needs configuring for it to work properly

-->That is why I never did this kind of resource, because it will never be a complete public system...

For those triggering for a long time now, this will just look like more of a tutorial (just as what I said on the first page)

but for those starting out, this is certainly a useful resource since the map is downloadable so they will have a base of what to do

and I agree with those 3 points... XF
 
Level 14
Joined
Aug 8, 2010
Messages
1,021
Also a few things that make it incomplete:

-System has no support/explanation of how to support permanent base damage increases. I.E., damage from upgrades, dice bonuses from upgrades, damage from Item Permanent Damage Increase.
Well, this has to be done in the DCS Other Damage Sources trigger by the... user, yeah.
-It calculates % damage increases from total damage, when % damage increases only increase base damage + primary attribute bonus.
I can't understand that... could you explain a little bit deeper? It calculates what from % damage [...]

If someone doesn't want to set all these values, then he has to use the Damage Detection System by... Maker (i think). Otherwise, they can use this as an alternative. I will repeat again - this is just an alternative for those who are afraid of vJass or probably for those who have problems with the system. Take HammerFist132 for an example. :)
 
%damage bonus abilities on wc3 only computes the bonus damage from the default damage of the unit, that is the Base damage + damage bonus due to main attribute...

example:


base damage is 50, damage per attribute is 1 and I have 50 points of the main attribute = + 100 damage
I have an item which gives + 50 bonus = + 50 damage
I have an item which gives +50% bonus damage = + 50 damage
total = 200 damage

the 50% bonus damage only gave 50 damage since the "default" damage of the unit is only 100... on your system, the result would be different since you calculate %bonus from total so it will be 150 + 50%(150) = 225 damage...

PS: the DDS you're talking about I believe was Bribe's GUI Damage Engine or if its vJASS then it must be Nestharus' system...
 
Level 14
Joined
Aug 8, 2010
Messages
1,021
  • DCS Event
  • Events
  • Player - Player 1 (Red) Selects a unit
  • Conditions
  • Actions
  • Set DCS_IncludeAttributeBonus = False
  • Set DCS_IncludeItemBonus = False
Setting those values to false makes the system calculate exactly this - the Base Damage + Damage bonus from main attribute. :) It adds damage bonus from attribute only if the unit is a hero... duh.
 
If I set the itembonus to false for my example it will calculate only 150 damage, when it is actually 200 since the damage bonuses from items will be gone from calculation...

btw, attribute bonus from items are part of the base calculation for %damage bonus as far as my playing experience is concerned...


Do it this way: Run the OtherDCS sources after the attribute calculation but before item calculation...

it would be

Run Core
Run Attribute calc
Run OtherDCS sources
Run Item calc
 
Level 14
Joined
Aug 8, 2010
Messages
1,021
Yes. In the next update i will fix this :
base damage is 50, damage per attribute is 1 and I have 50 points of the main attribute = + 100 damage
I have an item which gives + 50 bonus = + 50 damage
I have an item which gives +50% bonus damage = + 50 damage
total = 200 damage
So it wont be
150 + 50%(150) = 225 damage...
PS: the DDS you're talking about I believe was Bribe's GUI Damage Engine or if its vJASS then it must be Nestharus' system...
Yes.
 
Level 14
Joined
Aug 8, 2010
Messages
1,021
If I set the itembonus to false for my example it will calculate only 150 damage, when it is actually 200 since the damage bonuses from items will be gone from calculation...
This is if you want INTENTIONALLY to remove that damage from the calculations. You may want to do a spell only with the base damage of a unit, maybe without the damage of his items.

PS: Sorry for double post...
 
This is if you want INTENTIONALLY to remove that damage from the calculations. You may want to do a spell only with the base damage of a unit, maybe without the damage of his items.

then it won't solve the problem that Meticulous was pointing out which I was trying to tell you how to solve...

Adiktuz said:
btw, attribute bonus from items are part of the base calculation for %damage bonus as far as my playing experience is concerned...


Do it this way: Run the OtherDCS sources after the attribute calculation but before item calculation...

it would be

Run Core
Run Attribute calc
Run OtherDCS sources
Run Item calc
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Ill give you a bump :D
I think its quite nice, works properly even trough I dont know about the Code, for me GUI is a little bit too hard to read :D
overall, quite nice and it even randomizes the values as with the normal attacks
 
Level 17
Joined
Jul 17, 2011
Messages
1,864
you should make this get the whole range of damage the unit has not just 1 random number eg if the unit has 100 -110 damage then not just get a random number between 100 and 110 but the whole damage range. i think that will distinguish it from a damage engine also i ve never seen a system which does that
 
Level 14
Joined
Aug 8, 2010
Messages
1,021
Am, when you do damage with a unit, it deals random number between it's damage. And i simply want to get this damage in a variable, this random number is a part of the system. Also, what will you do with two values (100 and 110)?!
Or i can't understand what you mean. @@

i think that will distinguish it from a damage engine also i ve never seen a system which does that
Not all systems must be the same...
 
Level 14
Joined
Aug 8, 2010
Messages
1,021
Some more things you should add:
  • Configure buffs that increase damage
  • Configure abilities that increase damage
Both of this things should be done in the "DCS Other Damage Sources" trigger. I mean, i can make it work with the classic War3 buffs but what if a user wants to calculate a custom buff? He needs to do it for himself. Thus, this will not be really easy job.
The only thing i can do is to make the DCS ODS trigger without if/then/elses but with a hashtable instead.
 
Level 3
Joined
Oct 30, 2011
Messages
26
dude, I love your works... Especially this !
But the "DCS Other Damage Source" is quite wrong, What if my hero has 2 buffs at a time ?
1st buff for 95% damage and 2nd buff for 300% damage
My hero atk is about 292
-----> The Result is : (292*1.95)*(4) = 2277.6 damage ..... holly molly, it's totally got problem in this. The true result is 292*(1+0.95+3) = 1445.4 damage only...
 
Level 3
Joined
Oct 30, 2011
Messages
26
  • Set DCS_Damage = (DCS_Damage + (DCS_Damage x 1.00))
this is the calculating part. I want it to increases Default Damage ( as War3 increases )
Yes, it is possible to change the damage. But every skill has 5 levels -> 5 buffs / skills ... If i have 2 buffs on 1 hero, I have to do the If-else for 5*5 = 25 times ... Didn't mention if there're 3 4 or more buffs. Lol
 
Top