Damage Engine v0.A.2

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.

Damage Engine


By: aznricepuff


Version: 0.A.2

Damage Engine is a damage detection and manipulation system. It also provides functionality for dealing triggered damage and using custom damage types.

As of v0.A.0 it also includes Heal Engine: an optional module for dealing with triggered
healing events.

Open the Demo Map in WE to view the system code and documentation.

Requires
  • jasshelper 0.9.Z.0+
  • Object Merger (by grimoire)
  • Table (by Vexorian)
  • TimerUtils (by Vexorian)
  • TreeMap

Changelog
For the full changelog refer to the demo map.

Keywords:
damage detection, damage manipulation, triggered damage, healing manipulation, triggered healing
Contents

Damage Engine v0.A.2 (Map)

Reviews
18 October 2011 Bribe - This is deprecated. The code is superfluous compared to what it could be. GUI Damage Engine does this better, and vJass users can take advantage of our superior vJass damage modifying systems.
Level 7
Joined
Aug 2, 2008
Messages
193
Hi,

you have to add [automethodevaluate] to the jasshelper.conf which is placed in the JNGP folder itself, not in the jasshelper folder in the JNGP.

@aznricepuff:
Could you maybe add something like this:

JASS:
scope Critical initializer onInit
    private constant real CRIT_CHANCE

private function actions takes EventDamage eventDamage returns nothing
    if GetRandomReal(0., 1.) <= CRIT_CHANCE then
        set eventDamage.damage = eventDamage.damage * BONUS_DMG
    endif
endfunction

private function onInit takes nothing returns nothing
    call DamageEngine_OnAnyUnitDamageEvent(actions)
endfunction

So you could call the actions function via a function interface and you don't have to create a new struct everytime and extend these in DamageEngine.
Cause I don't know, how hard it is for the performance, if I would extend more than 200 structs in DamageEngine....
And so it may be easier to create CustomSpells or do you have a better idea to make for example a spell, which increases the attackspeed of an attacked unit, when it has a specific buff and takes damage, without creating creating the struct for it to every unit on the map?
 
Level 7
Joined
Aug 2, 2008
Messages
193
In my opinion, the code is very good.
You just could put all of the structs in their own librarys or try to use them via modules...
But then you have to add very much requirements to other librarys, which require the damage engine...
And there is also enough documentations...
Their more than 5 documentation trigger alone for the damage engine und 4 or 5 for the optional heal engine.
 
Level 22
Joined
Dec 9, 2007
Messages
3,091
Every time I use the healTarget method, it runs 16 times.

Edit:
If you need to know the circumstances...
JASS:
struct HealHealer extends Healer
    static HealType ht
    
    method getHealType takes unit attacker, unit target returns HealType
        return .ht
    endmethod
    
    method isTarget takes unit attacker, unit target returns boolean
        return IsUnitAlly(target, GetOwningPlayer(attacker))
    endmethod
    
    static method onInit takes nothing returns nothing
        set .ht = HealType.create()
        call .ht.addFlag(HEAL_TYPE_POTION)
    endmethod
endstruct
...
JASS:
    function LFPotionUser takes real min, real max, unit healer, unit healed returns nothing
        call PotHeal.healTargetForced(healer, healed, GetRandomReal(min, max))
        call DestroyEffect(AddSpecialEffectTarget( VHSeffectLF, healed, "origin"))
    endfunction
...
JASS:
    private function ReplenishPotionUserByPotionExec takes nothing returns nothing
    
        if GetItemTypeId(GetManipulatedItem()) == 'I011' then
            call LFPotionUser(100.00, 200.00, GetTriggerUnit(), GetTriggerUnit())
        elseif GetItemTypeId(GetManipulatedItem()) == 'I012' then
            call LFPotionUser(200.00, 300.00, GetTriggerUnit(), GetTriggerUnit())
        elseif GetItemTypeId(GetManipulatedItem()) == 'I013' then
            call LFPotionUser(300.00, 400.00, GetTriggerUnit(), GetTriggerUnit())
        endif
        
        if GetItemTypeId(GetManipulatedItem()) == 'I01U' then
            call MFPotionUser(100.00, 200.00, GetTriggerUnit(), GetTriggerUnit())
        elseif GetItemTypeId(GetManipulatedItem()) == 'I01W' then
            call MFPotionUser(200.00, 300.00, GetTriggerUnit(), GetTriggerUnit())
        elseif GetItemTypeId(GetManipulatedItem()) == 'I01X' then
            call MFPotionUser(300.00, 400.00, GetTriggerUnit(), GetTriggerUnit())
        endif
        
    endfunction
...
Is everything okay with my functions?
 
Last edited:
Level 7
Joined
Aug 2, 2008
Messages
193
Try to put a
JASS:
return
behind every is like:

JASS:
//....
if GetItemTypeId(GetManipulatedItem()) == 'I011' then
    call LFPotionUser(100.00, 200.00, GetTriggerUnit(), GetTriggerUnit())
    return
elseif GetItemTypeId(GetManipulatedItem()) == 'I012' then
//....

So if one statement is true, the function automatically stops. And if the potions are used more then 1 time anylonger, it sould be affected from elsewhere.
 
Level 22
Joined
Dec 9, 2007
Messages
3,091
An item can only have 1 ID.
AND if one of those are true, it will NOT go to the other LF potions, it will check the MF potions! It's not that!
I've checked everything and I cannot find out the problem!

By the way, if it matters, the items which I used were charged items, made in the BX-TRS II system.
Another problems those items show:
(This)
Common Cooldown (No matter which cooldown group I choose.)
Not displaying Gold, Lumber or Mana cost.
All descriptions begin with a line I've never seen before: "Use this item to equip/show stats." - I've never wrote such a thing.

I'll see if I can fix HIS system in the weekend...
 
Level 4
Joined
Dec 20, 2008
Messages
66
Additional questions

Hello. This is confusing and very awesome work.
I readed the code a bit, i found that it has many, really many lines. I just want to know if is there any way to show to each player the damage that only his units deal, or take (if it is not done yet). I couldn't find it out from the code; I'm just begginer (or lazy if you want). However about 80% functions I wanted to have in my actual map, I found here :) I'm grateful to you and your assistants. This is the only think I'm not sure about.

Oh wait, here is one more question. Is it possible to print some error message, restore the mana cost and restart colldown of used ability when the player try to use damaging ability to friendly target, or to heal an enemy, with some easy way?

Thanks alot and sorry for these spamming quesstions :) Just the manual is quite long...
PS: Be sure about thank-you-line in my map loading screen, because this is really alot of work you done :thumbs_up:
 
Last edited:
Level 13
Joined
Feb 18, 2009
Messages
1,382
I couldn't download the map, i'm not at home, so from the screenshot i guessed, maybe it is some random map with a trigger.
 
Level 7
Joined
May 21, 2009
Messages
289
Do I HAVE to download all those other programs for this to work? And if so can someone point me in the right direction for a damage system that works for at least normal attacks and spells? I only need a system for normal attacks and spells, not triggered spells or healing if you know what I mean.
 
Level 7
Joined
May 21, 2009
Messages
289
ohhh that.... yeah so I cant use that because my latest anti-virus throws a hissy fit and kills that one tool that can be considered something you can use for hacking, otherwise I would already have it. And I'm not going to stop virus scanning just for this tool.
 
Top