• 0

    posted a message on turn turret using trigger

    @avogatro: Go

    Straight up bump. I've been using the same method of dummy units and dummy weapons to simulate this effect. It's really not ideal.

    Posted in: Triggers
  • 0

    posted a message on 12 player Traceline and Terrain Collision. CPU friendly

    @EdwardSolomon: Go

    Optimizing the traceline for performance. Notice that each time the loop runs we calculate sin(-b) and Abs[cos(b)]. Since these values are constant we can calculate them one time at the start of the trigger in the variables section. Make two real variables Q and R then:

    Q = Abs[cos(B)] R = sin(-b)

    Now replace those expressions with their variables in the loop trigger. Pick each integer from 1 to M and do the actions: Set K picked integer Set C to P offset by K*Qtowards A degrees. Set H = K*R + constant Set S = CircleRegion(X of C, Y of X, radius = 1.25) Set U = units in region S Pick every unit in U and do actions If U is not equal to "Empty Unit Group" and Picked Unit is not equal to "No Unit" and Picked unit is in group FORBID equal to false and Height of Picked Unit is less than or equal to H + 1.25 and Height of Picked Unit is greter than or equal to H -1.25 then set Tracetarget = Picked Unit and Break Loop else if K = M, then set Tracetarget = "No unit" , else do nothing

    Now our trigger doesn't have to run these calucations for each execution of the loop, saving memory. Also rename all your variables to 1 letter names, as this also saves memory. Always try to optimize memory on a trigger of this magnitude. Remember that it will run at least 4 times a second (mine is set to 8 times a second) and will often complete all 50 loops per execution when there is not target. This can be a whopping 400 loops a second overall, thus reducing everything to one letter, including the name of the trigger itself, frees a lot of memory.

    EDIT: In order to synchronize the Traceline and Collision (and other related triggers), I added an independent trigger called CVR for Continuous Variable Reset. This trigger executes every 0.125 seconds (or 8 times a second) in which it updates the values of 11 different arrays of size 12. The camera Yaw and Camera Pitch of each player is an example, as well as the positions and absolute height of the observers and their current Traceline Target.

    Now the Traceline triggers and Collision triggers take the non-local data from the CVR instead of calculating it themselves, this alone attributed to a 0.5 - 1 degrees (Fahrenheit) drop in CPU temperature under the same test conditions and external environment (with all 12 tracelines and collisions running simultaneously, I simply executed it for Player 1 twelve times to test it).

    EDIT 2: Both the Traceline and the Collision triggers are executed when the player clicks either mouse 1 or mouse 2 to shoot their weapon, and it cannot be activated again for another 0.25 seconds (or 1/4 of a quarter). However your gun will continuing firing at a target in between this quarter second period, so there is no delay between shots. This attributed to substantial 2-3 degree cooldown in CPU under same conditions and nearly a 5-6 degrees cooldown with all 12 running. Overall we knocked about 7 degrees off of a quad-core 3.2 GZ processor with L3 cache (my processor).

    EDIT 3: Upon lifting Mouse 1 or Mouse 2, the observer unit is automatically ordered to stop attacking, this trigger does not have a cooldown. So your gun will stop firing at the tracetarget even if it within the 1/4 second timeframe. Did not effect temperatures, but made it aesthetically pleasing.

    Posted in: Triggers
  • 0

    posted a message on 12 player Traceline and Terrain Collision. CPU friendly

    @EdwardSolomon: Go

    Making a 3-D traceline. First we will start with a 2-D traceline. In order to make a 2-D traceline we need three pieces of information. The position of the observer, the Yaw of his camera and the Maximum Distance of his gun.

    Let P = Position of the Observer Let A = Yaw of Camera Let M = Max Distance and M must be an integer.

    Now we run a loop a M times. This loop will create M temporary points in the direction of the Yaw starting at P and ending at a distance of M from P. Let C be the temp point.

    Pick each integer from 1 to M and do the actions: Set K picked integer Set C to P offset by K towards A degrees.

    Now that we have created our temp points, we now need to create a circular region centered at the temp point with a radius of 1.25, and thus a diameter of 2.5. Remember that each adjacent temp point is a distance of 1 apart, such that each temp region overlaps the previous region and the one before it. The reason for this (and why we choose circular regions instead of rectangular regions) is given in Appendix A at the end of the post.

    So we add this to our loop, let S be the temp Region:

    Pick each integer from 1 to M and do the actions: Set K picked integer Set C to P offset by K towards A degrees. Set S = CircleRegion(C, radius = 1.25)

    Now we must check each consecutive region for units. We will create a temp unit group named U, we will introduce another Global unit group called FORBID which is a unit group consisting of units that we do want our traceline to detect (for instance we do not want our observer to target himself) and a Global Unit named Tracetarget.

    Pick each integer from 1 to M and do the actions: Set K picked integer Set C to P offset by K towards A degrees. Set S = CircleRegion(X of C, Y of X, radius = 1.25) Set U = units in region S Pick every unit in U and do actions If U is not equal to "Empty Unit Group" and Picked Unit is not equal to "No Unit" and Picked unit is in group FORBID equal to false Angle between P and Picked unit <= 10 degrees then set Tracetarget = Picked Unit and Break Loop else if K = M, then set Tracetarget = "No unit" , else do nothing

    Our nested conditional on the Else statement makes it so that if our traceline has not detected a unit in the final loop, its sets the Global Tracetarget to No Unit, instead of leaving it as the previously detected unit.

    So here we have a fully functioning 2-D traceline. With some modifications we can easily convert this to a 3-D traceline.

    In Starcraft 2, the above traceline trigger could cause you to shoot a target high in the air that you cannot see, because its X and Y coordinate happen to be contained inside of the temp regions during the traceline check. In effect Starcraft 2 turns our circular regions into 3-D cylinders of infinite height above and below the observer. What we need to do is modify the trigger to check unit heights in accordance to the Pitch of our camera. To accomplish this, we need only some intuition and knowledge of the sine and cosine trigonometric functions.

    Let B = Pitch of Camera.

    We must remember that we are now tracing a 3-D line that extends in the direction of the polar coordinates (A , B). The length of this line remains the same as the pitch changes, namely the length of this line remains M. However we must realize that we are dealing with a right triangle now.

    The hypotenuse of this triangle is the traceline itself. The main leg of the triangle is on the X-Y plane, this leg extends a distance of cos(B) towards angle A from the point P on the X-Y plane. Call the endpoint of this leg F. The other leg extends a distance of sin(B) at 90 degrees upwards from F. The endpoint of this leg is the edge of our hypotenuse.

    So what do we know? cos(b)^2 + sin(b)^2 = M, which tells us that

    Length of first leg = cos(b) Length of second leg = sin(b)

    The first leg is on the X-Y plane and points in the direction of angle A. The second leg (if we ignore the Yaw of the camera) in on the X-Z plane.

    With this information we can modify our trigger that calculates the temp point C in the X-Y plane by scaling the line by cos(b). We will make it read the absolute value of cos(b) so that we don't result with negative distances.

    Pick each integer from 1 to M and do the actions: Set K picked integer Set C to P offset by K*[Abs(cos(B)] towards A degrees.

    We also want to read the height of this X-Y point when projected onto the hypotenuse. We know that similar triangles are proportional, so we can calculate the height of the projected point simply by the loop number and sin(b). Let H be a real variable that will be set to the height of the projected point.

    Pick each integer from 1 to M and do the actions: Set K picked integer Set C to P offset by K*[Abs(cos(B)] towards A degrees. Set H = sin(-b) + constant

    Notice that we are calculated the sine of negative b instead of positive b. This is because some douche at Blizzard Entertainment decided to make the pitch = -90 when looking at the zenith and +90 when looking straight at the ground, instead of the other way around. If we do not change this to negative b in the sine argument, then we will be projecting a hypotenuse that is reflected over the X-Y plane from what we had originally intended.

    We also added a constant here. The constant is the actual height of the observer. This is so that if our observer is in an aerial craft above the ground, our heights on the projected hypotenuse will all be adjusted in a uniform manner.

    Ok, we're almost done! We now need to do one more thing. As of now, our cylinders still have an infinite height above and below the observer. We need to put bounds on these cylinders according the the Pitch of the Camera. The bounds of the cylinders will be within 1.25 units of the height of the temp point along the hypotenuse.

    So now we add this to our loop.

    Pick each integer from 1 to M and do the actions: Set K picked integer Set C to P offset by K*[Abs(cos(B)] towards A degrees. Set H = K*sin(-b) + constant Set S = CircleRegion(X of C, Y of X, radius = 1.25) Set U = units in region S Pick every unit in U and do actions If U is not equal to "Empty Unit Group" and Picked Unit is not equal to "No Unit" and Picked unit is in group FORBID equal to false and Height of Picked Unit is less than or equal to H + 1.25 and Height of Picked Unit is greter than or equal to H -1.25 then set Tracetarget = Picked Unit and Break Loop else if K = M, then set Tracetarget = "No unit" , else do nothing

    What is happening here is that any unit whose height is not within the bounds H - 1 to H + 1 within the temp region, is being rejected in the traceline detection, thus we have a fully functioning 3-D traceline that uses uniformly overlapping cylinders as its detection method.

    Appendix A The reason that circular regions are chosen instead of rectangular regions, is because rectangular regions cannot be rotated to correspond to the Yaw. Rectangular regions in Starcraft 2 have their sides parallel to the x and y axes of the map. This means that the overlapping of rectangular regions at different Yaws produce different overlap patterns, thus a mitigating factor would have to be added to increase the area of each region according to its Yaw. This would have to be handled with the Tan and Cotan functions and modular arithmetic in modulus 45. Also, even when dealt with, it still does not produce uniform overlapping patterns, but simply negates traceline failures, at the expense of creating traceline false positives at the Yaws near 45, 135, 225 and 315 degrees.

    Circular regions on the other hand have the advantage of creating uniform overlap patterns at any Yaw values, thus the traceline failure rate and false positive rate can be controlled by simply changing the radius of our circles (assuming our observer knows how to aim) and are uniform in all directions. The amount of overlap is determined by the radius. A larger radius creates more overlap, preventing traceline errors, but a radius that is too large (take 100 units for example) would produce false positives, and the gun would shoot things that you do not appear to be aiming at.

    EDIT: False positives can be negated completely by setting a limit to the difference between the angles "Yaw of camera" and "angle from P to picked unit." Set this limit to something that is appropriate to your camera's field of view.

    Also the arcsine of the Distance between P and picked unit/(Absolute height of picked unit - Absolute height of observer) returns the 3-D angle between P and picked unit. I also set this difference limit to 10. Remember that this is compared to the player camera's pitch.

    Posted in: Triggers
  • 0

    posted a message on 12 player Traceline and Terrain Collision. CPU friendly

    Commands: Backspace = Enters FPS mode

    Mouse 1 = Fire gattling guns at target (can hit air units)

    Mouse 2 = Fire tank projectile at target (can only hit ground)

    5 = leave FPS mode

    Important variables if you change the camera position.

    The observer unit (siege tank in my map) will have it's position and absolute height (ground height/air height + height of unit + camera Z offset above unit) adjusted every 0.0 seconds in a separate trigger from the traceline.

    When you change position of your observer in the X or Y or both directions, the trigger will automatically handle it for you. However If you decided to change the height of the observer unit you need to change the camera Z offset by the same amount.

    For instance G is currently set to 1.5 and the height of the siege tank is at 3. This means our observer sees himself 4.5 above the ground and 1.5 above the siege tank. If we change the siege tank back to ground height (or zero height above the ground) then we set our camera Z offset to 1.5 in our camera trigger, which is precisely the value of G. The value of G itself remains unchanged.

    Posted in: Triggers
  • 0

    posted a message on Patch 1.2 Changes

    @EdwardSolomon: Go

    It is supposed to be a "behavior" and I am wondering if this removes the "rocking" that terran air units do while standing.

    Posted in: General Chat
  • 0

    posted a message on Patch 1.2 Changes

    @Algirdyz: Go

    Does anyone know where the option is to "Suppress Fidgeting"

    Posted in: General Chat
  • 0

    posted a message on Weekly Trigger Exercise #2: Many Bodies, One Mind
    Quote from tFighterPilot: Go

    @EdwardSolomon: Go

    It's not a bug, you just didn't make any trigger that will cause them to stay in formation.

    Oh I haven't uploaded that version, still working on it. I'm aiming for memory efficiency

    Posted in: Triggers
  • 0

    posted a message on Weekly Trigger Exercise #2: Many Bodies, One Mind
    Quote from tFighterPilot: Go

    @EdwardSolomon: Go

    It doesn't work. They go in formation when I give the command, but when I move them they all just go to the same spot.

    That's interesting, there must be a bug. One moment

    Posted in: Triggers
  • 0

    posted a message on Weekly Trigger Exercise #2: Many Bodies, One Mind

    @Twinmold20: Go

    Here is a BETA version of what I currently have:

    There are two different types of Formation Groups. Ground Formations and Air Formations.

    Select as many marines as you want and type: -form

    This command will organize them into the nearest perfect square (rounded up).

    Select as many phoenix as you want and type -formair

    This command will organize them into the nearest perfect cube (rounded up).

    Make sure that you put selected units into a control group first. After they complete their formation, go ahead and move them (move the entire control group). You will see that they stay in formation.

    What I have completed by tomorrow: Command Card for leader will be updated to allow different formation shapes (2-D and 3-D). Units will ALWAYS move in formation and ATTACK in formation. Single Health bar will be added for formation.

    Other notes - Kill the leader unit to kill the entire formation. Type -disband while selecting the leader to disband the formation. Either of these will free up a Formation Group slot. You can have up to 8 formation groups at a time (to make more you must disband or kill them).

    You can have up to 3 aerial formations at any time (type disband or kill their leader to free up aerial group slots).

    AND MUCH MUCH MORE!

    Posted in: Triggers
  • 0

    posted a message on Creating a "Group of Integers"

    @s3rius: Go

    Yes thank you for the advice, this concept carries well into many other ideas as well. Thank you

    Posted in: Triggers
  • 0

    posted a message on Creating a "Group of Integers"
    Quote from tFighterPilot: Go

    @EdwardSolomon: Go

    It's pretty simple to implement them. There are many different ways to implement sets, which is best depends on your usage.

    Here is my usage:

    I need to limit the amount of Unit Groups that can exist on my map for a trigger that creates formations. The Unit Group Array is set to 300, thus I cannot have more than 300 formations on the map at any time. However, I want it to be possible to disband formations and destroy formations if the leader unit dies. Thus I need to be able to reuse a Formation Group index without overwriting it.

    So let's say I want to create a formation of units. The Trigger fires, the first thing it does is look for the first Empty Unit Group within my 300 unit group array. This means the loop needs to be executed up to a maximum of 300 times. After it finds the first index that is empty, it creates the group. This is how the function currently works. It is however, very inefficient, not to mention that the loop Array is not 300, but only 24 in size, as 300 to is too large a number for such a frequent trigger.

    What I would like to do instead: Start with some set A with the integers {1 , 2, 3, 4, 5 . . . 300} and a second set of integers B that is initially empty, so B = { } or null

    Now when we create the first formation is picks a random number n from A and the variable UNITGROUP[n] becomes the formation group. We then remove n from A and add n to B. Now A = {1, 2, 3 . . . 300} - {n} and B = {n}

    Now when I go to make my second formation group it picks a random number from A, but now n cannot be picked. Call this m, now A = {1, 2, 3...300} - {n} and B = {n, m}

    Now if the group is disbanded or the leader dies, I want to place that index back into A and remove it to B. Say the first group dies, then we put n back inside A and remove n from B.

    If A becomes empty and some player tries to form a new group, a message will be displayed that says "Too many formation groups, please disband some formations."

    Posted in: Triggers
  • 0

    posted a message on Creating a "Group of Integers"
    Quote from shardfenix: Go

    @EdwardSolomon: Go

    You can code your own sets with Galaxy. There is no built-in functionality for what you want.

    I've been looking for these functionality. Can you give me a small tutorial of how to create the following integer set, and how to use it in this following example?

    Create set A = {1 , 4, 9, 17, 29}, Create set B = {-5, 17, 4}, Create set C as the disjunction between sets A and B, C = {1, 9, 29, -5}

    Reset set A to set C, set A = {1, 9, 29, -5}, Set integerX to a random element of set A

    Posted in: Triggers
  • 0

    posted a message on Weekly Trigger Exercise #2: Many Bodies, One Mind

    @Doomsaloto: Go

    All right, here is how my system will work once released:

    Infinitely many Squads -> Squad will exist and perform actions under a "While" loop as long as the leader unit is alive.

    Four ground formations and four 3-D aerial formations -> Ground: Square, Rectangle, Circle, Wedge (wide) / Air: Cube, Rect Prism, Sphere, Cone (Wide)

    Designed so that any size formation can be handled that contains less than 225 units (the square of 15)

    Leader Unit is easy to see and is the last to die. Health bars are shared as in previous examples on this thread. Command Card has several commands to control formations. First you have the four shapes, you can control the "spread" of the units with two other commands, and the ability to amke them all "hold fire."

    A low memory alternative was found to make it so that once units are in formation, they will continue to move in formation. Only when creating the group will the units seem to move random until the first formation is complete.

    Only remaining hurdle: Collision, therefore collision is turned off for all units that I've been using.

    Posted in: Triggers
  • 0

    posted a message on Creating a "Group of Integers"

    @tFighterPilot: Go

    This doesn't work because I want to select a random value from these arrays. Not to mention that the size of an array is fixed. If I want to remove a value from the array such that it cannot be picked, but retain the ability to add it back later, how would I go about that?

    EDIT: Here is why I cannot use arrays.

    Pick a Random Number from set {1, 6, 18, -23, 5, 2, -14}

    vs

    Set Integer A = Random Number between 1 and 7, set Integer B = IntegerArray[A]

    Already this takes two steps instead of one. Now take a more complicated scenario.

    Subtract the set B {0, 4, 18, -14, 9) from set A {1, 6, 18, -23, 5, 2, -14} and set Set A to the result. Result Set A = { 1, 6, -23, 5, 2}

    vs

    ?

    The problem is that there are no set theory controls. It would nice to bring sets into union, disjunction and intersection, as well as create and destroy sets.

    Posted in: Triggers
  • 0

    posted a message on Creating a "Group of Integers"

    Yes, I cannot seem to accomplish basic set theory, as I have no ability to create/add/remove integers/reals from an Integer/Real Group, as I can create/destroy/add/remove units/players from Unit and Player Groups.

    The result is that I've been making hidden dummy units at certain X coordinates and getting the X position of the units in the unit group and converting it to a real/integer. I've been removing and adding these units to the unit group in order to simulate the effect of adding/removing integers/reals from Integer/Real groups.

    So my question: Is there a way to create sets of integers?

    For instance Set A = {1, 6, 18, -23, 5, 2, -14}

    Posted in: Triggers
  • To post a comment, please or register a new account.