System BuffStruct

If you are using dummy auras hidden in disabled spellbooks...The problem with using dummy auras is, that removing a dummy aura from a unit closes the spellbook, if the player has it opened.

I don't see how that is a problem. How could you possibly have a disabled spellbook open?
 
I don't see how that is a problem. How could you possibly have a disabled spellbook open?
Hmm, you didn't understand what I mean, so I try to be a little bit more precise:

Removing a dummy aura from a unit closes ALL opened spellbooks for that unit. Only removing of buffs is always safe.
This is why you basicly need an invisible unit floating overhead of the actual unit that holds the dummy aura, so that the actual unit does not require adding/removing of abilities, but still gets the buff icon.

Only some certain abilities that do not have an icon (like abils based on item abilities) do not close spellbooks.
 
@Zwieb: It's based on Slow Aura (Tornado): [ljass]//! i createobject("Aasl",sysIds[sysIdsUsed].abilType)[/ljass], which does not have a UI icon and does not close spellbooks (tested just now).


@J4L: Using an aura, upon addition, isn't there a momentary delay before the buff actually shows up on a unit?
 
@J4L: Using an aura, upon addition, isn't there a momentary delay before the buff actually shows up on a unit?
Not if the ability is directly applied to the buffed unit and only affects the unit itself. In this case, the buff icon appears instantly, as the game doesn't need to do enumerations internally here. Also, I think J4L doesn't scan for the actual buff icon, but only for the tornado ability applied to that unit.

I didn't know that the tornado aura doesn't have an UI icon and thus doesn't close open spellbooks upon removal. Awesome.


Now if only my objectmerger would work ... :(
 
I didn't know that the tornado aura doesn't have an UI icon and thus doesn't close open spellbooks upon removal. Awesome.
I didn't know removing a spellbook from a unit closed all open menus - that explains why in DotA occasionally the select ability menu closes itself (or is it just spellbooks...).

Yeah, it's based on tornado slow aura. No, as far as I know, there's no delay. But there is a delay on removing the buff when the ability is removed. That's why I remove the ability, and then remove the buff also (to fix that delay). :)
 
Is it possible to add .createTrigger, .destroyTrigger, .startTimer, and .stopTimer like in SpellStruct or would you rather have people keep track of their own triggers and timers in BuffStruct?
 
Is it possible to add .createTrigger, .destroyTrigger, .startTimer, and .stopTimer like in SpellStruct or would you rather have people keep track of their own triggers and timers in BuffStruct?
Yeah, I'm intending on it when I get around to it. It's just they're particularly advanced features, because of their self-cleansing stuff if you just destroy the buff, so I need to think carefully on it and find time to do it. :)

(For now, I'm slowing down a little bit.)
 
I didn't know removing a spellbook from a unit closed all open menus - that explains why in DotA occasionally the select ability menu closes itself (or is it just spellbooks...).
Its not the removing of spellbooks that closes all UI, but the removing of abilities that have an UI button.
There are exceptions to that rule - and some weird bugs also.

Once, I experimented with the Ghost ability of these undead sacrificed acolyte shades. When I was removing the ability alone, UI closed for that unit. If I disabled that ability before removing, it didn't close the UI.
However, that didn't work for ordinary aura abilities. It's weird and one of those many bugs of Warcraft III.

However, if tornado aura works fine, then there is no problem and your system is amazing. However, it requires the object merger and that sucks for me, as mine doesn't work for some reason. :rolleyes:

Sad thing that you didn't wrote this ealier. I wrote my own Buff system for my RPG, which is way less efficient and cool, but I do not want to switch to your system now that I have so many spells using it. :/
 
JASS:
function RemoveBuff takes BuffStruct b returns nothing
    call b.setUnit(null) // doesn't destroy the buff, just puts it on no unit - so it can be destroyed as per normal.
endfunction

call BuffList[unit].forEachBuff(BUFF_ALIGNMENT_??, RemoveBuff)

Something like that. I think that's the syntax. XD
 
hmm.. wait this thing does not take arguments?

how about if we want to refer to the 'applier' / caster of the buff to its target?

i.e.
apply a buff that reduced the target's armor (via Status system) according the caster's spell level?..

do we need to attach externally? (using PUI/AIDS)
 
For any buff, you may find .unit for the unit the buff is on.
If a buff has a caster, you may access them all using typecasting, as is expected.

Example:
For all buffs of type MyBuff, kill the caster:
JASS:
//! runtextmacro BuffType("MyBuff")
    //! runtextmacro SetBuffName("My Buff")
    //! runtextmacro SetBuffAlignment("NEUTRAL")
    //! runtextmacro SetBuffTooltip("This unit is buffed. Isn't that cool?")
    //! runtextmacro SetBuffIcon("ReplaceableTextures\\CommandButtons\\BTNDaggerOfEscape.blp")
//! runtextmacro BuffStruct()
    unit caster
    method onCreate takes nothing returns nothing
        set this.caster=GetSpellAbilityUnit() // this should probably be set externally, but hey, this is an example. And it works!
    endmethod
    method killCaster takes nothing returns nothing
        if this.getType()!=thistype.typeid then
            return // this will only continue if the struct type is thistype.
        endif      // meaning it is safe to call this method on any BuffStruct type, and it will just fail if it is the wrong type.
        call KillUnit(this.caster)
    endmethod
//! runtextmacro EndBuff()

function KillCastersOfMyBuffForUnit takes unit u returns nothing
    call BuffList[unit].forEachBuff(BUFF_ALIGNMENT_NEUTRAL, MyBuff.killCaster) // passes in the killCaster method. Which has been made safe by those three magic lines. <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />
endfunction

Get teh idea?

Edit: Oh, I think you were talking about this...
JASS:
//! runtextmacro BuffType(&quot;MyBuff&quot;)
    //! runtextmacro SetBuffName(&quot;My Buff&quot;)
    //! runtextmacro SetBuffAlignment(&quot;NEUTRAL&quot;)
    //! runtextmacro SetBuffTooltip(&quot;This unit is buffed. Isn&#039;t that cool?&quot;)
    //! runtextmacro SetBuffIcon(&quot;ReplaceableTextures\\CommandButtons\\BTNDaggerOfEscape.blp&quot;)
//! runtextmacro BuffStruct()
    unit caster
    // this should probably be set externally, and this time it will be.
    //method onCreate takes nothing returns nothing
    //    set this.caster=GetSpellAbilityUnit()
    //endmethod
    method killCaster takes nothing returns nothing
        if this.getType()!=thistype.typeid then
            return // this will only continue if the struct type is thistype.
        endif      // meaning it is safe to call this method on any BuffStruct type, and it will just fail if it is the wrong type.
        call KillUnit(this.caster)
    endmethod
//! runtextmacro EndBuff()

function WhenMySpellCasts takes nothing returns nothing
    local MyBuff b=MyBuff.create(null) // we apply it to a null unit, as not to apply Status effects, yet, before struct members are set.
    set b.caster=GetSpellAbilityUnit()
    call b.setUnit(GetSpellTargetUnit())
endfunction

It is done that way so that when onApply is called in the buff struct, all struct members have already been set.
 
oh yeah.. lol.

JASS:
function WhenMySpellCasts takes nothing returns nothing
    local MyBuff b=MyBuff.create(null) // we apply it to a null unit, as not to apply Status effects, yet, before struct members are set.
    set b.caster=GetSpellAbilityUnit()
    call b.setUnit(GetSpellTargetUnit())
endfunction


^that.

i forgot it was a struct (even the name says BuffStruct) :facepalm:.
i was treating it as a function..

thanks again.
 
hmm... i think this has one fatal flaw..

you can't retrieve a buff from a unit, if the buff is applied from another function/trigger.

i think hashtables would enable you to do that though..
a good example is UAC by Romek. it has a retrieval method.
 
you can't retrieve a buff from a unit, if the buff is applied from another function/trigger.
I totally agree on MyBuffType[unit]. The problem there is what if it has the buff twice? I propose to return the last instance added, or maybe the first. I'm not sure which, hence why I haven't added this yet either. Thinking carefully...
I'm thinking it makes sense to return the first instance. Reason being, let's say a unit has a buff which blocks an attack, or a spell, for 5 seconds. It should remove the oldest buff, in theory. Any suggestions?
 
I'm thinking it makes sense to return the first instance. Reason being, let's say a unit has a buff which blocks an attack, or a spell, for 5 seconds.
yes, that sounds logical.

Any suggestions?
ItemStruct 2 was able to get 'per instance' accuracy by using ItemUserData..

well, maybe you can design an Ability/BuffUserData system to go with this...
something like giving a unique instance a unique index or something along those lines.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    A probate is usually done with a will, yes? If so I am sorry for your loss
    +1
  • The Helper The Helper:
    Yeah Tom, me too sorry for your loss buddy my mom told me she finds out her olds friend died from Google searching them. She had not talked to one of her old friends in a year and found out she died from Google. Also another one in the same session. RIP all of them my sincere condolences Tom
    +1
  • Varine Varine:
    We have some elderly guests that regularly come hang out at the bar at the end of the night, and every once in a while we don't see someone for a few weeks and then someone shows up with their obituary.
  • Varine Varine:
    We usually let them do their memorials there in the morning if they want to and I'll make them some snacks and drinks. There was one guy named Tom that came in like every night and would sit by himself and get a bunch of soup and a glass of wine. idk why but he LOVED our fucking soup, like he would order a fucking quart of it at a time and would always get so sad when we stop doing it for the summer.
    +1
  • Varine Varine:
    But he also loved our calamari, which is another thing I hate but it sells super well so I can't change it. There was one day he came in and was asking me how to make it, because he tried to at home once in the off season when we stop running it and he really wanted it lol
  • Varine Varine:
    I think he's one of the only people I've made recipes for for free because he really wanted a broccoli cheddar, and it was like dude I don't have a recipe, it's just whatever I have, but here, this is how you do it
  • Varine Varine:
    I don't think he ever figured out how to do the calamari in a pan though, like idk how to do that either. He was afraid of the at home deep fryers though and it's like yeah, that's fair, I am too
  • Varine Varine:
    He was just such a sweet old man, we had two servers pregnant and they held a baby shower together, he was soooooo fucking excited to get to see a baby. Unfortunately he died a month or so before they were born
  • The Helper The Helper:
    So I decided to Google some people that I had not seen or heard from in a while and sure enough one of my old best friends, we had a falling out years ago but whatever, find out he died of Pancreatic Cancer in January. I have also lost a few of my closer acquaintances from growing up the last year. Getting old - people die - I kinda thought it was going to be this way a few years ago....
    +2
  • The Helper The Helper:
    Forum running super slow again
  • Ghan Ghan:
    Not really clear from the stats as to what is causing the slowness.
  • Ghan Ghan:
    We get a lot of guest traffic so it may just be the load is getting too high and not from any particular source.
  • Ghan Ghan:
    Looks like the server is maxed out on CPU.
  • Ghan Ghan:
    Oh it looks like a lot of the traffic is Silkroad Forums. That domain isn't protected by Cloudflare.
  • Ghan Ghan:
    But the old Silkroad site is still on its own server. I just had a test site set up on this server for it.
  • Ghan Ghan:
    I just disabled that test site. Let's see if that helps the load.
  • Ghan Ghan:
    Looks much better already.
  • The Helper The Helper:
    I had actually forgot about the Silkroad site. I had asked
  • The Helper The Helper:
    SD Ryoko about it and he said the couple of people left on there really like it, that was a few years ago, maybe I should check back
  • jonas jonas:
    I guess when you're getting old, and the last day of soup season draws near, you start wondering
  • jonas jonas:
    will I make it to the start of the next season? or was this the last time I'll ever have my favorite dish?
  • The Helper The Helper:
    I am doing my first Vibe Coding project. In installed the environment and tools according to instructions but it is all chat doing this for me at my direction. It is fun really and holy shit I might finish in 2 hours what it would have taken a day to in my Access and this would be an electron app complete new
  • Ghan Ghan:
    Good stuff.
  • Ghan Ghan:
    Just make sure it is secure. :)
  • The Helper The Helper:
    It will only be on internal network

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials
      Top