The skill made by me, sends the spirit, if spirit will face with the enemy,the enemy will be paused and the caster will transport to enemy and deal damage. If you want to take this skill in your map you sould only change the spell id in define SpellForGrabAndPull = 'A000' and your dummy id in define YourDummy = 'h000'
Spell code [jass=My Jass]
function Trig_spell_Conditions takes nothing returns boolean //main condition
return GetSpellAbilityId() == SpellForGrabAndPull //if skill = SpellForGramAndPull
endfunction
function condforcatch takes nothing returns boolean //condition for catch unit
local timer t = GetExpiredTimer() //get timer
local unit dammy = LoadUnitHandle(hash,GetHandleId(t),1) //load dammy
local unit a = LoadUnitHandle(hash,GetHandleId(t),2) //load unit a
local real angle = LoadReal(hash,GetHandleId(t),3) // load real angle
return IsUnitEnemy(GetEnumUnit(), GetOwningPlayer(a)) and not IsUnitType(GetEnumUnit(), UNIT_TYPE_DEAD) //if unit enemy and unit not dead
endfunction
function movetocatched takes nothing returns nothing // move caster to enemy
local timer t2 = GetExpiredTimer() // get timer t2
local timer t = LoadTimerHandle(hash,GetHandleId(t2),3) //load timer t
local unit catched = LoadUnitHandle(hash,GetHandleId(t2),1) //load unit catched
local unit a = LoadUnitHandle(hash,GetHandleId(t2),2) // loadl unit a
local effect e = LoadEffectHandle(hash,GetHandleId(t2),3) // loadl effect e
local real angle2 = bj_RADTODEG * Atan2(GetLocationY(GetUnitLoc(catched)) - GetLocationY(GetUnitLoc(a)), GetLocationX(GetUnitLoc(catched)) - GetLocationX(GetUnitLoc(a))) // angle between unit a and catched
local real dx = GetLocationX(GetUnitLoc(catched)) - GetLocationX(GetUnitLoc(a)) // distance between a and catched
local real dy = GetLocationY(GetUnitLoc(catched)) - GetLocationY(GetUnitLoc(a)) // distance between a and catched
if((SquareRoot(dx * dx + dy * dy) >= 140.1)) then // (if // distance between a and catched >= 140 then)
call SetUnitFacing(a, angle2) // set unit facing a to angle2
call SetUnitAnimation(a, "Walk") // play unit animation
call SetUnitX(a, GetUnitX(a)+20*Cos(angle2*bj_DEGTORAD)) // move unit a
call SetUnitY(a, GetUnitY(a)+20*Sin(angle2*bj_DEGTORAD)) // move unit a
set t2 = null
set t = null
set a = null
set catched = null
else //else
call SetUnitFacing(a, angle2) //set unit facing a to angle2
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl",catched,"origin")) //add & destroy effect
call UnitDamageTarget(a,catched,(90*GetUnitAbilityLevel(a,SpellForGrabAndPull)),false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null) // damage target
call SetUnitPathing(a,true) //set unit a pathing to true
call DestroyEffect(e) // destroy effect e
call PauseUnit(catched, false) // unpause unit catched
call DestroyTimer(t) // destroy timer t
call DestroyTimer(t2) // destroy timer t2
set t2 = null
set t = null
set a = null
set catched = null
call FlushChildHashtable(hash,GetHandleId(t)) //clear hash
call FlushChildHashtable(hash,GetHandleId(t2)) //clear hash
endif
endfunction
function catch2 takes nothing returns nothing // if dammy face enemy in range 75
local timer t = GetExpiredTimer() // get timer t
local timer t2 //create timer t2
local unit dammy = LoadUnitHandle(hash,GetHandleId(t),1) //load unit dammy
local unit a = LoadUnitHandle(hash,GetHandleId(t),2) //load unit a
local real angle = LoadReal(hash,GetHandleId(t),3) // load real angle
local unit catched = LoadUnitHandle(hash,GetHandleId(t),10) // loadl unit catched
local effect e //create effect variable
if(condforcatch()) then //if cond
call RemoveUnit(dammy) //remove dammy from game
set t2 = CreateTimer() // set variable t2 = CreateTimer()
set catched = GetEnumUnit() // set variable unit catched = GetEnumUnit()
call PauseUnit(catched, true) // pause unit
set bj_lastCreatedEffect = AddSpecialEffectTarget("Abilities\\Spells\\Orc\\ReinforcedTrollBurrow\\ReinforcedTrollBurrowTarget.mdl", catched, "origin" ) // add special effect
set e = bj_lastCreatedEffect // set variable effect e = get last created effect
call SaveTimerHandle(hash,GetHandleId(t2),3,t) // save timer t
call SaveUnitHandle(hash,GetHandleId(t2),1,catched) //save unit catched
call SaveUnitHandle(hash,GetHandleId(t2),2,a) // save unit a
call SaveEffectHandle(hash,GetHandleId(t2),3,e) // save effect e
call SetUnitPathing(a,false) // set unit a pathing to false
call TimerStart(t2,0.01,true,function movetocatched) // start timer t2
set t = null
set a = null
set catched = null
call FlushChildHashtable(hash,GetHandleId(t))
else
endif
endfunction
function condfordead takes nothing returns boolean //death condition
local timer t = GetExpiredTimer() // get timer
local unit dammy = LoadUnitHandle(hash,GetHandleId(t),1) //load dammy
if(not( GetUnitState(dammy, UNIT_STATE_LIFE) <= 0 == true)) then // if dammy is dead then
return false
endif
return true
endfunction
function catch takes nothing returns nothing //timer function
local unit key1 = null // for save/load hash
local timer t = GetExpiredTimer() // get timer t
local unit dammy = LoadUnitHandle(hash,GetHandleId(t),1) // load unit dammy
local unit a = LoadUnitHandle(hash,GetHandleId(t),2) // load unit a
local real angle = LoadReal(hash,GetHandleId(t),3) // load real angle
local real x1 = GetLocationX(GetUnitLoc(dammy))+20*Cos(angle*bj_DEGTORAD) // for check "RectContainsLoc"
local real y1 = GetLocationY(GetUnitLoc(dammy))+20*Sin(angle*bj_DEGTORAD) // for check "RectContainsLoc"
call SaveTimerHandle(hash,GetHandleId(key1),1,t) // save timer in key 1
if((RectContainsLoc(bj_mapInitialPlayableArea, Location(x1,y1)) == true)) then // if "our cond" then
call SetUnitX(dammy, GetUnitX(dammy)+20*Cos(angle*bj_DEGTORAD)) //move unit dammy
call SetUnitY(dammy, GetUnitY(dammy)+20*Sin(angle*bj_DEGTORAD)) //move unit dammy
call ForGroup(GetUnitsInRangeOfLocAll(75,GetUnitLoc(dammy)), function catch2) // catch units in range of loc dammy
set a = null
set dammy = null
set t = null
else // else (if rect not containts locaion)
call RemoveUnit(dammy) // remove dammy from game
call DestroyTimer(t) // destroy timer
call FlushChildHashtable(hash,GetHandleId(t)) //clear hash
set a = null
set dammy = null
set t = null
endif
if(condfordead()) then // if / then
set t = LoadTimerHandle(hash,GetHandleId(key1),1) // load timer (for delete)
call DestroyTimer(t) // destroy loaded timer
call FlushChildHashtable(hash,GetHandleId(key1)) // clear hash
call FlushChildHashtable(hash,GetHandleId(t)) // clear hash
else
endif
endfunction
function Trig_spell_Actions takes nothing returns nothing // main function
local unit key1 = null // create null variable for hash save/load
local timer t = CreateTimer() // create timer
local unit a = GetSpellAbilityUnit() // get spell ability unit
local unit catched // create unit variable catched
local unit dammy // create variable dammy (dummy)
local real angle = bj_RADTODEG * Atan2(GetLocationY(GetSpellTargetLoc()) - GetLocationY(GetUnitLoc(a)), GetLocationX(GetSpellTargetLoc()) - GetLocationX(GetUnitLoc(a))) // angle between unit loc a and spell loc
local real x = GetLocationX(GetUnitLoc(a))+60*Cos(angle*bj_DEGTORAD) // real x
local real y = GetLocationY(GetUnitLoc(a))+60*Sin(angle*bj_DEGTORAD) // real y
set bj_lastCreatedUnit = CreateUnitAtLoc(GetOwningPlayer(a), YourDummy, Location(x,y), angle) // create dummy
call UnitApplyTimedLife( bj_lastCreatedUnit, 'BTLF', 1.50 ) // life timer
set dammy = bj_lastCreatedUnit // set dammy = last created unit
call TimerStart(t,0.01,true,function catch) // starting timer
call FlushChildHashtable(hash,GetHandleId(t)) //clear hash
call SaveTimerHandle(hash,GetHandleId(key1),1,t) // save timer t in hash
call SaveUnitHandle(hash,GetHandleId(t),1,dammy) // save unit dammy in hash
call SaveUnitHandle(hash,GetHandleId(t),2,a) // save unit a in hash
call SaveReal(hash,GetHandleId(t),3,angle) // save real angle in hash
call SaveUnitHandle(hash,GetHandleId(t),10,catched) // save variable catched in hash
set a = null
set catched = null
set t = null
endfunction
//===========================================================================
function InitTrig_GrabAndPull takes nothing returns nothing
set gg_trg_GrabAndPull = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_GrabAndPull, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_GrabAndPull, Condition( function Trig_spell_Conditions ) )
call TriggerAddAction( gg_trg_GrabAndPull, function Trig_spell_Actions )
endfunction
[/code]
Tha map's cap [jass=My Jass]
globals
hashtable hash = InitHashtable()
endglobals
define SpellForGrabAndPull = 'A000' // change it on your spell id
define YourDummy = 'h000' // cahnge it on your dummy id
[/code]
Keywords:
Warcraft 3