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
398
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.
  • 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 The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top