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
((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 - Conditions
- 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)
- If - Conditions
- Else - Actions
- If - Conditions
- 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)
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
- If - Conditions
- Custom script: call RemoveLocation(udg_missile_point_1)
- Custom script: call RemoveLocation(udg_missile_point_2)
- Loop - Actions
- Unit Group - Pick every unit in missile_group and do (Actions)
- Else - Actions
- Trigger - Turn off (This trigger)
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Events