wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 06-13-2011, 01:31 PM   #1
Idontneedaname
User
 
Idontneedaname's Avatar
 
Join Date: Nov 2008
Posts: 61

Submissions (1)

Idontneedaname has little to show at this moment (6)

Default [JASS] Why does this script stop?

I have made a spell which should create an n-gon around the caster. But the script stops after the second corner for every n. Why is that?
(you can change the n in the trigger, it will change the number of sides)

Collapse JASS:
function floor takes real r returns real
    return R2I(r) //Yes, it's not needed. So what?
endfunction

function Create takes nothing returns nothing
    local location loc
    local integer n = 3
    local real a = 500.
    local real angle = udg_Winkel*bj_DEGTORAD
    local real pi = bj_PI
    local real r  = angle + ((pi - (2*pi/n))*floor(n*angle/(2*pi)))
    local real r1 = Sin(r)
    local real r2 = Sin((pi/2) + (pi/n) - r)
    local real dist = SquareRoot(((a*a*r1*r1)/(r2*r2))+(a*a)-((2*a*a*r1*Cos(((n-2)*pi)/(2*n)))/r2))
    local real x = GetUnitX(udg_caster) + dist * Cos(angle)
    local real y = GetUnitY(udg_caster) + dist * Sin(angle)
    call CreateUnit(Player(0), 'h000', x, y, 0.00)
    set udg_Winkel = udg_Winkel + 2.
    call DisplayTextToPlayer(Player(0), 0.00, 0.00, R2S(udg_Winkel))
    if udg_Winkel == 360. then
        call PauseTimer(GetExpiredTimer())
        call DestroyTimer(GetExpiredTimer())
    endif
endfunction

function Trig_Init_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'AHpx' then
        return true
    endif
    return false
endfunction

function Trig_Init_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    set udg_caster = GetSpellAbilityUnit()
    call TimerStart(t, 0.01, true, function Create)
endfunction

//===========================================================================
function InitTrig_Init takes nothing returns nothing
    set gg_trg_Init = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Init, EVENT_PLAYER_UNIT_SPELL_CHANNEL )
    call TriggerAddCondition( gg_trg_Init, Condition( function Trig_Init_Conditions ) )
    call TriggerAddAction( gg_trg_Init, function Trig_Init_Actions )
endfunction

Fünfeck.w3x
__________________

Thanks to Neonex for the idea.

Last edited by Idontneedaname : 06-13-2011 at 01:33 PM.
Idontneedaname is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 06-13-2011, 09:33 PM   #2
Captain Griffen
Dread Lord of the Cookies
 
Captain Griffen's Avatar


Content Director
 
Join Date: Sep 2003
Posts: 5,375

Submissions (2)

Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)Captain Griffen is a glorious beacon of light (497)

Approved Map: Warlords[Quicksilver #2] - 1st Place

Default

My guess would be r2=0, so divide by 0, but I cba to sort through all those horrible maths functions going from degrees to radians to degrees.
__________________
Quote:
Originally Posted by Earth-Fury
Griffen is correct, you are not.
Quote:
[13:32] <Akolyt0r> hmm.. stil i want to have some unused women
Captain Griffen is offline   Reply With Quote
Old 06-13-2011, 09:37 PM   #3
Idontneedaname
User
 
Idontneedaname's Avatar
 
Join Date: Nov 2008
Posts: 61

Submissions (1)

Idontneedaname has little to show at this moment (6)

Default

yes, the math is nice, isn't it?
So you say that a function can indeed stop at a division by zero? Here is an example for what happens for n = 3:



what confuses me is that the first corner works just fine (for every n!)
__________________

Thanks to Neonex for the idea.

Last edited by Idontneedaname : 06-13-2011 at 09:38 PM.
Idontneedaname is offline   Reply With Quote
Old 06-13-2011, 09:38 PM   #4
BBQ
User
 
Join Date: May 2011
Posts: 85

Submissions (2)

BBQ will become famous soon enough (30)BBQ will become famous soon enough (30)

Default

Yes, division by zero kills the thread.
BBQ is offline   Reply With Quote
Old 06-13-2011, 10:25 PM   #5
BBQ
User
 
Join Date: May 2011
Posts: 85

Submissions (2)

BBQ will become famous soon enough (30)BBQ will become famous soon enough (30)

Default

Heck, I read your code thoroughly and I couldn't see where the issue is. There is evidently no division by zero.

Anyway, I decided to test it, and it actually works as it should. No idea what's up with your map, as I can't open it (it's corrupted), but I can tell you that your code can only work with one instance, as it's not multi-instanceable due to those globals.


Last edited by BBQ : 06-13-2011 at 10:27 PM.
BBQ is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 05:27 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services