//*****************************************************
//* SPELL *
//* Ninja Stars *
//* By Element of Water *
//*****************************************************
//*****************************************************
//* CONSTANTS *
//* Change these to suit your specific spell needs *
//* Descriptions of each provided below *
//*****************************************************
constant function NinjaStars_BaseNumberOfStars takes nothing returns integer
return 4 //change this to how many stars you want him to throw when at ability level 1 - even numbers work best
//though you can use an odd number if you want
endfunction
constant function NinjaStars_StarsLevelModifier takes nothing returns integer
return 2 //change this to the amount more stars to be added per level - e.g., if the base is 4 and this
//is 2, at level 2 the attack will throw 6, at level 3, he will throw 8, etc. - again, even numbers are best
endfunction
constant function NinjaStars_StarDegrees takes nothing returns real
return 15.00 //change this to how many degrees you want between each star - MUST be a decimal number
endfunction
constant function NinjaStars_DummyUnitId takes nothing returns integer
return 'u001' //change this to the rawcode value of your dummy unit. the dummy's movement type -
//MUST be flying for the spell to work
endfunction
constant function NinjaStars_DummyAbilityId takes nothing returns integer
return 'A002' //change this to the rawcode value of the spell which shoots 1 star at a target location
//MUST have no cooldown for the spell to work
endfunction
constant function NinjaStars_DummyAbilityOrderString takes nothing returns string
return "shockwave" //to get this, look at the Text - Order String - Use/Turn Off and enclose what you see there in quotes
endfunction
constant function NinjaStars_MainAbilityId takes nothing returns integer
return 'A003' //change this to the rawcode value of the main spell
endfunction
constant function NinjaStars_BaseDamagePerStar takes nothing returns real
return 25.00 //change this to the amount of base (modified by stats) AOE (Area Of Effect) damage each star deals to its
//area at level 1 - again, MUST be decimal
endfunction
constant function NinjaStars_BonusDamagePerStarPerLevel takes nothing returns real
return 25.00 //change this to the amount of extra base AOE (Area Of Effect) damage each star deals to its area per level
// - again, MUST be decimal
endfunction
constant function NinjaStars_AgilityModifier takes nothing returns real
return 5.00 //this is a percentage - the ninja's damage will increase by this percentage per agility point
//MUST be decimal
endfunction
constant function NinjaStars_BaseAreaOfEffect takes nothing returns real
return 70.00 //change this to the radius of the AOE damage each star deals at level 1 - MUST be decimal
endfunction
constant function NinjaStars_BonusAreaOfEffectPerLevel takes nothing returns real
return 15.00 //change this to the bonus readius of the AOE damage each star deals per level - MUST be decimal
endfunction
constant function NinjaStars_Radius takes nothing returns real
return 250.00 //self-explanatory, must be less than or equal to the range of the dummy ability, should probably be
//equal to the range of your hero's attack - MUST be decimal
endfunction
constant function NinjaStars_DamageType takes nothing returns damagetype
return DAMAGE_TYPE_NORMAL //the damage type of the damage
endfunction
constant function NinjaStars_WeaponType takes nothing returns weapontype
return WEAPON_TYPE_METAL_LIGHT_SLICE //the weapon type of the damage - affects the noise it makes when it hits
endfunction
constant function NinjaStars_AttackType takes nothing returns attacktype
return ATTACK_TYPE_PIERCE //the attack type of the damage - determines damage reduction by units with certain armour types
//use "ATTACK_TYPE_CHAOS" (without the quotes) for damage which isn't reduced by any armour type
endfunction
constant function NinjaStars_DamageSelf takes nothing returns boolean
return false //if you want your hero to damage himself with his attack, set this to true. I suggest leaving it false
endfunction
constant function NinjaStars_DamageOwnUnits takes nothing returns boolean
return false //if you want your hero to damage his own units with his attack, set this to true. again, I suggest leaving it false
endfunction
//*****************************************************
//* END CONSTANTS *
//*****************************************************
//*****************************************************
//* USEFUL FUNCTIONS *
//* DO NOT CHANGE unless you know what you are doing *
//*****************************************************
//these are my 2 location-free PolarProjectionBJ equivalents
function PolarProjectionX takes real sourcex, real dist, real angle returns real
return sourcex + dist * Cos(angle * bj_DEGTORAD)
endfunction
function PolarProjectionY takes real sourcey, real dist, real angle returns real
return sourcey + dist * Sin(angle * bj_DEGTORAD)
endfunction
//determines the effect of the attacks, based on agility and level
function NinjaStars_NumberOfStars takes unit Hero returns integer
return NinjaStars_BaseNumberOfStars()+NinjaStars_StarsLevelModifier()*GetUnitAbilityLevel(Hero, NinjaStars_MainAbilityId())
endfunction
function NinjaStars_DamagePerStar takes unit Hero returns real
return NinjaStars_BaseDamagePerStar()+NinjaStars_BonusDamagePerStarPerLevel()*GetUnitAbilityLevel(Hero, NinjaStars_MainAbilityId())*(1+(NinjaStars_AgilityModifier()/100)*GetHeroAgi(Hero, true))
endfunction
function NinjaStars_AreaOfEffect takes unit Hero returns real
return NinjaStars_BaseAreaOfEffect()+NinjaStars_BonusAreaOfEffectPerLevel()*GetUnitAbilityLevel(Hero, NinjaStars_MainAbilityId())
endfunction
//*****************************************************
//* END USEFUL FUNCTIONS *
//*****************************************************
//*****************************************************
//* CONDITIONS *
//* DO NOT CHANGE unless you know what you are doing *
//*****************************************************
function Trig_NinjaStars_Conditions takes nothing returns boolean
return GetUnitAbilityLevel(GetAttacker(), NinjaStars_MainAbilityId()) >= 1
endfunction
//*****************************************************
//* ENDCONDITIONS *
//*****************************************************
//*****************************************************
//* MAIN CODE *
//* DO NOT CHANGE unless you know what you are doing *
//*****************************************************
function Trig_NinjaStars_Actions takes nothing returns nothing
//declare local variables, set up function
local unit u = GetAttacker()
local player p = GetOwningPlayer(u)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real x2
local real y2
local real face = GetUnitFacing(u)
local real angle
local unit array dummy
local group g
local unit u2
local integer i = 0
//the main loop which executes the spell
loop
exitwhen i >= NinjaStars_NumberOfStars(u)
set dummy
= CreateUnit(Player(13), NinjaStars_DummyUnitId(), x, y, bj_UNIT_FACING)
call UnitAddAbility(dummy, NinjaStars_DummyAbilityId())
call SetUnitInvulnerable(dummy, true)
set angle = face - (NinjaStars_NumberOfStars(u) / 2 * NinjaStars_StarDegrees()) + NinjaStars_StarDegrees() * i
set x2 = PolarProjectionX(x, NinjaStars_Radius(), angle)
set y2 = PolarProjectionY(y, NinjaStars_Radius(), angle)
set g = null
set g = CreateGroup()
call IssuePointOrder(dummy, NinjaStars_DummyAbilityOrderString(), x2, y2)
call GroupEnumUnitsInRange(g, x2, y2, NinjaStars_AreaOfEffect(u), null)
loop
set u2 = null
set u2 = FirstOfGroup(g)
exitwhen u2 == null
if (u2 != u and GetOwningPlayer(u2) != p) then
call UnitDamageTarget(u, u2, NinjaStars_DamagePerStar(u), true, true, NinjaStars_AttackType(), NinjaStars_DamageType(), NinjaStars_WeaponType())
endif
call GroupRemoveUnit(g, u2)
endloop
call DestroyGroup(g)
set i = i + 1
endloop
set i = 0
call TriggerSleepAction(0.2)
loop
exitwhen i >= NinjaStars_NumberOfStars(u)
call RemoveUnit(dummy)
set dummy = null
set i = i + 1
endloop
//remove leaks
set g = null
set u2 = null
set u = null
set p = null
endfunction
//*****************************************************
// END MAIN CODE *
//*****************************************************
//*****************************************************
//* TRIGGER INITIALISATION *
//* DO NOT CHANGE unless you know what you are doing *
//*****************************************************
function InitTrig_NinjaStars takes nothing returns nothing
local integer i = 0
set gg_trg_NinjaStars = CreateTrigger( )
call TriggerAddAction( gg_trg_NinjaStars, function Trig_NinjaStars_Actions )
call TriggerAddCondition(gg_trg_NinjaStars, Condition(function Trig_NinjaStars_Conditions))
loop
exitwhen i>=bj_MAX_PLAYERS
call TriggerRegisterPlayerUnitEvent(gg_trg_NinjaStars, Player(i), EVENT_PLAYER_UNIT_ATTACKED, null)
set i = i + 1
endloop
endfunction
//*****************************************************
//* END TRIGGER INITIALISATION *
//*****************************************************
//*****************************************************
//* END SPELL *
//*****************************************************
This is the spell for me, please check for mistakes