System BuffStruct

Jesus4Lyf

Good Idea™
Reaction score
397
fixed by adding a new boolean member of the struct that gets flagged when onDestroy is called,.
That won't work. If another buff is created since that buff is destroyed, it will overwrite the boolean and destroy the new buff.

The correct way to dispel a buff, if you're using destroyTimed, is:
JASS:
//          Use .setUnit(null) to unapply a buff without destroying it.

So basically, instead of destroying the buff, use .setUnit(null) to move it into the void until whatever created it effectively destroys it. :)
 

13lade619

is now a game developer :)
Reaction score
400
JASS:
function DestroyDeathRunes takes BuffStruct whatBuff returns nothing
    if whatBuff.getType()==RuneWolf.typeid or whatBuff.getType()==RuneTerror.typeid or whatBuff.getType()==RuneOgre.typeid or whatBuff.getType()==RuneArch.typeid then
        call whatBuff.setUnit(null)
    endif
endfunction

    call BuffList[target].forEachBuff(BUFF_ALIGNMENT_POSITIVE, DestroyDeathRunes)
    call BuffList[target].forEachBuff(BUFF_ALIGNMENT_NEGATIVE, DestroyDeathRunes)
    call BuffList[target].forEachBuff(BUFF_ALIGNMENT_NEUTRAL, DestroyDeathRunes)


works. thanks again.
 

Switch33

New Member
Reaction score
12
JASS:
library Returning
globals
private real x
private real y
endglobals
//! runtextmacro BuffType("Returning")
    //! runtextmacro SetBuffName("Returning")
    //! runtextmacro SetBuffAlignment("NEUTRAL")
    //! runtextmacro SetBuffTooltip("This unit is being Returned; it will return to its previous location soon.")
    //! runtextmacro SetBuffIcon("ReplaceableTextures\\CommandButtons\\BTNUnload.blp")
//! runtextmacro BuffStruct()
    method onCreate takes nothing returns nothing
        set x=GetUnitX(this.unit)
        set y=GetUnitY(this.unit)
    endmethod
    method preDestroy takes nothing returns nothing
        local Returned b = Returned.create(this.unit)
    endmethod
//! runtextmacro EndBuff()

//! runtextmacro BuffType("Returned")
    //! runtextmacro SetBuffName("Returned")
    //! runtextmacro SetBuffAlignment("NEUTRAL")
    //! runtextmacro SetBuffTooltip("This unit has just been returned to it's previous location.")
    //! runtextmacro SetBuffIcon("ReplaceableTextures\\CommandButtons\\BTNLoad.blp")
//! runtextmacro BuffStruct()

    method onApply takes nothing returns nothing
        call SetUnitX(this.unit,x)
        call SetUnitY(this.unit,y) 
    endmethod
    method preDestroy takes nothing returns nothing

    endmethod
//! runtextmacro EndBuff()

endlibrary


Should this work?:nuts:
Its supposed to be a sort of stealable "return unit" buff. It's similar to one on first post but i like the idea of the buff icon being unload/load cause it makes it look snazzier.
 

luorax

Invasion in Duskwood
Reaction score
67
Each time you use the "BuffType("SOMETHING")" textmacro, it creates a new struct, and after it you can configure it until you close it with the "EndBuff()" textmacro (it adds the endstruct).
So I think that will work. But you can easily test it.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Sorry for the delayed response. :)

It will not multi-instance whatsoever, since the coordinates are stored, for the duration of the buff, in global variables.

Instead, see the below:
JASS:
//! runtextmacro BuffType("Returning")
    //! runtextmacro SetBuffName("Returning")
    //! runtextmacro SetBuffAlignment("NEUTRAL")
    //! runtextmacro SetBuffTooltip("This unit is being Returned; it will return to its previous location soon.")
    //! runtextmacro SetBuffIcon("ReplaceableTextures\\CommandButtons\\BTNUnload.blp")
//! runtextmacro BuffStruct()
    real x
    real y
    method onCreate takes nothing returns nothing
        set x=GetUnitX(this.unit)
        set y=GetUnitY(this.unit)
    endmethod
    method preDestroy takes nothing returns nothing
        local Returned b = Returned.create(null)
        set b.x = x
        set b.y = y
        call b.setUnit(this.unit)
    endmethod
//! runtextmacro EndBuff()

//! runtextmacro BuffType("Returned")
    //! runtextmacro SetBuffName("Returned")
    //! runtextmacro SetBuffAlignment("NEUTRAL")
    //! runtextmacro SetBuffTooltip("This unit has just been returned to it's previous location.")
    //! runtextmacro SetBuffIcon("ReplaceableTextures\\CommandButtons\\BTNLoad.blp")
//! runtextmacro BuffStruct()
    real x
    real y
    method onApply takes nothing returns nothing
        call SetUnitX(this.unit,x)
        call SetUnitY(this.unit,y) 
    endmethod
//! runtextmacro EndBuff()

Freehanded, but should work. :thup:

(Why you want to do it this way, I do not understand. I would restore the unit's position at the end of the "Returning" buff, and add the other buff as purely aesthetic.. at least. :))
 

Switch33

New Member
Reaction score
12
I would restore the unit's position at the end of the "Returning" buff, and add the other buff as purely aesthetic.. at least.

:banghead:Yeah, i think i originally was going to do it this way but changed it and forgot. I re-did it roughly the way you did it in your first post and made the returned buff part just an aesthetic. Thanks
 

codart

New Member
Reaction score
0
hey j4l. Let say i want to detect when a buffstruct is created. Then check, if it's a negative buff then multiple it's duration by 2. Can you add or teach me the way to make a event similar to 'EVENT_BUFF_CREATED'
 

luorax

Invasion in Duskwood
Reaction score
67
I have an idea J4L. You should use a global, non-static timer member to call the "destroyTimed" method. If you call it, and you try to set the buff's duration to something different (for example from 5 sec to 10), the buff'll be destroyed after 5 seconds, and we'll have one more timer without any data.
 

Laiev

Hey Listen!!
Reaction score
188
JASS:
//          All BuffStructs have the .setUnit(unit) method, which will remove
//          the buff instance from the current unit, and apply it to the given unit.
//          Use .setUnit(null) to unapply a buff without destroying it.


JASS:
call MyBuffInstance.setUnit(myUnit)
 

luorax

Invasion in Duskwood
Reaction score
67
or
JASS:
call MyBuff.create(<unit>)


Both versions work (but I prefer using the "create" method to apply and the "seUnit" method to move the buff, just for clarity :p)
 

Laiev

Hey Listen!!
Reaction score
188
i'm with luorax, and Jesus4Lyf at some point in this thread said the same thing... create the buff for a null unit and set the buff to the target unit
 

emootootoo

Top Banana
Reaction score
51
so i seem to have hit a wall with buffstruct

it seems if i try to make more than around 60 buffs grimoire stuffs up and chucks out an error pointing to grimex.txt

C:\Users\XX\AppData\Local\Temp\VB55C.tmp.lua:1783: attempt to index field '?' (a nil value)

fyi - the last buff that is made before the error is B@Z&
 

Jesus4Lyf

Good Idea™
Reaction score
397
so i seem to have hit a wall with buffstruct

it seems if i try to make more than around 60 buffs grimoire stuffs up and chucks out an error pointing to grimex.txt

C:\Users\XX\AppData\Local\Temp\VB55C.tmp.lua:1783: attempt to index field '?' (a nil value)

fyi - the last buff that is made before the error is B@Z&
Ah, funny that.

Find this in the code:
JASS:
        //! runtextmacro BuffStruct__AllowSysId("@a")
        //! runtextmacro BuffStruct__AllowSysId("@b")
        //! runtextmacro BuffStruct__AllowSysId("@c")
        //! runtextmacro BuffStruct__AllowSysId("@d")
        //! runtextmacro BuffStruct__AllowSysId("@e")
        //! runtextmacro BuffStruct__AllowSysId("@f")
        //! runtextmacro BuffStruct__AllowSysId("@g")
        //! runtextmacro BuffStruct__AllowSysId("@h")
        //! runtextmacro BuffStruct__AllowSysId("@i")
        //! runtextmacro BuffStruct__AllowSysId("@j")
        //! runtextmacro BuffStruct__AllowSysId("@k")
        //! runtextmacro BuffStruct__AllowSysId("@l")
        //! runtextmacro BuffStruct__AllowSysId("@m")
        //! runtextmacro BuffStruct__AllowSysId("@n")
        //! runtextmacro BuffStruct__AllowSysId("@o")
        //! runtextmacro BuffStruct__AllowSysId("@p")
        //! runtextmacro BuffStruct__AllowSysId("@q")
        //! runtextmacro BuffStruct__AllowSysId("@r")
        //! runtextmacro BuffStruct__AllowSysId("@s")
        //! runtextmacro BuffStruct__AllowSysId("@t")
        //! runtextmacro BuffStruct__AllowSysId("@u")
        //! runtextmacro BuffStruct__AllowSysId("@v")
        //! runtextmacro BuffStruct__AllowSysId("@w")
        //! runtextmacro BuffStruct__AllowSysId("@x")
        //! runtextmacro BuffStruct__AllowSysId("@y")
        //! runtextmacro BuffStruct__AllowSysId("@z")
        //! runtextmacro BuffStruct__AllowSysId("@A")
        //! runtextmacro BuffStruct__AllowSysId("@B")
        //! runtextmacro BuffStruct__AllowSysId("@C")
        //! runtextmacro BuffStruct__AllowSysId("@D")
        //! runtextmacro BuffStruct__AllowSysId("@E")
        //! runtextmacro BuffStruct__AllowSysId("@F")
        //! runtextmacro BuffStruct__AllowSysId("@G")
        //! runtextmacro BuffStruct__AllowSysId("@H")
        //! runtextmacro BuffStruct__AllowSysId("@I")
        //! runtextmacro BuffStruct__AllowSysId("@J")
        //! runtextmacro BuffStruct__AllowSysId("@K")
        //! runtextmacro BuffStruct__AllowSysId("@L")
        //! runtextmacro BuffStruct__AllowSysId("@M")
        //! runtextmacro BuffStruct__AllowSysId("@N")
        //! runtextmacro BuffStruct__AllowSysId("@O")
        //! runtextmacro BuffStruct__AllowSysId("@P")
        //! runtextmacro BuffStruct__AllowSysId("@Q")
        //! runtextmacro BuffStruct__AllowSysId("@R")
        //! runtextmacro BuffStruct__AllowSysId("@S")
        //! runtextmacro BuffStruct__AllowSysId("@T")
        //! runtextmacro BuffStruct__AllowSysId("@U")
        //! runtextmacro BuffStruct__AllowSysId("@V")
        //! runtextmacro BuffStruct__AllowSysId("@W")
        //! runtextmacro BuffStruct__AllowSysId("@X")
        //! runtextmacro BuffStruct__AllowSysId("@Y")
        //! runtextmacro BuffStruct__AllowSysId("@Z")

Add some more. It ran out. :p
 

emootootoo

Top Banana
Reaction score
51
thanks, a little after this post i was thinking it might be something like that, just havent been able to check
 

Nestharus

o-o
Reaction score
84
Would be nice if the object generation done here and in Status was updated to use the Lua stuff so that they're safe to use.

Would also be nice to update all of the other object generating scripts like AIDS.
 

tooltiperror

Super Moderator
Reaction score
231
Jesus, I'll actually be planning on writing a tutorial about it.

Basically, Nestharus explained to me last night that the object generation used in BuffStruct and Status is unsafe, because just plain old object merger calls and lua calls with predefined variables can just overwrite things. So if someone has [ljass]'A000'[/LJASS] in their map and you overwrite it, they can't get it back unless it's backed up, and there's no warning it will be overwritten, so it's ... bad.

Nestharus' system LUA_GET_VAR_OBJECT as well as the ones it requires make safe unique ID's.

Also, interesting spin on your interface:
JASS:

//! runtextmacro Buff() // empty textmacro call
	//! runtextmacro BuffType("Knockback")
		//! runtextmacro SetBuffName("Knocked")
		//! runtextmacro SetBuffAlignment("NEGATIVE")
		//! runtextmacro SetBuffTooltip("This unit is being Knocked Back; it is stunned and sliding backwards.")
		//! runtextmacro SetBuffIcon("ReplaceableTextures\\CommandButtons\\BTNBash.blp")
	//! runtextmacro BuffStruct()
		real speed=400*T32_PERIOD
		private effect e
		private method periodic takes nothing returns nothing
			local real r=GetUnitFacing(this.unit)*bj_DEGTORAD
			call SetUnitX(this.unit,GetUnitX(this.unit)-Cos(r)*this.speed)
			call SetUnitY(this.unit,GetUnitY(this.unit)-Sin(r)*this.speed)
		endmethod
		implement T32x
		method onApply takes nothing returns nothing
			call Status[this.unit].addStun()
			call this.startPeriodic()
			set this.e=AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderclapTarget.mdl",this.unit,"overhead")
		endmethod
		method onRemove takes nothing returns nothing
			call Status[this.unit].removeStun()
			call this.stopPeriodic()
			call DestroyEffect(this.e)
		endmethod
	//! runtextmacro EndBuffStruct() // empty textmacro call
//! runtextmacro EndBuff()
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top