System Advanced Indexing & Data Storage

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?
 
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.
 
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.)
 
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. :)
 
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!
 
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.
 
>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... :)
 
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...
 
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.
 
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...
 
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)
 
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.
 
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 ?
 
>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.)
 
Suggestion: Use structs onInit method instead of library initializer to initialize AIDS :p.
 
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.
 
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.
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/
  • The Helper The Helper:
    Happy Thursday!

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top