System Damage

Sevion

The DIY Ninja
Reaction score
413
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
413
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
400
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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • 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!
  • 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

      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