• 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.

[JASS] Check this over please.

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
I need little help with this. Check it out and see what I did wrong please.
JASS:
function Trig_Pacifier_Copy_Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local real x = 0
    local real y = 0
    local location p
    local unit dumb
    local integer i = 1
    local integer o = 8
    loop
      exitwhen i>o
      set i = i + 1
      set x = GetUnitX(cast) + 500 * Cos(x + 45.*bj_DEGTORAD)
      set y = GetUnitY(cast) + 500 * Sin(y + 45.*bj_DEGTORAD)
      set p = Location(x,y)
      set dumb = CreateUnit(GetOwningPlayer(cast), 'h008', p, 0.00)
      // ^^^^I get a syntax
      call UnitAddAbility(dumb, 'A01H')
      call IssueTargetOrder(dumb, "chainlightning", cast)
      call UnitApplyTimedLife(dumb, 'BTLF', 10)
      call RemoveLocation(p)
      call TriggerSleepAction(.5)
    endloop
endfunction

Any help is appreciated +rep
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
set dumb = CreateUnit(GetOwningPlayer(cast), 'h008', p, 0.00)


native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit


Meaning it should be like this: set dumb = CreateUnit(GetOwningPlayer(cast), 'h008', x, y, 0.00)

Which means you don't need that location.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Here it is almost completely fixed:
JASS:
function Trig_Pacifier_Copy_Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local real x = 0
    local real y = 0
    local unit dumb
    local integer i = 1
    local integer o = 8
    loop
      exitwhen i>o
      set i = i + 1
      set x = GetUnitX(cast) + 500 * Cos(x + 45.*bj_DEGTORAD)
      set y = GetUnitY(cast) + 500 * Sin(y + 45.*bj_DEGTORAD)
      set dumb = CreateUnit(GetOwningPlayer(cast), 'h008', x, y, 0.)
      call UnitAddAbility(dumb, 'A01H')
      call IssueTargetOrder(dumb, "chainlightning", cast)
      call UnitApplyTimedLife(dumb, 'BTLF', 10)
      call TriggerSleepAction(.5) //Please use something else than TSA.
    endloop
    set dumb = null
    set cast = null
endfunction
Just one question: Why this: "Cos(x + 45.*bj_DEGTORAD)"?
I don't think it will look so good. You're supposed to give it an angle (in radians).
 
Level 9
Joined
Nov 28, 2008
Messages
704
To further elaborate, use GetUnitFacing if you want them to go 500 units in front of themselves.

Unless you intended for them to go in a random direction.

Also, dont use * bj_DEGTORAD. Ever. Unless you use GetUnitFacing. It's inefficient and stupid when you can use pi/2, 2pi and such without bothering to times something. You are using 45 degrees here it looks like, so that is actually, in radians, pi/4. Somewhere around .7~.8. Use a calculator.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Also, dont use * bj_DEGTORAD. Ever. Unless you use GetUnitFacing. It's inefficient and stupid when you can use pi/2, 2pi and such without bothering to times something.
Actually, it's not that inefficient. Of course, it's better not to use it, but it's still not that bad.

You are using 45 degrees here it looks like, so that is actually, in radians, pi/4. Somewhere around .7~.8. Use a calculator.
It's 0.78539816339744830961566084569875... :D
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Also, dont use * bj_DEGTORAD. Ever. Unless you use GetUnitFacing. It's inefficient and stupid when you can use pi/2, 2pi and such without bothering to times something. You are using 45 degrees here it looks like, so that is actually, in radians, pi/4. Somewhere around .7~.8. Use a calculator.
Uh, 45*bj_DEGTORAD is not really any different than bj_PI/4 (although the latter looks prettier), and writing .78540 or something is just ugly and unreadable.
 
Level 9
Joined
Jun 7, 2008
Messages
440
Here it is almost completely fixed:
JASS:
function Trig_Pacifier_Copy_Actions takes nothing returns nothing
    local unit cast = GetTriggerUnit()
    local real x = 0
    local real y = 0
    local unit dumb
    local integer i = 0
    local integer o = 8
    loop
      exitwhen i>o
      set i = i + 1
      set x = GetUnitX(cast) + 500 * Cos(x + 45.*bj_DEGTORAD)
      set y = GetUnitY(cast) + 500 * Sin(y + 45.*bj_DEGTORAD)
      set dumb = CreateUnit(GetOwningPlayer(cast), 'h008', x, y, 0.)
      call UnitAddAbility(dumb, 'A01H')
      call IssueTargetOrder(dumb, "chainlightning", cast)
      call UnitApplyTimedLife(dumb, 'BTLF', 10)
      call TriggerSleepAction(.5) //Please use something else than TSA.
    endloop
    set dumb = null
    set cast = null
endfunction
Just one question: Why this: "Cos(x + 45.*bj_DEGTORAD)"?
I don't think it will look so good. You're supposed to give it an angle (in radians).

I did this because I wanted the dummy to spawn 45 degrees farther around the caster (like a circle) (45 * 8 = 360) I had asked for help on this earlier, and the person that responded told me it was most efficient to do it this way :xxd: As for the TSA, I needed it to be a half a second behind to look like a wave effect. This is the only way I know how to do this.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Okay, why don't you explain to me in detail what you want this code to do, and I'll help you out. You never actually stated what was supposed to happen, you just stated there was a syntax error. The syntax error has been fixed, so what else do you need help with?
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
I did this because I wanted the dummy to spawn 45 degrees farther around the caster (like a circle) (45 * 8 = 360) I had asked for help on this earlier, and the person that responded told me it was most efficient to do it this way :xxd: As for the TSA, I needed it to be a half a second behind to look like a wave effect. This is the only way I know how to do this.

Then why are you using x + 45 and y + 45. Should be i * 45 if that is what you want to accomplish.
 
Status
Not open for further replies.
Top