• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Coding]My Codes

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Your system is better but Hashtables are slower than arrays, there's no doubt about that. We could modify it to work with Arrays or start a new one based on arrays.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
lick of the code for Resistance/Attack system:
JASS:
   /*
        a - Give/Set/Remove
        b - Passive/Item
        c - Resist/Attack
        d - Resistance/Attack
        e - ""/", real howMuch"
        f - container to hold the value(including [].real[])
        g - 0/howMuch/read container + howMuch
    */
    //! textmacro PRIVATE_EXPAND_SIMPLE_ATT_RES takes a, b, c, d, e, f, g
        function $a$$b$$c$ takes integer id, $d$ which $e$ returns nothing
            set $f$ = $g$
        endfunction
    //! endtextmacro
    
//resistances
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Give", "Passive", "Resist", "Resistance", ", real howMuch", "spellPassiveResist[which].real[id]", "howMuch")
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Add", "Passive", "Resist", "Resistance", ", real howMuch", "spellPassiveResist[which].real[id]", "spellPassiveResist[which].real[id] + howMuch")
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Remove", "Passive", "Resist", "Resistance", "", "spellPassiveResist[which].real[id]", "0")
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Give", "Item", "Resist", "Resistance", ", real howMuch", "itemPassiveResist[which].real[id]", "howMuch")
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Add", "Item", "Resist", "Resistance", ", real howMuch", "itemPassiveResist[which].real[id]", "itemPassiveResist[which].real[id] + howMuch")
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Remove", "Item", "Resist", "Resistance", "", "itemPassiveResist[which].real[id]", "0")

//attacks
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Give", "Passive", "Attack", "Attack", ", real howMuch", "spellPassiveAttack[which].real[id]", "howMuch")
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Add", "Passive", "Attack", "Attack", ", real howMuch", "spellPassiveAttack[which].real[id]", "spellPassiveAttack[which].real[id] + howMuch")
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Remove", "Passive", "Attack", "Attack", "", "spellPassiveAttack[which].real[id]", "0")
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Give", "Item", "Attack", "Attack", ", real howMuch", "itemPassiveAttack[which].real[id]", "howMuch")
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Add", "Item", "Attack", "Attack", ", real howMuch", "itemPassiveAttack[which].real[id]", "itemPassiveAttack[which].real[id] + howMuch")
//! runtextmacro PRIVATE_EXPAND_SIMPLE_ATT_RES("Remove", "Item", "Attack", "Attack", "", "itemPassiveAttack[which].real[id]", "0")
    
        private struct dataholder extends array
            implement Alloc
            integer id
            real howMuch
            integer which
            static method create takes nothing returns thistype
                return allocate()
            endmethod
            method destroy takes nothing returns nothing
                call deallocate()
            endmethod
        endstruct
    
    /*
        a - Give/Add/Remove
        b - Resist/Attack
        c - Resistance/Attack
        d - ""/", real howMuch, real time"
        e - container to store the data in(including [].real[])
        f - random identifier
        g - container to set after timeout
        h - true/false(if we are using Remove or not)
    */
    //! textmacro PRIVATE_EXPAND_ABIT_ATT_RES takes a, b, c, d, e, f, g, h
        static if not $h$ then
            private function timeOut$f$ takes nothing returns nothing
                local timer t = GetExpiredTimer()
                local dataholder data = GetTimerData(t)
                call ReleaseTimer(t)
                set $g$ = data.howMuch
                set t = null
            endfunction
        endif
        function $a$Spell$b$ takes integer id, $c$ which $d$ returns nothing
            static if not $h$ then
                local dataholder data = dataholder.create()
                set data.howMuch = $e$
                set data.id = id
                set data.which = which
                set $e$ = $e$ + howMuch
                call TimerStart(NewTimerEx(data), time, false, function timeOut$f$)
            else
                set $e$ = 0
            endif
        endfunction
    //! endtextmacro
    
//! runtextmacro PRIVATE_EXPAND_ABIT_ATT_RES("Give", "Resist", "Resistance", ", real howMuch, real time", "spellOnCastResist[which].real[id]", "gr", "spellOnCastResist[data.which].real[data.id]", "false")
//! runtextmacro PRIVATE_EXPAND_ABIT_ATT_RES("Add", "Resist", "Resistance", ", real howMuch, real time", "spellOnCastResist[which].real[id]", "ar", "spellOnCastResist[data.which].real[data.id]", "false")
//! runtextmacro PRIVATE_EXPAND_ABIT_ATT_RES("Remove", "Resist", "Resistance", "", "spellOnCastResist[which].real[id]", "", "", "true")

    private struct dataholderUnit extends array
        implement Alloc
        unit unit_t
        integer which
        real howMuch
        static method create takes nothing returns thistype
            return allocate()
        endmethod
        method destroy takes nothing returns nothing
            call deallocate()
        endmethod
    endstruct

    //! textmacro PRIVATE_EXPAND_HARDCORE_ATT_RES
        static if not $$ then
            private function onTime$$ takes nothing returns nothing
                local timer t = GetExpiredTimer()
                local dataholderUnit d = GetTimerData(t)
                set $$ = d.howMuch
                call ReleaseTimer(t)
                set t = null
            endfunction
        endif
        function $$Unit$$ takes 
    //! endtextmacro

as you see, its not done currently, but Im off to eat
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Here's what I have so far with the item system.

- Disables item drop when it's used
- Enables item drop after cd is reached
- Counts item hits
- Replaces broken items with their respective broken versions for X time
- Disables broken item drop until restored.

All Item Default Data is based on ItemTypeId (Cooldown, Hits to break, etc.) after that, specific item hits taken and cooldowns and stuff are handled individually (ofc, i don't even know why y say it... xD)

I added BJDebugMsg's to ease the test. Just pick, use and hit.

* ItemIndexer shoul replace some Hashtable things and ease the ItemHit CD while dropped
* TimerUtils should improve the timer create/destroy
* DamageDetection should improve the damage breaking thing, and improve the system in general if we use later Magic BreakAble items and Physic BreakAble Items. We could even make Use-Abuse-Breakable items (Breaks if used too much, like overheating).

Test map

I'd like to have your feedback, teachings, and suggestions to improve the code as it's, and improve the still-to-be-written code.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
the code looks solid and working, but it has some code imrpvomenets

The system could use private struct for data, and use New Table by bribe + TimerUtils by vexorian, create new instance with values and save the instance to timer from TimerUtils, and then load it.
You could also merge all those triggers and put them to library keyword(library ItemSystem.... ... endlibrary)

A bit of problem which I saw(maybe I missed soemthing) is that in function ItemSys_Data you keep increasing ItemSys_Index by 1 but you never decrease it.

In version I have(I downloaded your map) I put debug keywords before all BJDebugMsg calls, so that you can debug the system with it but if you disable debug mode, it will not print anymore

Im leaving home for now, I will be back tho :D
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
ItemSys_Data gives an index to every Item-Type.

When I'm working with the item in the rest of the functions and triggers I load the index of the Item-Type, and then load the rest of the data from the arrays.

I don't know how to use NewTable, TimerUtils nor Private Struct. I've used libraries but just to stack up functions, not to handle triggers. If you edit the triggers I have so far (or a part of them) and give the map back to me (with some comments) I could learn and work the rest of the stuff the same way.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
yea because I see its not entirly done yet, I will not touch any inter-code stuff, just to not break funcionality(its working and there is no problem with how it works, just struct syntax makes it a bit nicer/cleaner, theres almost no efficency from that) but yes I can wrap them to library.
I will also put the all in one trigger(GUI-like trigger) if you dont mind
 
Status
Not open for further replies.
Top