- Joined
- Oct 19, 2014
- Messages
- 187
I dont know if this is the right way to name this simple vjass system
Anyway this is poor because homing is not included XD..
Anyway this is poor because homing is not included XD..
JASS:
library CPP
/********************************************************************
*
* CUSTOM POLAR PROJECTION SYSTEM
* with addtional features
* Author: JC Helas
*
* System can be use to units and effects...AMEN...
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*********************************************************************/
struct CPP
private static constant real PERIODIC=0.031250
private static constant boolean END_HILLS=true
private static location zloc=Location(0.0,0.0)
private static timer tmr=CreateTimer()
private static integer ix=0
private static integer array ic
public static trigger array trig
private real dist
private real bdist
private real mdist
private real adeg
private real speed
private real dpitch//default
private real apitch//arc
private real defaultX
private real defaultY
private real previewsX
private real previewsY
private real zstart
private real zend
private real zdist
private real zarc
private real aarc
private integer cpp
private boolean onpitch
public static real EventCPP = 0.0
public static real EventCPPX = 0.0
public static real EventCPPY = 0.0
public static real EventCPPXA = 0.0
public static real EventCPPYA = 0.0
public static real EventCPPZ = 0.0
public static real EventCPPP = 0.0
public static real EventCPPR = 0.0
public static real EventCPPA = 0.0
public static integer EventCPPID = 0
public static integer EventCPPIX = 0
public static boolean EventCPPSTOP = false
public static method GetLocZ takes real x,real y returns real
call MoveLocation(zloc,x,y)
return GetLocationZ(zloc)
endmethod
public static method AngleBetweenXY takes real x1,real y1,real x2,real y2 returns real
return bj_RADTODEG * Atan2(y2 - y1, x2 - x1)
endmethod
public static method DistanceBetweenXY takes real x1,real y1,real x2,real y2 returns real
local real dx=x2-x1
local real dy=y2-y1
return SquareRoot(dx*dx+dy*dy)
endmethod
private static method Clear takes thistype this returns nothing
set speed=0.0
set defaultX=0.0
set defaultY=0.0
set adeg=0.0
set bdist=0.0
set zstart=0.0
set zend=0.0
set zdist=0.0
set zarc=0.0
set dpitch=0.0
set apitch=0.0
set dist=0.0
set cpp=0
endmethod
private static method Loop takes nothing returns nothing
local thistype this
local integer i=1
local real rate
local real sin
local real aarcs
loop
exitwhen i>ix
set this=ic[i]
if dist<mdist then
set EventCPPSTOP=false
set dist=dist+speed
set rate=(100.0/bdist)*dist
set sin=180.0/100.0
//Default Projection
set EventCPPX=defaultX+dist*Cos(adeg*bj_DEGTORAD)
set EventCPPY=defaultY+dist*Sin(adeg*bj_DEGTORAD)
//Angle Arc Projection
if aarc!=0.0 then
set aarcs=Sin((sin*rate)*bj_DEGTORAD)*aarc
set EventCPPXA=EventCPPX+aarcs*Cos((adeg+90.0)*bj_DEGTORAD)
set EventCPPYA=EventCPPY+aarcs*Sin((adeg+90.0)*bj_DEGTORAD)
set EventCPPA=AngleBetweenXY(previewsX,previewsY,EventCPPXA,EventCPPYA)
set previewsX=EventCPPXA
set previewsY=EventCPPYA
else
set EventCPPXA=EventCPPX
set EventCPPYA=EventCPPY
set EventCPPA=adeg
set previewsX=EventCPPXA
set previewsY=EventCPPYA
endif
//Z properties
set EventCPPZ=(zdist/100.0)*rate
//Z Arc
if zarc!=0.0 then
set EventCPPZ=EventCPPZ+(Sin((sin*rate)*bj_DEGTORAD)*zarc)
endif
//Location's Z
set EventCPPZ=EventCPPZ+(zstart-GetLocZ(EventCPPXA,EventCPPYA))
if END_HILLS and EventCPPZ<=0.0 then
set EventCPPSTOP=true
endif
//Pitch properties
if onpitch then
set EventCPPP=dpitch+(Sin((90.0+(sin*rate))*bj_DEGTORAD)*apitch)
if EventCPPP>180.0 then
set EventCPPP=180.0
elseif EventCPP<0.0 then
set EventCPPP=0.0
endif
else
set EventCPPP=90.0
endif
//Important data
set EventCPPID=cpp
set EventCPPIX=this
set EventCPPR=(100.0/mdist)*dist
call TriggerEvaluate(trig[cpp])
if EventCPPSTOP then
set dist=mdist
set EventCPPSTOP=false
endif
else
call deallocate(this)
set ic[i]=ic[ix]
set ix=ix-1
set i=i-1
if ix==0 then
call PauseTimer(tmr)
endif
endif
set i=i+1
endloop
endmethod
static method Create takes integer sections, real xstarts,real ystarts,real xends,real yends,real zstarts,real zends,real zarcs,real aarcs,real speeds,real dists,boolean pitch returns thistype
local thistype this=allocate()
local real bd
set ix=ix+1
set ic[ix]=this
set speed=speeds
set defaultX=xstarts
set defaultY=ystarts
set previewsX=xstarts
set previewsY=ystarts
set adeg=AngleBetweenXY(xstarts,ystarts,xends,yends)
set bdist=DistanceBetweenXY(xstarts,ystarts,xends,yends)
set zstart=GetLocZ(xstarts,ystarts)+zstarts
set zend=GetLocZ(xends,yends)+zends
set zdist=zend-zstart
set zarc=zarcs
set aarc=aarcs
if pitch then
set bd=bdist/2.0
set dpitch=90.0+((45.0/bd)*(zdist/2.0))
if bdist<aarcs then
set bd=bd+(aarcs-bd)
endif
set apitch=(45.0/bd)*zarcs
else
set dpitch=90.0
set apitch=0.0
endif
set onpitch=pitch
set dist=0.0
set cpp=sections
if dists!=0.0 then
set mdist=dists
else
set mdist=bdist
endif
if ix==1 then
call TimerStart(tmr,PERIODIC,true,function thistype.Loop)
endif
return this
endmethod
public static method RegisterAction takes integer section,code func returns nothing
if trig[section]==null then
set trig[section]=CreateTrigger()
endif
call TriggerAddCondition(trig[section],Filter(func))
endmethod
endstruct
endlibrary