Hello everyone, please take a look at this script:
Basically, this is meant to replace a critical strike ability for a triggered one in order to control critical hits from units. However, this apples to all damage that is dealt from units that have the Critical Strike ability, such as spells like Blizzard and others that the hero might have, which is highly and unfairly beneficial for the hero. Is there any way to prevent spell damage from firing the trigger, or is there another way of going about the making of this custom critical strike spell such that it is only triggered by normal damage?
Thanks
JASS:
scope CriticalStrike initializer Init
globals
//--------------------------------------------------SETUP--------------------------------------------------
private constant integer SpellID = 'A006' //Raw code of the spell
private constant real CritChance = 15. //Percent chance of dealing a critical hit.
private constant real CritChanceInc = 5. //Increase in percent chance per level.
private constant real DmgMultiplier = 2. //Number by which the damage dealt is multiplied when a critical strike is dealt.
private constant real MultiplierInc = .5 //Multiplier increment per level.
//------------------------------------------------SETUP END------------------------------------------------
private trigger CriticalTrig = CreateTrigger()
endglobals
private function AddUnits takes nothing returns boolean
call TriggerRegisterUnitEvent(CriticalTrig, GetFilterUnit(), EVENT_UNIT_DAMAGED)
return false
endfunction
private function Conditions takes nothing returns boolean
return GetUnitAbilityLevel(GetEventDamageSource(), SpellID) > 0 and GetRandomReal(0., 100.) <= CritChance + CritChanceInc * (GetUnitAbilityLevel(GetEventDamageSource(), SpellID) - 1)and IsUnitEnemy(GetTriggerUnit(), GetOwningPlayer(GetEventDamageSource()))
endfunction
private function Actions takes nothing returns nothing
local unit DmgSource = GetEventDamageSource()
local integer AbiLevel = GetUnitAbilityLevel(DmgSource, SpellID)
local real ExtraDamage = GetEventDamage() * (DmgMultiplier + MultiplierInc * (AbiLevel - 1)) - GetEventDamage()
local texttag Text = CreateTextTag()
call DisableTrigger(GetTriggeringTrigger())
call UnitDamageTarget(DmgSource, GetTriggerUnit(), ExtraDamage, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
call EnableTrigger(GetTriggeringTrigger())
call SetTextTagText(Text, I2S(R2I(GetEventDamage() + ExtraDamage))+"!", 10 * .023/10.)
call SetTextTagPosUnit(Text, GetEventDamageSource(), 64.)
call SetTextTagColor(Text, 255, 0, 0, 255)
call SetTextTagVelocity(Text, 120. * 0.071/128. * Cos(90. * bj_DEGTORAD), 120. * 0.071/128. * Sin(90. * bj_DEGTORAD))
call SetTextTagPermanent(Text, false)
call SetTextTagLifespan(Text, 2.)
call SetTextTagFadepoint(Text, 1.7)
set Text = null
set DmgSource = null
endfunction
private function Init takes nothing returns nothing
local group Targets = CreateGroup()
local trigger AddNewUnits = CreateTrigger()
call TriggerAddAction(CriticalTrig, function Actions)
call TriggerAddCondition(CriticalTrig, Condition(function Conditions))
call GroupEnumUnitsInRect(Targets, bj_mapInitialPlayableArea, Condition(function AddUnits))
call DestroyGroup(Targets)
endfunction
endscope
Basically, this is meant to replace a critical strike ability for a triggered one in order to control critical hits from units. However, this apples to all damage that is dealt from units that have the Critical Strike ability, such as spells like Blizzard and others that the hero might have, which is highly and unfairly beneficial for the hero. Is there any way to prevent spell damage from firing the trigger, or is there another way of going about the making of this custom critical strike spell such that it is only triggered by normal damage?
Thanks