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).
Changelog
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
Triggers
DCS Config
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
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
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
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
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 ! =)
Rating - 5.00 (1 vote)
(Hover and click)
Moderator Comments
Recommended
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
Example
Set Attribute_Strength = 1 Set Attribute_Agility = 2 Set Attribute_Intelligence = 3
Here is your trigger sir, next time add it on your own:
DCS Init
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
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
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
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
-------- ---------------------------------------- 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))
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...
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.
Quote:
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.
Quote:
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. :)
Quote:
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.
Quote:
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.
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...
->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
Quote:
Originally Posted by Adiktuz
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...
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...
Ye, ye! I i understand! :) I will try to do it these days if i have time. Because i have to study - the teachers in my school are true devils... entering the school is like you are entering hell... :X :@
*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! :)
Man this work perfect for me +rep. And 5/5. I like it so much because it'= easy to stand. I have 'stand this from first opening it, but damage engine and by maker I cannot for now xD
__________________
On vacation wit no pc for one week. But you must know to even now I am so cool.