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
    set Damage = BinaryBonus.create('A8T0', 12, 5)

    (0,1,2,...11) = 12 total
     
  2. Gwypaas

    Gwypaas hook DoNothing MakeGUIUsersCrash

    Ratings:
    +50 / 0 / -0
    I know, I forgot to edit that part, it goes to 11 or 12 in my test map :p



    Solved: I did like this:
    JASS:
    //! external ObjectMerger w3a AItg A8T8 anam "Bonus Damage" Iatt 1 1280 ansf "(binary 8)"
    //! external ObjectMerger w3a AItg A8T9 anam "Bonus Damage" Iatt 1 2560 ansf "(binary 9)"
    //! external ObjectMerger w3a AItg A8T: anam "Bonus Damage" Iatt 1 5120 ansf "(binary :)"
    //! external ObjectMerger w3a AItg A8T; anam "Bonus Damage" Iatt 1 10240 ansf "(binary ;)"
    //! external ObjectMerger w3a AItg A8T< anam "Bonus Damage" Iatt 1 20480 ansf "(binary <)"
    JASS:
    set Damage = BinaryBonus.create('A8T0', 13, 5)


    and now it works up to 40955 extra damage :)


    I think this works because now I only continue on the Latin_1 codes instead of jumping ~40 "slots" to come to 'a'.
     
  3. lucifekit

    lucifekit New Member

    Ratings:
    +2 / 0 / -0
    Maybe it's not good enough to make a increase max life aura.>.<

    Can you teach me how to make a increase max life aura :)
     
  4. Kenny

    Kenny Back for now.

    Ratings:
    +202 / 0 / -0
    I havent read through it all, but this definately seems capable of making such an aura.

    Base it off an already existing aura (maybe brilliance aura), then every every X seconds check for units with that aura, or unit within X distance of the aura unit, if the units have the buff or are in range, then add the max life ability to them, else remove the ability.
     
  5. Romek

    Romek Super Moderator Staff Member

    Ratings:
    +961 / 0 / -0
    Or you could just use UAC (see my sig), and add the bonus in the UnitEnter method, and remove it in the UnitLeave method. :)
     
  6. waaaks!

    waaaks! Zinctified

    Ratings:
    +256 / 0 / -0
    is there any built in function that removes bonuses?
    or if there is none, then how could i remove these bonuses?
     
  7. Romek

    Romek Super Moderator Staff Member

    Ratings:
    +961 / 0 / -0
    I'd guess doing "set Bonus_Blah = 0" would remove all the bonuses from that unit.
     
  8. waaaks!

    waaaks! Zinctified

    Ratings:
    +256 / 0 / -0
    ok ill try, thanks
     
  9. Rommel

    Rommel New Member

    Ratings:
    +13 / 0 / -0
    cool, this could help me alot, thanks :thup:
     
  10. Faust

    Faust You can change this now in User CP.

    Ratings:
    +123 / 0 / -0
    The method of that is to give your unit in the object editor some wicked long range, then in the editor or in the game, set Acquisition Range to your liking.

    This is the closest you can get.

    As for the system... looks badass at first sight of the comments. I'll definitely look into it deeper, later.
     
  11. TwoHeadedBoy

    TwoHeadedBoy New Member

    Ratings:
    +6 / 0 / -0
    Do abilities with 100 levels really take up that much memory/cause lag/load slowly?
     
  12. Cohadar

    Cohadar master of fugue

    Ratings:
    +209 / 0 / -0
    Yes.
    Ability with 100 levels is like 100 1-level abilities.
    And I mean this literally, wc3 does not do any optimization for multilevel abilities, they are basically a 1-level abilities stored in the record one after another.

    TRY:
    make an empty map,
    put one unit in the middle,
    make some 100-level ability,
    give that ability to the preplaced unit,
    see how long it takes for map to load.
     
  13. TwoHeadedBoy

    TwoHeadedBoy New Member

    Ratings:
    +6 / 0 / -0
    Well you certainly have me convinced. The map without took 5 seconds to load, the map with 4, 100 lv abilities: armor, damage, life and mana, took 20 seconds to load.

    Now the problem is that I dont understand JASS :(
     
  14. Rommel

    Rommel New Member

    Ratings:
    +13 / 0 / -0
    Wa...so useful information :D ...I've been working with WE over 4 years but i have just known this, How can you know so much, Cohadar ? :D
     
  15. Steel

    Steel Software Engineer

    Ratings:
    +109 / 0 / -0
    You need to rework how your system handles Life and Mana because it shouldn't have a limitation based on the abilities you feed into the system.

    There is an older system on Wc3c that I've used for a while

    JASS:
    constant function MaxStateModifierId takes unitstate u returns integer
        if u == UNIT_STATE_MAX_LIFE then
            return 'A007' // Rawcode of the Max Life Modifier ability.
        elseif u == UNIT_STATE_MAX_MANA then
            return 'A008' // Rawcode of the Max Mana Modifier ability.
        endif
        return 0
    endfunction
    function SetUnitMaxState takes unit whichUnit, unitstate whichUnitState, integer newVal returns boolean
        local integer c = newVal-R2I(GetUnitState(whichUnit, whichUnitState))
        local integer i = MaxStateModifierId(whichUnitState)
        if i == 0 then
            return false
        endif
        if c > 0 then
            loop
                exitwhen c == 0
                call UnitAddAbility(whichUnit, i)
                if c >= 100 then
                    set c = c - 100
                    call SetUnitAbilityLevel(whichUnit, i, 4)
                elseif c >= 10 then
                    set c = c - 10
                    call SetUnitAbilityLevel(whichUnit, i, 3)
                else
                    set c = c - 1
                    call SetUnitAbilityLevel(whichUnit, i, 2)
                endif
                call UnitRemoveAbility(whichUnit, i)
            endloop
        elseif c < 0 then
            set c = -c
            loop
                exitwhen c == 0
                call UnitAddAbility(whichUnit, i)
                if c >= 100 then
                    set c = c - 100
                    call SetUnitAbilityLevel(whichUnit, i, 7)
                elseif c >= 10 then
                    set c = c - 10
                    call SetUnitAbilityLevel(whichUnit, i, 6)
                else
                    set c = c - 1
                    call SetUnitAbilityLevel(whichUnit, i, 5)
                endif
                call UnitRemoveAbility(whichUnit, i)
            endloop
        endif
        return true
    endfunction


    With this you can have the system add 100,000 Life or Mana if you wanted to with just 1 ability and 3 levels.

    Also, the simple convention of a getter function is nicer than having to use your already existing overload functions, call me old fashion, but I find it more user friendly.

    Bonus_Life[<unit>] does return the value, but I like a getBonus("Life", u) better myself.

    Finally, I don't like the inability to Bonus_Life[<unit>] - 40 to simply subtract 40 hitpoints. You have to do the round about way of set Bonus_Life[<unit>] = Bonus_Life[<unit>] - 40. This is annoying as hell for something so simple.
     
  16. Cohadar

    Cohadar master of fugue

    Ratings:
    +209 / 0 / -0
    That Life and Mana modification depends on a blizzards bug.
    I won't make my system bug dependent because you never know when it might get fixed.

    Simply make some BJ function for yourself:
    JASS:
    
    public function AddLife takes unit whichUnit, real lifeDiff returns nothing
        set Bonus_Life[whichUnit] = Bonus_Life[whichUnit] + lifeDiff
    endfunction
     
  17. Steel

    Steel Software Engineer

    Ratings:
    +109 / 0 / -0
    Don't worry I did, but I will still depend on the "bug" to function properly for Life and Mana adjustments :p
     
  18. prismpirate

    prismpirate New Member

    Ratings:
    +2 / 0 / -0
    Could anyone instruct me on how to implement this in GUI?

    Update: This is what I have so far. Jasshelper hangs when I save it, so I know something is wrong. Can anyone tell me where I have gone wrong?
    Trigger:
    • Testing
      • Events
        • Unit - A unit Learns a skill
      • Conditions
        • (Learned Hero Skill) Equal to (==) Rock Slide (Troll)
      • Actions
        • Set TempInteger = (Learned skill level)
        • Set Temp_Unit = (Triggering unit)
        • Custom script: set Bonus_Life[GetUnitIndex(Temp_Unit)] = TempInteger
     
  19. Jesus4Lyf

    Jesus4Lyf Good Idea™

    Ratings:
    +394 / 0 / -0
    set Bonus_Life[GetUnitIndex(udg_Temp_Unit)] = udg_TempInteger

    Add udg_

    Don't see why it would hang over that, though... <_<
     
  20. LilBlueSmurf

    LilBlueSmurf New Member

    Ratings:
    +0 / 0 / -0
    This is a great system. I have a couple questions and requests though.

    1. (I didn't delve in the code) Is there a limit to 8 tiers, or can more be added?

    2. Would mana regen and life regen be possible to affect with this? I have no clue if they would stack or not either.

    If the answer to both of those is yes, can someone start me off on the mana and life regen skill lines needed? I can fill all the stuff in, but level 1 (or 0) for each would be appreciated.

    I know some jazz, but I'm back after many many years away so I'm quite rusty. That also makes looking up specific abilities that would have the right stat a big chore, while I figure people here probably would know right off hand.

    Thanks.
     

Share This Page