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

Shoot an Arrow

Status
Not open for further replies.
Level 2
Joined
May 8, 2014
Messages
10
Hello, I am making a map that will be a continuation of map known as Archers ES v 4.4 and I need a nice shooting system for arrows. Though I am new to mapmaking but have read a lot of articles about triggers and jass. So I made something that was looking like a good thing, but it appeared to have some problems. For example, using this shoot ability on the bridge makes arrow to fly very hight above archer and bridge. Also it's not very realistic, I really want it to be similiar with shooting system in Elimination Tournament map, but just have no ideas about how to do it.... So I hope very much that some kind man will help me with this. I attached a separate map with shooting system I made and ET map.
 

Attachments

  • Shoot.w3x
    43.3 KB · Views: 64
  • Elimination Tournament 2.w3x
    1.1 MB · Views: 46
Level 26
Joined
Aug 18, 2009
Messages
4,097
Give your missile move type none, remove elevation points and elevation radius, max roll and max pitch. Each time you move the missile, adjust the fly height via trigger (subtract the terrain height). Add/Remove ability Raven Form once to enable fly height changes on the unit.

To be more realistic, you should imitate physical laws, for example shoot the arrow in an arc by granting it start speedZ, which gets decreased over time (gravity).
 
Level 2
Joined
May 8, 2014
Messages
10
Well I meant realistic, but not like real arrows fly, maybe it was a wrong word...I did everything exept adjusting fly height, subtracting the terrain height,because I don't know how to get terrain height and how this will help. Will it make missle fly height undependent from terrain?
 
GetLocationZ If I recall right is the function to grab the height of terrain.

You'll have to set a variable to it through custom script or JASS.

Example; set udg_z = GetLocationZ(udg_pickedunit)

Now try using that however I don't know if it'll work because that is just an example. I don't remember it correctly myself so wait for someone better at JASS then me to reply unless you did after all read JASS.


Found a better example for you. http://www.hiveworkshop.com/forums/...tem-v1-02-a-157856/?prev=d=icon&r=200&u=nfwar
 
Level 2
Joined
May 8, 2014
Messages
10
Oh yes, GetLocationZ , how could I forget about it. As for the example, it's more about arc missles, so I don't think it's the thing I need.


Now It goes horizontally, nice.Now it is close to that what I want, but if you shoot from a cliff to the point below your unit level you want missle to go to that point, but not horisontally.
 
Level 2
Joined
May 8, 2014
Messages
10
Yes, thanks for reminding me that func. I think now the system must became much comlicated bcs shooting from below point makes missle to climb at it and then fly horosontally again, which it not realistic too.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Grab the target terrain height minus the source terrain height. That is the delta that needs to be gradually added to the missile. Divide it by the amount of update intervals which is R2I(overallDuration / updateInterval). Then start a periodic timer to add the calculated value in updateInterval. Do not forget to set the starting height of the missile.

However, a fly height cannot be negative (below terrain).

_A_/\_B_

If you shoot from A to B, it won't travel through the cliff in the middle graphics-wise, instead cling to the terrain there. You may edit the model to offset the pivot point and then always add that offset in the SetUnitFlyHeight-calls.
 
Level 2
Joined
May 8, 2014
Messages
10
That seems to be a clever thing. But I think that I didn't got 2-nd part of your reply, but think missle must just disapear while it's going to hit that cliff
 
Level 2
Joined
May 8, 2014
Messages
10
And how can I make arrow face target point? I mean it is facing it now, but only in X and Y.
 
Last edited:
Level 26
Joined
Aug 18, 2009
Messages
4,097
Pitch/Roll cannot be set via trigger directly. You could edit the model to have a head/chest bone, so you can use SetUnitLookAt or you implement different animations where you rotate the model a bit further each, that you can then select ingame via SetUnitAnimationByIndex or AddUnitAnimationProperties.

There is a model somewhere uploaded that does that but is invisible by itself. You can attach your arrow as an effect on this model, so it gets rotated as well. The disadvantage is that you subsequently have less control over the arrow.
 
Level 2
Joined
May 8, 2014
Messages
10
Was trying to make it atleast fly right to the point, but it doen't work properly, it gets lower fly height only once and I can't see a mistake. Maybe you can do it...

  • local real correction
  • local real number
  • set number = (udg_TargetDistance/udg_Speed)
  • set correction = (GetLocationZ(udg_TargetLoc) - GetLocationZ(udg_AppearLoc))/number
  • set udg_TempLoc1 = GetUnitLoc(GetEnumUnit())
  • set udg_TempLoc2 = PolarProjectionBJ(udg_TempLoc1, I2R(udg_Speed), GetUnitFacing(GetEnumUnit()))
  • call SetUnitX(GetEnumUnit(), GetLocationX(udg_TempLoc2))
  • call SetUnitY(GetEnumUnit(), GetLocationY(udg_TempLoc2))
  • call SetUnitFlyHeight(GetEnumUnit(),GetLocationZ(udg_AppearLoc) - GetLocationZ(udg_TempLoc2) + correction,0)
And this happens every 0.01 sec.
 
Last edited:
Level 2
Joined
May 8, 2014
Messages
10
There is last thing I tried to do with SetUnitFlyHeight to make it's flyight horizontal
 

Attachments

  • Shoot.w3x
    43.2 KB · Views: 83
Level 26
Joined
Aug 18, 2009
Messages
4,097
Well, multiple things. You did not remove the same Crow Shape ability that you added. You were supposed to determine the terrain height difference between ending and start point of the total movement, not in the individual steps. As I said, this value has to be divided by the amount of steps, so steps*dZ per step sums up to the total height difference that shall be climbed over the travel duration. Then you need to save the current missile's height, initial value + dZ per step.

Take a look at what I inserted. You still need to make it MUI etc., index the missile and save data in an array, hashtable or similar.
 

Attachments

  • Shoot.w3x
    42.6 KB · Views: 36
Level 2
Joined
May 8, 2014
Messages
10
Really that was a mistake, don't know why I made determing the terrain height difference in the loop, now it looks pretty simple. Thanks
 
Status
Not open for further replies.
Top