Making A Circle

WolfieeifloW

WEHZ Helper
Reaction score
372
I figured this out in GUI easy, but I can't in JASS.
JASS:
scope PeonCircle initializer PCInit
    
    globals
        private constant integer PCID = 'A000'
    endglobals
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == PCID
    endfunction
    
    private function Actions takes nothing returns nothing
        local unit Caster = GetTriggerUnit()
        local unit u
        local integer zz = 0
        local integer z = 0
        local real x
        local real y
        
        loop
        exitwhen z == 10
            //set x = PolarProjectionBJ(GetUnitLoc(Caster), 300, I2R((i * 36)))
            set x = GetLocationX(GetUnitLoc(Caster)) + 300 * Cos((z * 36) * bj_DEGTORAD)
            //set y = PolarProjectionBJ(GetUnitLoc(Caster), 300, I2R((i * 36)))
            set y = GetLocationY(GetUnitLoc(Caster)) + 300 * Sin((z * 36) * bj_DEGTORAD)
            loop
            exitwhen zz == GetUnitAbilityLevel(Caster, PCID)
                set u = CreateUnit(GetOwningPlayer(Caster), 'o000', x, y, GetUnitFacing(Caster))
                call IssuePointOrder(u, "attack", x, y)
                call UnitApplyTimedLife(u, 'BTLF', (2 + I2R(GetUnitAbilityLevel(Caster, PCID))))
                set u = null
                set zz = zz + 1
            endloop
            set z = z + 1
        endloop
        set Caster = null
    endfunction
    
//====================================================================================================
    private function PCInit 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

It creates X Peons around the hero for X seconds;
Where X depends on the level of the spell.

The problem?
It only creates 1 single peon at 0 degrees.
 

RaiJin

New Member
Reaction score
40
in the first loop your doing

also try removing bj_DEGTORAD because it already gives it in Radians IM GUESSING

EDIT re read that part anyhow as i said try removing bj_DEGTORAD
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Yes, I know it's (0 * 36) the first run through.
It should be.
But when it runs through the second and third time;
(1 * 36), (2 * 36), etc. all the way up to (10 * 36) which would be 360, the end of the circle.

EDIT: Removing bj_DEGTORAD did nothing.
 

RaiJin

New Member
Reaction score
40
ya i accidentally misinterpreted it but try removing bj_DEGTORAD

edit: really.. hmm ill look again

edit2: shouldnt a local unit variable be nulled after its use?
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I'm like 95% sure it has something to do with the x/y.
I was never good with Cos/Sin and that :eek: .
Never really been able to use them in WC3 either.
 
Reaction score
91
A loop in a loop is really, really bad. Avoid it as much as possible.
Why the hell do you need zz when you can just
JASS:
call UnitApplyTimedLife(u, 'BTLF', (2 + I2R(GetUnitAbilityLevel(Caster, PCID))))

You're not using it anywhere, just doing some pointless loop.

JASS:

set x = GetLocationX(GetUnitLoc(Caster)) + 300 * Cos((z * 36) * bj_DEGTORAD)

You're leaking a location. Just remove GetLocationX() and use GetUnitX() instead (as well as GetUnitY()).

This should be fine now:
JASS:

scope PeonCircle initializer PCInit
    
    globals
        private constant integer PCID = 'A000'
    endglobals
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == PCID
    endfunction
    
    private function Actions takes nothing returns nothing
        local unit Caster = GetTriggerUnit()
        local unit u
        local integer zz = 0
        local integer z = 0
        local real x
        local real y
        loop
        exitwhen z == 10
            set x = GetUnitX(Caster) + 300 * Cos((z * 36) * bj_DEGTORAD)
            set y = GetUnitY(Caster) + 300 * Sin((z * 36) * bj_DEGTORAD)
            set u = CreateUnit(GetOwningPlayer(Caster), 'o000', x, y, GetUnitFacing(Caster))
            call IssuePointOrder(u, "attack", x, y)
            call UnitApplyTimedLife(u, 'BTLF', (2 + I2R(GetUnitAbilityLevel(Caster, PCID))))
            set u = null
            set z = z + 1
        endloop
        set Caster = null
    endfunction
    
//====================================================================================================
    private function PCInit 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
 

WolfieeifloW

WEHZ Helper
Reaction score
372
The second loop is for creating the X number of units.
Here's the spells description:
Learn Peon Circle said:
Creates multiple Peons in a circle around the caster to defend him for several seconds. Number of Peons and duration increase with level.

Level 1 - 1 Peon, 3 seconds.
Level 2 - 2 Peons, 4 seconds.
Level 3 - 3 Peons, 5 seconds.
Level 4 - 4 Peons, 6 seconds.

Cooldown: 20/18/16/14 seconds.
Fixed the location leak, thank you.
Here's the new trigger, still not working:
JASS:
scope PeonCircle initializer PCInit
    
    globals
        private constant integer PCID = 'A000'
    endglobals
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == PCID
    endfunction
    
    private function Actions takes nothing returns nothing
        local unit Caster = GetTriggerUnit()
        local unit u
        local integer zz = 0
        local integer z = 0
        local real x
        local real y
        
        loop
        exitwhen z == 10
            set x = GetUnitX(Caster) + 300 * Cos((z * 36) * bj_DEGTORAD)
            set y = GetUnitY(Caster) + 300 * Sin((z * 36) * bj_DEGTORAD)
            loop
            exitwhen zz == GetUnitAbilityLevel(Caster, PCID)
                set u = CreateUnit(GetOwningPlayer(Caster), 'o000', x, y, GetUnitFacing(Caster))
                call IssuePointOrder(u, "attack", x, y)
                call UnitApplyTimedLife(u, 'BTLF', (2 + I2R(GetUnitAbilityLevel(Caster, PCID))))
                set u = null
                set zz = zz + 1
            endloop
            set z = z + 1
        endloop
        set Caster = null
    endfunction
    
//====================================================================================================
    private function PCInit 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
 

WolfieeifloW

WEHZ Helper
Reaction score
372
Wow...
Such an easy fix.

Although, some of the unit's don't attack.
Any reason for that, or just the sheer amount of Peon's being created makes some of them not attack?

EDIT: Nevermind, fixed.
Peon's were set to attack their own spawn point, not the Caster's point.
Fixed it though:
JASS:
scope PeonCircle initializer PCInit
    
    globals
        private constant integer PCID = 'A000'
    endglobals
    
    private function Conditions takes nothing returns boolean
        return GetSpellAbilityId() == PCID
    endfunction
    
    private function Actions takes nothing returns nothing
        local unit Caster = GetTriggerUnit()
        local unit u
        local integer zz = 0
        local integer z = 0
        local real x
        local real y
        
        loop
        exitwhen z == 8
            set x = GetUnitX(Caster) + 300 * Cos((z * 45) * bj_DEGTORAD)
            set y = GetUnitY(Caster) + 300 * Sin((z * 45) * bj_DEGTORAD)
            loop
            exitwhen zz == GetUnitAbilityLevel(Caster, PCID)
                set u = CreateUnit(GetOwningPlayer(Caster), 'o000', x, y, GetUnitFacing(Caster))
                call IssuePointOrder(u, "attack", GetUnitX(Caster), GetUnitY(Caster))
                call UnitApplyTimedLife(u, 'BTLF', (2 + I2R(GetUnitAbilityLevel(Caster, PCID))))
                set u = null
                set zz = zz + 1
            endloop
            set z = z + 1
            set zz = 0
        endloop
        set Caster = null
    endfunction
    
//====================================================================================================
    private function PCInit 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
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Add a short "wait" to the inner loop.
If it works, there's too many of them too quickly.

Peon? Or try with something that isn't a worker. They don't like attacking things.
 

WolfieeifloW

WEHZ Helper
Reaction score
372
I would've liked it to spawn one group at a time, one after another;
Not all at once.
But TSA's are inaccurate and I haven't learned timers yet :eek: .
 

Gwypaas

hook DoNothing MakeGUIUsersCrash
Reaction score
50
Creating a nova is easy...

JASS:
local real diffBetween = 360/Amount of Units In Nova
local real currAngle = 0
local integer i = 0
loop
exitwhen i >= Amount of units in nova
call CreateUnit(...... CenterX+ 300*Cos(currAngle * bj_DEGTORAD), CenterY+ 300*Sin(currAngle * bj_DEGTORAD)) // Change "300" to the radius you want.
set currAngle = currAngle + diffBetween
set i = i + 1
endloop

Note - This code is working in degrees but you could convert it to radians by changing 360 to a whole circle with radians which I belive is 2PI and remove the bj_DEGTORAD's.

You can also do the exitwhen like this:
JASS:
exitwhen currAngle >= 359 // (359 to avoids conflicts with decimals being trunced)
 
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

      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