making wisp moving in a blade-like circle

jig7c

Stop reading me...-statement
Reaction score
123
I need help..

I have created this script.. which is suppose to create a total of 22 wisp...
and move then around in a circle...

not an O circle... but more like a blade ... kinda like

-, /, -, \, -, /, -, \ like two blades of a fan opposite each other..... also like two spokes of a wheel... but of equal length and equal speed

anyways...
here is the script, i'm sure it has tons of errors in it.. can someone help me fix it


what i have done is combine two things into one script, (probably not so smart of me) but local trigger t stuff creates the wisp, and local trigger a makes the wisps move in circle every .03 seconds..

JASS:
scope StartCircle initializer Init
    globals
        constant integer dummy = 'e002'                         //wisp unit-id
        unit array wisp                                      //the actual wisp to be created
        constant location l = GetRectCenter(gg_rct_Rect_096)    //center of wisp circle
    endglobals

    private function Cond1 takes nothing returns boolean
        return ((GetUnitTypeId(GetTriggerUnit()) == 'H007')  or (GetUnitTypeId(GetTriggerUnit()) == 'H009')  or (GetUnitTypeId(GetTriggerUnit()) == 'H008')  or (GetUnitTypeId(GetTriggerUnit()) == 'H00A') == true)
    endfunction

    private function levelcheck takes nothing returns boolean
        return (udg_Level_Start == true ) 
    endfunction

    private function CreateActions takes nothing returns nothing
        local integer i = 1                                    //for the loop
        local location l                                       //wisp's starting location
       
        if ( levelcheck ) then
            call DisableTrigger( gg_trg_Spin_Wisps )
            loop
                exitwhen i > 22
                if ( i > 11 ) then
                    set l = PolarProjectionBJ(l, ( 75.00 * (i - 11.00 )), 0)
                    set wisp<i> = CreateUnitAtLoc(Player(11), dummy, l, 90)
                    call RemoveLocation(l)
                else
                    set l = PolarProjectionBJ(l, ( 75.00 * i), 0)
                    set wisp<i> = CreateUnitAtLoc(Player(11), dummy, l, 90)
                    call RemoveLocation(l)
                endif
                set i = i + 1
            endloop
            call EnableTrigger( a ) //error
        endif
    endfunction
    
    //moving wisp in circle...
        
    private function Actions takes nothing returns nothing
        local real angle = 1
        local integer wloop = 1
        local location wisppoint
        set angle = angle + 1.50
        loop
            exitwhen wloop == 22
            if (wloop &gt; 22) then
                set wisppoint = PolarProjectionBJ(l, ( 75.00 * ( wloop - 11.00 ) ), angle)
                call SetUnitPositionLoc( wisp[wloop], wisppoint )
                call RemoveLocation(wisppoint)
            else
                set wisppoint = PolarProjectionBJ(l, ( 75.00 * wloop ), angle)
                call SetUnitPositionLoc( wisp[wloop], wisppoint )
                call RemoveLocation(wisppoint)
            endif
            set wloop = wloop + 1
        endloop
        call RemoveLocation(l)
    endfunction


    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger ()
        local trigger a = CreateTrigger ()
        call TriggerRegisterEnterRectSimple( t, gg_rct_Block_1_Start_Copy_Copy )
        call TriggerAddCondition( t, Condition( function Cond1) )
        call TriggerAddAction( t, function CreateActions )
        
    
        call DisableTrigger( gg_trg_Spin_Wisps_Ice_Copy )
        call TriggerRegisterTimerEventPeriodic(a, 0.03 )
        call TriggerAddAction(a, function Actions )
    endfunction
    
endscope
</i></i>
 

Jedi

New Member
Reaction score
63
Circle movement with coordinates.
JASS:
private function Actions takes nothing returns nothing
        //If your center point isn&#039;t constant, save it everytime but I think it is.
        local real angle
        local real distance
        local integer loopi = 1
        local real x
        local real y
        loop
            exitwhen loopi &gt; 22 //wisp count
            set x = GetUnitX(wisp[loopi])
            set y = GetUnitX(wisp[ loopi])
            set distance = SquareRoot((x - CenterX) * (x - CenterX) + (y - CenterY) * (y - CenterY)
            set angle = (bj_RADTODEG * Atan2(y - CenterY, x - CenterX)) + 2.5 //This 2.5 is important, trust me <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" /> If they are moving too fast, decrease this 2.5
            call SetUnitX(wisp[loopi], CenterX + distance * Cos(angle * bj_DEGTORAD) //PolarX
            call SetUnitY(wisp[loopi], CenterY + distance * Sin(angle * bj_DEGTORAD)  //PolarY
            set loopi = loopi + 1
endfunction
 

Sevion

The DIY Ninja
Reaction score
413
That would be the traditional wisp wheel. But I'm not quite sure what he meant. Because he said "Not like a Circle" ._.

This also confused me: -/-\-/-\ like two blades of a fan opposite each other..... also like two spokes of a wheel... but of equal length and equal speed
 

jig7c

Stop reading me...-statement
Reaction score
123
sorry to be confusing fellas.. i did a bad job of explaining

sevion, your picture is exactly what i want.. where the spokes of the wheel is, is where i want my wisp to be...except, only 2 equally opposite spokes...

the wisp will move around in a circle, with a constant center point...
all of the wisp will be in a straight line, and with the most middle wisp staying in one place and the rest moving around it...

if you put your hands up, perpendicular to your body, but to towards the sides... and spin around, thats how I want the wisp to be spinning arounds

i tried looking for pictures.. but couldn't find it.. so here goes a snapshot

inside a region i want the wisp, designated by (o) to move around

Code:
1____________________________
|                    o     |
|                 o        | 
|              o           |
|           o              |
|         o                |
|___o______________________|

2________________________
|              o          |
|              o          | 
|              o          |
|              o          |
|              o          |
|______________o__________|

3_________________________
|   o                     |
|       o                 | 
|            o            |
|                 o       |
|                    o    |
|________________________o|

bad pictures, i know
and so on...
there will be 11 wisps on each side, moving 75 units every .03 seconds...
 

Sevion

The DIY Ninja
Reaction score
413
Ah. I see what you mean now. Did you want a wisp in the middle then? That'd be 23 total wisps with 22 spinning.

This should work:

JASS:
library WispWheel
    globals
        private constant integer WISP = &#039;ewsp&#039;
        private constant integer NUM_OF_WISPS = 22
        private constant real    DISTANCE = 70
        private constant boolean ADD_LOCUST = true
        private constant integer LOCUST = &#039;Aloc&#039;
    endglobals
    
    struct Wheel
        unit array Wisps[NUM_OF_WISPS]
        unit Center
        real CenterX
        real CenterY
        real Speed
        
        implement T32x
        
        method periodic takes nothing returns nothing
            local integer i = NUM_OF_WISPS
            local real angle
            local real x
            local real y
            
            set this.CenterX = GetUnitX(this.Center)
            set this.CenterY = GetUnitY(this.Center)
            
            set angle = Atan2(GetUnitY(this.Wisps<i>) - this.CenterY, GetUnitX(this.Wisps<i>) - this.CenterX) + this.Speed
            
            loop
                set x = GetUnitX(this.Wisps<i>)
                set y = GetUnitY(this.Wisps<i>)
                call SetUnitX(this.Wisps<i>, this.CenterX + (i - NUM_OF_WISPS / 2) * DISTANCE * Cos(angle))
                call SetUnitY(this.Wisps<i>, this.CenterY + (i - NUM_OF_WISPS / 2) * DISTANCE * Sin(angle))
                set i = i - 1
                exitwhen i == NUM_OF_WISPS / 2
            endloop
            
            set angle = Atan2(GetUnitY(this.Wisps<i>) - this.CenterY, GetUnitX(this.Wisps<i>) - this.CenterX) + this.Speed
            
            loop
                set x = GetUnitX(this.Wisps<i>)
                set y = GetUnitY(this.Wisps<i>)
                call SetUnitX(this.Wisps<i>, this.CenterX + i * DISTANCE * Cos(angle))
                call SetUnitY(this.Wisps<i>, this.CenterY + i * DISTANCE * Sin(angle))
                set i = i - 1
                exitwhen i == 0
            endloop
        endmethod
        
        static method create takes player owner, real x, real y, real speed returns thistype
            local thistype this = thistype.allocate()
            local integer i = NUM_OF_WISPS
            
            set this.Center = CreateUnit(owner, WISP, x, y, 0)
            set this.CenterX = x
            set this.CenterY = y
            static if ADD_LOCUST then
                call UnitAddAbility(this.Center, LOCUST)
            endif
            set this.Speed = speed * T32_PERIOD
            
            loop
                set this.Wisps<i> = CreateUnit(owner, WISP, x + (i - NUM_OF_WISPS / 2) * DISTANCE, y, 0)
                static if ADD_LOCUST then
                    call UnitAddAbility(this.Wisps<i>, LOCUST)
                endif
                set i = i - 1
                exitwhen i == NUM_OF_WISPS / 2
            endloop
            
            loop
                set this.Wisps<i> = CreateUnit(owner, WISP, x + -i * DISTANCE, y, 0)
                static if ADD_LOCUST then
                    call UnitAddAbility(this.Wisps<i>, LOCUST)
                endif
                set i = i - 1
                exitwhen i == 0
            endloop
            
            return this
        endmethod
    endstruct
endlibrary</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>


To test:

JASS:
scope Test initializer init
    private function init takes nothing returns nothing
        local Wheel dat = Wheel.create(Player(0), 0, 0, 1)
        call dat.startPeriodic()
    endfunction
endscope
 

Sevion

The DIY Ninja
Reaction score
413
You don't need events.

In your actions function, just do

JASS:
local Wheel dat = Wheel.create(Player(0), 0, 0, 1)
call dat.startPeriodic()


Edit:

So basically, it'd be:

JASS:
scope StartCircle initializer Init
    globals
        private boolexpr True
    endglobals
    
    private function Cond1 takes nothing returns boolean
        return ((GetUnitTypeId(GetTriggerUnit()) == &#039;H007&#039;)  or (GetUnitTypeId(GetTriggerUnit()) == &#039;H009&#039;)  or (GetUnitTypeId(GetTriggerUnit()) == &#039;H008&#039;)  or (GetUnitTypeId(GetTriggerUnit()) == &#039;H00A&#039;) == true)
    endfunction
    
    private function TrueFunc takes nothing returns boolean
        return true
    endfunction

    private function CreateActions takes nothing returns nothing
        local Wheel NewWheel
       
        if ( udg_level_Start ) then
            //call DisableTrigger( gg_trg_Spin_Wisps ) Wtf are you doing here?
            set NewWheel = Wheel.create(GetOwningPlayer(GetTriggerPlayer()), GetRectCenterX(gg_rct_Rect_096), GetRectCenterY(gg_rct_Rect_096), 1.5)
            call NewWheel.startPeriodic()
        endif
    endfunction


    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger ()
        set True = Filter(function TrueFunc)
        call TriggerRegisterEnterRectSimple( t, gg_rct_Block_1_Start_Copy_Copy )
        call TriggerAddCondition( t, Condition( function Cond1) )
        call TriggerAddAction( t, function CreateActions )
    endfunction
    
endscope
 

Jedi

New Member
Reaction score
63
Group enumeration functions caused a memory leak before patch 1.24 if null was used as the boolexpr argument. To avoid this, a coder would often resort to creating a garbage boolexpr function that returns true, to be used instead of null.

This no longer applies since Blizzard fixed this issue in patch 1.24. You may now input null as a boolexpr argument freely without worry of a memory leak.

@Helper.nerWiki

http://wiki.thehelper.net/wc3/jass/common.j/boolexpr
 

Sevion

The DIY Ninja
Reaction score
413
TBH, I looked over my code, and it's not even used. Just take it out.

Edit: Noticed another thing. I did GetOwningPlayer(GetTriggerPlayer()), should be GetOwningPlayer(GetTriggerUnit())
 

jig7c

Stop reading me...-statement
Reaction score
123
actually in my code, it needs to be Player(11)... it creates wisp for the enemies :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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