LUA Abuse [Inventory System, need design ideas]

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Jesus4Lyf said:
Edit: My friend suggested putting all wielded items in the buff tray.
The icons would be too small wouldn't they? If it was possible, which I reaaallly wish it was, it would look way better with icons as the attack-type icon, the armour, etc.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
Whilst you're right in theory, who the hell wants to implement a preprocessor to use a system.

Who the hell wants to implement a system to use it?

Just one extra step...
 

Jesus4Lyf

Good Idea™
Reaction score
397
A precompiler that compiles to vJass, as far as I know, requires to hook the JassHelper call by replacing it, and then wrapping the JassHelper call. I assume you guys know that that could be a pain in the ass to implement.

What's the point in writing a precompiler that just will add [LJASS]//! runtextmacro[/LJASS] to the start of a few lines? What if it is incompatible with things? What if I have to maintain and upgrade things? Alternatively I provide this interface which solves everything, and requires no added components.

Correct me if I'm wrong: External calls MAY NOT compile to vJass, because their result is parsed after the vJass code (only logical). In other words, an external code can't write JASS, because all the functions will be missing when JassHelper parses the vJass. :nuts:

The icons would be too small wouldn't they? If it was possible, which I reaaallly wish it was, it would look way better with icons as the attack-type icon, the armour, etc.
Could engineering upgrade do this? I might have to try that. Thanks! :thup:
 

Sickle

New Member
Reaction score
13
While almost totally unrelated, does anyone think that Engineering Upgrade would do anything interesting with buffs if we force a buff rawcode into the ability?
 

Jesus4Lyf

Good Idea™
Reaction score
397
While almost totally unrelated, does anyone think that Engineering Upgrade would do anything interesting with buffs if we force a buff rawcode into the ability?
I thought exactly that, earlier today. Especially things like can you change an ability into a buff (suddenly you could add/remove positive buffs, lol)...

Please continue that discussion in a new thread, though. I really want feedback on this item system, its interface and how it can be improved.
 

Hatebreeder

So many apples
Reaction score
381
>I remember Nestharus or something wanting to do a MPQ hack
Why is that useful?...

Infinite importing space means that you don't have to rely on WC3 Models and can basically make your very own environment without reaching the 4 Mbit limit...
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
Except then you don't get multiplayer. Easily, at least.
 

the Immortal

I know, I know...
Reaction score
51
> Except then you don't get multiplayer. Easily, at least.

The restriction was lifted to 8 Mb in 1.24.


On topic.. I like it, though it seems to create lots o' object data which is.. just impractical? And yes, the interface looks pretty decent and at the same time not-that-heavy as the FS ones. (think someone said that earlier but it's.. right).

And I think the buffs window should be only for that - buffs. Don't overdo it. Or at least add it as a module.

ps. 'not-that-heavy' for the user. It's much heavier as Object data than my WIP|FSInv for ex.
 

Jesus4Lyf

Good Idea™
Reaction score
397
it seems to create lots o' object data which is.. just impractical?
I don't see why that matters a bit, actually.

Edit: Progress.
JASS:
/*//! runtextmacro ItemType("BarkysHead")
    //! runtextmacro SetItemName("Barky's Head")
    //! runtextmacro SetItemIcon("Dog")
//! runtextmacro ItemStruct()
    private integer i=5
//! runtextmacro EndItem()*/

library MYSYS
//! externalblock extension=lua ObjectMerger $FILENAME$
    //! runtextmacro MYSYS__StartConfig()

//===========================================================================
// CONFIG AREA
//
    
    //===========================================================================
    // System Object Editor IDs.
    //
    
    //! runtextmacro MYSYS__BeginSysIds()
        // Uses:
        //  - 'Ixx&' for item type.
        //  - 'Axx&' for use ability.
        //  - 'Sxx&' for hider spellbook.
        
        //! runtextmacro MYSYS__AllowSysId("0a")
        //! runtextmacro MYSYS__AllowSysId("0b")
        //! runtextmacro MYSYS__AllowSysId("0c")
        //! runtextmacro MYSYS__AllowSysId("0d")
        //! runtextmacro MYSYS__AllowSysId("0e")
        //! runtextmacro MYSYS__AllowSysId("0f")
        //! runtextmacro MYSYS__AllowSysId("0g")
        //! runtextmacro MYSYS__AllowSysId("0h")
        //! runtextmacro MYSYS__AllowSysId("0i")
        //! runtextmacro MYSYS__AllowSysId("0j")
        //! runtextmacro MYSYS__AllowSysId("0k")
        //! runtextmacro MYSYS__AllowSysId("0l")
        //! runtextmacro MYSYS__AllowSysId("0m")
        //! runtextmacro MYSYS__AllowSysId("0n")
        //! runtextmacro MYSYS__AllowSysId("0o")
        //! runtextmacro MYSYS__AllowSysId("0p")
        //! runtextmacro MYSYS__AllowSysId("0q")
        //! runtextmacro MYSYS__AllowSysId("0r")
        //! runtextmacro MYSYS__AllowSysId("0s")
        //! runtextmacro MYSYS__AllowSysId("0t")
        //! runtextmacro MYSYS__AllowSysId("0u")
        //! runtextmacro MYSYS__AllowSysId("0v")
        //! runtextmacro MYSYS__AllowSysId("0w")
        //! runtextmacro MYSYS__AllowSysId("0x")
        //! runtextmacro MYSYS__AllowSysId("0y")
        //! runtextmacro MYSYS__AllowSysId("0z")
        //! runtextmacro MYSYS__AllowSysId("0A")
        //! runtextmacro MYSYS__AllowSysId("0B")
        //! runtextmacro MYSYS__AllowSysId("0C")
        //! runtextmacro MYSYS__AllowSysId("0D")
        //! runtextmacro MYSYS__AllowSysId("0E")
        //! runtextmacro MYSYS__AllowSysId("0F")
        //! runtextmacro MYSYS__AllowSysId("0G")
        //! runtextmacro MYSYS__AllowSysId("0H")
        //! runtextmacro MYSYS__AllowSysId("0I")
        //! runtextmacro MYSYS__AllowSysId("0J")
        //! runtextmacro MYSYS__AllowSysId("0K")
        //! runtextmacro MYSYS__AllowSysId("0L")
        //! runtextmacro MYSYS__AllowSysId("0M")
        //! runtextmacro MYSYS__AllowSysId("0N")
        //! runtextmacro MYSYS__AllowSysId("0O")
        //! runtextmacro MYSYS__AllowSysId("0P")
        //! runtextmacro MYSYS__AllowSysId("0Q")
        //! runtextmacro MYSYS__AllowSysId("0R")
        //! runtextmacro MYSYS__AllowSysId("0S")
        //! runtextmacro MYSYS__AllowSysId("0T")
        //! runtextmacro MYSYS__AllowSysId("0U")
        //! runtextmacro MYSYS__AllowSysId("0V")
        //! runtextmacro MYSYS__AllowSysId("0W")
        //! runtextmacro MYSYS__AllowSysId("0X")
        //! runtextmacro MYSYS__AllowSysId("0Y")
        //! runtextmacro MYSYS__AllowSysId("0Z")
        
    //! runtextmacro MYSYS__EndSysIds()
    
    //===========================================================================
    // System Object Editor Orders.
    //
    
    //! runtextmacro MYSYS__BeginSysOrders()
        
        //! runtextmacro MYSYS__AllowSysOrder("earthquake")
        //! runtextmacro MYSYS__AllowSysOrder("chainlightning")
        //! runtextmacro MYSYS__AllowSysOrder("thunderclap")
        //! runtextmacro MYSYS__AllowSysOrder("stormbolt")
        //! runtextmacro MYSYS__AllowSysOrder("mirrorimage")
        
    //! runtextmacro MYSYS__EndSysOrders()
    
    //===========================================================================
    // Pockets
    //
    
    //! runtextmacro MYSYS__BeginPockets()
        
        // Something special that relates to pockets.
        //! runtextmacro MYSYS__BeginLastOpenedIcon()
            //! runtextmacro MYSYS__SetLastOpenedIconHotkey("Y")
            //! runtextmacro MYSYS__SetLastOpenedIconX("2")
            //! runtextmacro MYSYS__SetLastOpenedIconY("1")
            //! runtextmacro MYSYS__SetLastOpenedIconIcon("ReplaceableTextures\\CommandButtons\\BTNChestOfGold.blp")
            //! runtextmacro MYSYS__SetLastOpenedIconTooltip("Open Inventor|cffffcc00y|r Pocket")
            //! runtextmacro MYSYS__SetLastOpenedIconUbertip("Opens up the last pocket you accessed in your inventory.")
        //! runtextmacro MYSYS__EndLastOpenedIcon()
        
        // Pockets.
        //! runtextmacro MYSYS__Pocket("Pocket1")
            
        //! runtextmacro MYSYS__EndPocket()
        
    //! runtextmacro MYSYS__EndPockets()
    
//===========================================================================
// END CONFIG AREA
//
    //! runtextmacro MYSYS__EndConfig()
    
    
    //===========================================================================
    // SYSTEM AREA (don't touch)
    //
    
    //! textmacro MYSYS__StartConfig
        // For IdBase struct members.
        //private keyword ...
    //! endtextmacro
    //! textmacro MYSYS__EndConfig
    //! endtextmacro
    
    
    //===========================================================================
    // Id Declaration
    //
    
    //! textmacro MYSYS__BeginSysIds
        private module IdBaseInitModule
            private static method onInit takes nothing returns nothing
                //! i sysIds={}
                //! i maxSysIds=0
    //! endtextmacro
    //! textmacro MYSYS__EndSysIds
            endmethod
        endmodule
        //! i sysIdsUsed=0
    //! endtextmacro
    
    //! textmacro MYSYS__AllowSysId takes SYSID
        set thistype.idMax=thistype.idMax+1
        //! i maxSysIds=maxSysIds+1
        
        set thistype(thistype.idMax).ItemStruct__itemType='I$SYSID$&'
        set thistype(thistype.idMax).ItemStruct__spellbookType='S$SYSID$&'
        set thistype(thistype.idMax).ItemStruct__abilityType='A$SYSID$&'
        //! i sysIds[maxSysIds]={itemType="I$SYSID$&", spellbookType="S$SYSID$&", abilityType="A$SYSID$&"}
    //! endtextmacro
    
    
    //===========================================================================
    // Order Declaration
    //
    
    //! textmacro MYSYS__BeginSysOrders
        globals
            private integer array SysOrders
            private integer MaxSysOrders=0
        endglobals
        private module OrdersInitModule
            private static method onInit takes nothing returns nothing
                //! i sysOrders={}
                //! i maxSysOrders=0
    //! endtextmacro
    //! textmacro MYSYS__EndSysOrders
            endmethod
        endmodule
        globals
            private integer SysOrdersUsed=0
        endglobals
        //! i sysOrdersUsed=0
    //! endtextmacro
    
    //! textmacro MYSYS__AllowSysOrder takes SYSORDER
        set MaxSysOrders=MaxSysOrders+1
        set SysOrders[MaxSysOrders]=OrderId("$SYSORDER$")
        //! i maxSysOrders=maxSysOrders+1
        //! i sysOrders[maxSysOrders]="$SYSORDER$"
    //! endtextmacro
    
    
    //===========================================================================
    // Pocket Declaration
    //
    
    //! textmacro MYSYS__BeginPockets
        private function PocketInit takes nothing returns nothing
            local Pocket this
            //! i setobjecttype("abilities")
            // Dummy ability for pockets.
            // Get id from first pocket's ability id (unused).
            //! i dummyItemAbility=sysIds[sysIdsUsed+1].abilityType
            //! i createobject("AItb",dummyItemAbility)
            //! i makechange(current,"acat","")
            //! i makechange(current,"anam","Dummy Item Ability")
            //! i makechange(current,"ansf","(ItemStruct)")
            //! i makechange(current,"Det1",1,0)
            //! i makechange(current,"aare",1,0)
            //! i makechange(current,"abuf",1,"")
            //! i makechange(current,"acdn",1,0)
            //! i makechange(current,"ahdu",1,0)
            //! i makechange(current,"adur",1,0)
            //! i makechange(current,"atar",1,"")
            // Init
            //! i maxPockets=0
    //! endtextmacro
    //! textmacro MYSYS__EndPockets
        endfunction
        //! i setobjecttype("abilities")
        //! i createobject("AInv","AInv")
        //! i if maxPockets>=6 then
            //! i makechange(current,"inv1",1,6)
        //! else
            //! i makechange(current,"inv1",1,maxPockets)
        //! i end
        private module PocketInitModule
            private static method onInit takes nothing returns nothing
                call PocketInit()
            endmethod
        endmodule
    //! endtextmacro
    
    //! textmacro MYSYS__BeginLastOpenedIcon
        //! i setobjecttype("abilities")
        //! i lastOpenedPocketAbility=sysIds[sysIdsUsed+1].spellbookType
        //! i createobject("Aspb",dummyItemAbility)
        //! i makechange(current,"aite",0)
        //! i makechange(current,"anam","Open Inventory Pocket")
        //! i makechange(current,"ansf","(ItemStruct)")
        //! i makechange(current,"spb4",1,11)
        //! i makechange(current,"spb3",1,0)
        //! i makechange(current,"spb2",1,0)
        // Default spell list.
        //! i makechange(current,"spb1",1,"")
        // Order Issues.
        globals
            private integer LAST_OPENED_OID
        endglobals
        set SysOrdersUsed=SysOrdersUsed+1
        set LAST_OPENED_OID=SysOrders[SysOrdersUsed]
        //! i sysOrdersUsed=sysOrdersUsed+1
        //! i LAST_OPENED_ORDER=sysOrders[sysOrdersUsed]
        //! i makechange(current,"aord",LAST_OPENED_ORDER)
        //! i makechange(current,"spb5",1,LAST_OPENED_ORDER)
        // Defaults.
        globals
            private string LAST_OPENED_HOTKEY="Y"
        endglobals
        //! i makechange(current,"ahky","Y")
        //! i makechange(current,"abpx",2)
        //! i makechange(current,"abpy",1)
        //! i makechange(current,"aart","ReplaceableTextures\\CommandButtons\\BTNChestOfGold.blp")
        //! i makechange(current,"atp1",1,"Open Inventor|cffffcc00y|r Pocket")
        //! i makechange(current,"aub1",1,"Opens up the last pocket you accessed in your inventory.")
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconHotkey takes VAL
        set LAST_OPENED_HOTKEY="$VAL$"
        //! i makechange(current,"ahky","$VAL$")
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconX takes VAL
        //! i makechange(current,"abpx",$VAL$)
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconY takes VAL
        //! i makechange(current,"abpy",$VAL$)
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconIcon takes VAL
        //! i makechange(current,"aart","$VAL$")
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconTooltip takes VAL
        //! i makechange(current,"atp1",1,"$VAL$")
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconUbertip takes VAL
        //! i makechange(current,"aub1",1,"$VAL$")
    //! endtextmacro
    //! textmacro MYSYS__EndLastOpenedIcon
    //! endtextmacro
    
    //! textmacro MYSYS__Pocket takes IDENTIFIER
        globals
            Pocket $IDENTIFIER$
        endglobals
        set $IDENTIFIER$=Pocket.create()
        set this=$IDENTIFIER$
        //! i sysIdsUsed=sysIdsUsed+1
        //! i maxPockets=maxPockets+1
        //! i $IDENTIFIER$=maxPockets
        //! i pocketIdentifier="$IDENTIFIER$"
        
        // Defaults.
        //! i pocketName=""
        //! i pocketDescription=""
        //! i pocketIcon=""
    //! endtextmacro
    
    //! textmacro MYSYS__SetPocketName takes NAME
        set this.ItemStruct__name="$NAME$"
        //! i pocketName="$NAME$"
    //! endtextmacro
    //! textmacro MYSYS__SetPocketDescription takes DESCRIPTION
        set this.ItemStruct__description="$DESCRIPTION$"
        //! i pocketDescription="$DESCRIPTION$"
    //! endtextmacro
    //! textmacro MYSYS__SetPocketIcon takes ICON
        //! i pocketIcon="$ICON$"
    //! endtextmacro
    
    //! textmacro MYSYS__EndPocket
        // Make object data.
        //! i setobjecttype("items")
        //! i createobject("ssil",sysIds[sysIdsUsed].itemType)
        //! i makechange(current,"iabi",dummyItemAbility)
        //! i makechange(current,"idro",0)
        //! i makechange(current,"isel",0)
        //! i makechange(current,"icla","Miscellaneous")
        //! i makechange(current,"igol",0)
        //! i makechange(current,"iicd",1)
        //! i makechange(current,"iprn",0)
        //! i makechange(current,"ilev",0)
        //! i makechange(current,"ipri",0)
        //! i makechange(current,"isto",0)
        //! i makechange(current,"istr",0)
        //! i makechange(current,"ides","")
        //! i makechange(current,"uhot","")
        //! i makechange(current,"utip","")
        //! i makechange(current,"iabi",pocketIcon)
        //! i makechange(current,"unam","pocketName")
        //! i makechange(current,"utub","pocketDescription")
    //! endtextmacro
    
    
    //===========================================================================
    // Item Declaration
    //
    
    //! textmacro ItemType takes IDENTIFIER
        globals
            integer $IDENTIFIER$
        endglobals
        private struct $IDENTIFIER$ extends Item
            private static method ItemStruct__init takes nothing returns nothing
                //! i itemIdentifier="$IDENTIFIER$"
                // Defaults.
                set ItemType(thistype).ItemStruct__name="$IDENTIFIER$"
                //! i itemName="$IDENTIFIER$"
                //! i itemPocket=0
                //! i itemIcon=""
                //! i itemHotkey=""
                //! i itemDescription=""
    //! endtextmacro
    //! textmacro ItemStruct
            endmethod
            implement ItemStruct
    //! endtextmacro
    //! textmacro EndItem
        endstruct
        // Make object data.
        //! i setobjecttype("items")
        //! i createobject("ssil",sysIds[sysIdsUsed].itemType)
        //! i makechange(current,"iabi",dummyItemAbility)
        //! i makechange(current,"idro",0)
        //! i makechange(current,"isel",0)
        //! i makechange(current,"icla","Miscellaneous")
        //! i makechange(current,"igol",0)
        //! i makechange(current,"iicd",1)
        //! i makechange(current,"iprn",0)
        //! i makechange(current,"ilev",0)
        //! i makechange(current,"ipri",0)
        //! i makechange(current,"isto",0)
        //! i makechange(current,"istr",0)
        //! i makechange(current,"ides","")
        //! i makechange(current,"uhot","")
        //! i makechange(current,"utip","")
        //! i makechange(current,"iabi",pocketIcon)
        //! i makechange(current,"unam","pocketName")
        //! i makechange(current,"utub","pocketDescription")
    //! endtextmacro
    
    //! textmacro SetItemName takes VAL
        set ItemType(thistype).ItemStruct__name="$VAL$"
        //! i itemName="$VAL$"
    //! endtextmacro
    //! textmacro SetItemPocket takes POCKET
        set ItemType(thistype).ItemStruct__pocket=$POCKET$
        //! i itemPocket=$POCKET$
    //! endtextmacro
    //! textmacro SetItemIcon takes VAL
        //! i itemIcon="$VAL$"
    //! endtextmacro
    //! textmacro SetItemHotkey takes VAL
        set ItemType(thistype).ItemStruct__hotkey="$VAL$"
        //! i itemHotkey="$VAL$"
    //! endtextmacro
    //! textmacro SetItemDescription takes VAL
        set ItemType(thistype).ItemStruct__description="$VAL$"
        //! i itemDescription="$VAL$"
    //! endtextmacro
    
    /*
    //! runtextmacro ItemType("BarkysHead")
        //! runtextmacro SetItemName("Barky's Head")
        //! runtextmacro SetItemIcon("Dog")
    //! runtextmacro ItemStruct()
        private integer i=5
    //! runtextmacro EndItem()
    */
    
    //===========================================================================
    // JASS System
    //
    
    //===========================================================================
    // Pockets and ItemTypes
    //
    
    //private function interface CreateItemTypeXY takes real x, real y returns integer
    //private function interface CreateItemUnit takes unit u
    
    private struct IdBase
        static integer idMax=0
        implement IdBaseInitModule
        implement OrdersInitModule
        
        // Autofilled.
        integer ItemStruct__itemType
        integer ItemStruct__spellbookType
        integer ItemStruct__abilityType
        
        // Filled on init.
        string ItemStruct__name
        string ItemStruct__description
    endstruct
    
    //! textmacro MYSYS__Expose takes TYPE, MEMBER
        method operator $MEMBER$ takes nothing returns $TYPE$
            return this.ItemStruct__$MEMBER$
        endmethod
    //! endtextmacro
    
    struct Pocket extends IdBase
        //! runtextmacro MYSYS__Expose("string","name")
        //! runtextmacro MYSYS__Expose("string","description")
        
        private static integer pocketMax=0
        implement PocketInitModule
        
        
    endstruct
    
    struct ItemType extends IdBase
        //! runtextmacro MYSYS__Expose("string","name")
        //! runtextmacro MYSYS__Expose("string","description")
        //! runtextmacro MYSYS__Expose("integer","itemType")
        //! runtextmacro MYSYS__Expose("integer","abilityType")
        
        string ItemStruct__hotkey
        //! runtextmacro MYSYS__Expose("string","hotkey")
        Pocket ItemStruct__pocket
        //! runtextmacro MYSYS__Expose("Pocket","pocket")
        
        integer ItemStruct__goldCost
        //! runtextmacro MYSYS__Expose("integer","goldCost")
        integer ItemStruct__lumberCost
        //! runtextmacro MYSYS__Expose("integer","lumberCost")
        
        // Spawn Instance of ItemType
        //private method spawn takes real x, real y returns Item
        
    endstruct
    
    //===========================================================================
    // ItemStruct
    //
    
    private interface DEFAULTS
        method onCreate takes nothing returns nothing defaults nothing // always on x/y.
        method onAcquire takes nothing returns nothing defaults nothing
        method onDrop takes nothing returns nothing defaults nothing
    endinterface
    
    struct Item extends DEFAULTS
        static method operator [] takes item i returns thistype
            return thistype(GetItemUserData(i))
        endmethod
        
        readonly item item
        readonly unit holder
        
        method operator x takes nothing returns real
            return GetItemX(this.item)
        endmethod
        method operator y takes nothing returns real
            return GetItemY(this.item)
        endmethod
        method setPosition takes real x, real y returns nothing
            if this.holder==null then
                call SetItemPosition(this.item,x,y)
            else
                //call CreateItem(
            endif
        endmethod
    endstruct
    
    module ItemStruct // implemented in all items.
        private delegate ItemType=ItemType(thistype)
        private static method onInit takes nothing returns nothing
            // thistype is a global integer.
            set thistype=ItemType.create()
            call thistype.ItemStruct__init()
        endmethod
    endmodule
    
    
    //===========================================================================
    // JASS Interface
    //
    
    function CreateItemXY takes integer itemType, real x, real y returns Item
        return 0
    endfunction
endlibrary
Nearly finished the object data stuff. :D
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
Doesn't massive amount of object data correspond to massive amount of loading time?
 

Viikuna

No Marlo no game.
Reaction score
265
No, if you use widgetizer.

Back in the day when Blizzard added the object editor to WE, people did notice loading times incereasing because of it.
Before that this stuff was done by editing abilitydata.slk ( or whatever it is called ), which did not have this side effect.

So, some guy called TertiaryEye ( or some guy like that ) figgured out how to get rid of that extra loading time, and guy called PitzerMike released this Widgetizer tool that converts all this object data back to slk format, so it takes like no space.

So with that tool you can have shitloads of object data without having to worry about loading time incereasing because of it.

If I recall correctly, Cassiel and those Tides of Blood guys once tested if it would be possible to generate more that 40 000 object editor abilities with some program they made, and it worked just fine, thanks to Widgetizer.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Doesn't massive amount of object data correspond to massive amount of loading time?
Wigitizer should help that. Further, each item in this case makes 3 objects. In many maps, no one gives a rats about making abilities with up to 5 levels at the drop of a hat. So meh?

Edit: Well this compiles, and should manage all object data.
JASS:
/*//! runtextmacro ItemType("BarkysHead")
    //! runtextmacro SetItemName("Barky's Head")
    //! runtextmacro SetItemIcon("Dog")
//! runtextmacro ItemStruct()
    private integer i=5
//! runtextmacro EndItem()*/

library MYSYS
//! externalblock extension=lua ObjectMerger $FILENAME$
    //! runtextmacro MYSYS__StartConfig()

//===========================================================================
// CONFIG AREA
//
    
    //===========================================================================
    // System Object Editor IDs.
    //
    
    //! runtextmacro MYSYS__BeginSysIds()
        // Uses:
        //  - 'Ixx&' for item type.
        //  - 'Axx&' for use ability.
        //  - 'Sxx&' for hider spellbook.
        
        //! runtextmacro MYSYS__AllowSysId("0a")
        //! runtextmacro MYSYS__AllowSysId("0b")
        //! runtextmacro MYSYS__AllowSysId("0c")
        //! runtextmacro MYSYS__AllowSysId("0d")
        //! runtextmacro MYSYS__AllowSysId("0e")
        //! runtextmacro MYSYS__AllowSysId("0f")
        //! runtextmacro MYSYS__AllowSysId("0g")
        //! runtextmacro MYSYS__AllowSysId("0h")
        //! runtextmacro MYSYS__AllowSysId("0i")
        //! runtextmacro MYSYS__AllowSysId("0j")
        //! runtextmacro MYSYS__AllowSysId("0k")
        //! runtextmacro MYSYS__AllowSysId("0l")
        //! runtextmacro MYSYS__AllowSysId("0m")
        //! runtextmacro MYSYS__AllowSysId("0n")
        //! runtextmacro MYSYS__AllowSysId("0o")
        //! runtextmacro MYSYS__AllowSysId("0p")
        //! runtextmacro MYSYS__AllowSysId("0q")
        //! runtextmacro MYSYS__AllowSysId("0r")
        //! runtextmacro MYSYS__AllowSysId("0s")
        //! runtextmacro MYSYS__AllowSysId("0t")
        //! runtextmacro MYSYS__AllowSysId("0u")
        //! runtextmacro MYSYS__AllowSysId("0v")
        //! runtextmacro MYSYS__AllowSysId("0w")
        //! runtextmacro MYSYS__AllowSysId("0x")
        //! runtextmacro MYSYS__AllowSysId("0y")
        //! runtextmacro MYSYS__AllowSysId("0z")
        //! runtextmacro MYSYS__AllowSysId("0A")
        //! runtextmacro MYSYS__AllowSysId("0B")
        //! runtextmacro MYSYS__AllowSysId("0C")
        //! runtextmacro MYSYS__AllowSysId("0D")
        //! runtextmacro MYSYS__AllowSysId("0E")
        //! runtextmacro MYSYS__AllowSysId("0F")
        //! runtextmacro MYSYS__AllowSysId("0G")
        //! runtextmacro MYSYS__AllowSysId("0H")
        //! runtextmacro MYSYS__AllowSysId("0I")
        //! runtextmacro MYSYS__AllowSysId("0J")
        //! runtextmacro MYSYS__AllowSysId("0K")
        //! runtextmacro MYSYS__AllowSysId("0L")
        //! runtextmacro MYSYS__AllowSysId("0M")
        //! runtextmacro MYSYS__AllowSysId("0N")
        //! runtextmacro MYSYS__AllowSysId("0O")
        //! runtextmacro MYSYS__AllowSysId("0P")
        //! runtextmacro MYSYS__AllowSysId("0Q")
        //! runtextmacro MYSYS__AllowSysId("0R")
        //! runtextmacro MYSYS__AllowSysId("0S")
        //! runtextmacro MYSYS__AllowSysId("0T")
        //! runtextmacro MYSYS__AllowSysId("0U")
        //! runtextmacro MYSYS__AllowSysId("0V")
        //! runtextmacro MYSYS__AllowSysId("0W")
        //! runtextmacro MYSYS__AllowSysId("0X")
        //! runtextmacro MYSYS__AllowSysId("0Y")
        //! runtextmacro MYSYS__AllowSysId("0Z")
        
    //! runtextmacro MYSYS__EndSysIds()
    
    //===========================================================================
    // System Object Editor Orders.
    //
    
    //! runtextmacro MYSYS__BeginSysOrders()
        
        //! runtextmacro MYSYS__AllowSysOrder("earthquake")
        //! runtextmacro MYSYS__AllowSysOrder("chainlightning")
        //! runtextmacro MYSYS__AllowSysOrder("thunderclap")
        //! runtextmacro MYSYS__AllowSysOrder("stormbolt")
        //! runtextmacro MYSYS__AllowSysOrder("mirrorimage")
        
    //! runtextmacro MYSYS__EndSysOrders()
    
    //===========================================================================
    // Pockets
    //
    
    //! runtextmacro MYSYS__BeginPockets()
        
        // Something special that relates to pockets.
        //! runtextmacro MYSYS__BeginLastOpenedIcon()
            //! runtextmacro MYSYS__SetLastOpenedIconHotkey("Y")
            //! runtextmacro MYSYS__SetLastOpenedIconX("2")
            //! runtextmacro MYSYS__SetLastOpenedIconY("1")
            //! runtextmacro MYSYS__SetLastOpenedIconIcon("ReplaceableTextures\\CommandButtons\\BTNChestOfGold.blp")
            //! runtextmacro MYSYS__SetLastOpenedIconTooltip("Open Inventor|cffffcc00y|r Pocket")
            //! runtextmacro MYSYS__SetLastOpenedIconUbertip("Opens up the last pocket you accessed in your inventory.")
        //! runtextmacro MYSYS__EndLastOpenedIcon()
        
        // Pockets.
        //! runtextmacro MYSYS__Pocket("Pocket1")
            
        //! runtextmacro MYSYS__EndPocket()
        
    //! runtextmacro MYSYS__EndPockets()
    
//===========================================================================
// END CONFIG AREA
//
    //! runtextmacro MYSYS__EndConfig()
    
    
    //===========================================================================
    // SYSTEM AREA (don't touch)
    //
    
    //! textmacro MYSYS__StartConfig
        // For IdBase struct members.
        //private keyword ...
    //! endtextmacro
    //! textmacro MYSYS__EndConfig
    //! endtextmacro
    
    
    //===========================================================================
    // Id Declaration
    //
    
    //! textmacro MYSYS__BeginSysIds
        private module IdBaseInitModule
            private static method onInit takes nothing returns nothing
                //! i sysIds={}
                //! i maxSysIds=0
    //! endtextmacro
    //! textmacro MYSYS__EndSysIds
            endmethod
        endmodule
        //! i sysIdsUsed=0
    //! endtextmacro
    
    //! textmacro MYSYS__AllowSysId takes SYSID
        set thistype.idMax=thistype.idMax+1
        //! i maxSysIds=maxSysIds+1
        
        set thistype(thistype.idMax).ItemStruct__itemType='I$SYSID$&'
        set thistype(thistype.idMax).ItemStruct__spellbookType='S$SYSID$&'
        set thistype(thistype.idMax).ItemStruct__abilityType='A$SYSID$&'
        //! i sysIds[maxSysIds]={itemType="I$SYSID$&", spellbookType="S$SYSID$&", abilityType="A$SYSID$&"}
    //! endtextmacro
    
    
    //===========================================================================
    // Order Declaration
    //
    
    //! textmacro MYSYS__BeginSysOrders
        globals
            private integer array SysOrders
            private integer MaxSysOrders=0
        endglobals
        private module OrdersInitModule
            private static method onInit takes nothing returns nothing
                //! i sysOrders={}
                //! i maxSysOrders=0
    //! endtextmacro
    //! textmacro MYSYS__EndSysOrders
            endmethod
        endmodule
        globals
            private integer SysOrdersUsed=0
        endglobals
        //! i sysOrdersUsed=0
    //! endtextmacro
    
    //! textmacro MYSYS__AllowSysOrder takes SYSORDER
        set MaxSysOrders=MaxSysOrders+1
        set SysOrders[MaxSysOrders]=OrderId("$SYSORDER$")
        //! i maxSysOrders=maxSysOrders+1
        //! i sysOrders[maxSysOrders]="$SYSORDER$"
    //! endtextmacro
    
    
    //===========================================================================
    // Pocket Declaration
    //
    
    //! textmacro MYSYS__BeginPockets
        private function PocketInit takes nothing returns nothing
            local Pocket this
            //! i setobjecttype("abilities")
            // Dummy ability for pockets.
            // Get id from first pocket's ability id (unused).
            //! i dummyItemAbility=sysIds[sysIdsUsed+1].abilityType
            //! i createobject("AItb",dummyItemAbility)
            //! i makechange(current,"acat","")
            //! i makechange(current,"anam","Dummy Item Ability")
            //! i makechange(current,"ansf","(ItemStruct)")
            //! i makechange(current,"Det1",1,0)
            //! i makechange(current,"aare",1,0)
            //! i makechange(current,"abuf",1,"")
            //! i makechange(current,"acdn",1,0)
            //! i makechange(current,"ahdu",1,0)
            //! i makechange(current,"adur",1,0)
            //! i makechange(current,"atar",1,"")
            // Init
            //! i maxPockets=0
    //! endtextmacro
    //! textmacro MYSYS__EndPockets
        endfunction
        //! i setobjecttype("abilities")
        //! i createobject("AInv","AInv")
        //! i if maxPockets>=6 then
            //! i makechange(current,"inv1",1,6)
        //! else
            //! i makechange(current,"inv1",1,maxPockets)
        //! i end
        // Pocket-orders duplication
        //! i pocketOrders={}
        //! i for tempPocketNum=0,maxPockets do
            //! i pocketOrders[tempPocketNum]=sysOrdersUsed
        //! i end
        private module PocketInitModule
            private static method onInit takes nothing returns nothing
                call PocketInit()
            endmethod
        endmodule
    //! endtextmacro
    
    //! textmacro MYSYS__BeginLastOpenedIcon
        //! i setobjecttype("abilities")
        //! i lastOpenedPocketAbility=sysIds[sysIdsUsed+1].spellbookType
        //! i createobject("Aspb",dummyItemAbility)
        //! i makechange(current,"aite",0)
        //! i makechange(current,"anam","Open Inventory Pocket")
        //! i makechange(current,"ansf","(ItemStruct)")
        //! i makechange(current,"spb4",1,11)
        //! i makechange(current,"spb3",1,0)
        //! i makechange(current,"spb2",1,0)
        // Default spell list.
        //! i makechange(current,"spb1",1,"")
        // Order Issues.
        globals
            private integer LAST_OPENED_OID
        endglobals
        set SysOrdersUsed=SysOrdersUsed+1
        set LAST_OPENED_OID=SysOrders[SysOrdersUsed]
        //! i sysOrdersUsed=sysOrdersUsed+1
        //! i LAST_OPENED_ORDER=sysOrders[sysOrdersUsed]
        //! i makechange(current,"aord",LAST_OPENED_ORDER)
        //! i makechange(current,"spb5",1,LAST_OPENED_ORDER)
        // Defaults.
        globals
            private string LAST_OPENED_HOTKEY="Y"
        endglobals
        //! i makechange(current,"ahky","Y")
        //! i makechange(current,"abpx",2)
        //! i makechange(current,"abpy",1)
        //! i makechange(current,"aart","ReplaceableTextures\\CommandButtons\\BTNChestOfGold.blp")
        //! i makechange(current,"atp1",1,"Open Inventor|cffffcc00y|r Pocket")
        //! i makechange(current,"aub1",1,"Opens up the last pocket you accessed in your inventory.")
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconHotkey takes VAL
        set LAST_OPENED_HOTKEY="$VAL$"
        //! i makechange(current,"ahky","$VAL$")
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconX takes VAL
        //! i makechange(current,"abpx",$VAL$)
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconY takes VAL
        //! i makechange(current,"abpy",$VAL$)
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconIcon takes VAL
        //! i makechange(current,"aart","$VAL$")
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconTooltip takes VAL
        //! i makechange(current,"atp1",1,"$VAL$")
    //! endtextmacro
    //! textmacro MYSYS__SetLastOpenedIconUbertip takes VAL
        //! i makechange(current,"aub1",1,"$VAL$")
    //! endtextmacro
    //! textmacro MYSYS__EndLastOpenedIcon
    //! endtextmacro
    
    //! textmacro MYSYS__Pocket takes IDENTIFIER
        globals
            Pocket $IDENTIFIER$
        endglobals
        set $IDENTIFIER$=Pocket.create()
        set this=$IDENTIFIER$
        //! i sysIdsUsed=sysIdsUsed+1
        //! i maxPockets=maxPockets+1
        //! i $IDENTIFIER$=maxPockets
        //! i pocketIdentifier="$IDENTIFIER$"
        
        // Defaults.
        //! i pocketName=""
        //! i pocketDescription=""
        //! i pocketIcon=""
    //! endtextmacro
    
    //! textmacro MYSYS__SetPocketName takes NAME
        set this.ItemStruct__name="$NAME$"
        //! i pocketName="$NAME$"
    //! endtextmacro
    //! textmacro MYSYS__SetPocketDescription takes DESCRIPTION
        set this.ItemStruct__description="$DESCRIPTION$"
        //! i pocketDescription="$DESCRIPTION$"
    //! endtextmacro
    //! textmacro MYSYS__SetPocketIcon takes ICON
        //! i pocketIcon="$ICON$"
    //! endtextmacro
    
    //! textmacro MYSYS__EndPocket
        // Make object data.
        //! i setobjecttype("items")
        //! i createobject("ssil",sysIds[sysIdsUsed].itemType)
        //! i makechange(current,"iabi",dummyItemAbility)
        //! i makechange(current,"idro",0)
        //! i makechange(current,"isel",0)
        //! i makechange(current,"icla","Miscellaneous")
        //! i makechange(current,"igol",0)
        //! i makechange(current,"iicd",1)
        //! i makechange(current,"iprn",0)
        //! i makechange(current,"ilev",0)
        //! i makechange(current,"ipri",0)
        //! i makechange(current,"isto",0)
        //! i makechange(current,"istr",0)
        //! i makechange(current,"ides","")
        //! i makechange(current,"uhot","")
        //! i makechange(current,"utip","")
        //! i makechange(current,"iabi",pocketIcon)
        //! i makechange(current,"unam",pocketName)
        //! i makechange(current,"utub",pocketDescription)
    //! endtextmacro
    
    
    //===========================================================================
    // Item Declaration
    //
    
    //! textmacro ItemType takes IDENTIFIER
        globals
            integer $IDENTIFIER$
        endglobals
        struct ItemStruct__$IDENTIFIER$ extends Item
            //! i itemIdentifier="$IDENTIFIER$"
            private static method ItemStruct__init takes nothing returns nothing
                local integer i=bj_MAX_PLAYERS
                local ItemType itemType=ItemType.create()
                set $IDENTIFIER$=itemType
                loop
                    set i=i-1
                    call SetPlayerAbilityAvailable(Player(i),ItemType($IDENTIFIER$).ItemStruct__spellbookType,false)
                    exitwhen i==0
                endloop
                //! i sysIdsUsed=sysIdsUsed+1
                // Defaults.
                set ItemType($IDENTIFIER$).ItemStruct__name="$IDENTIFIER$"
                //! i itemName="$IDENTIFIER$"
                set ItemType($IDENTIFIER$).ItemStruct__model="Objects\\InventoryItems\\TreasureChest\\treasurechest.mdl"
                //! i itemModel="Objects\\InventoryItems\\TreasureChest\\treasurechest.mdl"
                set ItemType($IDENTIFIER$).ItemStruct__redTint=255
                set ItemType($IDENTIFIER$).ItemStruct__greenTint=255
                set ItemType($IDENTIFIER$).ItemStruct__blueTint=255
                //! i itemTint={red=255,green=255,blue=255}
                set ItemType($IDENTIFIER$).ItemStruct__scale=1.0
                //! i itemScale=1.0
                set ItemType($IDENTIFIER$).ItemStruct__goldCost=0
                set ItemType($IDENTIFIER$).ItemStruct__lumberCost=0
                //! i itemCost={gold=0,lumber=0}
                set ItemType($IDENTIFIER$).ItemStruct__stockMax=0
                //! i itemStockMax=0
                set ItemType($IDENTIFIER$).ItemStruct__stockReplenishInterval=0
                //! i itemStockReplenishInterval=0
                set ItemType($IDENTIFIER$).ItemStruct__stockStartDelay=0
                //! i itemStockStartDelay=0
                //! i itemPocket=0
                //! i itemIcon=""
                //! i itemHotkey=""
                //! i itemDescription=""
                
                //! i itemBaseAbility="ANcl"
                //! i itemAbilityData={}
                //! i itemAbilityLevelData={}
    //! endtextmacro
    //! textmacro ItemStruct
            endmethod
            implement ItemStruct
    //! endtextmacro
    //! textmacro EndItem
        endstruct
        // Make object data.
        // Dummy item.
        //! i setobjecttype("items")
        //! i createobject("rspd",sysIds[sysIdsUsed].itemType)
        //! i makechange(current,"iabi",dummyItemAbility)
        //! i makechange(current,"iico",itemIcon)
        //! i makechange(current,"ifil",itemModel)
        //! i makechange(current,"iclr",itemTint.red)
        //! i makechange(current,"iclg",itemTint.green)
        //! i makechange(current,"iclb",itemTint.blue)
        //! i makechange(current,"isel",1)
        //! i makechange(current,"igol",itemCost.gold)
        //! i makechange(current,"ilub",itemCost.lumber)
        //! i makechange(current,"iicd",1)
        //! i makechange(current,"isto",itemStockMax)
        //! i makechange(current,"istr",itemStockReplenishInterval)
        //! i makechange(current,"isst",itemStockStartDelay)
        //! i makechange(current,"ides",itemDescription)
        //! i makechange(current,"uhot",itemHotkey)
        //! i makechange(current,"utip","[|cffffcc00"..itemHotkey.."|r] Purchase "..itemName)
        //! i makechange(current,"utub",itemDescription)
        // Use ability.
        //! i setobjecttype("abilities")
        //! i createobject(itemBaseAbility,sysIds[sysIdsUsed].abilityType)
        //! i makechange(current,"aart",itemIcon)
        //! i makechange(current,"aher",0)
        //! i makechange(current,"aite",0)
        //! i makechange(current,"alev",1)
        //! i makechange(current,"ahky",itemHotkey)
        //! i makechange(current,"anam",itemName)
        //! i if itemBaseAbility=="ANcl" then
            //! i pocketOrders[itemPocket]=pocketOrders[itemPocket]+1
            //! i makechange(current,"aord",sysOrders[pocketOrders[itemPocket]])
            //! i makechange(current,"Ncl6",1,sysOrders[pocketOrders[itemPocket]])
            //! i makechange(current,"Ncl5",1,0)
            //! i makechange(current,"Ncl1",1,0)
            //! i makechange(current,"Ncl3",1,1)
        //! i end
        //! i makechange(current,"atp1","[|cffffcc00"..itemHotkey".."|r] "..itemName)
        //! i makechange(current,"aub1",itemDescription)
        //! for key,value in pairs(itemAbilityData) do
            //! i makechange(current,key,value)
        //! end
        //! for key,value in pairs(itemAbilityLevelData) do
            //! i makechange(current,key,1,value)
        //! end
        // Spellbook
        //! i setobjecttype("abilities")
        //! i createobject("Aspb",sysIds[sysIdsUsed].spellbookType)
        //! i makechange(current,"aart","")
        //! i makechange(current,"aite",0)
        //! i makechange(current,"anam",itemName)
        //! i makechange(current,"ansf","(ItemStruct Spellbook)")
        //! i makechange(current,"aord",LAST_OPENED_ORDER)
        //! i makechange(current,"spb5",LAST_OPENED_ORDER)
        //! i makechange(current,"spb4",11)
        //! i makechange(current,"spb3",0)
        //! i makechange(current,"spb2",0)
        //! i makechange(current,"spb1",sysIds[sysIdsUsed].abilityType)
    //! endtextmacro
    
    //! textmacro SetItemName takes VAL
        set itemType.ItemStruct__name="$VAL$"
        //! i itemName="$VAL$"
    //! endtextmacro
    //! textmacro SetItemPocket takes POCKET
        set itemType.ItemStruct__pocket=$POCKET$
        //! i itemPocket=$POCKET$
    //! endtextmacro
    //! textmacro SetItemIcon takes VAL
        set itemType.ItemStruct__icon="$VAL$"
        //! i itemIcon="$VAL$"
    //! endtextmacro
    //! textmacro SetItemHotkey takes VAL
        set itemType.ItemStruct__hotkey="$VAL$"
        //! i itemHotkey="$VAL$"
    //! endtextmacro
    //! textmacro SetItemDescription takes VAL
        set itemType.ItemStruct__description="$VAL$"
        //! i itemDescription="$VAL$"
    //! endtextmacro
    //! textmacro SetItemModel takes VAL
        set itemType.ItemStruct__model="$VAL$"
        //! i itemModel="$VAL$"
    //! endtextmacro
    //! textmacro SetItemTint takes RED, GREEN, BLUE
        set itemType.ItemStruct__redTint=$RED$
        set itemType.ItemStruct__greenTint=$GREEN$
        set itemType.ItemStruct__blueTint=$BLUE$
        //! i itemTint={red=$RED$,green=$GREEN$,blue=$BLUE$}
    //! endtextmacro
    //! textmacro SetItemScale takes VAL
        set itemType.ItemStruct__scale=$VAL$
        //! i itemScale="$VAL$"
    //! endtextmacro
    //! textmacro SetItemCost takes GOLD, LUMBER
        set itemType.ItemStruct__goldCost=$GOLD$
        set itemType.ItemStruct__lumberCost=$LUMBER$
        //! i itemCost={gold=$GOLD$,lumber=$LUMBER$}
    //! endtextmacro
    //! textmacro SetItemStockMax takes VAL
        set itemType.ItemStruct__stockMax=$VAL$
        //! i itemStockMax=$VAL$
    //! endtextmacro
    //! textmacro SetItemStockReplenishInterval takes VAL
        set itemType.ItemStruct__stockReplenishInterval=$VAL$
        //! i itemStockReplenishInterval=$VAL$
    //! endtextmacro
    //! textmacro SetItemStockStartDelay takes VAL
        set itemType.ItemStruct__stockStartDelay=$VAL$
        //! i itemStockStartDelay=$VAL$
    //! endtextmacro
    //! textmacro SetItemBaseAbility takes VAL
        //! i itemBaseAbility="$VAL$"
    //! endtextmacro
    //! textmacro SetItemAbilityData takes ATTRIBUTE, VALUE
        //! i itemAbilityData["$ATTRIBUTE$"]="$VALUE$"
    //! endtextmacro
    //! textmacro SetItemAbilityLevelData takes ATTRIBUTE, VALUE
        //! i itemAbilityData["$ATTRIBUTE$"]="$VALUE$"
    //! endtextmacro
    
    //===========================================================================
    // JASS System
    //
    
    //===========================================================================
    // Pockets and ItemTypes
    //
    
    //private function interface CreateItemTypeXY takes real x, real y returns integer
    //private function interface CreateItemUnit takes unit u
    
    private struct IdBase
        static integer idMax=0
        implement IdBaseInitModule
        implement OrdersInitModule
        
        // Autofilled.
        integer ItemStruct__itemType
        integer ItemStruct__spellbookType
        integer ItemStruct__abilityType
        
        // Filled on init.
        string ItemStruct__name
        string ItemStruct__description
        string ItemStruct__icon
        string ItemStruct__model
    endstruct
    
    //! textmacro MYSYS__Expose takes TYPE, MEMBER
        method operator $MEMBER$ takes nothing returns $TYPE$
            return this.ItemStruct__$MEMBER$
        endmethod
    //! endtextmacro
    
    struct Pocket extends IdBase
        //! runtextmacro MYSYS__Expose("string","name")
        //! runtextmacro MYSYS__Expose("string","description")
        
        private static integer pocketMax=0
        implement PocketInitModule
        
        
    endstruct
    
    struct ItemType extends IdBase
        //! runtextmacro MYSYS__Expose("string","name")
        //! runtextmacro MYSYS__Expose("string","description")
        //! runtextmacro MYSYS__Expose("integer","itemType")
        //! runtextmacro MYSYS__Expose("integer","abilityType")
        
        string ItemStruct__hotkey
        //! runtextmacro MYSYS__Expose("string","hotkey")
        Pocket ItemStruct__pocket
        //! runtextmacro MYSYS__Expose("Pocket","pocket")
        integer ItemStruct__redTint=255
        //! runtextmacro MYSYS__Expose("integer","redTint")
        integer ItemStruct__greenTint=255
        //! runtextmacro MYSYS__Expose("integer","greenTint")
        integer ItemStruct__blueTint=255
        //! runtextmacro MYSYS__Expose("integer","blueTint")
        real ItemStruct__scale=1.0
        //! runtextmacro MYSYS__Expose("real","scale")
        integer ItemStruct__goldCost=0
        //! runtextmacro MYSYS__Expose("integer","goldCost")
        integer ItemStruct__lumberCost=0
        //! runtextmacro MYSYS__Expose("integer","lumberCost")
        integer ItemStruct__stockMax=0
        //! runtextmacro MYSYS__Expose("integer","stockMax")
        integer ItemStruct__stockReplenishInterval=0
        //! runtextmacro MYSYS__Expose("integer","stockReplenishInterval")
        integer ItemStruct__stockStartDelay=0
        //! runtextmacro MYSYS__Expose("integer","stockStartDelay")
        
        // Spawn Instance of ItemType
        //private method spawn takes real x, real y returns Item
        
    endstruct
    
    //===========================================================================
    // ItemStruct
    //
    
    private interface DEFAULTS
        method onCreate takes nothing returns nothing defaults nothing // always on x/y.
        method onAcquire takes nothing returns nothing defaults nothing
        method onDrop takes nothing returns nothing defaults nothing
    endinterface
    
    struct Item extends DEFAULTS
        static method operator [] takes item i returns thistype
            return thistype(GetItemUserData(i))
        endmethod
        
        readonly item item
        readonly unit holder
        delegate ItemType ItemStruct__itemType=ItemType(0)
        //! runtextmacro MYSYS__Expose("ItemType","itemType")
        
        method operator x takes nothing returns real
            return GetItemX(this.item)
        endmethod
        method operator y takes nothing returns real
            return GetItemY(this.item)
        endmethod
        method setPosition takes real x, real y returns nothing
            if this.holder==null then
                call SetItemPosition(this.item,x,y)
            else
                //call CreateItem(
            endif
        endmethod
    endstruct
    
    module ItemStruct // implemented in all items.
        private static method onInit takes nothing returns nothing
            call thistype.ItemStruct__init()
        endmethod
    endmodule
    
    
    //===========================================================================
    // JASS Interface
    //
    
    function CreateItemXY takes integer itemType, real x, real y returns Item
        return 0
    endfunction
endlibrary

That supports something like:
JASS:
//! runtextmacro ItemType("Sword")
    //! runtextmacro SetItemName("Really Big Sword")
    //! runtextmacro SetItemDescription("No really, this sword is huge.")
    //! runtextmacro SetItemHotkey("X")
    //! runtextmacro SetItemIcon("ReplaceableTextures\\\\CommandButtons\\\\BTNDaggerOfEscape.blp")
//! runtextmacro ItemStruct()
    
//! runtextmacro EndItem()

So far.
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Wow, so we can finally creating object editor stuff with the only downsides of an ugly interface and a negligible increase of save time? That could be really awesome for Item Systems... I just imagine how frigging annoying it is to work with the object editor especially when your chronology messes up duo to new objects or whatever.

But does this run every time I save the map and create the objects then? That would be horrible to test then since once created I had to remove the objects again I guess?
 

Jesus4Lyf

Good Idea™
Reaction score
397
But does this run every time I save the map and create the objects then? That would be horrible to test then since once created I had to remove the objects again I guess?
Conveniently, my script is written in a way that will lose all the items from the previous generation, so it has a fresh start each time. :cool: In fact, they are invisible in the object editor (always).

In fact, you don't even know what the ids of the objects will be. But see, I've written this in a very supportive vJass way... In fact, for any item type MyItemType you can use:
JASS:
MyItemType.itemType (returns the actual type, for adding to stops, etc)
MyItemType.goldCost (you can get its gold)
MyItemType.icon (yep, it's icon as a string)
MyItemType.model (you guessed it.)
// and much more: .abilityType, .redTint, .scale, .description, .name...

And every item will have its type as a delegate, meaning all those fields will be valid automatically for each item.

So this powerfully merges object data and JASS with attachment and stuff... I'm still working on it. Just need to test the object data stuff and then it's onto the JASS side of things. :)
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
It occurs to me that a system like this for generating code-specified custom buffs with all their data (icon, tooltip text, special FX, so on) and especially how they affect units (attack speed, armor modification, damage bonus, spell damage resistance, etc., all possible bonus types supported, and of course duration), with support for stacking (either within the same status icon or up to a number of separate instances, and of course it would generate appropriate levels for all possible combinations of stacking), and of course a method handling their application and all related disabled spellbooks, would be yummy.
 

Jesus4Lyf

Good Idea™
Reaction score
397
It occurs to me that a system like this for generating code-specified custom buffs with all their data (icon, tooltip text, special FX, so on) and especially how they affect units (attack speed, armor modification, damage bonus, spell damage resistance, etc., all possible bonus types supported, and of course duration), with support for stacking (either within the same status icon or up to a number of separate instances, and of course it would generate appropriate levels for all possible combinations of stacking), and of course a method handling their application and all related disabled spellbooks, would be yummy.
Well, hence my next sys would probably be BuffStruct. Very similar to ItemStruct. Would play nicely with SpellStruct.

Actually, you'd be able to make an item with ItemStruct which casts a spell caught by SpellStruct which would apply a buff from BuffStruct. XD

But seriously, no joke this stuff is painful to write.
 
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