• 🏆 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] [ Trigger Problem ] Does not decrease spell instances

Status
Not open for further replies.
Level 20
Joined
Aug 13, 2013
Messages
1,696
Here: It is now working but it doesn't decrease the instances.. if the instances is not decreased or reduced then the loop trigger will turn on everytime :///. Need help I don't need if you find leaks because this will not be submitted in the spell section I just want to know why it does not decrease the instances.. I'll gonna show the triggers and Debug Msgs to the game screen..

  • Function Loop
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Temp_Ability
    • Actions
      • Unit - Create 1 Temp_DummyType for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Set Temp_Dummy = (Last created unit)
      • Set UI_UDexID = (Custom value of Temp_Dummy)
      • -------- Debug Ball TIme --------
      • Unit - Add a 10.00 second Generic expiration timer to Temp_Dummy
      • Set UI_Target[UI_UDexID] = (Target unit of ability being cast)
      • Set Temp_Point2 = (Position of UI_Target[UI_UDexID])
      • Set UI_Caster[UI_UDexID] = (Triggering unit)
      • Set Temp_Point = (Position of UI_Caster[UI_UDexID])
      • Set UI_Angle[UI_UDexID] = (Angle from Temp_Point to Temp_Point2)
      • Set UI_Timer[UI_UDexID] = 3.00
      • -------- Missile --------
      • Set UI_Stage[UI_UDexID] = 1
      • Set UI_Instance = (UI_Instance + 1)
      • Custom script: call BJDebugMsg("Instances : " + I2S(udg_UI_Instance))
      • Unit Group - Add Temp_Dummy to Temp_Group
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • UI_Instance Equal to 1
        • Then - Actions
          • Trigger - Turn on Function Periodic Loop <gen>
        • Else - Actions
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Custom script: call RemoveLocation(udg_Temp_Point2)

  • Function Periodic Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Temp_Group and do (Actions)
        • Loop - Actions
          • Set Temp_Dummy = (Picked unit)
          • Set UI_UDexID = (Custom value of Temp_Dummy)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UI_Stage[UI_UDexID] Equal to 1
            • Then - Actions
              • Set Temp_Point3 = (Position of Temp_Dummy)
              • Unit - Move Temp_Dummy instantly to (Temp_Point3 offset by 15.00 towards UI_Angle[UI_UDexID] degrees)
              • Set Temp_Point2 = (Position of UI_Target[UI_UDexID])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Distance between Temp_Point3 and Temp_Point2) Less than or equal to 75.00
                • Then - Actions
                  • Set UI_Stage[UI_UDexID] = 2
                • Else - Actions
              • Custom script: call RemoveLocation(udg_Temp_Point3)
              • Custom script: call RemoveLocation(udg_Temp_Point2)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • UI_Stage[UI_UDexID] Equal to 2
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • UI_Timer[UI_UDexID] Greater than 0.00
                • Then - Actions
                  • Unit - Kill Temp_Dummy
                  • Set Temp_Point2 = (Position of UI_Target[UI_UDexID])
                  • Unit - Move UI_Target[UI_UDexID] instantly to (Temp_Point2 offset by 10.00 towards UI_Angle[UI_UDexID] degrees)
                  • Set UI_Timer[UI_UDexID] = (UI_Timer[UI_UDexID] - 0.03)
                • Else - Actions
                  • Set UI_Instance = (UI_Instance - 1)
                  • Unit Group - Remove Temp_Dummy from Temp_Group
                  • Custom script: call BJDebugMsg("Instances : " + I2S(udg_UI_Instance))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • UI_Instance Equal to 0
                    • Then - Actions
                      • Custom script: call BJDebugMsg("Removed")
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
              • Custom script: call RemoveLocation(udg_Temp_Point2)
            • Else - Actions
Here is the debug msg the show me... It doesn't decrease the instances by 1 :/. It is just showing me the number of instances used... That's why the trigger is now turn off when the spell cast is end. Anyway In this trigger I want the missile to be moved in the targeted unit and checks their distances. If the targeted unit and missile unit are in the 75 range the missile unit will destroy and the targeted unit will be knockbacked in 3 seconds then I'll reduce the isntances by 1 if the timer is less than or equal to 0.00 . As you see I reduce the timer by 0.03.

Here is the instances showed in the screen that's why there's a problem with my trigger. Anyway I need a real answer.
231860-albums6686-picture73901.png


If you see this way of Indexing unknown then I'm using Unit Indexer.
 
Last edited:
Level 22
Joined
Sep 24, 2005
Messages
4,821
Did you initialize the custom value of the unit in another trigger? You didn't do it on the spell cast event.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
  • Set UI_UDexID = (Custom value of Temp_Dummy)
I think you're using it as an index right? I'm asking if the Dummy already has a custom value set, but it appears it doesn't(from looking at those triggers you posted).
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
In the Function Loop Trigger, after creating the dummy.
  • Set Temp_Dummy = (Last created unit)
  • -------- set Temp_Dummy custom value --------
My guess:
  • custom value = UI_Instance
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
In the Function Loop Trigger, after creating the dummy.
  • Set Temp_Dummy = (Last created unit)
  • -------- set Temp_Dummy custom value --------
My guess:
  • custom value = UI_Instance


Actually I'm using Unit Indexer..

Check your picture :D, i can't see

Maybe it's you ^^. Anyway If you doesn't see the picture here is the game screen
In the first cast It shows the screen: " Instances : 1 "
In the 2nd cast It shows the screen: " Instances : 2 "
In the 3rd cast It shows the screen: " Instances : 3 "
When The hurl boulder hits the targeted enemy it must be decrease the index by 1 in that reason I saw that it didn't reduce the index by 1 it is looks like it is continuing the instances and does not turn off the trigger :/.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Oh, you should have told that in the first place.
EDIT: Are you sure the dummy_unit is being indexed properly, try putting a debug message that shows the index of the unit before setting the UI_UDexID.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
chobibo said:
Are you sure the dummy_unit is being indexed properly, try putting a debug message that shows the index of the unit before setting the UI_UDexID.
Try debugging that.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
  • UI_Timer[UI_UDexID] Greater than 0.00
Shouldn't this be Less than or Equal?

Nope, I was wrong. post the map that would be easier to debug.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
@ nhocklanox

Anyway I'm using Unit Indexer ^^. Bribe said I need to store it to a variable. That instance is the active instances of the spell, I'm using that to turn off and turn on the looping triggers.

@chobibo

Anyway I think I found the problem about their unique ID's. I try debugging them and shows me a message... In the first cast the unique Id of the dummy is "84" 83 ID's is the units in the map. When the spell end it is does not shows the "84" sign then I know now the problem... I remember this in the system.. " When the unit is decayed/removed it is now removed their ID's" So I'm thinking when I KILL the dummy It will cause to disfunction the stage 2 and stage 3 because the ID of the Unit is now removed that causes when I kill the unit...

And now I change the trigger.. I set the kill unit in the stage 3 ( this stage removes and decreases instances) not anymore in the stage 2. When I set that It is working now properly it is decreases now the instances of the spell and turning off the trigger because of that I have another problem about the unit... How I'll kill the unit when It reaches the distance of them? because when I kill the unit it will cause a non-index.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Uploading speed? you must mean downloading speed...
Anyways, I've suggested adding a timed life for the dummy because you said it breaks the de-allocation when killing the unit instantly.

EDIT: The only pictures that doesn't load are yours, I tried browsing the off-topic section, the photos load just fine.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
Uploading speed? you must mean downloading speed...
Anyways, I've suggested adding a timed life for the dummy because you said it breaks the de-allocation when killing the unit instantly.

EDIT: The only pictures that doesn't load are yours, I tried browsing the off-topic section, the photos load just fine.

In adding timed life it is not working too. Anyway, Thanks for your help, I think I'll use hashtable.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
It seems that the recycling code is unreachable, I tried fixing it but I can't seem to reconstruct the code flow, could you explain the stages of the periodic loop trigger. I've created a trigger that successfully reaches the recycling code, but only copied the original stage 1 actions (since I was unable to understand the flow) on it, I've uploaded your test map with my edits.

View attachment Test GUI Functions.w3x
 
jakeZinc
Your Screenshots isn't showing at all.
according to information I have, I believe you set your albums privacy to private (the one where you can choose wether an album is public, private or profile).

I believe the UI Instance is somehow messed up (never decrease), since it is the code recycler, I believe that's the issue.
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
Take "Set UI_Stage[UI_UDexID] = 3" out of that if/else block and put it right after the end of the "if" block (directly above "Custom script: call RemoveLocation(udg_Temp_Point2)")

I made that change and it fixed the issue.

Keep in mind, even with this change, that when your missile reaches the edge of the map, it will stay active forever and you will never reach 0. If you are precise and manage to hit your target every time, it will reach 0 when it's supposed to.
 
Level 20
Joined
Aug 13, 2013
Messages
1,696
Take "Set UI_Stage[UI_UDexID] = 3" out of that if/else block and put it right after the end of the "if" block (directly above "Custom script: call RemoveLocation(udg_Temp_Point2)")

I made that change and it fixed the issue.

Keep in mind, even with this change, that when your missile reaches the edge of the map, it will stay active forever and you will never reach 0. If you are precise and manage to hit your target every time, it will reach 0 when it's supposed to.


Thanks Bribe :). +Rep for all of your help. +Rep too, for all that help me.
 
Status
Not open for further replies.
Top