1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[General] Multiple projectiles bug

Discussion in 'World Editor Help Zone' started by Fakuspakus, Jul 5, 2019.

  1. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    94
    Resources:
    0
    Resources:
    0
    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: Jul 5, 2019
  2. Swatosj

    Swatosj

    Joined:
    Jun 12, 2018
    Messages:
    44
    Resources:
    0
    Resources:
    0
    Where does the speed value change in your code ?
    From what I can see here
    will remain to 50.00 for every instance
     
  3. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    94
    Resources:
    0
    Resources:
    0
    Each projectile spell has its own init and loop.
    In init speed is stored in SS_MissileSpeed array
     
  4. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    Show triggers of both spells.
     
  5. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    94
    Resources:
    0
    Resources:
    0
    It's same as the one I posted, only difference is speed value and dmg.
     
  6. Swatosj

    Swatosj

    Joined:
    Jun 12, 2018
    Messages:
    44
    Resources:
    0
    Resources:
    0
    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 ?
     
  7. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    You are probably misusing a variable, it is impossible to point the error without seeing both triggers.
     
  8. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    94
    Resources:
    0
    Resources:
    0
    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: Jul 5, 2019
  9. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    • 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: Jul 5, 2019
  10. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    94
    Resources:
    0
    Resources:
    0
    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)
     
  11. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    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.
     
  12. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    94
    Resources:
    0
    Resources:
    0
    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
     
  13. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    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.
     
  14. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    94
    Resources:
    0
    Resources:
    0
    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.
     
  15. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    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.
     
  16. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    94
    Resources:
    0
    Resources:
    0
    Replacing that in custom script gives an error that SS_IC and MissleSpeed don't exist.

    I will try to recreate SS_iC.
     
  17. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    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.
     
  18. Fakuspakus

    Fakuspakus

    Joined:
    Dec 25, 2018
    Messages:
    94
    Resources:
    0
    Resources:
    0
    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)
     
  19. Ceday

    Ceday

    Joined:
    Feb 22, 2010
    Messages:
    1,077
    Resources:
    0
    Resources:
    0
    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.