Staredit Network

Staredit Network -> UMS Assistance -> making a unit go in a reflected direction.
Report, edit, etc...Posted by -black-death- on 2004-09-04 at 21:09:46
Okay here is the deal. A element in my map involves units bouncing around the walls inside a box:

CODE

+-------------------------+
|                         |
|                         |
|                         |
|                         |
|        Frame 1          |
|                         |
|                         |
|  \                      |
|   \                     |
|    \                    |
|     ·                   |
+-------------------------+

+-------------------------+
|                         |
|                         |
|                         |
|                         |
|        Frame 2          |
|                         |
|                         |
|                         |
|                         |
|    \                    |
|     \                   |
+------·------------------+

+-------------------------+
|                         |
|                         |
|                         |
|                         |
|        Frame 3          |
|                         |
|                         |
|                         |
|                         |
|                         |
|       .                 |
+-------------------------+


+-------------------------+
|                         |
|                         |
|                         |
|                         |
|        Frame 4          |
|                         |
|                         |
|                         |
|         .               |
|        /                |
|       /                 |
+-------------------------+

+-------------------------+
|                         |
|                         |
|                         |
|                         |
|        Frame 4          |
|                         |
|           .             |
|          /              |
|         /               |
|                         |
+-------------------------+


etc.

And you have to take into account that the angle of intersection should equal the angle of deflection. ie. the unit will not always bounce at a 45° angle.

How can I achieve this bounce effect so that it will continuously bounce off the walls?

Thanks for the help,

b.d
Report, edit, etc...Posted by BeeR_KeG on 2004-09-04 at 21:28:27
This will be very hard and long time to make.

You might have to make lots off locations all around the place and make 1 trigger for every posible combination or angle on each wall space.
I don't think anyone will try making it that way.

I knew of a way to make this an easier was like in Pong, but I forgot how.
Report, edit, etc...Posted by Cloak(U) on 2004-09-04 at 21:42:37
loll bd nice question......
Report, edit, etc...Posted by Chill on 2004-09-04 at 21:44:31
I made a map like that once. The left side had locations labled from 1a, 2a, 3a, etc alway the way up to 10a. then the next side was the Bs, then the Cs and then the Ds. 1a bounces to 1b, then to 1c, then 1d, and so on and so forth. the players had units in the middle of the square that would bounce the ball to a location centered on an observer flying around outside of the squre. Then it woudl hit the wall and bounce around.
Report, edit, etc...Posted by -black-death- on 2004-09-04 at 22:17:54
QUOTE(Chill @ Sep 4 2004, 08:44 PM)
I made a map like that once.  The left side had locations labled from 1a, 2a, 3a, etc alway the way up to 10a.  then the next side was the Bs, then the Cs and then the Ds.  1a bounces to 1b, then to 1c, then 1d, and so on and so forth.  the players had units in the middle of the square that would bounce the ball to a location centered on an observer flying around outside of the squre.  Then it woudl hit the wall and bounce around.
[right][snapback]65443[/snapback][/right]


But with this method wouldn't the ball get in a pattern?

Wouldn't it go from 3a to 3b to 3c to 3d to 3a to 3b to 3c to 3d and so on?

That would work if the map was a square, but contrary to my first post, my map is not a sqaure, it is a rectangle, so that means the unit could potentially go in any direction at any angle after enough bouncing.

scem0
Report, edit, etc...Posted by LegacyWeapon on 2004-09-04 at 22:38:06
yes it would
Report, edit, etc...Posted by Stereo on 2004-09-04 at 23:17:22
There should be away to do this, I would make a demo map but things this complicated usually mess up my triggers. How would you define the "original" path? Have it start at say 1A then order it to 3C and it loses your control after you order it so it keeps bouncing?
Report, edit, etc...Posted by Chill on 2004-09-04 at 23:31:36
The players have things that hit the ball onto different paths... and you could just streach out the side locations for a rectangle
Report, edit, etc...Posted by DT_Battlekruser on 2004-09-04 at 23:57:13
Yea the location labeling would work even in a rectangular box but only at a 45 degree angle. Ig uess you gould set a counter to keep track of angle and have different set of triggers for each angle but that would use like 1000 triggers and 200 locations.
Report, edit, etc...Posted by -black-death- on 2004-09-05 at 00:18:51
Where's bolt when you need him?

He's good at these kinds of things wink.gif.

Well, ima go take a censored.gif and think about it on the pot. w00t.gif crazy.gif cool1.gif

b.d

edit - the toilet can do wonderful things. I think I thought up a solution. The unit will only be able to bounce in 45 degree angles but it will maintain a logical path. It involves using switches to determine which way the unit coming from and then using conditional triggers to determine where the unit goes next.
Report, edit, etc...Posted by Stereo on 2004-09-05 at 00:22:11
The way I see it, you need 4 variables:
Hfactor
Hdirection
Vfactor
Vdirection
h-horizontal
v-vertical
(assuming you can't store negative numbers)
If it hits the left or right side, it is ordered to the other side by a combination of Vfact and Vdirection, going either up Vfact or down Vfact based on Vdirection. You would have the locations extend out on either side so it could be ordered up even if it starts near the top.

If it hits the top or bottom, ditto but with Hfact and Hdirection.

With this you need either a fast subtraction system or quite a few triggers.

Y Obviously when it's going to the other side it may hit a 90 degree to it side at which point either Hdirection or Vdirection is set/unset and it rebounds using the other calculation. The ranges are Hfactor = 0 to (#locations across) and Vfactor = 0 to (#locations up/down) - when they launch it, it will start at some location and end at another on the square at which point, it can be calculated the difference in H and V from launch point to first collision. Store this in a variable. Place units equally up 3 times the length of the side (actual side, then same distance above/below) the side for the 'target' locations to allow it to move "up" when it's already near the top, and similar situations on the other sides. You also need some triggers to set up "move upwards x" or "move downwards x" or etc. which can easily be done by preplacing units under each location and then using center/give a repeated number of times until some score reaches 0 indicating it is up/down far enough, then order the unit. If it contacts a "side" unit (make diff ones for each side) execute that side's stuff.


Your only limits are how carefully you can place units along the sides - if it doesn't move up and down them reliably it won't work out.
Report, edit, etc...Posted by -black-death- on 2004-09-05 at 00:28:14
wow thanks for that long thought out response.

But that is waayyyyy to complicated. I wouldn't enjoy making those triggers, and my rule with mapmaking is to not do it unless i enjoy it (is that why i never finish my maps? wink.gif).

Thanks though,

b.d
Report, edit, etc...Posted by Stereo on 2004-09-05 at 00:31:50
It's a lot less work than you think..
1 trigger to toggle up/down for 4 sides = 4 trigs
5-6 trigger each contact --> other var for 4 sides (instant variable value transfer) = 20 trigs, mostly "condition: score1 is at least 16, action: sub 16 from score 1, add 16 to score2, add 16 to score3" type things.
5-6 trigger to move the location "target" instantly, then order it --> 20 more trigs, mostly like before. Man SC needs proper variables and arrays.
1 trigger to follow the "moving" unit --> 1 trig
total: 50, maybe 60 trigs depending how they go.
Report, edit, etc...Posted by Daigotsu on 2004-09-05 at 09:40:50
lol that is still alot of triggers.

If only it could be possible to make them go exactly where you want....
Report, edit, etc...Posted by Crispie on 2004-09-05 at 11:07:03
Make a grid of locations. Each spot must have its own location. Example.



A1 A2 A3 A4
B1 B2 B3 B4
C1 C2 C3 C4
D1 D2 D3 D4
E1 E2 E3 E4
F1 F2 F3 F4
G1 G2 G3 G4
H1 H2 H3 H4





Heres the tricky part. You need 2 points to create a line, thus determining at which angle to reflect. Have a trigger like this,

Conditions
Player X brings exactly 1 X unit to A2
Player X brings exactly 1 Y unit to B3

Actions
Kill all units at Location B3
Kill all units at Location A2
Create 1 Y unit at Location A2
Create 1 X unit at B1
Wait 500 milliseconds
Preserve Trigger



You are the one who has to calculate the angle at which it will deflect. X represents where you "Ball" or whatever that is reflecting is, and Y represents the Shadow of your X. You need both X and Y to tell where it will next deflect. X and Y together represent the line, or straight path that the ball is going in, and with that you can tell the game with triggers when it is in that straight path where it will go when it deflects out a certain area. See my trigger that I did, using both the shadow and the current location of the "ball" I was able to tell the direction the "ball" was moving in and at what angle it would deflect off the wall at. The triggers telling to destroy both X and Y are there since the previous Shadow is no longer needed, and the previous "ball" position now becomes the shadow of the new location, B1. What this trigger does is create a perpetual ball that is constantly relfecting off the wall randomly. To have a player control where to angle the ball, simple put a selection of beacons (8), that represent every location around the ball(ball cant be moving, thus have no shadow), and when the player picks which beacon, and puts his player on the beacon, that it creates a shadow at the parrallel location of whatever the beacon represents, thus angling the ball to go where he desires. The uses of this could be oh saythat the ball must hit a certain spot before the time limit, etc.
Report, edit, etc...Posted by (U)Bolt_Head on 2004-09-05 at 15:06:31
I made a mod of my Coordinates map that does that.

I decided to do it after i saw that Laurent14 had done that exact same thing. (except he had like 6 going at a time)

I'm lucky that i still have the map.

Of course this is differant from actually ordering a unit to bounce as opposed to plotting out the direction of movement. If you control the unit yourself the angle of the bounce is almost illrelivant. Otherwise you need to create a "grid system" with locations moved to spaces around your unit. Instead of ordering the unit to a loation on the other side of the map you order it to a location centered right next to it. When it would bounce you use the infromation of the direction it is moveing to know witch direction to tell it to move next. For example if it is moveing at 45degrees and hits the right side you would have it start moveing at 135. And if it hit the top while going 45 it would start moveing 315. (degrees are relitive to the unit circle not the angle of reflection)

What your doing is quite difficult and I can't see it being done with more than 16 differant angles (0, 22.5, 45, 67.5, 90, 112.5, 135, 157.5, 180, 202.5, 225, 247.5, 270, 292.5, 315, 337.5)
Report, edit, etc...Posted by Stereo on 2004-09-05 at 15:26:51
I have a method conceived, but currently I can't think of a way to make it work no matter which side they go instead of only working straight across.

I need a fraction calculator, that can take x/y and find what/z it's closest to. After that it's all easy.
Report, edit, etc...Posted by ShadowBrood on 2004-09-05 at 15:50:48
the only way i can think of doing this would be to use (U)bolt_head's grid system and use switches to determine bounce angle. ill ask my friend. hes really good at all the trajectory things so ill say what hes got to say when im done talkin to him. hey by any chance, is this a dodge map? because i was thinking of something like this where a unit or 5 tongue.gif bounces around a large arena at high speeds and you have to dodge it.
Report, edit, etc...Posted by .Coko[CK] on 2004-09-05 at 16:35:52
Randomisation in Bounces is easy enough, just have a couple of Corsairs/Scouts which move around the area of play, outside of view with Centre Locations, Four for each side, IE: 16 and randomisation of where it will go, and for that second it will aim for where the Location over one of them is...

But thats not what you want. I'd agree with Bolts indear, at least having it about two squares deep from every side of the map, and work it from there, adding Death Counts for certain movements though locations, differing from how they go through them as such.
Next Page (1)