System BuffStruct

Grundy

Ultra Cool Member
Reaction score
35
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?
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
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.
 

Weep

Godspeed to the sound of the pounding
Reaction score
401
@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?
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
@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 ... :(
 

Jesus4Lyf

Good Idea™
Reaction score
397
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). :)
 

Grundy

Ultra Cool Member
Reaction score
35
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?
 

Jesus4Lyf

Good Idea™
Reaction score
397
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.)
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
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. :/
 

Jesus4Lyf

Good Idea™
Reaction score
397
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
 

13lade619

is now a game developer :)
Reaction score
400
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)
 

Jesus4Lyf

Good Idea™
Reaction score
397
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.
 

13lade619

is now a game developer :)
Reaction score
400
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.
 

13lade619

is now a game developer :)
Reaction score
400
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.
 

Jesus4Lyf

Good Idea™
Reaction score
397
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?
 

13lade619

is now a game developer :)
Reaction score
400
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.

      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