06132011, 01:31 PM  #1 
User
Join Date: Nov 2008
Posts: 61

[JASS] Why does this script stop?
I have made a spell which should create an ngon 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) 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(((n2)*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 Last edited by Idontneedaname : 06132011 at 01:33 PM. 
Sponsored Links  Login to hide this ad! 

06132011, 09:33 PM  #2 
Dread Lord of the Cookies
Content Director

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.
__________________ 
06132011, 09:37 PM  #3 
User
Join Date: Nov 2008
Posts: 61

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!) Last edited by Idontneedaname : 06132011 at 09:38 PM. 
06132011, 09:38 PM  #4 
User
Join Date: May 2011
Posts: 85

Yes, division by zero kills the thread.

06132011, 10:25 PM  #5 
User
Join Date: May 2011
Posts: 85

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 multiinstanceable due to those globals. Last edited by BBQ : 06132011 at 10:27 PM. 
Thread Tools  Search this Thread 

