killingdyl
Active Member
- Reaction score
- 6
Shape Creator 3.1
Hello people of thehelper.net. First off i want to explain that Lord_Executor has asked me to continue this system because he lost interest.
Announcements:
Description:
Screenshots(Coming Soon!):
Interface:
Code:
Example Usage:
Changelog:
TESH:
More shapes soon to come. I would love suggestions
Shape Creator 3.1
vJass, sys independent (optional TimerUtils), MI
by Executor alias Lord_Executor
tookover by Killingdyl
by Executor alias Lord_Executor
tookover by Killingdyl
Hello people of thehelper.net. First off i want to explain that Lord_Executor has asked me to continue this system because he lost interest.
I made a new thread because it would be a lot easier to edit and post updates.I actually lost my motivation on this project. If you like, you can continue it for me. You can completely have the code, but I want still to be in credits .
Announcements:
I will be adding small updates until this thread gets more views. When the view count satisfy me (300-500) i will introduce a more complex shape!
Description:
This library allows you to work easily with various shapes. You simply choose the shape you want, define the number of points you need and define the callback function, which will be called for every single point of the shape. Of course there are more parameters than only number of points and callback function, but this shall help understand how my system works.
Screenshots(Coming Soon!):
Coming Soon!
Interface:
JASS:
// Shaper Interface
//
// Shape.createLine(real sx, real sy, real sz,
// real xyAngle, real zAngle,
// real distance, integer count,
// real interval,
// usrfunc periodic, usrfunc final)
//
// Shape.createEllipsis(real mx, real my, real mz,
// real sAngle, real xyAngle, real zAngle,
// real r1, real r2, integer count,
// integer dir, real interval,
// usrfunc periodic, usrfunc final)
//
// Shape.createSquare(real mx, real my, real mz,
// real angleToStartCorner, real zAngle,
// real edgeLength, integer countPerEdge,
// integer dir, real interval,
// usrfunc periodic, usrfunc final)
//
//
// Shape.createIntersectedStarPolygon(real mx, real my, real mz,
// real angleToStartCorner, real zAngle,
// real r, integer corners, integer countPerEdge,
// integer dir, real interval,
// usrfunc periodic, usrfunc final)
//
// Shape.createNonIntersectedStarPolygon(real mx, real my, real mz,
// real angleToStartCorner, real zAngle,
// real r, integer corners, integer countPerEdge,
// integer dir, real interval,
// usrfunc periodic, usrfunc final)
//
// Shape.createCycloid(real sx, real sy, real sz, real sAngle, real xyAngle,
// real zAngle, real r, integer countPerloops,
// integer loops, integer dir, real interval,
// usrfunc periodic, usrfunc final)
//
// Shape.createHypocycloid (real mx, real my, real mz, real sAngle,
// real xyAngle, real zAngle, real R, real points,
// real rotations, integer count, integer dir,
// real interval, usrfunc periodic, usrfunc final)
//
// set Instance.limit = integer
// set integer = Instance.limit
// limit equals the total points being calculated. Setting limit to limit*2 (after you called the create func of course)
// will result in the shape to be drawn two times one after the other...
//
// call Instance.stop()
// stops the shape-creation and erases the instance.
Code:
JASS:
//======================================================================
//====______====___=====___=======____========________====____________==
//===/ \==| |===| |====/ \=====/ ____ \==| |=
//==/ \=| |===| |===/ \===| |===| |=| |=
//=| | |=| |===| |==/ ___ \==| |===| |=| _______|=
//=| \ |=| |===| |=| |===| |=| |===| |=| |=========
//=| \ /==| |___| |=| |===| |=| |___| |=| |____=====
//==\ \/===| |=| |___| |=| ______/==| |====
//===\ \===| ___ |=| |=| |=========| ____|====
//==/ \ \==| |===| |=| ___ |=| |=========| |=========
//=| \ |=| |===| |=| |===| |=| |=========| |=========
//=| | |=| |===| |=| |===| |=| |=========| |_______==
//=| | |=| |===| |=| |===| |=| |=========| |=
//==\ /==| |===| |=| |===| |=| |=========| |=
//===\_____/===|___|===|___|=|___|===|___|=|___|=========|____________|=
//======================================================================
//===============================CREATOR================================
//===============================Version================================
//=============================== 3.0 ================================
//======================================================================
//= Made by Lord_Executor =
//= TookOver by Killingdyl =
//======================================================================
//======================================================================
// Desc:
// This library allows you to easily loop through shapes
// You can for example damage in a line, create effect pentagramms,
// create unit circles, etc.
//
// How to:
//
// All angles should be in radians!
// Please use bj_DEGTORAD * angle(degrees) and store it as a variable.
//
// sx : source x sy : source y sz : source z mx : mid x my : mid y mz : mid z
//
// interval: time between each step
// periodic: this code will be fired each step
// final: this code will on the last step, if final == 0 then periodic will be fired
//
//
// Line:
//
// Shape.createLine(real sx, real sy, real sz, real xyAngle, real zAngle, real distance,
// integer count, real interval, usrfunc periodic, usrfunc final)
//
// xyAngle: in which direction the line shall be created
// zAngle: angle between xy-plane and the line
// distance: the length of the line
// count: how many steps till end of the line
//
// Circle:
//
// Shape.createEllipsis takes real mx, real my, real mz, real r1, real r2, real sAngle, real xyAngle,
// real zAngle, integer dir,integer count, real interval, usrfunc periodic, usrfunc final)
//
// r1: first radius
// r2: second radius
//
// sAngle: angle to the first point of the circle, 90° will be the most northern point
// zAngle: angle between xy-plane and the ellipsis-plane
// xyAngle: where the point with the lowest z-value shall point at, relative to the mid
// direction: clockwise or not clockwise? 1 or -1
// count: how many steps till the circle is finished
//
// StarPolygons:
//
// <a href="http://upload.wikimedia.org/wikipedia/commons/9/96/Regular_Star_Polygons.jpg" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://upload.wikimedia.org/wikipedia/commons/9/96/Regular_Star_Polygons.jpg</a>
// You can create the far left and the far right diagonal chain
//
// Far left chain/ IntersectedStarPolygons:
//
// Shape.createIntersectedStarPolygon takes real mx, real my, real mz, real angleToStartCorner, integer corners,
// real r, real zAngle, integer dir, integer countPerEdge, real interval, usrfunc periodic, usrfunc final)
//
// Far right diagonal chain/ NonIntersectedStarPolygons:
//
// Shape.createNonIntersectedStarPolygon takes real mx, real my, real mz, real angleToStartCorner, integer corners,
// real r, real zAngle, integer dir, integer countPerEdge, real interval, usrfunc periodic, usrfunc final)
//
// angleToStartCorner: angle to the first corner
// corners: how many corners?
// r: radius of the circumcircle
// zAngle: angle between the xy-plane and the plane of the shape
// dir: direction of the shape creation, +1 or -1
// countPerEdge: steps each edge
// interval: time between each step
// code: this code will be fired each step
//
// Cycloids:
// Shape.createCycloid takes real sx, real sy, real sz, real sAngle, real xyAngle, real zAngle,
// real r, integer countPerloops, integer loops, integer dir, real interval, usrfunc periodic, usrfunc final returns thistype
//
// sAngle: start angle
// r: radius
// countPerloops: number of points in a loop
// loops: number of loops (This being too high and casting the spell next to the boundary might bug unit out)
// dir: direction of the shape creation, +1 or -1
// interval: time between each points
//
// Hypocycloids:
// Use this website <a href="http://www-groups.dcs.st-and.ac.uk/~history/Java/Hypocycloid.html" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://www-groups.dcs.st-and.ac.uk/~history/Java/Hypocycloid.html</a> to see the basic shapes
// Shape.createHypocycloid takes real mx, real my, real mz, real sAngle, real xyAngle, real zAngle,
// real R, real points, real rotations, integer count, integer dir, real interval, usrfunc periodic, usrfunc final
//
// sAngle: start angle
// R: radius
// points: points on the shape (a)
// rotations: how many rotations (b)
// count: number of points in the shape (recommended about 180 per rotation)
// dir: direction of the shape creation, +1 or -1
// interval: time between each points (recommended 0.01-)
// usrfunc issues:
//
// The code has to take nothing and returns nothing
// When in the usrfunc you may use Shape.getData() to return the "triggering" Shape instance
// Aswell as .x and .y as parameters for the current step + .customValue (integer) for attaching
//
// Have Fun!
//DO NOT TOUCH ANYTHING BELOW THIS LINE!!!!!!!!!
//VERY DELICATE CODING!!!!!!!!!
//========================================================================================================
library ShapeCreator requires optional TimerUtils
private function interface usrfunc takes Shape sp returns nothing
private function interface flusher takes integer this returns nothing
private struct LineData
real vx
real vy
real vz
//! runtextmacro ShapeCreator_Flush()
endstruct
private struct EllipsisData
real modAngle
real currAngle
real cosB
real sinB
real cosA
real sinA
real r1
real r2
//! runtextmacro ShapeCreator_Flush()
endstruct
private struct StarPolygonData
integer remPointsOnStage
integer pointsPerStage
real modAngle
real currAngle
real vx
real vy
real vz
real tx
real ty
real tz
real cosB
real sinB
real cosA
real sinA
real offset
//! runtextmacro ShapeCreator_Flush()
endstruct
private struct CycloidData
real r
real currAngle
real modAngle
real cosB
real sinB
real cosA
real sinA
//! runtextmacro ShapeCreator_Flush()
endstruct
private struct HypocycloidData
real R
real k
real r
real currAngle
real modAngle
real cosB
real sinB
real cosA
real sinA
//! runtextmacro ShapeCreator_Flush()
endstruct
struct Shape
real x
real y
real z
integer customValue
real sx
real sy
real sz
private integer remPoints
private integer shapeData
private flusher flushData
private usrfunc periodic
private usrfunc final
private timer intervalTimer
private static constant real PI2 = 2*bj_PI
private static constant real PIDiv2 = bj_PI/2
static if not LIBRARY_TimerUtils then
private static hashtable link
private static method onInit takes nothing returns nothing
set .link = InitHashtable()
endmethod
endif
method stop takes nothing returns nothing
call .flushData.evaluate(.shapeData)
call .destroy()
endmethod
method operator limit takes nothing returns integer
return .remPoints
endmethod
method operator limit= takes integer i returns nothing
set .remPoints = i
endmethod
private static method onPause takes nothing returns nothing
//! runtextmacro ShapeCreator_GetInstance()
call .flushData.evaluate(.shapeData)
call .destroy()
endmethod
private static method onCreateLineTimer takes nothing returns nothing
//! runtextmacro ShapeCreator_GetInstance()
local LineData d = .shapeData
set .x = .x + d.vx
set .y = .y + d.vy
set .z = .z + d.vz
//! runtextmacro ShapeCreator_ReleaseInstance()
endmethod
static method createLine takes real sx, real sy, real sz, real xyAngle, real zAngle, real distance, integer count, real interval, usrfunc periodic, usrfunc final returns thistype
local thistype this = thistype.allocate()
local real offset = distance/(count-1)
local real cosB = Cos(xyAngle-.PIDiv2)
local real sinB = Sin(xyAngle-.PIDiv2)
local real cosA = Cos(zAngle)
local real sinA = Sin(zAngle)
local real fac = cosA * offset
//! runtextmacro ShapeCreator_VarSetup("Line")
set .remPoints = count
set .sx = sx
set .sy = sy
set .sz = sz
set d.vx = -sinB * fac
set d.vy = cosB * fac
set d.vz = sinA * offset
set .x = sx - d.vx
set .y = sy - d.vy
set .z = sz - d.vz
//! runtextmacro ShapeCreator_TimerSetup("Line","periodic","final")
return this
endmethod
private static method onCreateEllipsisTimer takes nothing returns nothing
//! runtextmacro ShapeCreator_GetInstance()
local EllipsisData d = .shapeData
local real vx = d.r1 * Cos(d.currAngle)
local real vy = d.r2 * Sin(d.currAngle)
local real fac = d.cosA * vy
set .x = .sx + d.cosB * vx - d.sinB * fac
set .y = .sy + d.sinB * vx + d.cosB * fac
set .z = .sz + d.sinA * vy
set d.currAngle = d.currAngle + d.modAngle
//! runtextmacro ShapeCreator_ReleaseInstance()
endmethod
static method createEllipsis takes real mx, real my, real mz, real sAngle, real xyAngle, real zAngle,/*
*/real r1, real r2,integer count, integer dir, real interval, usrfunc periodic, usrfunc final returns thistype
local thistype this = thistype.allocate()
//! runtextmacro ShapeCreator_VarSetup("Ellipsis")
set .remPoints = count
set .sx = mx
set .sy = my
set .sz = mz
set xyAngle = xyAngle - .PIDiv2
set d.currAngle = sAngle
set d.cosB = Cos(xyAngle)
set d.sinB = Sin(xyAngle)
set d.cosA = Cos(zAngle)
set d.sinA = Sin(zAngle)
set d.r1 = r1
set d.r2 = r2
set d.modAngle = .PI2/(count) * dir
//! runtextmacro ShapeCreator_TimerSetup("Ellipsis","periodic","final")
endmethod
private static method onCreateStarPolygonTimer takes nothing returns nothing
//! runtextmacro ShapeCreator_GetInstance()
local StarPolygonData d = .shapeData
local real fac = 0
local real ux = 0
local real uy = 0
if d.pointsPerStage == 0 then
set d.remPointsOnStage = d.remPointsOnStage
set d.pointsPerStage = d.remPointsOnStage - 1
return
endif
set .x = .x + d.vx
set .y = .y + d.vy
set .z = .z + d.vz
set d.remPointsOnStage = d.remPointsOnStage - 1
if d.remPointsOnStage < 1 then
set d.currAngle = d.currAngle+d.modAngle
set ux = Cos(d.currAngle) * d.offset
set uy = Sin(d.currAngle) * d.offset
set fac = d.cosA * uy
set d.vx = d.cosB * ux - d.sinB * fac
set d.vy = d.sinB * ux + d.cosB * fac
set d.vz = d.sinA * uy
set d.remPointsOnStage = d.pointsPerStage
endif
//! runtextmacro ShapeCreator_ReleaseInstance()
endmethod
static method createIntersectedStarPolygon takes real mx, real my, real mz, real angleToStartCorner, real zAngle, real r,/*
*/integer corners, integer countPerEdge, integer dir, real interval, usrfunc periodic, usrfunc final returns thistype
local thistype this = thistype.allocate()
local real edgeLength = 0
local real fac = 0
local real ux = 0
local real uy = 0
//! runtextmacro ShapeCreator_VarSetup("StarPolygon")
set .remPoints = countPerEdge * corners - corners
set d.remPointsOnStage = countPerEdge
set .sx = mx
set .sy = my
set .sz = mz
set angleToStartCorner = angleToStartCorner - .PIDiv2
set d.cosB = Cos(angleToStartCorner)
set d.sinB = Sin(angleToStartCorner)
set d.cosA = Cos(zAngle)
set d.sinA = Sin(zAngle)
set d.pointsPerStage = 0
set d.modAngle = bj_PI-bj_PI/corners
set edgeLength = SquareRoot(2*r*r*(1-Cos(d.modAngle)))
set d.modAngle = d.modAngle * dir
set d.currAngle = bj_PI+(d.modAngle/2)
set d.offset = edgeLength/(countPerEdge-1) * dir
set uy = r
set fac = d.cosA * uy
set .x = mx - d.sinB * fac
set .y = my + d.cosB * fac
set .z = mz + d.sinA * uy
set ux = Cos(d.currAngle) * d.offset
set uy = Sin(d.currAngle) * d.offset
set fac = d.cosA * uy
set d.vx = d.cosB * ux - d.sinB * fac
set d.vy = d.sinB * ux + d.cosB * fac
set d.vz = d.sinA * uy
set .x = .x - d.vx
set .y = .y - d.vy
set .z = .z - d.vz
//! runtextmacro ShapeCreator_TimerSetup("StarPolygon","periodic","final")
endmethod
static method createNonIntersectedStarPolygon takes real mx, real my, real mz, real angleToStartCorner, real zAngle, real r,/*
*/integer corners, integer countPerEdge, integer dir, real interval, usrfunc periodic, usrfunc final returns thistype
local thistype this = thistype.allocate()
local real edgeLength = 0
local real fac = 0
local real ux = 0
local real uy = 0
//! runtextmacro ShapeCreator_VarSetup("StarPolygon")
set .remPoints = countPerEdge * corners - corners
set d.remPointsOnStage = countPerEdge
set .sx = mx
set .sy = my
set .sz = mz
set angleToStartCorner = angleToStartCorner - .PIDiv2
set d.cosB = Cos(angleToStartCorner)
set d.sinB = Sin(angleToStartCorner)
set d.cosA = Cos(zAngle)
set d.sinA = Sin(zAngle)
set d.pointsPerStage = 0
set d.modAngle = .PI2/corners
set edgeLength = 2*r * Sin(d.modAngle/2)
set d.modAngle = d.modAngle * dir
set d.currAngle = bj_PI+(d.modAngle/2)
set d.offset = edgeLength/(countPerEdge-1) * dir
set uy = Sin(.PIDiv2) * r
set fac = d.cosA * uy
set .x = mx - d.sinB * fac
set .y = my + d.cosB * fac
set .z = mz + d.sinA * uy
set ux = Cos(d.currAngle) * d.offset
set uy = Sin(d.currAngle) * d.offset
set fac = d.cosA * uy
set d.vx = d.cosB * ux - d.sinB * fac
set d.vy = d.sinB * ux + d.cosB * fac
set d.vz = d.sinA * uy
set .x = .x - d.vx
set .y = .y - d.vy
set .z = .z - d.vz
//! runtextmacro ShapeCreator_TimerSetup("StarPolygon","periodic","final")
endmethod
static method createSquare takes real mx, real my, real mz, real angleToStartCorner, real zAngle, real edgeLength,/*
*/integer countPerEdge, integer dir, real interval, usrfunc periodic, usrfunc final returns thistype
local real e2 = edgeLength*edgeLength
return .createNonIntersectedStarPolygon(mx,my,mz,angleToStartCorner,zAngle,0.5*SquareRoot(2*e2),4,countPerEdge,dir,interval,periodic,final)
endmethod
static method onCreateHypocycloidTimer takes nothing returns nothing
//! runtextmacro ShapeCreator_GetInstance()
local HypocycloidData d = .shapeData
local real vx = (d.r * (d.k - 1) * Cos(d.currAngle)) + (d.r * Cos(((d.k - 1) * d.currAngle)))
local real vy = (d.r * (d.k - 1) * Sin(d.currAngle)) - (d.r * Sin(((d.k - 1) * d.currAngle)))
local real fac = d.cosA * vy
set .x = .sx + d.cosB * vx - d.sinB * fac
set .y = .sy + d.sinB * vx + d.cosB * fac
set .z = .sz + d.sinA * vy
set d.currAngle = d.currAngle + d.modAngle
//! runtextmacro ShapeCreator_ReleaseInstance()
endmethod
static method createHypocycloid takes real mx, real my, real mz, real sAngle, real xyAngle, real zAngle,/*
*/real R, real points, real rotations, integer count, integer dir, real interval, usrfunc periodic, usrfunc final returns thistype
local thistype this = thistype.allocate()
//! runtextmacro ShapeCreator_VarSetup("Hypocycloid")
set .remPoints = count
set .sx = mx
set .sy = my
set .sz = mz
set xyAngle = xyAngle - .PIDiv2
set d.currAngle = sAngle
set d.cosB = Cos(xyAngle)
set d.sinB = Sin(xyAngle)
set d.cosA = Cos(zAngle)
set d.sinA = Sin(zAngle)
set d.R = R
set d.k = points/rotations
set d.r = d.R/d.k
set d.modAngle = (rotations * .PI2)/(count) * dir
//! runtextmacro ShapeCreator_TimerSetup("Hypocycloid","periodic","final")
endmethod
static method onCreateCycloidTimer takes nothing returns nothing
//! runtextmacro ShapeCreator_GetInstance()
local CycloidData d = .shapeData
local real vx = d.r * (d.currAngle - Sin(d.currAngle))
local real vy = d.r * (1 - Cos(d.currAngle))
local real fac = d.cosA * vy
set .x = .sx + d.cosB * vx - d.sinB * fac
set .y = .sy + d.sinB * vx + d.cosB * fac
set .z = .sz + d.sinA * vy
set d.currAngle = d.currAngle + d.modAngle
//! runtextmacro ShapeCreator_ReleaseInstance()
endmethod
static method createCycloid takes real sx, real sy, real sz, real sAngle, real xyAngle, real zAngle,/*
*/real r, integer countPerloops, integer loops, integer dir, real interval, usrfunc periodic, usrfunc final returns thistype
local thistype this = thistype.allocate()
//! runtextmacro ShapeCreator_VarSetup("Cycloid")
set .remPoints = loops * countPerloops
set .sx = sx
set .sy = sy
set .sz = sz
set xyAngle = xyAngle - .PIDiv2
set d.currAngle = sAngle
set d.cosB = Cos(xyAngle)
set d.sinB = Sin(xyAngle)
set d.cosA = Cos(zAngle)
set d.sinA = Sin(zAngle)
set d.r = r
set d.modAngle = (.PI2 / countPerloops) * dir
//! runtextmacro ShapeCreator_TimerSetup("Cycloid","periodic","final")
endmethod
//! textmacro ShapeCreator_GetInstance
static if LIBRARY_TimerUtils then
local thistype this = GetTimerData(GetExpiredTimer())
else
local thistype this = LoadInteger(.link,GetHandleId(GetExpiredTimer()),0)
endif
//! endtextmacro
//! textmacro ShapeCreator_ReleaseInstance
set .remPoints = .remPoints- 1
if .remPoints< 1 then
call PauseTimer(.intervalTimer)
call TimerStart(.intervalTimer,0.,false,function thistype.onPause)
if .final != 0 then
call .final.evaluate(this)
return
endif
endif
call .periodic.evaluate(this)
//! endtextmacro
//! textmacro ShapeCreator_Flush
static method flush takes integer i returns nothing
call thistype(i).destroy()
endmethod
//! endtextmacro
//! textmacro ShapeCreator_VarSetup takes FUNCNAME
local $FUNCNAME$Data d = $FUNCNAME$Data.create()
set .shapeData = d
set .flushData = $FUNCNAME$Data.flush
//! endtextmacro
//! textmacro ShapeCreator_TimerSetup takes FUNCNAME, PERIODIC, FINAL
static if LIBRARY_TimerUtils then
if .intervalTimer == null then
set .intervalTimer = NewTimer()
endif
call SetTimerData(.intervalTimer,this)
else
if .intervalTimer == null then
set .intervalTimer = CreateTimer()
endif
call SaveInteger(.link,GetHandleId(.intervalTimer),0,this)
endif
set .periodic = $PERIODIC$
set .final = $FINAL$
call TimerStart(.intervalTimer,interval,true,function thistype.onCreate$FUNCNAME$Timer)
return this
//! endtextmacro
endstruct
endlibrary
Example Usage:
JASS:
scope DarkFrenzy initializer Init
private function Radius takes integer lvl returns real
return 400. + lvl * 35.
endfunction
private function Duration takes integer lvl returns real
return 12.
endfunction
private function ArcherAmount takes integer lvl returns integer
return 5 * lvl
endfunction
globals
private constant string LIGHTNING_TYPE = "AFOD"
private constant integer ARCHER_ID = 039;n000039;
private constant integer DUMMY_ID = 039;ewsp039;
endglobals
// End Config
globals
private real sx
private real sy
private real ox
private real oy
private boolean first
private lightning array sfx
private integer max
private timer tim
private unit dummy
private integer lvl
endglobals
private function endDarkFrenzy takes nothing returns nothing
local integer i = 0
loop
exitwhen i == max
call DestroyLightning(sfx<i>)
set i = i + 1
endloop
set max = 0
call RemoveUnit(dummy)
endfunction
private function createFinalLightning takes Shape sp returns nothing
set sfx[max] = AddLightningEx(LIGHTNING_TYPE,false,ox,oy,0.,sp.x,sp.y,0.)
set max = max + 1
set sfx[max] = AddLightningEx(LIGHTNING_TYPE,false,sx,sy,0.,sp.x,sp.y,0.)
set max = max + 1
endfunction
private function createLightning takes Shape sp returns nothing
if first then
set first = false
set sx = sp.x
set sy = sp.y
else
set sfx[max] = AddLightningEx(LIGHTNING_TYPE,false,ox,oy,0.,sp.x,sp.y,0.)
set max = max + 1
endif
set ox = sp.x
set oy = sp.y
endfunction
private function createKnot takes Shape sp returns nothing
local unit u = GenerateDummy(sp.x,sp.y,sp.z,DUMMY_ID,Duration(lvl))
call SetUnitVertexColor(u,255,0,0,255)
endfunction
private function createArcher takes Shape sp returns nothing
local unit u = GenerateDummy(sp.x,sp.y,sp.z,ARCHER_ID,Duration(lvl))
call IssueImmediateOrder(u,"holdposition")
endfunction
private function onCast takes nothing returns boolean
local unit u = null
local real x = 0
local real y = 0
if GetSpellAbilityId() != 039;A002039; then
return false
endif
set u = GetTriggerUnit()
set x = GetUnitX(u)
set y = GetUnitY(u)
set lvl = GetUnitAbilityLevel(u,039;A002039;)
set first = true
set dummy = GenerateDummy(x,y,99999.,039;ewsp039;,9999.)
call UnitAddAbility(dummy,039;A003039;)
call SetUnitAbilityLevel(dummy,039;A003039;,lvl)
call Shape.createHypocycloid(x,y,300,0.,0.,0.,400.,5.,3.,180,1,0.005,createKnot,0)
call TimerStart(tim,Duration(lvl),false,function endDarkFrenzy)
return false
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterUnitEvent(t,HERO,EVENT_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function onCast))
set tim = CreateTimer()
set max = 0
endfunction
endscope</i>
Changelog:
v3.1: Added Cycloid creations
v3.0: Takeover; Introduced Hypocycloid creations
v2.2: Renamed from "Shaper" to "Shape Creator"; Updated some descriptions; Added Square-wrapper
v2.1: Cleaned up the code; Added Instance.stop(); Reorganized function parameters
v2.0: 3D-Upgrade
v1.1: Added optional TimerUtils usage
v1.0: Release
v3.0: Takeover; Introduced Hypocycloid creations
v2.2: Renamed from "Shaper" to "Shape Creator"; Updated some descriptions; Added Square-wrapper
v2.1: Cleaned up the code; Added Instance.stop(); Reorganized function parameters
v2.0: 3D-Upgrade
v1.1: Added optional TimerUtils usage
v1.0: Release
TESH:
I have included a TESH file for highlighting.
How to use:
1. Open up a blank text file and place this code in.
2. Save the file as a .j and place it in the correct folder.
3. Type in "Shape." then create'SHAPE'
P.S. It will autocomplete, and show the arguments needed, but will NOT highlight.
4. Input all of the take values
How to use:
1. Open up a blank text file and place this code in.
JASS:
//
// _____ ___ ___ _ _
// |_ _| __/ __| |_| |
// | | | _|\__ \ _ |
// |_| |___|___/_| |_| Highlighting:
// ShapeCreator-Killingdyl
// Original System-Lord_Executor
//
// What is this?
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Implementing this allows the TESH syntax highlighter in Jass NewGen
// to highlight the syntax for this system (and autocomplete the functions).
//
// How to import?
// ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
// Copy this into a blank text file, and save it at:
// <Your Jass NewGen folder>\tesh\includes\ShapeCreator.j
//
function createLine takes real sx, real sy, real sz, real xyAngle, real zAngle, real distance, integer count, real interval, usrfunc periodic, usrfunc final returns real x, real y, real z
//sx : source x
//sy : source y
//sz : source z
//xyAngle : in which direction the line shall be created
//zAngle : angle between xy-plane and the line
//distance : the length of the line
//count : how many steps till end of the line
//interval : time between each step
//periodic : this code will be fired each step
//final : this code will on the last step, if final == 0 then periodic will be fired
endfunction
function createEllipsis takes real mx, real my, real mz, real r1, real r2, real sAngle, real xyAngle, real zAngle, integer dir,integer count, real interval, usrfunc periodic, usrfunc final returns real x, real y, real z
//mx : middle x
//my : middle y
//mz : middle z
//r1 : first radius
//r2 : second radius
//sangle : angle to the first point of the circle, 90° will be the most northern point
//xyAngle : in which direction the ellipsis shall be created
//zAngle : angle between xy-plane and the ellipsis
//dir : clockwise or not clockwise? 1 or -1
//count : how many steps till end of the ellipsis
//interval : time between each step
//periodic : this code will be fired each step
//final : this code will on the last step, if final == 0 then periodic will be fired
endfunction
function createIntersectedStarPolygon takes real mx, real my, real mz, real angleToStartCorner, integer corners, real r, real zAngle, integer dir, integer countPerEdge, real interval, usrfunc periodic, usrfunc final returns real x, real y, real z
//mx : middle x
//my : middle y
//mz : middle z
//angleToStartCorner : angle to the first corner
//corners : how many corners?
//r : radius of the circumcircle
//zAngle : angle between the xy-plane and the plane of the shape
//dir : direction of the shape creation, +1 or -1
//countPerEdge : steps each edge
//periodic : this code will be fired each step
//final : this code will on the last step, if final == 0 then periodic will be fired
endfunction
function createNonIntersectedStarPolygon takes real mx, real my, real mz, real angleToStartCorner, integer corners, real r, real zAngle, integer dir, integer countPerEdge, real interval, usrfunc periodic, usrfunc final returns real x, real y, real z
//mx : middle x
//my : middle y
//mz : middle z
//angleToStartCorner : angle to the first corner
//corners : how many corners?
//r : radius of the circumcircle
//zAngle : angle between the xy-plane and the plane of the shape
//dir : direction of the shape creation, +1 or -1
//countPerEdge : steps each edge
//periodic : this code will be fired each step
//final : this code will on the last step, if final == 0 then periodic will be fired
endfunction
function createHypocycloid takes real mx, real my, real mz, real sAngle, real xyAngle, real zAngle, real R, real points, real rotations, integer count, integer dir, real interval, usrfunc periodic, usrfunc final returns real x, real y, real z
//mx : middle x
//my : middle y
//mz : middle z
//xyAngle : in which direction the hypocycloid shall be created
//zAngle : angle between xy-plane and the hypocycloid
//zAngle : angle between the xy-plane and the plane of the shape
//R : radius of hypocycloid
//Use this website <a href="http://www-groups.dcs.st-and.ac.uk/~history/Java/Hypocycloid.html" target="_blank" class="link link--external" rel="nofollow ugc noopener">http://www-groups.dcs.st-and.ac.uk/~history/Java/Hypocycloid.html</a> to see the basic shapes
//points : how many points? (a in the website)
//rotation : how many rotations? (b in the website)
//dir : direction of the shape creation, +1 or -1
//count : number of points in the shape (recommended about 180 per rotation)
//periodic : this code will be fired each step
//final : this code will on the last step, if final == 0 then periodic will be fired
endfunction
function createCycloid takes real sx, real sy, real sz, real sAngle, real xyAngle, real zAngle, real r, integer countPerloops, integer loops, integer dir, real interval, usrfunc periodic, usrfunc final returns real x, real y, real z
//sAngle: start angle
//r: radius
//countPerloops: number of points in a loop
//loops: number of loops (This being too high and casting the spell next to the boundary might bug unit out)
//dir: direction of the shape creation, +1 or -1
//interval: time between each points
endfunction
2. Save the file as a .j and place it in the correct folder.
3. Type in "Shape." then create'SHAPE'
P.S. It will autocomplete, and show the arguments needed, but will NOT highlight.
4. Input all of the take values
More shapes soon to come. I would love suggestions