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 → Client cogs and Rand();
Client cogs and Rand();
2002-11-16, 7:13 AM #1
I'm new to using client and server cogs and I was wondering... If you use a client cog to fire projectiles for weapons and you have the the standard randVec = VectorSet(Blah()randblahblah*0.5blah); for weapon inaccuracy in the client cog, would the projectile be going in a different direction on each player's computer?
I am _ Ace_1 _ , and I approve this message.
2002-11-16, 7:34 AM #2
Yes, because after the trigger is sent & recieved by each client, they'll have a different number for rand(); so what you want to do is send rand() along in the trigger.
-Hell Raiser
2002-11-16, 9:48 AM #3
Ok but how many params can you have in a send trigger command because I already am using 3 and I need 3 more because its a vector.
I am _ Ace_1 _ , and I approve this message.
2002-11-16, 9:57 AM #4
Why don't you just send the vector as a whole?

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-11-16, 10:00 AM #5
Simple, you cant send a vector. Trigger params are flex values, sending a vector isnt going to work. It has to be split up into its 3 components.

You might consider sending two triggers. One for your current values, another for the vector.

[This message has been edited by GBK (edited November 16, 2002).]
And when the moment is right, I'm gonna fly a kite.
2002-11-16, 10:35 AM #6
Ok I'll just use 2 triggers.
I am _ Ace_1 _ , and I approve this message.
2002-11-16, 10:36 AM #7
Yeah, I just noticed that in my own project. Sorry about it.

------------------
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2002-11-16, 2:17 PM #8
Nah, you dont need to triggers. In the TB coges I just went:

SendTrigger(-1, 61, gunnum, VectorX(randvec), VectorY(randvec), VectorZ(randvec));

Then retrieve it going:

player = GetSenderRef();
gun = GetParam(0);
VectorX= GetParam(1);
VectorY= GetParam(2);
VectorZ= GetParam(3);

That way you dont need to flood different triggers. And you can use arrays for projectiles.
Team Battle.
2002-11-16, 3:43 PM #9
Uhh, Hellcat, thats what he is doing. He needs to send 2 triggers, because he has 3 other values he needs to send as well.
And when the moment is right, I'm gonna fly a kite.
2002-11-16, 5:29 PM #10
Opps! Thats what I get for not reading everything. Sorry
Team Battle.
2002-11-16, 5:44 PM #11
Geeze, if you've got 3 params used up, just send Rand() in the trigger, duh. [http://forums.massassi.net/html/tongue.gif]
-Hell Raiser
2002-11-18, 4:12 AM #12
Actually, you'd probably only need to send two of the rand() values, since the Y value (I think its the Y) probably wouldn't ever need to be changed.
2002-11-19, 5:28 PM #13
Your right I can just send 2 params.
I am _ Ace_1 _ , and I approve this message.
2002-11-21, 5:36 AM #14
I've been using this method for my sendtriggers, but I'm a bit stumped as to how to do the shotgun spread. Right now the random vectors are generated locally, but of course I want these to be consistent on different machines. The only way I can think to do it as of right now is to define a set of different 'random' shotgun spreads, say eight and have one of the params send a number that will select that group of random numbers.

Does anyone know a better way?
2002-11-21, 1:48 PM #15
I was thinking you could somehow do all the rands in the non-trigger cog and add them up and send them as one number and divide them somehow in the client cog.
I am _ Ace_1 _ , and I approve this message.
2002-11-21, 2:32 PM #16
I think I came up with a way to do it. I call it "__Ace_1_'s Pattented Client/Server Shotgun Spread Without Using More Than One Trigger Code":

your coordinates:
y1 = ((Rand()-0.5)*5);
x1 = ((Rand()-0.5)*5);
y2 = ((Rand()-0.5)*5);
x2 = ((Rand()-0.5)*5);
y3 = ((Rand()-0.5)*5);
x3 = ((Rand()-0.5)*5);
y4 = ((Rand()-0.5)*5);
x4 = ((Rand()-0.5)*5);
y5 = ((Rand()-0.5)*5);
x5 = ((Rand()-0.5)*5);

------------------------------
coding it:
if(y1 < 0)
{
y1=(y1-(2*y1));
}
if(y2 < 0)
{
y2=(y2-(2*y2));
}
if(y3 < 0)
{
y3=(y3-(2*y3));
}
if(y4 < 0)
{
y4=(y4-(2*y4));
}
if(y5 < 0)
{
y5=(y5-(2*y5));
}
codedYcoords = (y1*100000)+(y2*10000)+(y3*1000)+(y4*100)+(y5*10);
if(x1 < 0)
{
x1=(x1-(2*x1));
}
if(x2 < 0)
{
x2=(x2-(2*x2));
}
if(x3 < 0)
{
x3=(x3-(2*x3));
}
if(x4 < 0)
{
x4=(x4-(2*x4));
}
if(x5 < 0)
{
x5=(x5-(2*x5));
}
codedXcoords = (x1*100000)+(x2*10000)+(x3*1000)+(x4*100)+(x5*10);

------------------------------
decoding it:
y1 = (codedYcoords/100000);
y2 = (codedYcoords/10000) - y1*10;
y3 = (codedYcoords/1000) - (y1*10+y2*10);
y4 = (codedYcoords/100)- (y1*10+y2*100+y3*1000);
y5 = (codedYcoords/10)- (y1*10+y2*100+y3*1000+y4*10000);
x1 = (codedXcoords/100000);
x2 = (codedXcoords/10000) - x1*10;
x3 = (codedXcoords/1000) - (x1*10+x2*100);
x4 = (codedXcoords/100) - (x1*10+x2*100+x3*1000);
x5 = (codedXcoords/10) - (x1*10+x2*100+x3*1000+x4*10000);

------------------------------
doing the shotgun spread:
randvec1 = VectorSet(x1, y1, 0);
randvec2 = VectorSet(-x2, y2, 0);
randvec3 = VectorSet(x3, -y3, 0);
randvec4 = VectorSet(-x4, -y4, 0);
randvec5 = VectorSet(x5, y5, 0);

------------------------------
Now this wont be exactly like a real randvec but it should be pretty **** close.

Oh and sombody tell me how to do that code thing on these forums.

[This message has been edited by Ace1 (edited November 21, 2002).]
I am _ Ace_1 _ , and I approve this message.
2002-11-21, 3:06 PM #17
Aww crap I just noticed a big error and that wont work.
I am _ Ace_1 _ , and I approve this message.
2002-11-21, 3:22 PM #18
I think this will work. I call it "__Ace_1_'s Pattented Fixed Client/Server Shotgun Spread Without Using More Than One Trigger Code":

your coordinates:
y1 = ((Rand()-0.5)*5);
x1 = ((Rand()-0.5)*5);
y2 = ((Rand()-0.5)*5);
x2 = ((Rand()-0.5)*5);
y3 = ((Rand()-0.5)*5);
x3 = ((Rand()-0.5)*5);
y4 = ((Rand()-0.5)*5);
x4 = ((Rand()-0.5)*5);
y5 = ((Rand()-0.5)*5);
x5 = ((Rand()-0.5)*5);

------------------------------
coding it:
if(y1 < 0)
{
y1=(y1-(2*y1));
}
if(y2 < 0)
{
y2=(y2-(2*y2));
}
if(y3 < 0)
{
y3=(y3-(2*y3));
}
if(y4 < 0)
{
y4=(y4-(2*y4));
}
if(y5 < 0)
{
y5=(y5-(2*y5));
}
codedYcoords = (y1*100000)+(y2*10000)+(y3*1000)+(y4*100)+(y5*10);
if(x1 < 0)
{
x1=(x1-(2*x1));
}
if(x2 < 0)
{
x2=(x2-(2*x2));
}
if(x3 < 0)
{
x3=(x3-(2*x3));
}
if(x4 < 0)
{
x4=(x4-(2*x4));
}
if(x5 < 0)
{
x5=(x5-(2*x5));
}
codedXcoords = (x1*100000)+(x2*10000)+(x3*1000)+(x4*100)+(x5*10);

------------------------------
decoding it:
y1 = (codedYcoords/100000);
y1int = (y1-0.1) //this better be an int or it will not work right
y2 = (codedYcoords/10000) - (y1int*10);
y2int = (y2-0.1)
y3 = (codedYcoords/1000) - (y1int*10)+(y2int*100);
y3int = (y3-0.1)
y4 = (codedYcoords/100) - (y1int*10)+(y2int*100)+(y3int*1000);
y4int = (y4-0.1)
y5 = (codedYcoords/10) - (y1int*10)+(y2int*100)+(y3int*1000)+(y4int*10000);
x1 = (codedXcoords/100000);
x1int = (x1-0.1) //this better be an int or it will not work right
x2 = (codedXcoords/10000) - (x1int*10);
x2int = (x2-0.1)
x3 = (codedXcoords/1000) - (x1int*10)+(x2int*100);
x3int = (x3-0.1)
x4 = (codedXcoords/100) - (x1int*10)+(x2int*100)+(x3int*1000);
x4int = (x4-0.1)
x5 = (codedXcoords/10) - (x1int*10)+(x2int*100)+(x3int*1000)+(x4int*10000);

------------------------------
doing the shotgun spread:
randvec1 = VectorSet(x1, y1, 0);
randvec2 = VectorSet(-x2, y2, 0);
randvec3 = VectorSet(x3, -y3, 0);
randvec4 = VectorSet(-x4, -y4, 0);
randvec5 = VectorSet(x5, y5, 0);

------------------------------
Now this wont be exactly like a real randvec but it should be pretty **** close.
I am _ Ace_1 _ , and I approve this message.
2002-11-22, 5:04 AM #19
I haven't tested it or anything, but I see what you're doing. Very ingenius idea.

↑ Up to the top!