Moving missile with partial homing

kingkwong92

Well-Known Member
Reaction score
25
I'm having trouble making my missile have partial homing. My missile is a unit with 1 move speed and 3.0 turn rate. It has a global acquisition range. When cast it turns towards the nearest enemy target. I want to change the direction of the of the missile towards the direction of the facing angle of the missile. I don't want it to turn if the angle is greater than 90 degrees from its original path (easier it current path). However I cannot get the conditions right. Please help, this is the main part that I need help with:

((Facing of (Picked unit)) + missile_angle) Less than or equal to 90.00
((Facing of (Picked unit)) + missile_angle) Greater than or equal to 270.00

Also is it possible to detect which unit is targeted by the missile. If possible, I would like to add:
if distance between user and missile is greater than distance between user and target.
This prevents the missile homing on the target if it has already passed it.
Thanks

Trigger:
  • Movement
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in missile_group) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in missile_group and do (Actions)
            • Loop - Actions
              • Set Player_Number = (Player number of (Owner of (Picked unit)))
              • Set missile = (Picked unit)
              • Set player_number = (Player number of (Owner of (Picked unit)))
              • Set missile_handle = (Picked unit)
              • Set missile_speed = (Load 1 of (Key missile_handle) from missile_hash)
              • Set missile_range = (Load 2 of (Key missile_handle) from missile_hash)
              • Set missile_damage = (Load 3 of (Key missile_handle) from missile_hash)
              • Set missile_hits = (Load 4 of (Key missile_handle) from missile_hash)
              • Set missile_user = (Load 5 of (Key missile_handle) in missile_hash)
              • Set missile_distance = (Load 6 of (Key missile_handle) from missile_hash)
              • Set missile_angle = (Load 7 of (Key missile_handle) from missile_hash)
              • Set missile_point_1 = (Position of missile)
              • Set missile_point_2 = (missile_point_1 offset by missile_speed towards missile_angle degrees)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at missile_point_2 of type Flyability is off) Equal to True
                • Then - Actions
                  • Custom script: call RemoveLocation(udg_missile_point_2)
                  • Set missile_point_2 = missile_point_1
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • missile_hits Greater than 0
                  • missile_distance Greater than 0.00
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of missile) Equal to Shuriken
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • missile_distance Less than or equal to 1700.00
                          • missile_distance Greater than or equal to 500.00
                          • ((Facing of (Picked unit)) + missile_angle) Less than or equal to 90.00
                          • ((Facing of (Picked unit)) + missile_angle) Greater than or equal to 270.00
                        • Then - Actions
                          • Game - Display to (All players) for 0.10 seconds the text: Turn
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ((Facing of (Picked unit)) - missile_angle) Greater than or equal to 270.00
                            • Then - Actions
                              • Set missile_angle = (missile_angle - 1.00)
                            • Else - Actions
                              • Set missile_angle = (missile_angle + 1.00)
                        • Else - Actions
                      • Hashtable - Save missile_angle as 7 of (Key missile_handle) in missile_hash
                      • Custom script: call DestroyGroup(udg_missile_target_group)
                      • Set missile_target_group = (Units within missile_range of missile_point_2 matching (((Matching unit) Not equal to missile_user) and (((Matching unit) is alive) Equal to True)))
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of units in missile_target_group) Greater than 0
                        • Then - Actions
                          • Set missile_target = (Random unit from missile_target_group)
                          • Unit - Cause Hero[player_number] to damage missile_target, dealing missile_damage damage of attack type Pierce and damage type Normal
                          • Set Temp_Loc_1 = (Position of missile_target)
                          • Unit - Create 1 Dummy for (Player(Player_Number)) at missile_point_1 facing missile_point_2
                          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                          • Unit - Add Stun (dummy) to (Last created unit)
                          • Unit - Set level of Stun (dummy) for (Last created unit) to 1
                          • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt missile_target
                          • Set missile_hits = (missile_hits - 1)
                          • Hashtable - Save missile_hits as 4 of (Key missile_handle) in missile_hash
                        • Else - Actions
                          • Set X = (X of missile_point_2)
                          • Set Y = (Y of missile_point_2)
                          • Set missile_distance = (missile_distance - missile_speed)
                          • Hashtable - Save missile_distance as 6 of (Key missile_handle) in missile_hash
                          • Custom script: call SetUnitX(udg_missile,udg_X)
                          • Custom script: call SetUnitY(udg_missile,udg_Y)
                    • Else - Actions
                • Else - Actions
              • Custom script: call RemoveLocation(udg_missile_point_1)
              • Custom script: call RemoveLocation(udg_missile_point_2)
        • Else - Actions
          • Trigger - Turn off (This trigger)
 

kingkwong92

Well-Known Member
Reaction score
25
The fired unit is a sliding unit
It has a global acquisition range and therefore will target thee closest unit.
I plan on adding in a stop command so it will constantly refresh the closest target enemy.
I found that the problem lies with the angles in the condition.
The change from 359.999 degrees to 0 degrees.
E.g degrees (300 + 90) = 30 degrees
real (300 + 90) = 390
So far I did this but it still doesnt work
Set X = (missile_angle + 90.00) Set Y = (missile_angle - 90.00) If (X Greater than or equal to 360.00) then do (Set X = (X - 360.00)) else do (Do nothing) If (Y Less than or equal to 0.00) then do (Set Y = (Y + 360.00)) else do (Do nothing) If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - (Facing of (Picked unit)) Less than or equal to X (Facing of (Picked unit)) Greater than or equal to Y
 

kingkwong92

Well-Known Member
Reaction score
25
Trigger:
  • Movement
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Set X = (missile_angle + 90.00)
      • Set Y = (missile_angle - 90.00)
      • If (X Greater than or equal to 360.00) then do (Set X = (X - 360.00)) else do (Do nothing)
      • If (Y Less than or equal to 0.00) then do (Set Y = (Y + 360.00)) else do (Do nothing)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • missile_distance Less than or equal to 1700.00
          • missile_distance Greater than or equal to 500.00
          • (Facing of (Picked unit)) Less than or equal to X
          • (Facing of (Picked unit)) Greater than or equal to Y
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else)
 

Slapshot136

Divide et impera
Reaction score
471
Trigger:
  • (Facing of (Picked unit)) Less than or equal to X
    • (Facing of (Picked unit)) Greater than or equal to Y

there is no picked unit here - and I don't quite understand your X/Y setup - where is the target? why not just adjust the current angle towards the target? what do you expect the missile to do if there is no target, go straight?
 

kingkwong92

Well-Known Member
Reaction score
25
Thats not the whole trigger. I have a picked unit.
I want to adjust the current angle towards the target however I can't seem to get the conditions right. If there is no target then it will continue going straight
Here is the full trigger. Its really big tho.
Trigger:
  • Movement
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in missile_group) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in missile_group and do (Actions)
            • Loop - Actions
              • Set Player_Number = (Player number of (Owner of (Picked unit)))
              • Set missile = (Picked unit)
              • Set player_number = (Player number of (Owner of (Picked unit)))
              • Set missile_handle = (Picked unit)
              • Set missile_speed = (Load 1 of (Key missile_handle) from missile_hash)
              • Set missile_range = (Load 2 of (Key missile_handle) from missile_hash)
              • Set missile_damage = (Load 3 of (Key missile_handle) from missile_hash)
              • Set missile_hits = (Load 4 of (Key missile_handle) from missile_hash)
              • Set missile_user = (Load 5 of (Key missile_handle) in missile_hash)
              • Set missile_distance = (Load 6 of (Key missile_handle) from missile_hash)
              • Set missile_angle = (Load 7 of (Key missile_handle) from missile_hash)
              • Set missile_point_1 = (Position of missile)
              • Set missile_point_2 = (missile_point_1 offset by missile_speed towards missile_angle degrees)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Terrain pathing at missile_point_2 of type Flyability is off) Equal to True
                • Then - Actions
                  • Custom script: call RemoveLocation(udg_missile_point_2)
                  • Set missile_point_2 = missile_point_1
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • missile_hits Greater than 0
                  • missile_distance Greater than 0.00
                • Then - Actions
                  • -------- Different Missiles --------
                  • -------- Shuriken --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of missile) Equal to Shuriken
                    • Then - Actions
                      • Custom script: call DestroyGroup(udg_missile_deflect_group)
                      • Set X = (missile_angle + 90.00)
                      • Set Y = (missile_angle - 90.00)
                      • If (X Greater than or equal to 360.00) then do (Set X = (X - 360.00)) else do (Do nothing)
                      • If (Y Less than or equal to 0.00) then do (Set Y = (Y + 360.00)) else do (Do nothing)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • missile_distance Less than or equal to 1700.00
                          • missile_distance Greater than or equal to 500.00
                          • (Facing of (Picked unit)) Less than or equal to X
                          • (Facing of (Picked unit)) Greater than or equal to Y
                        • Then - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ((Facing of (Picked unit)) - missile_angle) Greater than or equal to 270.00
                            • Then - Actions
                              • Set missile_angle = (missile_angle - 1.00)
                            • Else - Actions
                              • Set missile_angle = (missile_angle + 1.00)
                        • Else - Actions
                          • Game - Display to (All players) for 0.10 seconds the text: Turn
                      • Hashtable - Save missile_angle as 7 of (Key missile_handle) in missile_hash
                      • Custom script: call DestroyGroup(udg_missile_target_group)
                      • Set missile_target_group = (Units within missile_range of missile_point_2 matching (((Matching unit) Not equal to missile_user) and (((Matching unit) is alive) Equal to True)))
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of units in missile_target_group) Greater than 0
                        • Then - Actions
                          • Set missile_target = (Random unit from missile_target_group)
                          • Unit - Cause Hero[player_number] to damage missile_target, dealing missile_damage damage of attack type Pierce and damage type Normal
                          • Set Temp_Loc_1 = (Position of missile_target)
                          • Unit - Create 1 Dummy for (Player(Player_Number)) at missile_point_1 facing missile_point_2
                          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                          • Unit - Add Stun (dummy) to (Last created unit)
                          • Unit - Set level of Stun (dummy) for (Last created unit) to 1
                          • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt missile_target
                          • Set missile_hits = (missile_hits - 1)
                          • Hashtable - Save missile_hits as 4 of (Key missile_handle) in missile_hash
                        • Else - Actions
                          • Set X = (X of missile_point_2)
                          • Set Y = (Y of missile_point_2)
                          • Set missile_distance = (missile_distance - missile_speed)
                          • Hashtable - Save missile_distance as 6 of (Key missile_handle) in missile_hash
                          • Custom script: call SetUnitX(udg_missile,udg_X)
                          • Custom script: call SetUnitY(udg_missile,udg_Y)
                    • Else - Actions
                  • -------- Grand Fireball --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of missile) Equal to Grand Fireball
                    • Then - Actions
                      • Custom script: call DestroyGroup(udg_missile_target_group)
                      • Set missile_target_group = (Units within missile_range of missile_point_2 matching (((Matching unit) Not equal to missile_user) and (((Matching unit) is alive) Equal to True)))
                      • Set Temp_Loc_1 = (Position of missile)
                      • Special Effect - Create a special effect at Temp_Loc_1 using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of units in missile_target_group) Greater than 0
                        • Then - Actions
                          • Unit Group - Pick every unit in missile_target_group and do (Actions)
                            • Loop - Actions
                              • Set Temp_Loc_2 = (Position of (Picked unit))
                              • Unit - Cause Hero[player_number] to damage (Picked unit), dealing missile_damage damage of attack type Spells and damage type Normal
                              • Unit - Create 1 Dummy for (Player(Player_Number)) at Temp_Loc_1 facing Temp_Loc_2
                              • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                              • Unit - Add Stun (dummy) to (Last created unit)
                              • Unit - Set level of Stun (dummy) for (Last created unit) to 3
                              • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • ((Picked unit) is An Ancient) Equal to False
                                • Then - Actions
                                  • Set Temp_Loc_3 = (Temp_Loc_2 offset by 25.00 towards (Angle from Temp_Loc_1 to Temp_Loc_2) degrees)
                                  • Unit - Move (Picked unit) instantly to Temp_Loc_3
                                  • Custom script: call RemoveLocation(udg_Temp_Loc_3)
                                • Else - Actions
                              • Custom script: call RemoveLocation(udg_Temp_Loc_2)
                          • Set missile_hits = (missile_hits - (Number of units in missile_target_group))
                          • Set missile_distance = (missile_distance - missile_speed)
                          • Hashtable - Save missile_distance as 6 of (Key missile_handle) in missile_hash
                          • Hashtable - Save missile_hits as 4 of (Key missile_handle) in missile_hash
                        • Else - Actions
                          • Set X = (X of missile_point_2)
                          • Set Y = (Y of missile_point_2)
                          • Set missile_distance = (missile_distance - missile_speed)
                          • Hashtable - Save missile_distance as 6 of (Key missile_handle) in (Last created hashtable)
                          • Custom script: call SetUnitX(udg_missile,udg_X)
                          • Custom script: call SetUnitY(udg_missile,udg_Y)
                      • Custom script: call RemoveLocation(udg_Temp_Loc_1)
                    • Else - Actions
                  • -------- Phoenix Fire --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of missile) Equal to Fireball
                    • Then - Actions
                      • Custom script: call DestroyGroup(udg_missile_target_group)
                      • Set missile_target_group = (Units within missile_range of missile_point_2 matching (((Matching unit) Not equal to missile_user) and (((Matching unit) is alive) Equal to True)))
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of units in missile_target_group) Greater than 0
                        • Then - Actions
                          • Set missile_target = (Random unit from missile_target_group)
                          • Unit - Cause Hero[player_number] to damage missile_target, dealing missile_damage damage of attack type Pierce and damage type Normal
                          • Set Temp_Loc_1 = (Position of missile_target)
                          • Unit - Create 1 Dummy for (Player(Player_Number)) at missile_point_1 facing missile_point_2
                          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                          • Unit - Add Stun (dummy) to (Last created unit)
                          • Unit - Set level of Stun (dummy) for (Last created unit) to 4
                          • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt missile_target
                          • Set missile_hits = (missile_hits - 1)
                          • Hashtable - Save missile_hits as 4 of (Key missile_handle) in missile_hash
                          • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Other\Doom\DoomDeath.mdl
                          • Special Effect - Destroy (Last created special effect)
                        • Else - Actions
                          • Set X = (X of missile_point_2)
                          • Set Y = (Y of missile_point_2)
                          • Set missile_distance = (missile_distance - missile_speed)
                          • Hashtable - Save missile_distance as 6 of (Key missile_handle) in missile_hash
                          • Custom script: call SetUnitX(udg_missile,udg_X)
                          • Custom script: call SetUnitY(udg_missile,udg_Y)
                    • Else - Actions
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Unit-type of missile) Equal to Fireball
                          • (Unit-type of missile) Equal to Grand Fireball
                          • (Unit-type of missile) Equal to Shuriken
                          • (Unit-type of missile) Equal to Kunai
                    • Then - Actions
                      • Unit Group - Remove missile from missile_group
                      • Unit - Remove missile from the game
                      • Hashtable - Clear all child hashtables of child (Key missile_handle) in missile_hash
                    • Else - Actions
                      • Unit Group - Remove missile from missile_group
              • Custom script: call RemoveLocation(udg_missile_point_1)
              • Custom script: call RemoveLocation(udg_missile_point_2)
        • Else - Actions
          • Trigger - Turn off (This trigger)
 

Slapshot136

Divide et impera
Reaction score
471
I want to adjust the current angle towards the target however I can't seem to get the conditions right. If there is no target then it will continue going straight

how about making your missile face the "Math - angle between points" between your missile and your target (or compare that to your missile's current angle, and adjust it by 1% each iteration)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top