System Damage

JASS:
function callback
-> If Damage_IsAttack() and //some percentage calculations here
       call Damage_Block()
       //create "miss" texttag 
endif

//Register trigger to Damage
 
JASS:
function callback
-> If Damage_IsAttack() and //some percentage calculations here
       call Damage_Block()
       //create "miss" texttag 
endif

//Register trigger to Damage

- i meant not register the miss as an attack in another trigger

JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    if Damage_IsAttack() then
    call Damage_BlockAll
    endif
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call Damage_RegisterEvent(gg_trg_Untitled_Trigger_001 )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction
------------------------------------------------------------------------------------------
function Trig_UntActions takes nothing returns nothing
    if Damage_IsAttack() and then //how to make false for the 'miss'
        call BJDebugMsg("attack")
    endif
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_002 = CreateTrigger(  )
    call Damage_RegisterEvent(gg_trg_Untitled_Trigger_002 )
    call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_UntActions )
endfunction
 
BUMP(?)
sorry for double posting but..
how can i make an event for the miss / not miss as per post #124? xD
 
JASS:
function Trig_UntActions takes nothing returns nothing
    if not Damage_IsAttack() then //like this?
        call BJDebugMsg("attack")
    endif
endfunction


but this will trigger everytime a spell damage or pure or physical damage happen..

so may you change the BJ to

JASS:
function Trig_UntActions takes nothing returns nothing
    if not Damage_IsAttack() then //how to make false for the 'miss'
        call BJDebugMsg("Spell missed")
    endif
endfunction
 
.. i cant seem to see the differences between the 1st and 2nd code you posted xD BJ? where?
i guess i wasnt clear in my explanation.
- there are 2 events, firing at the same time with the event a unit is damaged.
the first code had action damage_blockall, the second with damage_isattack(). is it possible for the 2nd trigger to obtain the final output of the damage taken, ie minus the damage from the damage_blockall? is there like a function in 'damage' that obtains the final damage done to the unit?
 
JASS:
library AttackManipulator requires Damage, Event

    globals
        private Event AttackEvent
        private Event MissEvent
    endglobals
    
    function RegisterMissAttack takes trigger whichTrigger returns nothing
        call MissEvent.register(whichTrigger)
    endfunction
    
    function RegisterAttacked takes trigger whichTrigger returns nothing
        call AttackEvent.register(whichTrigger)
    endfunction
    
    private function Cond takes nothing returns boolean
        if Damage_IsAttack() then
            if /*Miss Condition*/ then
                call Damage_BlockAll()
                call MissEvent.fire()
            else
                call AttackEvent.fire()
            endif
        endif
        return false
    endfunction
    
    private struct Initializer extends array
        private static method onInit takes nothing returns nothing
            local trigger trig = CreateTrigger()
            call Damage_RegisterEvent(trig)
            call TriggerAddCondition(trig,Condition(function Cond))
        endmethod
    endstruct
endlibrary


JASS:
function onInit takes nothing returns nothing
    local trigger trig = CreateTrigger()
    call RegisterMissAttack(trig)
    call TriggerAddCondition(trig,Condition(function Cond))
endfunction
 
is there like a function in 'damage' that obtains the final damage done to the unit?
Nope, but you can write that yourself.

So close, kingking! (See onInit change. ;))
JASS:
library AttackManipulator requires Damage, Event

    globals
        private Event AttackEvent
        private Event MissEvent
    endglobals
    
    function RegisterMissAttack takes trigger whichTrigger returns nothing
        call MissEvent.register(whichTrigger)
    endfunction
    
    function RegisterAttacked takes trigger whichTrigger returns nothing
        call AttackEvent.register(whichTrigger)
    endfunction
    
    private function Cond takes nothing returns boolean
        if Damage_IsAttack() then
            if /*Miss Condition*/ then
                call Damage_BlockAll()
                call MissEvent.fire()
            else
                call AttackEvent.fire()
            endif
        endif
        return false
    endfunction
    
    private struct Initializer extends array
        private static method onInit takes nothing returns nothing
            local trigger trig = CreateTrigger()
            // but you forgot these:
            set AttackEvent = Event.create()
            set MissEvent = Event.create()
            call Damage_RegisterEvent(trig)
            call TriggerAddCondition(trig,Condition(function Cond))
        endmethod
    endstruct
endlibrary

Very well done, though. (+rep.)
 
ok i attempted(failed) to make a function that obtains the final damage.
i tried to add a 'damage stack' but found that the OnDamageEvent.fire() fires the block damage either too early or too late.

snippet of what i did--i feel like im missing something/did it completely wrong

JASS:
globals
    private real array EventDamageEx//stack
endglobals   

function GetEventDamageEx takes nothing returns real
    return  EventDamageEx[TypeStackLevel]//stack
endfunction

private function OnDamageActions takes nothing returns boolean
    if EventEnabled then
        if GetEventDamage()==0. then
            call OnZeroDamageEvent.fire()
        else
            call OnDamageEvent.fire()
        endif
        set  EventDamageEx[TypeStackLevel] = GetEventDamage()
        if ToBlock[TypeStackLevel]!=0. then
//====================================================
        // Blocking
        set ForUnit=GetTriggerUnit()
                
        set NextHealth=GetEventDamage()
                
        if ToBlock[TypeStackLevel]>=NextHealth then
            set NextHealth=GetWidgetLife(ForUnit)+NextHealth
                set  EventDamageEx[TypeStackLevel] = 0//blockall
            else
                set  EventDamageEx[TypeStackLevel] = EventDamageEx[TypeStackLevel]  - ToBlock[TypeStackLevel]//block (real) 
                set NextHealth=GetWidgetLife(ForUnit)+ToBlock[TypeStackLevel]
            endif
            
// removed irrelevant code
//====================================================
            set ToBlock[TypeStackLevel]=0.
        endif
    endif
    return false
endfunction


what method to obtain the final damage output to do you recommend?
thankyou =D
 
GetEventDamage doesnt account for blocks made through this trigger. post #130 code i think only accounted for one scope(?) of an ability, not a general 'system' that covers for the final output done to a unit in one stack.

i found another 'bug' in my post #134 code--first instance of recovering the eventdamagex stack is 0.0. <-- it appears to be retrieving from stack-1. again, is there any solutions around this to correctly put the .fire events?

also, it is also possible to 'add' to the final damage. eg bonuses
- 50+ damage and increases per attack-this means that i will have to use damage_??? for the bonus damage
- + triggered/normal critical strike
- a triggered 'miss/critical strike' will only take into the account of geteventdamage ie, without the 50.

i tried and failed lol:
JASS:
    function AddUnitDamage takes real amount returns nothing
        set TypeStackDamage[TypeStackLevel] = TypeStackDamage[TypeStackLevel] + amount
    endfunction

    // ..
    set TypeStackDamage[TypeStackLevel] = TypeStackDamage[TypeStackLevel] - ToBlock[TypeStackLevel]
these globals i made non-public/private

sorry for being picky and stuff :p..
thankyou for your inputs though
 
bump? :p
questions (post 136)
- i found another 'bug' in my post #134 code--first instance of recovering the eventdamagex stack is 0.0. <-- it appears to be retrieving from stack-1. again, is there any solutions around this to correctly put the .fire events?
-also, it is also possible to 'add' to the final damage.
 
Just wanted to let you know I have in mind to get back to you, but this doesn't directly fall under system support... I think it would be a lot of work for me to seriously think about this, but I will consider it if I find time... :)

There is one problem, which is when you intend for your trigger to fire which needs to detect how much damage as been blocked. Especially if you use recursive damage. In which case, I agree, you need to attach to the damage stack some how. But then you need callbacks to flush your attachments as the damage stack increments... which becomes a pain. :(

Let me know what you think. :p
 
So, you can't get an accurate UNIT_STATE_MAX_LIFE in recursive damage events when calling Damage_BlockAll(), right?

JASS:
library test initializer asdf requires Damage
	globals
		private group g = CreateGroup()
		private unit target
	endglobals

	private function fdsa takes nothing returns nothing
		local unit u = FirstOfGroup(g)
		if u != null then
			call GroupRemoveUnit(g, u)
			call Damage_Pure(u, target, 10.)
		endif
	endfunction
	
	private function zxcv takes nothing returns boolean
		call fdsa()
		call Damage_BlockAll()
		call BJDebugMsg(R2S(GetUnitState(GetTriggerUnit(), UNIT_STATE_MAX_LIFE))) //Prints &quot;650.000&quot; &quot;500650.000&quot; &quot;500650.000&quot;
		return false
	endfunction
	
	private function vcxz takes nothing returns nothing
		local trigger t = CreateTrigger()
		call Damage_RegisterEvent(t)
		call TriggerAddCondition(t, Condition(function zxcv))
		call GroupEnumUnitsOfPlayer(g, Player(0), null)
		set target = FirstOfGroup(g)
		call GroupRemoveUnit(g, target)
		call fdsa()
	endfunction
	
	private function asdf takes nothing returns nothing
		call TimerStart(CreateTimer(), 1., false, function vcxz)
	endfunction
endlibrary
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top