• 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.

[JASS] Need help making circle spell

Status
Not open for further replies.
Level 6
Joined
Nov 10, 2006
Messages
181
Right now , I am trying to create a spell that expands outwards from the caster to the caster, for some reason I don't want to use Polarprojection BJ so I decided to do this.

Yet it does not work , any ideas or clues to help me ?

JASS:
scope Fire initializer Init

globals
private constant integer SPELL = 'A002'
private constant string EFFECT = "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl" 
endglobals

private struct data
location CasterLoc
unit caster
real distance
real angle
real x
real y
static method create takes nothing returns data
local data d = data.allocate()
set d.caster = GetTriggerUnit()
set d.x = GetUnitX(d.caster)
set d.y = GetUnitY(d.caster)
set d.distance = 350
set d.angle = 30
return d
endmethod
endstruct
//..function PolarProjectionBJ takes location source, real dist, real angle returns location
 //   local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
 //   local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)
 //   return Location(x, y)
//endfunction
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL
endfunction

private function Actions takes nothing returns nothing
local data d = data.create()
local integer i = 0
local real x 
local real y
loop
exitwhen i > 12
set d.x = d.x + d.distance * Cos(d.angle * i )
set d.y = d.y + d.distance * Sin(d.angle * i )
call DestroyEffect(AddSpecialEffect(EFFECT,d.x,d.y))
set i = i + 1
endloop
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t= CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(t,Condition(function Conditions))
    call TriggerAddAction( t, function Actions )
endfunction

endscope
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
JASS:
scope Fire initializer Init

globals
    private constant integer SPELL = 'A002'
    private constant string EFFECT = "Abilities\\Spells\\Human\\FlameStrike\\FlameStrike1.mdl"
endglobals

private struct data
    location CasterLoc
    unit caster
    real distance
    real angle
    real x
    real y
    static method create takes nothing returns data
        local data d = data.allocate()
        set d.caster = GetTriggerUnit()
        set d.x = GetUnitX(d.caster)
        set d.y = GetUnitY(d.caster)
        set d.distance = 350.
        set d.angle = 30.
        return d
    endmethod

    method onDestroy takes nothing returns nothing
        set .caster = null
    endmethod
endstruct

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == SPELL
endfunction

private function Actions takes nothing returns nothing
    local data d = data.create()
    local real i = 0.
    loop
        exitwhen i > 12.
        set d.x = d.x + d.distance * Cos((d.angle * i)  * bj_DEGTORAD )
        set d.y = d.y + d.distance * Sin((d.angle * i)  * bj_DEGTORAD )
        call DestroyEffect(AddSpecialEffect(EFFECT,d.x,d.y))
        set i = i + 1.
    endloop
    call d.destroy()
endfunction

//===========================================================================
private function Init takes nothing returns nothing
    local trigger t= CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(t,Condition(function Conditions))
    call TriggerAddAction( t, function Actions )
    set t = null
endfunction

endscope
 
Status
Not open for further replies.
Top