System Status

Weep

Godspeed to the sound of the pounding
The stun spell is set to target Air, Enemy, Friend, Ground, Invulnerable, Neutral, Organic, Vulnerable. Wouldn't that prevent casting on mechanical units?

Invulnerable, Vulnerable ought to be sufficient.
 

Hatebreeder

So many apples
100% correct. Updated and credit note updated. Thanks.

Mod review? :D
Hey Jesus, i got a question:
Is AddStun(Unit,Timeout) Stackable?
For instance; Lets say you "stormbolt" (using AddStun), and stun for 3 seconds. 1 Second later, someone else uses the same ability to stun. Will it Stun for 5 Seconds?
 

Hatebreeder

So many apples
AIDS stands in place of PUI - if you use PUI you can delete it and replace it with AIDS and keep pretending you have PUI. But then you can use AIDS resources. :)

(But you should read the documentation on this.)

Otherwise, yes they conflict.
Bummers ! >_<
 

quraji

zap
That is now fixed (v1.1.3), I move for this to be approved. :thup:
:thup:

I actually really like this. Works well and is very simple (in interface and implementation). The only thing I would say it's missing is an AddTimedStun function. I can understand why you wouldn't want to include one, but it seems like an essential part of a stun system (as it will be how most stuns will be used).

So, I tweaked a version to add this functionality and fix something I saw as a possible issue. It also gave me a chance to play with the new [ljass]static if[/ljass]:
JASS:

library Stun initializer OnInit uses AIDS, DummyCaster, optional KT, optional TimerUtils
    globals
        public constant integer BUFF='Bstn'
        private constant integer ABIL='Astn'
        private constant integer OID_FIREBOLT=852231
    endglobals
    
    //====================================================================
    // AIDS struct for efficiently storing the &quot;level&quot; of stun for a unit.
    private struct StunData extends array
        integer level
        private static method AIDS_filter takes unit u returns boolean
            return GetUnitAbilityLevel(u,'Aloc')==0
        endmethod
        private method AIDS_onDestroy takes nothing returns nothing
            set this.level=0
        endmethod
        //! runtextmacro AIDS()
    endstruct
    
    //====================================================================
    // Functions.
    public function IsUnitStunned takes unit u returns boolean
        return GetUnitAbilityLevel(u,BUFF)&gt;0
    endfunction
    
    function AddStun takes unit target returns nothing
        local StunData data=StunData[target]
        set data.level=data.level+1
        call IssueTargetOrderById(DUMMY,OID_FIREBOLT,target)
    endfunction
    
    /* qEdit: Added a check to make sure a stun is only &quot;removed&quot; from a unit if there is one present.
     *          This ensures that if a user accidentally uses RemoveStun extra times, it wont break.
     */
    function RemoveStun takes unit target returns nothing
        local StunData data=StunData[target]
        if data.level&gt;0 then
            set data.level=data.level-1
        endif
        if data.level==0 then
            call UnitRemoveAbility(target,BUFF)
        endif
    endfunction
    
    /* qAdd: adds following function and automatically implements either TimerUtils or KT if they are present in the map
     * function AddTimedStun(unit target, real time)
     *     -stuns &lt;target&gt; for &lt;time&gt;
     */
    static if LIBRARY_TimerUtils then
    // timer utils first, it's better for one-shot timers, right?
        private struct tu_data
            unit u
        endstruct
        
        private function tu_RemoveTimedStun takes nothing returns nothing
            local tu_data d = GetTimerData(GetExpiredTimer())
            call RemoveStun(d.u)
            call d.destroy()
        endfunction
        
        function AddTimedStun takes unit target, real time returns nothing
            local timer t = NewTimer()
            local tu_data d = tu_data.create()
            set d.u = target
            call AddStun(target)
            call SetTimerData(t, d)
            call TimerStart(t, time, false, function tu_RemoveTimedStun)
        endfunction
        
    elseif LIBRARY_KT then
    
        private struct kt_data
            unit u
        endstruct
        
        private function kt_RemoveTimedStun takes nothing returns boolean
            local kt_data d = KT_GetData()
            call RemoveStun(d.u)
            call d.destroy()
            return true
        endfunction
        
        function AddTimedStun takes unit target, real time returns nothing
            local kt_data d = kt_data.create()
            set d.u = target
            call AddStun(target)
            call KT_Add(function kt_RemoveTimedStun, d, time)
        endfunction
    endif
    
    //====================================================================
    // Initialiser.
    private function OnInit takes nothing returns nothing
        call UnitAddAbility(DUMMY,ABIL)
    endfunction
endlibrary


Now of course you don't have to pay attention to this, but I thought I'd post it.

Once again nice little system.
 

quraji

zap
I agree, I don't think it's necessary to approval as the system is useful enough without the timed function. That doesn't make a self-expanding system any less cool though :p

Although I do think you should include the RemoveStun safety as I think it is plausible that someone call it too many times and put the stun level into the negative.
 

Jesus4Lyf

Good Idea™
Bump for approval.

>Although I do think you should include the RemoveStun safety as I think it is plausible that someone call it too many times and put the stun level into the negative.

That should not be plausible - it could then remove stuns it didn't create... But I should add debug messages if you do this.
 

quraji

zap
That should not be plausible - it could then remove stuns it didn't create... But I should add debug messages if you do this.
Well the problem isn't just removing stuns that aren't aren't yours, but it's also that if there stun level is 1 and you accidentally remove it twice (or if the stun level is 0 for that matter), then you have a problem.

Attached is a test map that gives an example of what I mean (in a believable way).

Even if it's not likely it could happen, breaking stuns for that unit.
 

Attachments

Jesus4Lyf

Good Idea™
That's the situation in which you would want a debug message, and not just a set-to-0 instead of -1. Let's say you had a massive 30 second stun spell, casting that smaller spell would remove that big stun, and if you stunned the unit again right before the end, it would only last a fraction of a second. :)

That's why I intend to add the debug message, but not the protection (because the protection would allow the system to behave incorrectly - doesn't actually solve anything <_<).
 

quraji

zap
Let's say you had a massive 30 second stun spell, casting that smaller spell would remove that big stun, and if you stunned the unit again right before the end, it would only last a fraction of a second. :)
Not sure what you mean. All I know is that there should only be as many, or less, RemoveStun calls as there are AddStun calls, in total. If the stun level of a unit drops below 0 then something is wrong (and if it isn't fixed/prevented then future stuns for the unit may never work).
 

Jesus4Lyf

Good Idea™
I mean like...
JASS:
    function RemoveStun takes unit target returns nothing
        local StunData data=StunData[target]
        set data.level=data.level-1
        if data.level==0 then
            call UnitRemoveAbility(target,BUFF)
        endif
    endfunction

-->
JASS:
    function RemoveStun takes unit target returns nothing
        local StunData data=StunData[target]
        set data.level=data.level-1
        if data.level==0 then
            call UnitRemoveAbility(target,BUFF)
        debug elseif data.level&lt;0 then
            debug call BJDebugMsg(&quot;Stun Error - Removed more stuns than added.&quot;)
        endif
    endfunction

It is invariably going to be a code error that needs repairing, not just a user style that should be accepted. Therefore, a debug message, not a correction, is the best approach, imho. Does that makes sense?

An error like that should never be in a released version...
 

quraji

zap
>I mean like...

I understand the debug message, I just didn't understand your spell example :p


>It is invariably going to be a code error that needs repairing, not just a user style that should be accepted. Therefore, a debug message, not a correction, is the best approach, imho. Does that makes sense?

Yes I agree that the user shouldn't do it, but if he does, and never sees the debug message...


>An error like that should never be in a released version...

True, which is why you should prevent it in your code ;)

How about a check and a debug message, so they can fix it if they find it, but it won't be a problem if they don't catch it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    they did not winterize any of the plants and they froze
  • The Helper The Helper:
    it is not that power consumption went up it was available capacity went down with power plants freezing
  • Varine Varine:
    What a fucking disaster. Are all of the Texas people okay? I see TH is, are we the only two?
  • Varine Varine:
    How have the other states held up? I just got power back so I have no idea what's going on, we didn't get warning
  • Varine Varine:
    Why the fuck didn't they fix this ten years ago when it happened?
  • Blackveiled Blackveiled:
    I'm in it with you and TH as well. My power has been in and out, and I have a ruptured pipe that I need to fix, shouldn't be too bad to fix myself.
  • Varine Varine:
    I hope you're staying warm! Apparently the supply is coming up so hopefully we can get back to normal power soon, mine has been on for six hours now.
  • M Mulciberxp:
    My power has been off most of the last 2 days. We had a generator installed 3 years ago though, so we're staying warm. Water is another issue...
  • The Helper The Helper:
    Where I live has a pool so we are using that to get water to flush the toilets. We have enough bottled water to drink and brush teeth and stuff but it has been a few days and no shower though....
  • Varine Varine:
    I had some water in gallon jugs, and got our water back on yesterday. We don't seem to have any leaks, but I haven't crawled down there to look yet.
  • The Helper The Helper:
    still no water I cannot remember when I last showered now I know how they felt in the old west lol
  • Varine Varine:
    My poor plants are happy, they aren
  • Varine Varine:
    aren't used to going this long without water or lights or normal heat. I think a couple of them froze, but they look like they'll make it
  • Varine Varine:
    Well one of them is pretty rough but I think it was sick to begin with, that one always had some problems.
  • jonas jonas:
  • jonas jonas:
    ???
  • Ghan Ghan:
    That is such a Texas thing to say lol
  • midnight8 midnight8:
    a positive could come out of this. So many people trapped at home could put a dent in the covid numbers in Texas
  • Varine Varine:
    That dude, Tom Boyd, is really upset about the backlash from his "it's your fault you're freezing" thing because he claims he resigned before saying it, so it wasn't like he said it in his official capacity or anything.
  • jonas jonas:
    Almost as if he was saying "screw you guys, I'm going home"
  • Varine Varine:
    I'm fairly new here still but that seems to be the analogous message by several of our politicians.
  • vypur85 vypur85:
    Nobody?
  • jonas jonas:
    Hi vypur85, long time no see
  • tom_mai78101 tom_mai78101:
    Hi vypur85, long time no see.
  • The Helper The Helper:
    We are all somebody

    Staff online

    Members online

    Affiliates

    Hive Workshop NUON Dome
    Top