System Polygon system

Dinowc

don't expect anything, prepare for everything
Reaction score
223
I don't know if a similar thing was posted before, but I'd like to show you my first system (don't be harsh on me :eek:)

so it's a Polygon/Polyeder system, that allows you to create some standard geometric shapes using lightning effects and some math :p
this may be improved later, that would include more different shapes

I don't know what to explain more so here's the code with screenshots and the map

I was too bored to make a custom ability, so I used Blizzard spell
you'll have to cast it in order to create a shape

I improved the code
JASS:
//====================================//
//  DINOWC'S POLYGON/POLYEDER SYSTEM  //
//====================================//
//
// Configuration:
// 1. Copy the above code into trigger editor
// 2. Make a custom ability and use it's raw code to run the trigger
// 3. I suck at explaining so I hope you&#039;ll get it <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />
//
// Pros:
//  I don&#039;t like showing off so you say the positive stuff <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />  
//   
// Cons:
//  Shapes cannot be changed ingame... what you set here, stays.
//  It&#039;s very easy to reach array limit cause of mass lightning effects, so I highly recommend not to set total N in 1 instance (before the timer expires) to greater than 200 - the more polygons you create, the less N should be and vice versa (more N, less polygons) or set timer&#039;s duration to lower value instead
//
// HOW TO USE?
//
// LIGHTNING - raw code of the lightning effect
// x,y - polygon&#039;s center coordinates
// StartHeight - starting height of the polygon set to higher value than Height and it will be upside-down
// Height - polygon&#039;s Z
// radius - polygon&#039;s width
// StartingAngle - determines polygon&#039;s rotation
// N - number of sides/angles
// Duration - duration of the polygon (seconds)
//                     


scope Polygons initializer init

private struct data
    lightning array l[200] //the more the N is, the less the array size should be
    integer N
    integer ptype
endstruct

globals
    private constant integer ID = &#039;AHbz&#039; 
    private constant string light = &quot;DRAM&quot; //I used mana drain effect
    private integer count = 0
    private integer b = 0
    private data array D
endglobals


private function conditions takes nothing returns boolean
    return GetSpellAbilityId() == ID
endfunction

private function PolarX takes real x, real dist, real angle returns real
    return x + dist * Cos(angle * bj_DEGTORAD)
endfunction

private function PolarY takes real y, real dist, real angle returns real
    return y + dist * Sin(angle * bj_DEGTORAD)
endfunction

private function DestroyLight takes nothing returns nothing
    local integer a = 0
    local integer i = 0
    local timer t = GetExpiredTimer()
    local data d
    
    set b = b - 1
    
    set d = D[0]
    
    loop
        call DestroyLightning(d.l[a])
        set d.l[a] = null
        set a = a + 1
        exitwhen a &gt; d.N + (d.ptype * d.N)
    endloop
    
    call d.destroy()
    
    loop
        set D<i> = D[i+1]
        set i = i + 1
        exitwhen i == count
    endloop
    
    set count = count - 1
    
    if b == 0 then
        set count = 0
    endif
    
    call DestroyTimer(t)
    set t = null
endfunction

public function Pyramid takes string LIGHTNING, real x, real y, real StartHeight, real Height, real radius, real StartingAngle, integer N, real Duration returns nothing

    local data d = data.create()
    local timer T = CreateTimer()

    local integer i = 0
    local real distance = radius
    
    local real Height2 = StartHeight
    
    local real angleI = 360.00 / I2R(N)
    set StartingAngle = StartingAngle - angleI
    
    set d.ptype = 1
    set d.N = N

    loop
        set d.l<i> = AddLightningEx(LIGHTNING, false, PolarX(x,radius,StartingAngle), PolarY(y,radius,StartingAngle), StartHeight, PolarX(x,distance,StartingAngle + angleI), PolarY(y,distance,StartingAngle + angleI), Height2)
        set StartingAngle = StartingAngle + angleI
        if i &gt;= N then
            set distance = 0.00
            set Height2 = Height
        endif
        
        set i = i + 1
        exitwhen i &gt; N + N
    endloop
    
    call TimerStart(T, Duration, false, function DestroyLight)

    set D[count] = d
    set b = b + 1
    set count = count + 1
    
    set T = null

endfunction


public function Prism takes string LIGHTNING, real x, real y, real StartHeight, real Height, real radius, real StartingAngle, integer N, real Duration returns nothing
    local data d = data.create()
    local timer T = CreateTimer()
    
    local integer i = 0
    
    local real heightI = StartHeight
    local real angleI = 360.00 / I2R(N)
    set StartingAngle = StartingAngle - angleI
    
    set d.ptype = 2
    set d.N = N
    
    loop
        set d.l<i> = AddLightningEx(LIGHTNING, false, PolarX(x,radius,StartingAngle), PolarY(y,radius,StartingAngle), StartHeight, PolarX(x,radius,StartingAngle + angleI), PolarY(y,radius,StartingAngle + angleI), heightI)
        set angleI = 360.00 / I2R(N)
        set StartingAngle = StartingAngle + angleI
        
        if i &gt;= N and i &lt; N + N then
            set angleI = 0.00
            set heightI = Height
        endif
        if i &gt;= N + N then
            set angleI = 360.00 / I2R(N)
            set StartHeight = Height
        endif
        
        set i = i + 1
        
        exitwhen i &gt; N * 3
    endloop
    
    call TimerStart(T, Duration, false, function DestroyLight)
    
    set D[count] = d
    set b = b + 1
    set count = count + 1
    
    set T = null

endfunction

public function Face takes string LIGHTNING, real x, real y, real Height, real radius, real StartingAngle, integer N, real Duration returns nothing
    local data d = data.create()
    local timer T = CreateTimer()
    
    local integer i = 0
    
    local real angleI = 360.00 / I2R(N)
    set StartingAngle = StartingAngle - angleI
    
    set d.ptype = 0
    set d.N = N
    
    loop
        set d.l<i> = AddLightningEx(LIGHTNING, false, PolarX(x,radius,StartingAngle), PolarY(y,radius,StartingAngle), Height, PolarX(x,radius,StartingAngle + angleI), PolarY(y,radius,StartingAngle + angleI), Height)
        set StartingAngle = StartingAngle + angleI
        set i = i + 1
        exitwhen i &gt; N
    endloop
    
    call TimerStart(T, Duration, false, function DestroyLight)

    set D[count] = d
    set b = b + 1
    set count = count + 1
    
    set T = null
    
endfunction

private function actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()

    local location target = GetSpellTargetLoc()
    
    local real angle = GetUnitFacing(caster)
    local real x = GetLocationX(target)
    local real y = GetLocationY(target)
    
    call Prism(light, x, y, 0.00, 300.00, 400.00, angle, 4, 5.00)
    call Pyramid(light, x, y, 300.00, 500.00, 400.00, angle, 4, 5.00)
    
    call RemoveLocation(target)
    set caster = null
    set target = null
    
endfunction

//===========================================================================

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    
    call TriggerAddCondition(t, Condition(function conditions))
    call TriggerAddAction(t, function actions)
    
endfunction

endscope</i></i></i></i>


The 2 main shapes:

-prism
View attachment 31112
-pyramid
View attachment 31054

some nice tricks you can do:
View attachment 31064
View attachment 31111
View attachment 31051
View attachment 31147 - I know, it looks ugly in the ss
View attachment 31113 - if you make a polygon like this DON'T overuse it because each of these has over 30 lightning effects, creating only 10 of these results in 300 lightning effects and that may fulfill the array limit and lead to malfunction
IT'S UNFIXABLE

any comment appreciated :thup:

___________
updated (v2.5)
 

simonake

New Member
Reaction score
72
Very nice :thup: + rep, How do you make the location up in the airs? (To add the effect after)

Wow, took very few time to get in Tutorial and ressources.

sorry doublepost :(

Nvm...
I think my medicatments are to heaver :rolleyes:
 

WolfieeifloW

WEHZ Helper
Reaction score
372
It could be a System, but it could be a Snippet.
Anyways;
From the screenshots it looks pretty cool.
I might use this is my map to make some cool spells :) .
 

D.V.D

Make a wish
Reaction score
73
Systems don't always need user functions. But, if you need to turn triggers on and off to use a system, then there's no point of having the system. I strongly suggest you make a function that creates the lightning and remove the wait via timers.
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
remove the wait via timers

I suck at Jass and I don't know how to use timers :(

You could make a custom function that reads your shapes with strings or reals
I'm aiming for that

this is still WIP

if this doesn't get graveyarded I'll surely improve it soon
 

Nexor

...
Reaction score
74
there is an unused lightning variable in the variable editor

And you could make it changeable ingame ...

Just remove the private from some global variables...

And name them to something unique
 

Faust

You can change this now in User CP.
Reaction score
123
Damn you I wanted to do something similar. ^^
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
Damn you I wanted to do something similar. ^^

hehe :D

I see no user functions

is it better now? <3

my final goal would probably be creating something like this:

images


any suggestions about doing that :p?
 

Trollvottel

never aging title
Reaction score
262
well use spheric coordinates.


newx = centerx + radius * Cos(normalangle) * Cos(z-angle)
newy = centery + radius * Sin(normalangle) * Cos(z-angle)
newz = centerx + radius * Sin(z-angle)

You would have to somehow connect the lightnings. i think i have a demo map, i will look for it...

/edit:

JASS:
library RotatingBall 

globals
    private constant integer amount = 20 // dividable by 4

endglobals


private struct Circle
    lightning array li[amount]
endstruct

private struct Ball
    real x 
    real y
    real z
    
    real radius
    
    
    real ch = 0
    real cv = 0
    Circle array HLight[amount]
    Circle array VLight[amount]
    
    static method create takes nothing returns Ball
        local Ball this = Ball.allocate()
        local integer i = 0
        
        loop
            exitwhen i == amount
            call .HLight<i>.create()
            call .VLight<i>.create()
            set i = i + 1
        endloop
        
        return this
    endmethod
   

endstruct

function Create takes real x, real y, real z, real radius, real facingturn, real angleturn returns nothing
    local Ball dat = Ball.create()
    local integer i =  amount / 4
    local integer j = 0
    local real x1
    local real y1
    local real z1
    local real x2
    local real y2
    local real z2
    local real x3
    local real y3
    local real offset = 360. / amount
    
    set dat.x = x
    set dat.y = y
    set dat.z = z
    set dat.radius = radius
    
    loop
        exitwhen i == 3 * amount / 4
        set z1 = z + radius * Sin(i*offset*bj_DEGTORAD)
        set z2 = z + radius * Sin((i+1)*offset*bj_DEGTORAD)
        loop
            exitwhen j == amount
            set x1 = x + radius * Cos(i*offset*bj_DEGTORAD) * Cos(j*offset*bj_DEGTORAD)
            set y1 = y + radius * Cos(i*offset*bj_DEGTORAD) * Sin(j*offset*bj_DEGTORAD)
            
            set x2 = x + radius * Cos(i*offset*bj_DEGTORAD) * Cos((j+1)*offset*bj_DEGTORAD)
            set y2 = y + radius * Cos(i*offset*bj_DEGTORAD) * Sin((j+1)*offset*bj_DEGTORAD)
            
            set x3 = x + radius * Cos((i+1)*offset*bj_DEGTORAD) * Cos((j)*offset*bj_DEGTORAD)
            set y3 = y + radius * Cos((i+1)*offset*bj_DEGTORAD) * Sin((j)*offset*bj_DEGTORAD)
            
            
            
            
            set dat.HLight<i>.li[j] = AddLightningEx(&quot;DRAL&quot;, false, x1, y1, z1, x2, y2, z1)
            
            set dat.VLight<i>.li[j] = AddLightningEx(&quot;DRAL&quot;, false, x1, y1, z1, x3, y3, z2)
        
            set j = j + 1
        endloop
        set j = 0
        set i = i + 1
    endloop
    

endfunction



endlibrary</i></i></i></i>


this worked for me.
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
hm I think I'll just stick with the simple stuff :D

thanks anyway
 

Azlier

Old World Ghost
Reaction score
461
If you used a timer instead of TriggerSleepAction, then it might be usable.
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
MAJOR UPDATE

I added a timer instead of TriggerSleepAction

I think it can be usable now :p

please check for any leaks or give me some suggestions on improving the code (I'm still a beginner in vJass :eek:)
 

BRUTAL

I'm working
Reaction score
118
i dont think its mui yet
cause i managed to glitch them when casting alot really fast, meaning about like 3 of the prisms didnt disappear ;o
 

BlackRose

Forum User
Reaction score
239
It looks good, I might want to maybe use in a terrain I might make.... though I don't like in-game warcraft shots.... they are damn ugly.
Bookmarked this page XD
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
i dont think its mui yet
cause i managed to glitch them when casting alot really fast, meaning about like 3 of the prisms didnt disappear ;o

well I tested like 10x by creating 10 prisms in row within it's duration and I had no problem

I haven't tried it with 30-40 prisms though...

EDIT: omg you're right... some of the prisms don't disappear

I don't know what happened :(

it worked last time I tested

I'll try to fix it later

EDIT2: I figured out the problem... it's because I reached the array limit and it started to override the array slots

I fixed it by setting this:

JASS:
private struct data
    lightning array l[500]


to this:

JASS:
private struct data
    lightning array l[200]


but then again, don't use to many angles/sides (the N integer) because it will lead to malfunction, I mean total N shouldn't go above 200

I know, it's a BIG disadvantage of this system, but I made it for fun and for some ppl that might use it

I need more feedback and suggestions!! and please check for any leaks
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
bump

I fixed the last known bugs and it should work perfectly fine now

now all I need is someone to comment or check for leaks

also, here's a mini poll:

should I continue this or you think it's total crap and I should quit it immediately?
 

wraithseeker

Tired.
Reaction score
122
What's with the lightning array L [200] ?

Another way of doing would be use a struct array loop and every interval you set

JASS:
set d.time = d.time + INTERVAL

if d.time &gt;== duration then
      //do stuff
endif
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
I don't get it :confused:

have I mentioned that I'm still a beginner in vJass?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top