System Damage

Troll-Brain

You can change this now in User CP.
Reaction score
85
It was a joke.
You can fix it easily in a reasonnable efficient way, but you just don't care, like it is a personal resource and not a public one.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Nevermind, i was wrong.
I thought the timer needed to be fired each time, but i've realized it's not the case after i've read the code.
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
Okay here is a thing i need to do.

I have a spell on a hero that adds X damage to him for 1 attack.
When the spell is activated i give the hero Item Damage Bonus Ability and set it's level to the appropriate level.

Now i need to be able to detect when this unit attacked a target in order to remove the damage, but if i use a Unit is Attacked event and remove damage than it will not work correctly. Why?

because the damage is determined when the missile hits the target thus if i remove the ability before this happens the attack wont deal that X bonus damage.

The way i know this problem is solved is by adding an ability such as Item Attack Frost Damage Bonus and doing this:

hero attacks a unit
create a new trigger
register UnitTakesDamage event for the attacked unit
check weather the damage taken is >1 - to prevent effect if dmg is blocked
check weather the damage dealer = hero - to only trigger when the hero dmges him
check weather the unit has debuf XY - to see if the heroe's ATTACK actually did the damage, because hero could theoretically use a spell dealing damage to the target before the attack missile hit him.

if all these conditions passed however it would mean that the hero attacked the target, and the target was dealt damage from a hero while having a buff that heroe's attack leaves so basically hero did attack the target and the missile hit him.

if the conditions passed than the attack was made and buff is removed from a target and Item Damage Bonus was removed from the hero.

Now my question
What would your system actually contribute to me?
I mean what can i do with it, I've read that it allows me to block damage (currently don't need that), deal damage (i can do that with normal functions can't I?) and detect damage, basically this is what i need.

But by detect damage what do you mean?
Can i detect by who was the damage done?
Can i detect did the damage come from a REAL attack?

If yes than just name the functions that are used for doing these two things.
The way i see it your system allows us to detect damage type, which isn't good enough, there could be physical spells, or rather spells that are triggered to deal physical damage.

Told you it would be better over the msn :D
If you don't mind take a look at this

Basically i did what i explained here but the GetEventDamage only works if i attack my units, it wont work on enemies. dont know why?
 

Jesus4Lyf

Good Idea™
Reaction score
397
>Told you it would be better over the msn
And I said read the documentation, but neither of us listened. :p

>What would your system actually contribute to me?
Answered in documentation and demo map.

>deal damage (i can do that with normal functions can't I?
Answered in documentation.
JASS:
//          It also provides a means to detect what type
//          of damage was dealt, so long as all damage in your map is dealt using
//          this system's deal damage functions (except for basic attacks).


If you have a perfect Damage implementation (ie. deal damage through the Damage functions), your mash of trigger stuff for removing your ability on attack becomes this:
JASS:
scope RemoveItemDamageBuff initializer OnInit
    globals
        private constant integer BONUS_ABIL='A00X'
    endglobals
    private function OnDamage takes nothing returns boolean
        if Damage_IsAttack() then
            call UnitRemoveAbility(GetEventDamageSource(),ABIL)
        endif
        return false
    endfunction
    private function OnInit takes nothing returns nothing
        local trigger t=CreateTrigger()
        call TriggerAddCondition(t,Filter(function OnDamage))
        call Damage_RegisterEvent(t)
    endfunction
endscope

>But by detect damage what do you mean?
See the [LJASS]Damage_RegisterEvent(t)[/LJASS] line above. It registers when any unit is damaged. :)

>Can i detect by who was the damage done?
Yes: [LJASS]GetEventDamageSource()[/LJASS]

>Can i detect did the damage come from a REAL attack?
Yes, with a perfect Damage implementation (all spell damage dealt by Damage_Spell(...), all pure damage dealt by Damage_Pure(...), etc, see documentation): [LJASS]Damage_IsAttack()[/LJASS]

>The way i see it your system allows us to detect damage type, which isn't good enough, there could be physical spells, or rather spells that are triggered to deal physical damage.
Use global booleans, I can't write your whole map for you. :p

>dont know why?
Unsure. To be honest, since I know this works, I don't intend to read 50 versions of people coming up with it themselves and not having it work...
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
I read the documentation.....2-3 times...
map says nothing, just blocks all damage...

1.1
okay so i would deal damage with you functions and thus enable me to detect if the damage done is spell/attack/physical/pure....

The IsAttack basically detects what?
If i was to use the
JASS:

Physycal(hero,target,200.00,ATTACK_TYPE_NORMAL,true,false)
//pay attention to the last 2 parameters

would it get detected by the IsAttack?

1.2
do i have to keep the last 2 parametars false,false in order for it not to get detected?

What i need is this:
Being able to deal physical damage through triggers (because it takes reduction by armor, not by spell resistance).
But make it so i can choose is it detected by IsAttack.

What i meant by "can i detect did the damage come from REAL attack" is did the damage come from the actual attack rather than a triggered damage.
The actual enemy unit attacking me, not the one that i made by trigger, can THAT be detected.
to clerify:
footman has 11-13 damage and attacks me, will this get detected?
triggered spell does X damage, will this get detected
triggered spell 2 does Y damage, can i make this NOT get detected?


for example:
execute - deals X physical damage (doesnt count as attack) is not detected by IsAttack
mighty strike - deals Y physical damage (counts as attack) and it is detected by IsAttack.

I do not understand your TypeStackValue, TypeStackAttack and TypeStackLevel variables otherwise i could answer those questions myself probably, what do you accomplish with them, what are they suppose to suggest to the functions?

1.3
thanks for posting the trigger code to solve my problem but i got cupple of questions on it:
This will try to remove the ability from any unit that deals damage correct, providing that the IsAttack check was passed?
If yes than it is ok, providing that Damage_IsAttack only passess when damage is done with actual attack (pressing A and left clicking a unit), not if it is physical check, but guess yo uwill answere that in the previous question (1.2).


1.4 :banghead::banghead:
i ask you again to please just take a look at what i posted, the whole thing works perfectly when i attack allied units, but it wont work on enemies, problem is i did not use a SINGLE player related check in the whole thing and it wont pass the GetEventDamage > 1.0 check, even though the unit is clearly damaged which can be seen by selecting him.:banghead:
 

Jesus4Lyf

Good Idea™
Reaction score
397
>I read the documentation.....2-3 times...
Perculiar.

>would it get detected by the IsAttack?
JASS:
//          function Damage_IsAttack takes nothing returns boolean
//              - Checks if the damage is from a physical attack (so you can deal
//                physical damage without it being registered as an actual attack).

JASS:
//          function Damage_Physical takes unit source, unit target, real amount,
//            attacktype whichType, boolean attack, boolean ranged returns boolean
//              - A clean wrapper for physical damage.
//              - 'attack' determines if this is to be treated as a real physical
//                attack or just physical type damage.
//              - 'ranged' determines if this is to be treated as a ranged or melee
//                attack.

So "yes". As the second dot point is suggesting.

>do i have to keep the last 2 parametars false,false in order for it not to get detected?
Just the first one. But generally, yea you'd put both on "false" for a spell that deals physical damage.

>i ask you again to please just take a look at what i posted
I don't think I have time. I also don't have WC3 with me, usually.

Btw,
>This will try to remove the ability from any unit that deals damage correct
Originally I had a check to see if the unit had the ability, then I realised that removing the ability will simply fail it the unit doesn't have it, so there is no need for a check (it does the check itself anyway)... :)
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
okay thanks for the explenation on the posibility of the detecion with is attack and physical spells.

However, would you be so kind to in short terms elaborate how does the IsAttack know when the damage came from a regular attack?

I understand that you can check the function you made but how do you check it when the damage did not came from one of your functions, but rather by a regular wc3 spell or attack. I am just interested in can it be check or not, dont really have to bother explaining the whole thing.
So basically the question would be:

Okay the IsAttack can get the result of an damaging attack that came from your function, but can it differ the regular attack from a regular warcraft spell? or does it always have a TRUE return value for damages that did not come thought your functions?

About checking my post, well whenever you catch a moment of laziness that you dont know what you can do, i dont need it answered urgent or anything just looked upon, it is a very anoying thing because everything should be fine i checked the whole code over 10 times, what i written there is just a part of the code in which the error is happening not the whole thing, and it aint big tbh.

I will try to use this system if i manage to get AIDS to work, they give me an error.....

thanks in advance
 

Jesus4Lyf

Good Idea™
Reaction score
397
>does it always have a TRUE return value for damages that did not come thought your functions?
Correct. Actually, WC3 spells that deal damage must instead deal 0 damage and have triggered damage coming from [LJASS]Damage_Spell(source,target,amount)[/LJASS] calls as well.

>However, would you be so kind to in short terms elaborate how does the IsAttack know when the damage came from a regular attack?
Eh, it reads from a stack where the bottom level is permenantly "true" and the other levels are for Damage_X calls where level 1 is a basic call and level 2+ is recursion in Damage_X calls. :thup:
 

W!†A_cRaft

Ultra Cool Member
Reaction score
28
okay thanks for explanation, when i figure out how to use it i will most likely give a comment on what i couldn't have done :p
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Um, what? Doesn't that utterly break detection of to-be-triggered spell impacts?
 

Lobster

Old Fogey ofthe site
Reaction score
90
Could you make a function or two that allows different types of damage to deal different damage to different types of armor?
 

Jesus4Lyf

Good Idea™
Reaction score
397
Could you make a function or two that allows different types of damage to deal different damage to different types of armor?
Two things.

Warcraft III has this built in. Using physical damage types you can accomplish this.

That functionality, if not achievable by what's in Warcraft III, belongs in a different system of its own.
 

Viikuna

No Marlo no game.
Reaction score
265
You just need some 2d array for damage and armor types, and then some first priority damage event to modify the actual damage dealt before other damage triggers fire.

And even though wc3 has something like this already, it sucks, because its not dynamic.

But then again, if you make something like this dynamic, it sucks too, because theres no dynamic tooltips, which means that it will end up looking fucking ugly.



Anyways, I still think you should add priority events to Event. This thing that guy is asking is perfectly possible with Rising_Dusks damage detection system, just because of priority events, and it would be shame if this could not do that stuff too.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Does anyone have problem with my removing it? I'd always intended to take it out...
While I can't really say because I'm not using Damage, I'm confused because I thought that 0 damage spells were the entire foundation of how to use Damage in a map to discern between attacks and spells. :confused:
 

Jesus4Lyf

Good Idea™
Reaction score
397
Anyways, I still think you should add priority events to Event. This thing that guy is asking is perfectly possible with Rising_Dusks damage detection system, just because of priority events, and it would be shame if this could not do that stuff too.
That's like saying Magic Numbers are a better solution than labelled constants.
JASS:
library ArmorTypes
    globals
        private hashtable Store=InitHashtable()
        private constant key ARMOR_TYPE
        private constant key DAMAGE_TYPE
    endglobals
    function SetUnitTypeArmor takes integer unitType, integer armorType returns nothing
        call SaveInteger(Store,unitType,ARMOR_TYPE,armorType)
    endfunction
    function SetUnitTypeDamage takes integer unitType, integer damageType returns nothing
        call SaveInteger(Store,unitType,DAMAGE_TYPE,damageType)
    endfunction
    function SetDamageArmorFactor takes integer damageType, integer armorType, real factor returns nothing
        call SaveReal(Store,damageType,armorType,factor)
    endfunction
    
    private function GetUnitArmor takes unit u returns integer
        return LoadInteger(Store,GetUnitTypeId(u),ARMOR_TYPE)
    endfunction
    private function GetUnitDamage takes unit u returns integer
        return LoadInteger(Store,GetUnitTypeId(u),DAMAGE_TYPE)
    endfunction
    private function GetDamageArmorFactor takes integer damageType, integer armorType returns real
        return LoadReal(Store,damageType,armorType)
    endfunction
    private function GetUnitToUnitFactor takes unit source, unit target returns real
        return GetDamageArmorFactor(GetUnitDamage(source),GetUnitArmor(target))
    endfunction
    
    //globals
    //    boolean Damage_IsSpecial=false
    //endglobals
    function DealDamage takes unit source, unit target, real amount returns nothing
        //set Damage_IsSpecial=true // so you could lifesteal on special damage being dealt.
        call Damage_Pure(source,target,amount*GetUnitToUnitFactor(source,target))
        //set Damage_IsSpecial=false
    endfunction
    
    private function OnDamage takes nothing returns boolean
        if Damage_IsAttack() then
            call Damage_BlockAll()
            call DealDamage(GetEventDamageSource(),GetTriggerUnit(),GetEventDamage())
        endif
        return false
    endfunction
    
    private struct Init extends array
        private static method onInit takes nothing returns nothing
            local trigger t=CreateTrigger()
            call TriggerAddCondition(t,Filter(function OnDamage))
            call Damage_RegisterEvent(t)
        endmethod
    endstruct
endlibrary

What you're talking about has nothing to do with event priorities. And it shouldn't be done with event priorities. It should be done with a hierarchy of events, if necessary. Here's another example:
JASS:
library Logic
    globals
        Event EvasionCheck // Event priorities without magic numbers.
        Event ResistanceCheck
        Event BlockCheck
        Event LifestealCheck
    endglobals
    
    globals
        private real CurrentDamage
    endglobals
    
    function CancelDamage takes nothing returns nothing
        set CurrentDamage=0
    endfunction
    function ReduceDamage takes real amount returns nothing
        set CurrentDamage=CurrentDamage-amount
    endfunction
    function GetCurrentDamage takes nothing returns real
        return CurrentDamage
    endfunction
    
    private function OnDamage takes nothing returns boolean
        if Damage_IsAttack() then
            set CurrentDamage=GetEventDamage()
            call Damage_BlockAll()
            
            if CurrentDamage>0 then
                call EvasionCheck.fire()
                if CurrentDamage>0 then
                    call ResistanceCheck.fire()
                    if CurrentDamage>0 then
                        call BlockCheck.fire()
                        if CurrentDamage>0 then
                            call LifestealCheck.fire()
                            call Damage_Pure(GetEventDamageSource(),GetTriggerUnit(),CurrentDamage)
                        endif
                    endif
                endif
            endif
            
        endif
        return false
    endfunction
    
    private struct Init extends array
        private static method onInit takes nothing returns nothing
            local trigger t=CreateTrigger()
            call TriggerAddCondition(t,Filter(function OnDamage))
            call Damage_RegisterEvent(t)
            
            set EvasionCheck=Event.create()
            set ResistanceCheck=Event.create()
            set BlockCheck=Event.create()
            set LifestealCheck=Event.create()
        endmethod
    endstruct
endlibrary

Look, it's like priority events, but with lots more maintainability and efficiency! (Only the correct events fire in the sequence, if it was cancelled, no O(n) complexity adding, labelled constants instead of "magic numbers", etc.)

Notice how short these little libraries are. Damage is a support system, if users want evasion to register a change in damage or some such, they should add a level like the above. Takes a few minutes to write, and makes lots of sense...
Edit:
While I can't really say because I'm not using Damage, I'm confused because I thought that 0 damage spells were the entire foundation of how to use Damage in a map to discern between attacks and spells. :confused:
Well, detecting 0 damage is only needed on projectile spells, and isn't a guarantee of which spell actually hit the unit. I'm willing to revert this if I'm denying people functionality, though. It's just there's no way to stop faerie fire from counting as a physical attack dealing 0 damage...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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