Game Development Community

my second game mode is acting up

by Jonas · in Torque 3D Professional · 05/10/2011 (5:50 pm) · 7 replies

Hey!

Today when i started to modify my second game mode i half way through realised that
none of the changes i made applied when i tested it. At that point i checked all point
of reference to other places in my code such as exec and Parent:: calls.

Nothing looked wrong and when i call echo($server::missiontype); in game it shows me
the correct game mode. Then i tried adding in echo commands to my code to see if it
read the file, none of the echo commands was displayed in the console.

At that point i showed the game mode in a .txt file and used the vanilla gameDM.cs
code from a new project instead. This did not yield any result it still behaves just the same.
I then commented out:

Parent::onClientTenterGame(%game, %client);
and
parent::preparePlayer(%game, %client);

This normally results in a loading screen that won't load or a charactar that dosn't get eqquiped.
But with a second game mode it dosn't affect anything what so ever.

The wierd part about this is that if it cant find a game mode it should default to gameDM.cs(which is still coded that way in my project) but instead of using my custom loadout system its using the Gamecore.cs old system that i have yet to do any changes to.

I see no point in providing code for this error since its the vanilla gameDM.cs code but of course i changed the Deathmatchgame:: thingy and checked so i did it correctly 700 times. Im pretty sure this is a error located somewhere in gameCore.cs or game.cs (both are unchanged as well)

Summary:
1. The error ONLY happens with a second/multiple game modes the first (deathmatch) game mode works as intended.

2. the game mode in question is from any new project and total unchanged when the error appears.

Best regards
Jonas

About the author

Freelance 3D artist at day scripter/coder on Enduring Life at night. Lover of all things TorqueScript.


#1
05/10/2011 (6:33 pm)
1. Have you exec'd the new gameMode files in scriptExec.cs?

2. You need "gameType = Your_new_game_mode" in theLevelInfo of the .mis file or it will default to the default ServerType.

3. If you don't comment out the callbacks in your new gameMode file, they call the original function gameCore.cs function and overwrite your custom script.

//  parent::onClientEnterGame(%game, %client);
//comment this out if you don't want it to read the gameCore.cs version
//but make sure that you have everything you need firing from this script
//eg: spawning cameras, calls needed to run the game, etc
#2
05/10/2011 (6:59 pm)
1. Yep done.

2. done.

3. Im sorry i was a bit unclear on that matter i am aware thats the case. It was more a test like "will the game mode even notice if i change around stuff"

I changed the prepare function to my new format aka using a specific loadout located in the game mode in question and as i thought it still uses the loadout in gamecore.cs on top of that no echo commands will work it simply dosn't read the file for some reason.

Best regards
Jonas
#3
05/10/2011 (8:11 pm)
What is the name of your game type, and what is the namespace of it's functions?

#4
05/11/2011 (6:44 am)
The gameType names is: TeamDM and the namespace is teamDeathMatch.
#5
05/11/2011 (9:18 am)
That is the likely problem then. The code takes your gametype name and appends Game to the end of it and expects that as your function namespace.
if ($Server::MissionType $= "")
   $Server::MissionType = "Deathmatch"; //Default gametype, just in case
new ScriptObject(Game)
{
   // This line creates the function namespace to use.
   class = $Server::MissionType @"Game";
   superClass = GameCore;
};
That effectively takes the MissionType of Deathmatch and makes it's class DeathmatchGame and is what the script methods should be named for that gametype. TeamDM would be TeamDMGame. Capture becomes CaptureGame. CTF becomes CTFGame. etc, etc.
#6
05/11/2011 (5:44 pm)
Argh such a small thing once again, many thanks it works now.

I will just get another question in since were already rolling on
the Gamemode thing. If i want a GUI to display in this manner:
Connect > Load game > spawn camera > display GUI

Right now i cant seem to get it to work the way i want to. I have camera spawnning located in onClientEnterGame so that should in theory happen right when the game starts and it does, However if i do %game.GuiCallFunction to display the gui right after all the camera spawnning/score setting the gui file will be shown during the loading screen.

Best regards
Jonas
#7
05/11/2011 (6:19 pm)
Looking back over things I guess I could have been a bit more descriptive and verbose in the comments for the gametype stuff when I added it to T3D...

But glad you got it working! :)