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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • 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 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