System Damage

Sevion

The DIY Ninja
Reaction score
424
Just save it as .j

On the part where it says File Type: [DROP DOWN BOX]

Change it to All Types.

As for the syntax highlighting, you don't need the endfunctions' in there. Or the comments.

Just the [ljass]function NAME takes STUFF returns STUFF[/ljass] parts.
 

Sevion

The DIY Ninja
Reaction score
424
True, but mostly, I find that pop-up stuff really annoying as it blocks code underneath and I'm like stretching my neck around trying to see around it, then I decide to click away to get rid of the annoying box then have to reclick into the ('s to finish my code :p
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
So I tested your system in my map now for some hours and I'm really impressed ^.^
That finally opens the door to 'on damage'-events with nice performance and nothing leaking.
And your damage functions are so much better, easier to use. And the boolean checks are great as well.

Therefore you get one :thup: and another one :thup:

Edit:
Is there a way to make a single unit takes damage event that still can use your IsAttack() stuff etc.?
Because I have some things in mind for that a single unit takes extra damage when it got attacked with a certain skill. Now it would be unnecessary if that trigger tries to 'run' for every unit, performance-wise.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Personally, in my latest map I just check if the damaged unit has the ability. I only really care for efficiency in my low level or publicly released items of code.

However, actually everything will work fine if you define a "unit takes damage" event yourself, except damage blocking...

Edit:
>Now it would be unnecessary if that trigger tries to 'run' for every unit, performance-wise.
Think of how it is standard to run the trigger for 40 spells every time any spell is cast. (Although GTrigger resolves this.) Isn't really nasty though. I prefer nice code. :)
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Yah the performance loss is probably negligible ^^
After all I don't really know how that trigger events stuff is made in the Wc3 engine :O

However since you say everything still works expect the blocking part I may register it on a single unit since I don't have any intentions of blocking for that scenario, but I'll see.
Thanks for your fast answers ;P
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
You really need a better demo map. You didn't even gave examples on non-blocking damage. How do I get the event damage? There is no function for that, or am I missing something?
And how can I make for example an ability, that blocks damage only when the ability is active? All I saw now was a general condition that blocks all damage.
I'm confused and don't understand how it works.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
The it doesn't work ... I don't know why. Maybe you can see what is wrong here:

JASS:

private function Damage_text_Conditions takes nothing returns boolean
    local real amount = GetEventDamage()
    if DSabsorb[GetTriggerUnit()] > 0 then
        if DSabsorb[GetTriggerUnit()] >= amount then
            call Damage_Block(amount)
        else
            call Damage_Block(DSabsorb[GetTriggerUnit()])
        endif
        set DSabsorb[GetTriggerUnit()] = DSabsorb[GetTriggerUnit()] - amount
        if DSabsorb[GetTriggerUnit()] < 0 then
            set DSabsorb[GetTriggerUnit()] = 0
        endif
    endif
    if amount >= 1.00 then
        return true
    endif
    return false
endfunction

function Damage_text_Actions takes nothing returns nothing
...
endfunction

private function StartDamageText takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerAddCondition(t, Condition(function Damage_text_Conditions))
    call Damage_RegisterEvent(t)
endfunction
endscope

The function Damage_text_Actions never fires, though it should.
DSabsorb is a PUI Struct that always exists. That's not the problem.
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Would be better if you DebugMSG the Condition function to tell us where directly it isn't working.
 

Jesus4Lyf

Good Idea™
Reaction score
397
JASS:
private function StartDamageText takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerAddCondition(t, Condition(function Damage_text_Conditions))
    call Damage_RegisterEvent(t)
endfunction

-->
JASS:
private function StartDamageText takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerAddCondition(t, Condition(function Damage_text_Conditions))
    call TriggerAddAction(t, function Damage_text_Actions)
    call Damage_RegisterEvent(t)
endfunction

Should use a local var for [LJASS]DSabsorb[GetTriggerUnit()][/LJASS], by the way. But I understand if that's just an experiment or whatever.
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Weehh this system removed quite a lot of code from my current triggers already and improved so much. The blocking is working great as well and sure a hell of useful.
Seriously the most useful stuff I had so far.
I probably try out some of your other things as well. Especially since PandaMine isn't modding anymore and the HSAS System may no more be up to date.
Edit: Though it seems like your struct attachment systems attach to timers only. Whatever, will do for most parts ;P
 

Jesus4Lyf

Good Idea™
Reaction score
397
:)

Worth seeing is T32 for timer attachment (only for a period of 0.03125 though, and it isn't the easiest to use, but it is the most efficient) and AIDS for unit attachment (my fave attachment sys <3 AIDS structs).

KT2 is also good for timers when you can't use T32, although sometimes TimerUtils is better (see what you like, either are fine).

That's my rundown on attachment systems. Attaching to triggers is a little harder. I'd probably say use hashtables.

>Seriously the most useful stuff I had so far.
Thanks. I'm glad you have found it useful. :thup:
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
JASS:
private function StartDamageText takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerAddCondition(t, Condition(function Damage_text_Conditions))
    call Damage_RegisterEvent(t)
endfunction

-->
JASS:
private function StartDamageText takes nothing returns nothing
    local trigger t=CreateTrigger()
    call TriggerAddCondition(t, Condition(function Damage_text_Conditions))
    call TriggerAddAction(t, function Damage_text_Actions)
    call Damage_RegisterEvent(t)
endfunction

Should use a local var for [LJASS]DSabsorb[GetTriggerUnit()][/LJASS], by the way. But I understand if that's just an experiment or whatever.
Wow, LOL, what a stupid mistake. My bad. I'm drowning in shame :/ ...
Thanks ...

Well, the PUI Struct is fine for that variable, I think.
 

Jesus4Lyf

Good Idea™
Reaction score
397
What I mean is:
JASS:
private function Damage_text_Conditions takes nothing returns boolean
    local real amount = GetEventDamage()
    if DSabsorb[GetTriggerUnit()] &gt; 0 then
        if DSabsorb[GetTriggerUnit()] &gt;= amount then

-->
JASS:
private function Damage_text_Conditions takes nothing returns boolean
    local real dsAbsorb = DSabsorb[GetTriggerUnit()]
    local real amount = GetEventDamage()
    if dsAbsorb &gt; 0 then
        if dsAbsorb &gt;= amount then

And so on.

Maybe since you're doing a set operation ([LJASS]set DSabsorb[GetTriggerUnit()][/LJASS]) it isn't worth fixing anyway because you'd need to work around that a little anyway. I'm not personally fussed.
 

Weep

Godspeed to the sound of the pounding
Reaction score
401
Out of curiosity, what's the difference between resuming an expired 0 timer, and starting one anew?
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Resuming it double fires it for some reason, and I assume it's more efficient. :p
Double is the word :

JASS:
library TestResumeTimer initializer init

globals
    private integer I = 0
endglobals

private function Handler takes nothing returns nothing
    set I = I+1
    call BJDebugMsg(I2S(I))
endfunction

private function init takes nothing returns nothing
local timer tim = CreateTimer()
local integer i = 0

call TimerStart(tim,0.,false,function Handler)


call TriggerSleepAction(1.)

    loop
    exitwhen i == 100
    
        call ResumeTimer(tim)
    
    set i = i+1
    endloop

endfunction

endlibrary


Yes it's an unrealistic scenario, but as you see the timer is fired only two times, and this case isn't so incredible (4 - 5, whatever).

So instead, you would go to the timer expire event add add conditions / clear conditions
 
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