Game Development Community

Easy to Reproduce Lag Issue (FPS RTS hybrid)

by Vijay Myneni · in RTS Starter Kit · 11/28/2004 (9:39 pm) · 92 replies

Okay, this might not actually be an issue, but it's driving me crazy. Hopefully, someone can try this out and let me know if I'm just seeing things. It's fairly quick to set up and try. This post also doubles as a good set of instructions for the basics of getting the FPS player into your RTS game (I want to ultimately make this a resource combined with instructions for setting up clean switching between RTS and FPS control).

1. Start with a clean RTS Engine build, and a clean starter.RTS project. Also have a starter.fps directory around to grab files from.
2. Grab the server/scripts/player.cs file from starter.fps and copy it to server/scripts/avatars/fpsPlayer.cs in starter.RTS.
3. Grab the data/shapes/player directory from starter.fps and copy it to data/shapes/fpsPlayer in starter.RTS.
4. In server/scripts/avatars/fpsPlayer.cs, change the very first exec line to point to your new data directory:
exec("~/data/shapes/fpsPlayer/player.cs");
5. In server/init.cs, add a line to exec your new fpsPlayer.cs script:
exec("./scripts/avatars/fpsPlayer.cs");
.
6. Repeat step 5 in your server/scripts/core/game.cs file. My understanding is that the exec's should happen in the same order in both these files. I have mine happening right after player.cs gets exec'd. Also, I had to ultimately add a line for scripts/fx/environment.cs into my game.cs, so that it matched up with init.cs. If I don't do this, the game crashes during datablock transfer.
7. In server/scripts/core/gameConnection.cs, replace the existing onClientEnterGame with this:
function GameConnection::onClientEnterGame(%this)
{
   commandToClient(%this, 'SyncClock', $Sim::Time - $Game::StartTime);

   %clientIndex = %this.getClientIndex();
   %this.setTeam(%clientIndex);

   %offset = ((%this.getTeam()-1) * (%unitsPerDir + 5));

   // Create a new camera object.
   %this.camera = new Camera() {
      dataBlock = Observer;
   };
   MissionCleanup.add( %this.camera );
   %this.camera.scopeToClient(%this);

   // Setup game parameters, the onConnect method currently starts
   // everyone with a 0 score.
   %this.score = 0;

   // Create a player object.
   %this.createFPSPlayer((%offset*5) SPC (%offset*5) SPC "250");
}

8. Also in gameConnection.cs, add the following function:
function GameConnection::createFPSPlayer(%this, %spawnPoint)

{
   if (%this.player > 0)  {
      // The client should not have a player currently
      // assigned.  Assigning a new one could result in 
      // a player ghost.
      error( "Attempting to create an angus ghost!" );
   }

   // Create the player object
   %player = new Player() {
      dataBlock = PlayerBody;
      client = %this;
   };
   MissionCleanup.add(%player);

   // Player setup...
   %player.setTransform(%spawnPoint);
   %player.setShapeName(%this.name);
   
   // Starting equipment
   %player.setInventory(Crossbow,1);
   %player.setInventory(CrossbowAmmo,10);
   %player.mountImage(CrossbowImage,0);

   // Update the camera to start with the player
   %this.camera.setTransform(%player.getEyeTransform());

   // Give the client control of the player
   %this.player = %player;
   %this.setControlObject(%player);
}

Continued...
Page«First 1 2 3 4 5 Next»
#81
11/22/2005 (8:08 pm)
As Tom said, check your case. Rts and RTS are NOT the same (and they need to be).
#82
11/22/2005 (8:36 pm)
Ooops :-(

It almost fealt like tom was giving me a riddle. Sleep deprivation and programming does not mix.
#83
11/23/2005 (8:33 am)
Warnings do not halt the compilation. Typically during a compilation of the engine you will get a few warnings, usually telling you about possible data loss during different castings.

As to the other error,

This error can be caused by having a newline character in a string constant without a continuation character. For example:

#include <stdio.h>
main() {
printf("\n %s
%s    // error: 's' : undeclared identifier
%s",
"this", "is", "it");
}
#84
11/23/2005 (8:38 am)
Having just read my post, I realized you probably wouldn't understand what a continuation character was, etc.... so I'll post a possible fix for the broken example code that I splashed down.

The most common method to split a constant string over multiple lines is to change the format string. Strings separated only by whitespace (spaces, tabs, newlines) are concatenated. For example:

#include <stdio.h>
main() {
printf("\n %s"
 " %s"
 " %s",
 "this", "is", "it");
 }

In other words, you can't just open a string constant then hit the Enter key and continue adding to that constant. If you didnt do this on purpose, chances are you might have just forgotten to close the string in the first place. So go to line 147 of gameConnection.cc and see what you find.

You probably already know this but you do realize that an error breaks down like the following:
FileLocation(ApproximateErrorLine) : Error Code: Description

And for the future, for many errors, you can search either the error code or the description in Google and typically if it is a normal C++ programming mistake find a good description/solution on MSDN. I never mind answering simple programming questions once, but don't come back in here with the same semi-colon error again!

Hope this helps.
#85
11/23/2005 (9:37 pm)
Ok ok I won't I've learned more with debugging this week than i have with just staring at the code. I reallly do appreciate all of the help
#86
01/15/2006 (11:08 pm)
I'm back again. I basically started from scratch.

I have two questions

Although I made changes to the engine I can still run the torque demo even with the errors. Why is this?

Also now I get an error that says:

C:\Torque\SDK\engine\game\gameConnection.cc(1366) : error C2259: 'SetTeamEvent' : cannot instantiate abstract class due to following members:
C:\Torque\SDK\engine\game\gameConnection.cc(87) : see declaration of 'SetTeamEvent'

My question is what should the declaration be? Because I followed the script exactly.
#87
01/16/2006 (11:29 am)
I'm back again. I basically started from scratch.

I have two questions

Although I made changes to the engine I can still run the torque demo even with the errors. Why is this?

Also now I get an error that says:

C:\Torque\SDK\engine\game\gameConnection.cc(1366) : error C2259: 'SetTeamEvent' : cannot instantiate abstract class due to following members:
C:\Torque\SDK\engine\game\gameConnection.cc(87) : see declaration of 'SetTeamEvent'

My question is what should the declaration be? Because I followed the script exactly.
#88
01/16/2006 (6:09 pm)
Okay

should I be getting these?
#89
01/16/2006 (6:17 pm)
GameConnection.obj : error LNK2001: unresolved external symbol "public: void __thiscall GameConnection::setDisconnectReason(char const *)" (?setDisconnectReason@GameConnection@@QAEXPBD@Z)
gameConnection.obj : error LNK2001: unresolved external symbol "public: void __thiscall RTSUnit::setMoveDestination(class Point3F const &)" (?setMoveDestination@RTSUnit@@QAEXABVPoint3F@@@Z)
gameConnection.obj : error LNK2001: unresolved external symbol "public: void __thiscall RTSUnit::clearAim(void)" (?clearAim@RTSUnit@@QAEXXZ)
gameConnection.obj : error LNK2001: unresolved external symbol "public: void __thiscall RTSUnit::setAimObject(class GameBase *)" (?setAimObject@RTSUnit@@QAEXPAVGameBase@@@Z)
../example/torqueDemo.exe : fatal error LNK1120: 4 unresolved externals
Error executing link.exe.
#90
01/17/2006 (10:13 am)
You aren't linking in at least some of the RTS code into your build. Check to make sure the /rts folder is in your source project, and you may also want to try a clean build.
#91
01/17/2006 (7:13 pm)
Oh my god i think it worked but how can I test it? I mean what's the controls anyway?
#92
01/25/2006 (7:06 pm)
Me again.... What should have changed in the demo program. (anything I should look out for?)

After I made the changes and compiled it (no errors) The stronghold demo looks the same

The orc starts in a the house with his usual cross bow. I could use a little help.
Page«First 1 2 3 4 5 Next»