• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Some help needed for a trigger

Status
Not open for further replies.
Level 15
Joined
Nov 26, 2005
Messages
1,151
Ok, hello guys.
I want to make a spell that basically creates a boulder that moves forward and can only hit a unit ONCE for (75 x Lvl of ability) damage.

Here are my triggers:


  • Rolling Bouldr Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Rolling Boulder
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • RB_Index Equal to 0
        • Then - Actions
          • Trigger - Turn on Rolling Bouldr Loop <gen>
        • Else - Actions
      • Set RB_Index = (RB_Index + 1)
      • Set RB_MUI = (RB_MUI + 1)
      • Set RB_check[RB_MUI] = True
      • Set TempLoc[1] = (Position of (Casting unit))
      • Set TempLoc[2] = (Target point of ability being cast)
      • Set RB_Angle[RB_MUI] = (Angle from TempLoc[1] to TempLoc[2])
      • Set TempLoc[3] = (TempLoc[1] offset by 17.00 towards RB_Angle[RB_MUI] degrees)
      • Unit - Create 1 Spell Dummy for (Owner of (Casting unit)) at TempLoc[1] facing RB_Angle[RB_MUI] degrees
      • Animation - Change (Last created unit)'s size to (350.00%, 350.00%, 350.00%) of its original size
      • Animation - Change (Last created unit)'s animation speed to 65.00% of its original speed
      • Special Effect - Create a special effect attached to the origin of (Last created unit) using abilities\weapons\catapult\catapultmissile.mdl
      • Set RB_Boulder[RB_MUI] = (Last created unit)
      • Set RB_Distance[RB_MUI] = 800.00
      • Set RB_Distance_Traveled[RB_MUI] = 0.00
      • Set RB_Speed[RB_MUI] = 6.20
      • Set RB_AlreadyHit[RB_MUI] = RB_AlreadyHit[RB_MUI]
      • Set RB_Damage[RB_MUI] = (75.00 x (Real((Level of Rolling Boulder for (Casting unit)))))
      • Custom script: call RemoveLocation(udg_TempLoc[1])
      • Custom script: call RemoveLocation(udg_TempLoc[2])
      • Custom script: call RemoveLocation(udg_TempLoc[3])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Binding Slam for (Casting unit)) Greater than 0
        • Then - Actions
          • Set BS_Level = (Level of Binding Slam for (Casting unit))
          • Set TempLoc[1] = (Position of (Casting unit))
          • Unit - Create 1 Spell Dummy for (Owner of (Casting unit)) at TempLoc[1] facing Default building facing degrees
          • Unit - Add dummy_BS_clap to (Last created unit)
          • Unit - Set level of dummy_BS_clap for (Last created unit) to BS_Level
          • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
          • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
          • Custom script: call RemoveLocation(udg_TempLoc[1])
        • Else - Actions



  • Rolling Bouldr Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer RB_loop) from 1 to RB_MUI, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RB_check[RB_loop] Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RB_Distance_Traveled[RB_loop] Less than RB_Distance[RB_MUI]
                • Then - Actions
                  • Set TempLoc[1] = (Position of RB_Boulder[RB_loop])
                  • Set TempLoc[2] = (TempLoc[1] offset by RB_Speed[RB_loop] towards RB_Angle[RB_loop] degrees)
                  • Unit - Move RB_Boulder[RB_loop] instantly to TempLoc[2]
                  • Special Effect - Create a special effect at TempLoc[1] using Abilities\Spells\Other\Volcano\VolcanoDeath.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Set RB_Distance_Traveled[RB_loop] = (RB_Distance_Traveled[RB_loop] + RB_Speed[RB_loop])
                  • Set TempGroup[1] = (Units within 45.00 of TempLoc[2] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is dead) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of RB_Boulder[RB_loop])) Equal to True) and (((Matching unit) is
                  • Unit Group - Pick every unit in TempGroup[1] and do (Actions)
                    • Loop - Actions
                      • Unit - Cause RB_Boulder[RB_loop] to damage (Picked unit), dealing RB_Damage[RB_loop] damage of attack type Spells and damage type Universal
                      • Unit Group - Add (Picked unit) to RB_AlreadyHit[RB_loop]
                  • Unit Group - Remove all units from TempGroup[1]
                  • Custom script: call DestroyGroup(udg_TempGroup[1])
                  • Custom script: call RemoveLocation(udg_TempLoc[1])
                  • Custom script: call RemoveLocation(udg_TempLoc[2])
                • Else - Actions
                  • Set TempLoc[1] = (Position of RB_Boulder[RB_loop])
                  • Unit - Kill RB_Boulder[RB_loop]
                  • Unit - Remove RB_Boulder[RB_loop] from the game
                  • Special Effect - Create a special effect at TempLoc[1] using Objects\Spawnmodels\Human\HCancelDeath\HCancelDeath.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • -------- -------------------- --------
                  • Set RB_Index = (RB_Index - 1)
                  • -------- -------------------- --------
                  • Set RB_Boulder[RB_loop] = No unit
                  • Set RB_Angle[RB_loop] = 0.00
                  • Set RB_Distance[RB_loop] = 0.00
                  • Set RB_Distance_Traveled[RB_loop] = 0.00
                  • Set RB_Speed[RB_loop] = 0.00
                  • Set RB_Damage[RB_loop] = 0.00
                  • Unit Group - Remove all units from RB_AlreadyHit[RB_loop]
                  • Custom script: call DestroyGroup(udg_RB_AlreadyHit[udg_RB_loop])
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • RB_Index Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                      • Set RB_MUI = 0
                    • Else - Actions
            • Else - Actions


Ecerything seemed to work fine with moving and the spells looks MUI etc but the damage is applied every 0.03 seconds inspite of my check for unit is in group "AlreadyHit". Any idea where I was wrong? And also if u find any wrong or not good parts of the spell - pls infor me!

Ty very much :)
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
The group thing doesn't work because you're adding the unit to a unit-group array based on the loop index, with is always different everytime the loop runs, so you dmg unit, and add it to Group[1] then dmg and add to Group[2], etc...

When a unit gets damaged by the stone, save a boolean on the units ID in a Hashtable. Check in that Hashtable and that unit id if the unit has already been damaged before dealing damage.

NOTE: still, as it is, your ability is not MUI.
 
It can work with groups... My old missile system uses groups to save which units have been already hit and it works perfectly fine [and it's one group per instance of a missile]... and I can't see why it shouldn't work...

Make sure you set the max index for the group array at the variable editor to maybe 8190... your problem could be that the groups in the array aren't initalized meaning you could be adding units to a null group... by default, wc3 only creates groups from GroupArray[0] up to GroupArray[maxindex]...

@Spart - the groups need to be one per instance because if its just one group then it won't be MUI...
 
Level 15
Joined
Nov 26, 2005
Messages
1,151
It can work with groups... My old missile system uses groups to save which units have been already hit and it works perfectly fine [and it's one group per instance of a missile]... and I can't see why it shouldn't work...

Make sure you set the max index for the group array at the variable editor to maybe 8190... your problem could be that the groups in the array aren't initalized meaning you could be adding units to a null group... by default, wc3 only creates groups from GroupArray[0] up to GroupArray[maxindex]...

@Spart - the groups need to be one per instance because if its just one group then it won't be MUI...

I tried that, went to the var editor and se the Size to 8190. Still no improvement.

Set RB_AlreadyHit[RB_MUI] = RB_AlreadyHit[RB_MUI]
This is the line I think shouldn't be there, but I do not know how to initialize the group...

Would u mind giving me an example with ur system or smth? :S


P.S.
I think this solved the problem:

Custom script: set udg_groupVariable = CreateGroup()

Do u think it does?
 
Last edited:
If you already set the group array index to 8190, wc3 should have already initialized all of the groups...

oh wait I think your problem is because you called DestroyGroup when an instance is finished... never ever destroy global groups...

btw, I think your indexing has a flaw... You should look at Dynamic indexing template of Hanky...
 
Level 15
Joined
Nov 26, 2005
Messages
1,151
If I do not destroy the group after the instance end, should I just remove that line or replace it with something else?

What kind of flaw?

Btw, I noticed the next spell I am trying to make with this indexing, sometimes doesn't do what it has to. What's the benefit of Hanky's system? (I've looked over it a lot and looks a BIT unclear :S)
 
Just remove the line... It isn't really needed... You shouldn't destroy the global groups... You just need to empty them after the instance ends since you're using the GUI enum units...

Its because your indexing doesn't recycle the indexes right... so you better check out Hanky's Dynamic Indexing Template and learn how to properly recycle indexes...
 
Status
Not open for further replies.
Top