System Bonus (unit state modification)

Discussion in 'Systems and Snippets' started by Cohadar, Nov 25, 2008.

  1. Cohadar

    Cohadar master of fugue

    Ratings:
    +209 / 0 / -0
    JASS:
    
    //==============================================================================
    //                Bonus -- State modification system -- v1.3
    //==============================================================================
    //
    //  AUTHOR:
    //       * Cohadar
    //
    //  PURPOUSE:
    //       * Easy changing of units' max life, max mana, armor, damage, str, agi, int, 
    //         move speed, attack speed, evasion, critical...
    //         (or anything else you put in)
    //
    //  EXAMPLES:
    //       * set Bonus_Life[whichUnit] = 4    // will add 400 life (DELTA = 100)
    //       * set Bonus_Armor[whichUnit] = 10  // will add 10 armor (DELTA = 1)
    //       * set Bonus_Damage[whichUnit] = 5  // will add 25 damage (DELTA = 5)
    //       * set Bonus_Evasion[whichUnit] = 4 // will add 20% evasion (DELTA = 5%)
    //
    //  PLUGINS:
    //       * Abilities needed by Bonus system are created with plugins
    //         If you do not need some bonus type simply do not use that type plugin
    //
    //  PROS: 
    //       * It removes the need for using abilties with 100 levels
    //         (significantly reduces map loading time)
    //       * It can be easily extended for other bonus types
    //
    //  CONS:
    //       * You have to be smart enough to calculate wanted modification from DELTA
    //       * System does not support negative values
    //
    //  DETAILS:
    //       * DELTA is the smallest value of modification (bonus resolution)
    //         DELTA is the bonus value in first bonus ability
    //       * COUNT is the number of custom abilities used per bonus
    //         Valid bonus ranges for binary bonuses are 0..(2^COUNT)-1
    //         Valid bonus ranges for linear bonuses are 0..COUNT
    //         Bonus is multiplied by DELTA to get the resulting modification
    //         For example bonus 7 will change units' life by 700 
    //         because life delta is set to 100
    //
    //  HOW TO IMPORT:
    //       * Just create a trigger named Bonus
    //         convert it to text and replace the whole trigger text with this one
    //       * Create needed abilities with Bonus Plugins
    //
    //==============================================================================
    library Bonus initializer Init
    
    //===========================================================================
    globals
        private constant integer MAX_CODES = 20 // max number of abilities per bonus
    endglobals    
    
    //===========================================================================
    interface IBonus
        method operator DELTA takes nothing returns integer
        method operator MAXBONUS takes nothing returns integer
        method operator[] takes unit whichUnit returns integer
        method operator[]= takes unit whichUnit, integer bonus returns nothing
    endinterface
    
    //===========================================================================
    //  This one is for stackable item abilities (life, mana, armor, str...)
    //===========================================================================
    private struct BinaryBonus extends IBonus
        private integer firstCode
        private integer count
        private integer delta
        private integer maxbonus
        private static integer array POWZ // powers of 2 for binary algorithm
    
        //-----------------------------------------------------------------------
        static method create takes integer firstCode, integer count, integer delta returns BinaryBonus
            local BinaryBonus bb = BinaryBonus.allocate()
            set bb.firstCode = firstCode
            set bb.count = count
            set bb.delta = delta
            set bb.maxbonus = .POWZ[count]-1
            return bb
        endmethod
        
        //-----------------------------------------------------------------------
        method operator DELTA takes nothing returns integer
            return .delta
        endmethod
        
        //-----------------------------------------------------------------------
        method operator MAXBONUS takes nothing returns integer
            return .maxbonus
        endmethod
        
        //-----------------------------------------------------------------------
        method operator[] takes unit whichUnit returns integer
            local integer bonus = 0
            local integer i = .count-1
            loop
                exitwhen i<0
                if GetUnitAbilityLevel(whichUnit, .firstCode+i)>0 then
                    set bonus = bonus + .POWZ[i]
                endif
                set i = i - 1
            endloop    
            return bonus    
        endmethod
        
        //-----------------------------------------------------------------------
        method operator[]= takes unit whichUnit, integer bonus returns nothing
            local integer i = .count-1
    
            if bonus < 0 then
                call BJDebugMsg("|c00ff0000"+SCOPE_PREFIX+"$NAME$["+GetUnitName(whichUnit)+"] = "+I2S(bonus)+" // bonus underflow")
            endif        
            if bonus > .POWZ[.count]-1 then
                call BJDebugMsg("|c00ff0000"+SCOPE_PREFIX+"$NAME$["+GetUnitName(whichUnit)+"] = "+I2S(bonus)+" // bonus overflow")
            endif        
            
            loop
                exitwhen i<0
                if bonus >= .POWZ[i] then
                    set bonus = bonus - .POWZ[i]
                    if GetUnitAbilityLevel(whichUnit, .firstCode+i)==0 then
                        call UnitAddAbility(whichUnit, .firstCode+i)
                        call UnitMakeAbilityPermanent(whichUnit, true, .firstCode+i)
                    endif
                else
                    if GetUnitAbilityLevel(whichUnit, .firstCode+i)>0 then
                        call UnitMakeAbilityPermanent(whichUnit, false, .firstCode+i)
                        call UnitRemoveAbility(whichUnit, .firstCode+i)
                    endif
                endif
                set i = i - 1
            endloop    
        endmethod
        
        //-----------------------------------------------------------------------
        private static method onInit takes nothing returns nothing
            local integer i = 0
            local integer pow = 1
            loop
                exitwhen i > MAX_CODES
                set .POWZ[i] = pow
                set i = i + 1
                set pow = pow * 2
            endloop
        endmethod
    endstruct
    
    //===========================================================================
    //  This one is for non-stackable abilities (move speed, evasion, critical, ...)
    //===========================================================================
    private struct LinearBonus extends IBonus
        private integer firstCode
        private integer count
        private integer delta
        private integer maxbonus
    
        //-----------------------------------------------------------------------
        private static method hideSpellBook takes integer abilId returns nothing
            local integer p = 0
            loop
                call SetPlayerAbilityAvailable(Player(p), abilId, false)
                set p = p + 1
                exitwhen p == bj_MAX_PLAYER_SLOTS
            endloop         
        endmethod    
        
        //-----------------------------------------------------------------------
        static method create takes integer firstCode, integer count, integer delta, boolean spellBook returns LinearBonus
            local LinearBonus lb = LinearBonus.allocate()
            local integer i
            set lb.firstCode = firstCode
            set lb.count = count
            set lb.delta = delta
            set lb.maxbonus = count
            if spellBook then
                set i = 0
                loop
                    exitwhen i>=count
                    call .hideSpellBook(firstCode+i)
                    set i = i + 1
                endloop    
            endif
            return lb
        endmethod
        
        //-----------------------------------------------------------------------
        method operator DELTA takes nothing returns integer
            return .delta
        endmethod
        
        //-----------------------------------------------------------------------
        method operator MAXBONUS takes nothing returns integer
            return .maxbonus
        endmethod
        
        //-----------------------------------------------------------------------
        method operator[] takes unit whichUnit returns integer
            local integer bonus = 0
            local integer i = .count-1
            loop
                exitwhen i<0
                if GetUnitAbilityLevel(whichUnit, .firstCode+i)>0 then
                    return i+1
                endif
                set i = i - 1
            endloop    
            return 0   
        endmethod
        
        //-----------------------------------------------------------------------
        method operator[]= takes unit whichUnit, integer bonus returns nothing
            local integer i = .count-1
    
            if bonus < 0 then
                call BJDebugMsg("|c00ff0000"+SCOPE_PREFIX+"$NAME$["+GetUnitName(whichUnit)+"] = "+I2S(bonus)+" // bonus underflow")
                set bonus = 0
            endif        
            if bonus > .count then
                call BJDebugMsg("|c00ff0000"+SCOPE_PREFIX+"$NAME$["+GetUnitName(whichUnit)+"] = "+I2S(bonus)+" // bonus overflow")
                set bonus = .count 
            endif        
            
            loop
                exitwhen i<0
                if GetUnitAbilityLevel(whichUnit, .firstCode+i)>0 then
                    call UnitMakeAbilityPermanent(whichUnit, false, .firstCode+i)
                    call UnitRemoveAbility(whichUnit, .firstCode+i)
                    exitwhen true
                endif
                set i = i - 1
            endloop
            
            if bonus > 0 then
                call UnitAddAbility(whichUnit, .firstCode+bonus-1)
                call UnitMakeAbilityPermanent(whichUnit, true, .firstCode+bonus-1)
            endif   
        endmethod
    endstruct
    
    //===========================================================================
    //  Bonus struct global variables
    //===========================================================================
    globals
        public IBonus Life
        public IBonus Mana
        public IBonus Armor
        public IBonus Damage
        public IBonus Str
        public IBonus Agi
        public IBonus Int
        public IBonus AttackSpeed
        public IBonus MoveSpeed    
        public IBonus Evasion
        public IBonus Critical
    endglobals
    
    //===========================================================================
    //  Init bonus structs
    //===========================================================================
    private function Init takes nothing returns nothing
        set Life   = BinaryBonus.create('A8L0', 8, 100)
        set Mana   = BinaryBonus.create('A8M0', 8, 100)
        
        set Armor  = BinaryBonus.create('A8D0', 8, 1)
        set Damage = BinaryBonus.create('A8T0', 8, 5)
        
        set Str    = BinaryBonus.create('A8S0', 8, 1)
        set Agi    = BinaryBonus.create('A8A0', 8, 1)
        set Int    = BinaryBonus.create('A8I0', 8, 1)
        
        set AttackSpeed = BinaryBonus.create('A8H0', 7, 5)
        set MoveSpeed   = LinearBonus.create('A8P1', 10, 5, false)    
        
        set Evasion  = LinearBonus.create('A8E1', 8, 5, true)
        set Critical = LinearBonus.create('A8C1', 8, 5, true)
    endfunction
    
    endlibrary


    JASS:
    
    //==============================================================================
    //                       BONUS PLUGINS -- v1.3
    //==============================================================================
    //
    //  AUTHOR:
    //       * Cohadar
    //
    //  PURPOSE:
    //       * Bonus plugins are used for creating abilities needed by Bonus system
    //       * Bonus plugins should be disabled by default
    //
    //  HOW TO USE PLUGINS:
    //       * Enable plugin trigger, save the map, close the map, open the map, disable plugin trigger
    //       * You must do this for every plugin trigger
    //
    //  WARNING:
    //       * Plugin triggers create lots abilities that start with 'A8'
    //         Check your map to make sure rawcodes don't collide with something you already have
    //         or your existing abilities may get overwritten.
    //       * Some linear abilities use skillbook with Base Order ID: attributemodskill
    //         Make sure you do not use this order ID for your custom skillbooks
    //       * Ability generation can take a very long time (up to 10 min), be patient.
    //         I also noticed it sometimes bugs if you alt-tab during generation.
    //
    //  CONVENTIONS:
    //       * All rawcodes start with 'A8'
    //       * Binary bonus rawcodes start from zero  // 'A8L0', 'A8L1', 'A8L2', ...
    //         Linear bonus rawcodes start from one   // 'A8e1', 'A8e2', 'A8e3', ...
    //       * Binary bonuses use uppercase letter on 3-rd digit
    //         Linear bonuses use lowercase letter on 3-rd digit
    //         Spellbooks use uppercase letter on 3-rd digit (same as their linear bonus ability) 'A8e1' -> 'A8E1'
    //       
    //  THANKS TO:
    //       * PitzerMike - for making grimex
    //
    //  NOTE: 
    //       * You should probably preload bonus abilities to prevent first cast lag
    //  
    //==============================================================================


    Plugins:
    JASS:
    
    //==============================================================================
    //  BONUS Plugin: Life and Mana 
    //==============================================================================
    //  This trigger should be disabled by default
    //==============================================================================
    //  To generate bonus abilities:
    //  Enable this trigger, save the map, close the map, open the map, disable this trigger
    //==============================================================================
    
    //---------------------------------< LIFE >-----------------------------------//
    //! external ObjectMerger w3a AIl2 A8L0 anam "Bonus Life" Ilif 1 100   ansf "(binary 0)"
    //! external ObjectMerger w3a AIl2 A8L1 anam "Bonus Life" Ilif 1 200   ansf "(binary 1)"
    //! external ObjectMerger w3a AIl2 A8L2 anam "Bonus Life" Ilif 1 400   ansf "(binary 2)"
    //! external ObjectMerger w3a AIl2 A8L3 anam "Bonus Life" Ilif 1 800   ansf "(binary 3)"
    //! external ObjectMerger w3a AIl2 A8L4 anam "Bonus Life" Ilif 1 1600  ansf "(binary 4)"
    //! external ObjectMerger w3a AIl2 A8L5 anam "Bonus Life" Ilif 1 3200  ansf "(binary 5)"
    //! external ObjectMerger w3a AIl2 A8L6 anam "Bonus Life" Ilif 1 6400  ansf "(binary 6)"
    //! external ObjectMerger w3a AIl2 A8L7 anam "Bonus Life" Ilif 1 12800 ansf "(binary 7)"
    
    //---------------------------------< MANA >-----------------------------------//
    //! external ObjectMerger w3a AImz A8M0 anam "Bonus Mana" Iman 1 100   ansf "(binary 0)"
    //! external ObjectMerger w3a AImz A8M1 anam "Bonus Mana" Iman 1 200   ansf "(binary 1)"
    //! external ObjectMerger w3a AImz A8M2 anam "Bonus Mana" Iman 1 400   ansf "(binary 2)"
    //! external ObjectMerger w3a AImz A8M3 anam "Bonus Mana" Iman 1 800   ansf "(binary 3)"
    //! external ObjectMerger w3a AImz A8M4 anam "Bonus Mana" Iman 1 1600  ansf "(binary 4)"
    //! external ObjectMerger w3a AImz A8M5 anam "Bonus Mana" Iman 1 3200  ansf "(binary 5)"
    //! external ObjectMerger w3a AImz A8M6 anam "Bonus Mana" Iman 1 6400  ansf "(binary 6)"
    //! external ObjectMerger w3a AImz A8M7 anam "Bonus Mana" Iman 1 12800 ansf "(binary 7)"
    
    //==============================================================================


    JASS:
    
    //==============================================================================
    //  BONUS Plugin: Armor and Damage
    //==============================================================================
    //  This trigger should be disabled by default
    //==============================================================================
    //  To generate bonus abilities:
    //  Enable this trigger, save the map, close the map, open the map, disable this trigger
    //==============================================================================
    
    //---------------------------------< ARMOR >----------------------------------//
    //! external ObjectMerger w3a AId2 A8D0 anam "Bonus Armor" Idef 1 1   ansf "(binary 0)"
    //! external ObjectMerger w3a AId2 A8D1 anam "Bonus Armor" Idef 1 2   ansf "(binary 1)"
    //! external ObjectMerger w3a AId2 A8D2 anam "Bonus Armor" Idef 1 4   ansf "(binary 2)"
    //! external ObjectMerger w3a AId2 A8D3 anam "Bonus Armor" Idef 1 8   ansf "(binary 3)"
    //! external ObjectMerger w3a AId2 A8D4 anam "Bonus Armor" Idef 1 16  ansf "(binary 4)"
    //! external ObjectMerger w3a AId2 A8D5 anam "Bonus Armor" Idef 1 32  ansf "(binary 5)"
    //! external ObjectMerger w3a AId2 A8D6 anam "Bonus Armor" Idef 1 64  ansf "(binary 6)"
    //! external ObjectMerger w3a AId2 A8D7 anam "Bonus Armor" Idef 1 128 ansf "(binary 7)"
    
    //---------------------------------< DAMAGE >---------------------------------//
    //! external ObjectMerger w3a AItg A8T0 anam "Bonus Damage" Iatt 1 5   ansf "(binary 0)"
    //! external ObjectMerger w3a AItg A8T1 anam "Bonus Damage" Iatt 1 10  ansf "(binary 1)"
    //! external ObjectMerger w3a AItg A8T2 anam "Bonus Damage" Iatt 1 20  ansf "(binary 2)"
    //! external ObjectMerger w3a AItg A8T3 anam "Bonus Damage" Iatt 1 40  ansf "(binary 3)"
    //! external ObjectMerger w3a AItg A8T4 anam "Bonus Damage" Iatt 1 80  ansf "(binary 4)"
    //! external ObjectMerger w3a AItg A8T5 anam "Bonus Damage" Iatt 1 160 ansf "(binary 5)"
    //! external ObjectMerger w3a AItg A8T6 anam "Bonus Damage" Iatt 1 320 ansf "(binary 6)"
    //! external ObjectMerger w3a AItg A8T7 anam "Bonus Damage" Iatt 1 640 ansf "(binary 7)"
    
    //==============================================================================


    JASS:
    
    //==============================================================================
    //  BONUS Plugin: Strength, Agility and Intelligence
    //==============================================================================
    //  This trigger should be disabled by default
    //==============================================================================
    //  To generate bonus abilities:
    //  Enable this trigger, save the map, close the map, open the map, disable this trigger
    //==============================================================================
    
    //---------------------------------< STR >-----------------------------------//
    //! external ObjectMerger w3a AIs1 A8S0 anam "Bonus Strength" Istr 1 1   ansf "(binary 0)"
    //! external ObjectMerger w3a AIs1 A8S1 anam "Bonus Strength" Istr 1 2   ansf "(binary 1)"
    //! external ObjectMerger w3a AIs1 A8S2 anam "Bonus Strength" Istr 1 4   ansf "(binary 2)"
    //! external ObjectMerger w3a AIs1 A8S3 anam "Bonus Strength" Istr 1 8   ansf "(binary 3)"
    //! external ObjectMerger w3a AIs1 A8S4 anam "Bonus Strength" Istr 1 16  ansf "(binary 4)"
    //! external ObjectMerger w3a AIs1 A8S5 anam "Bonus Strength" Istr 1 32  ansf "(binary 5)"
    //! external ObjectMerger w3a AIs1 A8S6 anam "Bonus Strength" Istr 1 64  ansf "(binary 6)"
    //! external ObjectMerger w3a AIs1 A8S7 anam "Bonus Strength" Istr 1 128 ansf "(binary 7)"
    
    //---------------------------------< AGI >-----------------------------------//
    //! external ObjectMerger w3a AIa1 A8A0 anam "Bonus Agility" Iagi 1 1   ansf "(binary 0)"
    //! external ObjectMerger w3a AIa1 A8A1 anam "Bonus Agility" Iagi 1 2   ansf "(binary 1)"
    //! external ObjectMerger w3a AIa1 A8A2 anam "Bonus Agility" Iagi 1 4   ansf "(binary 2)"
    //! external ObjectMerger w3a AIa1 A8A3 anam "Bonus Agility" Iagi 1 8   ansf "(binary 3)"
    //! external ObjectMerger w3a AIa1 A8A4 anam "Bonus Agility" Iagi 1 16  ansf "(binary 4)"
    //! external ObjectMerger w3a AIa1 A8A5 anam "Bonus Agility" Iagi 1 32  ansf "(binary 5)"
    //! external ObjectMerger w3a AIa1 A8A6 anam "Bonus Agility" Iagi 1 64  ansf "(binary 6)"
    //! external ObjectMerger w3a AIa1 A8A7 anam "Bonus Agility" Iagi 1 128 ansf "(binary 7)"
    
    //---------------------------------< INT >-----------------------------------//
    //! external ObjectMerger w3a AIi1 A8I0 anam "Bonus Intelligence" Iint 1 1   ansf "(binary 0)"
    //! external ObjectMerger w3a AIi1 A8I1 anam "Bonus Intelligence" Iint 1 2   ansf "(binary 1)"
    //! external ObjectMerger w3a AIi1 A8I2 anam "Bonus Intelligence" Iint 1 4   ansf "(binary 2)"
    //! external ObjectMerger w3a AIi1 A8I3 anam "Bonus Intelligence" Iint 1 8   ansf "(binary 3)"
    //! external ObjectMerger w3a AIi1 A8I4 anam "Bonus Intelligence" Iint 1 16  ansf "(binary 4)"
    //! external ObjectMerger w3a AIi1 A8I5 anam "Bonus Intelligence" Iint 1 32  ansf "(binary 5)"
    //! external ObjectMerger w3a AIi1 A8I6 anam "Bonus Intelligence" Iint 1 64  ansf "(binary 6)"
    //! external ObjectMerger w3a AIi1 A8I7 anam "Bonus Intelligence" Iint 1 128 ansf "(binary 7)"
    
    //==============================================================================


    JASS:
    
    //==============================================================================
    //  BONUS Plugin: Attack and Move Speed
    //==============================================================================
    //  This trigger should be disabled by default
    //==============================================================================
    //  To generate bonus abilities:
    //  Enable this trigger, save the map, close the map, open the map, disable this trigger
    //==============================================================================
    
    //---------------------------------< ATTS >----------------------------------//
    //! external ObjectMerger w3a AIsx A8H0 anam "Bonus Attack Speed" Isx1 1 0.05 ansf "(binary 0)"
    //! external ObjectMerger w3a AIsx A8H1 anam "Bonus Attack Speed" Isx1 1 0.10 ansf "(binary 1)"
    //! external ObjectMerger w3a AIsx A8H2 anam "Bonus Attack Speed" Isx1 1 0.20 ansf "(binary 2)"
    //! external ObjectMerger w3a AIsx A8H3 anam "Bonus Attack Speed" Isx1 1 0.40 ansf "(binary 3)"
    //! external ObjectMerger w3a AIsx A8H4 anam "Bonus Attack Speed" Isx1 1 0.80 ansf "(binary 4)"
    //! external ObjectMerger w3a AIsx A8H5 anam "Bonus Attack Speed" Isx1 1 1.60 ansf "(binary 5)"
    //! external ObjectMerger w3a AIsx A8H6 anam "Bonus Attack Speed" Isx1 1 3.20 ansf "(binary 6)"
    
    //---------------------------------< MOVE >----------------------------------//
    //! external ObjectMerger w3a AIms A8P1 anam "Bonus Move Speed" Imvb 1 10  ansf "(linear 1)"
    //! external ObjectMerger w3a AIms A8P2 anam "Bonus Move Speed" Imvb 1 20  ansf "(linear 2)"
    //! external ObjectMerger w3a AIms A8P3 anam "Bonus Move Speed" Imvb 1 30  ansf "(linear 3)"
    //! external ObjectMerger w3a AIms A8P4 anam "Bonus Move Speed" Imvb 1 40  ansf "(linear 4)"
    //! external ObjectMerger w3a AIms A8P5 anam "Bonus Move Speed" Imvb 1 50  ansf "(linear 5)"
    //! external ObjectMerger w3a AIms A8P6 anam "Bonus Move Speed" Imvb 1 60  ansf "(linear 6)"
    //! external ObjectMerger w3a AIms A8P7 anam "Bonus Move Speed" Imvb 1 70  ansf "(linear 7)"
    //! external ObjectMerger w3a AIms A8P8 anam "Bonus Move Speed" Imvb 1 80  ansf "(linear 8)"
    //! external ObjectMerger w3a AIms A8P9 anam "Bonus Move Speed" Imvb 1 90  ansf "(linear 9)"
    //! external ObjectMerger w3a AIms A8P: anam "Bonus Move Speed" Imvb 1 100 ansf "(linear :)"
    
    //==============================================================================


    JASS:
    
    //==============================================================================
    //  BONUS Plugin: Evasion and Critical
    //==============================================================================
    //  This trigger should be disabled by default
    //==============================================================================
    //  To generate bonus abilities:
    //  Enable this trigger, save the map, close the map, open the map, disable this trigger
    //==============================================================================
    
    //---------------------------------< EVASION >-------------------------------//
    //! external ObjectMerger w3a AIev A8e1 anam "Bonus Evasion" Eev1 1 0.05 ansf "(linear 1)"
    //! external ObjectMerger w3a AIev A8e2 anam "Bonus Evasion" Eev1 1 0.10 ansf "(linear 2)"
    //! external ObjectMerger w3a AIev A8e3 anam "Bonus Evasion" Eev1 1 0.15 ansf "(linear 3)"
    //! external ObjectMerger w3a AIev A8e4 anam "Bonus Evasion" Eev1 1 0.20 ansf "(linear 4)"
    //! external ObjectMerger w3a AIev A8e5 anam "Bonus Evasion" Eev1 1 0.25 ansf "(linear 5)"
    //! external ObjectMerger w3a AIev A8e6 anam "Bonus Evasion" Eev1 1 0.30 ansf "(linear 6)"
    //! external ObjectMerger w3a AIev A8e7 anam "Bonus Evasion" Eev1 1 0.35 ansf "(linear 7)"
    //! external ObjectMerger w3a AIev A8e8 anam "Bonus Evasion" Eev1 1 0.40 ansf "(linear 8)"
    //-- spellbook
    //! external ObjectMerger w3a Aspb A8E1 anam "Bonus Evasion" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e1 ansf "(spellbook 1)" aart "ReplaceableTextures\CommandButtons\BTNEvasion.blp"
    //! external ObjectMerger w3a Aspb A8E2 anam "Bonus Evasion" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e2 ansf "(spellbook 2)" aart "ReplaceableTextures\CommandButtons\BTNEvasion.blp"
    //! external ObjectMerger w3a Aspb A8E3 anam "Bonus Evasion" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e3 ansf "(spellbook 3)" aart "ReplaceableTextures\CommandButtons\BTNEvasion.blp"
    //! external ObjectMerger w3a Aspb A8E4 anam "Bonus Evasion" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e4 ansf "(spellbook 4)" aart "ReplaceableTextures\CommandButtons\BTNEvasion.blp"
    //! external ObjectMerger w3a Aspb A8E5 anam "Bonus Evasion" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e5 ansf "(spellbook 5)" aart "ReplaceableTextures\CommandButtons\BTNEvasion.blp"
    //! external ObjectMerger w3a Aspb A8E6 anam "Bonus Evasion" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e6 ansf "(spellbook 6)" aart "ReplaceableTextures\CommandButtons\BTNEvasion.blp"
    //! external ObjectMerger w3a Aspb A8E7 anam "Bonus Evasion" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e7 ansf "(spellbook 7)" aart "ReplaceableTextures\CommandButtons\BTNEvasion.blp"
    //! external ObjectMerger w3a Aspb A8E8 anam "Bonus Evasion" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e8 ansf "(spellbook 8)" aart "ReplaceableTextures\CommandButtons\BTNEvasion.blp"
    
    //---------------------------------< CRITICAL >-------------------------------//
    //! external ObjectMerger w3a AIcs A8c1 anam "Bonus Critical" Ocr1 1 5  ansf "(linear 1)"
    //! external ObjectMerger w3a AIcs A8c2 anam "Bonus Critical" Ocr1 1 10 ansf "(linear 2)"
    //! external ObjectMerger w3a AIcs A8c3 anam "Bonus Critical" Ocr1 1 15 ansf "(linear 3)"
    //! external ObjectMerger w3a AIcs A8c4 anam "Bonus Critical" Ocr1 1 20 ansf "(linear 4)"
    //! external ObjectMerger w3a AIcs A8c5 anam "Bonus Critical" Ocr1 1 25 ansf "(linear 5)"
    //! external ObjectMerger w3a AIcs A8c6 anam "Bonus Critical" Ocr1 1 30 ansf "(linear 6)"
    //! external ObjectMerger w3a AIcs A8c7 anam "Bonus Critical" Ocr1 1 35 ansf "(linear 7)"
    //! external ObjectMerger w3a AIcs A8c8 anam "Bonus Critical" Ocr1 1 40 ansf "(linear 8)"
    //-- spellbook
    //! external ObjectMerger w3a Aspb A8C1 anam "Bonus Critical" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c1 ansf "(spellbook 1)" aart "ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp"
    //! external ObjectMerger w3a Aspb A8C2 anam "Bonus Critical" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c2 ansf "(spellbook 2)" aart "ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp"
    //! external ObjectMerger w3a Aspb A8C3 anam "Bonus Critical" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c3 ansf "(spellbook 3)" aart "ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp"
    //! external ObjectMerger w3a Aspb A8C4 anam "Bonus Critical" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c4 ansf "(spellbook 4)" aart "ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp"
    //! external ObjectMerger w3a Aspb A8C5 anam "Bonus Critical" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c5 ansf "(spellbook 5)" aart "ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp"
    //! external ObjectMerger w3a Aspb A8C6 anam "Bonus Critical" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c6 ansf "(spellbook 6)" aart "ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp"
    //! external ObjectMerger w3a Aspb A8C7 anam "Bonus Critical" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c7 ansf "(spellbook 7)" aart "ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp"
    //! external ObjectMerger w3a Aspb A8C8 anam "Bonus Critical" spb5 1 "attributemodskill" spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c8 ansf "(spellbook 8)" aart "ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp"
    
    //==============================================================================
     

    Attached Files:

    • Like Like x 6
  2. Trollvottel

    Trollvottel never aging title

    Ratings:
    +261 / 0 / -0
    I think i have seen something similar on wc3c. anyway, can you remove bonusses?
     
  3. Renendaru

    Renendaru (Evol)ution is nothing without love.

    Ratings:
    +309 / 0 / -0
    @Trollvotel: That script is out of date on wc3c. It doesn't work that well anymore I think.
     
  4. Builder Bob

    Builder Bob Live free or don't

    Ratings:
    +249 / 0 / -0
    I was just looking for a simple way to modify max health.

    This looks like a great addition to your line of user friendly systems. Don't even have to create an ability in the object editor. Nicely done!

    Edit: Does the same method work for Movespeed increases?
     
  5. Hatebreeder

    Hatebreeder So many apples

    Ratings:
    +383 / 0 / -0
    Awesomeness !
    THis is just what I needed =)
    Thnx, Cohadar =P
     
  6. Cohadar

    Cohadar master of fugue

    Ratings:
    +209 / 0 / -0
    Yes

    Yes (read FAQ in map)

    EDIT: Maybe you should give me a list of abilities you want "bonused" so I can include them in next version?
     
  7. Builder Bob

    Builder Bob Live free or don't

    Ratings:
    +249 / 0 / -0
    Oh, I get it now. I can add movement speed myself.

    If you want more bonuses in the system move speed and attack speed are bonuses I think is very important. Maybe someone would like health and mana regen too. If you're feeling crazy you could even add sight range, however little useful it might be ^_^


    Edit: It seems I came to a wall when trying to add movement speed.
    Code:
    //! external ObjectMerger w3a AIms A8B0 anam "Bonus Movespeed" [B]Imov[/B] 1 10   ansf "(level 0)"
    I have no idea what it should say at the bolded part.
    The rest should be right I think. I've never made abilities this way though, so I don't know.
     
  8. Cohadar

    Cohadar master of fugue

    Ratings:
    +209 / 0 / -0
    [​IMG]
     

    Attached Files:

  9. Builder Bob

    Builder Bob Live free or don't

    Ratings:
    +249 / 0 / -0
    what editor are you using that can show that? Do I have to enable anything in Newgen?

    Edit: It compiled now :)

    Edit2: I enabled grimore object editor hack and now all those extra codes show up.

    Sorry if you think I've cluttered your thread. It's just that you posted your system when I needed it very much. Thanks for your help!
     
  10. Cohadar

    Cohadar master of fugue

    Ratings:
    +209 / 0 / -0
    Updated with support for linear bonuses (evasion, critical ...)
    Basically anything that does not stack additively or needs a disabled spellbook (for hiding ability icon)

    I will add support for other abilities as a separate code fragments. (in order not to bloath the system)
     
  11. Builder Bob

    Builder Bob Live free or don't

    Ratings:
    +249 / 0 / -0
    It's very minor, but I spotted an error
    Code:
    //! external ObjectMerger w3a AIev A8e1 anam "Bonus Evasion" Eev1 1 0.05 ansf "(linear 1)"
    //! external ObjectMerger w3a AIev A8e2 anam "Bonus Evasion" Eev1 1 [B]0.01[/B] ansf "(linear 2)"
    //! external ObjectMerger w3a AIev A8e3 anam "Bonus Evasion" Eev1 1 0.15 ansf "(linear 3)"
     
  12. Gamat

    Gamat New Member

    Ratings:
    +1 / 0 / -0
    I'm having problems to run the test map without errors, i use normal we i need anything more?
     
  13. Cohadar

    Cohadar master of fugue

    Ratings:
    +209 / 0 / -0
    You need NewGen

    //=============================
    Version 1.2 - you can now write plugins
    //=============================
     
  14. Builder Bob

    Builder Bob Live free or don't

    Ratings:
    +249 / 0 / -0
    Nice changes.

    -----------------
    I did some testing with move speed bonuses using GetUnitMoveSpeed(). It seems move speed should be a linear bonus. Only the highest bonus applies unfortunately...

    Test input:
    Code:
    Delta = 20
    
    //! runtextmacro BINARYBONUS("Move", "A8P0", "8", "20")
    
    //---------------------------------< MOVE >----------------------------------//
    //! external ObjectMerger w3a AIms A8P0 anam "Bonus Move Speed" Imvb 1 20  ansf "(binary 0)"
    //! external ObjectMerger w3a AIms A8P1 anam "Bonus Move Speed" Imvb 1 40  ansf "(binary 1)"
    //! external ObjectMerger w3a AIms A8P2 anam "Bonus Move Speed" Imvb 1 80  ansf "(binary 2)"
    //! external ObjectMerger w3a AIms A8P3 anam "Bonus Move Speed" Imvb 1 160  ansf "(binary 3)"
    //! external ObjectMerger w3a AIms A8P4 anam "Bonus Move Speed" Imvb 1 320 ansf "(binary 4)"
    //! external ObjectMerger w3a AIms A8P5 anam "Bonus Move Speed" Imvb 1 640 ansf "(binary 5)"
    //! external ObjectMerger w3a AIms A8P6 anam "Bonus Move Speed" Imvb 1 1280 ansf "(binary 6)"
    //! external ObjectMerger w3a AIms A8P7 anam "Bonus Move Speed" Imvb 1 2560 ansf "(binary 7)"

    Test results:
    set Bonus_Move[] = 0
    GetUnitMoveSpeed() returns 300
    set Bonus_Move[] = 1 //20
    GetUnitMoveSpeed() returns 320
    set Bonus_Move[] = 2 //40
    GetUnitMoveSpeed() returns 340
    set Bonus_Move[] = 3 //60
    GetUnitMoveSpeed() returns 340
    set Bonus_Move[] = 4 //80
    GetUnitMoveSpeed() returns 380
    set Bonus_Move[] = 5 //100
    GetUnitMoveSpeed() returns 380
    set Bonus_Move[] = 6 //120
    GetUnitMoveSpeed() returns 380
    set Bonus_Move[] = 7 //140
    call GetUnitMoveSpeed() returns 380
    set Bonus_Move[] = 8 //160
    call GetUnitMoveSpeed() returns 460
    set Bonus_Move[] = 9 //180
    call GetUnitMoveSpeed() returns 460
     
  15. Cohadar

    Cohadar master of fugue

    Ratings:
    +209 / 0 / -0
    Will see what I can do. Maybe there is some other speed ability that stacks.

    I have no time right now, so you can write linear speed plugin.
    If I don't find a better solution I will include it in the sys.

    EDIT:
    It turns out that you cannot add more than 100 move speed bonus with that ability.
    So logic solution would be to use linear : 10, 20, 30, ... 100
     
  16. Builder Bob

    Builder Bob Live free or don't

    Ratings:
    +249 / 0 / -0
    Yup, I'm using a linear bonus until you find a better way.
     
  17. Grundy

    Grundy Ultra Cool Member

    Ratings:
    +35 / 0 / -0
    I know it's % based and doesn't add an exact value to the move speed, but if you want to do this with an endurance aura for bonus move speed would that have to be a linear one?
     
  18. saw792

    saw792 Is known to say things. That is all.

    Ratings:
    +280 / 0 / -0
    Sexiest system I've seen for a long time. Good to see people finally making (widespread) use of GrimEx functions.

    In the unlikely event that I possibly make a map I may consider using this perhaps (maybe).
     
  19. Hatebreeder

    Hatebreeder So many apples

    Ratings:
    +383 / 0 / -0
    Isn't there an "SetUnitMoveSpeed(Unit,Speed)" function?
    Wouldn't it be easier to use that?
     
  20. Cohadar

    Cohadar master of fugue

    Ratings:
    +209 / 0 / -0

Share This Page