I cant figure out why this thread is crashing.. Most likely its because of a squareroot(negative) but I'm unable to locate it
yes i know i need to switch to Nestharus's DDS, ill get to it when i get to it.
crit
damage detector
JASS:
library crit initializer Init
globals
private hashtable critHash = InitHashtable()
private real ExternalFactorRate = 20
private real ExternalFactorPower = 200
private real InternalFactorRate = 20
private real InternalFactorPower = 20
private real SubtractionFactorRate = 25
private real SubtractionFactorPower = 25
endglobals
function registerCritRate takes item i, real critRate returns nothing
call SaveReal(critHash, GetItemTypeId(i), 0, critRate)
endfunction
function registerCritPow takes item i, real critPow returns nothing
call SaveReal(critHash, GetItemTypeId(i), 1, critPow)
endfunction
function getCritRate takes unit u returns real
local boolean test = SubtractionFactorRate > GetHeroInt(u, true)
local real rate
local real r = 0
local integer i = 0
if test then
set rate = 0
// set rate = (ExternalFactorRate * SquareRoot((1/(GetHeroLevel(u) + InternalFactorRate)) * SquareRoot(GetHeroInt(u, true) - SubtractionFactorRate)))
else
set rate = 0
endif
if u == udg_PlayerUnit[GetConvertedPlayerId(GetOwningPlayer(u))] then
loop
exitwhen i == 10
set r = 100 - rate
set r = ModuloReal(r, LoadReal(critHash, GetEquippedItemTypeId(GetOwningPlayer(u), i), 0))
set rate = rate + r
set r = 0
set i = i + 1
call print(R2S(r))
call print(R2S(rate))
endloop
endif
return rate
endfunction
function getCritPow takes unit u returns real
local boolean test = SubtractionFactorPower > GetHeroAgi(u, true)
local real rate
local real r = 0
local integer i = 0
if test then
set rate = -0
// set rate = (ExternalFactorPower * SquareRoot((1/(GetHeroLevel(u) + InternalFactorPower)) * SquareRoot(GetHeroAgi(u, true) - SubtractionFactorPower)))
else
set rate = 0
endif
if u == udg_PlayerUnit[GetConvertedPlayerId(GetOwningPlayer(u))] then
loop
exitwhen i == 10
set r = 100 - rate
set r = ModuloReal(r, LoadReal(critHash, GetEquippedItemTypeId(GetOwningPlayer(u), i), 1))
set rate = rate + r
set r = 0
set i = i + 1
call print(R2S(r))
call print(R2S(rate))
endloop
endif
return rate
endfunction
private function Init takes nothing returns nothing
endfunction
endlibrary
JASS:
function Trig_Set_Damage_Copy_Actions takes nothing returns nothing
local unit s = udg_DamageEventSource
local unit t = udg_DamageEventTarget
local unit udum = null
local unit caster
local group g = CreateGroup()
local location l
local location l2
local integer i = GetPlayerId(GetOwningPlayer(s))
local integer i2
local integer i3
local real i4
local real amount = udg_DamageEventAmount
local boolean crit
if GetPlayerId(GetOwningPlayer(s)) < 10 then
if s != udg_PlayerUnit[i + 1] then
if GetRandomInt(1, 100) < getCritRate(s) then
set crit = true
set udg_DamageEventAmount = getCritPow(s)
set amount = udg_DamageEventAmount
endif
else
if GetRandomInt(1,100) < getCritRate(udg_PlayerUnit[i + 1]) then
set crit = true
set udg_DamageEventAmount = getCritPow(udg_PlayerUnit[i + 1])
set amount = udg_DamageEventAmount
endif
endif
else
call print(I2S(i))
endif
//chop//
if ( crit ) then
call CreateTextTagUnitBJ( ( I2S(R2I(udg_DamageEventAmount)) + "!" ), udg_DamageEventTarget, 50.00, 13.00, 100, 5.00, 10.00, 0 )
call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 75.00, 90.00 )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 3.50 )
call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 1.40 )
endif
call DestroyGroup(g)
set s = null
set t = null
set udum = null
set caster = null
set l = null
set l2 = null
set g = null
//ll TimerStart(time, 0.01, false,function timerEnd)
endfunction
//===========================================================================
function InitTrig_Set_Damage_Copy takes nothing returns nothing
set gg_trg_Set_Damage_Copy = CreateTrigger( )
call TriggerRegisterVariableEvent( gg_trg_Set_Damage_Copy, "udg_DamageModifierEvent", EQUAL, 1.00 )
call TriggerAddAction( gg_trg_Set_Damage_Copy, function Trig_Set_Damage_Copy_Actions )
endfunction
yes i know i need to switch to Nestharus's DDS, ill get to it when i get to it.