• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[vJass] (system) Missile

I have worked on this missle engine for 2 months now and start the first official beta today.

Please post feedback, critism, pros, cons, bugs, etc.
Thanks all for your patience!

And thanks for downloading.
Preview image by Furby. Thanks a lot!

Edit:
I've updated the testmap and added a second spell.
There is a lot of improvements in version 0.1.7 and I plan to make it even faster and even more modular. I also plan to create an easy to understand API.

Used librarys:


Changed all constants (TRUE, FALSE) to true/false
Changed interval to 0.03125
Fixed object leaks
Performance improvements on MissileMovement: Less object generation
Merged MissileLocHelpers to Missile<type>Target
Removed HomingMissile wrapper
Added second spell (Rain of Fire)
Removed Libraries from Modules



Changed name to Missile.
Completely remade in modules, supports now a lot of optional stuff.
Added SpellHelper, fixed a lot of problems, made the Miranas Arrow example WAY more powerful to show what this system is able to be capable of.


Keywords:
Missile, Projectile, xe, xemissile, xecollider, projectile, collider, awesome, anachron, collide, colliding, vJass
Contents

CustomMissile 0.1.7 (Map)

Reviews
BPower: 11:02, 25th Feb 2016 Reason for re-review: Nowadays the spell section is packed full of missile systems from different authors, therefore a more qualified moderator comment than "this is neat stuff" is required. There is keen...
Visitor Message. Check your profile.
Btw, the examples do not work 100% because the height is to less.
Ignoring the height (call setTargetUnit(unit, false)) will hit every unit, ignoring its current height.

#Update - 0.0.H

  • Increased testmap.
  • Fixed testmap issues.
  • Fixed zArc. Works perfectly now! Check it out on the units on the high walls!
 
Level 12
Joined
Sep 4, 2007
Messages
407
hittree, hitwalls n' hitunits working perfecly. the zarc still seems to interfere with the zxarc ( togueter they don't seem to make an "diagonal arc") alone, the zarc is perfect.

BTW, since i'll be using your system extensivelly in my map project, i think i can help you alot improving it (speacially cuz i need it improved).

I will give you some spell samples from my map so you can put it in your sample map for better demonstration (checkin the entries it seems people complain a lot of it's lack of
flashy-stuff-it-can-easilly-do.) like the rubber ball (i'm working on that, could not do because onTargetReach does not accept destructables, so i'd have to make my own method to do so. i could use the "no target missile", but it is not currently fully functional.)

be back tomorrow.
 
Last edited:
Hmm, I'll make a next check whether xyArc does interfere with zArc.

I will give you some spell samples from my map so you can put it in your sample map for better demonstration (checkin the entries it seems people complain a lot of it's lack of
flashy-stuff-it-can-easilly-do.) like the rubber ball (i'm working on that, could not do because onTargetReach does not accept destructables, so i'd have to make my own method to do so. i could use the "no target missile", but it is not currently fully functional.)
Well, the onTargetReach does not have anything as parameter because you have to store the target manually.

Use the SetTargetPos function for that. (Since destructables never move I chosed that this is the best way).
 
Level 12
Joined
Sep 4, 2007
Messages
407
Is there Z speciaffication in the destructable detection method? cuz in my map the dest are only noticed in certain Z. (i set the missile with an random zarc, 0.10, 0.15, in certain arcs it does detect the tree, in others, it does not. so i suppose is not exacly a matter o arc, but a matter o the missile's Z when it touches the tree. o_O)

dude, this system will rock when it gets complete (it already does)
 
Of course, as already told, this cares about the z position of the missile, so it only touches units/destructables that are really touching it. (It's a feature)

To ignore the z-height you can use this:
call setTargetUnitZ(unit, false)
You'll have to wait for target locations till I add a method called setTargetPosZ(x, y, bol)
 
Level 12
Joined
Sep 4, 2007
Messages
407
well that depends: say that i can imput my specific destructable height (like: i know that my tree is 250. height tall, because units at this height stay in top of her) So can i imput a condition that checks if the destructible is that speciffic tree n' check if the missile is high enough to pass through (that means 250 z or more on onDestTouch).

For me this is important because in my map there are two types of destructibles. the ones you can sends spells above them and others that no spell can possibly go above them.

Other thing! how do i get the unit missile in the middle of a method? i can get the caster unit using .source, i can get the missile unit using... ? I want this because i want play special effects exacly at the height of the missile.
 
Level 12
Joined
Sep 4, 2007
Messages
407
the zarc n xy are still not compatible. also, the settargetpos although working uses the target location as parameter of height in the end.z that would make the arrow to "hit the ground" where the ability location was set making it invisible when it hits it. At least that iis what i can tell for the code... wait a sec let me check ingame.

yes it is like i said. the only way to get over this is to somehow cauculate the final location when the decay time is over and set the end.z to this place's high.
 
I don't get it, you can manually put the height if you don't want to hit the ground?
ABout the xyArc and zArc not being compactible: I'll check it right now.

Edit:
#Update - 0.0.J

  • xyArc and zArc now are able to interact with each other.
  • Missiles now automatically get destroyed when flying out of playable map. (Preventing bugs & crashes.
 
Level 12
Joined
Sep 4, 2007
Messages
407
Ugh, and i got something weird to show you:

FIRST: forget about those "current shot angle", i was using it to speciffy the angle the arrow will go in the polar projection as you will se in the coding below.

138643-albums3204-picture27754.jpg


1º: The arrow start with a VERY wrong angle and then it get it's proper angle after some time. In the picture it is in the transition.
2º: The arrow does not start at the caster's position.

The Red tragetory is the actual one it happens when i play the trigger. The first red circle is where the arrow was created.

the Blue tragetory is the one it should do when i play the trigger. The blue circle is where the arrow was supposed to be created.

The Yellow Circle is the actually position of the arrow (look how weird it is XD)


The code i'm using:
JASS:
         public static method new takes spell ins, unit caster, real spellx, real spelly returns thistype
            local real x = GetUnitX(caster)
            local real y = GetUnitY(caster)
            
            local real angle = bj_RADTODEG * Atan2(spelly - y, spellx - x)
            
            local real xloc = x + 2500 * Cos(angle * bj_DEGTORAD)
            local real yloc = y + 2500 * Sin(angle * bj_DEGTORAD)
            
            local thistype this = thistype.create(x, y, GetLocZ(x, y) + 75., 0.)
            
            set .source = caster
            set .spellInst = ins
            
            call .setTargetPos(xloc, yloc)
            call BJDebugMsg("curren shot angle= " + R2S(angle))
            
            return this
        endmethod

As you can see i set the create location exacly the location of the caster.
 
Last edited:
local thistype this = thistype.create(x, y, GetLocZ(x, y) + 75., 0.)
The angle is 0 (radians) and will change to the aim angle as fast as it can be.
Calculate the angle (just add it) as radians and you'll be better.

JASS:
local thistype this = thistype.create(x, y, GetLocZ(x, y) + 75., angle * bj_DEGTORAD)

Basically, your arrow moves wrong because the initial value is wrong and the arrow is trying to be correct but it can't be correct.

Anyway, do you mind sending me the onCreate settings?
(Or the whole struct)

Btw, this would be even better:

JASS:
 public static method new takes spell ins, unit caster, real spellx, real spelly returns thistype
    local real x = GetUnitX(caster)
    local real y = GetUnitY(caster)
    local real angle = Atan2(spelly - y, spellx - x)
    local real xloc = x + 2500. * Cos(angle)
    local real yloc = y + 2500. * Sin(angle)
    local thistype this = thistype.create(x, y, GetLocZ(x, y) + 75., angle)

    set .source = caster
    set .spellInst = ins
    
    call .setTargetPos(xloc, yloc)
    call BJDebugMsg("curren shot angle= " + R2S(angle * bj_RADTODEG))
    
    return this
endmethod
 
Level 12
Joined
Sep 4, 2007
Messages
407
your way solves it. but i found another curious thing XD let see how can i paste it in here. So, i discovered that GetLocZ(x,y) is a relative parameter between the current location and the "cast" location. that means that the "real height" (.z - GetLocZ(x,y)) of the current missile location only works if the current terrain height of the missile's location is equal to the "cast" terrain height location. Is there any way to solve this?

by "cast" i mean the location of the missile at the moment of it's creation

here's a screenshot explaining:

138643-albums3204-picture27769.jpg


The red circle one is the first projectile. the red retangle contains the first projectile data.
the blue circle one is the second. the blue retangle contains the second projectile data.

notice that both are practically at the same Y, and as the image shows, they should be at almost the same "Z" aswell.
The calcule .z - GetLocZ(x,y) suppose to set the minimum real height to approximally 0, but in the picture is negative (because the GetLocZ(x,y) is relative to the "cast" location). Is ther anyway to the GetLocZ be a universal parameter?

This is important to me because i want to create a headshot system, that depends on the "real height" of the missile when it hits the unit.

here's the struct of the spell:
JASS:
     private struct spellMissile extends CustomMissile
        private spell   spellInst = 0
        
        private unit source = null
        
        public static method new takes spell ins, unit caster, real spellx, real spelly returns thistype
           local real x = GetUnitX(caster)           
           local real y = GetUnitY(caster)
           local real angle = Atan2(spelly - y, spellx - x)
           local real xloc = x + 1500. * Cos(angle)
           local real yloc = y + 1500. * Sin(angle)
           local real rangethrueshold = 1500
           local thistype this = thistype.create(x, y, GetLocZ(x, y) + 75., angle)

           local real xth = spellx - x
           local real yth = spelly - y
           local real thdistance = SquareRoot(xth * xth + yth * yth) 
           
           set .source = caster
           set .spellInst = ins
           
           if thdistance > rangethrueshold then
               call .setTargetPos(xloc, yloc)
           else
               call .setTargetPos(spellx, spelly)
           endif
           return this
        endmethod
        
        method onCreate takes nothing returns nothing
            set .sfx         = "Abilities\\Weapons\\Arrow\\ArrowMissile.mdl"
            set .movespeed   = 1000. // the best = 2000 , but i'm using 1000 for testing.
            set .hitrange    = 32. // collision size of basic model.
            set .decay       = 20. // The missle will be destroied 20 seconds after it's creation, no matter if it stops or not.
            set .height      = 50.
            set .hitunits    = true
            set .hitdests    = true
            set .autoface    = true
            set .zarc        = 0.03
            set .checkheight = false
            set .hitwalls    = true
        endmethod
        
        method onDestTouch takes destructable theDestructable returns nothing
            local real realhigh = .z - GetLocZ(x,y)
            set .active = false
            call BJDebugMsg("TREE HIT!!!")
            call BJDebugMsg("X= " + R2S(.x) + " Y= " + R2S(.y) + " Real Projectile Height= " + R2S(realhigh))
            set .colorR = 0   //
            set .colorG = 255  // needed to make the missile more visible so it changes the color to green when it hit's the tree.
            set .colorB = 0   //
        endmethod
        
        method onTargetReach takes nothing returns nothing
            local real realhigh = .z - GetLocZ(x,y)
            call BJDebugMsg("X= " + R2S(.x) + " Y= " + R2S(.y) + " Real Projectile Height=" + R2S(realhigh)) // real height will always be a number close to 0.00 unless the terrain's height at missile's creation is different from the terrain's height at onTargetReach. (need to solve this)
            set .active = false
            set .alive = true
        endmethod
        
        method onUnitTouch takes unit theUnit returns nothing
            local real realhigh = .z - GetLocZ(x,y) // the real heigh makes the terrain heigh be equal to 0.00 so i can calculate the relative height of the missile when it hit's the target.(not fully functional - only works if terrain's height at missile's creation is equal to the terrain's height at onUnitTouch.)
            if GetUnitState(theUnit, UNIT_STATE_LIFE) <= 0 then
                return
            endif
            if theUnit == .source then
                return
            endif
            call UnitDamageTarget(.source, theUnit, 100., false, false, ATTACK_TYPE_PIERCE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_METAL_LIGHT_SLICE)
            set .active = false // sets the missile static so i can se where it hit the target.
            call BJDebugMsg("UNIT HIT!!!")
            call BJDebugMsg("X= " + R2S(.x) + " Y= " + R2S(.y) + " Real Projectile Height= " + R2S(realhigh))
            set .colorR = 255 //
            set .colorG = 0   // needed to make the missile more visible so it changes the color to red when it hit's the target.
            set .colorB = 0   //
            return
        endmethod
    endstruct

In a graphic I might explain better:

138643-albums3204-picture27775.jpg


i need to know that little mathematic function. Need to use GetLocZ(x,y) as a parameter (for the mathematic not jass)
 
Last edited:
So, i discovered that GetLocZ(x,y) is a relative parameter between the current location and the "cast" location.
that means that the "real height" (.z - GetLocZ(x,y)) of the current missile location only works if the current terrain height
of the missile's location is equal to the "cast" terrain height location. Is there any way to solve this?
Oh wait, you always get the ABSOLUTE height of the missile at ANY missile location with
JASS:
call BJDebugMsg("Missiles absolute height is: " + R2S(.z))

When you move the missile it will automatically change so that on non-flat terrain it will be on the same height.
This is a feature.

notice that both are practically at the same Y, and as the image shows, they should be at almost the same "Z" aswell.
Nope, they should not, because the one unit is standing on the hill. It's a feature that you will always hit the correct vector.

The calcule .z - GetLocZ(x,y) suppose to set the minimum real height to approximally 0, but in the picture is negative (because the GetLocZ(x,y) is relative to the "cast" location). Is ther anyway to the GetLocZ be a universal parameter?
Nope, it's NOT relative to any position.
It's always the terrain height of the terrain you have there.

Edit:
JASS:
method onUnitTouch takes unit theUnit returns nothing
        local real realhigh = GetUnitFlyHeight(.getEffUnit())
        if GetUnitState(theUnit, UNIT_STATE_LIFE) <= 0 then
            return
        endif
        if theUnit == .source then
            return
        endif
        call UnitDamageTarget(.source, theUnit, 100., false, false, ATTACK_TYPE_PIERCE, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_METAL_LIGHT_SLICE)
        set .active = false // sets the missile static so i can se where it hit the target.
        call BJDebugMsg("UNIT HIT!!!")
        call BJDebugMsg("X= " + R2S(.x) + " Y= " + R2S(.y) + " Real Projectile Height= " + R2S(realhigh))
        set .colorR = 255 //
        set .colorG = 0   // needed to make the missile more visible so it changes the color to red when it hit's the target.
        set .colorB = 0   //
        return
    endmethod
Btw, this should work.
 
Level 12
Joined
Sep 4, 2007
Messages
407
well, ok i get it, but can you help me with that? the z is fixed no matter the terrain high right? that means the height check (how tall a unit is for onUnitTouch purposes) of units in terrain above or bellow normal should be different. but it isn't. check out the graphic. The way it is a projectile may pass through an unit's head or shoulderss and not touch it if the unit's is in higher terrain while it would on lower terrain.
 
well, ok i get it, but can you help me with that? the z is fixed no matter the terrain high right? that means the height check (how tall a unit is for onUnitTouch purposes) of units in terrain above or bellow normal should be different. but it isn't. check out the graphic. The way it is a projectile may pass through an unit's head or shoulderss and not touch it if the unit's is in higher terrain while it would on lower terrain.
Sadly there is no way to get an units model height, even with vJass.
There is no way to solve this, sorry, if there would be any, I would do it, but there really isn't.
 
Level 12
Joined
Sep 4, 2007
Messages
407
u didn't get it. I imput the model's height using .z! like that villagerman: his head is located at .z 100 for example (not real value, but it works, i discover the values by try and error ingame stating the .z of the arrow when it hits the target). Since i'm only using models with the same ".z height" that can be easilly simulated as i've shown you with the graphic!
I just whant to compensate the terrain height in ".z height", get it?
 
Level 12
Joined
Sep 4, 2007
Messages
407
the "constant" height of the missile according to the terrain

Example: if a unit is in elevated ground, it's head is at same "height" value than at lower ground. .z does not does that. i wanna know which value/variable do i use to measure that o_O

i think (you tell me) capturing the arrow's flying height would do but i dunno how you call the "missile" (.what?)

i also want to know how to call for an special effect using your customeffects system. (I wanna blood splash effects at the exact same location and .z the missile hits the widget)
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Okay, he even drew a picture; by this point I think that it's pretty clear.

He wants to account for changes in the terrain height from the source of the missile to the target of the missile so that the height offset at both of those locations is a certain, predefined amount (he has given the example of 100).
 
the "constant" height of the missile according to the terrain
There is no constant height, it's based on terrain height and fly height from the missile (Plus missile height).

Example: if a unit is in elevated ground, it's head is at same "height" value than at lower ground. .z does not does that. i wanna know which value/variable do i use to measure that o_O
You mean you want to aim the missile for units head and not for the feet?

i think (you tell me) capturing the arrow's flying height would do but i dunno how you call the "missile" (.what?)
Well, I don't really know what you are talking about, sadly, could you make a quick draw?

i also want to know how to call for an special effect using your customeffects system. (I wanna blood splash effects at the exact same location and .z the missile hits the widget)
Well you can just create an effect and use the 'oTip' destructable to move it to the corrospondenting z height.

And you always get the absolute x, y and z of the missile by using .x, .y and/or .z.

He wants to account for changes in the terrain height from the source of the missile to the target of the missile so that the height offset at both of those locations is a certain, predefined amount (he has given the example of 100).
You can't really do that with my engine right now. I'll add x, y and z-Offsets in the next version. Thanks for telling.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
If you used vectors it wouldn't really be a problem, the way I have it set up is so that the user chooses both the 3D location that the projectile starts, and the 3D location that the projectile finishes.
 
Level 12
Joined
Sep 4, 2007
Messages
407
Well, I don't really know what you are talking about, sadly, could you make a quick draw?

dude, whats the variable name of the missile? so I can try
JASS:
GetUnitFlyHeight(variablename)

EDIT: oh wait, you edited the post. let me check if that worked. if it does i'll implement a HeadShot system, datz gonna be grait
 
If you used vectors it wouldn't really be a problem, the way I have it set up is so that the user chooses both the 3D location that the projectile starts, and the 3D location that the projectile finishes.
I will use an offset that always is added after calculation, so it hasn't anything to do with start/endloc and can be removed in flight.

dude, whats the variable name of the missile? so I can try
JASS:
GetUnitFlyingHeight(variablename)
Anachron said:
JASS:
    method onUnitTouch takes unit theUnit returns nothing
        local real realhigh = GetUnitFlyHeight(.getEffUnit())
 
Level 12
Joined
Sep 4, 2007
Messages
407
yeah you edited the post and I didn't noticed, srry 'bout dat

Edit:

LOL, this works just fine:
JASS:
local real realhigh = GetUnitFlyHeight(.getEffUnit())
now i can put my headshot system to work (and the projectiles that goes above the target won't hit him never (unless he jumps but datz gonna be stupid)).

thanks, sorry for all this mess xD
 
Top