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

Indexing problems!!!

Status
Not open for further replies.
Level 13
Joined
Oct 16, 2010
Messages
731
Hi, I'm trying to make a spell where the user launches a massive blade that moves in a target direction. The blade then launches other mini-blades either side of it at a right angle (+/- 90 degrees). However what seems to happen is the main blade moves perfectly fine but the mini-blades just randomly stop and I don't know what's causing it to happen.

Below are the 2 triggers that I have at the minute, the caster does not need to be in an array as there is only 1 person who can cast the ability.

  • Conference Call Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to The Conference Call
    • Actions
      • Set CC_CasterUnit = (Casting unit)
      • Set CC_Point = (Position of CC_CasterUnit)
      • Set CC_MainDistance = 1200.00
      • Unit - Create 1 Dummy (Conference Main) for (Owner of CC_CasterUnit) at CC_Point facing Default building facing degrees
      • Set CC_MainDummy = (Last created unit)
      • Custom script: call RemoveLocation(udg_CC_Point)
      • Set CC_Point = (Target point of ability being cast)
      • Unit - Make CC_MainDummy face CC_Point over 0.00 seconds
      • Trigger - Turn on CC Loop <gen>
      • Custom script: call RemoveLocation(udg_CC_Point)
  • CC Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set CC_Point = (Position of CC_MainDummy)
      • Set TempPoint = (CC_Point offset by 15.00 towards (Facing of CC_MainDummy) degrees)
      • Unit - Move CC_MainDummy instantly to TempPoint
      • Set CC_MainDistance = (CC_MainDistance - 15.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CC_MainDistance Less than 15.00
        • Then - Actions
          • Unit - Kill CC_MainDummy
          • Set CC_MainDummy = No unit
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Random integer number between 1 and 15) Equal to 1
            • Then - Actions
              • Set CC_LoopMax = (CC_LoopMax + 1)
              • Unit - Create 1 Dummy (Conference Sub) for (Owner of CC_CasterUnit) at TempPoint facing ((Facing of CC_CasterUnit) + 90.00) degrees
              • Set CC_SubDummy[CC_LoopMax] = (Last created unit)
              • Set CC_SubDistance[CC_LoopMax] = 800.00
              • Set CC_LoopMax = (CC_LoopMax + 1)
              • Unit - Create 1 Dummy (Conference Sub) for (Owner of CC_CasterUnit) at TempPoint facing ((Facing of CC_CasterUnit) - 90.00) degrees
              • Set CC_SubDummy[CC_LoopMax] = (Last created unit)
              • Set CC_SubDistance[CC_LoopMax] = 800.00
            • Else - Actions
      • Custom script: call RemoveLocation(udg_CC_Point)
      • Custom script: call RemoveLocation(udg_TempPoint)
      • For each (Integer CC_LoopInt) from 1 to CC_LoopMax, do (Actions)
        • Loop - Actions
          • Set CC_Point = (Position of CC_SubDummy[CC_LoopInt])
          • Set TempPoint = (CC_Point offset by 30.00 towards (Facing of CC_SubDummy[CC_LoopInt]) degrees)
          • Unit - Move CC_SubDummy[CC_LoopInt] instantly to TempPoint
          • Set CC_SubDistance[CC_LoopInt] = (CC_SubDistance[CC_LoopInt] - 30.00)
          • Set CC_Group = (Units within 50.00 of TempPoint matching ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of CC_CasterUnit)) Equal to True)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in CC_Group) Greater than or equal to 1
            • Then - Actions
              • Set CC_TargetUnit = (Random unit from CC_Group)
              • Set CC_Dmg = (((Real((Intelligence of CC_CasterUnit (Exclude bonuses)))) x 0.10) x ((800.00 - CC_SubDistance[CC_LoopInt]) / 800.00))
              • Unit - Cause CC_CasterUnit to damage CC_TargetUnit, dealing CC_Dmg damage of attack type Spells and damage type Universal
              • Set CC_TargetUnit = No unit
              • Set CC_SubDistance[CC_LoopMax] = CC_SubDistance[CC_LoopInt]
              • Set CC_SubDummy[CC_LoopMax] = CC_SubDummy[CC_LoopInt]
              • Set CC_LoopMax = (CC_LoopMax - 1)
              • Set CC_LoopInt = (CC_LoopInt - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CC_LoopMax Equal to 0
                  • CC_MainDummy Equal to No unit
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CC_SubDistance[CC_LoopInt] Less than 30.00
                • Then - Actions
                  • Unit - Cause CC_CasterUnit to damage CC_TargetUnit, dealing CC_Dmg damage of attack type Spells and damage type Universal
                  • Set CC_TargetUnit = No unit
                  • Set CC_SubDistance[CC_LoopMax] = CC_SubDistance[CC_LoopInt]
                  • Set CC_SubDummy[CC_LoopMax] = CC_SubDummy[CC_LoopInt]
                  • Set CC_LoopMax = (CC_LoopMax - 1)
                  • Set CC_LoopInt = (CC_LoopInt - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • CC_LoopMax Equal to 0
                      • CC_MainDummy Equal to No unit
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
          • Custom script: call RemoveLocation(udg_CC_Point)
          • Custom script: call RemoveLocation(udg_TempPoint)
EDIT: I realised I hadn't actually killed any of the mini-blades die apon reaching their full distance but now that's sorted. However now I seem to get loads of lag after casting the ability. Any ideas?

EDIT 2: Managed to make it stop the looping trigger after all dummies are gone. Still got some lag after casting though, seems to be every 0.5 seconds or something that it lags.

Here's the updated one! (Messages are there for testing purposes)

  • CC Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CC_MainDummy Not equal to No unit
        • Then - Actions
          • Set CC_Point = (Position of CC_MainDummy)
          • Set TempPoint = (CC_Point offset by 4.00 towards (Facing of CC_MainDummy) degrees)
          • Unit - Move CC_MainDummy instantly to TempPoint
          • Set CC_MainDistance = (CC_MainDistance - 4.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CC_MainDistance Less than 4.00
            • Then - Actions
              • Unit - Kill CC_MainDummy
              • Set CC_MainDummy = No unit
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Random integer number between 1 and 4) Equal to 1
                • Then - Actions
                  • Set CC_LoopMax = (CC_LoopMax + 1)
                  • Set CC_SubAngle[CC_LoopMax] = (CC_MainAngle + 90.00)
                  • Unit - Create 1 Dummy (Conference Sub) for (Owner of CC_CasterUnit) at TempPoint facing CC_SubAngle[CC_LoopMax] degrees
                  • Set CC_SubDummy[CC_LoopMax] = (Last created unit)
                  • Set CC_SubDistance[CC_LoopMax] = 800.00
                  • Set CC_LoopMax = (CC_LoopMax + 1)
                  • Set CC_SubAngle[CC_LoopMax] = (CC_MainAngle - 90.00)
                  • Unit - Create 1 Dummy (Conference Sub) for (Owner of CC_CasterUnit) at TempPoint facing CC_SubAngle[CC_LoopMax] degrees
                  • Set CC_SubDummy[CC_LoopMax] = (Last created unit)
                  • Set CC_SubDistance[CC_LoopMax] = 800.00
                • Else - Actions
          • Custom script: call RemoveLocation(udg_CC_Point)
          • Custom script: call RemoveLocation(udg_TempPoint)
        • Else - Actions
      • For each (Integer CC_LoopInt) from 1 to CC_LoopMax, do (Actions)
        • Loop - Actions
          • Set CC_Point = (Position of CC_SubDummy[CC_LoopInt])
          • Set TempPoint = (CC_Point offset by 15.00 towards CC_SubAngle[CC_LoopInt] degrees)
          • Unit - Move CC_SubDummy[CC_LoopInt] instantly to TempPoint
          • Set CC_SubDistance[CC_LoopInt] = (CC_SubDistance[CC_LoopInt] - 15.00)
          • Set CC_Group = (Units within 50.00 of TempPoint matching ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of CC_CasterUnit)) Equal to True)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in CC_Group) Greater than or equal to 1
            • Then - Actions
              • Set CC_TargetUnit = (Random unit from CC_Group)
              • Set CC_Dmg = (((Real((Intelligence of CC_CasterUnit (Exclude bonuses)))) x 0.10) x (1.00 - ((800.00 - CC_SubDistance[CC_LoopInt]) / 800.00)))
              • Game - Display to (All players) the text: (String(CC_Dmg))
              • Unit - Cause CC_CasterUnit to damage CC_TargetUnit, dealing CC_Dmg damage of attack type Spells and damage type Universal
              • Set CC_TargetUnit = No unit
              • Unit - Kill CC_SubDummy[CC_LoopInt]
              • Set CC_SubDistance[CC_LoopInt] = CC_SubDistance[CC_LoopMax]
              • Set CC_SubDummy[CC_LoopInt] = CC_SubDummy[CC_LoopMax]
              • Set CC_LoopMax = (CC_LoopMax - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CC_LoopMax Equal to 0
                  • CC_MainDummy Equal to No unit
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                  • Game - Display to (All players) the text: 2
                • Else - Actions
                  • Set CC_LoopInt = (CC_LoopInt - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CC_SubDistance[CC_LoopInt] Less than 15.00
                • Then - Actions
                  • Unit - Kill CC_SubDummy[CC_LoopInt]
                  • Set CC_SubDistance[CC_LoopInt] = CC_SubDistance[CC_LoopMax]
                  • Set CC_SubDummy[CC_LoopInt] = CC_SubDummy[CC_LoopMax]
                  • Set CC_LoopMax = (CC_LoopMax - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • CC_LoopMax Equal to 0
                      • CC_MainDummy Equal to No unit
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                      • Game - Display to (All players) the text: 1
                    • Else - Actions
                      • Set CC_LoopInt = (CC_LoopInt - 1)
                • Else - Actions
          • Custom script: call RemoveLocation(udg_CC_Point)
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call DestroyGroup(udg_CC_Group)
 
Last edited:
Level 15
Joined
Aug 7, 2013
Messages
1,337
It's definitely the timer you added. This is why you're getting lots of map lag since you went from a casting event to timer.

The problem appears to be that the code is being fired every 0.3 seconds. I imagine that can cause a bit of map lag, since the entire body is nested inside a timer.

Shouldn't the spell be in response to the casting? That would eliminate any map lag for sure.

Can you make it so the first version works? That one probably has 0 map lag.
 
Level 13
Joined
Oct 16, 2010
Messages
731
Trigger 1 is in response to the spell being cast and the second is the periodic one. The lag only really becomes noticeable after the spell has been cast, which is confusing as the loop does turn itself off (Which was tested via text). Honestly I don't see how MUI would solve it and I don't really want to have to make it any more complicated than it has to be. If you're sure that that'll fix it then I'll give it a go!
 
Status
Not open for further replies.
Top