////////////////////////////////////////////////////////////////////
// Enhanced Critical Strike by 1)ark_NiTe //
// //
// i = Level of Enhanced Critical Strike //
// r = Extra Damage Dealt (Real Damage * Level of Ability) //
// //
////////////////////////////////////////////////////////////////////
//==================================================================================================================================
// Start of constants. These will need to be changed by you. They provide the user with easier implementing//changing of the spell's rawcodes and effects.
//==================================================================================================================================
constant function Crit_Strike_ID takes nothing returns integer
return 'A001' // Enhanced Critical Strike ability rawcode.
endfunction
constant function Crit_Struck_ID takes nothing returns integer
return 'A000' // Critically Struck (Dummy) ability rawcode.
endfunction
constant function Dummy_Unit_ID takes nothing returns integer
return 'h002' // Dummy Unit rawcode.
endfunction
//==================================================================================================================================
// End of constants. Do not touch anything below this unless you are familiar with JASS.
//==================================================================================================================================
function Enhanced_Critical_Strike_Conds takes nothing returns boolean
return GetOwningPlayer(GetTriggerUnit()) != GetOwningPlayer(GetEventDamageSource()) and GetUnitAbilityLevel(GetEventDamageSource(), 'A001') >=1 and IsUnitInGroup(GetEventDamageSource(), udg_JustCastSpell) == false and GetRandomInt(1, 100) <= 15
endfunction
function Trig_Enhanced_Critical_Strike takes nothing returns nothing
// Declares Local Variables
local unit e
local unit d = GetEventDamageSource()
local unit t = GetTriggerUnit()
local force f = CreateForce()
local force g = CreateForce()
local texttag tag
local integer i = GetUnitAbilityLevel(d, Crit_Strike_ID())
local real dmg = ( GetEventDamage() * i )
local real a
local real fd
local real r
local trigger trig = GetTriggeringTrigger()
call DisableTrigger(trig)
set a = GetUnitArmor(t)
set fd = GetFullDamage(dmg, a)
set r = GetReducedDamage(fd, a)
call UnitDamageTarget(d, t, r, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call EnableTrigger(trig)
// Creates Floating Text showing the Damage Dealt (dmg+r)
set tag = CreateTextTagUnitBJ( ( "|cffFF0000" + ( I2S(R2I(( ( r / i ) + r ))) + "|r" ) ), d, 0, 10, 100, 100, 100, 0 )
if (IsPlayerInForce(GetLocalPlayer(), bj_FORCE_ALL_PLAYERS))then
call SetTextTagVisibility(tag, false)
endif
call ForceEnumAllies(f, GetOwningPlayer(d), null)
call ForceEnumAllies(g, GetOwningPlayer(t), null)
if (IsPlayerInForce(GetLocalPlayer(), f)) or (IsPlayerInForce(GetLocalPlayer(), g)) then
call SetTextTagVisibility(tag, true)
endif
call SetTextTagVelocity(tag, 0, 0.04)
call SetTextTagPermanent(tag, false)
call SetTextTagFadepoint(tag, 2.00)
call SetTextTagLifespan(tag, 3.00)
if GetWidgetLife(t) > 0 then
set e = CreateUnit(GetOwningPlayer(d), Dummy_Unit_ID(), GetUnitX(t), GetUnitY(t), 0)
call UnitApplyTimedLife(e, 'BTLF', 1.00)
call UnitAddAbility(e, Crit_Struck_ID())
call IssueTargetOrder( e, "drunkenhaze", t )
else
// Does not create dummy unit because unit has died
endif
set tag = null
set trig = null
set f = null
set g = null
set e = null
set d = null
set t = null
endfunction
//===========================================================================
function InitTrig_Enhanced_Critical_Strike takes nothing returns nothing
set gg_trg_Enhanced_Critical_Strike = CreateTrigger( )
call TriggerAddCondition( gg_trg_Enhanced_Critical_Strike, Condition( function Enhanced_Critical_Strike_Conds ) )
call TriggerAddAction( gg_trg_Enhanced_Critical_Strike, function Trig_Enhanced_Critical_Strike )
endfunction