Game Development Community

Capture the flag, problem with score

by Jonas · in Torque 3D Professional · 11/09/2010 (10:14 am) · 8 replies

Hi community!

I have been creating a capture the flag for a while but one thing i cannot figure out
is score. I have made a "test" trigger to kind of see if it can change the curret score
but so far i have been unsuccesful in the end i want to have blue_team_score and red but so far
i cannot get my foot in the door.

This is what i have so far:

function Flag_DropPoint::onEnterTrigger( %this, %trigger, %obj, %client, %game)
{
if(%obj.getInventory(RedMPFlag))
{
if(%obj.getInventory(BlueMPFlag))
{
echo("IF part is successful, deleting Flags");

%obj.decInventory(RedMPFlag, 1);
%obj.decInventory(BlueMPFlag, 1);
echo("Flags deleted properly");

echo("Canvas.pushDialog!");
canvas.pushDialog(flag_return);
Canvas.schedule(5500, popDialog, flag_return);

game.incScore(%client, 1);
echo("Function is now complete! check if score is changed?");
}
else
{
echo("You dont have the flags!");
}
}
}

So far it does nothing to the score at all ... the code is contained with in my game mode script.
My thought is that the gameCore is being a bitch and is simply overwriting the current game mode because
of unclarified something.
Is there even a way to create a completely new game mode 100% away from the gamecore.cs files reach without engine coding? It seems that everytime i try to create a new way of handling score it completely ignores it and uses gamecore.cs instead.

PS: the game core incscore function is only supposed to add score whenever a command is sent
however the only thing that happens is the second line:

messageAll('MsgClientScoreChanged', "", %client.score, %client.kills, %client.deaths, %client);

it ignores the first line which is score, Why? it gives me no error what so ever or even show a trace of
sending the command other then that second line of code.

Best regards
Jonas

About the author

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


#1
11/09/2010 (2:58 pm)
A little update on the problem:

I have made some tests and it is indeed calling the GameCore::incScore function within the GameCore script but it jumps over the score part and only prints the current score which of course is 0 0 0.

Also i recreated the IncScore function in the capture the flag game mode like this:

function Gamecore::incFLAGScore(%game, %client, %score)
{
echo("Function called!");
%client.score += %score;
messageAll('MsgClientScoreChanged', "", %client.score, %client.kills, %client.deaths, %client);
}

and it works like a charm... it dosent do anything but it calls the function but if i write it like this:

function CTF_game::incFLAGScore(%game, %client, %score)
{
echo("Function called!");
%client.score += %score;
messageAll('MsgClientScoreChanged', "", %client.score, %client.kills, %client.deaths, %client);
}

it does not find the function what so ever. Dont tell me that scoring is standardized to GameCore? also note that i cnaged the incscore to incFlagScore in the trigger as well.
#2
11/10/2010 (10:12 am)
I really need help with this it seems that however i twist and turn it the line: game.incScore(%client, 1); will only work in the already created functions and i cant find a reason why?

Is the scoring system hard coded into the engine itself? there is no answer to be had, neither is there any comments on the most important part of the entire scoring system why?

Best regards
Jonas
#3
11/10/2010 (10:34 am)
The way to create new game types is to write a package for them that contains the overrides for the functions in GameCore that your gametype needs to modify. If the override is not present then it defaults to using those in GameCore -- which are simply the old GameConnection class methods wrapped up in a different namespace.

A gametype package is then automatically called if the mission type is set in the levelInfo for your level.

Is "CTF_game" the namespace for your CTF package?


Unfortunately there is no example of how the gametype code should work, and my suggestion to revert back to using the old TGE/TGEa GameConnection methods fell on unresponsive ears. I added this functionality back before the FPS Kit got stripped to what it is now... and truth be told I'm not sure that it still works as it used to due to changes in the "core" code.
#4
11/10/2010 (11:13 am)
I see, thank you for the response. I have not created any package for my game mode since i did not have information that was needed however now i know and can modify acordingly.

Kind regards
Jonas
#5
11/12/2010 (12:02 am)
Yeah, looking back over that code I guess I was a little vague about how that works in my comments when I submitted that.

I've got some scripts for teambased gametypes like TeamDeathmatch and CTF (partially tested) lying around that drops right in if you want some example code to examine -- just send a message to me to the email found on my profile.
#6
11/13/2010 (9:53 am)
Sure thanks! i will be dropping in a email today

Kind regards
Jonas
#7
11/13/2010 (11:06 am)
Your OP looks to me like:

If you have the red flag, see if you have the blue as well or echo you don’t have flags.

If you don’t have the red flag it does not care at all whether you have the blue flag or not.
#8
11/13/2010 (11:54 am)
Thank you Christian,

i know i eventually need to fix that but right now i just need to get the trigger to work @ scoring points when doing so.