• 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] Another script problem. Damn!)

Status
Not open for further replies.
Level 2
Joined
Jun 18, 2008
Messages
6
Another script problem with moving in degrees interval. Damn!

I don't think that this problem caused by globals, so...

JASS:
struct MovinData    
unit missile
real dist
real d1        
real sin    
real cos
location end
endstruct

function interval takes nothing returns real
return 0.01
endfunction

function MoveP takes nothing returns nothing    
local MovinData md    
local integer i = 0    
local real x    
local real y    
loop        
exitwhen i >= Total        
set md = Ar[i]        
set x = GetUnitX(md.missile) + md.d1 * md.cos        
set y = GetUnitY(md.missile) + md.d1 * md.sin        
call SetUnitX(md.missile, x)        
call SetUnitY(md.missile, y)
call SetUnitPosition(md.missile,x,y)                
if GetUnitX(md.missile) >= GetLocationX(md.end) then            
call PauseUnit(md.missile, false)            
set Ar[i] = Ar[Total - 1]            
set Total = Total - 1            
call md.destroy()        
endif        
set i = i + 1    
endloop    
if Total == 0 then        
call PauseTimer(time)    
endif
endfunction

function Proj takes unit missile, real dist, real speed returns nothing    
local MovinData md = MovinData.create()    
local integer q
local real w = dist / speed
local real angle = AngleBetweenPoints(GetUnitLoc(GetSpellAbilityUnit()),GetSpellTargetLoc())
local location end = OffsetLocation(GetSpellTargetLoc(), dist*CosBJ(angle), dist*SinBJ(angle))
set md.end=end
set q = R2I(w / interval())    
set md.missile = missile
set md.d1 = 2 * dist / (q + 1)        
set md.sin = SinBJ(angle)    
set md.cos = CosBJ(angle)    
call SetUnitPosition(missile, GetUnitX(missile), GetUnitY(missile))    
call PauseUnit(missile, true)    
if Total == 0 then        
call TimerStart(time, interval(), true, function MoveP)    
endif    
set Total = Total + 1    
set Ar[Total - 1] = md
endfunction
In interval from 89.9 degrees to -89.9 this script work correctly(missile unit moving in right direction and speed). But in interval from 90 to -90 degrees missile unit even don't move!
Mb I just stupid and that's the problem :grin: but I want to know what causes this(not why I stupid, why unit don't want to move).
This is almost a piece of Silvenon's knockback tutorial(thanks him again). Almost. Hm!
 
Last edited:
Status
Not open for further replies.
Top