Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Best way to do this thing
Best way to do this thing
2005-06-26, 1:03 PM #1
I haven't tried writing out this cog that I will be needing soon, but I expect I may hit a few stumbling blocks before I get it right. Thats why I thought I'd ask for suggestions first.

What it needs to do is simply find the players location(single player) and shift a thing to one of its frames according to the position of the player around the center of the level. I get a little confused with the vector verbs so I'm not sure yet what is necessary to do this.

There will need to be 20 frames and the cog needs to check which "section" the player is in out of 20 "pie-sections" around the center of the level. That makes each section 18 degrees out of a full circle. (It would be nice if I could also check within this radius a proximity to the center at which a different trigger would be sent, say within 3 Jku of the origin .)

I know it will have to use a pulse message to keep checking. I don't need a full cog written out just the few lines where the position of the player is concerned.
2005-06-26, 2:08 PM #2
To find a position of the player you can use: "GetThingPos (JKGetLocalPlayer())" which should return a "thing" which acts as a "ghost location".

It should be noted that this doesn't auto-update, so you'll need to make regular calls like this to check on the player's position.

I don't have time to flesh this out at present, but that's how you can get a handle on the player's location. I suppose you could run a check on whether or not this ghost location is in a particular sector, but if you're doing that, you may as well check directly whether or not the player is in the sector....

Hope this helps get you started :)

-Jackpot
"lucky_jackpot is the smily god..." -gothicX
"Life is mostly froth and bubble, but two things stand in stone,
Kindness in another's trouble, courage in your own"
- "Ye Wearie Wayfarer"
|| AI Builder: compatible with both JK & MotS || My website ||
2005-06-26, 3:42 PM #3
Yes. I want to check what Quadrant the player is in TOO. Actually instead of quadrants I want to check in 1/20ths of a complete 360 degree circle around the origin of the level. That is where I'm not exactly sure yet. :)
2005-06-26, 4:12 PM #4
I'd probably do something like this...
Code:
player = GetLocalPlayerThing();
pos = < center point of your quadrants -- probably should be defined in the Jed cog window... >;
vec = VectorSub(GetThingPos(player), pos);
dot = VectorDot(VectorNorm(vec), VectorNorm(pos));
y = VectorY(pos) - VectorY(vec);
if(dot > .951) //cos(18) = .951
   quadrant = 0;
else if(dot > .809) //cos(36) = .809
   quadrant = 1;
else if(dot > .588) //cos(54) = .588
   quadrant = 2;
.
.
.
else
   quadrant = 9;
if(y < 0) quadrant = 19 - quadrant;

MoveToFrame(elevator, quadrant, speed);

Hopefully it'll give you some ideas.

Imagining a clock as your division of quads for a moment, this code will (if I did it right) "define" quadrant 0 between 12 and 1 o'clock, and will continue to "define" them in a clockwise fashion, ending at 19 (quadrants 0 thru 19 count up to be 20 quads total, obviously).
May the mass times acceleration be with you.
2005-06-26, 4:14 PM #5
Simple... place a ghost object in the center of the level to be referenced by the cog. Then you can compare the players location with the ghost object location. I dont know the math off hand, but it shouldnt be too difficult to calculate what direction the player is from the ghost object when you compare the two values.

↑ Up to the top!