- Joined
- Oct 2, 2013
- Messages
- 95
So I made a "system" and was thinking about posting it as a resource, but not sure yet.
It works like this:
U = the "caster", whose dmg is being retrieved
T = the target, whose armor is being tested against u's damage.
When the user wants to detect damage, it call a "startDamage()" function inside a spell struct and creates a dummy unit ( via an system function ) that is a clone of U with all items and max atk speed ( 0.00 cooldown, 0.00 animations ). That dummy is ordered to attack T. When he does, a dmg detection trigger in fire and evaluate if that damage source is part of any of the active spell structs ( active structs are defined using "startDamage" ). If damage source == dummy, then in blocks all damage done by that dummy, kills the dummy and sends the damage var to the spell struct, while calling a specific method named "do_damage". That method will do whatever the spell does with the dmg retrieved and call "stopDamage", meaning the GetDmg process is over.
The thing is am not sure if this is really efficient, maybe its just better to have all units dmg saved in some vars, modifying it every time that unit levels up or gets an item.
Also, the way I looped the GetUnitDamageX static method was taken from T32 ( Jesus4Lyf ), it works for this system but im not sure if its the best option.
So any help with improving the system code and opinions on this are greatly appreciated.
Is this useless garbage? Should I post it as a resource? It there any way to improve the code?
Theres a test map. Normal damage instances will be put out in strings like "Unit X dealt Y damage to unit Z", and theres a spell that, when used, will send a text message with just te value retrieved. Also note that i've put all armor effectiveness vs attack tipes to 100% in gameplay constants.
It works like this:
U = the "caster", whose dmg is being retrieved
T = the target, whose armor is being tested against u's damage.
When the user wants to detect damage, it call a "startDamage()" function inside a spell struct and creates a dummy unit ( via an system function ) that is a clone of U with all items and max atk speed ( 0.00 cooldown, 0.00 animations ). That dummy is ordered to attack T. When he does, a dmg detection trigger in fire and evaluate if that damage source is part of any of the active spell structs ( active structs are defined using "startDamage" ). If damage source == dummy, then in blocks all damage done by that dummy, kills the dummy and sends the damage var to the spell struct, while calling a specific method named "do_damage". That method will do whatever the spell does with the dmg retrieved and call "stopDamage", meaning the GetDmg process is over.
The thing is am not sure if this is really efficient, maybe its just better to have all units dmg saved in some vars, modifying it every time that unit levels up or gets an item.
Also, the way I looped the GetUnitDamageX static method was taken from T32 ( Jesus4Lyf ), it works for this system but im not sure if its the best option.
So any help with improving the system code and opinions on this are greatly appreciated.
Is this useless garbage? Should I post it as a resource? It there any way to improve the code?
Theres a test map. Normal damage instances will be put out in strings like "Unit X dealt Y damage to unit Z", and theres a spell that, when used, will send a text message with just te value retrieved. Also note that i've put all armor effectiveness vs attack tipes to 100% in gameplay constants.