• 🏆 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] Still Not MUI

Status
Not open for further replies.

BUP

BUP

Level 9
Joined
Sep 9, 2012
Messages
172
My spell has been OK with Dynamic Indexing.
But I changed the Indexing method now, it appears not to be MUI.
Would you check which part am I making mistakes??

Here are the Triggers


  • spr Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Sets the ability to activate the trigger --------
      • Set spr_ability = Spiritual Disrupt
      • -------- The animation string for the caster[The "slam" animation is set bcuz it looks good on Tauren] --------
      • Set spr_caster_animation = slam
      • -------- Damage dealt to the enemies[Arrays are Levels e.g. Array 1 = Level 1] --------
      • Set spr_damage[1] = 90.00
      • Set spr_damage[2] = 120.00
      • Set spr_damage[3] = 150.00
      • Set spr_damage[4] = 180.00
      • -------- Is the picked units a structure?? --------
      • Set spr_condition[1] = False
      • -------- Do the picked units belong to the enemy of the caster?? --------
      • Set spr_condition[2] = True
      • -------- Is the Picked Unit Alive?? --------
      • Set spr_condition[3] = True
      • -------- Is the Picked Unit belong in the spr_finished_group? --------
      • Set spr_condition[4] = False
      • -------- Is the Picked Unit in spr_finished_group in desirable range?? --------
      • Set spr_condition[5] = True
      • -------- The max distances that the wave will travel[Arrays are Levels e.g. Array 1 = Level 1] --------
      • Set spr_max_distance[1] = 800.00
      • Set spr_max_distance[2] = 1100.00
      • Set spr_max_distance[3] = 1400.00
      • Set spr_max_distance[4] = 1700.00
      • -------- The size of the wave travelled.[Arrays are Levels e.g. Array 1 = Level 1] --------
      • Set spr_dummy_size[1] = 140.00
      • Set spr_dummy_size[2] = 140.00
      • Set spr_dummy_size[3] = 140.00
      • Set spr_dummy_size[4] = 140.00
      • -------- The range around the wave that the enemies will be pushed out [Arrays are Levels e.g. Array 1 = Level 1] --------
      • Set spr_range[1] = 280.00
      • Set spr_range[2] = 280.00
      • Set spr_range[3] = 280.00
      • Set spr_range[4] = 280.00
      • -------- The travelling speed of the wave --------
      • Set spr_speed[1] = 20.00
      • Set spr_speed[2] = 20.00
      • Set spr_speed[3] = 20.00
      • Set spr_speed[4] = 20.00
      • -------- The repulsive force speed of the wave --------
      • Set spr_recoil_speed[1] = 9.00
      • Set spr_recoil_speed[2] = 12.00
      • Set spr_recoil_speed[3] = 15.00
      • Set spr_recoil_speed[4] = 18.00
      • -------- The time interval that the wave effect ocuuring --------
      • Set spr_Howl_Interval = 0.09
      • -------- Damage cause type --------
      • Set spr_attack_type = Chaos
      • -------- The model file of the wave effect --------
      • Set spr_effect_model[1] = Abilities\Spells\Other\HowlOfTerror\HowlCaster.mdl
      • -------- The attachent & model file of the damage caused effect --------
      • Set spr_attachment[2] = chest
      • Set spr_effect_model[2] = Abilities\Spells\Undead\DeathandDecay\DeathandDecayTarget.mdl
      • -------- The attachent & model file of the pushing effect --------
      • Set spr_attachment[3] = overhead
      • Set spr_effect_model[3] = Abilities\Weapons\DruidoftheTalonMissile\DruidoftheTalonMissile.mdl
      • -------- FOR PROS --------
      • Set spr_dummy_type = Universal Dummy
      • Set global_interval = 0.03
      • Trigger - Add to spr Loop <gen> the event (Time - Every global_interval seconds of game time)


  • spr Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to spr_ability
    • Actions
      • Set spr_maxIndex = (spr_maxIndex + 1)
      • Set spr_timer[spr_maxIndex] = spr_Howl_Interval
      • Set spr_caster[spr_maxIndex] = (Triggering unit)
      • Animation - Play spr_caster[spr_maxIndex]'s spr_caster_animation animation
      • Set spr_player[spr_maxIndex] = (Owner of spr_caster[spr_maxIndex])
      • Set spr_level[spr_maxIndex] = (Level of spr_ability for spr_caster[spr_maxIndex])
      • Set spr_start_point[spr_maxIndex] = (Position of spr_caster[spr_maxIndex])
      • Set spr_target_point[spr_maxIndex] = (Target point of ability being cast)
      • Set spr_angle[spr_maxIndex] = (Angle from spr_start_point[spr_maxIndex] to spr_target_point[spr_maxIndex])
      • Unit - Create 1 spr_dummy_type for spr_player[spr_maxIndex] at spr_start_point[spr_maxIndex] facing spr_angle[spr_maxIndex] degrees
      • Set spr_dummy[spr_maxIndex] = (Last created unit)
      • Animation - Change spr_dummy[spr_maxIndex]'s size to (spr_dummy_size[spr_level[spr_maxIndex]]%, 0.00%, 0.00%) of its original size
      • Custom script: call RemoveLocation(udg_spr_target_point[udg_spr_maxIndex])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • spr_maxIndex Equal to 1
        • Then - Actions
          • Trigger - Turn on spr Loop <gen>
        • Else - Actions


  • spr Loop
    • Events
    • Conditions
    • Actions
      • For each (Integer spr_loop) from 1 to spr_maxIndex, do (Actions)
        • Loop - Actions
          • Set spr_dummy_point[spr_loop] = (Position of spr_dummy[spr_loop])
          • Set spr_distance[spr_loop] = (Distance between spr_start_point[spr_loop] and spr_dummy_point[spr_loop])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • spr_distance[spr_loop] Greater than spr_max_distance[spr_level[spr_loop]]
            • Then - Actions
              • Special Effect - Create a special effect at spr_dummy_point[spr_loop] using spr_effect_model[1]
              • Special Effect - Destroy (Last created special effect)
              • Unit - Kill spr_dummy[spr_loop]
              • Unit Group - Remove all units from spr_finished_group[spr_loop]
              • Unit Group - Remove all units from spr_group[spr_loop]
              • Set spr_caster[spr_loop] = spr_caster[spr_maxIndex]
              • Set spr_caster[spr_maxIndex] = No unit
              • Set spr_player[spr_loop] = spr_player[spr_maxIndex]
              • Set spr_level[spr_loop] = spr_level[spr_maxIndex]
              • Set spr_start_point[spr_loop] = spr_start_point[spr_maxIndex]
              • Custom script: call RemoveLocation(udg_spr_start_point[udg_spr_maxIndex])
              • Set spr_target_point[spr_loop] = spr_target_point[spr_maxIndex]
              • Custom script: call RemoveLocation(udg_spr_target_point[udg_spr_maxIndex])
              • Set spr_angle[spr_loop] = spr_angle[spr_maxIndex]
              • Set spr_dummy[spr_loop] = spr_dummy[spr_maxIndex]
              • Set spr_dummy[spr_maxIndex] = No unit
              • Set spr_maxIndex = (spr_maxIndex - 1)
              • Set spr_loop = (spr_loop - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • spr_timer[spr_loop] Greater than 0.00
                • Then - Actions
                  • Set spr_timer[spr_loop] = (spr_timer[spr_loop] - global_interval)
                • Else - Actions
                  • Set spr_timer[spr_loop] = spr_Howl_Interval
                  • Special Effect - Create a special effect at spr_dummy_point[spr_loop] using spr_effect_model[1]
                  • Special Effect - Destroy (Last created special effect)
              • Custom script: call SetUnitX(udg_spr_dummy[udg_spr_loop],GetUnitX(udg_spr_dummy[udg_spr_loop]) + udg_spr_speed[udg_spr_level[udg_spr_loop]] * Cos(udg_spr_angle[udg_spr_loop] * bj_DEGTORAD))
              • Custom script: call SetUnitY(udg_spr_dummy[udg_spr_loop],GetUnitY(udg_spr_dummy[udg_spr_loop]) + udg_spr_speed[udg_spr_level[udg_spr_loop]] * Sin(udg_spr_angle[udg_spr_loop] * bj_DEGTORAD))
              • Set spr_group[spr_loop] = (Units within spr_range[spr_level[spr_loop]] of spr_dummy_point[spr_loop])
              • Unit Group - Pick every unit in spr_group[spr_loop] and do (Actions)
                • Loop - Actions
                  • Set spr_picked = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (spr_picked is A structure) Equal to spr_condition[1]
                      • (spr_picked belongs to an enemy of spr_player[spr_loop]) Equal to spr_condition[2]
                      • (spr_picked is alive) Equal to spr_condition[3]
                      • (spr_picked is in spr_finished_group[spr_loop]) Equal to spr_condition[4]
                    • Then - Actions
                      • Custom script: call DestroyEffect(AddSpecialEffectTarget(udg_spr_effect_model[2], udg_spr_picked,udg_spr_attachment[2]))
                      • Set spr_TestReal[spr_loop] = spr_damage[spr_level[spr_loop]]
                      • Unit - Cause spr_caster[spr_loop] to damage spr_picked, dealing spr_TestReal[spr_loop] damage of attack type spr_attack_type and damage type Normal
                      • Game - Display to (All players) the text: (String(spr_TestReal[spr_loop]))
                      • Unit Group - Add spr_picked to spr_finished_group[spr_loop]
                    • Else - Actions
              • Custom script: call DestroyGroup(udg_spr_group[udg_spr_loop])
              • Unit Group - Pick every unit in spr_finished_group[spr_loop] and do (Actions)
                • Loop - Actions
                  • Set spr_picked2 = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (spr_picked2 is in (Units within spr_range[spr_level[spr_loop]] of spr_dummy_point[spr_loop])) Equal to spr_condition[5]
                    • Then - Actions
                      • Set spr_picked2_point = (Position of spr_picked2)
                      • Set spr_angle_2[spr_loop] = (Angle from spr_dummy_point[spr_loop] to spr_picked2_point)
                      • Custom script: call RemoveLocation(udg_spr_picked2_point)
                      • Custom script: call SetUnitX(udg_spr_picked2,GetUnitX(udg_spr_picked2) + udg_spr_recoil_speed[udg_spr_level[udg_spr_loop]] * Cos(udg_spr_angle_2[udg_spr_loop] * bj_DEGTORAD))
                      • Custom script: call SetUnitY(udg_spr_picked2,GetUnitY(udg_spr_picked2) + udg_spr_recoil_speed[udg_spr_level[udg_spr_loop]] * Sin(udg_spr_angle_2[udg_spr_loop] * bj_DEGTORAD))
                      • Custom script: call DestroyEffect(AddSpecialEffectTarget(udg_spr_effect_model[3], udg_spr_picked2,udg_spr_attachment[3]))
                    • Else - Actions
                      • Unit Group - Remove spr_picked2 from spr_finished_group[spr_loop]
          • Custom script: call RemoveLocation(udg_spr_dummy_point[udg_spr_loop])



The map is in the attachment.
Please help me! :)
 

Attachments

  • Spiritual Disrupt.w3x
    27.9 KB · Views: 34
Level 29
Joined
Oct 24, 2012
Messages
6,543
Whenever you have to destroy something when de-indexing you have to destroy then set the current index to max index.
Example: You do it this way.
  • Set spr_start_point[spr_loop] = spr_start_point[spr_maxIndex]
  • Custom script: call RemoveLocation(udg_spr_start_point[udg_spr_maxIndex])
  • Set spr_target_point[spr_loop] = spr_target_point[spr_maxIndex]
  • Custom script: call RemoveLocation(udg_spr_target_point[udg_spr_maxIndex])
It needs to be this way.
  • Custom script: call RemoveLocation(udg_spr_start_point[udg_spr_loop])
  • Set spr_start_point[spr_loop] = spr_start_point[spr_maxIndex]
  • Custom script: call RemoveLocation(udg_spr_target_point[udg_spr_loop])
  • Set spr_target_point[spr_loop] = spr_target_point[spr_maxIndex]
The reason it needs to be done this way is that variables are pointers. They only point to objects in memory. They do not store those objects.
That being said here is what was happening the way you were doing things.

spr_start_point[ index] = spr_start_point[ maxIndex]
The above you overwrite the variable on were it points to. Both variables now point to the same object in memory.
Custom script: call RemoveLocation(udg_spr_start_point[udg_spr_maxIndex])
Now you removed it. Problem is that you removed the one at maxindex since maxindex still points to the object in memory.
Also you lost the location that used to be at spr_loop index creating a leak.

Also after de-indexing you should check to see if the trigger should be turned off.
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • spr_maxIndex Less than 1
    • Then - Actions
      • Trigger - Turn off spr Loop <gen>
    • Else - Actions
 
  • Like
Reactions: BUP
Status
Not open for further replies.
Top