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

[Solved] Angle/Math issue

Status
Not open for further replies.
Level 14
Joined
Jul 26, 2008
Messages
1,009
Hi, I'm trying to make a spell that shoot a breath effect from the caster.

Simple enough. The way it works is the play channels the ability, and whatever way they're facing is the way the breath shoots.

I know I got the angle wrong because the effect shoots from odd angles, mainly facing to the east (0). Could someone help me figure out the right formula? .c is the Caster.

JASS:
     local real a = GetUnitFacing(.c)
     local real x = GetUnitX(.c) + 180 * Cos(a)
     local real y = GetUnitY(.c) + 180 * Sin(a)
        if GetUnitCurrentOrder(.c) == OrderId("breathoffrost")then
            call DestroyEffect(AddSpecialEffect(GetAbilityEffectById(SPELLID, EFFECT_TYPE_MISSILE, 0), x, y))
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
use this
JASS:
     local real a = GetUnitFacing(.c)
     local real x = GetUnitX(.c) + 180 * Cos(a @* bj_DEGTORAD@)
     local real y = GetUnitY(.c) + 180 * Sin(a @* bj_DEGTORAD@)
        if GetUnitCurrentOrder(.c) == OrderId("breathoffrost")then
            call DestroyEffect(AddSpecialEffect(GetAbilityEffectById(SPELLID, EFFECT_TYPE_MISSILE, 0), x, y))
 
Level 15
Joined
Feb 15, 2006
Messages
851
use this
JASS:
     local real a = GetUnitFacing(.c) @* bj_DEGTORAD@ // better :)
     local real x = GetUnitX(.c) + 180 * Cos(a)
     local real y = GetUnitY(.c) + 180 * Sin(a)
        if GetUnitCurrentOrder(.c) == OrderId("breathoffrost")then
            call DestroyEffect(AddSpecialEffect(GetAbilityEffectById(SPELLID, EFFECT_TYPE_MISSILE, 0), x, y))
Much better :)
 
Level 14
Joined
Jul 26, 2008
Messages
1,009
Thanks! My only issue now is how to make the effect fire in a certain direction, much like a breath attack. Right now it's firing off facing Angle 0. Hopefully this isn't impossible to do, since breath spells do it. :X

And Starquizer is right, I need to maintain the angle for the next effect, but still both ways essentially work. Thanks!
 
Level 16
Joined
Mar 3, 2006
Messages
1,564
When you say this has to be done by a dummy unit do you mean it has to be attached to the dummy unit that I create at that point, facing the angle, and then kill the unit, or do you mean a dummy unit that has some breath ability to make this?

The first one
(the second will be the same as having the ability on the caster unless you want to make a breath spell in 3 or 4 directions)
 
Status
Not open for further replies.
Top