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

[Request] Dummy.mdx Z-Angle formula

Status
Not open for further replies.
Level 14
Joined
Apr 20, 2009
Messages
1,543
Are you refferencing this part?

JASS:
            readonly unit     proj     = null                 // The actual projectile unit.
            readonly real     angle    = 0.00               // The angle at which the projectile is facing.
            readonly real     pitch    = 0.00               // The pitch at which the projectile is facing.
            readonly vector   pos      = 0                  // A vector struct holding the XYZ coordinates of the projectiles position.
            readonly vector   vel      = 0                  // A vector struct holding the XYZ coordinates of the projectiles velocity.
            readonly vector   targ     = 0                  // A vector struct holding the XYZ coordinates of the projectiles target location.


            method modifyTargeting takes real xPos, real yPos, real zPos returns nothing
               set this.angle  = Atan2((yPos - this.pos.y),(xPos - this.pos.x))
               set this.pitch  = Atan2(SquareRoot((xPos - this.pos.x) * (xPos - this.pos.x) + (yPos - this.pos.y) * (yPos - this.pos.y)),(zPos - this.pos.z))
               set this.vel.x  = Sin(this.pitch) * Cos(this.angle) * speed
               set this.vel.y  = Sin(this.pitch) * Sin(this.angle) * speed
               set this.vel.z  = Cos(this.pitch) * speed
               set this.targ.x = xPos
               set this.targ.y = yPos
               set this.targ.z = zPos
               if not this.arcing then
                   call SetUnitAnimationByIndex(this.proj,R2I(bj_RADTODEG * Atan2(this.vel.z,SquareRoot(this.vel.x * this.vel.x + this.vel.y * this.vel.y)) + 0.50) + 90)
               endif
                   call SetUnitFacing(this.proj,this.angle * bj_RADTODEG)
            endmethod
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
Are you refferencing this part?

JASS:
            readonly unit     proj     = null                 // The actual projectile unit.
            readonly real     angle    = 0.00               // The angle at which the projectile is facing.
            readonly real     pitch    = 0.00               // The pitch at which the projectile is facing.
            readonly vector   pos      = 0                  // A vector struct holding the XYZ coordinates of the projectiles position.
            readonly vector   vel      = 0                  // A vector struct holding the XYZ coordinates of the projectiles velocity.
            readonly vector   targ     = 0                  // A vector struct holding the XYZ coordinates of the projectiles target location.


            method modifyTargeting takes real xPos, real yPos, real zPos returns nothing
               set this.angle  = Atan2((yPos - this.pos.y),(xPos - this.pos.x))
               set this.pitch  = Atan2(SquareRoot((xPos - this.pos.x) * (xPos - this.pos.x) + (yPos - this.pos.y) * (yPos - this.pos.y)),(zPos - this.pos.z))
               set this.vel.x  = Sin(this.pitch) * Cos(this.angle) * speed
               set this.vel.y  = Sin(this.pitch) * Sin(this.angle) * speed
               set this.vel.z  = Cos(this.pitch) * speed
               set this.targ.x = xPos
               set this.targ.y = yPos
               set this.targ.z = zPos
               if not this.arcing then
                   call SetUnitAnimationByIndex(this.proj,R2I(bj_RADTODEG * Atan2(this.vel.z,SquareRoot(this.vel.x * this.vel.x + this.vel.y * this.vel.y)) + 0.50) + 90)
               endif
                   call SetUnitFacing(this.proj,this.angle * bj_RADTODEG)
            endmethod

y problem is the xyzPos and this.pos.xyz thing, what is them? old and new position?

xe:
http://www.wc3c.net/showthread.php?t=101150

It's in vJass, uses a similar(if not the same) dummy model and the formala should be easy to understand.
(xdfx/collider should be pretty similar to that projectile)

y that was the 1st system what i got via google but there more harder to understand than in that post in thehelper.net
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
http://www.wc3c.net/vexorian/jasshelpermanual.html said:
Methods

Methods are just like functions, the difference is that they are associated with the class, also [normal] methods are associated with an instance (in this case 'this')

Once again an example is needed

JASS:
    struct point
        real x=0.0
        real y=0.0

        method move takes real tx, real ty returns nothing
            set this.x=tx
            set this.y=ty
        endmethod

    endstruct

    function testpoint takes nothing returns nothing
     local point p=point.create()
        call p.move(56,89)

        call BJDebugMsg(R2S(p.x))
    endfunction
this : A keyword that denotes a pointer to current instance, [normal] methods are instance methods which means that they are called from an already assigned variable/value of that type, and this will point to it. In the above example we use this inside the method to assign x and y, when calling p.move() it ends up modiffying x and y attributes for the struct pointed by p.

this.x simply points to the associated poperties of the struct in which the method exists.

For example:

this.pos.y points to the y co-ordinate of the pos property of the struct.
this.pos.x points to the x co-ordinate of the pos property of the struct.

You should start leaning vJass bro, you've got so much potential :D
Read through the JassHelper manual and try to understand it ^.^
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
this.x simply points to the associated poperties of the struct in which the method exists.

For example:

this.pos.y points to the y co-ordinate of the pos property of the struct.
this.pos.x points to the x co-ordinate of the pos property of the struct.

You should start leaning vJass bro, you've got so much potential :D
Read through the JassHelper manual and try to understand it ^.^

i understand the structr a bit, roblem is the value what was stored there hehe
i mean there 2 x/y/z and idk the difference between that but anyway

the z-angle now work but still i got questions, since z-angle problem (atleast mostly because i dont understand why different my formula and what was there and both work)
we can mark this thread solved and continue with this thread

http://www.hiveworkshop.com/forums/2121204-post11.html

next problems setting missile end height if missile do parabola (example target is in air and i want arrow going only till target and if possible with make unit group and check the targets on way)

and why dummy units going back to caster if i start spam the arrows (i am not sure but maybe something in linked list? coz arrows reach the target with parabola then going back to caster without parabola instead just die at target location)

anyway my formula is this, somebody can tell me why in other formula have x/y/z and alot sin cos?
JASS:
set h1 = ( 4 * udg_MS_MaxHeight[i] / udg_MS_MaxDist[i] ) * ( udg_MS_MaxDist[i] - (udg_MS_CurDist[i]-udg_MS_Speed[i]) ) * ( (udg_MS_CurDist[i]-udg_MS_Speed[i]) / udg_MS_MaxDist[i] )
set h2 = ( 4 * udg_MS_MaxHeight[i] / udg_MS_MaxDist[i] ) * ( udg_MS_MaxDist[i] - udg_MS_CurDist[i] ) * ( udg_MS_CurDist[i] / udg_MS_MaxDist[i] )
set h3 = bj_RADTODEG * Atan2(h2-h1,udg_MS_Speed[i])
 
Status
Not open for further replies.
Top