• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJASS]Math/Spell Problem

Status
Not open for further replies.
Level 8
Joined
Feb 15, 2009
Messages
463
hey guys im trying to create a spiral spell which goes outside-in in begin it moves correctly inside and furthermore.. but the last thingies are never at the center but still about 200 range away also in myopinion the value Polar Project +0 comes out so it should be the center but it isnt
JASS:
globals
////////////////////////////////////////CONFIGURATION////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    private constant integer SPELL_ID = 'A000'
    //The Id of the Spell used by your Hero
    private constant integer MAX_EFFECT = 100
    //How many Effects are created
    private constant real START_DISTANCE = 600.
    //How far from the caster the 1st Effect is created
    private constant real ANGLE_DECREMENT = 10.
    //How much the next Angle differs from the previous one
    private constant real START_HEIGHT = 600.
    //In which Height the 1st Effect is created
    private constant real HEIGHT_DECREMENT = 10.
    //How much Height is lost per Intervall?
    private constant real TIMER_INTERVALL = 0.03
    
    private constant string SHADOW_FX = "Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl"
    //The Model of every Spiraleffect
////////////////////////////////////////////////END///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
endglobals
JASS:
private function Callback takes nothing returns nothing
    local Spiral e = GetTimerData(GetExpiredTimer())
    local location l
    
    if e.counter > MAX_EFFECT then
    call ReleaseTimer(GetExpiredTimer())
    set e.counter = 0
    call e.destroy()
    else
    
    set e.angle = (360. - ANGLE_DECREMENT) * bj_DEGTORAD * e.counter
    set e.cos = Cos(e.angle)
    set e.sin = Sin(e.angle)
    set e.x = e.sx + (START_DISTANCE - (RANGE_DECREMENT * e.counter)) * e.cos
    set e.y = e.sy + (START_DISTANCE - (RANGE_DECREMENT * e.counter)) * e.sin
    set e.faceangle = Atan2( e.sy - e.y , e.sx - e.x)
    set l = Location(e.x , e.y)
    set e.z = GetLocationZ(l) + (START_HEIGHT - HEIGHT_DECREMENT * e.counter)
    set e.shadow[e.counter] = xefx.create( e.x , e.y , e.faceangle )
    set e.shadow[e.counter].fxpath = SHADOW_FX
    set e.shadow[e.counter].z = e.z
    
    call RemoveLocation(l)
    set l = null
    set e.counter = e.counter + 1
    endif
endfunction
JASS:
private function Conditions takes nothing returns boolean
    local unit u
    local timer t
    local Spiral sp
    
    if GetSpellAbilityId() == SPELL_ID then
    
    set u = GetSpellAbilityUnit()
    set t = NewTimer()
    set sp = Spiral.create()
    set sp.sx = GetUnitX(u)
    set sp.sy = GetUnitY(u)
    //set sp.x = sp.sx + START_DISTANCE
    //set sp.y = sp.sy + START_DISTANCE
    
    call SetTimerData( t , sp)
    call TimerStart(t , TIMER_INTERVALL , true , function Callback)

    endif
    
    return false
endfunction

The rest is not interesting i hope you can figure out the problem in my formula i tried it now for about 2 hours and i am to idiotic
i created spiral spells before and they were correct but here i have probs

also feel free to comment the rest concerning efficiency , performance etc....

Saia_Djinn
+Rep for every answer that helps for sure
 
Level 17
Joined
Sep 8, 2007
Messages
994
Maybe it isn't even a maths problem. I guess this may be the problem:
JASS:
local Spiral e = GetTimerData(GetExpiredTimer())
I suggest you change this to
JASS:
local Spiral e = <STRUCTNAME>(GetTimerData(GetExpiredTimer()))

What I also find strange is this, in your condition:
JASS:
set sp = Spiral.create()
do you probably mean this?:
JASS:
set sp = Spiral.allocate()
All in all it is pretty crazy defining the stuff outside the create method. It would be safer to set all the stuff in the create method.

Any corrections are welcome .... though, I suggest you post all of the code.

Oh, and btw. You leak a unit handle in the condition. Better nullify it.
 
Level 8
Joined
Feb 15, 2009
Messages
463
The thing is the spell works and also till the end but the effects dont come till the caster position that is my problem
i will make the suggestions u gave
but before i attach old map so u can have a quick look on how it works and test it yourself:thumbs_up:
Spell is under Category WIP and name is Spiral of Shadows(the current fx was just for test) u see the z thingie best if you scroll down to nearly rpg view =D
 

Attachments

  • SpellWorking.w3x
    105.5 KB · Views: 50
Level 17
Joined
Mar 17, 2009
Messages
1,349
xxdingo93xx said:
What I also find strange is this, in your condition:
JASS:
set sp = Spiral.create()
do you probably mean this?:
JASS:
set sp = Spiral.allocate()
You use .allocate() only inside the create method. Whenever used outside the struct, you use .create()

And I'll check the WIP later :) I've used a spiral in my first spell Comradeship... you might want to take a look (although it's GUI :s).
 
Level 8
Joined
Feb 15, 2009
Messages
463
the spiral works although it never comes till the caster pos which should be if i go after the formula that is my only problem
leaks etc. are treated afterwards(e.g. the location thing i will rahter use a global and move it then always create)
 
Status
Not open for further replies.
Top