• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Scripted Multiple Attack, need Help, check this out!

Status
Not open for further replies.
Level 21
Joined
Dec 9, 2007
Messages
3,096
I need a special scripted attack, a ninja attack, i can't make such a thing with GUI then i need help from someone who knows JASS very good!
I want my ninja to throw forward a ninja star, with the normal attack, but, in the saming time, throw one more ninja star at 15 degrees on the left, anotherone at 15 degrees on the right, anotherone in 30 degrees on the left and one at 30 degrees on the right. At the impact they damage equal to the hero's agillity. I wish somebody can help me!:con:My ninja will be a mercenary on my RPG.
 
Ninja Stars spell

Here is your spell. The same kind of thing could be done by using a custom model and the fan of knives as the base spell, but this is, of course, full MUI and shouldn't cause any lag, so it's as good and (I think) easier to implement than the alternative. Also, it doesn't require the extra map size a model uses. Enjoy! PM me if you have any queries on how to implement the spell. :thumbs_up:
JASS:
//*****************************************************
//*                   SPELL                           *
//*                Ninja Stars                        *
//*             By Element of Water                   *
//*****************************************************

//*****************************************************
//*                  CONSTANTS                        *
//*   Change these to suit your specific spell needs  *
//*        Descriptions of each provided below        *
//*****************************************************

constant function NinjaStars_NumberOfStars takes nothing returns integer
    return 6 //change this to how many stars you want him to throw - even numbers work best
    //though you can use an odd number if you want
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 'h001' //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 'A000' //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 'A001' //change this to the rawcode value of the main spell
endfunction

constant function NinjaStars_DamagePerStar takes nothing returns real
    return 200.00 //change this to the amount of AOE (Area Of Effect) damage each star deals to its area - again, MUST be decimal
endfunction

constant function NinjaStars_AreaOfEffect takes nothing returns real
    return 100.00 //change this to the radius of the AOE damage each star deals - 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 - 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 spell, 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 woth his spell, 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

//*****************************************************
//*            END USEFUL FUNCTIONS                   *
//*****************************************************

//*****************************************************
//*                 CONDITIONS                        *
//* DO NOT CHANGE unless you know what you are doing  *
//*****************************************************

function Trig_NinjaStars_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == NinjaStars_MainAbilityId()
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 = GetTriggerUnit()
    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()
        set dummy[i] = CreateUnit(Player(13), NinjaStars_DummyUnitId(), x, y, bj_UNIT_FACING)
        call UnitAddAbility(dummy[i], NinjaStars_DummyAbilityId())
        call SetUnitInvulnerable(dummy[i], true)
        set angle = face - (NinjaStars_NumberOfStars() / 2 * NinjaStars_StarDegrees()) + NinjaStars_StarDegrees() * i
        set x2 = PolarProjectionX(x, NinjaStars_Radius(), angle)
        set y2 = PolarProjectionY(y, NinjaStars_Radius(), angle)
        set g = CreateGroup()
        call IssuePointOrder(dummy[i], NinjaStars_DummyAbilityOrderString(), x2, y2)
        call GroupEnumUnitsInRange(g, x2, y2, NinjaStars_AreaOfEffect(), null)
        loop
            set u2 = FirstOfGroup(g)
            exitwhen u2 == null
            if (u2 != u and GetOwningPlayer(u2) != p) then
                call UnitDamageTarget(u, u2, NinjaStars_DamagePerStar(), 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()
        call RemoveUnit(dummy[i])
        set dummy[i] = 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_SPELL_CAST, null)
        set i = i + 1
    endloop
endfunction

//*****************************************************
//*           END TRIGGER INITIALISATION              *
//*****************************************************

//*****************************************************
//*                   END SPELL                       *
//*****************************************************
 
Level 22
Joined
Jun 23, 2007
Messages
3,242
return 'A000' //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

wouldnt that be bad since people would just spam the spell?

EDIT:why do you want it as his special attack? it would look funny with him throwing around ninja stars every time he attacks.
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
also, i don't need the missiles to follow targets, i need them to dissepear in 700 range or when they hit!
Also, i need 2 conditions, if the level of Ninja Attack (-a passive abillity - i will make the spell and fit the ID later) equal to 1 and the unit within range of the star not equal to the unit attacked by the hero, when the hero strikes with a melee attack, that 4 stars are throw from him and damage enemies in 70 AoE. i didn't read it all, but i need them to damage on impact an amout equal to the hero's agillity. I know you mustn't help me if you don't want, but i will add in my spell's description : Thanks to 'Elemental of Water' from HiveWorkShop for main core!
 
Last edited:
return 'A000' //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

wouldnt that be bad since people would just spam the spell?
No. This is the dummy ability that must have no cooldown, not the main ability.

@Vercas
Yes, I can easily modify it - will take me half an hour only, will repost soon.

EDIT: I forgot one thing - will the damage be based on his strength, intellect or agility? Making it based on agility for now as this seems to fit the bill.

EDIT done:
JASS:
//*****************************************************
//*                   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 'h001' //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 'A000' //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 'A001' //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[i] = CreateUnit(Player(13), NinjaStars_DummyUnitId(), x, y, bj_UNIT_FACING)
        call UnitAddAbility(dummy[i], NinjaStars_DummyAbilityId())
        call SetUnitInvulnerable(dummy[i], 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[i], 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[i])
        set dummy[i] = 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                       *
//*****************************************************
 
Last edited:
no. they do aoe damage when they get to where they are directed to. To make them stop when they hit a target would be very time-consuming and you would have to move them step-by-step - aka would probably lag.

I already have the test map.
anyways, I don't find the attach thing anywhere...

whatever...

//*****************************************************
//* 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 'h001' //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 'A000' //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 'A001' //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 *
//*****************************************************
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
//*****************************************************
//* 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 :(
 
Status
Not open for further replies.
Top