For my map project, here is a current spell that I have heavily modified off of another one. Basically the unit stands still and attacks a number of times to all in range of the spell. The thing that gets me, is that the unit hurts itself when casting it, by the amount of damage the spell does. Also, if its any longer than 5 hits (Dont know the exact amount though), the unit can move around while the trigger continues to go through the remaining attacks (After the unit finishes the animations. So, I guess the problems that I dont know how to fix are- How to make the unit not take damage when casting (Not making the unit invulnerable or divine), and pausing the unit while the spell is cast, and unpausing when done. Help is greatly appreciated.
Also, this is not really needed, but would be nice- To play the riflemans attack sound while attacking, and having the riflemans projectile effect on the enemy units hit by the spell.
Also, this is not really needed, but would be nice- To play the riflemans attack sound while attacking, and having the riflemans projectile effect on the enemy units hit by the spell.
JASS:
function Trig_Rapid_Fire_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A021'
endfunction
function Unit_Group takes nothing returns boolean
return GetBooleanAnd( IsUnitAliveBJ(GetFilterUnit()) == true, IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction
function Trig_Rapid_Fire_Actions takes nothing returns nothing
local unit Caster = GetTriggerUnit()
local integer i = 0
local group UnitGroup
local unit TargetRandom
local unit Target = GetSpellTargetUnit()
local location R
local real Damage = 100
local integer Amount = 5 + ( GetUnitAbilityLevelSwapped('A021', Caster) * 0 )
call TriggerSleepAction( 0.20 )
call SetUnitVertexColor( Caster, 255, 255, 255, 255 )
call UnitDamageTarget( Caster, Target, Damage, false, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_AXE_MEDIUM_CHOP )
call SetUnitAnimation( Caster, "attack" )
call TriggerSleepAction( 0.2 )
loop
set i = i + 1
exitwhen i > Amount
set UnitGroup = GetUnitsInRangeOfLocMatching(600.00, GetUnitLoc(Caster), Condition(function Unit_Group))
if ( IsUnitGroupEmptyBJ(UnitGroup) == false ) then
set TargetRandom = GroupPickRandomUnit (UnitGroup)
set R = GetUnitLoc(TargetRandom)
call UnitDamageTarget( Caster, TargetRandom, Damage, false, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_AXE_MEDIUM_CHOP )
call SetUnitAnimation( Caster, "attack" )
call RemoveLocation ( R )
call TriggerSleepAction( 0.2 )
else
endif
call DestroyGroup(UnitGroup)
endloop
call SetUnitVertexColor( Caster, 255, 255, 255, 255 )
set Caster = null
set UnitGroup = null
set TargetRandom = null
set Target = null
set Amount = 0
set R = null
set Damage = 0
endfunction
//===========================================================================
function InitTrig_Rapid_Fire_Copy_2 takes nothing returns nothing
set gg_trg_Rapid_Fire_Copy_2 = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Rapid_Fire_Copy_2, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_Rapid_Fire_Copy_2, Condition( function Trig_Rapid_Fire_Conditions ) )
call TriggerAddAction( gg_trg_Rapid_Fire_Copy_2, function Trig_Rapid_Fire_Actions )
endfunction