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

[General] Multiple projectiles bug

Status
Not open for further replies.
Level 5
Joined
Dec 25, 2018
Messages
110
I am using projectile skillshot system I found on this forum but I am having a problem when theres multiple projectiles at once.
Example:
-Spell 1 has speed of 50
-Spell 2 has speed of 10

If spell 1 is still in air and spell 2 is casted, then spell 2 gains speed values of spell 1.

Triggers:

  • INIT
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to ability
    • Actions
      • Set SS_iM = (SS_iM + 1)
      • Set SS_Caster[SS_iM] = (Triggering unit)
      • Set SS_Player[SS_iM] = (Owner of SS_Caster[SS_iM])
      • Set SS_aLevel[SS_iM] = (Level of SS_AbilityDamage for SS_Caster[SS_iM])
      • Set SS_MissleSpeed[SS_iM] = 50.00
      • Set SS_cLoc[SS_iM] = (Position of SS_Caster[SS_iM])
      • Set SS_tLoc[SS_iM] = (Target point of ability being cast)
      • Set SS_Angle[SS_iM] = (Angle from SS_cLoc[SS_iM] to SS_tLoc[SS_iM])
      • Set SS_rLoc[SS_iM] = (SS_cLoc[SS_iM] offset by 1900.00 towards SS_Angle[SS_iM] degrees)
      • Unit - Create 1 SS_Dummy for SS_Player[SS_iM] at SS_cLoc[SS_iM] facing SS_Angle[SS_iM] degrees
      • Unit - Set Max HP of (Last created unit) to ((Intelligence of SS_Caster[SS_iM] (Include bonuses)) x 3)
      • Set SS_Missle[SS_iM] = (Last created unit)
      • Animation - Change SS_Missle[SS_iM]'s size to (SS_MissleSize%, SS_MissleSize%, SS_MissleSize%) of its original size
      • Special Effect - Create a special effect attached to the chest of SS_Missle[SS_iM] using Abilities\Weapons\NecromancerMissile\NecromancerMissile.mdl
      • Set SS_SFX[SS_iM] = (Last created special effect)
      • Set SS_mLoc[SS_iM] = (Position of SS_Missle[SS_iM])
      • Set SS_Distance[SS_iM] = (Distance between SS_mLoc[SS_iM] and SS_rLoc[SS_iM])
      • Animation - Change SS_Missle[SS_iM] flying height to SS_MissleHeight at 0.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SS_iM Equal to 1
        • Then - Actions
          • Trigger - Turn on Curse Loop <gen>
        • Else - Actions
  • LOOP
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SS_iC) from 1 to SS_iM, do (Actions)
        • Loop - Actions
          • Set SS_Move = (SS_mLoc[SS_iC] offset by SS_MissleSpeed[SS_iM] towards SS_Angle[SS_iC] degrees)
          • Unit - Move SS_Missle[SS_iC] instantly to SS_Move
          • Custom script: call RemoveLocation (udg_SS_mLoc[udg_SS_iC])
          • Set SS_mLoc[SS_iC] = (Position of SS_Missle[SS_iC])
          • Set SS_Distance[SS_iC] = (Distance between SS_mLoc[SS_iC] and SS_rLoc[SS_iC])
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within SS_MissleAoE of SS_mLoc[SS_iC]) and do (Actions)
            • Loop - Actions
              • Set SS_eUnit = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SS_eUnit belongs to an enemy of SS_Player[SS_iC]) Equal to True
                  • (SS_eUnit is alive) Equal to True
                  • (SS_eUnit is Magic Immune) Equal to False
                  • (SS_eUnit is A structure) Equal to False
                • Then - Actions
                  • Unit Group - Add SS_eUnit to SS_Group
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • SS_Distance[SS_iC] Less than or equal to SS_MissleAoE
                  • (SS_Group is empty) Equal to False
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SS_Group is empty) Equal to True
                • Then - Actions
                  • Special Effect - Create a special effect at SS_mLoc[SS_iC] using Abilities\Weapons\BansheeMissile\BansheeMissile.mdl
                  • Special Effect - Destroy (Last created special effect)
                • Else - Actions
                  • Unit Group - Pick every unit in SS_Group and do (Actions)
                    • Loop - Actions
                      • Set SS_eUnit = (Picked unit)
                      • Special Effect - Create a special effect attached to the SS_MissleHit_AP of SS_eUnit using Abilities\Weapons\BansheeMissile\BansheeMissile.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Unit - Cause SS_Missle[SS_iM] to damage SS_eUnit, dealing (Max life of SS_Missle[SS_iM]) damage of attack type Normal and damage type Normal
                      • Unit Group - Remove SS_eUnit from SS_Group
              • Custom script: call RemoveLocation (udg_SS_rLoc[udg_SS_iC])
              • Custom script: call RemoveLocation (udg_SS_tLoc[udg_SS_iC])
              • Custom script: call RemoveLocation (udg_SS_cLoc[udg_SS_iC])
              • Custom script: call RemoveLocation (udg_SS_mLoc[udg_SS_iC])
              • Special Effect - Destroy SS_SFX[SS_iC]
              • Unit - Remove SS_Missle[SS_iC] from the game
              • Set SS_Caster[SS_iC] = SS_Caster[SS_iM]
              • Set SS_Player[SS_iC] = SS_Player[SS_iM]
              • Set SS_aLevel[SS_iC] = SS_aLevel[SS_iM]
              • Set SS_cLoc[SS_iC] = SS_cLoc[SS_iM]
              • Set SS_tLoc[SS_iC] = SS_tLoc[SS_iM]
              • Set SS_Angle[SS_iC] = SS_Angle[SS_iM]
              • Set SS_rLoc[SS_iC] = SS_rLoc[SS_iM]
              • Set SS_Missle[SS_iC] = SS_Missle[SS_iM]
              • Set SS_SFX[SS_iC] = SS_SFX[SS_iM]
              • Set SS_mLoc[SS_iC] = SS_mLoc[SS_iM]
              • Set SS_Distance[SS_iC] = SS_Distance[SS_iM]
              • Set SS_iM = (SS_iM - 1)
              • Set SS_iC = (SS_iC - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SS_iM Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
I know how to fix it by having all spells in 1 loop trigger and multiple if's, but I want my triggers to be clear and eaisly editable. So any ideas how to fix it?

Issue is propably with SS_Move, but even with

set udg_SS_Move[udg_SS_iC] = PolarProjectionBJ(udg_SS_mLoc[udg_SS_iC], 50.00, udg_SS_Angle[udg_SS_iC])
call SetUnitPositionLoc( udg_SS_Missle[udg_SS_iC], udg_SS_Move[udg_SS_iC] )

bug still occured.
 
Last edited:
Level 5
Joined
Jun 12, 2018
Messages
146
Each projectile spell has its own init and loop.

These are the triggers you've posted here right ? I'm confused..

Some things look weird to me, as I told you the value of SS_MissileSpeed will always be 50.00.

Also when does your SS_Missile[SS_iM] being created ? I can't see any "Unit - Create" call in your init function.

Is the SS_MissileAoE being initialized in another trigger ?

Maybe you should post the map with the full triggers to help us finding out what's happening.

Edit : Given your answer, why don't you just use a single Init+Loop triggers and then check the ability to give proper damage/speed to your missile ?
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
You are probably misusing a variable, it is impossible to point the error without seeing both triggers.
 
Level 5
Joined
Dec 25, 2018
Messages
110
Config File (Some things are not used)
  • SS Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- object editor variables --------
      • Set SS_Dummy = Dummy
      • -------- missle config --------
      • Set SS_MissleSize = 125.00
      • Set SS_MissleAoE = 100.00
      • Set SS_MissleDistance = 1000.00
      • Set SS_MissleHeight = 25.00
      • Set SS_MissleArt = Abilities\Spells\Human\StormBolt\StormBoltMissile.mdl
      • Set SS_MissleHitSFX = Abilities\Spells\Human\StormBolt\StormBoltMissile.mdl
      • Set SS_MissleHit_AP = chest
      • Set SS_MissleEndSFX = Abilities\Weapons\FarseerMissile\FarseerMissile.mdl
      • -------- skill shot damage config --------
      • Set SSd_Damage[1] = 50.00
      • Set SSd_Damage[2] = 75.00
      • Set SSd_Damage[3] = 100.00
      • Set SSd_AttackType = Spells
      • Set SSd_DamageType = Normal
      • -------- preload --------
      • Set tempLoc = (Center of (Playable map area))
      • Unit - Create 1 SS_Dummy for Neutral Passive at tempLoc facing Default building facing degrees
      • Set tempUnit = (Last created unit)
      • Unit - Remove tempUnit from the game
      • Custom script: call RemoveLocation (udg_tempLoc)

Second Spell
  • INIT2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to ability
    • Actions
      • Set SS_iM = (SS_iM + 1)
      • Set SS_Caster[SS_iM] = (Triggering unit)
      • Set SS_Player[SS_iM] = (Owner of SS_Caster[SS_iM])
      • Set SS_aLevel[SS_iM] = (Level of SS_AbilityDamage for SS_Caster[SS_iM])
      • Set SS_MissleSpeed[SS_iM] = 10.00
      • Set SS_cLoc[SS_iM] = (Position of SS_Caster[SS_iM])
      • Set SS_tLoc[SS_iM] = (Target point of ability being cast)
      • Set SS_Angle[SS_iM] = (Angle from SS_cLoc[SS_iM] to SS_tLoc[SS_iM])
      • Set SS_rLoc[SS_iM] = (SS_cLoc[SS_iM] offset by 1200.00 towards SS_Angle[SS_iM] degrees)
      • Unit - Create 1 SS_Dummy for SS_Player[SS_iM] at SS_cLoc[SS_iM] facing SS_Angle[SS_iM] degrees
      • Unit - Set Max HP of (Last created unit) to ((Intelligence of SS_Caster[SS_iM] (Include bonuses)) x 6)
      • Set SS_Missle[SS_iM] = (Last created unit)
      • Animation - Change SS_Missle[SS_iM]'s size to (SS_MissleSize%, SS_MissleSize%, SS_MissleSize%) of its original size
      • Special Effect - Create a special effect attached to the chest of SS_Missle[SS_iM] using Abilities\Weapons\NecromancerMissile\NecromancerMissile.mdl
      • Set SS_SFX[SS_iM] = (Last created special effect)
      • Set SS_mLoc[SS_iM] = (Position of SS_Missle[SS_iM])
      • Set SS_Distance[SS_iM] = (Distance between SS_mLoc[SS_iM] and SS_rLoc[SS_iM])
      • Animation - Change SS_Missle[SS_iM] flying height to SS_MissleHeight at 0.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SS_iM Equal to 1
        • Then - Actions
          • Trigger - Turn on Curse Loop <gen>
        • Else - Actions
  • LOOP2
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer SS_iC) from 1 to SS_iM, do (Actions)
        • Loop - Actions
          • Set SS_Move = (SS_mLoc[SS_iC] offset by SS_MissleSpeed[SS_iM] towards SS_Angle[SS_iC] degrees)
          • Unit - Move SS_Missle[SS_iC] instantly to SS_Move
          • Custom script: call RemoveLocation (udg_SS_mLoc[udg_SS_iC])
          • Set SS_mLoc[SS_iC] = (Position of SS_Missle[SS_iC])
          • Set SS_Distance[SS_iC] = (Distance between SS_mLoc[SS_iC] and SS_rLoc[SS_iC])
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within SS_MissleAoE of SS_mLoc[SS_iC]) and do (Actions)
            • Loop - Actions
              • Set SS_eUnit = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SS_eUnit belongs to an enemy of SS_Player[SS_iC]) Equal to True
                  • (SS_eUnit is alive) Equal to True
                  • (SS_eUnit is Magic Immune) Equal to False
                  • (SS_eUnit is A structure) Equal to False
                • Then - Actions
                  • Unit Group - Add SS_eUnit to SS_Group
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • SS_Distance[SS_iC] Less than or equal to SS_MissleAoE
                  • (SS_Group is empty) Equal to False
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SS_Group is empty) Equal to True
                • Then - Actions
                  • Special Effect - Create a special effect at SS_mLoc[SS_iC] using Abilities\Weapons\BansheeMissile\BansheeMissile.mdl
                    • Special Effect - Destroy (Last created special effect)
                • Else - Actions
                  • Unit Group - Pick every unit in SS_Group and do (Actions)
                    • Loop - Actions
                      • Set SS_eUnit = (Picked unit)
                      • Special Effect - Create a special effect attached to the SS_MissleHit_AP of SS_eUnit using Abilities\Weapons\BansheeMissile\BansheeMissile.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • Unit - Cause SS_Missle[SS_iM] to damage SS_eUnit, dealing (Max life of SS_Missle[SS_iM]) damage of attack type Normal and damage type Normal
                      • Unit Group - Remove SS_eUnit from SS_Group
              • Custom script: call RemoveLocation (udg_SS_rLoc[udg_SS_iC])
              • Custom script: call RemoveLocation (udg_SS_tLoc[udg_SS_iC])
              • Custom script: call RemoveLocation (udg_SS_cLoc[udg_SS_iC])
              • Custom script: call RemoveLocation (udg_SS_mLoc[udg_SS_iC])
              • Special Effect - Destroy SS_SFX[SS_iC]
              • Unit - Remove SS_Missle[SS_iC] from the game
              • Set SS_Caster[SS_iC] = SS_Caster[SS_iM]
              • Set SS_Player[SS_iC] = SS_Player[SS_iM]
              • Set SS_aLevel[SS_iC] = SS_aLevel[SS_iM]
              • Set SS_cLoc[SS_iC] = SS_cLoc[SS_iM]
              • Set SS_tLoc[SS_iC] = SS_tLoc[SS_iM]
              • Set SS_Angle[SS_iC] = SS_Angle[SS_iM]
              • Set SS_rLoc[SS_iC] = SS_rLoc[SS_iM]
              • Set SS_Missle[SS_iC] = SS_Missle[SS_iM]
              • Set SS_SFX[SS_iC] = SS_SFX[SS_iM]
              • Set SS_mLoc[SS_iC] = SS_mLoc[SS_iM]
              • Set SS_Distance[SS_iC] = SS_Distance[SS_iM]
              • Set SS_iM = (SS_iM - 1)
              • Set SS_iC = (SS_iC - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SS_iM Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions

(Both abilities will have different effects in loop once I fix the speed bug)
 
Last edited:
Level 12
Joined
Feb 22, 2010
Messages
1,115
  • Set SS_Move = (SS_mLoc[SS_iC] offset by SS_MissleSpeed[SS_iM] towards SS_Angle[SS_iC] degrees)
SS_MissleSpeed[SS_iM] here should be SS_MissleSpeed[SS_iC], in both triggers.

Edit: Apart from speed problem, both your LOOP and LOOP2 triggers seem to use same set of variables. which will make triggers run twice as many (first LOOP trigger will also move projectile of second ability, and vice versa). Also cause some bugs.
 
Last edited:
Level 5
Joined
Dec 25, 2018
Messages
110
  • Set SS_Move = (SS_mLoc[SS_iC] offset by SS_MissleSpeed[SS_iM] towards SS_Angle[SS_iC] degrees)
SS_MissleSpeed[SS_iM] here should be SS_MissleSpeed[SS_iC], in both triggers.

Edit: Apart from speed problem, both your LOOP and LOOP2 triggers seem to use same set of variables. which will make triggers run twice as many (first LOOP trigger will also move projectile of second ability, and vice versa). Also cause some bugs.

I changed them to IC before
set udg_SS_Move[udg_SS_iC] = PolarProjectionBJ(udg_SS_mLoc[udg_SS_iC], 50.00, udg_SS_Angle[udg_SS_iC])
call SetUnitPositionLoc( udg_SS_Missle[udg_SS_iC], udg_SS_Move[udg_SS_iC] )

So are you telling me to use 1 loop after all?
I knew thats way to fix it but I really wanted to keep init and loop for every ability since its easier for me to come back to them later and change stuff.

(Or perhaps you know a system that would better suit my needs)
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
I changed them to IC before
set udg_SS_Move[udg_SS_iC] = PolarProjectionBJ(udg_SS_mLoc[udg_SS_iC], 50.00, udg_SS_Angle[udg_SS_iC])
call SetUnitPositionLoc( udg_SS_Missle[udg_SS_iC], udg_SS_Move[udg_SS_iC] )

So are you telling me to use 1 loop after all?
I knew thats way to fix it but I really wanted to keep init and loop for every ability since its easier for me to come back to them later.

You are using constant speed 50 here, not using speed of the spell. Change the way I show you (You are not using SS_MissleSpeed anywhere)

I would sugges using multiple init triggers, 1 periodic trigger and multiple finish triggers. You can decide which finish trigger to run in your periodic trigger, or create a custom projectile hit event with real variable event, similar to weep's damage detection.
 
Level 5
Joined
Dec 25, 2018
Messages
110
You are using constant speed 50 here, not using speed of the spell. Change the way I show you (You are not using SS_MissleSpeed anywhere)

I would sugges using multiple init triggers, 1 periodic trigger and multiple finish triggers. You can decide which finish trigger to run in your periodic trigger, or create a custom projectile hit event with real variable event, similar to weep's damage detection.
You mean something like this?

  • Unit Group - Pick every unit in SS_Group and do (Actions)
    • Loop - Actions
      • Set SS_eUnit = (Picked unit)
      • Trigger - Run Finish Trigger 1 <gen> (ignoring conditions)
  • Finish Trigger 1
    • Events
    • Conditions
    • Actions
      • Special Effect - Create a special effect attached to the SS_MissleHit_AP of SS_eUnit using Objects\Spawnmodels\Human\HumanBlood\BloodElfSpellThiefBlood.mdl
      • Special Effect - Destroy (Last created special effect)
      • Unit - Cause SS_Missle[SS_iM] to damage SS_eUnit, dealing (Max life of SS_Missle[SS_iM]) damage of attack type Normal and damage type Normal
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Thats similar to how I would do it, but you should probably wait for someone with more knowledge who might have a better way/system suggestion.
 
Level 5
Joined
Dec 25, 2018
Messages
110
Got one more question, how does he select SS_iC in world editor?
When I try to find it in the list its only SS_iM in there.
SS_iM is integer with 0 def.
SS_iC is integer with NONE def but when I try to edit it, its type is empty.

This is why I was doing custom script before.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Well, that is not supposed to happen. Maybe you should delete SS_iC variable and recreate the integer variable with same name and hope it fixes things.

You can replace 50.00 in your custom script with udg_SS_MissleSpeed[udg_SS_iC]. But better to fix variable.
 
Level 5
Joined
Dec 25, 2018
Messages
110
Well, that is not supposed to happen. Maybe you should delete SS_iC variable and recreate the integer variable with same name and hope it fixes things.

You can replace 50.00 in your custom script with udg_SS_MissleSpeed[udg_SS_iC]. But better to fix variable.

Replacing that in custom script gives an error that SS_IC and MissleSpeed don't exist.

I will try to recreate SS_iC.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Replacing that in custom script gives an error that SS_IC and MissleSpeed don't exist.

I will try to recreate SS_iC.
Are you sure you wrote udg_ parts at the start. Even your own custom script version you are using SS_iC, there is no way it does not exist. Also its iC, not IC.
 
Level 5
Joined
Dec 25, 2018
Messages
110
Are you sure you wrote udg_ parts at the start. Even your own custom script version you are using SS_iC, there is no way it does not exist. Also its iC, not IC.
I got speed to work, last problem remains with iC, is that a problem if in finish trigger I use iM instead of iC?
(Recreating iC will take some time, because every trigger with it is blank so I kinda want to avoid that)
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
SS_iM is the last index that is used by the spell. For example if 3 units are using missile abilities at the same time, it will be equal to 3. Using speed[SS_iM] is the reason your last missile speed overrides the others. It looks like M in iM stands for maximum and C in iC stands for current.
 
Status
Not open for further replies.
Top