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

[Trigger] Issues with Angles

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
731
Hi,

I've been trying to work this out by myself for a good hour or so and I'm just not getting anywhere with it and I don't know what I'm going wrong.... so I'm asking for help instead!

I am trying to make a spell that makes a "Drone" fly around and attack enemies, however I want it to only attack while the enemy is in front of them and they fly like a plane would. So they go forwards then have to turn back to attack again etc etc etc.

My problem is that I can't get them to go towards the target, oddly they mostly end up going the complete opposite direction to the target. I've tried just using angles, then Sine, it's just not working at all. Does anyone have any ideas?

P.S. The trigger is still very much a WIP

  • AotD Loop
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • For each (Integer AotD_LoopInt) from 1 to AotD_MaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Life of AotD_CasterUnit[AotD_LoopInt]) Less than 0.20
            • Then - Actions
              • -------- Immediately detonate if caster dead --------
              • -------- DEINDEX --------
              • Unit - Add a 0.01 second Generic expiration timer to AotD_DummyUnit[AotD_LoopInt]
              • Set AotD_CasterUnit[AotD_LoopInt] = AotD_CasterUnit[AotD_MaxIndex]
              • Set AotD_Dmg[AotD_LoopInt] = AotD_Dmg[AotD_MaxIndex]
              • Set AotD_Duration[AotD_LoopInt] = AotD_Duration[AotD_MaxIndex]
              • Set AotD_Heal[AotD_LoopInt] = AotD_Heal[AotD_MaxIndex]
              • Set AotD_DummyUnit[AotD_LoopInt] = AotD_DummyUnit[AotD_MaxIndex]
              • Set AotD_TargetUnit[AotD_LoopInt] = AotD_TargetUnit[AotD_MaxIndex]
              • Set AotD_MaxIndex = (AotD_MaxIndex - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AotD_MaxIndex Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
                  • Set AotD_LoopInt = (AotD_LoopInt - 1)
            • Else - Actions
              • Set AotD_Duration[AotD_LoopInt] = (AotD_Duration[AotD_LoopInt] - 0.03)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AotD_Duration[AotD_LoopInt] Less than or equal to 0.00
                • Then - Actions
                  • -------- Return to caster --------
                  • Set Spell_CasterPoint = (Position of AotD_DummyUnit[AotD_LoopInt])
                  • Set Spell_TargetPoint = (Position of AotD_CasterUnit[AotD_LoopInt])
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between Spell_CasterPoint and Spell_TargetPoint) Less than or equal to 20.00
                    • Then - Actions
                      • Unit - Set life of AotD_TargetUnit[AotD_LoopInt] to ((Life of AotD_TargetUnit[AotD_LoopInt]) + AotD_Heal[AotD_LoopInt])
                      • -------- DEINDEX --------
                      • Unit - Add a 0.01 second Generic expiration timer to AotD_DummyUnit[AotD_LoopInt]
                      • Set AotD_CasterUnit[AotD_LoopInt] = AotD_CasterUnit[AotD_MaxIndex]
                      • Set AotD_Dmg[AotD_LoopInt] = AotD_Dmg[AotD_MaxIndex]
                      • Set AotD_Duration[AotD_LoopInt] = AotD_Duration[AotD_MaxIndex]
                      • Set AotD_Heal[AotD_LoopInt] = AotD_Heal[AotD_MaxIndex]
                      • Set AotD_DummyUnit[AotD_LoopInt] = AotD_DummyUnit[AotD_MaxIndex]
                      • Set AotD_TargetUnit[AotD_LoopInt] = AotD_TargetUnit[AotD_MaxIndex]
                      • Set AotD_MaxIndex = (AotD_MaxIndex - 1)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • AotD_MaxIndex Equal to 0
                        • Then - Actions
                          • Trigger - Turn off (This trigger)
                        • Else - Actions
                          • Set AotD_LoopInt = (AotD_LoopInt - 1)
                    • Else - Actions
                      • Set TempPoint = (Spell_CasterPoint offset by 15.00 towards (Angle from Spell_CasterPoint to Spell_TargetPoint) degrees)
                      • Unit - Move AotD_DummyUnit[AotD_LoopInt] instantly to TempPoint, facing Spell_TargetPoint
                      • Custom script: call RemoveLocation(udg_TempPoint)
                  • Custom script: call RemoveLocation(udg_Spell_CasterPoint)
                  • Custom script: call RemoveLocation(udg_Spell_TargetPoint)
                • Else - Actions
                  • -------- If the target is dead then set no target --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • AotD_TargetUnit[AotD_LoopInt] Not equal to No unit
                      • (Life of AotD_TargetUnit[AotD_LoopInt]) Less than 0.20
                    • Then - Actions
                      • Set AotD_TargetUnit[AotD_LoopInt] = No unit
                    • Else - Actions
                  • -------- If there is a target follow/attack --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • AotD_TargetUnit[AotD_LoopInt] Not equal to No unit
                    • Then - Actions
                      • Set Spell_CasterPoint = (Position of AotD_DummyUnit[AotD_LoopInt])
                      • Set Spell_TargetPoint = (Position of AotD_TargetUnit[AotD_LoopInt])
                      • -------- If looking at target - fire --------
                      • Set TempAngle = (Sin(((Facing of AotD_DummyUnit[AotD_LoopInt]) + 180.00)))
                      • Set TempReal = (Sin((Angle from Spell_CasterPoint to Spell_TargetPoint)))
                      • Game - Display to (All players) the text: (String(TempReal))
                      • Game - Display to (All players) the text: (String((Facing of AotD_DummyUnit[AotD_LoopInt])))
                      • Game - Display to (All players) the text: (String(TempAngle))
                      • Game - Display to (All players) the text: (String((Angle from Spell_CasterPoint to Spell_TargetPoint)))
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • TempAngle Less than TempReal
                        • Then - Actions
                          • Game - Display to (All players) the text: 1
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Distance between Spell_CasterPoint and Spell_TargetPoint) Less than or equal to 600.00
                            • Then - Actions
                              • Set TempPoint = (Spell_CasterPoint offset by 15.00 towards ((Facing of AotD_DummyUnit[AotD_LoopInt]) + 5.00) degrees)
                            • Else - Actions
                              • Set TempPoint = (Spell_CasterPoint offset by (15.00 x (600.00 / (Distance between Spell_CasterPoint and Spell_TargetPoint))) towards ((Facing of AotD_DummyUnit[AotD_LoopInt]) + 5.00) degrees)
                          • Unit - Move AotD_DummyUnit[AotD_LoopInt] instantly to TempPoint, facing ((Facing of AotD_DummyUnit[AotD_LoopInt]) + 5.00) degrees
                          • Custom script: call RemoveLocation(udg_TempPoint)
                        • Else - Actions
                          • Game - Display to (All players) the text: 2
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Distance between Spell_CasterPoint and Spell_TargetPoint) Less than or equal to 600.00
                            • Then - Actions
                              • Set TempPoint = (Spell_CasterPoint offset by 15.00 towards ((Facing of AotD_DummyUnit[AotD_LoopInt]) - 5.00) degrees)
                            • Else - Actions
                              • Set TempPoint = (Spell_CasterPoint offset by (15.00 x (600.00 / (Distance between Spell_CasterPoint and Spell_TargetPoint))) towards ((Facing of AotD_DummyUnit[AotD_LoopInt]) - 5.00) degrees)
                          • Unit - Move AotD_DummyUnit[AotD_LoopInt] instantly to TempPoint, facing ((Facing of AotD_DummyUnit[AotD_LoopInt]) - 5.00) degrees
                          • Custom script: call RemoveLocation(udg_TempPoint)
                      • Custom script: call RemoveLocation(udg_Spell_CasterPoint)
                      • Custom script: call RemoveLocation(udg_Spell_TargetPoint)
                    • Else - Actions
                      • -------- Otherwise follow caster --------
 
Status
Not open for further replies.
Top