System ABC - Struct Attachment System

Cohadar

master of fugue
Reaction score
209
Mostly I'm interested in passing a function parameter to another function, and a dynamic type struct to any function. Can I just use the "code" handle to pass a function_name arguement, and once I'm in the appropriate function which I have passed the function I want to pass to, how would I call it?
Ok for this you need to use function interfaces
read jasshelper documentation for that.

A few more questions: For leak removal, do structs attached to units through their custom value get auto removed when the unit is removed? I assume so because the custom value is just an integer value on the unit.

I assume we are talking about PUI usage here,
the answer to your question in NO.
You have to destroy structs manually.
If you use PUI unit attaching don't remove units but call Struct.destroy()
and in onDestroy method put RemoveUnit() stuff.

For any other questions related to ABC or PUI please post in here.
 

Cohadar

master of fugue
Reaction score
209
//========< Version 5.2 >========//

Nothing special, only added support for regions.
 

cr4xzZz

Also known as azwraith_ftL.
Reaction score
51
> I don't even use ABC with timers any more, only with triggers, regions and dialogs.
Hmm. Can you give an ABC example with regions? I just can't seem to understand the usage of region attaching...
 

Cohadar

master of fugue
Reaction score
209
It is for "unit enters region" events.

For example if you have a map where you want creeps to go from one point to the other you register region events.

To every region you assign some data that has a pointer to next region.
(make a linked list of regions.)

Then when creep enters region X you just order it to go to X->next
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615

  • I have a question about if it would be possible to set my own "A", "B", and "C".
  • Would I simply create new textmacros with another string?
  • Can I use multiple letters (like //! runtextmacro ABC("WHOAH","Timer","timer"))?
  • Can I place these textmacros outside the system (say in another library or a scope)?
  • Why is it bad to use this kind of struct attachment on units?

Thanks. :D
 

Cohadar

master of fugue
Reaction score
209
Darthfett said:
I have a question about if it would be possible to set my own "A", "B", and "C".
Would I simply create new textmacros with another string?
Can I use multiple letters (like //! runtextmacro ABC("WHOAH","Timer","timer"))?
Can I place these textmacros outside the system (say in another library or a scope)?
The whole point of ABC is that you don't need to do that.
Besides I only use A functions, B and C are made for debugging.

Darthfett said:
Why is it bad to use this kind of struct attachment on units?
Because units can get removed from game before spell that uses attachment gets to use or clear it.
 

SerraAvenger

Cuz I can
Reaction score
234
Mind adding button as a preset type for attaching?
It might get really useful with modevotes etc

Cheers, Davey
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
The whole point of ABC is that you don't need to do that.
Besides I only use A functions, B and C are made for debugging.

I'm trying to get my own system going here, with only one attachment system. If you attach 2 structs to the same unit using any method other than PUI, one will overwrite the old one. I want to be able to attach multiple structs to a unit, and if I have more than 3 spells, I would need more than A, B, and C.

Because units can get removed from game before spell that uses attachment gets to use or clear it.

If I were to replace all my RemoveUnit functions, and all the KillUnit functions that kill a non-hero, with something like this:

JASS:
    function RemoveUnitSafely takes unit u returns nothing
        local CombatState cs = CombatState(GetUnitStructCombat(u))
        local Charge_Data cd = Charge_Data(GetUnitStructCharge(u))
        local Rampage_Data rd = Rampage_Data(GetUnitStructRampage(u))
        if cs != 0 then
            call CombatState.destroy(cs)
        endif
        if cd != 0 then
            call Charge_Data.destroy(cd)
        endif
        if rd != 0 then        
            call Rampage_Data.destroy(rd)
        endif
        call RemoveUnit(u)
    endfunction


would this fix this problem? (These CombatState, Charge_Data and Rampage_Data are the only structs that can be attached to a unit in my map atm).

Each of the structs has an onDestroy method that finishes the spell, and calls the ClearUnitStruct$X$ function.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Why not just use PUI then?

Darthfett said:
I'm trying to get my own system going here, with only one attachment system.

I'm also not a fan of having to create an array of structs. It looks like bad coding practice to me. (It isn't bad coding practice, it just looks ugly :p)

Also, I read that if you remove a unit, PUI might mess up as well.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
I think Cohadar added some safety against units being removed to PUI :p

PUI Description said:
JASS:
* System is using unit array to keep track of all units with an index.
//         Array is periodically checked for removed units,
//         when removed unit is found, index is recycled.
//         Indexes have &quot;decay time&quot; to prevent bugs
//         caused by attaching to &quot;Can&#039;t Raise, Does not decay&quot; type units,
//         or by using RemoveUnit() function

I'm trying to figure out how the "decay time" works. I don't want a unit losing it's attachment if it has it attached for a longer period of time.
 

Cohadar

master of fugue
Reaction score
209
Do you really think it is possible for me to make a faulty system?

I mean it is not just that I test my systems like maniac, there are also a lot of people using them.
If there was something wrong in any of them it would be reported long time ago.

And please ask about PUI in PUI thread.
 

SerraAvenger

Cuz I can
Reaction score
234
Mind adding button as a preset type for attaching?
It might get really useful with modevotes etc

Cheers, Davey

Btw, wouldn't a simple
JASS:

/! runtextmacro ABC( &quot;A&quot;, &quot;&quot;, &quot;handle&quot; )
/! runtextmacro ABC( &quot;B&quot;, &quot;&quot;, &quot;handle&quot; )
/! runtextmacro ABC( &quot;C&quot;, &quot;&quot;, &quot;handle&quot; )


work in order to allow for attaching structs to anything?

like
JASS:

call SetStructA( My_Timer, My_Struct )


or would it become buggy?
 

Cohadar

master of fugue
Reaction score
209
Mind adding button as a preset type for attaching?
Button attaching is not needed.
I made a Dialog system that uses ABC, search around.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Cohadar said:
JASS:
    call FlushGameCache(InitGameCache(&quot;Timer.gc&quot;))
    call FlushGameCache(InitGameCache(&quot;Trigger.gc&quot;))
    call FlushGameCache(InitGameCache(&quot;Dialog.gc&quot;))
    call FlushGameCache(InitGameCache(&quot;Region.gc&quot;))
    
    set TimerCache   = InitGameCache(&quot;Timer.gc&quot;)
    set TriggerCache = InitGameCache(&quot;Trigger.gc&quot;)
    set DialogCache  = InitGameCache(&quot;Dialog.gc&quot;)
    set RegionCache  = InitGameCache(&quot;Region.gc&quot;)

Wait, what? ABC is using gamecache as a backup now? (You may want to add it to the list of features, if that is true ;))

JASS:
function GetTimerCollisionA takes nothing returns integer
    return TimerMaxCollisionA
endfunction


Shouldn't these be constant functions, so that they are inlined into the code during preprocessing?

I like the new organization of the textmacros, it's easier to see the actual function calls and the create/get/clear textmacros.

Just curious, were the
JASS:
call InitTimerHashB()
type functions removed solely because the textmacros no longer contain the globals block and the Init$NAME$Hash$X$ function, or was there another reason behind it?
 
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