which system should I use?

Nexor

...
Reaction score
74
I'm making a map with a damage detection system. this system allows the Heroes to have special effects on attacking (on damaging the target) like hex, entangling roots, etc.
My problem is that I want to save in a struct the items, the stats and other things and use it again at the damage part.
Which attachment system would be the best? I think this will require dynamic triggers, like Tinki3's Impetus spell
 

Romek

Super Moderator
Reaction score
963
Table or ABC are good, suitable and safe systems.

Note that the 1.23b patch (available from Westfall) makes H2I not work. So you may need to change which version of the systems you use before and after the patch.
Personally, I think you should just use the newest versions, and wait until 1.23b is stable and public. :)

I can't seem to get a link to Table. Wc3C isn't working.
 

Nexor

...
Reaction score
74
ABC's 6.1 version is compatible with 1.23b, yea, but will it work under 1.23 or less?
 

Romek

Super Moderator
Reaction score
963
No, version 6.1 won't work with 1.23 or less.
However, version 6.0 (available from the same thread) will work on 1.23 or less (but won't work on 1.23b or higher).
 

Nexor

...
Reaction score
74
okay. From now on this thread should be in the JASS section.

My next questions are how to use the ABC?
As far I have this trigger but can't continue :S:S
And ofc it isn't working


JASS:
library DMG

struct Dmg
    unit source
    integer S
    integer A
    integer I
    string WPN
    real CHANCE
endstruct

function AttackActions_2 takes nothing returns nothing
    // here should come the damage part
endfunction

function AttackActions takes nothing returns nothing
    local trigger t = CreateTrigger()
    local unit u = GetTriggerUnit()
    //local Dmg D = SetTriggerStructA(D,t) <-- isnt working:S don't know what to do with this one
    
    call TriggerRegisterUnitEvent( t, u, EVENT_UNIT_DAMAGED )
    call TriggerAddAction( t, AttackActions_2)
    
    set t = null
endfunction

//===========================================================================
function InitTrig_Attack takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddAction( t, function AttackActions )
    set t = null
endfunction

endlibrary
 

Romek

Super Moderator
Reaction score
963
You need to learn how to use structs before anything. :p

More than just the declaration.
 

Nexor

...
Reaction score
74
Woa, now it works, I post the code, are there any things that need to be changed?

JASS:
library DMG uses Library

private struct Dmg
    unit source
    unit target
    integer S
    integer A
    integer I
    string WPN
    real CHANCE
    trigger T
endstruct

function DamagedetectionConditions takes nothing returns boolean
    return GetUnitAbilityLevel(GetTriggerUnit(), 'Bssi') > 0 or GetUnitAbilityLevel(GetTriggerUnit(), 'Bspo') > 0 or GetUnitAbilityLevel(GetTriggerUnit(), 'Bssd') > 0
endfunction

function AttackActions_2 takes nothing returns nothing
    local Dmg d = GetTriggerStructA(GetTriggeringTrigger())
    local real damage = GetEventDamage()
    local unit target = d.target
    local unit source = d.source
    local player Sowner = GetOwningPlayer(source)
    local integer pi = GetPlayerId(Sowner)
    
    local integer level = 0
    local boolean crit = false
    local real random = GetRandomReal(0,100)
    local real finaldamage = 0
    local real critdamage = 0
    local string s
    local integer red = 255
    local integer blue = 255
    local integer green = 255
    
    local integer AGI = d.A
    local integer INT = d.I
    local integer STR = d.S
    local real power = 1
    local real chance = 0
    
    call BJDebugMsg(R2S(damage))
    
    debug if IsUnitType(source, UNIT_TYPE_HERO) == true then
        debug call ClearTextMessages()
        debug call DebugHero(source,"Current chance: "+R2S(random))
    debug endif
    if AGI > 0 then
        set chance = I2R(AGI)/3
        debug call DebugHero(source,"Crit chance: "+R2S(chance))
    endif
    if STR > 0 then
        set power = 1+I2R(STR)/20
        debug call DebugHero(source,"Power: "+R2S(power))
    endif
    
call DisableTrigger( GetTriggeringTrigger() )
    
    call UnitRemoveAbility(  target,'Bssi' )
    call UnitRemoveAbility(  target,'Bspo' )
    call UnitRemoveAbility(  target,'Bssd' )
    
    if random > chance then
        set s = I2S(R2I(damage))
        set critdamage = damage
        debug call DebugHero(source,"Normal")
    else
        set red = 255
        set blue = 0
        set green = 0
        set critdamage = damage * power
        set finaldamage = critdamage - damage
        set s = I2S(R2I(critdamage))+"!"
        set crit = true
        debug call DebugHero(source,"Critical")
    endif
    
    if IsUnitType(source, UNIT_TYPE_HERO) == true and d.WPN != "" then
        set s = SpecialProc(s,source,target,Sowner,d.WPN,d.CHANCE, critdamage)
    endif
    
    if finaldamage != 0 then
        call UnitDamageTargetBJ(source, target, finaldamage, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL)
    endif
    call FloatingText( target, Sowner, s, red, green, blue)
    
call EnableTrigger( GetTriggeringTrigger() )

    set target = null
    set source = null
    
    
    call DestroyTrigger(GetTriggeringTrigger())
endfunction

function AttackActions takes nothing returns nothing
    local trigger t = CreateTrigger()
    local unit u = GetTriggerUnit()
    local unit a = GetAttacker()
    local player p = GetOwningPlayer(a)
    local integer pi = GetPlayerId(p)
    local Dmg d = Dmg.create()
    
    set d.source = a
    set d.target = u
    set d.S = GetHeroStr(a,true)
    set d.A = GetHeroAgi(a,true)
    set d.I = GetHeroInt(a,true)
    set d.WPN = WEAPON[pi]
    set d.CHANCE = PROC[pi]
    set d.T = t
    
    call SetTriggerStructA(t,d)
    
    call TriggerRegisterUnitEvent( t, u, EVENT_UNIT_DAMAGED )
    call TriggerAddCondition( t, Condition( function DamagedetectionConditions ) )
    call TriggerAddAction( t, function AttackActions_2)
    
    set t = null
endfunction

//===========================================================================
function InitTrig_Attack takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddAction( t, function AttackActions )
    set t = null
endfunction

endlibrary


EDIT: some variables are of course global

EDIT 2: I read somewhere that triggeractions do leak, how should I remove this leak?
 

Akolyt0r

New Member
Reaction score
33
damage detection is really tricky, and can cause many errors if not coded >very< well.
So i would advides you to use a established system for your map, like: Light Leakless Damage Detect (LLDD), ADamage or IDDS

If you just started your map, i would use IDDS, if not i would recommend LLDD... ADamage seems to difficult for jass beginners, since it uses function interfaces and stuff.
 

Nexor

...
Reaction score
74
yeah I know there are damage detection systems, but I needed an accurate way to transfer the options the damage source has got on attack.

I don't want to use any other systems than this. I only ask you for help to make it leakless. Romek helped me by suggesting ABC. Now I got this system working. Yeah I know, there can't be any orb effects. And? I'll trigger them if I need them but now I'm making this system (well, not a system, it's a simple testing map) to the best I can. I need help at leaks and other stuff to make it cleaner.
 

Romek

Super Moderator
Reaction score
963
> I'm using this. Clear, short, flawless.
I use stuff like that to, though I tend to inline it.
It leaks an event when a unit is registered, then removed from the game somehow.

I don't care about that little leak. It's not game-breaking. In-fact. It doesn't affect the game at all probably. Especially when you choose which units to register.
 

Romek

Super Moderator
Reaction score
963
Just register a damage event on a trigger (Or use a condition, or w/e the system needs).
Then use the event responses.
 
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