• 🏆 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!

Reflection

Status
Not open for further replies.
Level 16
Joined
Aug 20, 2009
Messages
1,552
Hi, I wanted to simulate a reflection,
in my missile system.

http://en.wikipedia.org/wiki/File:Corner-reflector.svg
http://en.wikipedia.org/wiki/File:Fényvisszaverődés.jpg
http://en.wikipedia.org/wiki/File:Reflection_angles.svg

Assuming you know the position of the shooter,
direction to which its shot to,
Position on where it hits a wall (how do we find the normal of the wall? o_O)
Direction of the bullet.

how do i do this?

i saw maps like Elimination tournament are able to do this.

anyone give me a hint or idea?
 
Last edited:
Hmm it depends on your map, if you use cliffs you can detect projectile Z coordinate and if it's value higher than some constant you set you can then handle reflection.

If you don't use cliffs you can use dummy units for example and check is projectile in range of dummy each time when you move it, and so on.

You can use recs as well.

Well it depend on map really, decide will you code this to work for your map or to be public resource.
 
Level 16
Joined
Aug 20, 2009
Messages
1,552
What i want to achieve is, how does it detects the terrain's normal?
i know very little of jass, and its very limited.

and i wanted to create one for pathing blockers (assuming they count as infinite height).
since my map mostly contains doodads, and there is no "Cliffs" around.

I hear from someone in chat, that is familiar with the system, that its possible to do with pathing blockers, but its a "bit" more complex.

3 equations or so i hear. i forgot what he said xD
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
When using vectors for unit or projectile movement, you add vector's coordinates to unit's.
So you start off by finding the vector with which the projectile should move.
To get vector between 2 locations, you subtract coordinates of location towards which vector should point to with coordinates of location from which vector should point (which is projectile's starting location). The resulting coordinates are coordinates of your vector. This vector has proper direction, but length of distance between those locations.
Now you set vector's length using setLength function from Antiarf's library to the speed of the projectile (the speed per tick, which is usually how much the projectile moves each 0.03 secs).
In the looping trigger, assuming v is your vector and p projectile, do this:
JASS:
SetUnitX(p) = GetUnitX(p) + v.x //vector's X
SetUnitY(p) = GetUnitY(p) + v.y //Y
SetUnitZ(p) = GetUnitZ(p) + v.z //Z
JASS:
library Z
    globals
        private location l = Location(0.00,0.00)
    endglobals  

    function GetUnitZ takes unit u returns real
        call MoveLocation(l, GetUnitX(u), GetUnitY(u))
        return GetUnitFlyHeight(u) + GetLocationZ(l)
    endfunction

    function SetUnitZ takes unit u, real z returns nothing
        call MoveLocation(l, GetUnitX(u), GetUnitY(u))
        return SetUnitFlyHeight(u, z - GetLocationZ(l), 0)
    endfunction

endlibrary
When hitting terrain or cliffs (when projectile's height is 0), use createTerrainNormal function to make a terrain normal vector, project movement vector on terrain normal one and add the projection to the movement vector.

For pathing blockers, it depends how you place them :X
If they form straight lines on map edges, for example, you can, when projectile flies over them, enumerate nearby pathing blockers to find angle between them. Then create a vector perpendicular to this line and add it to the movement vector.
 
Status
Not open for further replies.
Top