System Advanced Indexing & Data Storage

Nerzhul

New Member
Reaction score
7
I Mean, I need to attach lot of data for EACH creep in the map but with many variables with big arrays it cause corruption.Is there a way with AIDS to solve that?
 

Azlier

Old World Ghost
Reaction score
461
Yes, AIDS makes unit attachment easy. And efficient.

Anyway, are you trying to create a big stack of arrays with size 1000 or something? That won't make it past map initialization. Set array size to 0, you can still use all the indices up to 8191.
 

Jesus4Lyf

Good Idea™
Reaction score
397
If you have AIDS in your map and want to attach to units from GUI, use Get Unit's Custom Value (make sure you NEVER use set unit's custom value though).

That will return a unique number for that unit from 1 to 8191. So you can use that for an array index. (This is actually how AIDS structs work anyway.)
 

Jesus4Lyf

Good Idea™
Reaction score
397
Sorry for the delay.
I'm creating an aggro system and I was wondering if the following snippet correctly assigns an index and setup up aggro-related stuff for a unit:
In AIDS, you do not need to have the "[LJASS]unit source[/LJASS]" member, as AIDS provides you with a member: [LJASS].unit[/LJASS]. This is the unit for which the struct exists.
Also, I have a spell that bestows a debuff on an enemy unit. Everytime the enemy unit casts a spell it takes damage. However, I have to know the source of the spell (the caster) to properly deal damage so that the source gets the bounty for the kill, if the target dies.

Would you then use the index of the unit as an index for a specific array of structs that the spell uses?
I would not use unit attaching at all for this. What you need is a stand-alone struct, with a trigger (which you register for when that unit casts a spell) and you need to attach the casting unit to that trigger (by attaching the struct). Destroy the struct and the trigger after x seconds using a timer (timer system of some sort). Hope you get what I mean.

>But if you use GetWorldBounds instead of bj_mapInitialPlayableArea, it will have less checks.
I'll address this soon enough. When I find time with WC3.
This was actually on my list of things to add.

I believe that's all questions answered, if I missed anything or any more information is needed, please ask. :)
 

Embrace_It

New Member
Reaction score
9
Great explantion! :thup: Just what I needed to know.

I would not use unit attaching at all for this. What you need is a stand-alone struct, with a trigger (which you register for when that unit casts a spell) and you need to attach the casting unit to that trigger (by attaching the struct). Destroy the struct and the trigger after x seconds using a timer (timer system of some sort). Hope you get what I mean.

Just to be clear, this is what you mean:

JASS:

private struct Data
   unit source
   unit target
   real damage
   trigger dealdamage // Registered in the create method
   
   ...

endstruct


I thought up another question meanwhile :D:

If you have two or more systems in your map that need AIDS, can you use it for both? Even though the structs and such are completely different?

Thanks!
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I just want to point in fact you have to check if the unit is already indexed or not, since you can put the unit outside the entire map ( GetWorldBounds() ) without making war3 crash (should be pointless though, and is definitely possible source of crash).

But since it's possible to fix it, in a reasonable efficient and easy way, you should do it.
 

Jesus4Lyf

Good Idea™
Reaction score
397
>But since it's possible to fix it, in a reasonable efficient and easy way, you should do it.
Absolutely. As said, will be in next update. Be patient with me, I have limited WC3 time. It will be done. :)

>If you have two or more systems in your map that need AIDS, can you use it for both? Even though the structs and such are completely different?
Absolutely! You can have as many different AIDS structs as you like. For the same units, or not. The system is incredibly flexible:
You can even typecast between AIDS structs for the same unit. :thup:

@Embrace_It
Yes, that's what I mean. And find a system of choice to attach that struct to the trigger, and make the trigger fire when the target casts a spell... :)
 

SanKakU

Member
Reaction score
21
You mean...
JASS:
struct CreepRevival extends array
    //! runtextmacro AIDS()
    private trigger t
    private real x
    private real y
    private integer utype
    
    private static method OnDeath takes nothing returns nothing
        local thistype d=thistype[GetTriggerUnit()]
        
        // Because the struct may be destroyed before the wait finishes.
        local trigger t=d.t
        local real x=d.x
        local real y=d.y
        local integer utype=d.utype
        set d.t=null
        
        call TriggerSleepAction(3.0)
        call CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE),utype,x,y,0)
        call DestroyTrigger(t)
        set t=null
    endmethod
    
    private static method AIDS_filter takes unit u returns boolean
        return GetOwningPlayer(u)==Player(PLAYER_NEUTRAL_AGGRESSIVE)
    endmethod
    private method AIDS_onCreate takes nothing returns nothing
        set this.utype=GetUnitTypeId(this.unit)
        set this.x=GetUnitX(this.unit)
        set this.y=GetUnitY(this.unit)
        
        set this.t=CreateTrigger()
        call TriggerAddAction(this.t,function thistype.OnDeath)
        call TriggerRegisterUnitEvent(this.t,this.unit, EVENT_UNIT_DEATH )
    endmethod
endstruct
? :D

I kinda had to. For each unit owned by neutral hostile, that will store its x/y/type, and on death wait 3.0 seconds and then spawn a new unit of that type at that original x and y, regardless where it died. Change 3.0 to your liking. This is why I made AIDS... It makes map-wide unit data systems sooo easy to code. <_<

Edit: I may add something called Locks (which won't break anything currently made) which will stop an index from being freed (and hence all AIDS structs on it) until the same number of Unlocks have been called. :)

... So, you'd be able to attach the struct to a timer, and not worry about it getting destroyed, because it won't be until the timer unlocks it after its callback... (Which is what I should've done here, not that it matters.)

Edit again:
In answer to your question, I'd recommend you give your map AIDS.

just curious, why is triggersleepaction used instead of a timer like from KT2? is it just because doing so would complicate the code further?

edit: after looking at your system a bit and your example of creeprevival i think i can figure out how to do what i asked you about in that private message earlier with your code...thanks.

finally i got something practical to work with in structs...i guess i'm one step closer to understanding them.

edit2: oh wow i must be tired! what did i just type in there? i have no idea how to use a timer...lol...but i'm a lot closer to learning structs so i guess i can forget about timers for now...
 

Jesus4Lyf

Good Idea™
Reaction score
397
Don't worry, I made this version just to confuse the frak out of innocent JASSers like yourself! :D

It's a few posts down, and is much better...
So for Renendaru, here's a AIDS/KT version of a simple creep respawn system. You could even add an AIDS_onDestroy so if creeps were REMOVED from the game, they'd STILL respawn. XD
JASS:
struct CreepRevival extends array
    //! runtextmacro AIDS()
    private trigger t
    private real x
    private real y
    private integer utype
    
    private static method Callback takes nothing returns boolean
        local thistype this=KT_GetData()
        call CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE),this.utype,this.x,this.y,0)
        call this.AIDS_removeLock()
        return true
    endmethod
    
    private static method OnDeath takes nothing returns boolean
        local thistype this=thistype[GetTriggerUnit()]
        call this.AIDS_addLock() // So the struct can&#039;t disappear before the timer ticks.
        call KT_Add(function thistype.Callback,this,3.0)
        call DestroyTrigger(this.t)
        set this.t=null
        return false
    endmethod
    
    private static method AIDS_filter takes unit u returns boolean
        return GetOwningPlayer(u)==Player(PLAYER_NEUTRAL_AGGRESSIVE)
    endmethod
    private method AIDS_onCreate takes nothing returns nothing
        set this.utype=GetUnitTypeId(this.unit)
        set this.x=GetUnitX(this.unit)
        set this.y=GetUnitY(this.unit)
        
        set this.t=CreateTrigger()
        call TriggerAddCondition(this.t,Condition(function thistype.OnDeath))
        call TriggerRegisterUnitEvent(this.t,this.unit, EVENT_UNIT_DEATH )
    endmethod
endstruct
PS. The previous version leaked trigger actions, I forgot. lol.
 

SanKakU

Member
Reaction score
21
Don't worry, I made this version just to confuse the frak out of innocent JASSers like yourself! :D

It's a few posts down, and is much better...

and..."PS. The previous version leaked trigger actions, I forgot. lol."

ahhh...oh of course it did! lol...

yeah i gotta study more...
 

black.sheep

Active Member
Reaction score
24
Would it be possible to make a "saftey" version of this for people who dont wanna go back and redo all the Custom Value triggers with a dummy ability with +1000 levels?
(If its even possible to get over that)
 

Viikuna

No Marlo no game.
Reaction score
265
The main complication is AIDS struct locking (something AutoIndex lacks to the best of my knowledge ).

These locks?

JASS:
Locks just
//            put off AIDS struct destruction in case you wish to attach to a timer
//            or something which must expire before the struct data disappears.
//            Hence, not freeing all locks will leak the struct (and index).


So it just prevents AIDS from recycling AIDS struct instance and giving it to some new unit, right?

I see that it is useful with AIDS structs, but the thing is different with AutoIndex, because it has no AIDS struct like thingies.
It simple recycles index when unit is removed from the game, since you dont really need to keep index for some non existing unit. ( At leats I cant think any reason to do so )

Hrm. I was sure I had some point I wanted to say, but I forgot it.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Hrm. I was sure I had some point I wanted to say, but I forgot it.
Some limitations caused by the need of an array struct like not possible to have array members, maybe ?
 

Jesus4Lyf

Good Idea™
Reaction score
397
>But since it's possible to fix it, in a reasonable efficient and easy way, you should do it.
Absolutely. As said, will be in next update. Be patient with me, I have limited WC3 time. It will be done. :)
Done. Now uses [LJASS]GetWorldBounds()[/LJASS] and checks that the unit's userdata is 0. (Version 1.0.4 released.)
 
Reaction score
456
Suggestion: Use structs onInit method instead of library initializer to initialize AIDS :p.
 

Romek

Super Moderator
Reaction score
964
So that you can use a units index in a struct initializer.

Struct initializers fire in the order they appear in the maps script.
So libraries get priority, and using [ljass]requires[/ljass] will make it run before other libraries.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Just released 1.1.0 which features undefend removal detection (O(1) complexity).

I like periodic removal better. There is a constant. Flick the switch. Default is undefend removal (seems to be fashionable).

The relative order between different struct initializers depends on the location they are found in the map script, therefore they actually depend on things like libraries as well (A struct initializer inside a library will run before the initializers inside other libraries that require it and also before initializers inside scopes).
Hm. I'll use a struct initialiser then, and release an update.

Edit: Actually, AIDS initialisation needs to fire after all structs. The structs onInit is used to fill AIDS with a list of structs to create/destroy for units on indexing, so the AIDS init which starts indexing units needs to fire after struct onInits. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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