• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Solved] Angle/Math issue

Status
Not open for further replies.
Level 13
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 13
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