- Joined
- Jul 7, 2007
- Messages
- 22
I am making a critical strike which is based on agility, it's chance and damage.
Currently this is what I have:
(Converted to custom text with Edit...Convert to Custom Text)
Everything works fine, damage, chance etc. But it is easily exploited because if you just spam your hero to attack one person during combat (constantly press S and right click your enemy) it will just constantly fire this trigger. If anyone knows away around this, such as a condition to check if your hero is attacking or not, please post.
Currently this is what I have:
JASS:
function Trig_Critical_Strike_Chance_Func006C takes nothing returns boolean
if ( not ( udg_Temp_Integer[4] < 15 ) ) then
return false
endif
return true
endfunction
function Trig_Critical_Strike_Chance_Func007C takes nothing returns boolean
if ( not ( udg_Temp_Integer[4] >= 75 ) ) then
return false
endif
return true
endfunction
function Trig_Critical_Strike_Chance_Func013C takes nothing returns boolean
if ( not ( udg_Temp_Integer[1] <= udg_Temp_Integer[4] ) ) then
return false
endif
return true
endfunction
function Trig_Critical_Strike_Chance_Actions takes nothing returns nothing
set udg_Temp_Integer[1] = GetRandomInt(1, 100)
set udg_Temp_Integer[2] = GetHeroStatBJ(bj_HEROSTAT_AGI, GetAttacker(), true)
set udg_Temp_Integer[3] = 10
// Divider
set udg_Temp_Integer[4] = ( udg_Temp_Integer[2] / udg_Temp_Integer[3] )
if ( Trig_Critical_Strike_Chance_Func006C() ) then
set udg_Temp_Integer[4] = 15
else
endif
if ( Trig_Critical_Strike_Chance_Func007C() ) then
set udg_Temp_Integer[4] = 75
else
endif
// Divider
set udg_Temp_Real[1] = ( I2R(GetHeroStatBJ(bj_HEROSTAT_AGI, GetAttacker(), true)) + I2R(GetHeroStatBJ(bj_HEROSTAT_STR, GetAttacker(), true)) )
set udg_Temp_Real[2] = 1.50
set udg_Temp_Real[3] = ( udg_Temp_Real[1] * udg_Temp_Real[2] )
set udg_Temp_Real[3] = I2R(R2I(udg_Temp_Real[3]))
if ( Trig_Critical_Strike_Chance_Func013C() ) then
call UnitDamageTargetBJ( GetAttacker(), GetAttackedUnitBJ(), udg_Temp_Real[3], ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
set udg_Temp_Point[1] = GetUnitLoc(GetAttacker())
// Divider
call CreateTextTagLocBJ( ( udg_PlayerColor[GetConvertedPlayerId(GetOwningPlayer(GetAttacker()))] + ( R2S(udg_Temp_Real[3]) + "!" ) ), udg_Temp_Point[1], 0, 9.00, 100, 100, 100, 0 )
call SetTextTagVelocityBJ( GetLastCreatedTextTag(), 64, 90 )
call SetTextTagPermanentBJ( GetLastCreatedTextTag(), false )
call SetTextTagLifespanBJ( GetLastCreatedTextTag(), 4.00 )
call SetTextTagFadepointBJ( GetLastCreatedTextTag(), 3.00 )
// Divider
call RemoveLocation( udg_Temp_Point[1] )
else
endif
endfunction
//===========================================================================
function InitTrig_Critical_Strike_Chance takes nothing returns nothing
set gg_trg_Critical_Strike_Chance = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Critical_Strike_Chance, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddAction( gg_trg_Critical_Strike_Chance, function Trig_Critical_Strike_Chance_Actions )
endfunction
(Converted to custom text with Edit...Convert to Custom Text)
Everything works fine, damage, chance etc. But it is easily exploited because if you just spam your hero to attack one person during combat (constantly press S and right click your enemy) it will just constantly fire this trigger. If anyone knows away around this, such as a condition to check if your hero is attacking or not, please post.