1. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  2. And she's bought a stairway to heaven. The 6th Special Effect Contest Results are here.
    Dismiss Notice
  3. Seek unity between the elements in the 22nd Terraining Contest Poll.
    Dismiss Notice
  4. Seize the moment! The 18th Mini Mapping Contest has commenced.
    Dismiss Notice
  5. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Damage Engine v0.A.2

Submitted by aznricepuff
This bundle is marked as substandard. It may contain bugs, not perform optimally or otherwise be in violation of the submission rules.

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
Moderator
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.
  1. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    That's pretty much impossible unless I inject something into WE that provides GUI support for just this system, which isn't going to happen.

    I think every dds is in JASS (pretty sure it's not possible in GUI...at least not in any useful way). And the point of this is object-oriented event handling, which I haven't seen in any dds I've used before.
     
  2. NoobMapmaker

    NoobMapmaker

    Joined:
    Oct 17, 2007
    Messages:
    550
    Resources:
    0
    Resources:
    0
    I've been looking for a system that just displays the damage amount with text over the damaged unit. It's pretty hard to find one I can work with after the 1.24 patch. I just need to be able to configure it in GUI. I can sorta read JASS, but not to the level that this system is written in. Can you make a simpler version with just the text display and custom spell damage?
     
  3. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    If you want damage display with my system, copy the following library into your map (along with Damage Engine):

    damage display

    Code (vJASS):

    library DamageDisplay requires DamageEngine

    globals
        constant integer DAMAGE_TEXT_RED = 0xff
        constant integer DAMAGE_TEXT_GREEN = 0xcc
        constant integer DAMAGE_TEXT_BLUE = 0x00
        constant integer DAMAGE_TEXT_SIZE = 10
        constant integer DAMAGE_TEXT_Z_OFFSET = 100.0
        constant integer DAMAGE_TEXT_FADE = 1.00
        constant integer DAMAGE_TEXT_LIFE = 2.00
    endglobals

    function CreateTT takes string text, integer r, integer g, integer b, real size, unit u, real z, real fade, real life returns nothing
        local texttag tt = CreateTextTagUnitBJ(text, u, z, size, r * 100 / 255.0, g * 100 / 255.0, b * 100 / 255.0, 0)
       
        call SetTextTagPos(tt, GetUnitX(u) - StringLength(text) * 5, GetUnitY(u), z)
        call SetTextTagVisibility(tt, true)
        call SetTextTagFadepoint(tt, fade)
        call SetTextTagLifespan(tt, life)
        call SetTextTagVelocity(tt, 0.0, 0.05)
        call SetTextTagPermanent(tt, false)
       
        set tt = null
    endfunction

    struct DisplayListener extends DamageListener
        static constant integer PRIORITY = 10
       
        static method create takes nothing returns DisplayListener
            return DisplayListener.allocate(.PRIORITY)
        endmethod
       
        method onFinalDamage takes EventDamage eventDamage returns nothing
            call CreateTT(I2S(R2I(eventDamage.damage)), DAMAGE_TEXT_RED, DAMAGE_TEXT_GREEN, DAMAGE_TEXT_BLUE, DAMAGE_TEXT_SIZE, eventDamage.target.u, DAMAGE_TEXT_Z_OFFSET, DAMAGE_TEXT_FADE, DAMAGE_TEXT_LIFE)
        endmethod
       
        private static method onInit takes nothing returns nothing
            call DamageEngine.registerDamageListener(DisplayListener.create())
        endmethod
    endstruct

    endlibrary
     

     
  4. NoobMapmaker

    NoobMapmaker

    Joined:
    Oct 17, 2007
    Messages:
    550
    Resources:
    0
    Resources:
    0
    Will it detect blizzard standard spells? if I make a custom GUI spell will the damage show when i trigger the damage or do I have to make it show manually using GUI?
     
  5. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    The damage will show.
     
  6. Vercas

    Vercas

    Joined:
    Dec 9, 2007
    Messages:
    2,604
    Resources:
    1
    Spells:
    1
    Resources:
    1
    You know something? I am tired of trying to make your system work for the JH ...Z.2+.
    I am tired of putting ".evaluate" to all your methods... and stuff like that for more than an hour.

    How about making it work with the latest jasshelper?
     
  7. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    It does work with the latest jasshelper. Force evaluate is off by default. Just dont put [forcemethodevaluate] in jasshelper.conf (or if you did, just comment it out).
     
  8. Vercas

    Vercas

    Joined:
    Dec 9, 2007
    Messages:
    2,604
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I do not have such a line in my jasshelper.conf
    The compile error says to add [automethodevaluate], and so I did. Anyway, it does not work.
    By the way, I have JassHelper Z.2
     
  9. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    Then get Z.5, or A.2.5.
     
  10. Vercas

    Vercas

    Joined:
    Dec 9, 2007
    Messages:
    2,604
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I must wait for an update to JNGPS then. >.>
     
  11. aznricepuff

    aznricepuff

    Joined:
    Feb 22, 2006
    Messages:
    749
    Resources:
    4
    Maps:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    4
    Can't you just replace the jasshelper.exe?
     
  12. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,793
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
  13. Kricz

    Kricz

    Joined:
    Aug 2, 2008
    Messages:
    183
    Resources:
    6
    Spells:
    6
    Resources:
    6
    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:

    Code (vJASS):

    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?
     
  14. Vercas

    Vercas

    Joined:
    Dec 9, 2007
    Messages:
    2,604
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I've updated JH and now it works. :xxd:
     
  15. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,220
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    This code is really awful :(. It's a mess, and that all in one library, that's totally awful.
    At least separate them and increase documentation, ALOT.
     
  16. Kricz

    Kricz

    Joined:
    Aug 2, 2008
    Messages:
    183
    Resources:
    6
    Spells:
    6
    Resources:
    6
    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.
     
  17. Vercas

    Vercas

    Joined:
    Dec 9, 2007
    Messages:
    2,604
    Resources:
    1
    Spells:
    1
    Resources:
    1
    Every time I use the healTarget method, it runs 16 times.

    Edit:
    If you need to know the circumstances...
    Code (vJASS):
    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

    ...
    Code (vJASS):
        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

    ...
    Code (vJASS):
        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: Nov 13, 2009
  18. Kricz

    Kricz

    Joined:
    Aug 2, 2008
    Messages:
    183
    Resources:
    6
    Spells:
    6
    Resources:
    6
    Try to put a
    Code (vJASS):
    return

    behind every is like:

    Code (vJASS):

    //....
    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.
     
  19. Vercas

    Vercas

    Joined:
    Dec 9, 2007
    Messages:
    2,604
    Resources:
    1
    Spells:
    1
    Resources:
    1
    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...
     
  20. gengar

    gengar

    Joined:
    Dec 20, 2008
    Messages:
    63
    Resources:
    0
    Resources:
    0
    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: Nov 20, 2009