Why is It not Remove the Unit from the Group?

Squeekems

TH.net Regular
Reaction score
11
I want to add a simple push-back for Fan of Knives. I add the units that get hit to a unit group called "Slammed_Units." Units in this group will be picked in another trigger that automatically moves them in a certain direction (depending on their custom value)
every .04 seconds. I thought this would work perfect, but it seems that the units are not being pulled from the group.

Apologies for the long post.

Code:
Fan of Knives
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Fan of Knives 
    Actions
        Set AoE_of_Ability = 200.00
        Set Temp_Point = (Position of (Casting unit))
        Set Temp_Group = (Units within AoE_of_Ability of Temp_Point matching (((Matching unit) Not equal to (Triggering unit)) and ((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) is Mechanical) Equal to False) and ((((Matching unit) is A structure) Equal to
        Unit Group - Pick every unit in Temp_Group and do (Actions)
            Loop - Actions
                Set Temp_Point2 = (Position of (Picked unit))
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (X of Temp_Point2) Less than (X of Temp_Point)
                                (Y of Temp_Point2) Greater than (Y of Temp_Point)
                    Then - Actions
                        Unit - Set the custom value of (Picked unit) to 0
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (X of Temp_Point2) Equal to (X of Temp_Point)
                                (Y of Temp_Point2) Greater than (Y of Temp_Point)
                    Then - Actions
                        Unit - Set the custom value of (Picked unit) to 1
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (X of Temp_Point2) Greater than (X of Temp_Point)
                                (Y of Temp_Point2) Greater than (Y of Temp_Point)
                    Then - Actions
                        Unit - Set the custom value of (Picked unit) to 2
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (X of Temp_Point2) Greater than (X of Temp_Point)
                                (Y of Temp_Point2) Equal to (Y of Temp_Point)
                    Then - Actions
                        Unit - Set the custom value of (Picked unit) to 3
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (X of Temp_Point2) Greater than (X of Temp_Point)
                                (Y of Temp_Point2) Less than (Y of Temp_Point)
                    Then - Actions
                        Unit - Set the custom value of (Picked unit) to 4
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (X of Temp_Point2) Equal to (X of Temp_Point)
                                (Y of Temp_Point2) Less than (Y of Temp_Point)
                    Then - Actions
                        Unit - Set the custom value of (Picked unit) to 5
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (X of Temp_Point2) Less than (X of Temp_Point)
                                (Y of Temp_Point2) Less than (Y of Temp_Point)
                    Then - Actions
                        Unit - Set the custom value of (Picked unit) to 6
                    Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                (X of Temp_Point2) Less than (X of Temp_Point)
                                (Y of Temp_Point2) Equal to (Y of Temp_Point)
                    Then - Actions
                        Unit - Set the custom value of (Picked unit) to 7
                    Else - Actions
                Custom script:   call RemoveLocation(udg_Temp_Point2)
                Unit Group - Add (Picked unit) to Slammed_Units
        Wait 0.40 seconds
        Unit Group - Pick every unit in Temp_Group and do (Actions)
            Loop - Actions
                Unit Group - Remove (Picked unit) from Slammed_Units
        Custom script:   call DestroyGroup(udg_Temp_Group)
        Custom script:   call RemoveLocation(udg_Temp_Point)
 

canons200

New Member
Reaction score
50
use the action game display message to assist you to know which part of trigger is working and not working.
 

viktorpapa

New Member
Reaction score
2
This is a very bad implemetation of the push back effect, the lots of if condition nested in eachother isn't healthy... Not to mention this could not be very accurate. this is my implementation:


Code:
Push Back
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to whateverability
    Actions
        Set x1 = (X of (Position of (Triggering unit)))
        Set y1 = (Y of (Position of (Triggering unit)))
        Unit Group - Pick every unit in (Units within 312.00 of (Position of (Triggering unit))) and do (Actions)
            Loop - Actions
                Set x2 = (X of (Position of (Picked unit)))
                Set y2 = (Y of (Position of (Picked unit)))
                Set rise = ((y2 - y1) / (x2 - x1))
                Set rise = (Atan(rise))
                Set modifier = ((((Sign(((Abs(x2)) - (Abs(x1))))) / 2.00) + 0.50) x 180.00)
                Set modifier = ((modifier + 180.00) + (90.00 x (1.00 + (Sign(x1)))))
                Set angle = (modifier + rise)
                Unit - Set the custom value of (Picked unit) to (Integer(angle))


Hashtables would be better then custom value, but what ever...
Anyways, this function sets the picked units custom value to a facing degree which u can use like this in other triggers:
Code:
Unit - Move (Picked unit) instantly to ((Position of (Triggering unit)) offset by distance towards (Real((Custom value of (Picked unit)))) degrees)
 

Squeekems

TH.net Regular
Reaction score
11
I appreciate the code. Some of it is a little over my head, but I'll understand it with implementation (I think). I suck at trigonometry. :p

I haven't used hashtables before. I understand their usefulness, I just never learned how to implement them.

I'm glad you could tell that my push-back trigger also was a cluster-fuck of if-statements. Lol.

If this all works(If I implement it correctly), I bet the unit group problem will be solved.

EDIT: This actually has not solved the problem, lol. Though, it does make for much more fluent triggering. Here's the new code:

Code:
Fan of Knives
    Events
        Unit - A unit Begins casting an ability
    Conditions
        (Ability being cast) Equal to Fan of Knives 
    Actions
        Set AoE_of_Ability = 200.00
        Set Temp_Point = (Position of (Casting unit))
        Set Temp_Group = (Units within AoE_of_Ability of Temp_Point matching (((Matching unit) Not equal to (Triggering unit)) and ((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) is Mechanical) Equal to False) and ((((Matching unit) is A structure) Equal to
        Unit Group - Pick every unit in Temp_Group and do (Actions)
            Loop - Actions
                Set Temp_Point2 = (Position of (Picked unit))
                Set Rise = (((Y of Temp_Point2) - (Y of Temp_Point)) / ((X of Temp_Point2) - (X of Temp_Point)))
                Set Rise = (Atan(Rise))
                Set Modifier = ((((Sign(((Abs((X of Temp_Point2))) - (Abs((X of Temp_Point)))))) / 2.00) + 0.50) x 180.00)
                Set Modifier = ((Modifier + 180.00) + (90.00 x (1.00 + (Sign((X of Temp_Point))))))
                Set Angle = (Modifier + Rise)
                Unit - Set the custom value of (Picked unit) to (Integer(Angle))
                Custom script:   call RemoveLocation(udg_Temp_Point2)
                Unit Group - Add (Picked unit) to Slammed_Units
        Wait 0.40 seconds
        Unit Group - Pick every unit in Temp_Group and do (Actions)
            Loop - Actions
                Unit Group - Remove (Picked unit) from Slammed_Units
        Custom script:   call DestroyGroup(udg_Temp_Group)
        Custom script:   call RemoveLocation(udg_Temp_Point)

Here's the Pushback Trigger if it matters:
Code:
Pushback
    Events
        Time - Every 0.04 seconds of game time
    Conditions
    Actions
        Unit Group - Pick every unit in Slammed_Units and do (Actions)
            Loop - Actions
                Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 10.00 towards (Real((Custom value of (Picked unit)))) degrees)

use the action game display message to assist you to know which part of trigger is working and not working.

I did this figure out that it was that units were not being removed from the unit group (Slammed_Units). I here because I don't understand why this is happening.
 

viktorpapa

New Member
Reaction score
2
the problem is waits mess up all triggers, during 0,4 seconds all your variabbles can change, and they porbably are changed. For example i guess after 0,4 seconds your (Temp_Group) variable is not what it used to be. You picked up units from Temp_Group but who knows which units are in temp group after 0,4 seconds? Solution = use local variables.
 

canons200

New Member
Reaction score
50
do you need to make it GUI MUI, if so it is sure not working due to the presentation of "wait" in your trigger.

Just search around this forum, there is a GUI base knock system, just implentment it
 

viktorpapa

New Member
Reaction score
2
no, actually its very easy to make this pushback MUI, just implement the sliding in the same trigger instead of a periodic time event in another trigger.
i mean put this to the end of your push back trigger:

Code:
 For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
                Wait 0.10 seconds
                Unit Group - Pick every unit in (unitgroup) and do Unit - Move (Picked unit) instantly to ((Position of (Picked unit)) offset by 10.00 towards (Real((Custom value of (Picked unit)))) degrees)
 

Squeekems

TH.net Regular
Reaction score
11
Hey guys, thanks for the responses. I'm going to have to agree with you on the Temp_ Group changing. I'll try creating a local variable as you say and see if that works the next time I work on the map. I'm taking another break from editing maps unfortunately.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top