[Trigger] How to make this (currently working) skillshot MUI?

Status
Not open for further replies.
Level 4
Joined
Jun 10, 2019
Messages
69
Hi all,

I currently have a skillshot that seems to be working as hoped for, but I don't think it's currently MUI. I'm hoping to rectify this problem, and could definitely use help with this matter!

The triggers are as follows:

  • Non MUI Skillshot Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Non MUI Skill Shot Example
    • Actions
      • Set NonMUISkillshotCaster = (Triggering unit)
      • Set NonMUISkillshotAngle = (Angle from (Position of (Triggering unit)) to (Target point of ability being cast))
      • Set NonMUISkillshotStart = (Position of NonMUISkillshotCaster)
      • Unit - Create 1 Dummy for (Owner of NonMUISkillshotCaster) at ((Position of NonMUISkillshotCaster) offset by 50.00 towards NonMUISkillshotAngle degrees) facing NonMUISkillshotAngle degrees
      • Set NonMUISkillshotProjectile = (Last created unit)
      • Special Effect - Create a special effect attached to the overhead of NonMUISkillshotProjectile using Abilities\Weapons\LordofFlameMissile\LordofFlameMissile.mdl
      • Set NonMUISkillshotSpecialEffect = (Last created special effect)
      • Trigger - Turn on Non MUI Skillshot Impact <gen>
  • Non MUI Skillshot Impact
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
      • (NonMUISkillshotProjectile is alive) Equal to True
    • Actions
      • Unit - Move NonMUISkillshotProjectile instantly to ((Position of NonMUISkillshotProjectile) offset by 20.00 towards NonMUISkillshotAngle degrees)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between NonMUISkillshotStart and (Position of NonMUISkillshotProjectile)) Greater than or equal to 1050.00
        • Then - Actions
          • Unit - Remove NonMUISkillshotProjectile from the game
          • Special Effect - Destroy NonMUISkillshotSpecialEffect
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Unit Group - Pick every unit in (Units within 90.00 of (Position of NonMUISkillshotProjectile)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) belongs to an enemy of (Owner of NonMUISkillshotCaster)) Equal to True
                  • ((Picked unit) is A structure) Equal to False
                  • ((Picked unit) is alive) Equal to True
                • Then - Actions
                  • Unit - Cause NonMUISkillshotProjectile to damage (Picked unit), dealing (100.00 x (Real((Level of Non MUI Skill Shot Example for NonMUISkillshotCaster)))) damage of attack type Spells and damage type Normal
                  • Unit - Remove NonMUISkillshotProjectile from the game
                  • Special Effect - Destroy NonMUISkillshotSpecialEffect
                  • Trigger - Turn off (This trigger)
                • Else - Actions
The above triggers are pretty much a slightly simplified (no rider effects or AOE) example of how I've been making skillshots. I'm starting a new project soon, and this time, I want to do the skillshots right.

Thanks in advance!
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Hello again! You're leaking some points and unit groups, which you can learn how to fix here: Things That Leak. The key to doing this properly is, again, dynamic indexing: Visualize: Dynamic Indexing. Instead of just checking/moving one dummy, you loop through array of dummies and check/move all of them. Also instead of recomputing the distance between start and current location you can just use a real variable that counts up the distance traveled.

  • MUI Skillshot Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to MUI Skill Shot Example
    • Actions
      • MUI_Count = MUI_Count + 1
      • Set TempUnit = (Triggering unit)
      • Set TempPoint[1] = (Position of TempUnit)
      • Set TempPoint[2] = (Target point of ability being cast)
      • Set TempPoint[3] = (TempPoint[1] offset by 50.00 towards NonMUISkillshotAngle degrees)
      • Set MUISkillshotAngle[MUI_Count] = (TempPoint[1]) to TempPoint[2])
      • Unit - Create 1 Dummy for (Owner of TempUnit) at TempPoint[3] facing MUISkillshotAngle[MUI_Count] degrees
      • Set MUISkillshotProjectile[MUI_Count] = (Last created unit)
      • Special Effect - Create a special effect attached to the overhead of MUISkillshotProjectile[MUI_Count] using Abilities\Weapons\LordofFlameMissile\LordofFlameMissile.mdl
      • Set MUISkillshotSpecialEffect[MUI_Count] = (Last created special effect)
      • Set MUISkillShotDistance[MUI_Count] = 0.00
      • Set MUISkillShotLevel[MUI_Count] = (Level of MUI Skill Shot Example for TempUnit)
      • Custom script: call RemoveLocation(udg_TempPoint[1])
      • Custom script: call RemoveLocation(udg_TempPoint[2])
      • Custom script: call RemoveLocation(udg_TempPoint[3])
      • If (All conditions are true) then do (Then actions) else do (Else actions)
        • If - Conditions
          • MUI_Count equal to 1
        • Then - Actions
          • Trigger - Turn on MUI Skillshot Impact <gen>
        • Else - Actions
  • MUI Skillshot Impact
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • For each (Integer MUI_Loop) from 1 to MUI_Count do (Actions) //this is "for each integer <variable>" instead of int A or int B
        • Loop - Actions
          • Set TempPoint[1] = (Position of MUISkillshotProjectile[MUI_Loop])
          • Set TempPoint[2] = (TempPoint[1] offset by 20.00 towards MUISkillshotAngle[MUI_Loop] degrees)
          • Unit - Move MUISkillshotProjectile[MUI_Loop] instantly to TempPoint[2]
          • Set MUISkillShotDistance[MUI_Loop] = MUISkillShotDistance[MUI_Loop] + 20.00
          • Set Done = False //boolean variable
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MUISkillShotDistance[MUI_Loop] Greater than or equal to 1050.00
            • Then - Actions
              • Set Done = True
            • Else - Actions
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 90.00 of TempPoint[2]) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) belongs to an enemy of (Owner of NonMUISkillshotCaster)) Equal to True
                  • ((Picked unit) is A structure) Equal to False
                  • ((Picked unit) is alive) Equal to True
                • Then - Actions
                  • Unit - Cause MUISkillshotProjectile[MUI_Loop] to damage (Picked unit), dealing (100.00 x Real(MUISkillShotLevel[MUI_Loop])) damage of attack type Spells and damage type Normal
                  • Set Done = True
                • Else - Actions
          • Custom script: call RemoveLocation(udg_TempPoint[1])
          • Custom script: call RemoveLocation(udg_TempPoint[2])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Done equal to True
            • Then - Actions
              • Special Effect - Destroy MUISkillshotSpecialEffect[MUI_Loop] //I think you have to destroy the effect before you remove the unit
              • Unit - Remove MUISkillshotProjectile[MUI_Loop] from the game
              • -------- now have to swap the last instance into this place in the array --------
              • Set MUISkillshotAngle[MUI_Loop] = MUISkillshotAngle[MUI_Count]
              • Set MUISkillShotProjectile[MUI_Loop] = MUISkillshotProjectile[MUI_Count]
              • Set MUISkillshotSpecialEffect[MUI_Loop] = MUISkillShotSpecialEffect[MUI_Count]
              • Set MUISkillShotDistance[MUI_Loop] = MUISkillShotDistance[MUI_Count]
              • Set MUISkillShotLevel[MUI_Loop] = MUISkillShotLevel[MUI_Count]
              • Set MUI_Count = MUI_Count - 1
              • Set MUI_Loop = MUI_Loop - 1
              • If (All conditions are true) then do (Then actions) else do (Else actions)
                • If - Conditions
                  • MUI_Count equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
You'll notice I moved some of the if blocks outside each other. The way you had it set before, the projectile wouldn't hit anything on the very last move iteration even if there was something in range. Then, to avoid duplicate bits of code for ending an instance we just use a boolean variable flag to see if it should end and only check that once right before the end of the loop.
 
Status
Not open for further replies.
Top