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 The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/
  • The Helper The Helper:
    I think we need to add something to the bottom of the front page that shows the Headline News forum that has a link to go to the News Forum Index so people can see there is more news. Do you guys see what I am saying, lets say you read all the articles on the front page and you get to the end and it just ends, no kind of link for MOAR!
  • The Helper The Helper:
    Happy Wednesday!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    Sticking with the desserts for now the latest recipe is Fried Apple Pies - https://www.thehelper.net/threads/recipe-fried-apple-pies.194297/
  • The Helper The Helper:
    Finally finding about some of the bots that are flooding the users online - bytespider apparently is a huge offender here - ignores robots.txt and comes in from a ton of different IPs

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top