Hey there.
In the ORPG I'm working on players can increase their mana regeneration with a custom stat. This stat is called 'Wisdom'.
With some math I made 2 formula's to calculate the mana regeneration bonus a unit should get from a specific amount of Wisdom, however the higher the level of the unit, the more Wisdom he will need for the same amount of mana regeneration increasement.
If the unit is under level 11 then he will use this formula:
Bonus (in %) = (( Wisdom / (1+(HeroLevel*0.13)))*4) / 100
If the unit is above level 10 then he will use this formula:
Bonus (in %) = (Wisdom / (16*(HeroLevel - 6)/150)) / 100
I'm using a binair system in my map that adds this mana regeneration with the help of this function: call UnitModifyManaRegenPercent(Unit,Amount)
If the amount is negative it will (obviously) reduce the mana regeneration of that unit.
Now for some reason I can't get this to work in my map.
This is what I've got to test:
In the ORPG I'm working on players can increase their mana regeneration with a custom stat. This stat is called 'Wisdom'.
With some math I made 2 formula's to calculate the mana regeneration bonus a unit should get from a specific amount of Wisdom, however the higher the level of the unit, the more Wisdom he will need for the same amount of mana regeneration increasement.
If the unit is under level 11 then he will use this formula:
Bonus (in %) = (( Wisdom / (1+(HeroLevel*0.13)))*4) / 100
If the unit is above level 10 then he will use this formula:
Bonus (in %) = (Wisdom / (16*(HeroLevel - 6)/150)) / 100
I'm using a binair system in my map that adds this mana regeneration with the help of this function: call UnitModifyManaRegenPercent(Unit,Amount)
If the amount is negative it will (obviously) reduce the mana regeneration of that unit.
Now for some reason I can't get this to work in my map.
This is what I've got to test:
JASS:
scope MapInit initializer Init
function Wisdom takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
local unit u = PlayerHero[i]
local integer int = S2I(SubString(GetEventPlayerChatString(),8,StringLength(GetEventPlayerChatString())))
///PlayerEnergyReg[] is a real, PlayerWisdom[] is an integer///
call UnitModifyManaRegenPercent(u,-PlayerEnergyReg[i]) ///Setting the reg to 0
set PlayerWisdom[i] = int
if GetHeroLevel(u) < 11 then
set PlayerEnergyReg[i] = ((PlayerWisdom[i]/(1+(GetHeroLevel(u)*0.13)))*4)/100
else
set PlayerEnergyReg[i] = (PlayerWisdom[i]/(16*(GetHeroLevel(u)-6)/150))/100
endif
call UnitModifyManaRegenPercent(u,PlayerEnergyReg[i]) ///Should set the reg to a value, but currently it looks like it stays at 0
endfunction
function Init takes nothing returns nothing
local trigger Trig
local integer i = 0
loop
exitwhen i > GetPlayers()
set Trig = CreateTrigger()
call TriggerRegisterPlayerChatEvent(Trig,Player(i),"-Wisdom ", false)
call TriggerAddAction(Trig,function Wisdom)
endloop
set Trig = null
endfunction
endscope