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

xyz Momentum v1.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
A kind of a jump system

I'm aware that there is plenty of jump systems on the hive but all of them uses Parabola logic or something similar. What makes this system different is the fact that it uses real life gravity and friction.

Each unit in the system has momentum in the x, y and z direction. While the unit is in the air, only the unit's z value will change according to gravity. While the unit is on the ground, only the XY value will change according to friction. If two forces in opposite directions is applied to the unit, the forces will be cancel out. This system also contains an event when the unit lands.

Modify this system however you want, just remember credits, thanks :)

Requires Bribe's or similar Unit Indexer

  • ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Gravity = -2.50
      • Set Friction = -1.50
      • Set XBountry = 3300.00
      • Set YBountry = 3300.00
  • Momentum loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in MomentumGroup and do (Actions)
        • Loop - Actions
          • Set Cus = (Custom value of (Picked unit))
          • Set Temp_Point = (Position of UDexUnits[Cus])
          • Set XCur = (X of Temp_Point)
          • Set YCur = (Y of Temp_Point)
          • Custom script: if RAbsBJ(udg_XCur) > udg_XBountry then
          • Set XVel[Cus] = (XVel[Cus] x -1.00)
          • Custom script: endif
          • Custom script: if RAbsBJ(udg_YCur) > udg_YBountry then
          • Set YVel[Cus] = (YVel[Cus] x -1.00)
          • Custom script: endif
          • Set ZCur = (Current flying height of UDexUnits[Cus])
          • Custom script: set udg_ZGround = GetLocationZ(udg_Temp_Point)
          • Custom script: call RemoveLocation(udg_Temp_Point)
          • Custom script: call SetUnitX(udg_UDexUnits[udg_Cus],udg_XCur + udg_XVel[udg_Cus])
          • Custom script: call SetUnitY(udg_UDexUnits[udg_Cus],udg_YCur + udg_YVel[udg_Cus])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ZCur Less than 1.00
              • ZVel[Cus] Less than or equal to 0.00
            • Then - Actions
              • Custom script: if udg_ZVel[udg_Cus] < 0 then
              • Set LandPoint = (Position of UDexUnits[Cus])
              • Special Effect - Destroy LeapSFX[Cus]
              • Custom script: call DestroyEffect(AddSpecialEffectLoc( udg_LandSFX[udg_Cus],udg_LandPoint))
              • Set ZVel[Cus] = (ZVel[Cus] x -1.00)
              • Set LandEvent = 1.00
              • Set LandEvent = 0.00
              • Custom script: call RemoveLocation(udg_LandPoint)
              • Set ZVel[Cus] = 0.00
              • Custom script: endif
              • Custom script: set udg_XVel[udg_Cus] = udg_XVel[udg_Cus] + (udg_Friction / (RAbsBJ(udg_XVel[udg_Cus]) + RAbsBJ(udg_YVel[udg_Cus]))) * udg_XVel[udg_Cus]
              • Custom script: set udg_YVel[udg_Cus] = udg_YVel[udg_Cus] + (udg_Friction / (RAbsBJ(udg_XVel[udg_Cus]) + RAbsBJ(udg_YVel[udg_Cus]))) * udg_YVel[udg_Cus]
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Abs(XVel[Cus])) Less than 1.00
                  • (Abs(YVel[Cus])) Less than 1.00
                • Then - Actions
                  • Set XVel[Cus] = 0.00
                  • Set YVel[Cus] = 0.00
                  • Unit Group - Remove UDexUnits[Cus] from MomentumGroup
                  • Custom script: if CountUnitsInGroup(udg_MomentumGroup) == 0 then
                  • Trigger - Turn off (This trigger)
                  • Custom script: endif
                • Else - Actions
            • Else - Actions
              • Set Temp_Point = (Point((XCur + XVel[Cus]), (YCur + YVel[Cus])))
              • Custom script: set udg_LocDiffirence = GetLocationZ(udg_Temp_Point)
              • Custom script: call RemoveLocation(udg_Temp_Point)
              • Custom script: call SetUnitZ(udg_UDexUnits[udg_Cus], udg_ZCur + udg_ZVel[udg_Cus] + udg_ZGround - udg_LocDiffirence)
              • Set ZVel[Cus] = (ZVel[Cus] + Gravity)
  • Example
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Leap
    • Actions
      • Custom script: if CountUnitsInGroup(udg_MomentumGroup) == 0 then
      • Trigger - Turn on Momentum loop <gen>
      • Custom script: endif
      • Set Cus = (Custom value of (Triggering unit))
      • Unit Group - Add UDexUnits[Cus] to MomentumGroup
      • -------- Let the Land event trigger know what ability are we dealing with --------
      • Set LeapType[Cus] = Leap
      • -------- - --------
      • -------- The following is used to calculate xyz --------
      • Set CastPoint = (Position of UDexUnits[Cus])
      • Set TargetPoint = (Target point of ability being cast)
      • Set Distance = (Distance between CastPoint and TargetPoint)
      • -------- - --------
      • -------- Here you set the amount of momentum... This equation must be ajusted if you change the gravity to ensure that the unit land on the target point accuratly --------
      • Set XVel[Cus] = (XVel[Cus] + (((Square root(Distance)) / 1.40) x (Cos((Angle from CastPoint to TargetPoint)))))
      • Set YVel[Cus] = (YVel[Cus] + (((Square root(Distance)) / 1.40) x (Sin((Angle from CastPoint to TargetPoint)))))
      • Set ZVel[Cus] = (2.00 x ((Abs(XVel[Cus])) + (Abs(YVel[Cus]))))
      • -------- The Z value may be a fixed value. Just remember to ajust the X and Y --------
      • -------- - --------
      • Custom script: call RemoveLocation(udg_TargetPoint)
      • Special Effect - Destroy LeapSFX[Cus]
      • -------- Configurate landing special effect --------
      • Special Effect - Create a special effect attached to the orign of UDexUnits[Cus] using Abilities\Weapons\ProcMissile\ProcMissile.mdl
      • -------- - --------
      • Set LeapSFX[Cus] = (Last created special effect)
      • -------- More Configuratables --------
      • Set LandSFX[Cus] = Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
      • Set LeapDamageSource[Cus] = UDexUnits[Cus]
      • Set LeapDamageAmount[Cus] = 300.00
      • Set LeapDamageAoE[Cus] = 300.00
  • Land Event
    • Events
      • Game - LandEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LeapType[Cus] Equal to Leap
        • Then - Actions
          • Custom script: call DestroyEffect(AddSpecialEffectLocBJ( udg_LandPoint, "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl" ))
          • Unit Group - Pick every unit in (Units within LeapDamageAoE[Cus] of LandPoint matching (((Owner of (Matching unit)) is an enemy of (Owner of LeapDamageSource[Cus])) Equal to True)) and do (Actions)
            • Loop - Actions
              • Unit - Cause LeapDamageSource[Cus] to damage (Picked unit), dealing (5.00 x ZVel[Cus]) damage of attack type Spells and damage type Normal
          • Custom script: call DestroyGroup(GetLastCreatedGroup())
        • Else - Actions
Keywords:
knock, back, momentum, leap, jump, fall, throw, system, trajectory
Contents

Just another Warcraft III map (Map)

Reviews
12th Dec 2015 IcemanBo: For long time as NeedsFix. Rejected. 19:56, 8th Apr 2015 IcemanBo: Will wait for your next update. Read posts in thread.

Moderator

M

Moderator

12th Dec 2015
IcemanBo: For long time as NeedsFix. Rejected.

19:56, 8th Apr 2015
IcemanBo: Will wait for your next update. Read posts in thread.
 
Level 11
Joined
Dec 19, 2012
Messages
411
  • Custom script: if CountUnitsInGroup(udg_MomentumGroup) == 0 then
  • Trigger - Turn on Momentum loop <gen>
  • Custom script: endif
  • Set Cus = (Custom value of (Triggering unit))
  • Unit Group - Add UDexUnits[Cus] to MomentumGroup
Just want to know why when the unit group contain no unit then turn on the trigger?

Ignore that my mistake...

EDIT : Well please add comments text about the configurable parts and explain what do the variables do as well as explain the trigger part.

Special effect, damage type, attack type, attack range, attack damage, leap range should all be configurable.

Besides that, you should also disable the leap spell if the unit is leaping (wouldn't that strange if you can leap again in the air?)
 
-Don't pause and unpause the jumper
-Turn off its collision while jumping
I didn't pause the unit. I will remove collision size

EDIT : Well please add comments text about the configurable parts and explain what do the variables do as well as explain the trigger part.

Special effect, damage type, attack type, attack range, attack damage, leap range should all be configurable.

Besides that, you should also disable the leap spell if the unit is leaping (wouldn't that strange if you can leap again in the air?)
More comments? Alright I'll work on that.

Special effects and damage are already configurable. I'm not sure how to put damage/attack type in a variable. For your leap range idea - I'll reply on that in the reserved post.

The spell was just an example to show you how to use the system. You can easily tune the system by disable it in casting trigger and enable the spell in the land event. Thanks for posting :).

Your variable namings are way too specific for global variables, like Cus, XCur, LandPoint, LandEvent, etc. There is a good chance those name will conflict with other user-defined variables in their maps. Please, fix them.

Roger that.
 
To make it launch (and land) on a fixed point using momentum you can use the following formula:
ZVelocity = (((TargetZ + GetLocationZ(Target)) - StartHeightZ) / (TimeToImpact / TimerSpeed)) + ((Gravity / TimerSpeed) * TimeToImpact) / 2

- TagretZ is how high you want to be at the end (0 in your case)
- StartHeightZ being the Z height of the jumper (Flying Height + LocationZ + StartHeight), 0 + LocationZ + 0 for a jump system I imagine
- TimeToImpact will be the distance to travel / Momentum (Get the distance you're going to travel and then divide it by the speed (squareroot(Xvel2 + Yvel2) This should end up being the time it'll take in seconds
- TimerSpeed is the speed at which the loop operates (0.03)
- Gravity is well, gravity
- If you're still getting problems, depending on how your system works dividing by (TimeToImpact/TimerSpeed) at the end or some variant of it can fix the issues, though I don't see why you would have this issue (I sometimes get the issue because of how I store the velocities)
 
I'm not sure if I've done something wrong but the Caster stays flat on the ground. This is what I've done:
  • Set xyz_Distance = (Distance between CastPoint and TargetPoint)
  • Set xyz_XVel[Cus] = (xyz_XVel[Cus] + (((Square root(xyz_Distance)) / 1.40) x (Cos((Angle from CastPoint to TargetPoint)))))
  • Set xyz_YVel[Cus] = (xyz_YVel[Cus] + (((Square root(xyz_Distance)) / 1.40) x (Sin((Angle from CastPoint to TargetPoint)))))
  • Custom script: set udg_xyz_Time = udg_xyz_Distance/SquareRoot((udg_xyz_XVel[udg_Cus]*udg_xyz_XVel[udg_Cus]) + (udg_xyz_YVel[udg_Cus]*udg_xyz_YVel[udg_Cus]) )
  • Custom script: set udg_xyz_ZVel[udg_Cus] = (((0 + GetLocationZ(udg_TargetPoint)) - 0) / (udg_xyz_Time / 0.03)) + ((udg_Gravity / 0.03) * udg_xyz_Time) / 2
 
Well I'll give you the base formula for which the one I gave earlier is derived.
You start with your suvat equation for s (displacement)
s = ut + (at2)/2
applying to your case:
where s is the difference in z height, u is the initial z velocity, a is the acceleration and t is how long until it hits the target
rearrange to find u:
ut = s - (at2)/2
u = (s - (at2)/2)/t
Perhaps with that you'll be able to better get the formula you want for it to work, since the one I gave was an in-practice example of how it works (and as stated, depending on how your system handles it, changes the specifics of the formula)
(keep in mind it's important to remember which direction is up and down in terms of the equation, if gravity is negative (down) then when calculating the difference in height. If the point is lower then the displacement (s) should also be negative, I notice you made this mistake when you were trying to use the one I gave you - I should've pointed that out but only noticed it now)
 
Top