System Customizable Item System

wraithseeker

Tired.
Reaction score
122
attachment.php

Requires Table, UnitProperties, AutoIndex

Documention
JASS:
Customizable Item System
    v1.04                                                       Made by wraithseeker
                                            
                                            
                                        Credits
                                        
                                Thanks to Pyrogasm for helping me.
                                Thanks to Litany for UnitProperties.
                                Thanks to Vexorian for Table.
                                Thanks to grim001 for AutoIndex.
                                
                            Pros
                        - You do not have to do much OE editing as you only need to set stats in the Initialization function.
                        - Allows 12 inventory for units while carrying bonus in backpack
                        - MUI and leakless
                        - Allow custom item stats.
                        - Allows custom random item stats generating
                        - Configurable and useful
                        - Recipes
                        - Set Items
                        
                            Cons
                        - Requires some importing
                        - Might take some time to get used to the system
                        - Uses ItemUserData
                                
                                
                                Changelog v1.00
                                
                            - Initial release
                            
                                Changelog v1.01
                                
                            - Fixed a stupid bug
                            
                                Changelog v1.02
                                
                            - Ported some stuff and added a new function
                            
                                Changelog v1.03
                            - Extra functions like recipes and SetItems.
                            
                                Changelog v.104
                            - Fixed stuffs
                            
    Why was this system even created to begin with?
    
    Blizzard made the item system for warcraft really limited by not having recipes,
    set items and more inventory spaces so this was created. This system is designed to 
    take down the problems faced by many users with items that couldnt be possible. This
    is a very useful system for people who want something to replace the item system of warcraft
    but yet retain some of the features of it. This has a feature of creating item types in game but
    you cannot change the icon due to the warcraft engine. If you have realised for items, you always
    have to create new abilities in order to add stats to units but this system creates the abilities
    already and you can just create a new ItemType bonus for a item. There are some function interface
    for you to manipulate and there will be examples below.
    
    Extra features that you might not know of as of
    
    - Custom item stats for a item, you can have a item type that have the stats generated already but
        if you create an item of that and give it a custom stat, the item type bonuses will be ignored.
    
        This can be very useful for dungeon crawlers or other maps like a RPG.
        
    - Recipes
    
        Allows creation of recipes.
        
    - Set Items
    
        Maybe you played too many RPG games and liked those item sets so much that you want them to
        be in warcraft. This is the right system for you!. Simply create the ingredients needed for
        the event to fire off to get your bonuses when the unit has the items
        
    - Random Item stats
    
        Since with this system you can create a new set of stats for a item, you can generate them
        randomly which can be good for RPGs that need randomness although icons cannot be changed.
    
    - Function interface
    
        This system allows you will call a function that you want when you set the correct fields
        for the function to fire off. This was made as the user might want to do something to the
        unit other then adding stats to it.
    
    - Abilities
    
        Now you can create abilities for items instead of just 1 which was limited but it uses
        the slots for hero skills which you might not want. You might have to set abilities for
        the item to click if you want to click a item to fire off a ability as doing this in the
        warcraft engine is not possible.
        

            
Available function are as follow

static method Itemtype takes integer ItemId returns bonus
static method Item takes item whichItem returns bonus
static method Recipe takes integer i1, integer i2, integer i3,integer i4, integer i5, integer i6, integer result returns bonus
static method SetItem takes integer i1, integer i2, integer i3, integer i4, integer i5, integer i6 returns bonus
set d.[struct member] = value

                            
How to use it?

    integer ItemId      =   The ItemId of the item. Remember to use '____' for your rawcodes.
    integer Str         =   The amount of Strength.
    integer Agi         =   The amount of Agility.
    integer Int         =   The amount of Intelligence.
    real Damage         =   The amount of Damage.
    real Armor          =   The amount of Armour
    real MaxLife        =   The max life that you want to increase meaning that you increase the base of the unit health.
    real MaxMana        =   The max mana that you want to increase meaning that you increase the base of the unit mana.
    real LifeRegen      =   The amount of life regen you want to give to the unit.
    real ManaRegen      =   The amount of mana regen you want to give to the unit.
    real AttackSpeed    =   The amount of attack speed you want to give to the unit.
    real MoveSpeed      =   The amount of movement speed you want to give to the unit.
    
Abilities Section

    integer array Abilities[MAX_ABILITIES]
    integer array AbilityLevels[MAX_ABILITIES]

    
                        private constant integer MAX_ABILITIES = 6
                    
The max amount of abilities you want to give per unit through one item.

                      integer array AbilityLevels[MAX_ABILITIES]
                      
Whether you want the ability to have levels.

    
                    private constant integer BackpackId = 'BAG1'
    
This is the ID of the dummy spell that will be used to detect whether a unit whats to move it to the backpack.


static method Itemtype takes item whichItem returns bonus
    
You should only use this if you want to generate stats for an Itemtype.

Example of Usage

    private function Stats takes unit u returns nothing
        call KillUnit(u) (Unit u can be any naming but it must take a unit)
    endfunction
    
        set d = bonus.Itemtype(whichItem)
        set d.Int = 300
        set d.ItemTypePick = Stats 
        (Notice I do not add a function line infront as you cannot do that)
        set d.Abilities[0] = 'AHtb'  (adds the ability when picked up)
        set d.AbilityLevels[0] = value (Note that if the value is 1, you do not have to do this)
        
    It creates properties for the unit in the first line 
    and the second line generates 300 Int whenever you pickup the item
    and removes bonus when you drop it. The third line gives u a function to do 
    whatever you want to the unit if that function is there else there will be
    a syntax error.
    
static method Item takes item whichItem returns bonus

    set d = bonus.Item(whichItem)
    set d.Agi = 150
    
This is about the same as the itemtype but just creating stats for that specific item itself
and the itemtype stats will not be applied. function or struct members used in ItemType
can be used here as well.

static method Recipe takes integer i1, integer i2, integer i3,integer i4, integer i5, integer i6, integer result returns bonus

    set d = bonus.Recipe(ingredient 1, ingredient 2 , ingredient 3, ingredient 4, ingredient 5, ingredient 6, your final item)
    set d.Damage = 200
    
Creating recipes will be very simple, for example if you only need 3 items to form a item, 
simply leave ingredient 4 to 6 set as 0.

static method SetItem takes integer i1, integer i2, integer i3, integer i4, integer i5, integer i6 returns bonus

    set d = bonus.SetItem(ingredient 1, ingredient 2 , ingredient 3, ingredient 4, ingredient 5, ingredient 6)

Somewhat similar to the recipe usage but the items do not get removed and they give u bonuses when
the ingredients are together. You can only have a maximum SetItem type of 2 per unit, one in the
backpack while another in your inventory.

A illustration (for a set item type)

Your inventory  Backpack

i1  | i2        i1  | i3
i3  | null      i2  | null
null| null      null| null

The order of the items do not matter but you must remember only 2 sets of a set itemtype can be
on a unit.

Last but not least, this system can be fatal if you do not create properties for the units picking
the items up. Notice that I do CreateUnitProperties(preplaced unit) for the system to function
properly. Remember this at all times if not the system will bug.

If you still do not get how to use the system, check CISInit, I included some examples on how to do
it.



Thanks for looking through the documention and have a nice day!




System
JASS:
library CIS initializer Init requires Table, UnitProperties, AutoIndex

globals
    private constant integer BackpackId = 'BAG1'
    private constant integer MAX_ABILITIES = 6  
    private constant string DEFAULTSFX = "Abilities\\Spells\\Items\\AIlm\\AIlmTarget.mdl"
endglobals

globals
    private Table DataTable // stores the itemtype data
endglobals

function interface OnPick takes unit target returns nothing
function interface OnDrop takes unit target returns nothing

private function UnitHasItemOfType takes unit whichUnit, integer itemId returns boolean
    local integer index = 0
    local item indexItem
    loop
        set indexItem = UnitItemInSlot(whichUnit, index)
        if indexItem != null and GetItemTypeId(indexItem) == itemId then
            return true
        endif
        set index = index + 1
        exitwhen index > 5
    endloop
    return false
endfunction

private function UnitHasItemOfTypeBackpack takes backpack d, integer itemId returns boolean
    local integer index = 0 // something similar but checks backpack
    local integer indexId = 0
    loop
        set indexId = d.ItemType[index]
        if indexId != 0 and indexId == itemId then
            return true
        endif
        set index = index + 1
        exitwhen index > 5
    endloop
    return false
endfunction    

struct bonus // just merged everything together, hope that it doesn't break MUI.
    static integer Count = 0 // set item count
    static bonus array D // set item count
    static bonus array R // recipe count
    static integer RCount = 0 // recipe count
    Table COMBINED // needed so as to have a true or false inside a struct instance while making it MUI
    Table Boolean
    OnPick ItemTypePick
    OnPick CustomItemPick
    OnPick SetItemPick
    OnPick RecipeCombine
    OnDrop ItemTypeDrop
    OnDrop CustomItemDrop
    OnDrop SetItemDrop
    integer ItemId = 0
    integer Str = 0
    integer Agi = 0
    integer Int = 0
    real Damage = 0.00
    real Armor = 0.00
    real MaxLife = 0.00
    real MaxMana = 0.00
    real LifeRegen = 0.00
    real ManaRegen = 0.00
    real AttackSpeed = 0.00
    real MoveSpeed = 0.00
    string SFX
    integer array Items[6]
    integer result = 0
    integer array Abilities[MAX_ABILITIES]
    integer array AbilityLevels[MAX_ABILITIES]
    
static method Itemtype takes integer ItemId returns bonus
    local bonus d = bonus.create()
    local integer i = 0
    loop
        set d.Abilities<i> = 0
        set d.AbilityLevels<i> = 1
        set i = i+1
        exitwhen i &gt;= MAX_ABILITIES
    endloop
    set d.ItemId = ItemId
    set DataTable[ItemId] = d
    return d
endmethod
        
static method Item takes item whichItem returns bonus
    local bonus d = bonus.create()
    local integer i = 0
    loop
        set d.Abilities<i> = 0
        set d.AbilityLevels<i> = 1
        set i = i+1
        exitwhen i &gt;= MAX_ABILITIES
    endloop
    call SetItemUserData(whichItem,d)
    return d
endmethod
        
static method SetItem takes integer i1, integer i2, integer i3, integer i4, integer i5, integer i6 returns bonus
    local bonus d = bonus.create()
    local integer i = 0
    set d.Items[0] = i1
    set d.Items[1] = i2
    set d.Items[2] = i3
    set d.Items[3] = i4
    set d.Items[4] = i5
    set d.Items[5] = i6
    loop
        set d.Abilities<i> = 0
        set d.AbilityLevels<i> = 1
        set i = i+1
        exitwhen i &gt;= MAX_ABILITIES
    endloop
    set d.D[d.Count] = d
    set d.Count = d.Count + 1
    set d.COMBINED = Table.create()
    set d.Boolean = Table.create()
    return d
endmethod
        
static method Recipe takes integer i1, integer i2, integer i3,integer i4, integer i5, integer i6, integer result returns bonus
    local bonus d = bonus.create()
    local integer i = 0
    set d.Items[0] = i1
    set d.Items[1] = i2
    set d.Items[2] = i3
    set d.Items[3] = i4
    set d.Items[4] = i5
    set d.Items[5] = i6
    set d.result = result
    set d.SFX = DEFAULTSFX
    loop
        set d.Abilities<i> = 0
        set d.AbilityLevels<i> = 1
        set i = i+1
        exitwhen i &gt;= MAX_ABILITIES
    endloop
    set d.R[d.RCount] = d
    set d.RCount = d.RCount + 1
    return d
endmethod
endstruct

//! textmacro CheckAndApply takes VALUE  
    if d.$VALUE$ != 0 then
        set $VALUE$<u> = $VALUE$<u> + d.$VALUE$
    endif
//! endtextmacro

//! textmacro CheckAndUnapply takes VALUE
    if d.$VALUE$ != 0 then
        set $VALUE$<u> = $VALUE$<u> + -1*d.$VALUE$
    endif
//! endtextmacro
    
private function UnitApplyItem takes unit u, bonus d returns nothing
    local integer i
    //! runtextmacro CheckAndApply(&quot;Str&quot;)
    //! runtextmacro CheckAndApply(&quot;Agi&quot;)
    //! runtextmacro CheckAndApply(&quot;Int&quot;)
    //! runtextmacro CheckAndApply(&quot;Damage&quot;)
    //! runtextmacro CheckAndApply(&quot;Armor&quot;)
    //! runtextmacro CheckAndApply(&quot;MaxLife&quot;)
    //! runtextmacro CheckAndApply(&quot;MaxMana&quot;)
    //! runtextmacro CheckAndApply(&quot;LifeRegen&quot;)
    //! runtextmacro CheckAndApply(&quot;ManaRegen&quot;)
    //! runtextmacro CheckAndApply(&quot;AttackSpeed&quot;)
    //! runtextmacro CheckAndApply(&quot;MoveSpeed&quot;)
    if d.Abilities[0] != 0 then
        set i = 0
        loop
            call UnitAddAbility(u, d.Abilities<i>)
            call SetUnitAbilityLevel(u, d.Abilities<i>, d.AbilityLevels<i>)
            set i = i+1
            exitwhen d.Abilities<i> == 0 or i &gt;= MAX_ABILITIES
        endloop
    endif
endfunction

private function UnitUnapplyItem takes unit u, bonus d returns nothing
    local integer i
    //! runtextmacro CheckAndUnapply(&quot;Str&quot;)
    //! runtextmacro CheckAndUnapply(&quot;Agi&quot;)
    //! runtextmacro CheckAndUnapply(&quot;Int&quot;)
    //! runtextmacro CheckAndUnapply(&quot;Damage&quot;)
    //! runtextmacro CheckAndUnapply(&quot;Armor&quot;)
    //! runtextmacro CheckAndUnapply(&quot;MaxLife&quot;)
    //! runtextmacro CheckAndUnapply(&quot;MaxMana&quot;)
    //! runtextmacro CheckAndUnapply(&quot;LifeRegen&quot;)
    //! runtextmacro CheckAndUnapply(&quot;ManaRegen&quot;)
    //! runtextmacro CheckAndUnapply(&quot;AttackSpeed&quot;)
    //! runtextmacro CheckAndUnapply(&quot;MoveSpeed&quot;)
    if d.Abilities[0] != 0 then
        set i = 0
        loop
            call UnitRemoveAbility(u, d.Abilities<i>)
            set i = i + 1
            exitwhen d.Abilities<i> == 0 or i &gt;= MAX_ABILITIES
        endloop
    endif
endfunction
    
private function UnitUnapplyAbilities takes unit u, bonus d returns nothing
    local integer i
    if d.Abilities[0] != 0 then
        set i = 0
        loop
            call UnitRemoveAbility(u, d.Abilities<i>)
            set i = i + 1
            exitwhen d.Abilities<i> == 0 or i &gt;= MAX_ABILITIES
        endloop
    endif
endfunction
        
private function UnitApplyAbilities takes unit u, bonus d returns nothing
    local integer i
    if d.Abilities[0] != 0 then
        set i = 0
        loop
            call UnitAddAbility(u, d.Abilities<i>)
            call SetUnitAbilityLevel(u, d.Abilities<i>, d.AbilityLevels<i>)
            set i = i + 1
            exitwhen d.Abilities<i> == 0 or i &gt;= MAX_ABILITIES
        endloop
    endif
endfunction
        
private function Check takes bonus d, unit u returns boolean // for checking of SetItems
    local integer i = 0
    local integer array Items
    loop
        exitwhen i &gt; 5
        set Items<i> = d.Items<i>
        set i = i + 1
    endloop
    set i = 0
    loop
        exitwhen i &gt; 5
        if UnitHasItemOfType(u,Items<i>) then
            set Items<i> = 0
        endif
        set i = i + 1
    endloop
    set i = 0
    loop
        exitwhen i &gt; 5
        if Items<i> != 0 then
            return false
        endif
        set i = i + 1
    endloop
    return true
endfunction

private function RecipeCheck takes bonus d, unit u returns boolean
    local integer i = 0 // took some reference to artificial&#039;s code
    local integer array Items
    local item array ItemRetrieve
    local integer it = 0
    local integer j = 0
    loop
        exitwhen i &gt; 5
        set Items<i> = d.Items<i>
        set i = i + 1
    endloop
    set i = 0
    loop
        set it = GetItemTypeId(UnitItemInSlot(u,i))
        loop
            if it == Items[j] and it != 0 then
                set ItemRetrieve[j] = UnitItemInSlot(u,i)
                set Items[j] = 0
                exitwhen true
            endif
            set j = j + 1
            exitwhen j &gt; 5
        endloop
        set j = 0
        set i = i + 1
        exitwhen i &gt; 5
    endloop
    set j = 0
    set i = 0
    loop
        if Items<i> != 0 then
            loop
                exitwhen j &gt; 5
                set ItemRetrieve[j] = null
                set j = j + 1
            endloop
            return false
        endif
        set i = i + 1
        exitwhen i &gt; 5
    endloop
    set i = 0
    loop
        exitwhen i &gt; 5
        if ItemRetrieve<i> != null then
            call RemoveItem(ItemRetrieve<i>)
            set ItemRetrieve<i> = null
        endif
        set i = i + 1
    endloop
    call DestroyEffect(AddSpecialEffect(d.SFX,GetUnitX(u),GetUnitY(u)))
    call UnitAddItemById(u,d.result)
    return true
endfunction

private function BackCheck takes bonus d,unit u returns boolean
    local integer i = 0
    local integer array Items
    loop
        exitwhen i &gt; 5
        set Items<i> = d.Items<i>
        set i = i + 1
    endloop
    set i = 0
    loop
        exitwhen i &gt; 5
        if UnitHasItemOfType(u,Items<i>) then
            set Items<i> = 0
        endif
        set i = i + 1
    endloop
    set i = 0
    loop
        exitwhen i &gt; 5
        if Items<i> != 0 then
            return false
        endif
        set i = i + 1
    endloop
    return true
endfunction

private function onPickup takes nothing returns nothing
    local item t = GetManipulatedItem()
    local bonus d = GetItemUserData(t)
    local unit u = GetTriggerUnit()
    local integer i = 0
    local integer r = 0
    local boolean UserItem = false
    if d != 0 then
        call d.CustomItemPick.execute(u) 
        call UnitApplyItem(u,d)
        set UserItem = true
    endif
    set d = DataTable[GetItemTypeId(t)]
    if d &gt; 0 then
        if not UserItem then
            call d.ItemTypePick.execute(u)
            call UnitApplyItem(u,d)
        endif
    endif
    loop
        exitwhen r &gt;= d.Count
        set d = d.D[r]
        if Check(d,u) and d.COMBINED[GetUnitId(u)] == 0 then
            call d.SetItemPick.execute(u)
            call UnitApplyItem(u,d)
            set d.COMBINED[GetUnitId(u)] = 1
        endif
        set r = r + 1
    endloop
    set r = 0
    loop
        exitwhen r &gt;= d.RCount
        set d = d.R[r]
        if RecipeCheck(d,u) then
            call d.RecipeCombine.execute(u) 
            call UnitApplyItem(u,d)
        endif
        set r = r + 1
    endloop
    set t = null
    set u = null
endfunction

private struct UnitAttach
    unit target
    timer t
    
static method create takes nothing returns UnitAttach
    local UnitAttach d = UnitAttach.allocate()
    set d.target = GetTriggerUnit()
    set d.t = NewTimer()
    return d
endmethod

method onDestroy takes nothing returns nothing
    call ReleaseTimer(.t)
endmethod

endstruct

private function SetCheck takes nothing returns nothing
    local UnitAttach c = GetTimerData(GetExpiredTimer())
    local integer r = 0
    local bonus d
    loop
        exitwhen r &gt;= d.Count
        set d = d.D[r]
        if d.COMBINED[GetUnitId(c.target)] == 1 and not Check(d,c.target) then
            call d.SetItemDrop.execute(c.target)
            call UnitUnapplyItem(c.target,d)
            set d.COMBINED[GetUnitId(c.target)] = 0
        endif
        set r = r + 1
        call c.destroy() // destroy after using
    endloop
endfunction
 
private function onDrop takes nothing returns nothing
    local item t = GetManipulatedItem()
    local bonus d = GetItemUserData(t)
    local unit u = GetTriggerUnit()
    local boolean UserItem = false
    local UnitAttach c = UnitAttach.create() // for the attaching of the 0. timer
    if d != 0 then
        call d.CustomItemDrop.execute(u)
        call UnitUnapplyItem(u,d)
        set UserItem = true
    endif
    set d = DataTable[GetItemTypeId(t)]
    if d &gt; 0 then
        if not UserItem then
        call d.ItemTypeDrop.execute(u)
        call UnitUnapplyItem(u,d)// if there is no custom stats assigned for that unit then we apply the normal basic stats
        endif
    endif
    call SetTimerData(c.t,c) // Stupid blizzard takes dropped item in inventory when the event is run.
    call TimerStart(c.t,0.,false,function SetCheck)
    set u = null
    set t = null
endfunction

struct backpack
    integer array ItemType[6]
    integer array Charges[6]
    integer array UserData[6]    
    
static method create takes unit u returns backpack
    local backpack d = backpack.allocate()
    local backpack c
    local UnitAttach p = UnitAttach.create()
    local bonus a
    local bonus r
    local integer i = 0
    local item it
    local integer j = 0
    local boolean UserData = false
    loop
        exitwhen j &gt;= bonus.Count
        set r = bonus.D[j]
        if BackCheck(r,u) then
            call UnitApplyItem(u,r)
            set r.Boolean[GetUnitId(u)] = 1
        endif
        set j = j + 1
    endloop
    loop
        set it = UnitItemInSlot(u, i)
        set d.ItemType<i> = GetItemTypeId(it)
        set d.Charges<i> = GetItemCharges(it)
        set d.UserData<i> = GetItemUserData(it)
        set c = DataTable[d.ItemType<i>]
        set a = GetItemUserData(it)
        if a != 0 then
            call UnitApplyItem(u,a)
            call RemoveItem(it)
            call UnitApplyAbilities(u,a)
            set UserData = true
        endif
        if not UserData then
            call UnitApplyItem(u,c)
            call RemoveItem(it)
            call UnitApplyAbilities(u,c)
        endif
        set i = i + 1
        exitwhen i &gt; 5
    endloop
    call SetTimerData(p.t,p)
    call TimerStart(p.t,0.,false,function backpack.apply)
    set it = null
    return d
endmethod

static method apply takes nothing returns nothing
    local UnitAttach d = GetTimerData(GetExpiredTimer())
    local bonus r
    local integer j = 0
    loop
        exitwhen j &gt;= bonus.Count
        set r = bonus.D[j]
        if r.Boolean[GetUnitId(d.target)] == 1 then
            call UnitApplyAbilities(d.target,r)
            call r.SetItemPick.execute(d.target)
            set r.Boolean[GetUnitId(d.target)] = 0
        endif
        set j = j + 1
    endloop
    call d.destroy()
endmethod
    implement AutoData
endstruct

function ActivateBackpack takes nothing returns nothing
    local unit target = GetTriggerUnit()
    local backpack d1
    local backpack d2 = backpack[target]
    local backpack d
    local integer i = 0
    local integer j = 0
    local item it
    local bonus a
    local bonus r
    local boolean done = false
    set d1 = backpack.create(target)
    if d2 != 0 then
        loop
            if d2.ItemType<i> != 0  then
                set it = UnitAddItemById(target, d2.ItemType<i>)
                call SetItemCharges(it, d2.Charges<i>)
                call SetItemUserData(it, d2.UserData<i>)
                set d = DataTable[d2.ItemType<i>]
                call UnitUnapplyItem(target,d)
                call UnitApplyAbilities(target,d)
                endif
            set i = i + 1
            exitwhen i &gt; 5
        endloop
            loop
            exitwhen j &gt;= bonus.Count
            set r = bonus.D[j]
            if BackCheck(r,target) then
                call UnitUnapplyItem(target,r)
                call UnitApplyAbilities(target,r)
            endif
            set j = j + 1
        endloop
        call d2.destroy()
    endif
    set backpack[target] = d1
    set it = null
endfunction

private function BackpackCondition takes nothing returns boolean
    return GetSpellAbilityId() == BackpackId
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_PICKUP_ITEM)
    call TriggerAddAction(t,function onPickup)
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_DROP_ITEM)
    call TriggerAddAction(t,function onDrop)
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t,Condition(function BackpackCondition))
    call TriggerAddAction(t,function ActivateBackpack)
    set DataTable = Table.create()
endfunction

endlibrary</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></u></u></u></u></i></i></i></i></i></i></i></i>
 

Attachments

  • CIS 1.4.w3x
    127.6 KB · Views: 230

wraithseeker

Tired.
Reaction score
122
It allows up to 12 inventory slots per unit instead of 6 and holds bonus and abilities.

You can randomly generate item stats since all items will be dummies which will not add any stats. You have to specify them yourself which means you can get randomly generated items which might be useful for maps but mainly RPGS.
 

Viikuna

No Marlo no game.
Reaction score
265
This should not be limited to PUI only. If this already requires Unit Properties, you should do something similiar as Cassiel does in Unit Properties:

Taken from UnitProperties code:
JASS:

// ******************************************************************************
// These functions that allow you to retrieve the handle index of a unit. Other
// methods of indexing units, like UnitUserData and HAIL, would also work. This
// method is only viable if you correctly dispose of used handles, so if your
// map suffers from inflated handle indices you should either change 
// the &quot;UnitProperties&quot; array above to &quot;UnitProperties[verybignumber]&quot;, or use a
// different system. A UnitUserData system is recommended as a replacement
// regardless.
//
// The Id wrapper allows you to retrieve a unit&#039;s Id as with:
//
// unit:Id
//
private function H2I takes handle h returns integer
    return h
    return 0
endfunction
function GetUnitId takes unit u returns integer
    return H2I(u)-0x100000
endfunction
struct Id
    static method operator [] takes unit u returns integer
        return H2I(u)-0x100000
    endmethod
endstruct


This way people can choose which indexing system to use.
edit. I mean that you should add wrappers like this for UnitId

edit. And rename your test map pls.
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
this system looks like a realy useful thing to have. +Rep
 

wraithseeker

Tired.
Reaction score
122
Ok, updated to v 1.01, had a lame minor bug where if you had 12 inventory slots, 1 item will always drop.
 

waaaks!

Zinctified
Reaction score
256
by waaaks! from Realms of the Genesis v3 thread
also for the item concept, I really want to terminate the basic concept of items, the buy-and-boost concept which is too basic, like buy boots of speed gain permanent move speed, I want to change that to something more unique without the loss of usability, meaning, players would still love to farm gold for that item with a unique concept.

nice, as you can see, im searching for something to replace the basic item system in wc3, like the buy-and-boost concept, buy weapon, increase damage, what im searching for is more complexibility, and i found this interesting, maybe ill use this system in my map RotG v3 when it is "finally" approved (no more bugs)

for now im going to test it
 

MagnaGuard

Active Member
Reaction score
49
>> This seems really helpful (I certainly am going to use it +rep) but I don't understand how to add the abilities. The other stuff is obvious, change the variables.

>> Also for Remember to use '____' for your rawcodes that rawcode part may confuse GUI users.
 

wraithseeker

Tired.
Reaction score
122
How does that confuses GUI users? If they can't understand that, then they shouldn't use it since it's self explainary.

You add the abilities through
JASS:
set d.Abilities[0] = &#039;Apxf&#039;
    set d.Abilities[1] = &#039;Ahea&#039;
    set d.Abilities[2] = &#039;Aivs&#039;


Where those 4 digits stuff is your abilities rawcode.
 

wraithseeker

Tired.
Reaction score
122
I might update this soon when I have the time to do more stuffs and of course, to create RandomStats for just a item.
 

13lade619

is now a game developer :)
Reaction score
398
i think this needs better documentation..

be more descriptive, what does it do
and describe how it works..

and i dont see a list of functions that we can use..
y'know for the sake of beginners.

like this, from darth
How it Works:

It's a very simple system. When a unit attacks, or casts a spell, it makes both the target as well as the triggering unit in combat. This is done by attaching a struct to the unit, and then running a timer which expires in 4 seconds. If the unit attacks again, that timer will start over again. If the timer expires, the attached struct is destroyed.

Lastly, if a user wants to know if a Unit is in combat or not, it simply returns whether any struct is attached to the unit.

and i dont see the part where you get additional stats when you have sobi mask...

idk.. maybe i just got used to my instructor telling us to do better docu..
 

wraithseeker

Tired.
Reaction score
122
I will work on documention when the new one is released, this is quite simple, in the test function, I didn't add any custom stats to sobi mask thats why and I only added it to slipper of agility I think.
 

waaaks!

Zinctified
Reaction score
256
why not make the bag an item instead of an ability?
can i use the system without the bag system? leaving the map make use of the default 6 item slot? and just using your custom item bonus and ability system?

also i think it would be better if adding like a bit more user-custom functions, like adding reponses when the system is created, what if i ask...

"why does the system only support its maximum potential, like just adding bonus stats and custom abilities? why cant i add some of my custom functions? what if i want to create a projectile that travels towards my unit when the item is picked? why cant i take control of the system when the item was dropped? while i want to kill my unit when he dropped the item"

more like:
JASS:
//item description: the item used by the suiciding dragon, grants you
//ultimate power, but when dropped, you will kill yourself

scope Suicidal initializer init

//derived from adamage
private struct shield extends ADamage_Shield
	method prevent takes unit u, real dmg returns prevented
		return dmg //the returned value will be the prevented damage
	endmethod
endstruct

//by the use of function interface (or what you called them?)
function take_em takes unit drunk, bonus data returns nothing
    	//i dont need to reapply all the bonus stuff, while the system will do the job for me
    	////! runtextmacro CheckAndApply(&quot;Str&quot;)
    	////! runtextmacro CheckAndApply(&quot;Agi&quot;)
    	////! runtextmacro CheckAndApply(&quot;Int&quot;)
    	////! runtextmacro CheckAndApply(&quot;Damage&quot;)
    	// ...
    	// all i need is my custom calls
    	local shield s
	local real blockdamage = 50.0
    	set s.create(drunk,blockdamage,data) //attaching data to the shield
    	set data.Str = 20 // will automatically add 20 strength to the item bonus being picked
endfunction

function drop_em takes unit drunk, bonus data returns nothing
	//i dont need to re-unapply all the bonus stuff, while the system will do the job for me
    	////! runtextmacro CheckAndUnapply(&quot;Str&quot;)
    	////! runtextmacro CheckAndUnapply(&quot;Agi&quot;)
    	////! runtextmacro CheckAndUnapply(&quot;Int&quot;)
    	////! runtextmacro CheckAndUnapply(&quot;Damage&quot;)
    	// ...
    	// all i need is my custom calls
	call KillUnit(drunk)
	call data.shield.destroy() //destroying the shield that was attached from the bonus system
	//call data.destroy() //destroys the system or do i need to destroy it?
endfunction

private function init takes nothing returns nothing
    	local bonus b = bonus.create(&#039;I000&#039;,take_em,drop_em)
    	//...
    	//do stuffs here
endfunction

endscope

i think this would add more functionability to the system, more flexibilty by combing the system to other systems, interacting with some systems to greatly increase its limit, limit of adding stats and custom abilities is not too good, also it would greatly change the usage of item in any other maps, changing the way map makers edit their items

thats all i can suggest, if you think it would be impossible, then anitarf did the impossible, i liked abuff a lot, i like its functionality to interact with other functions when an event response was triggered, like you can do anything with this unit when a certain buff was removed from it, do anything when the unit with the buff takes damage

thats why im suggesting to use his style of creating systems because really, shit break loose with abuff system, so flexible and lots of support for users who uses his system

anyways its just a suggestion, its up to you if you will implement it
 

waaaks!

Zinctified
Reaction score
256
please also add the data attachment, so that we can attach stuffs to it, and then retrieve it using the bonus struct
 
General chit-chat
Help Users
  • 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 The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    Sticking with the desserts for now the latest recipe is Fried Apple Pies - https://www.thehelper.net/threads/recipe-fried-apple-pies.194297/
  • The Helper The Helper:
    Finally finding about some of the bots that are flooding the users online - bytespider apparently is a huge offender here - ignores robots.txt and comes in from a ton of different IPs
  • Monovertex Monovertex:
    @The Helper I'm really not seeing the "Signature" link in the sidebar on that page. Here's a screenshot:
  • The Helper The Helper:
    I have reported it - I was wondering why nobody I have given sigs to over the last few years have used them
  • The Helper The Helper:
    Ghan has said he has fixed this. Monovertex please confirm this fix. This was only a problem with people that had signatures in the upper levels like not the special members but the respected members.
  • The Helper The Helper:
    Here is a better place to manage this stuff https://www.thehelper.net/account/account-details which I think should be way more visible
  • The Helper The Helper:
    I am hoping that online user count drop is finally that TikTok bot banned

      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