• 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] Help with spamming bug?

Status
Not open for further replies.
Level 12
Joined
Aug 12, 2008
Messages
350
Spell description
Place a water orb when cast. As long as the orb is still alive, Water Elemental is able to morph to the position of the orb once. If Water Elemental did not morph to the position of the orb while the orb is still alive, Water Elemental will automatically morph to the position of the orb when the orb die. Orb lasts for 7 seconds.
Water Way ability will be added when cast
Cast time: 0.5 seconds
Here's the trigger:
[trigger=WO cast]WO cast
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Water Orb
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WO_index1 Equal to 0
Then - Actions
Trigger - Turn on WO count <gen>
Trigger - Turn on WO water way <gen>
Else - Actions
Set WO_index1 = (WO_index1 + 1)
Set WO_index2 = (WO_index2 + 1)
Set WO_check[WO_index2] = False
Set WO_caster[WO_index2] = (Triggering unit)
Set WO_casterpoint = (Position of WO_caster[WO_index2])
Set WO_count[WO_index2] = 0.00
Unit - Add Water Way to WO_caster[WO_index2]
Unit Group - Add WO_caster[WO_index2] to WO_heroesgroup
Unit - Create 1 Orb of Water for (Owner of WO_caster[WO_index2]) at WO_casterpoint facing Default building facing degrees
Set WO_dummy[WO_index2] = (Last created unit)
Special Effect - Create a special effect at WO_casterpoint using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
Special Effect - Destroy (Last created special effect)
[/trigger]
[trigger=WO count]WO count
Events
Time - Every 0.25 seconds of game time
Conditions
Actions
For each (Integer WO_index3) from 1 to WO_index2, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
WO_count[WO_index3] Less than 7.00
(WO_caster[WO_index3] is in WO_heroesgroup) Equal to True
Then - Actions
Set WO_count[WO_index3] = (WO_count[WO_index3] + 0.25)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(WO_caster[WO_index3] is in WO_heroesgroup) Equal to True
Then - Actions
Unit Group - Remove WO_caster[WO_index3] from WO_heroesgroup
Else - Actions
Set WO_dummypoint = (Position of WO_dummy[WO_index3])
Unit - Move WO_caster[WO_index3] instantly to WO_dummypoint
Special Effect - Create a special effect at WO_dummypoint using Objects\Spawnmodels\Naga\NagaDeath\NagaDeath.mdl
Special Effect - Destroy (Last created special effect)
Unit - Kill WO_dummy[WO_index3]
Unit - Remove Water Way from WO_caster[WO_index3]
Custom script: set udg_WO_caster[udg_WO_index3] = null
Custom script: call RemoveLocation (udg_WO_dummypoint)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WO_check[WO_index3] Equal to False
Then - Actions
Set WO_index1 = (WO_index1 - 1)
Set WO_check[WO_index3] = True
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WO_index1 Equal to 0
Then - Actions
Trigger - Turn off (This trigger)
Set WO_index2 = 0
Else - Actions
[/trigger]
[trigger=WO water way]WO water way
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Water Way
Actions
Unit Group - Remove (Triggering unit) from WO_heroesgroup
[/trigger]

Triggers looks fine, isn't it? I made the spell based on the Fiery Form spell created by me but the Fiery Form works perfectly fine while this isn't.
When more than caster cast this spell, no problem occur. Here's the problem, when one of the caster's water orb's duration end, the special effect which I put it at the end of duration keep spamming at the point until all of caster's water orb's duration end. Can anyone help me with this?
 
Your first trigger leaks location and unfortunately you use old indexing system. Nowadays you can make it much better, with recycling indexes as well. Use Bride's Unit Indexer/Hanky dynamic inexing for that.

Anyways, using this indexing you shoud try this:
  • WO cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Water Orb
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WO_index1 Equal to 0
        • Then - Actions
          • Trigger - Turn on WO count <gen>
          • Trigger - Turn on WO water way <gen>
        • Else - Actions
      • Set WO_index1 = (WO_index1 + 1)
      • Set WO_index2 = (WO_index2 + 1)
      • Set WO_check[WO_index2] = False
      • Set WO_caster[WO_index2] = (Triggering unit)
      • Set WO_casterpoint = (Position of WO_caster[WO_index2])
      • Set WO_count[WO_index2] = 0.00
      • Unit - Add Water Way to WO_caster[WO_index2]
      • Unit Group - Add WO_caster[WO_index2] to WO_heroesgroup
      • Unit - Create 1 Orb of Water for (Owner of WO_caster[WO_index2]) at WO_casterpoint facing Default building facing degrees
      • Set WO_dummy[WO_index2] = (Last created unit)
      • Special Effect - Create a special effect at WO_casterpoint using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation (udg_WO_casterpoint)
[trigger=WO count]WO count
Events
Time - Every 0.25 seconds of game time
Conditions
Actions
For each (Integer WO_index3) from 1 to WO_index2, do (Actions)
Loop - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WO_check[WO_index3] = False
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
WO_count[WO_index3] Less than 7.00
(WO_caster[WO_index3] is in WO_heroesgroup)
Then - Actions
Set WO_count[WO_index3] = (WO_count[WO_index3] + 0.25)
Else - Actions
Set WO_check[WO_index3] = True
Set WO_dummypoint = (Position of WO_dummy[WO_index3])
Unit - Move WO_caster[WO_index3] instantly to WO_dummypoint
Special Effect - Create a special effect at WO_dummypoint using Objects\Spawnmodels\Naga\NagaDeath\NagaDeath.mdl
Special Effect - Destroy (Last created special effect)
Unit - Kill WO_dummy[WO_index3]
Unit Group - Remove WO_caster[udg_WO_index3] from WO_heroesgroup
Unit - Remove Water Way from WO_caster[WO_index3]
Custom script: set udg_WO_caster[udg_WO_index3] = null
Custom script: set udg_WO_dummy[udg_WO_index3] = null
Custom script: call RemoveLocation (udg_WO_dummypoint)
Set WO_index1 = (WO_index1 - 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WO_index1 = 0
Then - Actions
Trigger - Turn off (This trigger)
Set WO_index2 = 0
Else - Actions
Else - Actions[/trigger]
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
The problem is you do not deallocate completed instances until all instances in the list end thus they get itterated through and treated as if they still exist.

Why are so many people doing this? Is it like a plague or something? This has to be the 50th spell I have seen that has this problem...

There are 2 approaches for a proper indexing system.
1. Static instances. Each instance is assigned a unique address which remains constant during the entire instance life (until it is deallocated). A linked stack system is used using an integer array (can even be a member of the system or dedicated array) to help recycle deallocated instances. Advantage of this approach is very fast allocation and deallocation time (no bulk copies) and no logic needed to keep referential integrity. Disadvantage is that there is no native way to itterate through all allocated instances like a list. This is what Vjass structs use.
2. List of instances. You allocate instances to the end of the list. You deallocate instances by bulk copying the final instance over the one you are deallocating and decrimenting list size. Easy to itterate through all instances, fast to allocate but slow to deallocate due to bulk copy of variables. Instances are kept as a set (unordered) and are not static (referencial integrity is problematic). What this spell should be using is a implimentation of this.

Vjass spells often use a combination of both 1 and 2. 1 comes in the form of a struct which provides the spell instances. 2 comes in the form of a list of structs eliminating the bulk copy problem and providing the ability to itterate through all instances. They however often do this when not needing all the functionality both provide which can be inefficeint (as taylor made indexing systems can use implimentation specific optimizations).

An example was a hybrid instance list system I made that supports allocation like a normal struct but can only be deallocated by a list index. This saved on arrays by using the list array to help recycle indicies.
 
The problem is you do not deallocate completed instances until all instances in the list end thus they get itterated through and treated as if they still exist.

Everything you said is fine, but fact, that this indexing do not allow user to recycle instances immidiately (only when all are done) is not the reason for action-create effect spam. I was using Paladaon indexing system for years - since that indexing was first created by Paladon, and it worked fine, although its inefficent nowadays.

His trigger wasn't just made properly.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Everything you said is fine, but fact, that this indexing do not allow user to recycle instances immidiately (only when all are done) is not the reason for action-create effect spam. I was using Paladaon indexing system for years - since that indexing was first created by Paladon, and it worked fine, although its inefficent nowadays.
His "Indexing" system has been always flawed and inefficient. I hate how people even call them indexing systems, they are more like management styles for arrays and they are very easy to make to do whatever you want.

The problem still remains that he is itterating through instances that are meant to be destroyed.
 
Level 12
Joined
Aug 12, 2008
Messages
350
To Spinnaker: I see. Thanks Spinnaker. =)
To Dr Super Good: I thought it's still can be use and I get used to this indexing system. I'll change it later. Thanks too =)

[EDIT]: It's all fixed now. =) Thanks to Hanky's dynamic indexing system
Here's the trigger for those who may need it.
[trigger=WO cast]WO cast
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Water Orb
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WO_index_size Equal to 0
Then - Actions
Trigger - Turn on WO count <gen>
Trigger - Turn on WO water way <gen>
Else - Actions
Set WO_index_size = (WO_index_size + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WO_index_size Greater than WO_indexmax
Then - Actions
Set WO_index1[WO_index_size] = WO_index_size
Set WO_indexmax = WO_index_size
Else - Actions
Set WO_index2 = WO_index1[WO_index_size]
-------- ----------------------------------------------------------------------------------------------------------------- --------
Set WO_caster[WO_index2] = (Triggering unit)
Set WO_casterpoint = (Position of WO_caster[WO_index2])
Set WO_count[WO_index2] = 0.00
Unit - Create 1 Orb of Water for (Owner of WO_caster[WO_index2]) at WO_casterpoint facing Default building facing degrees
Set WO_dummy[WO_index2] = (Last created unit)
Special Effect - Create a special effect at WO_casterpoint using Abilities\Spells\Items\TomeOfRetraining\TomeOfRetrainingCaster.mdl
Special Effect - Destroy (Last created special effect)
Unit Group - Add WO_caster[WO_index2] to WO_heroesgroup
Unit - Add Water Way to WO_caster[WO_index2]
Custom script: call RemoveLocation (udg_WO_casterpoint)
[/trigger]
[trigger=WO count]WO count
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
For each (Integer WO_index3) from 1 to WO_index_size, do (Actions)
Loop - Actions
Set WO_index2 = WO_index1[WO_index3]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WO_count[WO_index2] Less than 7.00
(WO_caster[WO_index2] is in WO_heroesgroup) Equal to True
Then - Actions
Set WO_count[WO_index2] = (WO_count[WO_index2] + 0.03)
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(WO_caster[WO_index2] is in WO_heroesgroup) Equal to True
Then - Actions
Unit Group - Remove WO_caster[WO_index2] from WO_heroesgroup
Else - Actions
Unit - Remove Water Way from WO_caster[WO_index2]
Set WO_dummypoint = (Position of WO_dummy[WO_index2])
Unit - Move WO_caster[WO_index2] instantly to WO_dummypoint
Special Effect - Create a special effect at WO_dummypoint using Objects\Spawnmodels\Naga\NagaDeath\NagaDeath.mdl
Special Effect - Destroy (Last created special effect)
Unit - Kill WO_dummy[WO_index2]
Custom script: call RemoveLocation (udg_WO_dummypoint)
-------- ----------------------------------------------------------------------------------------------------------------- --------
Set WO_index1[WO_index3] = WO_index1[WO_index_size]
Set WO_index1[WO_index_size] = WO_index2
Set WO_index_size = (WO_index_size - 1)
Set WO_index3 = (WO_index3 - 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
WO_index_size Equal to 0
Then - Actions
Trigger - Turn off WO water way <gen>
Trigger - Turn off (This trigger)
Else - Actions
[/trigger]
[trigger=WO water way]WO water way
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Water Way
Actions
Unit Group - Remove (Triggering unit) from WO_heroesgroup
[/trigger]
 
Last edited:
Status
Not open for further replies.
Top