Game Development Community

Simple Torque level2level

by Jep Hest · in Technical Issues · 06/12/2008 (6:43 am) · 3 replies

Hi,

I am working with Torque for 3 weeks and I've build a world with some objects which can be collected. Now I want to make 10 missions which are all exactly the same, so I saved the level to level1.mis to level10.mis.

My problem: I want to make sure that when te player has picked up all items, he gets a dialog screen with "good work" and then he can click OK! and go to the next mission.

I looked on this forum and read the Single Player level exit but its to difficult for me to copy the code I need. I guess my problem is quite easy, I guess I can give the object.cs a function? But I do not know how...

I allready have this in my testmodel.cs:


can someone help me out? thanx!

function ItemData::create(%data)
{
// The mission editor invokes this method when it wants to create
// an object of the given datablock type. For the mission editor
// we always create "static" re-spawnable rotating objects.
%obj = new Item() {
dataBlock = %data;
static = true;
};
}

datablock ItemData(testModel)
{
category = "Items";
shapeFile = "~/data/shapes/testobject/testobject.dts";
};

datablock ItemData(testModel2)
{
category = "ItemsII";
shapeFile = "~/data/shapes/testobject/testobject2.dts";
};

function testModel::onCollision(%this, %obj, %col)
{
if(%col.getClassName() $= "Player")
{
%client = %col.client;
%client.score++;
commandToClient(%client, 'SetScoreCounter', %client.score);

%obj.delete();
%itemCount = Muntjes.getCount(); // de naam van de Simgroep

if(%itemCount > 0)
return;
// When Simgroup "Muntjes" is empty the player has won.
commandToClient(%client, 'ShowVictory', %client.score);
}
}

About the author

Recent Threads

  • Open URL from torque

  • #1
    06/13/2008 (5:53 pm)
    First Create a GUIpopupcontrol that is triggered when the player has completed all what he is supposed to do. I believe that is what you are asking for.

    Second, create a button on the GUIpopupcontrol that when you click it it will exit the game or load another level.
    I believe you put the code in the command section of the new button.

    An example would be the team implementation resource found on here. It sets two teams (Blue) and (Red). Depending on which button you pick is what the popupwill do. All you would need to do there is change the coding so that in the command line in the GUI is something along the lines of (endgame); or (loadnewmission);
    Whatever you have. Instead of (pickteamblue); or (pickteamred);

    Now I'm aware those aren't the actual commands, but you get the idea.

    Hope this was helpful.

    If you need any more help E-mail me.
    #2
    06/13/2008 (6:10 pm)
    Or just look at the end game dialog that torque has by default. You'll need to keep track of the items and trigger it when all the items are picked up and call it from there. The mission will automatically advance to the next one after x seconds.
    #3
    06/14/2008 (3:09 pm)
    Thanx for your comments, I am going to look at it on monday, thanx!!