System Larcenist's Enhanced Experience Trigger

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
What might this be?

LEET is an experience and bounty system, which does nothing more than handling the experience and bounty gain of units. Experience and bounty values are registered to unittypes, and can be changed throughout the whole game. For a more detailed list of functionality check section 3, Function List, in the main trigger's comments.

Requires:
- Jass NewGen Pack.

Pros:
- Gives the user great control over the experience and bounty in general.
- Gives the user control over things such as dynamic bounty throughout the game.
- Shouldn't be very difficult to use at all.
- It's LEET.

Cons:
- Disables all regular experience and bounty gain, which requires all unittypes that are to give experience and/or bounty to be registered (if both functionalities are to be used that is, else you can prevent this by changing global variables).

Code:
JASS:
/*              Larcenist´s Enhanced Experience Trigger (LEET) v. 1.3
                         by Larcenist (obviously)

    1) Implementation:
        - Create a new trigger and name it whatever you feel like naming it, LEET for example.
        - Convert the trigger to custom text. Edit > Convert to custom text.
        - Copy and paste this code into your newly created trigger.
    
    2) How to use:
        - Register any unittypes that you want registered by calling the register function.
          Just create a new trigger and add the calls to the init function of that one.
          (Function list is located in section 3.)
        - The system will now distribute the experience according to the default settings
          set in the global block.
        - Exp will be given by unittypes until they are unregistered (see section 3 for functions).
    
    3) Function List:
    
    3a) Functions without return values:
    
        - function LEET_RegisterUnitType takes integer utype, integer exp, integer bountylb, integer bountyhb returns nothing
            * utype is the unittype that is to be registered. 'hfoo' for example.
            * exp is the amount of experience gained from killing a unit of this type.
            * bountylb is the low bound of the bounty given.\
                                                             -- Bounty given is a random integer between lowbound and highbound
            * bountyhb is the highbound of the bounty given./
            
        - function LEET_RegisterHeroType takes integer utype returns nothing
            * utype is the unittype to be registered. This is for heroes only.
            
        - function LEET_UnregisterUnitType takes integer utype returns nothing
            * utype is the unittype you wish to unregister from the experience system.
            
        - function LEET_SetUnitTypeExp takes integer utype, integer newexp returns nothing
            * utype is the unittype of which you wish to change the exp rate.
            * newexp is the new amount of exp to be gained by killing a unit of this type.
            
        - function LEET_SetUnitTypeExpFlag takes integer utype boolean flag returns nothing
            * utype is the unittype of which you wish to change the flag.
            * flag is a boolean that indicates whether or not the entered unittype gives 
              exp to all enemies of the dying unit in an AoE around it.
              
        - function LEET_SetUnitTypeExpShareFlag takes integer utype, boolean flag returns nothing
            * utype is the unittype of which you wish to change the flag.
            * flag is a boolean that indicates whether or not the experience given by a unit
              of entered type is equally shared between the units who gain exp.
              
        - function LEET_SetUnitTypeExpRadius takes integer utype, real radius returns nothing
            * utype is the unittype of which you wish to change the radius.
            * radius is the experience AoE radius.
            
        - function LEET_SetUnitTypeBounty takes integer utype, integer bountylb, integer bountyhb returns nothing
            * utype is the unittype of which you wish to change the bounty.
            * bountylb is the lowbound of the bounty given.
            * bountyhb is the highbound of the bounty given.
            
        - function LEET_SetUnitTypeBountyFlag takes integer utype, boolean flag returns nothing
            * utype is the unittype of which you wish to change the flag.
            * flag is a boolean that indicated whether or not the entered unittype gives
              bounty to all enemies of the dying unit in an AoE around it.
              
        - function LEET_SetUnitTypeBountyShareFlag takes integer utype, boolean flag returns nothing
            * utype is the unittype of which you wish the change the flag.
            * flag is a boolean that indicated whether or not given bounty is equally distributed.
            
        - function LEET_SetUnitTypeBountyRadius takes integer utype, real radius returns nothing
            * utype is the unittype of which you wish to change the radius.
            * radius is the bounty AoE radius.
            
        - function LEET_SetUnitTypeExpFilter takes integer utype, boolexpr filter returns nothing
            * utype is the unittype of which you wish to change the filter.
            * filter is the new filter function you wish the entered unittype should use when granting exp.
            < Note that this takes a boolexpr, not code argument. So you have to add Filter(function myFunc) in the arguments.
            
        - function LEET_SetUnitTypeBountyFilter takes integer utype, boolexpr filter returns nothing
            * utype is the unittype of which you wish to change the filter.
            * filter is the new filter function you wish the entered unittype should use when giving bounty.
            < Note that this takes a boolexpr, not code argument. So you have to add Filter(function myFunc) in the arguments.
            
        - function LEET_ResetUnitTypeExpFilter takes integer utype returns nothing
            * utype is the unittype of which you wish to reset the filter.
            < This resets any custom filter function attached to the unittype and makes it use the default one again.
            
        - function LEET_ResetUnitTypeBountyFilter takes integer utype returns nothing
            * utype is the unittype of which you wish to reset the filter.
            < This resets any custom filter function attached to the unittype and makes it use the default one again.
            
    3b) Functions with return values:
        
        - function LEET_GetUnitTypeExp takes integer utype returns integer
            * utype is the unittype of which you wish to get the current experience set to it.
            > Returns the experience you´ve set to the unittype.
            
        - function LEET_GetUnitTypeExpFlag takes integer utype returns boolean
            * utype is the unittype of which you wish to get the current exp AoE flag set to it.
            > Returns whether or not the unittype grants AoE experience.
            
        - function LEET_GetUnitTypeExpShareFlag takes integer utype returns boolean
            * utype is the unittype of which you wish to get the current exp share flag set to it.
            > Returns whether or not the exp granted by the unittype is split equally between exp recievers.
            < Note that this will return false for unittypes with the ExpFlag set to false.
            
        - function LEET_GetUnitTypeExpRadius takes integer utype returns real
            * utype is the unittype of which you wish to get the current exp radius set to it.
            > Returns the Experience AoE radius you´ve set to the unittype.
            < Note that this will return 0. for unittypes with the ExpFlag set to false.
            
        - function LEET_GetUnitTypeBountyLowBound takes integer utype returns integer
            * utype is the unittype of which you wish to get the current bounty lowbound set to it.
            > Returns the bounty lowbound you´ve set to the unittype.
            
        - function LEET_GetUnitTypeBountyHighBound takes integer utype returns integer
            * utype is the unittype of which you wish to get the current bounty highbound set to it.
            > Returns the bounty highbound you´ve set to the unittype.
            
        - function LEET_GetUnitTypeBountyFlag takes integer utype returns boolean
            * utype is the unittype of which you wish to get the current bounty AoE flag set to it.
            > Returns whether or not the unittype gives AoE bounty.
            
        - function LEET_GetUnitTypeBountyShareFlag takes integer utype returns boolean
            * utype is the unittype of which you wish to get the current bounty share flag set to it.
            > Returns whether or not the bounty given by the unittype is split equally among bounty recievers.
            < Note that this will return false for unittypes with the BountyFlag set to false.
            
        - function LEET_GetUnitTypeBountyRadius takes integer utype returns real
            * utype is the unittype of which you wish to get the current bounty radius set to it.
            > Returns the bounty AoE radius you´ve set to the unittype.
            < Note that this will return 0. for unittypes with the BountyFlag set to false.
            
    4) Credits:
        - Jesus4Lyf for his rawcode hashing.
        - Vexorian for his bounty texttag which I totally ripped and merged into the actions function.
        
    5) Various Notes:
        
        - This system disables any regular experience and bounty gain.
          
        - In any custom filter function added, please remember to add the line "set LEET_N = LEET_N + 1"
          if a unit is to be given exp/bounty. This is for the split function to work properly.
          
        - If you wish to use the dying unit in your custom filter function, simply refer to it by using LEET_U.
*/
library LEET initializer Init
    
    globals
        //These you may mess with.
        private constant boolean UTILIZE_EXP_FUNCTIONALITY = true       //Should the system handle the exp given by units?
        private constant boolean UTILIZE_BOUNTY_FUNCTIONALITY = true    //Should the system handle the bounty given by units?
        private constant boolean EXP_AOE_BY_DEFAULT = true              //Should exp be given in an AoE around the dying unit by default?
        private constant boolean BOUNTY_AOE_BY_DEFAULT = false          //Should bounty be given in an AoE around the dying unit by default?
        private constant boolean SHARED_EXP_BY_DEFAULT = false          //Should exp be equally divided by units within the AoE by default?
        private constant boolean SHARED_BOUNTY_BY_DEFAULT = false       //Should bounty be equally divided by units within the AoE by default?
        private constant real DEFAULT_EXP_RADIUS = 1000.                //The default radius of the exp AoE.
        private constant real DEFAULT_BOUNTY_RADIUS = 500.              //The default radius of the bounty AoE.
        private constant real DENY_RATE = 1.                            //Percentage amount of exp gained when a unit is denied (meaning an allied unit kills it instead of an enemy). 1. == 100% and so on.
        
        //=======================================================\\
        
        //These you may not mess with.
        public integer N
        public unit U
    endglobals
    
    //Function for calculating the bounty given by a hero when killed.
    private function GetHeroBounty takes unit hero returns integer
        return 200 + 15 * GetHeroLevel(hero)
    endfunction
    
    //Function for calculating the experience given by a hero when killed.
    private function GetHeroExp takes unit hero returns integer
        return 100 + 50 * GetHeroLevel(hero)
    endfunction
    
    //Default experience filter.
    private function DefaultExpFilter takes nothing returns boolean
        local unit u = GetFilterUnit()
        local boolean bool = false
        if (IsUnitEnemy(u, GetOwningPlayer(U)) == true) and (IsUnitType(u, UNIT_TYPE_HERO) == true) and (GetWidgetLife(u) > .405) then
            set bool = true
            set N = N + 1
        endif
        
        set u = null
        
        return bool
    endfunction
    
    //Default bounty filter.
    private function DefaultBountyFilter takes nothing returns boolean
        local unit u = GetFilterUnit()
        local boolean bool = false
        if (IsUnitEnemy(u, GetOwningPlayer(U)) == true) and (IsUnitType(u, UNIT_TYPE_HERO) == true) and (GetWidgetLife(u) > .405) then
            set bool = true
            set N = N + 1
        endif
        
        set u = null
        
        return bool
    endfunction
    
    private struct Node
        integer exp
        integer bountylb
        integer bountyhb
        boolean regd = true
        boolean aoe = EXP_AOE_BY_DEFAULT
        boolean baoe = BOUNTY_AOE_BY_DEFAULT
        boolean expshare = SHARED_EXP_BY_DEFAULT
        boolean bountyshare = SHARED_BOUNTY_BY_DEFAULT
        boolexpr expfilter
        boolexpr bountyfilter
        real exprad = DEFAULT_EXP_RADIUS
        real bountyrad = DEFAULT_BOUNTY_RADIUS
        static method create takes integer exp, integer blb, integer bhb returns Node
            local Node n = Node.allocate()
            
            set n.exp = exp
            set n.bountylb = blb
            set n.bountyhb = bhb
            set n.expfilter = Filter(function DefaultExpFilter)
            set n.bountyfilter = Filter(function DefaultBountyFilter)
            
            return n
        endmethod
    endstruct
    
    globals
        private constant integer HASH_NEXT=53
        private constant integer MAX_HASH_VALUE=8191
        private integer array HashedInt
        
        private Node array D
        private group G = CreateGroup()
        private integer temp
        private integer J
    endglobals
    
    private function Hash takes integer int returns integer
        local integer hash=int-(int/MAX_HASH_VALUE)*MAX_HASH_VALUE
        loop
            exitwhen HashedInt[hash]==int
            if HashedInt[hash]==0 then
                set HashedInt[hash]=int
                return hash
            endif
            set hash=hash+HASH_NEXT
            if hash>=MAX_HASH_VALUE then
                set hash=hash-MAX_HASH_VALUE
            endif
        endloop
        return hash
    endfunction
    
    public function SetUnitTypeBountyFilter takes integer utype, boolexpr filter returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyfilter = filter
        debug else
            debug call BJDebugMsg(&quot;Cannot set the bounty filter of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function SetUnitTypeExpFilter takes integer utype, boolexpr filter returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.expfilter = filter
        debug else
            debug call BJDebugMsg(&quot;Cannot set the experience filter of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function SetUnitTypeBounty takes integer utype, integer bountylb, integer bountyhb returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountylb = bountylb
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyhb = bountyhb
        debug else
            debug call BJDebugMsg(&quot;Cannot set the bounty of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function SetUnitTypeBountyRadius takes integer utype, real radius returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyrad = radius
        debug else
            debug call BJDebugMsg(&quot;Cannot set the bounty radius of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function SetUnitTypeExpRadius takes integer utype, real radius returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.exprad = radius
        debug else
            debug call BJDebugMsg(&quot;Cannot set the exp radius of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function SetUnitTypeBountyShareFlag takes integer utype, boolean flag returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyshare = flag
        debug else
            debug call BJDebugMsg(&quot;Cannot share bounty given of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function SetUnitTypeExpShareFlag takes integer utype, boolean flag returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.expshare = flag
        debug else
            debug call BJDebugMsg(&quot;Cannot share exp given of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function SetUnitTypeBountyFlag takes integer utype, boolean flag returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.baoe = flag
        debug else
            debug call BJDebugMsg(&quot;Cannot set the bounty area flag of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function SetUnitTypeExpFlag takes integer utype, boolean flag returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.aoe = flag
        debug else
            debug call BJDebugMsg(&quot;Cannot set the exp area flag of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function SetUnitTypeExp takes integer utype, integer newexp returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.exp = newexp
        debug else
            debug call BJDebugMsg(&quot;Cannot set the experience value of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function GetUnitTypeBountyHighBound takes integer utype returns integer
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            return hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyhb
        debug else
            debug call BJDebugMsg(&quot;Cannot get the bounty highbound of a non-registered unittype.&quot;)
        endif
        
        return 0
    endfunction
    
    public function GetUnitTypeBountyLowBound takes integer utype returns integer
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            return hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountylb
        debug else
            debug call BJDebugMsg(&quot;Cannot get the bounty lowbound of a non-registered unittype.&quot;)
        endif
        
        return 0
    endfunction
    
    public function GetUnitTypeBountyRadius takes integer utype returns real
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) and (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.baoe) then
            return hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyrad
        debug else
            debug call BJDebugMsg(&quot;Cannot get the radius of a unittype that is either unregistered or has the bounty area flag set to false.&quot;)
        endif
        
        return 0.
    endfunction
    
    public function GetUnitTypeExpRadius takes integer utype returns real
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) and (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.aoe) then
            return hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.exprad
        debug else
            debug call BJDebugMsg(&quot;Cannot get the radius of a unittype that is either unregistered or has the exp area flag set to false.&quot;)
        endif
        
        return 0.
    endfunction
    
    public function GetUnitTypeBountyShareFlag takes integer utype returns boolean
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) and (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.baoe) then
            return hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyshare
        debug else
            debug call BJDebugMsg(&quot;Cannot get the bounty share flag of a unittype that is either unregistered or has the AoE flag set to false.&quot;)
        endif
        
        return false
    endfunction
    
    public function GetUnitTypeExpShareFlag takes integer utype returns boolean
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) and (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.aoe) then
            return hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.expshare
        debug else
            debug call BJDebugMsg(&quot;Cannot get the exp share flag of a unittype that is either unregistered or has the AoE flag set to false.&quot;)
        endif
        
        return false
    endfunction
    
    public function GetUnitTypeBountyFlag takes integer utype returns boolean
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            return hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.baoe
        debug else
            debug call BJDebugMsg(&quot;Cannot get the area bounty flag of a non-registered unittype.&quot;)
        endif
        
        return false
    endfunction
    
    public function GetUnitTypeExpFlag takes integer utype returns boolean
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            return hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.aoe
        debug else
            debug call BJDebugMsg(&quot;Cannot get the area exp flag of a non-registered unittype.&quot;)
        endif
        
        return false
    endfunction
    
    public function GetUnitTypeExp takes integer utype returns integer
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            return hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.exp
        debug else
            debug call BJDebugMsg(&quot;Cannot get the experience of a non-registered unittype.&quot;)
        endif
        
        return 0
    endfunction
    
    public function ResetUnitTypeBountyFilter takes integer utype returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyfilter = Filter(function DefaultBountyFilter)
        debug else
            debug call BJDebugMsg(&quot;Cannot reset the bounty filter of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function ResetUnitTypeExpFilter takes integer utype returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.expfilter = Filter(function DefaultExpFilter)
        debug else
            debug call BJDebugMsg(&quot;Cannot reset the exp filter of a non-registered unittype.&quot;)
        endif
    endfunction
    
    public function UnregisterUnitType takes integer utype returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd = false
        debug else
            debug call BJDebugMsg(&quot;Non-registered unittype unregistered.&quot;)
        endif
    endfunction
    
    public function RegisterHeroType takes integer utype returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" /> == 0) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" /> = Node.create(0, 0, 0)
            return
        endif
        
        if (not hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd = true
        debug else
            debug call BJDebugMsg(&quot;HeroType registered twice&quot;)
        endif
    endfunction
    
    public function RegisterUnitType takes integer utype, integer exp, integer bountylb, integer bountyhb returns nothing
        local integer hash = Hash(utype)
        if (hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" /> == 0) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" /> = Node.create(exp, bountylb, bountyhb)
            return
        endif
        
        if (not hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd) then
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.exp = exp
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountylb = bountylb
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyhb = bountyhb
            set hash<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd = true
        debug else
            debug call BJDebugMsg(&quot;UnitType registered twice.&quot;)
        endif
    endfunction
    
    private function GetUnitBounty takes integer lb, integer hb returns integer
        if (hb &lt; lb) then
            return GetRandomInt(hb, lb)
        endif
        
        return GetRandomInt(lb, hb)
    endfunction
    
    private function GroupCallback takes nothing returns nothing
        call AddHeroXP(GetEnumUnit(), temp, true)
    endfunction
    
    private function Conditions takes nothing returns boolean
        set J = Hash(GetUnitTypeId(GetTriggerUnit()))
        return J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.regd
    endfunction
    
    private function BountyCallback takes nothing returns nothing
        local texttag t = CreateTextTag()
        local string s = &quot;+&quot;
        local unit u = GetEnumUnit()
        
        if (temp &lt;= 0) then
            set s = &quot;&quot;
        else
            call SetPlayerState(GetOwningPlayer(u), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetOwningPlayer(u), PLAYER_STATE_RESOURCE_GOLD) + temp)
            call SetTextTagText(t,s+I2S(temp),0.025)
            call SetTextTagPos(t,GetUnitX(U),GetUnitY(U), 0.00)
            call SetTextTagColor(t,255,220,0,255)
            call SetTextTagVelocity(t,0,0.03)
            if (GetLocalPlayer() == GetOwningPlayer(u)) then
                call SetTextTagVisibility(t,true)
                set s=&quot;UI\\Feedback\\GoldCredit\\GoldCredit.mdl&quot;
            else
                call SetTextTagVisibility(t,false)
                set s=&quot;&quot;
            endif
            
            call DestroyEffect(AddSpecialEffect(s,GetUnitX(U),GetUnitY(U)))
        endif
        
        call SetTextTagFadepoint(t,2)
        call SetTextTagLifespan(t,3)
        call SetTextTagPermanent(t,false)
        
        set u = null
        set t = null
    endfunction
    
    private function Actions takes nothing returns nothing
        local unit u = GetKillingUnit()
        local texttag t = CreateTextTag()
        local player p = GetOwningPlayer(u)
        local string s = &quot;+&quot;
        local integer i
        set U = GetTriggerUnit()
        if (IsUnitType(U, UNIT_TYPE_HERO) == true) then
            set temp = GetHeroExp(U)
            set i = GetHeroBounty(U)
        else
            set temp = J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.exp
            set i = GetUnitBounty(J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountylb, J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyhb)
        endif
        
        if (IsUnitAlly(u, GetOwningPlayer(U)) == true) then
            set temp = R2I(temp * DENY_RATE)
            set i = 0
        endif
        
        if (UTILIZE_EXP_FUNCTIONALITY) then
            if (J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.aoe) then
                set N = 0
                
                call GroupEnumUnitsInRange(G, GetUnitX(u), GetUnitY(u), J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.exprad, J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.expfilter)
                if (J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.expshare) then
                    set temp = R2I(temp / N)
                endif
                
                call ForGroup(G, function GroupCallback)
            else
                call AddHeroXP(u, temp, true)
            endif
        endif
        
        if (UTILIZE_BOUNTY_FUNCTIONALITY) then
            if (i &lt;= 0) then
                set s = &quot;&quot;
            else
                if (J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.baoe) then
                    set N = 0
                    call GroupEnumUnitsInRange(G, GetUnitX(u), GetUnitY(u), J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyrad, J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyfilter)
                    if (J<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />.bountyshare) then
                        set temp = R2I(i / N)
                    else
                        set temp = i
                    endif
                    
                    call ForGroup(G, function BountyCallback)
                else
                    call SetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(p, PLAYER_STATE_RESOURCE_GOLD) + i)
                    call SetTextTagText(t,s+I2S(i),0.025)
                    call SetTextTagPos(t,GetUnitX(U),GetUnitY(U), 0.00)
                    call SetTextTagColor(t,255,220,0,255)
                    call SetTextTagVelocity(t,0,0.03)
                    if (GetLocalPlayer() == p) then
                        call SetTextTagVisibility(t,true)
                        set s=&quot;UI\\Feedback\\GoldCredit\\GoldCredit.mdl&quot;
                    else
                        call SetTextTagVisibility(t,false)
                        set s=&quot;&quot;
                    endif
                    
                    call DestroyEffect(AddSpecialEffect(s,GetUnitX(U),GetUnitY(U)))
                endif
            endif
        endif
        
        call SetTextTagFadepoint(t,2)
        call SetTextTagLifespan(t,3)
        call SetTextTagPermanent(t,false)
        
        set u = null
        set p = null
        set t = null
    endfunction
    
    private function Init takes nothing returns nothing
        local trigger trig = CreateTrigger()
        local integer i = 0
        call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_DEATH)
        call TriggerAddCondition(trig, Condition(function Conditions))
        call TriggerAddAction(trig, function Actions)
        loop
            if (GetPlayerController(Player(i)) == MAP_CONTROL_USER) and (GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING) and (UTILIZE_EXP_FUNCTIONALITY) then
                call SetPlayerHandicapXP(Player(i), 0.)
            endif
            if (UTILIZE_BOUNTY_FUNCTIONALITY) then
                call SetPlayerState(Player(i), PLAYER_STATE_GIVES_BOUNTY, 0)
            endif
            
            set i = i + 1
            exitwhen i == 16
        endloop
    endfunction
endlibrary


Example Usage:
JASS:
scope ExperienceRegistry initializer Init
    private function Init takes nothing returns nothing
        call LEET_RegisterUnitType(&#039;hpea&#039;, 20, 10, 20)  //Registers Peasants to give 20 exp, and bounty between 10 and 20.
        call LEET_RegisterUnitType(&#039;opeo&#039;, 50, 10, 40)  //Registers Peons to give 50 exp, and bounty between 10 and 40.
        call LEET_RegisterUnitType(&#039;uaco&#039;, 100, 20, 30) //Registers Acolytes to give 100 exp, and bounty between 20 and 30.
        call LEET_RegisterUnitType(&#039;nftr&#039;, 150, 20, 50) //Registers Forest Trolls to give 150 exp, and bounty between 20 and 50.
        call LEET_RegisterHeroType(&#039;Hblm&#039;)              //Registers the Blood Mage hero.
        call LEET_RegisterHeroType(&#039;Hamg&#039;)              //Registers the Archmage hero.
    endfunction
endscope


And yes the test map is ridiculously plain, so I want no complaining about it :p.

Changelog:
- v. 1.3: Added 2 new global boolean variables, UTILIZE_EXP/BOUNTY_FUNCTIONALITY.

- v. 1.2b: Made globals N and U public for custom filter usage.

- v. 1.2: Made it possible to give bounty in an AoE, aswell as split it equally among heroes who gain bounty. Added a few functions related to bounty similar to the old experience funcions (see the function list for more info).

- v. 1.1: Made it possible to split exp equally among heroes who gain exp. Added 4 new functions:
* SetUnitTypeExpShareFlag - Shared exp or not?
* GetUnitTypeExpShareFlag - Gets the current flag of the unittype
* SetUnitTypeExpFilter - Sets a new exp filter function to the unittype.
* ResetUnitTypeExpFilter - Sets the exp filter to the default one.

- v. 1.0b: Fixed bounty text to appear over the correct unit.

- v. 1.0: Initial release.
 

Attachments

  • LEET v. 1.3.w3x
    40.4 KB · Views: 293

Romek

Super Moderator
Reaction score
964
I can't sleep. :p

Also, this can all be done with one-liner hashtable functions.
Save/Get the exp. Unit Id as the key.
 
Reaction score
456
You don't need local Node for functions RegisterUnitTypeExp, UnregisterUnitTypeExp, GetUnitTypeExp, and ModifyUnitTypeExp. You could also add debug keyword in front of the elses :p.

Also is that condition in Init function necessary?

Not sure, but using hashing this could be less of a mess.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I can't sleep. :p

Also, this can all be done with one-liner hashtable functions.
Save/Get the exp. Unit Id as the key.
Blizzard has made them in the current patch.

Wait ... it seems they are still not working correctly :D
 

quraji

zap
Reaction score
144
Sorry to break your hard work Larcenist, but Romek is right, you can easily register any information to a unit type by using the type id as a hashtable key. I just did this myself yesterday to test it out, it works great :eek:

Maybe you should expand on this and make an actual experience system (gold too, eh? And anything else...).
 

Romek

Super Moderator
Reaction score
964
> Wait ... it seems they are still not working correctly
Last time I checked, they worked enough to store/retrieve integers.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
> I can't sleep.

I knew you of someone were to post this though :p

> You don't need local Node for functions RegisterUnitTypeExp, UnregisterUnitTypeExp, GetUnitTypeExp, and ModifyUnitTypeExp. You could also add debug keyword in front of the elses .


Totally true.

> Also is that condition in Init function necessary?

Not really, but I like to put in some extra work to prevent unnecessary stuff :p.

> Sorry to break your hard work Larcenist, but Romek is right

Hard work, no. This is some really easy stuff that doesn't require any work at all. I just found it useful.

As for the hashtable arguments, I personally neither like nor use them. Mainly because I do not trust them yet. If I ever were to use them I'd await a stable patch if something. Hence the making of this. There also seems to be a ridiculous amount of people having issues with NewGen and 1.24 (for some unfathomable reason), which at this point lowers the requirement and/or usage of hashtables.

While I'm on it, rewriting this to utilize hashtables would end up in about the same length anyway (if you exclude what could be excluded from the non-ht one). The only reason this system is a bit "lengthy" is because of the linked lists and fact that I protect the user from himself with the safety checks.
 

quraji

zap
Reaction score
144
> Sorry to break your hard work Larcenist, but Romek is right

Hard work, no. This is some really easy stuff that doesn't require any work at all. I just found it useful.

Better to say hard than easy, and offend you :p

At least make a hashtable version? For those of us who do trust them =]
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
With the current limitations, a hashtable version seems utterly useless. But if it makes someone just a little bit happier I can't see why not.

Edit: A hashtable version would be custom BJ functions basically so I won't make one as it is right now. And there would be extra calls nevertheless if you wish to store the exp of a unit type while using the unit id as key.
 

quraji

zap
Reaction score
144
With the current limitations, a hashtable version seems utterly useless.

What limitations?

I just see a hashtable version (although it may mostly just be "BJ" functions, as opposed your nice little list) as smaller, and maybe faster (speed of hashtable functions vs. assignments and searching for an id). Also, it could be easily expanded by the user (just through function calls) to store any information, not just the experience reward.

Edit: A hashtable version would be custom BJ functions basically so I won't make one as it is right now. And there would be extra calls nevertheless if you wish to store the exp of a unit type while using the unit id as key.

Just because lists are more complicated than hashtables doesn't justify this, if you think a hashtable version would be unnecessary.
 

Jesus4Lyf

Good Idea™
Reaction score
397
As for the hashtable arguments, I personally neither like nor use them. Mainly because I do not trust them yet. If I ever were to use them I'd await a stable patch if something. Hence the making of this. There also seems to be a ridiculous amount of people having issues with NewGen and 1.24 (for some unfathomable reason), which at this point lowers the requirement and/or usage of hashtables.
I agree, especially about the stable patch thing. We never know what on earth Blizzard will do next. Last time they broke return/else.

HOWEVER. There's an easy solution to this, as hashtables are not the right tool to do this anyway. Rawcode Hashing...

It is exactly what you need. Currently, this is O(n) complexity and doesn't need to be.

Also, I personally expect Rawcode Hashing to be faster than Blizzard's hashtables.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Yeah your rawcode hashing sure is nifty, but as I awoke from my quiet slumber quite drastically this "morning" (that being about half an hour ago :p) I figured that this can easily be rewritten as it is to work as an independant experience system, given that the user enters his/her own equation for calculating any hero experience. So as it is right now, this might be exactly what I'll do.

> What limitations?

I meant the limitations of this system, seeing as it only registers experience at this point.

> Currently, this is O(n) complexity and doesn't need to be.

This was mainly intentional just to keep a ridiculously easy interface to begin with. I could rewrite quite the lot of it to make it O(1) complexity, while changing the way of using it at the same time.

> Also, I personally expect Rawcode Hashing to be faster than Blizzard's hashtables.

This I would not doubt after seeing that the hashtables were not too damn fast to begin with.

On a somewhat related note, is there any set limitation of the values of keys used for Blizzard's hashtables (meaning key values can't excees value X)? I'm way too lazy to check it out myself.
 

UndeadDragon

Super Moderator
Reaction score
447
I personally think you should go the whole way and make the experience system.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Seeing as there is quite the lack of experience systems here at TheHelper I think I'll do just that. The main question is whether or not to keep the interface simple (since apperantly O(n) complexity gives J4L nightmares :p).
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
I think you should add some Add-ons, bounty, item drop, etc. Otherwise, it's a good example for teh new people.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
I'm currently rewriting it to work as an experience system, so add-ons are a given. The only thing is that I'll most likely leave the end user to write his/her own equations for hero exp/bounty, since those will most likely have quite the variation from map to map.
 

quraji

zap
Reaction score
144
Good to hear that you're rewriting this into (no offense) something useful :thup:

I still think hashtables should be given a fair chance, but do what you like. If not, you might want to do with J4L's hashing so you don't get knocked around for the searching.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
With it looking the way it currently is hashtables would be utterly useless to use (seeing as there's more than one value to get than just exp at this point, so a struct syntax seems cleaner). On a related note, I would not know what people expect of an experience system so this'll probably be one of the subjects to discuss after the release of the remade version of this (should be sometime soon, tomorrow if all's well).
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
So umm like, updated with a total remake which isn't tested at all basically. Now it's an experience/bounty system, so if some mod could change the title to Larcenist's Enhanced Experience Trigger that'd be great ^^.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top