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
964
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
964
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
964
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
964
> 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
964
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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top