Game Development Community

Putting logic into a mission file

by Lee Latham · in Torque Game Engine · 01/27/2008 (7:12 pm) · 4 replies

I KNOW I've seen this done, but for the life of me I can't find it in the forums.

How can you put logic into a mission file? For example, I want to put a flag object into the mission, but only if $CTF server variable is true. You can't just throw an if statement in or it won't compile the mission.

?

#1
01/29/2008 (3:51 pm)
Why not just create a flagbase object, put that into the map instead of the flag object itself.
Durring initialization, check for the CTF variable and if true, create a flag instance and mount to the base.

You could even then use the same flagbase object in different game types, like as a point to spawn a primary target for destruction game types (like a generator, computer core, holy relic, or magic cauldron), or special powerups for deathmatches (extra damage, double points, invisibility, ect...).



Putting the logic in the mission file seems more useful for special triggers, unique objects, and the like.
#2
01/29/2008 (4:08 pm)
I see what you're saying. Well, it's not a bad idea--I've kindof gotten resigned to doing it in script, one way or another. But there are other things that I thought would be nice to do in the mission file as well, here and there, so I'd just like to know how to do it.

The main thing I wanted to avoid is having to have a separate mission file for different game types, as that would be a maintenance headache, and your idea certainly helps with that--thanks!

But mostly I just don't grasp the context of the mission file, I guess.
#3
01/29/2008 (4:09 pm)
You can put logic into the mission file at the bottom of it, after the line
//--- OBJECT WRITE END ---

so you could put a named simGroup up above in the body of the mission, like
new SimGroup(LogicControlledGroup) {
   };

...

};
//--- OBJECT WRITE END ---

if ($CTF)
{
   %obj = new FlagObject() { blah blah blah };
   LogicControlledGroup.add(%obj);
}
#4
01/29/2008 (4:45 pm)
Ohhhhhhhhhhhhhh. You know now that I think about it it was you, Orion, who posted what I'd seen before.

I see now. It's just scripting outside of the actual mission data, but in the same file.

Cool, thanks!