1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. 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.

[Trigger] Skill doesn't work

Discussion in 'Triggers & Scripts' started by GangSpear, Dec 21, 2011.

  1. GangSpear

    GangSpear

    Joined:
    Oct 25, 2009
    Messages:
    971
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I am making a skill for my friends,it work,but it doesn't damage enemy,anyone can tell me why?This skill same with DotA Windrunner Powershot, and is it MUI!?When 2 people cast the skill at same time,the missle very strange,sometimes go to another way.
    here's the trigger:
    Cast
    • BS Cast
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Battle Shot
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • BS_IndexSize Equal to 0
          • Then - Actions
            • Trigger - Turn on BS Loop <gen>
          • Else - Actions
        • Set BS_IndexSize = (BS_IndexSize + 1)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • BS_IndexSize Greater than BS_IndexMaxSize
          • Then - Actions
            • Set BS_Index[BS_IndexSize] = BS_IndexSize
            • Set BS_IndexMaxSize = BS_IndexSize
          • Else - Actions
        • Set BS_ZInteger = BS_Index[BS_IndexSize]
        • Set BS_Caster[BS_ZInteger] = (Triggering unit)
        • Set BS_Boolean[BS_ZInteger] = False
        • Set BS_Range[BS_ZInteger] = 1700.00
        • Set BS_ReduceInteger[BS_ZInteger] = 0
        • Set BS_Speed[BS_ZInteger] = 0.00
        • Set BS_Damage[BS_ZInteger] = (40.00 + (80.00 x (Real((Level of Battle Shot for BS_Caster[BS_ZInteger])))))
        • Set BS_ReduceDamage[BS_ZInteger] = (BS_Damage[BS_ZInteger] / (10.00 / 100.00))
        • Set BS_RealReduceDamage[BS_ZInteger] = 0.00
        • Set BS_Points[1] = (Position of BS_Caster[BS_ZInteger])
        • Set BS_Points[2] = (BS_Points[1] offset by 50.00 towards (Facing of BS_Caster[BS_ZInteger]) degrees)
        • Unit - Create 1 BS_Dummy for (Triggering player) at BS_Points[2] facing (Facing of BS_Caster[BS_ZInteger]) degrees
        • Set BS_Dummy[BS_ZInteger] = (Last created unit)
        • Set BS_Points[3] = (Position of BS_Dummy[BS_ZInteger])
        • Unit - Turn collision for BS_Dummy[BS_ZInteger] Off
        • Set BS_Group[BS_ZInteger] = (Units within 100.00 of BS_Points[3] matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner
        • Unit Group - Pick every unit in BS_Group[BS_ZInteger] and do (Actions)
          • Loop - Actions
            • Set BS_PickedUnit[BS_ZInteger] = (Picked unit)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (BS_PickedUnit[BS_ZInteger] is in BS_PickGroup[BS_ZInteger]) Equal to False
              • Then - Actions
                • Set BS_ReduceInteger[BS_ZInteger] = (BS_ReduceInteger[BS_ZInteger] + 1)
                • Set BS_RealReduceDamage[BS_ZInteger] = ((Real(BS_ReduceInteger[BS_ZInteger])) x BS_ReduceDamage[BS_ZInteger])
                • Unit - Cause BS_Dummy[BS_ZInteger] to damage BS_PickedUnit[BS_ZInteger], dealing (BS_Damage[BS_ZInteger] - BS_RealReduceDamage[BS_ZInteger]) damage of attack type Spells and damage type Normal
                • Unit Group - Add BS_PickedUnit[BS_ZInteger] to BS_PickGroup[BS_ZInteger]
              • Else - Actions
        • Custom script: call DestroyGroup(udg_BS_Group[udg_BS_ZInteger])
        • Custom script: if udg_BS_PickGroup[udg_BS_ZInteger] == null then
        • Custom script: set udg_BS_PickGroup[udg_BS_ZInteger] = CreateGroup()
        • Custom script: endif
        • Custom script: call RemoveLocation(udg_BS_Points[2])
    Loop
    • BS Loop
      • Events
        • Time - Every 0.03 seconds of game time
      • Conditions
      • Actions
        • For each (Integer BS_IndexLoop) from 1 to BS_IndexSize, do (Actions)
          • Loop - Actions
            • Set BS_ZInteger = BS_Index[BS_IndexLoop]
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • BS_Range[BS_ZInteger] Greater than BS_Speed[BS_ZInteger]
              • Then - Actions
                • Set BS_Speed[BS_ZInteger] = (BS_Speed[BS_ZInteger] + 50.00)
                • Set BS_Points[4] = (BS_Points[1] offset by BS_Speed[BS_ZInteger] towards (Facing of BS_Dummy[BS_ZInteger]) degrees)
                • Set BS_Points[5] = (Position of BS_Dummy[BS_ZInteger])
                • Unit - Move BS_Dummy[BS_ZInteger] instantly to BS_Points[4]
                • Set BS_Group[BS_ZInteger] = (Units within 100.00 of BS_Points[5] matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner
                • Unit Group - Pick every unit in BS_Group[BS_ZInteger] and do (Actions)
                  • Loop - Actions
                    • Set BS_PickedUnit[BS_ZInteger] = (Picked unit)
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (BS_PickedUnit[BS_ZInteger] is in BS_PickGroup[BS_ZInteger]) Equal to False
                      • Then - Actions
                        • Set BS_ReduceInteger[BS_ZInteger] = (BS_ReduceInteger[BS_ZInteger] + 1)
                        • Set BS_RealReduceDamage[BS_ZInteger] = ((Real(BS_ReduceInteger[BS_ZInteger])) x BS_ReduceDamage[BS_ZInteger])
                        • Unit - Cause BS_Dummy[BS_ZInteger] to damage BS_PickedUnit[BS_ZInteger], dealing (BS_Damage[BS_ZInteger] - BS_RealReduceDamage[BS_ZInteger]) damage of attack type Spells and damage type Normal
                        • Unit Group - Add BS_PickedUnit[BS_ZInteger] to BS_PickGroup[BS_ZInteger]
                      • Else - Actions
                • Custom script: call DestroyGroup(udg_BS_Group[udg_BS_ZInteger])
                • Custom script: call RemoveLocation(udg_BS_Points[3])
                • Custom script: call RemoveLocation(udg_BS_Points[4])
                • Custom script: call RemoveLocation(udg_BS_Points[5])
              • Else - Actions
                • Unit - Explode BS_Dummy[BS_ZInteger]
                • Set BS_Boolean[BS_ZInteger] = True
                • Custom script: call RemoveLocation(udg_BS_Points[1])
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • BS_Boolean[BS_ZInteger] Equal to True
              • Then - Actions
                • Set BS_Index[BS_IndexLoop] = BS_Index[BS_IndexSize]
                • Set BS_Index[BS_IndexSize] = BS_ZInteger
                • Set BS_IndexLoop = (BS_IndexLoop - 1)
                • Set BS_IndexSize = (BS_IndexSize - 1)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • BS_IndexSize Equal to 0
                  • Then - Actions
                    • Trigger - Turn off (This trigger)
                  • Else - Actions
              • Else - Actions

    +REP for helpers
     
  2. Lord_Earthfire

    Lord_Earthfire

    Joined:
    Oct 5, 2008
    Messages:
    353
    Resources:
    1
    Spells:
    1
    Resources:
    1
    The point, why your spell does not deal damage is pretty simple:

    • Unit Group - Pick every unit in BS_Group[BS_ZInteger] and do (Actions)
    • Loop - Actions
    • Set BS_PickedUnit[BS_ZInteger] = (Picked unit)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • (BS_PickedUnit[BS_ZInteger] is in BS_PickGroup[BS_ZInteger]) Equal to False
    • Then - Actions
    • Set BS_ReduceInteger[BS_ZInteger] = (BS_ReduceInteger[BS_ZInteger] + 1)
    • Set BS_RealReduceDamage[BS_ZInteger] = ((Real(BS_ReduceInteger[BS_ZInteger])) x BS_ReduceDamage[BS_ZInteger])
    • Unit - Cause BS_Dummy[BS_ZInteger] to damage BS_PickedUnit[BS_ZInteger], dealing (BS_Damage[BS_ZInteger] - BS_RealReduceDamage[BS_ZInteger]) damage of attack type Spells and damage type Normal
    • Unit Group - Add BS_PickedUnit[BS_ZInteger] to BS_PickGroup[BS_ZInteger]
    • Else - Actions

    You pick all units of this group and deal only damage to them, when they does not belong to the group you picked them from. The "if/then/else" blocks the damage effect.

    The point, why your spell is not mui lies here:

    • Set BS_Points[4] = (BS_Points[1] offset by BS_Speed[BS_ZInteger] towards (Facing of BS_Dummy[BS_ZInteger]) degrees)


    BS Point [1] is set to the position from which the spell is casted, thats logical, but when you cast the spell another time, this point will be overriden. You should add:

    Custom script: call RemoveLocation(udg_BS_Points[1])

    and

    Custom script: call RemoveLocation(udg_BS_Points[3])

    on the end of BScast trigger and remove these from BS loop, since they will be overriden anyway when you recast the spell.

    • BS Loop
    • Events
    • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
    • For each (Integer BS_IndexLoop) from 1 to BS_IndexSize, do (Actions)
    • Loop - Actions
    • Set BS_ZInteger = BS_Index[BS_IndexLoop]
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • BS_Range[BS_ZInteger] Greater than BS_Speed[BS_ZInteger]
    • Then - Actions
    • Set BS_Speed[BS_ZInteger] = (BS_Speed[BS_ZInteger] + 50.00)
    • Set BS_Points[4] = (BS_Points[1] offset by BS_Speed[BS_ZInteger] towards (Facing of BS_Dummy[BS_ZInteger]) degrees)
    • Set BS_Points[5] = (Position of BS_Dummy[BS_ZInteger])
    • Unit - Move BS_Dummy[BS_ZInteger] instantly to BS_Points[4]
    • Set BS_Group[BS_ZInteger] = (Units within 100.00 of BS_Points[5] matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner
    • Unit Group - Pick every unit in BS_Group[BS_ZInteger] and do (Actions)
    • Loop - Actions
    • Set BS_PickedUnit[BS_ZInteger] = (Picked unit)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • (BS_PickedUnit[BS_ZInteger] is in BS_PickGroup[BS_ZInteger]) Equal to False
    • Then - Actions
    • Set BS_ReduceInteger[BS_ZInteger] = (BS_ReduceInteger[BS_ZInteger] + 1)
    • Set BS_RealReduceDamage[BS_ZInteger] = ((Real(BS_ReduceInteger[BS_ZInteger])) x BS_ReduceDamage[BS_ZInteger])
    • Unit - Cause BS_Dummy[BS_ZInteger] to damage BS_PickedUnit[BS_ZInteger], dealing (BS_Damage[BS_ZInteger] - BS_RealReduceDamage[BS_ZInteger]) damage of attack type Spells and damage type Normal
    • Unit Group - Add BS_PickedUnit[BS_ZInteger] to BS_PickGroup[BS_ZInteger]
    • Else - Actions
    • Custom script: call DestroyGroup(udg_BS_Group[udg_BS_ZInteger])
    • Custom script: call RemoveLocation(udg_BS_Points[3])
    • Custom script: call RemoveLocation(udg_BS_Points[4])
    • Custom script: call RemoveLocation(udg_BS_Points[5])


    Here, you should remove the RemoveLocation(udg_BS_Points[3]), like said above and change this
    • Set BS_Points[4] = (BS_Points[1] offset by BS_Speed[BS_ZInteger] towards (Facing of BS_Dummy[BS_ZInteger]) degrees)
    • Set BS_Points[5] = (Position of BS_Dummy[BS_ZInteger])

    into this:
    • Set BS_Points[4] = (Position of BS_Dummy[BS_ZInteger])
    • Set BS_Points[5] = (BS_Points[4] offset by 50 towards (Facing of BS_Dummy[BS_ZInteger]) degrees)


    Or you put your former BS_Point[1] into the indexer too, so it would not be removed.

    I hope, that i explained it right and i hop that i could help ;)
     
  3. GangSpear

    GangSpear

    Joined:
    Oct 25, 2009
    Messages:
    971
    Resources:
    1
    Spells:
    1
    Resources:
    1
  4. Jay the Editor

    Jay the Editor

    Joined:
    Aug 12, 2008
    Messages:
    317
    Resources:
    6
    Icons:
    2
    Spells:
    4
    Resources:
    6
    Lots of mistakes have been check by Lord EarthFire.
    By the way, you should not make the points to array. Instead, you should split it to several variables. Arrayed variable took up much more space.
    In the loop trigger, instead of storing the unit group, then pick them and destroy the group, I suggest you to use the native "set bj_wantDestroyGroup = true". The native mentioned helps you destroy the group after you use it.
     
  5. Lord_Earthfire

    Lord_Earthfire

    Joined:
    Oct 5, 2008
    Messages:
    353
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I have edited the trigger and it should work now. I have improved the efficience of the trigger and dome some things here and there, i have commented everything i have changed.

    The trigger and the concept of the execution was good, but there was some things to improve.


    For the efficience:
    -See what variables you have changed and need to set again
    -"set bj_want DestroyGroup" is a good way to save some lines. (Thanks to Jay the Editor for the suggestion)
    -Look what you really need in an indexer, too much variables are just too much ;)

    I can't remember what was false now, i have written all my changed and i think that tzhere was one main issue, i can't find it now :/
    But keep on the work and the learning, your doing well.

    I hope i could help.

    By the way, i believe that there are more ways to improve the triggers and i don't claim that i have made the best possible (what is impossible i believe), i have made some changes, if you know some, fell free to post
     

    Attached Files:

  6. Jay the Editor

    Jay the Editor

    Joined:
    Aug 12, 2008
    Messages:
    317
    Resources:
    6
    Icons:
    2
    Spells:
    4
    Resources:
    6
    Indeed the variables are just too much. You should replace some variables with global variables which you clear them after you use it. These variables can be used in as many spells as possible. That's what suggested by Bribe. :)