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.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1

      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