+20% Strenght/Agility bonus AURA

jarekpl12

TH.net Regular
Reaction score
6
Hello... I got problem. I'm trying to make aura which adds 20% of BASE amount strenght and agility. When any hero recive aura's buff then let it add 20% strenght/agility and when aura's buff disappear then let it back to normal value i mean to value which had hero when he was reciving aura' buff. I made something like this but it's totaly failed. Can somone help me with this ability? thx

Trigger:
  • Strenght of Earth aura
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set StrenghtOfEarthGroup = (Units in (Playable map area) matching ((((Matching unit) has buff Strenght of Earth Totem (aura)) Equal to True) and ((((Matching unit) is in CheckGroup) Equal to False) and (((Matching unit) is Bohater) Equal to True))))
      • Unit Group - Pick every unit in StrenghtOfEarthGroup and do (Actions)
        • Loop - Actions
          • Set Strenght = ((Strenght of (Picked unit) (Exclude bonuses)) / 5)
          • Set Agility = ((Agility of (Picked unit) (Exclude bonuses)) / 5)
          • Hero - Modify Strenght of (Picked unit): Add Strenght
          • Hero - Modify Agility of (Picked unit): Add Agility
          • Unit Group - Add (Picked unit) to CheckGroup
      • Unit Group - Pick every unit in CheckGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Strenght of Earth Totem (aura)) Equal to False
            • Then - Actions
              • Hero - Modify Strenght of (Picked unit): Subtract Strenght
              • Hero - Modify Agility of (Picked unit): Subtract Agility
              • Unit Group - Remove (Picked unit) from CheckGroup
            • Else - Actions
      • Custom script: call DestroyGroup (udg_StrenghtOfEarthGroup)
 

canons200

New Member
Reaction score
50
i think the better way is to add those hero to unitgroup, then check is those unitgroup is in the unitgroup using the condition, next only add stat.

so when those unit has no aura, then remove those unit from the unitgroup and then continue subtract stat.
 

Nherwyziant

Be better than you were yesterday :D
Reaction score
96
Use real for agi and str instead of integer, since diving or multiplying an integer with a decimal will result 0.

Do this

Trigger:
  • Actions
    • Set Strength[(Player number of (Owner of (Picked unit)))] = ((Real((Strength of (Picked unit) (Exclude bonuses)))) / 5.00)
    • Set Agility[(Player number of (Owner of (Picked unit)))] = ((Real((Agility of (Picked unit) (Exclude bonuses)))) / 5.00)
    • -------- set them real and add arrays. --------
    • Hero - Modify Strength of (Picked unit): Add (Integer(Strength[(Player number of (Owner of (Picked unit)))]))
    • Hero - Modify Strength of (Picked unit): Add (Integer(Agility[(Player number of (Owner of (Picked unit)))]))
    • -------- - --------
    • Hero - Modify Strength of (Picked unit): Subtract (Integer(Strength[(Player number of (Owner of (Picked unit)))]))
    • Hero - Modify Strength of (Picked unit): Subtract (Integer(Agility[(Player number of (Owner of (Picked unit)))]))


anyways...

This will bug if you have multiple hero on 1 player and when the hero leveled up, example:

The hero is lvl 5, has 50 str, agi

Gains the buff, so it has 60 str, and agi,

when the hero level up, let's say 5 bonus stats, so it has 65, and when the hero leaves the aura, removing the buff, it will return 52(should be 55)
 

Nexor

...
Reaction score
74
I don't know if you can use vJASS at all, but I created the spell for you, you can set the period, the buff's id and the percentage of increase.
Here ya go:

Needs AIDS too

JASS:
scope Aura initializer onInit

globals
    private constant integer        AuraBuffID      = 'B000' // Use Ctrl + D at object editor to see the IDs of the abilities and buffs
    private constant real           Period          = 3.      // How many seconds should pass between each check
    private constant real           Percentage      = 20.     // This means 20%
    
    private group StrengthOfEarthGroup               = CreateGroup()
endglobals

private function StatIncrease takes unit u,integer stat returns integer
    return R2I( GetHeroStatBJ(stat,u,false) * Percentage / 100)
endfunction

private struct aura
    unit hero
    integer stat_agi
    integer stat_str
    
    static method create takes unit u returns thistype
        local thistype this = thistype.allocate()
        set .hero = u
        return this
    endmethod
    //! runtextmacro PUI()
endstruct

private function Conditions takes nothing returns boolean
    return IsUnitType(GetFilterUnit(),UNIT_TYPE_HERO) == true and GetUnitAbilityLevel(GetFilterUnit(),AuraBuffID) > 0
endfunction

private function Actions takes nothing returns nothing
    local group g = CreateGroup()
    local unit f
    
    call GroupEnumUnitsInRect(StrengthOfEarthGroup,GetWorldBounds(),Condition(function Conditions))
    set g = StrengthOfEarthGroup
    
    loop
        set f = FirstOfGroup(g)
        exitwhen f == null
        if aura(aura[f]) == 0 then
            call aura(aura[f]).create(f)
        endif
        call SetHeroAgi(f,GetHeroAgi(f,false)-aura(aura[f]).stat_agi,false)
        call SetHeroStr(f,GetHeroStr(f,false)-aura(aura[f]).stat_str,false)
        call GroupRemoveUnit(g,f)
        call GroupRemoveUnit(StrengthOfEarthGroup,f)
    endloop
    
    call GroupEnumUnitsInRect(StrengthOfEarthGroup,GetWorldBounds(),Condition(function Conditions))
    
    set g = StrengthOfEarthGroup
    
    loop
        set f = FirstOfGroup(g)
        exitwhen f == null
        if aura(aura[f]) == 0 then
            call aura(aura[f]).create(f)
        endif
        set aura(aura[f]).stat_agi = StatIncrease(f,bj_HEROSTAT_AGI)
        set aura(aura[f]).stat_str = StatIncrease(f,bj_HEROSTAT_STR)
        call SetHeroAgi(f,GetHeroAgi(f,false)+StatIncrease(f,bj_HEROSTAT_AGI),false)
        call SetHeroStr(f,GetHeroStr(f,false)+StatIncrease(f,bj_HEROSTAT_STR),false)
        call GroupRemoveUnit(g,f)
    endloop
    
    call DestroyGroup(g)
    set g = null
    set f = null
endfunction

//===========================================================================
private function onInit takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterTimerEvent(t,Period,true)
    call TriggerAddAction( t, function Actions )
endfunction

endscope
 

Ayanami

칼리
Reaction score
288
It's quite easy actually with the use of hashtables. Create a variable called SoEHashtable and set it at map init. Here's the trigger.

Trigger:
  • Map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set SoEHashtable = (Last created hashtable)


Trigger:
  • Strenght of Earth aura
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set StrenghtOfEarthGroup = (Units in (Playable map area) matching ((((Matching unit) has buff Strength of Earth Totem (aura)) Equal to True) and ((((Matching unit) is in CheckGroup) Equal to False) and (((Matching unit) is Bohater) Equal to True))))
      • Unit Group - Pick every unit in StrengthOfEarthGroup and do (Actions)
        • Loop - Actions
          • Set TempInt = ((Strength of (Picked unit) (Exclude bonuses)) / 5)
          • Custom script: call SaveInteger( udg_SoEHashtable, StringHash("str"), GetHandleId(GetEnumUnit(), udg_TempInt)
          • Hero - Modify Strength of (Picked unit): Add TempInt
          • Set TempInt = ((Agility of (Picked unit) (Exclude bonuses)) / 5)
          • Custom script: call SaveInteger( udg_SoEHashtable, StringHash("agi"), GetHandleId(GetEnumUnit(), udg_TempInt)
          • Hero - Modify Agility of (Picked unit): Add TempInt
          • Unit Group - Add (Picked unit) to CheckGroup
      • Unit Group - Pick every unit in CheckGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff Strength of Earth Totem (aura)) Equal to False
            • Then - Actions
              • Custom script: set udg_TempInt = LoadInteger(udg_SoEHashtable, StringHash("str"), GetHandleId(GetEnumUnit()))
              • Set Strength = ((Strength of (Picked unit) (Exclude bonuses)) - TempInt) / 5)
              • Set TempInt = (((Strength of (Picked unit) (Exclude bonuses)) - TempInt) + Strength)
              • Hero - Modify Strength of (Picked unit): Set to TempInt
              • Custom script: set udg_TempInt = LoadInteger(udg_SoEHashtable, StringHash("agi"), GetHandleId(GetEnumUnit()))
              • Set Agility = ((Agility of (Picked unit) (Exclude bonuses)) - TempInt) / 5)
              • Set TempInt = (((Agilty of (Picked unit) (Exclude bonuses)) - TempInt) + Agility)
              • Hero - Modify Agility of (Picked unit): Set to TempInt
              • Custom script: call SaveInteger( udg_SoEHashtable, StringHash("str"), GetHandleId(GetEnumUnit(), udg_Strength)
              • Custom script: call SaveInteger( udg_SoEHashtable, StringHash(agi"), GetHandleId(GetEnumUnit(), udg_Agility)
            • Else - Actions
              • Custom script: set udg_TempInt = LoadInteger(udg_SoEHashtable, StringHash("str"), GetHandleId(GetEnumUnit()))
              • Set TempInt = ((Strength of (Picked unit) (Exclude bonuses)) - TempInt)
              • Hero - Modify Strength of (Picked unit): Set to TempInt
              • Custom script: set udg_TempInt = LoadInteger(udg_SoEHashtable, StringHash("agi"), GetHandleId(GetEnumUnit()))
              • Set TempInt = ((Agility of (Picked unit) (Exclude bonuses)) - TempInt)
              • Hero - Modify Agility of (Picked unit): Set to TempInt
              • Unit Group - Remove (Picked unit) from CheckGroup
      • Custom script: call DestroyGroup (udg_StrenghtOfEarthGroup)
 

jarekpl12

TH.net Regular
Reaction score
6
something is wrong with:

Trigger:
  • Custom script: call SaveInteger( udg_SoEHashtable, StringHash("str"), GetHandleId(GetEnumUnit(), udg_TempInt)


Script errors: Wrong arguments count

Trigger:
  • Custom script: call SaveInteger( udg_SoEHashtable, StringHash("str"), GetHandleId(GetEnumUnit(), udg_Strength)


Trigger:
  • Custom script: call SaveInteger( udg_SoEHashtable, StringHash(agi"), GetHandleId(GetEnumUnit(), udg_Agility)


Script errors: Name Expect
 

Ayanami

칼리
Reaction score
288
What version are you using? Did you ensure your hashtable variable is named exactly "SoEHashtable"?
 

Ayanami

칼리
Reaction score
288
Add an extra ) at the end of each custom script that's wrong.

Oh, finally spotted that. Here's the correct version. The red part is the part you need to add.

Code:
Custom script: call SaveInteger( udg_SoEHashtable, StringHash("str"), GetHandleId(GetEnumUnit()[COLOR="Red"][B])[/B][/COLOR], udg_TempInt)

Code:
Custom script: call SaveInteger( udg_SoEHashtable, StringHash("str"), GetHandleId(GetEnumUnit()[COLOR="Red"][B])[/B][/COLOR], udg_Strength)

Code:
Custom script: call SaveInteger( udg_SoEHashtable, StringHash(agi"), GetHandleId(GetEnumUnit()[COLOR="Red"][B])[/B][/COLOR], udg_Agility)
 

LotK

Member
Reaction score
8
will this still work correctly, if you level up and get strength under the effect of the aura?

im worried that you get some less, when you leave it

eg: you got 100 str
with the aura you got 120
you level up and get 120 (base) strenght, with aura 144
when you leave it, you get 20% reduced strength.. in that case 115,2

is it like that, or is it really 'save'?
 

Ayanami

칼리
Reaction score
288
will this still work correctly, if you level up and get strength under the effect of the aura?

im worried that you get some less, when you leave it

eg: you got 100 str
with the aura you got 120
you level up and get 120 (base) strenght, with aura 144
when you leave it, you get 20% reduced strength.. in that case 115,2

is it like that, or is it really 'save'?

It returns the original value. So in your case, it will return back to 120 strength, not 115.2.
 

jarekpl12

TH.net Regular
Reaction score
6
Oh, finally spotted that. Here's the correct version. The red part is the part you need to add.

Code:
Custom script: call SaveInteger( udg_SoEHashtable, StringHash("str"), GetHandleId(GetEnumUnit()[COLOR="Red"][B])[/B][/COLOR], udg_Strength)

Code:
Custom script: call SaveInteger( udg_SoEHashtable, StringHash(agi"), GetHandleId(GetEnumUnit()[COLOR="Red"][B])[/B][/COLOR], udg_Agility)


still something wrong with Str and Agi custom script...
 

Nexor

...
Reaction score
74
Using my solution hurts your eyes ? :O

It's configurable, if you need some other things to the ability, please let me know.

ps: it uses the system called AIDS
 
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