|
|
#31 | ||
![]() Join Date: Feb 2012
Reputation: 4
Posts: 80
|
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:
Quote:
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");
}
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. |
||
|
|
|
|
|
#32 |
![]() Join Date: Jun 2009
Reputation: 34
Posts: 85
|
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.
|
|
|
|
|
|
#33 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 80
|
Ah, duhhh ... Didn't see those at first. Thanks for pointing that out
Will keep at it!
|
|
|
|
|
|
#34 |
![]() Join Date: Jun 2008
Reputation: 351
Posts: 1,804
|
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. |
|
|
|
|
|
#35 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 80
|
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. |
|
|
|
|
|
#36 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 80
|
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??? |
|
|
|
|
|
#37 | |
![]() Join Date: Jun 2008
Reputation: 351
Posts: 1,804
|
Quote:
).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. |
|
|
|
|
|
|
#38 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 80
|
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 |
|
|
|
|
|
#39 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 80
|
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) );
Code:
if ( !V_stricmp( args[0], "MyCommand" ) )
{
Msg( "MyCommand received! Value: %f\n", args[1] );
return true;
}
|
|
|
|
|
|
#40 | |
![]() Join Date: Mar 2012
Reputation: 1
Posts: 38
|
Quote:
Code:
engine->ServerCmd(VarArgs("MyCommand %i", static_cast<int>(vecForward.x));
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. |
|
|
|
|
|
|
#41 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 80
|
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) );
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 |
|
|
|
|
|
#42 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 80
|
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. |
|
|
|
|
|
#43 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 80
|
Ughhhh, how has no one else solved this? :P
I might go back and try UserCmdStrings instead!! https://developer.valvesoftware.com/...erver_Messages |
|
|
|
|
|
#44 |
![]() Join Date: Oct 2010
Reputation: 1
Posts: 49
|
It might be worth looking at the Insurgency source code; they did this with UserCMD's
|
|
|
|
|
|
#45 |
![]() Join Date: Feb 2012
Reputation: 4
Posts: 80
|
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> Cheers, C Last edited by ChadReitsma: 05-02-2012 at 02:14 AM. |
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|