• 🏆 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!

How to figure out an equation?

Status
Not open for further replies.
Level 9
Joined
Nov 4, 2007
Messages
931
This is equation is needed for a trigger in my map.

I need an equation that will properly space apart units shown on the screen in the correct fashion. Allow me to demonstrate how I need it to work, the X's represent my units and their spacing represents their location.
X
X X
X X X
X X X X
Etecetra, this should be easy but I just can't figure out the formula.
One last thing, I don't need it to display and space apart all of the rows at the same time, but only 1 row depending on the units that are present, for instances 6 units would not be spaced apart between rows 1 - 3 like so
X
X X
X X X
but instead spaced as
X X X X X X
 
Level 5
Joined
Jul 10, 2010
Messages
124
Make each row created in an action definition taking the integer parameter for number of units.

each action definition then will have a Y coordinate that is a function of the integer parameter. So if you want each row to be 4 distance apart and the triangle shaped with 2 sloped sides (roughly 60 degrees), and you have a trigger that makes rows 1,2,3 and 5, then it would look like this:

Trigger 1
Events - what you want
Conditions -
Actions -
Action Definition "Row"(1)
Action Definition "Row"(2)
Action Definition "Row"(3)
Action Definition "Row"(5)

Then your Action Definition "Row" would look like this:

***makes sure the "create thread" box is checked***

Row
Parameters - Units (Integer)
Local Variables -
Loop A = 1 (Integer)
Y Inc = 4.0 (Real) **The distance between rows**
X Inc = 4.0 (Real) **The spacing between units in each row**
Y Start = (H + YInc * (Units - 1)) (Real) **H is half your maps Y height**
X Start = (W - (XInc/2) * (Units - 1)) (Real) **W is half your maps X width**
Point = (X,Y)
RowUnit = the unit you want to make (Unit Type)
Actions -
For each integer Loop A from 1 to Units, do actions -
Create 1 RowUnit at Point facing default angle ignoring placement
Set Point = ((X of Point + Xinc),(Y of Point))


So the trigger should do the action definition 4 times, each row beginning at:

1. X = half of map width, Y = half of map height and create 1 unit there
2. X = 2 units left of 1, Y = 4 units above row 1 and create 1 unit there and then 1 unit 4 units to the right of it
3. X = 2 units left of 2, Y = 4 units above row 2 and create 1 unit there, 1 unit 4 to the right, and a third unit 4 to the right
5. X = 4 units left of 3, Y = 8 units above row 3 and create 1 unit there and 4 more units spaced 4 apart


This isnt tested but you can tweak the Local Vars in the action definition to make the spacing different without messing with the actions
 
Status
Not open for further replies.
Top