• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Formula help

Status
Not open for further replies.
Level 3
Joined
Sep 9, 2009
Messages
658
I've been trying to solve this for a while now but I can't seem to think of the right way. I need a spell that creates dummy units perpendicular to the caster.

The way I'm going about it is

facing of caster
facing of caster + 270 degrees
facing of caster + 90 degrees

I should be able to create te effects I want perpendicular. But how do I incorporate it into a loop? What formula should I use to get a difference of 270 then 90 on each iteration?
 
If he wants to create them in this order(maybe because there is a delay between units?) that won't work.

http://world-editor-tutorials.thehelper.net/formula.php

You can enter values for level 1,2,3 like this:
0 270 450
360 270 450
0 270 90


For first set you have:
(loopInteger*405) - (loopInteger*loopInteger*45)

Edit:Fixed formula as wietlol said.
 
Last edited:
I wouldn't use a loop in this scenario at all, in fact I don't see the benefit since the facing + x is constant.

If you ask me there is nothing wrong with doing

facing + 90
do stuff with that
facing - 90
do stuff again

If there are a lot of actions it might be a bit ineffective. In that case I guess I would do something like..
JASS:
// handwritten outside the editor, beware of errors.
local integer i = 90
loop
    exitwhen i == 270
    facing = facing of unit + i
    //do stuff with facing
    set i = 270
endloop
 
@Wietlol were you referring to Chaosy's post? I don't understand what you mean with -360.

@Chaosy Doing it without the loop would be easier but it doesn't sit well with me knowing it's possible with a loop with the right formula. I like the technique of your loop but won't it do two instances instead of three?

@Ceday can you explain your formula more?

Just to clarify, I want to do this with a loop (pretend the degrees are in radians)

JASS:
set facing = GetUnitFacing(u)

set px = x + 100 * Cos(facing + 270)
set px = x + 100 * Cos(facing + 90)
set px = x + 100 * Cos(facing)

call CreateUnit(PlayerId, Dummy, px, py, facing)

EDIT: @Ceday your formula wasn't exactly what I was looking for but I think I got it now with the link you gave. Thanks!
 
If you're going to make units stand in a line/row to the left & right of the caster or whatever then I'd either do as Chaosy and make two loops, one for left and right direction each, or if you really want only one loop then "facing + (90 * pow( -1, loopInt) )" would work

Odds would be on one side and evens on the other since two negatives makes positives.
 
Why use power if you can just add 180 multiplied with the loopinteger?

You can just do this:
JASS:
    set facing = GetUnitFacing(u)
    
    set i = 0
    loop
        exitwhen i >= 2
        
        set a = (facing + 90 + 180*i)*bj_DEGTORAD
        set px = x + 100*Cos(a)
        set px = x + 100*Sin(a)
        call CreateUnit(PlayerId, Dummy, px, py, facing)
        
        set i = i +1
    endloop
 
Why do people keep forgetting angles are circular...

What you actually want is caster angle added to -90, 0 and +90. This is a lot easier and more logical since now it increments by 90 each iteration and works for all cases, not just two of them.

JASS:
    // increment by pi/2 radians (90 degrees)
    set increment = bj_PI / 2
    // starting angle converted to radians and offset appropriately
    set angle = GetUnitFacing(u) * bj_DEGTORAD - increment
    // displacement of 100 units
    set displacement = 100

    set i = 0
    loop
        // loop 3 times
        exitwhen i >= 3

        // create unit
        call CreateUnit(PlayerId, Dummy, x + displacement * Cos(angle), y + displacement * Sin(angle), angle * bj_RADTODEG)
        
        // increment angle
        set angle = angle + increment

        // loop increment
        set i = i + 1
    endloop
 
As said before creating units with -90, 0 and +90 angle respectively is not the same thing as 0, -90, +90 if there is a delay between creations.
 
As said before creating units with -90, 0 and +90 angle respectively is not the same thing as 0, -90, +90 if there is a delay between creations.
In which case you use an array to feed in the offsets. The array is initialized at map initialization and the offsets are ordered as you desire.

I was under the impression the topic creator wanted the units created instantly at those offsets.
 
Status
Not open for further replies.
Back
Top