System Bonus (unit state modification)

Cohadar

master of fugue
Reaction score
209
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 &lt; 0 then
            call BJDebugMsg(&quot;|c00ff0000&quot;+SCOPE_PREFIX+&quot;$NAME$[&quot;+GetUnitName(whichUnit)+&quot;] = &quot;+I2S(bonus)+&quot; // bonus underflow&quot;)
        endif        
        if bonus &gt; .POWZ[.count]-1 then
            call BJDebugMsg(&quot;|c00ff0000&quot;+SCOPE_PREFIX+&quot;$NAME$[&quot;+GetUnitName(whichUnit)+&quot;] = &quot;+I2S(bonus)+&quot; // bonus overflow&quot;)
        endif        
        
        loop
            exitwhen i&lt;0
            if bonus &gt;= .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)&gt;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 &gt; 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&gt;=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&lt;0
            if GetUnitAbilityLevel(whichUnit, .firstCode+i)&gt;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 &lt; 0 then
            call BJDebugMsg(&quot;|c00ff0000&quot;+SCOPE_PREFIX+&quot;$NAME$[&quot;+GetUnitName(whichUnit)+&quot;] = &quot;+I2S(bonus)+&quot; // bonus underflow&quot;)
            set bonus = 0
        endif        
        if bonus &gt; .count then
            call BJDebugMsg(&quot;|c00ff0000&quot;+SCOPE_PREFIX+&quot;$NAME$[&quot;+GetUnitName(whichUnit)+&quot;] = &quot;+I2S(bonus)+&quot; // bonus overflow&quot;)
            set bonus = .count 
        endif        
        
        loop
            exitwhen i&lt;0
            if GetUnitAbilityLevel(whichUnit, .firstCode+i)&gt;0 then
                call UnitMakeAbilityPermanent(whichUnit, false, .firstCode+i)
                call UnitRemoveAbility(whichUnit, .firstCode+i)
                exitwhen true
            endif
            set i = i - 1
        endloop
        
        if bonus &gt; 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(&#039;A8L0&#039;, 8, 100)
    set Mana   = BinaryBonus.create(&#039;A8M0&#039;, 8, 100)
    
    set Armor  = BinaryBonus.create(&#039;A8D0&#039;, 8, 1)
    set Damage = BinaryBonus.create(&#039;A8T0&#039;, 8, 5)
    
    set Str    = BinaryBonus.create(&#039;A8S0&#039;, 8, 1)
    set Agi    = BinaryBonus.create(&#039;A8A0&#039;, 8, 1)
    set Int    = BinaryBonus.create(&#039;A8I0&#039;, 8, 1)
    
    set AttackSpeed = BinaryBonus.create(&#039;A8H0&#039;, 7, 5)
    set MoveSpeed   = LinearBonus.create(&#039;A8P1&#039;, 10, 5, false)    
    
    set Evasion  = LinearBonus.create(&#039;A8E1&#039;, 8, 5, true)
    set Critical = LinearBonus.create(&#039;A8C1&#039;, 8, 5, true)
endfunction

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


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 &#039;A8&#039;
//         Check your map to make sure rawcodes don&#039;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 &#039;A8&#039;
//       * Binary bonus rawcodes start from zero  // &#039;A8L0&#039;, &#039;A8L1&#039;, &#039;A8L2&#039;, ...
//         Linear bonus rawcodes start from one   // &#039;A8e1&#039;, &#039;A8e2&#039;, &#039;A8e3&#039;, ...
//       * 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) &#039;A8e1&#039; -&gt; &#039;A8E1&#039;
//       
//  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
//==============================================================================

//---------------------------------&lt; LIFE &gt;-----------------------------------//
//! external ObjectMerger w3a AIl2 A8L0 anam &quot;Bonus Life&quot; Ilif 1 100   ansf &quot;(binary 0)&quot;
//! external ObjectMerger w3a AIl2 A8L1 anam &quot;Bonus Life&quot; Ilif 1 200   ansf &quot;(binary 1)&quot;
//! external ObjectMerger w3a AIl2 A8L2 anam &quot;Bonus Life&quot; Ilif 1 400   ansf &quot;(binary 2)&quot;
//! external ObjectMerger w3a AIl2 A8L3 anam &quot;Bonus Life&quot; Ilif 1 800   ansf &quot;(binary 3)&quot;
//! external ObjectMerger w3a AIl2 A8L4 anam &quot;Bonus Life&quot; Ilif 1 1600  ansf &quot;(binary 4)&quot;
//! external ObjectMerger w3a AIl2 A8L5 anam &quot;Bonus Life&quot; Ilif 1 3200  ansf &quot;(binary 5)&quot;
//! external ObjectMerger w3a AIl2 A8L6 anam &quot;Bonus Life&quot; Ilif 1 6400  ansf &quot;(binary 6)&quot;
//! external ObjectMerger w3a AIl2 A8L7 anam &quot;Bonus Life&quot; Ilif 1 12800 ansf &quot;(binary 7)&quot;

//---------------------------------&lt; MANA &gt;-----------------------------------//
//! external ObjectMerger w3a AImz A8M0 anam &quot;Bonus Mana&quot; Iman 1 100   ansf &quot;(binary 0)&quot;
//! external ObjectMerger w3a AImz A8M1 anam &quot;Bonus Mana&quot; Iman 1 200   ansf &quot;(binary 1)&quot;
//! external ObjectMerger w3a AImz A8M2 anam &quot;Bonus Mana&quot; Iman 1 400   ansf &quot;(binary 2)&quot;
//! external ObjectMerger w3a AImz A8M3 anam &quot;Bonus Mana&quot; Iman 1 800   ansf &quot;(binary 3)&quot;
//! external ObjectMerger w3a AImz A8M4 anam &quot;Bonus Mana&quot; Iman 1 1600  ansf &quot;(binary 4)&quot;
//! external ObjectMerger w3a AImz A8M5 anam &quot;Bonus Mana&quot; Iman 1 3200  ansf &quot;(binary 5)&quot;
//! external ObjectMerger w3a AImz A8M6 anam &quot;Bonus Mana&quot; Iman 1 6400  ansf &quot;(binary 6)&quot;
//! external ObjectMerger w3a AImz A8M7 anam &quot;Bonus Mana&quot; Iman 1 12800 ansf &quot;(binary 7)&quot;

//==============================================================================


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
//==============================================================================

//---------------------------------&lt; ARMOR &gt;----------------------------------//
//! external ObjectMerger w3a AId2 A8D0 anam &quot;Bonus Armor&quot; Idef 1 1   ansf &quot;(binary 0)&quot;
//! external ObjectMerger w3a AId2 A8D1 anam &quot;Bonus Armor&quot; Idef 1 2   ansf &quot;(binary 1)&quot;
//! external ObjectMerger w3a AId2 A8D2 anam &quot;Bonus Armor&quot; Idef 1 4   ansf &quot;(binary 2)&quot;
//! external ObjectMerger w3a AId2 A8D3 anam &quot;Bonus Armor&quot; Idef 1 8   ansf &quot;(binary 3)&quot;
//! external ObjectMerger w3a AId2 A8D4 anam &quot;Bonus Armor&quot; Idef 1 16  ansf &quot;(binary 4)&quot;
//! external ObjectMerger w3a AId2 A8D5 anam &quot;Bonus Armor&quot; Idef 1 32  ansf &quot;(binary 5)&quot;
//! external ObjectMerger w3a AId2 A8D6 anam &quot;Bonus Armor&quot; Idef 1 64  ansf &quot;(binary 6)&quot;
//! external ObjectMerger w3a AId2 A8D7 anam &quot;Bonus Armor&quot; Idef 1 128 ansf &quot;(binary 7)&quot;

//---------------------------------&lt; DAMAGE &gt;---------------------------------//
//! external ObjectMerger w3a AItg A8T0 anam &quot;Bonus Damage&quot; Iatt 1 5   ansf &quot;(binary 0)&quot;
//! external ObjectMerger w3a AItg A8T1 anam &quot;Bonus Damage&quot; Iatt 1 10  ansf &quot;(binary 1)&quot;
//! external ObjectMerger w3a AItg A8T2 anam &quot;Bonus Damage&quot; Iatt 1 20  ansf &quot;(binary 2)&quot;
//! external ObjectMerger w3a AItg A8T3 anam &quot;Bonus Damage&quot; Iatt 1 40  ansf &quot;(binary 3)&quot;
//! external ObjectMerger w3a AItg A8T4 anam &quot;Bonus Damage&quot; Iatt 1 80  ansf &quot;(binary 4)&quot;
//! external ObjectMerger w3a AItg A8T5 anam &quot;Bonus Damage&quot; Iatt 1 160 ansf &quot;(binary 5)&quot;
//! external ObjectMerger w3a AItg A8T6 anam &quot;Bonus Damage&quot; Iatt 1 320 ansf &quot;(binary 6)&quot;
//! external ObjectMerger w3a AItg A8T7 anam &quot;Bonus Damage&quot; Iatt 1 640 ansf &quot;(binary 7)&quot;

//==============================================================================


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
//==============================================================================

//---------------------------------&lt; STR &gt;-----------------------------------//
//! external ObjectMerger w3a AIs1 A8S0 anam &quot;Bonus Strength&quot; Istr 1 1   ansf &quot;(binary 0)&quot;
//! external ObjectMerger w3a AIs1 A8S1 anam &quot;Bonus Strength&quot; Istr 1 2   ansf &quot;(binary 1)&quot;
//! external ObjectMerger w3a AIs1 A8S2 anam &quot;Bonus Strength&quot; Istr 1 4   ansf &quot;(binary 2)&quot;
//! external ObjectMerger w3a AIs1 A8S3 anam &quot;Bonus Strength&quot; Istr 1 8   ansf &quot;(binary 3)&quot;
//! external ObjectMerger w3a AIs1 A8S4 anam &quot;Bonus Strength&quot; Istr 1 16  ansf &quot;(binary 4)&quot;
//! external ObjectMerger w3a AIs1 A8S5 anam &quot;Bonus Strength&quot; Istr 1 32  ansf &quot;(binary 5)&quot;
//! external ObjectMerger w3a AIs1 A8S6 anam &quot;Bonus Strength&quot; Istr 1 64  ansf &quot;(binary 6)&quot;
//! external ObjectMerger w3a AIs1 A8S7 anam &quot;Bonus Strength&quot; Istr 1 128 ansf &quot;(binary 7)&quot;

//---------------------------------&lt; AGI &gt;-----------------------------------//
//! external ObjectMerger w3a AIa1 A8A0 anam &quot;Bonus Agility&quot; Iagi 1 1   ansf &quot;(binary 0)&quot;
//! external ObjectMerger w3a AIa1 A8A1 anam &quot;Bonus Agility&quot; Iagi 1 2   ansf &quot;(binary 1)&quot;
//! external ObjectMerger w3a AIa1 A8A2 anam &quot;Bonus Agility&quot; Iagi 1 4   ansf &quot;(binary 2)&quot;
//! external ObjectMerger w3a AIa1 A8A3 anam &quot;Bonus Agility&quot; Iagi 1 8   ansf &quot;(binary 3)&quot;
//! external ObjectMerger w3a AIa1 A8A4 anam &quot;Bonus Agility&quot; Iagi 1 16  ansf &quot;(binary 4)&quot;
//! external ObjectMerger w3a AIa1 A8A5 anam &quot;Bonus Agility&quot; Iagi 1 32  ansf &quot;(binary 5)&quot;
//! external ObjectMerger w3a AIa1 A8A6 anam &quot;Bonus Agility&quot; Iagi 1 64  ansf &quot;(binary 6)&quot;
//! external ObjectMerger w3a AIa1 A8A7 anam &quot;Bonus Agility&quot; Iagi 1 128 ansf &quot;(binary 7)&quot;

//---------------------------------&lt; INT &gt;-----------------------------------//
//! external ObjectMerger w3a AIi1 A8I0 anam &quot;Bonus Intelligence&quot; Iint 1 1   ansf &quot;(binary 0)&quot;
//! external ObjectMerger w3a AIi1 A8I1 anam &quot;Bonus Intelligence&quot; Iint 1 2   ansf &quot;(binary 1)&quot;
//! external ObjectMerger w3a AIi1 A8I2 anam &quot;Bonus Intelligence&quot; Iint 1 4   ansf &quot;(binary 2)&quot;
//! external ObjectMerger w3a AIi1 A8I3 anam &quot;Bonus Intelligence&quot; Iint 1 8   ansf &quot;(binary 3)&quot;
//! external ObjectMerger w3a AIi1 A8I4 anam &quot;Bonus Intelligence&quot; Iint 1 16  ansf &quot;(binary 4)&quot;
//! external ObjectMerger w3a AIi1 A8I5 anam &quot;Bonus Intelligence&quot; Iint 1 32  ansf &quot;(binary 5)&quot;
//! external ObjectMerger w3a AIi1 A8I6 anam &quot;Bonus Intelligence&quot; Iint 1 64  ansf &quot;(binary 6)&quot;
//! external ObjectMerger w3a AIi1 A8I7 anam &quot;Bonus Intelligence&quot; Iint 1 128 ansf &quot;(binary 7)&quot;

//==============================================================================


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
//==============================================================================

//---------------------------------&lt; ATTS &gt;----------------------------------//
//! external ObjectMerger w3a AIsx A8H0 anam &quot;Bonus Attack Speed&quot; Isx1 1 0.05 ansf &quot;(binary 0)&quot;
//! external ObjectMerger w3a AIsx A8H1 anam &quot;Bonus Attack Speed&quot; Isx1 1 0.10 ansf &quot;(binary 1)&quot;
//! external ObjectMerger w3a AIsx A8H2 anam &quot;Bonus Attack Speed&quot; Isx1 1 0.20 ansf &quot;(binary 2)&quot;
//! external ObjectMerger w3a AIsx A8H3 anam &quot;Bonus Attack Speed&quot; Isx1 1 0.40 ansf &quot;(binary 3)&quot;
//! external ObjectMerger w3a AIsx A8H4 anam &quot;Bonus Attack Speed&quot; Isx1 1 0.80 ansf &quot;(binary 4)&quot;
//! external ObjectMerger w3a AIsx A8H5 anam &quot;Bonus Attack Speed&quot; Isx1 1 1.60 ansf &quot;(binary 5)&quot;
//! external ObjectMerger w3a AIsx A8H6 anam &quot;Bonus Attack Speed&quot; Isx1 1 3.20 ansf &quot;(binary 6)&quot;

//---------------------------------&lt; MOVE &gt;----------------------------------//
//! external ObjectMerger w3a AIms A8P1 anam &quot;Bonus Move Speed&quot; Imvb 1 10  ansf &quot;(linear 1)&quot;
//! external ObjectMerger w3a AIms A8P2 anam &quot;Bonus Move Speed&quot; Imvb 1 20  ansf &quot;(linear 2)&quot;
//! external ObjectMerger w3a AIms A8P3 anam &quot;Bonus Move Speed&quot; Imvb 1 30  ansf &quot;(linear 3)&quot;
//! external ObjectMerger w3a AIms A8P4 anam &quot;Bonus Move Speed&quot; Imvb 1 40  ansf &quot;(linear 4)&quot;
//! external ObjectMerger w3a AIms A8P5 anam &quot;Bonus Move Speed&quot; Imvb 1 50  ansf &quot;(linear 5)&quot;
//! external ObjectMerger w3a AIms A8P6 anam &quot;Bonus Move Speed&quot; Imvb 1 60  ansf &quot;(linear 6)&quot;
//! external ObjectMerger w3a AIms A8P7 anam &quot;Bonus Move Speed&quot; Imvb 1 70  ansf &quot;(linear 7)&quot;
//! external ObjectMerger w3a AIms A8P8 anam &quot;Bonus Move Speed&quot; Imvb 1 80  ansf &quot;(linear 8)&quot;
//! external ObjectMerger w3a AIms A8P9 anam &quot;Bonus Move Speed&quot; Imvb 1 90  ansf &quot;(linear 9)&quot;
//! external ObjectMerger w3a AIms A8P: anam &quot;Bonus Move Speed&quot; Imvb 1 100 ansf &quot;(linear <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />&quot;

//==============================================================================


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
//==============================================================================

//---------------------------------&lt; EVASION &gt;-------------------------------//
//! external ObjectMerger w3a AIev A8e1 anam &quot;Bonus Evasion&quot; Eev1 1 0.05 ansf &quot;(linear 1)&quot;
//! external ObjectMerger w3a AIev A8e2 anam &quot;Bonus Evasion&quot; Eev1 1 0.10 ansf &quot;(linear 2)&quot;
//! external ObjectMerger w3a AIev A8e3 anam &quot;Bonus Evasion&quot; Eev1 1 0.15 ansf &quot;(linear 3)&quot;
//! external ObjectMerger w3a AIev A8e4 anam &quot;Bonus Evasion&quot; Eev1 1 0.20 ansf &quot;(linear 4)&quot;
//! external ObjectMerger w3a AIev A8e5 anam &quot;Bonus Evasion&quot; Eev1 1 0.25 ansf &quot;(linear 5)&quot;
//! external ObjectMerger w3a AIev A8e6 anam &quot;Bonus Evasion&quot; Eev1 1 0.30 ansf &quot;(linear 6)&quot;
//! external ObjectMerger w3a AIev A8e7 anam &quot;Bonus Evasion&quot; Eev1 1 0.35 ansf &quot;(linear 7)&quot;
//! external ObjectMerger w3a AIev A8e8 anam &quot;Bonus Evasion&quot; Eev1 1 0.40 ansf &quot;(linear 8)&quot;
//-- spellbook
//! external ObjectMerger w3a Aspb A8E1 anam &quot;Bonus Evasion&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e1 ansf &quot;(spellbook 1)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNEvasion.blp&quot;
//! external ObjectMerger w3a Aspb A8E2 anam &quot;Bonus Evasion&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e2 ansf &quot;(spellbook 2)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNEvasion.blp&quot;
//! external ObjectMerger w3a Aspb A8E3 anam &quot;Bonus Evasion&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e3 ansf &quot;(spellbook 3)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNEvasion.blp&quot;
//! external ObjectMerger w3a Aspb A8E4 anam &quot;Bonus Evasion&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e4 ansf &quot;(spellbook 4)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNEvasion.blp&quot;
//! external ObjectMerger w3a Aspb A8E5 anam &quot;Bonus Evasion&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e5 ansf &quot;(spellbook 5)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNEvasion.blp&quot;
//! external ObjectMerger w3a Aspb A8E6 anam &quot;Bonus Evasion&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e6 ansf &quot;(spellbook 6)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNEvasion.blp&quot;
//! external ObjectMerger w3a Aspb A8E7 anam &quot;Bonus Evasion&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e7 ansf &quot;(spellbook 7)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNEvasion.blp&quot;
//! external ObjectMerger w3a Aspb A8E8 anam &quot;Bonus Evasion&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8e8 ansf &quot;(spellbook 8)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNEvasion.blp&quot;

//---------------------------------&lt; CRITICAL &gt;-------------------------------//
//! external ObjectMerger w3a AIcs A8c1 anam &quot;Bonus Critical&quot; Ocr1 1 5  ansf &quot;(linear 1)&quot;
//! external ObjectMerger w3a AIcs A8c2 anam &quot;Bonus Critical&quot; Ocr1 1 10 ansf &quot;(linear 2)&quot;
//! external ObjectMerger w3a AIcs A8c3 anam &quot;Bonus Critical&quot; Ocr1 1 15 ansf &quot;(linear 3)&quot;
//! external ObjectMerger w3a AIcs A8c4 anam &quot;Bonus Critical&quot; Ocr1 1 20 ansf &quot;(linear 4)&quot;
//! external ObjectMerger w3a AIcs A8c5 anam &quot;Bonus Critical&quot; Ocr1 1 25 ansf &quot;(linear 5)&quot;
//! external ObjectMerger w3a AIcs A8c6 anam &quot;Bonus Critical&quot; Ocr1 1 30 ansf &quot;(linear 6)&quot;
//! external ObjectMerger w3a AIcs A8c7 anam &quot;Bonus Critical&quot; Ocr1 1 35 ansf &quot;(linear 7)&quot;
//! external ObjectMerger w3a AIcs A8c8 anam &quot;Bonus Critical&quot; Ocr1 1 40 ansf &quot;(linear 8)&quot;
//-- spellbook
//! external ObjectMerger w3a Aspb A8C1 anam &quot;Bonus Critical&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c1 ansf &quot;(spellbook 1)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp&quot;
//! external ObjectMerger w3a Aspb A8C2 anam &quot;Bonus Critical&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c2 ansf &quot;(spellbook 2)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp&quot;
//! external ObjectMerger w3a Aspb A8C3 anam &quot;Bonus Critical&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c3 ansf &quot;(spellbook 3)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp&quot;
//! external ObjectMerger w3a Aspb A8C4 anam &quot;Bonus Critical&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c4 ansf &quot;(spellbook 4)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp&quot;
//! external ObjectMerger w3a Aspb A8C5 anam &quot;Bonus Critical&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c5 ansf &quot;(spellbook 5)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp&quot;
//! external ObjectMerger w3a Aspb A8C6 anam &quot;Bonus Critical&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c6 ansf &quot;(spellbook 6)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp&quot;
//! external ObjectMerger w3a Aspb A8C7 anam &quot;Bonus Critical&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c7 ansf &quot;(spellbook 7)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp&quot;
//! external ObjectMerger w3a Aspb A8C8 anam &quot;Bonus Critical&quot; spb5 1 &quot;attributemodskill&quot; spb4 1 1 spb3 1 1 spb2 1 True spb1 1 A8c8 ansf &quot;(spellbook 8)&quot; aart &quot;ReplaceableTextures\CommandButtons\BTNCriticalStrike.blp&quot;

//==============================================================================
 

Attachments

  • Bonus_v1.3.w3x
    32.6 KB · Views: 737

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
@Trollvotel: That script is out of date on wc3c. It doesn't work that well anymore I think.
 

Builder Bob

Live free or don't
Reaction score
249
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?
 

Builder Bob

Live free or don't
Reaction score
249
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?

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.
 

Cohadar

master of fugue
Reaction score
209
attachment.php
 

Attachments

  • filedcodes.png
    filedcodes.png
    5.3 KB · Views: 3,074

Builder Bob

Live free or don't
Reaction score
249
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!
 

Cohadar

master of fugue
Reaction score
209
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)
 

Builder Bob

Live free or don't
Reaction score
249
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)"
 

Gamat

New Member
Reaction score
1
I'm having problems to run the test map without errors, i use normal we i need anything more?
 

Cohadar

master of fugue
Reaction score
209
I'm having problems to run the test map without errors, i use normal we i need anything more?

You need NewGen

//=============================
Version 1.2 - you can now write plugins
//=============================
 

Builder Bob

Live free or don't
Reaction score
249
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
 

Cohadar

master of fugue
Reaction score
209
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
 

Builder Bob

Live free or don't
Reaction score
249
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.

Yup, I'm using a linear bonus until you find a better way.
 

Grundy

Ultra Cool Member
Reaction score
35
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?
 

saw792

Is known to say things. That is all.
Reaction score
280
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).
 

Hatebreeder

So many apples
Reaction score
381
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

Isn't there an "SetUnitMoveSpeed(Unit,Speed)" function?
Wouldn't it be easier to use that?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top