- Reaction score
- 587
Omni Slash - Nontarget
MUI: Yes
JESP: Yes
Comments/Implement Inst: Yes
Easily Editable: Yes
Import Difficulty: 2/10
Awesome Level: 2/1

JASS:
scope OmniSlash initializer Init
//Config Header
globals
private constant integer SpellID = 'A001' //This is the spell code, replace this with your spell's ID.
private constant real Damage = 50.00 //This is the base amount of damage done to the target.
private constant real Pause = 0.32 //This is the duration of the pause before the hero teleports again.
private constant real LockOn = 700.00 //This is the range in which the hero will acquire a target.
private constant string Anim = "slam" //This is the animation that will be used each time the hero teleports.
endglobals
//At the bottom of this trigger there are a few more things you can customize.
//EndConfigHeader
globals
private string array Effects
private integer array AbilLvl
endglobals
private function Living takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0
endfunction
private function OSC takes nothing returns boolean
return GetSpellAbilityId() == SpellID
endfunction
private function OSA takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit target
local integer loopd = 0
local integer splvl = GetUnitAbilityLevel(caster, SpellID)
local location tarloc
local location casloc
local location temp
local group randtarget = CreateGroup()
call PauseUnit(caster, true)
call SetUnitInvulnerable(caster, true)
loop
exitwhen loopd == AbilLvl[GetUnitAbilityLevel(caster, SpellID)]
set casloc = GetUnitLoc(caster)
call GroupEnumUnitsInRangeOfLoc(randtarget, casloc, LockOn, Condition(function Living))
set target = FirstOfGroup(randtarget) //This picks the unit to attack.
if (target == null) then
call RemoveLocation(casloc) //Stops the spell if there are no targets around.
call GroupClear(randtarget)
endif
exitwhen target == null
set tarloc = GetUnitLoc(target)
set temp = PolarProjectionBJ(tarloc, 0.00, GetRandomInt(1, 360))
call SetUnitPositionLoc(caster, temp) //Sets the unit position.
call SetUnitFacing(caster, AngleBetweenPoints(temp, tarloc)) //Makes the caster face the target.
call SetUnitAnimation( caster, Anim ) //This is just the attack animation
call DestroyEffect(AddSpecialEffectTarget(Effects[GetRandomInt(1, 6)], caster, "origin")) //Effect shown on the caster at teleport.
call DestroyEffect(AddSpecialEffectTarget(Effects[GetRandomInt(1, 6)], target, "origin")) //Effect shown on the target.
call UnitDamageTarget(caster, target, splvl*Damage, false, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS) //This is what does the damage.
call RemoveLocation(casloc)
call RemoveLocation(tarloc)
call RemoveLocation(temp)
call GroupClear(randtarget)
call PW(Pause)
set loopd = loopd + 1
endloop
call PauseUnit(caster, false)
call SetUnitInvulnerable(caster, false)
call DestroyGroup(randtarget)
set caster = null
set target = null
set temp = null
set casloc = null
set tarloc = null
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
set Effects[1] = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdx" //Model 1 to be displayed.
set Effects[2] = "Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdx" //Model 2 to be displayed.
set Effects[3] = "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdx" //Model 3 to be displayed.
set Effects[4] = "Abilities\\Spells\\Demon\\ReviveDemon\\ReviveDemon.mdx" //Model 4 to be displayed.
set Effects[5] = "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdx" //Model 5 to be displayed.
set Effects[6] = "Abilities\\Spells\\Human\\Resurrect\\Resurrecttarget.mdx" //Model 6 to be displayed.
set AbilLvl[1] = 3 //Number of units level one of the spell hits.
set AbilLvl[2] = 5 //Number of units level two of the spell hits.
set AbilLvl[3] = 8 //Number of units level three of the spell hits.
loop
exitwhen i > 15
call TriggerRegisterPlayerUnitEvent(t,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,Condition(function FailSafe))
set i = i + 1
endloop
call TriggerAddCondition(t, Condition( function OSC))
call TriggerAddAction(t, function OSA)
endfunction
endscope
Code:
Change Log:
1.00 - Released.
1.1 - Code Improved.
1.15 - Accepted.
1.2 - Added Dummies that have a 1 Jump OmniSlash.
1.4 - Implemented Constants.
2.0 - Upgraded to work with globals. Code Improvements. Dummys have been removed. Constants cycled out.
2.2 - Code has been improved. Added new implementation instructions. Cleaned up some useless object data. Updated the tooltip.
2.3 - More errors cleaned out. Got rid of the "Double Free" bug.
3.0 - Further updated code, improved a lot of things.
Attachments
-
37.7 KB Views: 502