• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

good moving

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2013
Messages
1,105
  • Custom script: call SetUnitX(udg_TempUnit), GetUnitX(udg_TempUnit) + udg_AmountOffset * Cos(bj_DEGTORAD * udg_Angle))
  • Custom script: call SetUnitY(udg_TempUnit), GetUnitY(udg_TempUnit) + udg_AmountOffset * Sin(bj_DEGTORAD * udg_Angle))

Angle's a real.
AmountOffset is an int.
 
Level 25
Joined
Sep 26, 2009
Messages
2,387
The custom scripts look like this:
  • Custom script: call SetUnitX(udg_Your_Unit, udg_x_Coordinate)
  • Custom script: call SetUnitY(udg_Your_Unit, udg_y_Coordinate)
SetUnitX moves Your_Unit to x_Coordinate
SetUnitY does basically the same - it moves Your_Unit, but to y_Coordinate

all variables have to have the udg_ prefix - e.g. Your_Unit variable has to look like this in custom script: udg_Your_Unit.

X and Y coordinates are real numbers, but you don't necessarily have to set them before hand.
You can get X and Y coordinates via function from point or from unit's position.
GetLocationX(udg_Your_Point) gets X coordinate from Your_Point variable.
GetUnitX(udg_Your_Unit) gets X coordinate from Your_Unit variable.
Both can be used to get Y coordinate as well.

So instead of real variable you can use one of the function above - e.g.
  • Custom script: call SetUnitX(udg_Your_Unit, GetLocationX(udg_Your_Point))
  • - or -
  • Custom script: call SetUnitX(udg_Your_Unit, GetUnitX(udg_Your_Unit))
If you want to change the location, where the unit will be moved a bit, you can also add another number/variable there - just like pOke did - e.g.
  • Custom script: call SetUnitX(udg_Your_Unit, GetUnitX(udg_Your_Unit) + 70)
This will move Your_Unit to the location where Your_Unit stands + 70 more on the X axis.
You don't have to use numbers only, you can use another variable, or function and you're not limited to only 1 additional number - you can see in pOke's post that he in fact got the Unit's X coordinate, and add another calculations by using 2 more functions (Cos and DEGTORAD) and 2 more variables (Angle and AmountOffset) => udg_AmountOffset * Cos(bj_DEGTORAD * udg_Angle).

Also note, that SetUnitX and SetUnitY functions ignore map pathing - so a ground unit may be moved into deep water this way, if precaution is not taken.
You can learn more here: http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/about-movement-172309/
 
Level 8
Joined
May 9, 2010
Messages
266
  • Custom script: call SetUnitX(udg_TempUnit), GetUnitX(udg_TempUnit) + udg_AmountOffset * Cos(bj_DEGTORAD * udg_Angle))
  • Custom script: call SetUnitY(udg_TempUnit), GetUnitY(udg_TempUnit) + udg_AmountOffset * Sin(bj_DEGTORAD * udg_Angle))

Angle's a real.
AmountOffset is an int.

Thanks, but I have made like you said yesterday, but my unit just stays =(
I can put in a part of my trigger.
  • Custom script: set udg_ENG_x = GetUnitX(GetEnumUnit())
  • Custom script: set udg_ENG_y = GetUnitY(GetEnumUnit())
  • Custom script: set udg_ENG_xn = udg_ENG_x + udg_ENG_InershionFactor*udg_ENG_SpeedFactor*Cos(udg_ENG_RA*bj_DEGTORAD)
  • Custom script: set udg_ENG_yn = udg_ENG_y + udg_ENG_InershionFactor*udg_ENG_SpeedFactor*Sin(udg_ENG_RA*bj_DEGTORAD)
And after that i used SetUnitX and Y.
The custom scripts look like this:
  • Custom script: call SetUnitX(udg_Your_Unit, udg_x_Coordinate)
  • Custom script: call SetUnitY(udg_Your_Unit, udg_y_Coordinate)
SetUnitX moves Your_Unit to x_Coordinate
SetUnitY does basically the same - it moves Your_Unit, but to y_Coordinate

all variables have to have the udg_ prefix - e.g. Your_Unit variable has to look like this in custom script: udg_Your_Unit.
X and Y coordinates are real numbers, but you don't necessarily have to set them before hand.
You can get X and Y coordinates via function from point or from unit's position.
GetLocationX(udg_Your_Point) gets X coordinate from Your_Point variable.
GetUnitX(udg_Your_Unit) gets X coordinate from Your_Unit variable.
Both can be used to get Y coordinate as well.

So instead of real variable you can use one of the function above - e.g.
  • Custom script: call SetUnitX(udg_Your_Unit, [COLOR="red"]GetLocationX(udg_Your_Point)[/COLOR])
  • - or -
  • Custom script: call SetUnitX(udg_Your_Unit, [COLOR="red"]GetUnitX(udg_Your_Unit)[/COLOR])
If you want to change the location, where the unit will be moved a bit, you can also add another number/variable there - just like pOke did - e.g.
  • Custom script: call SetUnitX(udg_Your_Unit, GetUnitX(udg_Your_Unit)[COLOR="red"] + 70[/COLOR])
This will move Your_Unit to the location where Your_Unit stands + 70 more on the X axis. You don't have to use numbers only, you can use another variable, or function and you're not limited to only 1 additional number - you can see in pOke's post that he in fact got the Unit's X coordinate, and add another calculations by using 2 more functions (Cos and DEGTORAD) and 2 more variables (Angle and AmountOffset) => udg_AmountOffset * Cos(bj_DEGTORAD * udg_Angle).

Also note, that SetUnitX and SetUnitY functions ignore map pathing - so a ground unit may be moved into deep water this way, if precaution is not taken.
You can also learn more here: http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/about-movement-172309/

Thank you for good explanation.
  • Custom script: call SetUnitPosition(GetEnumUnit(), udg_ENG_xn, udg_ENG_yn)
is better than SetUnitX or no?
And yeah, its veeeery good that SetUnitX ignores path conditions ^^.
 
Level 8
Joined
May 9, 2010
Messages
266
Try saving that unit into variable before hand and then get its X and Y coordinates using that unit variable.
  • Custom script: call SetUnitX(udg_TempUnit, udg_ENG_xn)
  • Custom script: call SetUnitY(udg_TempUnit, udg_ENG_yn)
Like this. What i see: the unit stays and after few seconds moves big distance.
With this function
  • Custom script: call SetUnitPosition(GetEnumUnit(), udg_ENG_xn, udg_ENG_yn)
it works fine.

Trigger here:
  • engin periodic loop
    • События
      • Время - Every 0.02 seconds of game time
    • Условия
      • (Number of units in ENG_group) не равно (!=) 0
    • Действия
      • Отряд - Pick every unit in ENG_group and do (Actions)
        • Цикл - Действия
          • Custom script: set udg_ENG_key = GetHandleId(GetEnumUnit())
          • Set ENG_SpeedFactor = (Load (Key SpeedFactor) of ENG_key from ENG_hash)
          • Боевая единица - Turn collision for (Picked unit) Откл.
          • Set TempUnit = (Picked unit)
          • Set ENG_RA = (Facing of (Picked unit))
          • Set ENG_size = (Load (Key Size) of ENG_key from ENG_hash)
            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • Если - Условия
                • ENG_SpeedFactor больше (>) 0.00
              • То - Действия
                • Set ENG_dx = (ENG_SpeedFactor x ENG_BounceKoefficient)
                • Set ENG_dy = ENG_dx
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • Если - Условия
                      • ENG_IsSlow равно (==) Да
                    • То - Действия
                      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • Если - Условия
                          • ENG_SpeedFactor больше (>) ENG_StopFactor
                        • То - Действия
                          • Хэш-таблица - Save (((ENG_SpeedFactor / (1.00 + ENG_SlowLiquidFactor)) - (ENG_SlowFactor x ENG_g)) x 1.00) as (Key SpeedFactor) of ENG_key in ENG_hash
                        • Иначе - Действия
                          • -------- ! --------
                          • Хэш-таблица - Save 0.00 as (Key SpeedFactor) of ENG_key in ENG_hash
                          • Анимация - Change (Picked unit)'s animation speed to 0.00% of its original speed
                    • Иначе - Действия
                • Custom script: set udg_ENG_x = GetUnitX(GetEnumUnit())
                • Custom script: set udg_ENG_y = GetUnitY(GetEnumUnit())
                • Custom script: set udg_ENG_xn = udg_ENG_x + udg_ENG_InershionFactor*udg_ENG_SpeedFactor*Cos(udg_ENG_RA*bj_DEGTORAD)
                • Custom script: set udg_ENG_yn = udg_ENG_y + udg_ENG_InershionFactor*udg_ENG_SpeedFactor*Sin(udg_ENG_RA*bj_DEGTORAD)
                • Set CP_Point = (Point(ENG_xn, ENG_yn))
                • Триггер - Run Check Walkability <gen> (ignoring conditions)
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • Если - Условия
                      • CP_PointIsWalkable равно (==) Нет
                      • ENG_IsWallBounce равно (==) Да
                    • То - Действия
                      • Set TempPoint = (Position of TempUnit)
                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • Если - Условия
                            • ENG_RA больше или равно (>=) 0.00
                            • ENG_RA меньше или равно (<=) 90.00
                          • То - Действия
                            • Custom script: set udg_ENG_xo = udg_ENG_x + udg_ENG_dx
                            • Custom script: set udg_ENG_yo = udg_ENG_y + udg_ENG_dy
                          • Иначе - Действия
                            • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                              • Если - Условия
                                • ENG_RA больше (>) 90.00
                                • ENG_RA меньше или равно (<=) 180.00
                              • То - Действия
                                • Custom script: set udg_ENG_xo = udg_ENG_x - udg_ENG_dx
                                • Custom script: set udg_ENG_yo = udg_ENG_y + udg_ENG_dy
                              • Иначе - Действия
                                • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                  • Если - Условия
                                    • ENG_RA больше (>) 180.00
                                    • ENG_RA меньше или равно (<=) 270.00
                                  • То - Действия
                                    • Custom script: set udg_ENG_xo = udg_ENG_x - udg_ENG_dx
                                    • Custom script: set udg_ENG_yo = udg_ENG_y - udg_ENG_dy
                                  • Иначе - Действия
                                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                      • Если - Условия
                                        • ENG_RA больше (>) 270.00
                                        • ENG_RA меньше или равно (<=) 360.00
                                      • То - Действия
                                        • Custom script: set udg_ENG_xo = udg_ENG_x + udg_ENG_dx
                                        • Custom script: set udg_ENG_yo = udg_ENG_y - udg_ENG_dy
                                      • Иначе - Действия
                      • Custom script: set udg_CP_Point = Location(udg_ENG_xo, udg_ENG_y)
                      • Триггер - Run Check Walkability <gen> (ignoring conditions)
                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • Если - Условия
                            • CP_PointIsWalkable равно (==) Нет
                          • То - Действия
                            • Set ENG_NFA = ((180.00 + (Random real number between (-1.00 x ENG_AngleDeformationFactor) and (1.00 x ENG_AngleDeformationFactor))) - ENG_RA)
                          • Иначе - Действия
                            • Set ENG_NFA = ((0.00 + (Random real number between (-1.00 x ENG_AngleDeformationFactor) and (1.00 x ENG_AngleDeformationFactor))) - ENG_RA)
                      • Custom script: call RemoveLocation(udg_CP_Point)
                      • Хэш-таблица - Clear all child hashtables of child ENG_key in ENG_hash
                      • Отряд - Remove (Picked unit) from ENG_group
                      • Боевая единица - Remove TempUnit from the game
                      • Боевая единица - Create 1 ENG_UnitType for Игрок 1 (красный) at TempPoint facing ENG_NFA degrees
                      • Set ENG_Unit = (Last created unit)
                      • Custom script: set udg_ENG_HandleId0 = GetHandleId(udg_ENG_Unit)
                      • Отряд - Add ENG_Unit to ENG_group
                      • Анимация - Change ENG_Unit's size to (ENG_size%, ENG_size%, ENG_size%) of its original size
                      • Анимация - Change ENG_Unit's animation speed to (ENG_AnimationFactor x ENG_SpeedFactor)% of its original speed
                      • Custom script: call DestroyEffect(AddSpecialEffectLoc( udg_ENG_BounceSFX, udg_TempPoint))
                      • Хэш-таблица - Save (Facing of ENG_Unit) as (Key Angle) of ENG_HandleId0 in ENG_hash
                      • Хэш-таблица - Save (ENG_SpeedFactor x (Power((1.00 - ENG_EnergyFactor), 0.50))) as (Key SpeedFactor) of ENG_HandleId0 in ENG_hash
                      • Хэш-таблица - Save ENG_size as (Key Size) of ENG_HandleId0 in ENG_hash
                    • Иначе - Действия
                • Custom script: call RemoveLocation(udg_TempPoint)
                • Custom script: call RemoveLocation(udg_CP_Point)
                • Custom script: call SetUnitPosition(GetEnumUnit(), udg_ENG_xn, udg_ENG_yn)
                • Custom script: call SetUnitX(udg_TempUnit, udg_ENG_xn)
                • Custom script: call SetUnitY(udg_TempUnit, udg_ENG_yn)
                • Set TempPoint2 = (Position of TempUnit)
                • Set TempGroup = (Units within ((1.00 x ENG_TouchKoefficient) x ENG_size) of TempPoint2 matching (((Unit-type of (Matching unit)) равно (==) (Unit-type of (Picked unit))) and ((Matching unit) не равно (!=) TempUnit)))
                • Отряд - Pick every unit in TempGroup and do (Actions)
                  • Цикл - Действия
                    • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • Если - Условия
                        • (Number of units in TempGroup) не равно (!=) 0
                      • То - Действия
                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                          • Если - Условия
                            • ENG_IsExplode равно (==) Да
                          • То - Действия
                            • Set TempPoint = (Position of (Picked unit))
                            • -------- Взрыв здесь --------
                            • Set ENG_key2 = (Key (Picked unit))
                            • Set ENG_size2 = (Load (Key Size) of ENG_key2 from ENG_hash)
                            • Set ENG_SpeedFactor2 = (Load (Key SpeedFactor) of ENG_key2 from ENG_hash)
                            • Set ENG_TotalDamage = ((((Power(ENG_size, 0.50)) x ENG_SpeedFactor) + ((Power(ENG_size2, 0.50)) x ENG_SpeedFactor2)) x ((Abs(((Facing of TempUnit) - (Facing of (Picked unit))))) + 1.00))
                            • Custom script: //call BJDebugMsg(R2S(udg_ENG_TotalDamage))
                              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • Если - Условия
                                  • ENG_TotalDamage больше или равно (>=) ENG_DestroyFactor
                                • То - Действия
                                  • Set ENG_Picked = (Picked unit)
                                  • Custom script: set udg_ENG_xm = 0.5 * (GetUnitX(GetEnumUnit()) + GetUnitX(udg_TempUnit))
                                  • Custom script: set udg_ENG_ym = 0.5 * (GetUnitY(GetEnumUnit()) + GetUnitY(udg_TempUnit))
                                  • Custom script: set udg_TempPoint2 = Location(udg_ENG_xm, udg_ENG_ym)
                                  • Custom script: set bj_wantDestroyGroup = true
                                  • Отряд - Pick every unit in (Units within 225.00 of TempPoint matching ((Unit-type of (Matching unit)) не равно (!=) (Unit-type of (Picked unit)))) and do (Actions)
                                    • Цикл - Действия
                                      • Set TempPoint = (Position of (Picked unit))
                                      • Боевая единица - Cause ENG_Picked to damage (Picked unit), dealing (((Load (Key Size) of ENG_key from ENG_hash) + (Load (Key Size) of ENG_key2 from ENG_hash)) / (0.05 x (Distance between TempPoint and TempPoint2))) damage of attack type Заклинание and damage type Обычный
                                      • Custom script: call RemoveLocation(udg_TempPoint)
                                  • Custom script: call DestroyEffect(AddSpecialEffectLoc( udg_ENG_StrikeSFX, udg_TempPoint2))
                                  • Отряд - Remove (Picked unit) from ENG_group
                                  • Отряд - Remove TempUnit from ENG_group
                                  • Хэш-таблица - Clear all child hashtables of child ENG_key in ENG_hash
                                  • Хэш-таблица - Clear all child hashtables of child ENG_key2 in ENG_hash
                                  • Боевая единица - Remove (Picked unit) from the game
                                  • Боевая единица - Remove TempUnit from the game
                                  • Custom script: call RemoveLocation(udg_TempPoint2)
                                • Иначе - Действия
                                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • Если - Условия
                                      • ENG_TotalDamage меньше или равно (<=) ENG_NothingFactor
                                    • То - Действия
                                      • Хэш-таблица - Save 0.00 as (Key SpeedFactor) of ENG_key in ENG_hash
                                      • Анимация - Change (Picked unit)'s animation speed to 0.00% of its original speed
                                      • Хэш-таблица - Save 0.00 as (Key SpeedFactor) of ENG_key2 in ENG_hash
                                      • Анимация - Change TempUnit's animation speed to 0.00% of its original speed
                                    • Иначе - Действия
                                      • -------- НЕ Ð*АБОТАЕТ ВСЕГДА --------
                                      • -------- МБ ПОТОМУ ЧТО НЕ ПÐ*ОГÐ*УЖАЕТСЯ SIZE? --------
                                      • -------- действия при среднем попадании --------
                                      • -------- не сильным чтобы разрушить и не слабым чтобы остановиться --------
                                        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                          • Если - Условия
                                            • ENG_SpeedFactor2 равно (==) 0.00
                                          • То - Действия
                                            • -------- действия в случае, когда один из комней стоит --------
                                            • Хэш-таблица - Clear all child hashtables of child ENG_key2 in ENG_hash
                                            • Отряд - Remove ENG_Picked from ENG_group
                                            • Боевая единица - Remove ENG_Picked from the game
                                            • Боевая единица - Create 1 ENG_UnitType for Игрок 1 (красный) at TempPoint facing ENG_NFA degrees
                                            • Set ENG_Unit = (Last created unit)
                                            • Custom script: set udg_ENG_HandleId0 = GetHandleId(udg_ENG_Unit)
                                            • Отряд - Add ENG_Unit to ENG_group
                                            • Set ENG_size = (Load (Key Size) of ENG_key from ENG_hash)
                                            • Анимация - Change ENG_Unit's size to (ENG_size%, ENG_size%, ENG_size%) of its original size
                                            • Анимация - Change ENG_Unit's animation speed to (ENG_AnimationFactor x ENG_SpeedFactor)% of its original speed
                                            • Custom script: call DestroyEffect(AddSpecialEffectLoc( udg_ENG_BounceSFX, udg_TempPoint))
                                            • Хэш-таблица - Save (Facing of ENG_Unit) as (Key Angle) of ENG_HandleId0 in ENG_hash
                                            • Хэш-таблица - Save (ENG_SpeedFactor x 0.80) as (Key SpeedFactor) of ENG_HandleId0 in ENG_hash
                                            • Хэш-таблица - Save ENG_size as (Key Size) of ENG_HandleId0 in ENG_hash
                                            • -------- -*-*- --------
                                            • -------- -*-*- --------
                                            • -------- -*-*- --------
                                            • -------- -*-*- --------
                                            • Set ENG_PUpoint = (Position of TempUnit)
                                            • Set ENG_Point1 = (Position of (Picked unit))
                                            • Set ENG_SpeedFactor = (Load (Key SpeedFactor) of ENG_key from ENG_hash)
                                            • Set ENG_SpeedFactor2 = (Load (Key SpeedFactor) of ENG_key2 from ENG_hash)
                                            • Set ENG_AngleBP = (Angle from ENG_PUpoint to TempPoint)
                                            • Set ENG_size2 = (Load (Key Size) of ENG_key2 from ENG_hash)
                                            • -------- - --------
                                            • Хэш-таблица - Clear all child hashtables of child ENG_key2 in ENG_hash
                                            • Отряд - Remove (Picked unit) from ENG_group
                                            • Боевая единица - Remove (Picked unit) from the game
                                            • -------- - --------
                                            • Боевая единица - Create 1 ENG_UnitType for Игрок 1 (красный) at ENG_Point1 facing ENG_AngleBP degrees
                                            • Set ENG_Unit = (Last created unit)
                                            • Custom script: set udg_ENG_HandleId1 = GetHandleId(udg_ENG_Unit)
                                            • Отряд - Add ENG_Unit to ENG_group
                                            • -------- - --------
                                            • Custom script: call DestroyEffect(AddSpecialEffectLoc( udg_ENG_StrikeSFX, udg_ENG_Point1))
                                            • -------- - --------
                                            • Хэш-таблица - Save (Facing of ENG_Unit) as (Key Angle) of ENG_HandleId1 in ENG_hash
                                            • Хэш-таблица - Save (ENG_SpeedFactor x 0.40) as (Key SpeedFactor) of ENG_HandleId1 in ENG_hash
                                            • Хэш-таблица - Save ENG_size2 as (Key Size) of ENG_HandleId1 in ENG_hash
                                            • -------- - --------
                                            • Хэш-таблица - Save (ENG_SpeedFactor x 0.32) as (Key SpeedFactor) of ENG_key in ENG_hash
                                            • -------- - --------
                                            • Set ENG_SpeedFactor = (Load (Key SpeedFactor) of ENG_HandleId1 from ENG_hash)
                                            • -------- - --------
                                            • Set ENG_size2 = (Load (Key Size) of ENG_HandleId1 from ENG_hash)
                                            • -------- - --------
                                            • Анимация - Change ENG_Unit's size to (ENG_size2%, ENG_size2%, ENG_size2%) of its original size
                                            • Анимация - Change ENG_Unit's animation speed to (ENG_AnimationFactor x ENG_SpeedFactor)% of its original speed
                                            • Custom script: call RemoveLocation(udg_ENG_PUpoint)
                                            • Custom script: call RemoveLocation(udg_TempPoint)
                                          • Иначе - Действия
                                            • -------- основные действия при двух движущихся камнях --------
                                            • -------- пикд юнит = 1-й дв. камень --------
                                            • -------- темп юнит = 2-й дв. камень --------
                            • Custom script: call RemoveLocation(udg_TempPoint)
                            • Custom script: call RemoveLocation(udg_TempPoint2)
                          • Иначе - Действия
                        • Custom script: call RemoveLocation(udg_TempPoint)
                      • Иначе - Действия
                • Custom script: call DestroyGroup(udg_TempGroup)
                • Custom script: call RemoveLocation(udg_TempPoint2)
              • Иначе - Действия
Some part is not on English, but you can see this anyway =)
 
Level 8
Joined
May 9, 2010
Messages
266
i can't read it @,@

  • Set TempUnit = (Picked unit)
  • Set ENG_RA = (Facing of (Picked unit))
  • Custom script: set udg_ENG_x = GetUnitX(GetEnumUnit())
  • Custom script: set udg_ENG_y = GetUnitY(GetEnumUnit())
  • Custom script: set udg_ENG_xn = udg_ENG_x + udg_ENG_InershionFactor*udg_ENG_SpeedFactor*Cos(udg_ENG_RA*bj_DEGTORAD)
  • Custom script: set udg_ENG_yn = udg_ENG_y + udg_ENG_InershionFactor*udg_ENG_SpeedFactor*Sin(udg_ENG_RA*bj_DEGTORAD)
  • Custom script: call SetUnitX(udg_TempUnit, udg_ENG_xn)
  • Custom script: call SetUnitY(udg_TempUnit, udg_ENG_yn)
like this.
Same :/
You should try to convert this to english since i don't understand xD
Here`s a "move part" of this code.
 
Level 8
Joined
May 9, 2010
Messages
266
Depends what you want to do with it.
SetUnitPosition breaks unit's current order, while SetUnitX/Y does not.

Also, what are you trying to achieve with this trigger?

I am doing a bounce system. Just for some expirience. Here is an ability to throw a ston. Stone rolls, bounces fromout a walls, there is friction etc.
  • Custom script: call SetUnitPosition(GetEnumUnit(), udg_ENG_xn, udg_ENG_yn)
- works
  • Custom script: call SetUnitX(GetEnumUnit(), udg_ENG_xn)
  • Custom script: call SetUnitY(GetEnumUnit(), udg_ENG_yn)
- doesnt work =(

since we can't read the whole triggers, the best way is asking

triggers are pretty large :D

EDIT:
Btw i can shell a test map that contains my system if you have the editor.
 
Level 25
Joined
Sep 26, 2009
Messages
2,387
If I convert triggers to English text and post it in private massege, could you help? Or better give you a test map?
posting the map with only those triggers may be better

edit:
I'm giving up... apart from some useless ITEs and some actions which were probably left when you tried other functions, I don't see why it doesn't move via SetUnitX/Y :(
 
Last edited:
Level 20
Joined
Aug 13, 2013
Messages
1,696
Level 20
Joined
Aug 13, 2013
Messages
1,696
Oh yeah internet's awesome ^^
Post your triggers as asked above.

This is the trigger of the Black Hole spell (Trigger Looping) it moves the units at the center and damaging them.
  • Black Hole Loop Pull
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in BH_Group and do (Actions)
        • Loop - Actions
          • Set BH_PickedUnits = (Picked unit)
          • Custom script: set udg_BH_Key = GetHandleId(udg_BH_PickedUnits)
          • Custom script: set udg_BH_X = GetUnitX(udg_BH_PickedUnits)
          • Custom script: set udg_BH_Y = GetUnitY(udg_BH_PickedUnits)
          • Set BH_Caster = (Load (Key caster) of BH_Key in Enigma_Hashtable)
          • Set BH_Reals[1] = (Load 1 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[2] = (Load 2 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[3] = (Load 3 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[4] = (Load 4 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[10] = (Load 5 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[11] = (Load 6 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[12] = (Load 7 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[13] = (Load 8 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[14] = (Load 9 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[15] = (Load 10 of BH_Key from Enigma_Hashtable)
          • Set BH_Counter = (Load (Key counter) of BH_Key from Enigma_Hashtable)
          • Hashtable - Save (BH_Counter + 0.05) as (Key counter) of BH_Key in Enigma_Hashtable
          • Set BH_SmallRadiusDistance = (Distance between (Point(BH_X, BH_Y)) and (Point(BH_PullUnitsX, BH_PullUnitsY)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BH_SmallRadiusDistance Less than or equal to BH_Reals[11]
            • Then - Actions
              • Set BH_SmallRadGroup = (Units within BH_Reals[11] of (Point(BH_X, BH_Y)) matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) belongs to an enemy of (Owner of BH_Caster)) Equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in BH_SmallRadGroup and do (Actions)
                • Loop - Actions
                  • Set BH_SmallRadiusUnits = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Random real number between 0.00 and 100.00) Less than or equal to BH_Reals[12]
                    • Then - Actions
                      • -------- The bonus damage to the small radius. --------
                      • Unit - Cause BH_Caster to damage BH_SmallRadiusUnits, dealing BH_Reals[10] damage of attack type BH_AttackType and damage type BH_DamageType
                      • Custom script: call DestroyEffect (AddSpecialEffectTarget(udg_BH_SmallRadiusDamageEffect,udg_BH_SmallRadiusUnits,udg_BH_SmallRadiusAttachment))
                    • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random real number between 0.00 and 100.00) Less than or equal to BH_Reals[15]
            • Then - Actions
              • Custom script: call DestroyEffect( AddSpecialEffect(udg_BH_CenterSFX,udg_BH_X,udg_BH_Y))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • BH_CenterIgnoreUnitTypes Equal to True
                • Then - Actions
                  • Set BH_CenterIgnoreGroup = (Units within BH_Reals[13] of (Point(BH_X, BH_Y)) matching (((Matching unit) belongs to an enemy of Player 1 (Red)) Equal to True))
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in BH_CenterIgnoreGroup and do (Actions)
                    • Loop - Actions
                      • Set BH_CenterUnits = (Picked unit)
                      • Unit - Cause BH_Caster to damage BH_CenterUnits, dealing BH_Reals[14] damage of attack type BH_CenterAttackType and damage type BH_CenterDamageType
                • Else - Actions
                  • Set BH_CenterGroup = (Units within BH_Reals[13] of (Point(BH_X, BH_Y)) matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) belongs to an enemy of (Owner of BH_Caster)) Equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in BH_CenterGroup and do (Actions)
                    • Loop - Actions
                      • Set BH_CenterUnits = (Picked unit)
                      • Unit - Cause BH_Caster to damage BH_CenterUnits, dealing BH_Reals[14] damage of attack type BH_CenterAttackType and damage type BH_CenterDamageType
            • Else - Actions
          • Set BH_PullGroup = (Units within BH_Reals[3] of (Point(BH_X, BH_Y)) matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) belongs to an enemy of (Owner of BH_Caster)) Equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and (
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in BH_PullGroup and do (Actions)
            • Loop - Actions
              • Set BH_PickedPullUnits = (Picked unit)
              • Hashtable - Save Handle OfBH_PickedPullUnits as 12 of BH_Key in Enigma_Hashtable
              • Custom script: set udg_BH_PullUnitsX = GetUnitX(udg_BH_PickedPullUnits)
              • Custom script: set udg_BH_PullUnitsY = GetUnitY(udg_BH_PickedPullUnits)
              • Set BH_Reals[10] = (Angle from (Point(BH_PullUnitsX, BH_PullUnitsY)) to (Point(BH_X, BH_Y)))
              • Custom script: set udg_BH_MX = udg_BH_PullUnitsX + udg_BH_Reals[4] * Cos( udg_BH_Reals[10] * bj_DEGTORAD)
              • Custom script: set udg_BH_MY = udg_BH_PullUnitsY + udg_BH_Reals[4] * Sin( udg_BH_Reals[10] * bj_DEGTORAD)
              • Custom script: call SetUnitX(udg_BH_PickedPullUnits,udg_BH_MX)
              • Custom script: call SetUnitY(udg_BH_PickedPullUnits,udg_BH_MY)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random real number between 0.00 and 100.00) Less than or equal to BH_Reals[12]
                • Then - Actions
                  • Unit - Cause BH_Caster to damage BH_PickedPullUnits, dealing BH_Reals[1] damage of attack type BH_AttackType and damage type BH_DamageType
                  • Custom script: call DestroyEffect (AddSpecialEffect(udg_BH_DamageSfx,udg_BH_PullUnitsX,udg_BH_PullUnitsY))
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BH_Counter Greater than or equal to BH_Reals[2]
            • Then - Actions
              • Unit - Kill BH_PickedUnits
              • Unit Group - Remove BH_PickedUnits from BH_Group
              • Hashtable - Clear all child hashtables of child BH_Key in Enigma_Hashtable
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (BH_Group is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
 
Level 8
Joined
May 9, 2010
Messages
266
This is the trigger of the Black Hole spell (Trigger Looping) it moves the units at the center and damaging them.
  • Black Hole Loop Pull
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in BH_Group and do (Actions)
        • Loop - Actions
          • Set BH_PickedUnits = (Picked unit)
          • Custom script: set udg_BH_Key = GetHandleId(udg_BH_PickedUnits)
          • Custom script: set udg_BH_X = GetUnitX(udg_BH_PickedUnits)
          • Custom script: set udg_BH_Y = GetUnitY(udg_BH_PickedUnits)
          • Set BH_Caster = (Load (Key caster) of BH_Key in Enigma_Hashtable)
          • Set BH_Reals[1] = (Load 1 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[2] = (Load 2 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[3] = (Load 3 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[4] = (Load 4 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[10] = (Load 5 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[11] = (Load 6 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[12] = (Load 7 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[13] = (Load 8 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[14] = (Load 9 of BH_Key from Enigma_Hashtable)
          • Set BH_Reals[15] = (Load 10 of BH_Key from Enigma_Hashtable)
          • Set BH_Counter = (Load (Key counter) of BH_Key from Enigma_Hashtable)
          • Hashtable - Save (BH_Counter + 0.05) as (Key counter) of BH_Key in Enigma_Hashtable
          • Set BH_SmallRadiusDistance = (Distance between (Point(BH_X, BH_Y)) and (Point(BH_PullUnitsX, BH_PullUnitsY)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BH_SmallRadiusDistance Less than or equal to BH_Reals[11]
            • Then - Actions
              • Set BH_SmallRadGroup = (Units within BH_Reals[11] of (Point(BH_X, BH_Y)) matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) belongs to an enemy of (Owner of BH_Caster)) Equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in BH_SmallRadGroup and do (Actions)
                • Loop - Actions
                  • Set BH_SmallRadiusUnits = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Random real number between 0.00 and 100.00) Less than or equal to BH_Reals[12]
                    • Then - Actions
                      • -------- The bonus damage to the small radius. --------
                      • Unit - Cause BH_Caster to damage BH_SmallRadiusUnits, dealing BH_Reals[10] damage of attack type BH_AttackType and damage type BH_DamageType
                      • Custom script: call DestroyEffect (AddSpecialEffectTarget(udg_BH_SmallRadiusDamageEffect,udg_BH_SmallRadiusUnits,udg_BH_SmallRadiusAttachment))
                    • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random real number between 0.00 and 100.00) Less than or equal to BH_Reals[15]
            • Then - Actions
              • Custom script: call DestroyEffect( AddSpecialEffect(udg_BH_CenterSFX,udg_BH_X,udg_BH_Y))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • BH_CenterIgnoreUnitTypes Equal to True
                • Then - Actions
                  • Set BH_CenterIgnoreGroup = (Units within BH_Reals[13] of (Point(BH_X, BH_Y)) matching (((Matching unit) belongs to an enemy of Player 1 (Red)) Equal to True))
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in BH_CenterIgnoreGroup and do (Actions)
                    • Loop - Actions
                      • Set BH_CenterUnits = (Picked unit)
                      • Unit - Cause BH_Caster to damage BH_CenterUnits, dealing BH_Reals[14] damage of attack type BH_CenterAttackType and damage type BH_CenterDamageType
                • Else - Actions
                  • Set BH_CenterGroup = (Units within BH_Reals[13] of (Point(BH_X, BH_Y)) matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) belongs to an enemy of (Owner of BH_Caster)) Equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and
                  • Custom script: set bj_wantDestroyGroup = true
                  • Unit Group - Pick every unit in BH_CenterGroup and do (Actions)
                    • Loop - Actions
                      • Set BH_CenterUnits = (Picked unit)
                      • Unit - Cause BH_Caster to damage BH_CenterUnits, dealing BH_Reals[14] damage of attack type BH_CenterAttackType and damage type BH_CenterDamageType
            • Else - Actions
          • Set BH_PullGroup = (Units within BH_Reals[3] of (Point(BH_X, BH_Y)) matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) belongs to an enemy of (Owner of BH_Caster)) Equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and (
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in BH_PullGroup and do (Actions)
            • Loop - Actions
              • Set BH_PickedPullUnits = (Picked unit)
              • Hashtable - Save Handle OfBH_PickedPullUnits as 12 of BH_Key in Enigma_Hashtable
              • Custom script: set udg_BH_PullUnitsX = GetUnitX(udg_BH_PickedPullUnits)
              • Custom script: set udg_BH_PullUnitsY = GetUnitY(udg_BH_PickedPullUnits)
              • Set BH_Reals[10] = (Angle from (Point(BH_PullUnitsX, BH_PullUnitsY)) to (Point(BH_X, BH_Y)))
              • Custom script: set udg_BH_MX = udg_BH_PullUnitsX + udg_BH_Reals[4] * Cos( udg_BH_Reals[10] * bj_DEGTORAD)
              • Custom script: set udg_BH_MY = udg_BH_PullUnitsY + udg_BH_Reals[4] * Sin( udg_BH_Reals[10] * bj_DEGTORAD)
              • Custom script: call SetUnitX(udg_BH_PickedPullUnits,udg_BH_MX)
              • Custom script: call SetUnitY(udg_BH_PickedPullUnits,udg_BH_MY)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random real number between 0.00 and 100.00) Less than or equal to BH_Reals[12]
                • Then - Actions
                  • Unit - Cause BH_Caster to damage BH_PickedPullUnits, dealing BH_Reals[1] damage of attack type BH_AttackType and damage type BH_DamageType
                  • Custom script: call DestroyEffect (AddSpecialEffect(udg_BH_DamageSfx,udg_BH_PullUnitsX,udg_BH_PullUnitsY))
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BH_Counter Greater than or equal to BH_Reals[2]
            • Then - Actions
              • Unit - Kill BH_PickedUnits
              • Unit Group - Remove BH_PickedUnits from BH_Group
              • Hashtable - Clear all child hashtables of child BH_Key in Enigma_Hashtable
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (BH_Group is empty) Equal to True
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions

Everything works now, but to reach this, I used both of the functions.
like this:
  • Custom script: call SetUnitPosition(udg_TempUnit, udg_ENG_xn, udg_ENG_yn)
  • Custom script: call SetUnitX(GetEnumUnit(), udg_ENG_xn)
  • Custom script: call SetUnitY(GetEnumUnit(), udg_ENG_yn)
Now, dummy units even check each other to bounce.
And my dummy has MS setted to 0.
What do you think about that?
 
Status
Not open for further replies.
Top