Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 04-23-2012, 04:03 AM   #31
ChadReitsma
 
Join Date: Feb 2012
Reputation: 4
Posts: 91
I think I've almost got it, but it doesn't seem to be transmitting the Vector via cmd-> properly

Here's what I did:

Quote:
Modify the UserCmd class to contain your new variable.
Added: Vector shootingDir; inside of usercmd.h

Quote:
Then in CInput::CreateMove (or in your mod specific derived class of CInput) calculate your free aim forward vector and add it to the UserCmd.
I didn't do it in CreateMove as that didn't contain my vecForward, so I placed this immediately after I calculated that variable: cmd->shootingDir = vecForward;


Now.. this is where I'm having some trouble...
Inside of CPrediction::RunCommand(prediction.cpp) and CPlayerMove::RunCommand(player_command.cpp), I've created these If Statements:


Code:
if ( ucmd->shootingDir.x != 0) {
  player->shootingDir = ucmd->shootingDir;
  Msg("Got a shooting Dir inside of prediction.cpp...\n");
}
Code:
if ( ucmd->shootingDir.x != 0) {
  player->shootingDir = ucmd->shootingDir;
  Msg("Got a shooting Dir inside of player_command.cpp...\n");
}
When I run the code, it only outputs the message from inside of player_command.cpp... it seems that the prediction one doesn't work...

Annnnd, sadly - it doesn't seem to be receiving the vector properly, when I try to Msg() out ucmd->shootingDir.x, or shootingDir.y etc... it's NAN

Last edited by ChadReitsma: 04-23-2012 at 04:09 AM.
ChadReitsma is offline   Reply With Quote
Old 04-23-2012, 04:10 AM   #32
Sandern
 
 
 
Join Date: Jun 2009
Reputation: 34
Posts: 101
You also need to modify the functions WriteUsercmd and ReadUsercmd in usercmd.cpp and Reset, GetCheckSum and "operator =" in usercmd.h. Just follow the example of the other variables.
Sandern is offline   Reply With Quote
Old 04-23-2012, 04:23 AM   #33
ChadReitsma
 
Join Date: Feb 2012
Reputation: 4
Posts: 91
Ah, duhhh ... Didn't see those at first. Thanks for pointing that out Will keep at it!
ChadReitsma is offline   Reply With Quote
Old 04-23-2012, 08:36 AM   #34
Biohazard_90
 
 
 
Join Date: Jun 2008
Reputation: 351
Posts: 1,812
Wait - why are you adding a new variable to CUserCmd at all?

You don't need to. The angles (which already exist there) in CUserCmd represent the aiming vector, that's all.

The viewangle stays on the client.

If you don't do it like that you will have to make the rest compatible again. I'm 99.9% sure that merely removing all sorts of <pseudocode>isthirdperson</pseudocode> will make it work in firstperson.

If you send it to the server, you will have much more work all in all and it will require more bandwidth.

What I was talking about is that the variable in CUserCmd used as viewangle will become the firing angle solely and the client overrides the viewangle as the tutorial does.
Biohazard_90 is offline   Reply With Quote
Old 04-25-2012, 01:39 AM   #35
ChadReitsma
 
Join Date: Feb 2012
Reputation: 4
Posts: 91
That's what I tried bro, didn't seem to work...
I appreciate the concern for bandwidth but my mod will ONLY be run at a lan more on that once I can get past this ridiculous angle stuff.

The Firing angle is different from the ViewAngle... IE: When I move the mouse - it only moves the crosshair on the screen, not the view... got that far... now when a user fires a weapon it needs to take the X,Y Position of the crosshair on the screen and calculate the Firing angle from that using ScreenToWorld, but because that function is client-side the only way I could get it to change that was to add that stuff into base_machinegun... are you saying that I can access some angles using pPlayer-> ???

Last edited by ChadReitsma: 04-25-2012 at 03:02 AM.
ChadReitsma is offline   Reply With Quote
Old 04-25-2012, 02:16 AM   #36
ChadReitsma
 
Join Date: Feb 2012
Reputation: 4
Posts: 91
Let's just try and simplify this process as much as possible...
I have the correct aiming vector stored client-side in vecForward... so how do we get the server to recognize this??? can I use some commands to retrieve it from the client???
ChadReitsma is offline   Reply With Quote
Old 04-25-2012, 11:58 AM   #37
Biohazard_90
 
 
 
Join Date: Jun 2008
Reputation: 351
Posts: 1,812
Quote:
Originally Posted by ChadReitsma View Post
Let's just try and simplify this process as much as possible...
I have the correct aiming vector stored client-side in vecForward... so how do we get the server to recognize this??? can I use some commands to retrieve it from the client???
You get it to the server by making it the 'viewangle' in the CUserCmd (this is definitely happing somewhere already, since that's how the tutorial works after all ).

Then in OverrideView you will use your *local* angle, not based on the 'viewangle' in CUserCmd, like the tutorial does it too.

So all in all it literally works the same way, unfortunately I can't work on this right now and tell you which lines to change exactly, but I can still assure you that there's virtually no difference, apart from moving the viewmodel itself.

The bandwidth advantage was just a bonus, it's more that doing it this way requires barely any additional work.
Biohazard_90 is offline   Reply With Quote
Old 04-26-2012, 03:54 AM   #38
ChadReitsma
 
Join Date: Feb 2012
Reputation: 4
Posts: 91
Hey Guys,
Could you help me understand ConCommands a little better? I'm thinking we could send it with one of those?? I know it's not the best idea (from a bandwidth) point of view, but I gotta get this figured out!!!

Thanks again for helping a total noob, haha.

Cheers,
C
ChadReitsma is offline   Reply With Quote
Old 04-26-2012, 04:13 AM   #39
ChadReitsma
 
Join Date: Feb 2012
Reputation: 4
Posts: 91
I've got a little bit further with this:
https://developer.valvesoftware.com/...erverCmd%28%29

But am having trouble passing vectors
Tried:
Code:
engine->ServerCmd( VarArgs("MyCommand", vecForward.x) );
And on the Server:
Code:
if ( !V_stricmp( args[0], "MyCommand" ) )
	{
	Msg( "MyCommand received! Value: %f\n", args[1] );
	return true;
}
But args[1] is just zero... is something converting it to an INT??
ChadReitsma is offline   Reply With Quote
Old 04-26-2012, 07:42 AM   #40
Jeremy__
 
Join Date: Mar 2012
Reputation: 1
Posts: 38
Quote:
Originally Posted by ChadReitsma View Post
I've got a little bit further with this:
https://developer.valvesoftware.com/...erverCmd%28%29

But am having trouble passing vectors
Tried:
Code:
engine->ServerCmd( VarArgs("MyCommand", vecForward.x) );
And on the Server:
Code:
if ( !V_stricmp( args[0], "MyCommand" ) )
	{
	Msg( "MyCommand received! Value: %f\n", args[1] );
	return true;
}
But args[1] is just zero... is something converting it to an INT??
Code:
engine->ServerCmd(VarArgs("MyCommand %i", static_cast<int>(vecForward.x));
Are you sure you want to cast it to an integer? You may lose a bit of data truncating that float.

As to reiterate what Biohazard_90 had said, console commands are a very bad idea for transmitting data over to the server as frequently as it seems you'd like to. Even if it is an enitrely lan game, the practice would be frowned upon. It doesn't seem like it would be too difficult to override OverrideView. It would seem that all you do is access CViewSetup::angles member of the first argument passed to OverrideView and adjust the yaw pitch roll. If you want to translate the camera, you can also access the origin member.

There is a lot over overhead in transmitting a server command including text parsing and going through a call hierarchy to find the handler.

Last edited by Jeremy__: 04-26-2012 at 07:45 AM.
Jeremy__ is offline   Reply With Quote
Old 04-26-2012, 03:06 PM   #41
ChadReitsma
 
Join Date: Feb 2012
Reputation: 4
Posts: 91
Hi Jeremy,
EDITED:: For the love of sweet baby jesus...Got it figured out,
Inside of my server-side code I had %f, I changed it to: %s (Assuming that's because it's a string??) duhhhhh... anyways, it worked so I can finally send these bloody angles server side.

So client is this:
Code:
engine->ServerCmd( VarArgs("MyCommand %f", vecForward.x) );
And Server (I use player.cpp) is this:
Code:
CON_COMMAND(MyCommand, "Retrieval of client commands...")
{
	Msg("Something on server is: %s\n", args.Arg(1) );
	return;
};

I just want to say again, that I really really REAAALLLY appreciate all the help you guys are giving me - I know it's frustrating dealing with noobs like me! haha.

When I have money to hire "real programmers" like you guys, I will make you an offer Right now I'm just getting a rough-draft/prototype together to show investors.

Cheers,
C

Last edited by ChadReitsma: 04-26-2012 at 03:40 PM. Reason: -thnx
ChadReitsma is offline   Reply With Quote
Old 04-26-2012, 04:45 PM   #42
ChadReitsma
 
Join Date: Feb 2012
Reputation: 4
Posts: 91
Alright... this should be my last question, lol.

I've retrieved the floats server-side (in player.cpp) and I've converted them from CON_COMMAND strings back to floats, and stored them inside a vector (tempAng).

I've declared the Vector (firingAngle) in player.h, How do I store the tempAng vector into pPlayer->firingAngle so that I can retrieve it inside other files??

I've tried this, but I can't get retrieve it with pPlayer->firingAngle inside of weapon_machinegun.... I get some stupid error that FiringAngle doesn't belong to the C_BasePlayer Class (Client side??) arghh....

Code:
CON_COMMAND(MyCommand, "Retrieval of client commands...")
{

	CBasePlayer *pPlayer;
	
	Vector tempAng;
	tempAng.x = atof(args.Arg(1));
	tempAng.y = atof(args.Arg(2));
	tempAng.z = atof(args.Arg(3));

	pPlayer->firingAngle = tempAng;
	return;
	
};

Thanks again!

Last edited by ChadReitsma: 04-26-2012 at 05:25 PM.
ChadReitsma is offline   Reply With Quote
Old 04-30-2012, 01:29 PM   #43
ChadReitsma
 
Join Date: Feb 2012
Reputation: 4
Posts: 91
Ughhhh, how has no one else solved this? :P
I might go back and try UserCmdStrings instead!!
https://developer.valvesoftware.com/...erver_Messages
ChadReitsma is offline   Reply With Quote
Old 04-30-2012, 08:57 PM   #44
JLea
 
Join Date: Oct 2010
Reputation: 1
Posts: 49
It might be worth looking at the Insurgency source code; they did this with UserCMD's
JLea is offline   Reply With Quote
Old 05-02-2012, 01:01 AM   #45
ChadReitsma
 
Join Date: Feb 2012
Reputation: 4
Posts: 91
Thanks JLea, I'll check in to that...

Edited:
Just tried to implement UserCmd Strings...


I got to the implementation part where it talks about adding this to C_BasePlayer...
I open C_BasePlayer.h, and go to the protected section... and add:

Code:
 CUtlLinkedList<const char *, byte>
intelliSense says: Error, declaration does not declare anything... WTF???



Cheers,
C

Last edited by ChadReitsma: 05-02-2012 at 02:14 AM.
ChadReitsma is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -7. The time now is 02:27 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2014, All Rights Reserved.