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

[Trigger] Skill doesn't work

Status
Not open for further replies.
Level 13
Joined
Oct 25, 2009
Messages
995
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:
  • 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])
  • 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
 
Level 10
Joined
Oct 5, 2008
Messages
355
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 ;)
 
Level 12
Joined
Aug 12, 2008
Messages
349
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.
 
Level 10
Joined
Oct 5, 2008
Messages
355
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
 

Attachments

  • Battle Shot modified.w3x
    36.9 KB · Views: 85
Status
Not open for further replies.
Top