System Damage

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.
 
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.
 
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?
 
>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...
 
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:
 
>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)... :)
 
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
 
>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:
 
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
 
Um, what? Doesn't that utterly break detection of to-be-triggered spell impacts?
 
Could you make a function or two that allows different types of damage to deal different damage to different types of armor?
 
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.
 
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.
 
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:
 
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.
  • Varine Varine:
    And since almost all of my programming experience is with defunct shit now, I figure my best place is helping preserve legacy stuff. Which I don't know how to do necessarily, but I need some kind of a hobby and figuring out how older things worked is the only shit that really interests me. Well soldering and restoration is fun too, but no one is bringing me new stuff to fix and restore, so it's mostly old shit, and I LOVE OG Xbox so much. I want to make sure it can function as long as possible, until someone can effectively emulate it at least. I have like 15 I was going to fix over the winter and didn't get to.
    +1
  • Varine Varine:
    I also have a couple OG gameboys, but idk if I can do that without like, manufacturing new parts that no one makes anymore and I can't do that right now
  • tom_mai78101 tom_mai78101:
    Currently in the middle of getting the probate process going. We're doing the informal probate process.
    +3
  • Varine Varine:
    A probate is usually done with a will, yes? If so I am sorry for your loss
    +1
  • The Helper The Helper:
    Yeah Tom, me too sorry for your loss buddy my mom told me she finds out her olds friend died from Google searching them. She had not talked to one of her old friends in a year and found out she died from Google. Also another one in the same session. RIP all of them my sincere condolences Tom
    +1
  • Varine Varine:
    We have some elderly guests that regularly come hang out at the bar at the end of the night, and every once in a while we don't see someone for a few weeks and then someone shows up with their obituary.
  • Varine Varine:
    We usually let them do their memorials there in the morning if they want to and I'll make them some snacks and drinks. There was one guy named Tom that came in like every night and would sit by himself and get a bunch of soup and a glass of wine. idk why but he LOVED our fucking soup, like he would order a fucking quart of it at a time and would always get so sad when we stop doing it for the summer.
    +1
  • Varine Varine:
    But he also loved our calamari, which is another thing I hate but it sells super well so I can't change it. There was one day he came in and was asking me how to make it, because he tried to at home once in the off season when we stop running it and he really wanted it lol
  • Varine Varine:
    I think he's one of the only people I've made recipes for for free because he really wanted a broccoli cheddar, and it was like dude I don't have a recipe, it's just whatever I have, but here, this is how you do it
  • Varine Varine:
    I don't think he ever figured out how to do the calamari in a pan though, like idk how to do that either. He was afraid of the at home deep fryers though and it's like yeah, that's fair, I am too
  • Varine Varine:
    He was just such a sweet old man, we had two servers pregnant and they held a baby shower together, he was soooooo fucking excited to get to see a baby. Unfortunately he died a month or so before they were born
  • The Helper The Helper:
    So I decided to Google some people that I had not seen or heard from in a while and sure enough one of my old best friends, we had a falling out years ago but whatever, find out he died of Pancreatic Cancer in January. I have also lost a few of my closer acquaintances from growing up the last year. Getting old - people die - I kinda thought it was going to be this way a few years ago....
    +2
  • The Helper The Helper:
    Forum running super slow again
  • Ghan Ghan:
    Not really clear from the stats as to what is causing the slowness.
  • Ghan Ghan:
    We get a lot of guest traffic so it may just be the load is getting too high and not from any particular source.
  • Ghan Ghan:
    Looks like the server is maxed out on CPU.
  • Ghan Ghan:
    Oh it looks like a lot of the traffic is Silkroad Forums. That domain isn't protected by Cloudflare.
  • Ghan Ghan:
    But the old Silkroad site is still on its own server. I just had a test site set up on this server for it.
  • Ghan Ghan:
    I just disabled that test site. Let's see if that helps the load.
  • Ghan Ghan:
    Looks much better already.
  • The Helper The Helper:
    I had actually forgot about the Silkroad site. I had asked
  • The Helper The Helper:
    SD Ryoko about it and he said the couple of people left on there really like it, that was a few years ago, maybe I should check back
  • jonas jonas:
    I guess when you're getting old, and the last day of soup season draws near, you start wondering
  • jonas jonas:
    will I make it to the start of the next season? or was this the last time I'll ever have my favorite dish?
  • The Helper The Helper:
    I am doing my first Vibe Coding project. In installed the environment and tools according to instructions but it is all chat doing this for me at my direction. It is fun really and holy shit I might finish in 2 hours what it would have taken a day to in my Access and this would be an electron app complete new

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top