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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top