'Damage' (System) Help

WolfieeifloW

WEHZ Helper
Reaction score
372
Hey there.
I've just 'installed' Damage, and am trying to convert all my spells over and I've already ran into problems :)().
I've created a 'DamageText' system to pair up with the Damage system.
It's here:
JASS:
scope DamageText initializer init
    
    private function Conditions takes nothing returns boolean
        local texttag tt
        
        set tt = CreateTextTag()
        call SetTextTagText(tt, I2S(R2I(GetEventDamage())), 8 * 0.023 / 10)
        call SetTextTagPosUnit(tt, GetTriggerUnit(), 0.)
        if (Damage_IsAttack()) then
            call SetTextTagColor(tt, 255, 255, 255, 255)
        elseif (Damage_IsSpell()) then
            call SetTextTagColor(tt, 255, 255, 0, 255)
        endif
        call SetTextTagPermanent(tt, false)
        call SetTextTagLifespan(tt, 2)
        call SetTextTagFadepoint(tt, 1)
        call SetTextTagVelocity(tt, 0, 0.05)
        set tt = null
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call Damage_RegisterEvent(t)
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction
        
endscope


Now, I'm trying to convert my Death Coil spell over, so I set the damage in the Object Editor to 0.
I then created this code:
JASS:
scope DeathCoilDK initializer init

    private function Damage takes integer level returns real
        return level * 10.
    endfunction

    private function Conditions takes nothing returns boolean
        call BJDebugMsg("Att: " + GetUnitName(GetAttacker()))
        call BJDebugMsg("EDS: " + GetUnitName(GetEventDamageSource()))
        call BJDebugMsg("Def: " + GetUnitName(GetTriggerUnit()))
        
        if (GetSpellAbilityId() == deathCoilDK) then
            call Damage_Spell(GetEventDamageSource(), GetTriggerUnit(), Damage(GetUnitAbilityLevel(GetEventDamageSource(), deathCoilDK)))
        endif
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call Damage_RegisterZeroEvent(t)
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction

endscope

No floating text is created, and the BJ's show this:
Att:
EDS:
Def: TargetUnit
So, I went ahead and set the damage of the Death Coil in the OE to 1, and tried the 'normal' event:
JASS:
scope DeathCoilDK initializer init

    private function Damage takes integer level returns real
        return (level * 10.) - 1
    endfunction

    private function Conditions takes nothing returns boolean
        call BJDebugMsg("Att: " + GetUnitName(GetAttacker()))
        call BJDebugMsg("EDS: " + GetUnitName(GetEventDamageSource()))
        call BJDebugMsg("Def: " + GetUnitName(GetTriggerUnit()))
        
        if (GetSpellAbilityId() == deathCoilDK) then
            call Damage_Spell(GetEventDamageSource(), GetTriggerUnit(), Damage(GetUnitAbilityLevel(GetEventDamageSource(), deathCoilDK)))
        endif
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call Damage_RegisterEvent(t)
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction

endscope

Note the change to the Damage function.
It now shows floating text that says '0', but the BJ's display the same thing.

What am I doing wrong?
 

Ayanami

칼리
Reaction score
288
Your code has some problems.

JASS:
scope DeathCoilDK initializer init

    private function Damage takes integer level returns real
        return level * 10.
    endfunction

    private function Conditions takes nothing returns boolean
        call BJDebugMsg("Att: " + GetUnitName(GetAttacker())) // a damage event doesn't have an attacker, only damage source (GetEventDamageSource()) and damaged unit (GetTriggerUnit())
        call BJDebugMsg("EDS: " + GetUnitName(GetEventDamageSource())) // i'm not sure why this isn't showing :/
        call BJDebugMsg("Def: " + GetUnitName(GetTriggerUnit())) // works fine I presume
        
        if (GetSpellAbilityId() == deathCoilDK) then // in a damage event, you can't have GetSpellAbilityId(), as the event doesn't refer to any ability cast, etc
            call Damage_Spell(GetEventDamageSource(), GetTriggerUnit(), Damage(GetUnitAbilityLevel(GetEventDamageSource(), deathCoilDK)))
        endif
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call Damage_RegisterZeroEvent(t)
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction

endscope


Instead of detecting for zero damage, why not just deal damage directly from the first place?

JASS:
scope DeathCoil initializer OnInit
    globals
        private constant integer ABILID = 'A000' // raw code of Death Coil
    endglobals

    private function OnCast takes nothing returns boolean
        call Damage_Spell(GetTriggerUnit(), GetSpellTargetUnit(), 100.) // deal the damage

        return false
    endfunction

    private function OnInit takes nothing returns nothing
        local trigger t = CreateTrigger()
        call GT_RegisterStartsEffectEvent(t, ABILID)
        call TriggerAddCondition(t, Condition(function OnCast))
        set t = null
    endfunction
endscope


Note that I used GTrigger. I recommend you use it too if you aren't.
 

tooltiperror

Super Moderator
Reaction score
231
GTrigger is a lot of bloat for stuff most people don't need, but I can't complain about that...

Anyways, Glenphir, you should be inlining your GT calls I guess, that's what the kids do these days, since GT_RegisterXEvent returns the trigger passed in.

JASS:
private function onInit takes nothing returns nothing
    call TriggerAddCondition(GT_RegisterStartsEffectEvent(CreateTrigger(), ABILID)), Condition(function OnCast))
endfunction


Also, nowadays it's onEvent, not OnEvent.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Do I need GTrigger?
I have Event (Obviously, a requirement of Damage).
Is there anyway to use what I already have as to avoid another system?
 

tooltiperror

Super Moderator
Reaction score
231
Don't try to avoid adding systems. That is foolish, and leads to making worse code.

GTrigger is really good. Let's say you have 50 spells in your map, as I assume you have something around that.

16 events generated per spell, that's 800 events being created.
With 50 spells, you are running 50 events every time a player casts any spell.

The solution is to use a trigger array, each trigger unique to a Spell ID. Or, to be simpler, use GTrigger. It's a really good system, and saves you a lot of events.
 

Ayanami

칼리
Reaction score
288
GTrigger is a lot of bloat for stuff most people don't need, but I can't complain about that...

Anyways, Glenphir, you should be inlining your GT calls I guess, that's what the kids do these days, since GT_RegisterXEvent returns the trigger passed in.

JASS:
private function onInit takes nothing returns nothing
    call TriggerAddCondition(GT_RegisterStartsEffectEvent(CreateTrigger(), ABILID)), Condition(function OnCast))
endfunction


Also, nowadays it's onEvent, not OnEvent.

I thought camel casing is for methods only? I always thought functions are capital case for the first letter @_@
 

Laiev

Hey Listen!!
Reaction score
188
most of system just don't care about the init function name, they use

function Init takes nothing returns nothing

or

function init takes nothing returns nothing
 

WolfieeifloW

WEHZ Helper
Reaction score
372
It semi-works now.
It deals damage correctly, but the damage text shows a yellow "10", and then a white "0".
How would I fix this? Maybe stop zero damage events from triggering the DamageText?

Here's the Death Coil script:
JASS:
scope DeathCoilDK initializer onInit

    private function Damage takes integer level returns real
        return level * 10.
    endfunction

    private function onCast takes nothing returns boolean
        call Damage_Spell(GetTriggerUnit(), GetSpellTargetUnit(), Damage(GetUnitAbilityLevel(GetTriggerUnit(), deathCoilDK)))
        return false
    endfunction

    private function onInit takes nothing returns nothing
        call TriggerAddCondition(GT_RegisterStartsEffectEvent(CreateTrigger(), deathCoilDK), Condition(function onCast))
    endfunction

endscope

Here's the DamageText script:
JASS:
scope DamageText initializer init
    
    private function Conditions takes nothing returns boolean
        local texttag tt
        
        set tt = CreateTextTag()
        call SetTextTagText(tt, I2S(R2I(GetEventDamage())), 8 * 0.023 / 10)
        call SetTextTagPosUnit(tt, GetTriggerUnit(), 0.)
        if (Damage_IsAttack()) then
            call SetTextTagColor(tt, 255, 255, 255, 255)
        elseif (Damage_IsSpell()) then
            call SetTextTagColor(tt, 255, 255, 0, 255)
        endif
        call SetTextTagPermanent(tt, false)
        call SetTextTagLifespan(tt, 2)
        call SetTextTagFadepoint(tt, 1)
        call SetTextTagVelocity(tt, 0, 0.05)
        set tt = null
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call Damage_RegisterEvent(t)
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction
        
endscope
 

Ayanami

칼리
Reaction score
288
This:
JASS:
scope DamageText initializer init
    
    private function Conditions takes nothing returns boolean
        local texttag tt
        
        if GetEventDamage() > 0 then
            set tt = CreateTextTag()
            call SetTextTagText(tt, I2S(R2I(GetEventDamage())), 8 * 0.023 / 10)
            call SetTextTagPosUnit(tt, GetTriggerUnit(), 0.)
            if (Damage_IsAttack()) then
                call SetTextTagColor(tt, 255, 255, 255, 255)
            elseif (Damage_IsSpell()) then
                call SetTextTagColor(tt, 255, 255, 0, 255)
            endif
            call SetTextTagPermanent(tt, false)
            call SetTextTagLifespan(tt, 2)
            call SetTextTagFadepoint(tt, 1)
            call SetTextTagVelocity(tt, 0, 0.05)
        endif

        set tt = null
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call Damage_RegisterEvent(t)
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction
        
endscope
 

dudeim

New Member
Reaction score
22
or change the isAttack() to isNormal() (i think that's how it's called) if it still doesn't work, it will register all normal attacks and normal damage dealt using the function provided.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Any optimization I could do to that, besides switching it over to GTrigger?
Nevermind, I don't need to use GTrigger, I think?


/EDIT: It still shows both numbers, even with using IsPhysical() instead of IsAttack().
JASS:
scope DamageText initializer init
    
    private function Conditions takes nothing returns boolean
        local texttag tt
        
        if GetEventDamage() > 0 then
            set tt = CreateTextTag()
            call SetTextTagText(tt, I2S(R2I(GetEventDamage())), 8 * 0.023 / 10)
            call SetTextTagPosUnit(tt, GetTriggerUnit(), 0.)
            if (Damage_IsAttack()) then
            //if (Damage_IsPhysical()) then
                call SetTextTagColor(tt, 255, 255, 255, 255)
            elseif (Damage_IsSpell()) then
                call SetTextTagColor(tt, 255, 255, 0, 255)
            endif
            call SetTextTagPermanent(tt, false)
            call SetTextTagLifespan(tt, 2)
            call SetTextTagFadepoint(tt, 1)
            call SetTextTagVelocity(tt, 0, 0.05)
        endif

        set tt = null
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call Damage_RegisterEvent(t)
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction
        
endscope
 

Laiev

Hey Listen!!
Reaction score
188
Damage_RegisterEvent

Don't register 0 damage, this is why we have a Damage_RegisterZeroEvent
 

dudeim

New Member
Reaction score
22
Instead of Death Coil spell use Channel and change it to your needs, channel is the ultimate custom spell as it can change the base order id and lots of other values too, and it doesn't deal damage so I think that might fix all your problems.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I'm using Damage_RegisterEvent, but it still shows a yellow 10, followed by a white 0 for some reason.
I really don't want to have to change all my spells over to Channel, but I guess it would be better..
 

Ayanami

칼리
Reaction score
288
Actually, it could be that the damage isn't 0, but maybe somewhere in between 0 and 1. Try displaying the real value rather than the I2S value.
 

Laiev

Hey Listen!!
Reaction score
188
I'm using Damage_RegisterEvent, but it still shows a yellow 10, followed by a white 0 for some reason.
I really don't want to have to change all my spells over to Channel, but I guess it would be better..

Whats the base ability of your spell?

Also, make sure that you set the damage in all fields to 0

No other trigger deals damage?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
The base ability is indeed Death Coil.
I didn't plan on using Damage, but I see it would be easier to use later on.

The damage for the level 1 field (What level I'm testing with) is 0.
And I'm quite certain no other trigger would be dealing damage.

And yeah...
The text is 10.000, then 0.500.
I have no idea where the half a damage is coming from though.


/EDIT: Changing the requirement to ">= 1" works though.
JASS:
scope DamageText initializer init
    
    private function Conditions takes nothing returns boolean
        local texttag tt
        
        if GetEventDamage() >= 1 then
            set tt = CreateTextTag()
            call SetTextTagText(tt, I2S(R2I(GetEventDamage())), 8 * 0.023 / 10)
            call SetTextTagPosUnit(tt, GetTriggerUnit(), 0.)
            if (Damage_IsAttack()) then
                call SetTextTagColor(tt, 255, 255, 255, 255)
            elseif (Damage_IsSpell()) then
                call SetTextTagColor(tt, 255, 255, 0, 255)
            endif
            call SetTextTagPermanent(tt, false)
            call SetTextTagLifespan(tt, 2)
            call SetTextTagFadepoint(tt, 1)
            call SetTextTagVelocity(tt, 0, 0.05)
        endif

        set tt = null
        return false
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call Damage_RegisterEvent(t)
        call TriggerAddCondition(t, Condition(function Conditions))
        set t = null
    endfunction
        
endscope

I have one quick question though.
Will showing the floating text to only the localplayer cause desyncs?
I want it so that only the person dealing that damage sees the text, or else your screen would get sort of crowded with everyone's damage.
Just like:
JASS:

Is this even possible with Damage?
Wouldn't it be like, [ljass]GetOwningPlayer(GetEventDamageSource())[/ljass] or something?
 

Ayanami

칼리
Reaction score
288
Do note that using GetLocalPlayer() can cause de-syncs. I heard this happens when you create a handle for the local player. So if you were to create the floating text for GetLocalPlayer(), I believe that would cause a de-sync. Laiev did it in a way that hides the floating text, and not creating it. Thus, it won't cause de-sync. Just saying in case you don't know.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Yeah, I knew it was when handles were created.
I just had trouble finding the texttag thing to see what it extended.
Of course, I found it right after posting :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/
  • The Helper The Helper:
    Here is another comfort food favorite - Million Dollar Casserole - https://www.thehelper.net/threads/recipe-million-dollar-casserole.193614/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top