Game Development Community

Mission boundry

by Jules · in Torque 3D Professional · 08/01/2010 (5:59 pm) · 13 replies

Hi, I'd like to prevent players from going over a certain area in the game, how do I go about setting a mission boundry, and display "A force prevents you from going any further". ?

Has LevelInfo.worldSize been added?

#1
08/01/2010 (6:39 pm)

Use MissionArea and the onEnterMissionArea and onLeaveMissionArea callbacks on PlayerData to display the message. To prevent the player from exiting the area, you could either manually affect the steering or use PhysicalZones along the boundaries.
#2
08/01/2010 (6:54 pm)
Thanks Rene. I couldnt find anything on this when I searched.
Probably down to "Mission Area" a space in between, without it brought up some results.
#3
08/01/2010 (6:59 pm)
Add a MissionArea to your level and tweak the boundaries to suit:
new MissionArea(GlobalMissionArea) 
{
   canSaveDynamicFields = "1";
   Area = "-100 -100 200 200";
   flightCeiling = "300";
   flightCeilingRange = "20";
   Enabled = "1";
   locked = "true";
};
The Area is a XY dimension box defined like so: Xstart Ystart Xend Yend
The flightCeilingwill set a Z value for height of the MissionArea box. This field was primarily used to restrict the height range of vehicles in a mission.
Think of the MissionArea as a giant trigger, and make sure it is named "GlobalMissionArea" as that is the name the c-code is looking for.

The stock scripts (FPS Example, Full Template) do not implement any methods for doing anything when exiting/entering the MissionArea other than a series of callbacks that send a message to the console and/or ChatHUD.

Take a look in player.cs and find
function Armor::onLeaveMissionArea(%this, %obj)
{
   //echo("c4Leaving Mission Area at POS:"@ %obj.getPosition());

   // Inform the client
   %obj.client.onLeaveMissionArea();

   // Damage over time and kill the coward!
   //%obj.setDamageDt(0.2, "MissionAreaDamage");
}

function Armor::onEnterMissionArea(%this, %obj)
{
   //echo("c4Entering Mission Area at POS:"@ %obj.getPosition());

   // Inform the client
   %obj.client.onEnterMissionArea();

   // Stop the punishment
   //%obj.clearDamageDt();
}
These in turn hand off the messaging to the game connection related methods in game.cs
function GameConnection::onLeaveMissionArea(%this)
{
   // The control objects invoke this method when they
   // move out of the mission area.

   messageClient(%this, 'MsgClientJoin', 'c2Now leaving the mission area!');
}

function GameConnection::onEnterMissionArea(%this)
{
   // The control objects invoke this method when they
   // move back into the mission area.

   messageClient(%this, 'MsgClientJoin', 'c2Now entering the mission area.');
}
That gets your enter/leave messages displayed in the client's chatHud.

The damage over time function when leaving the MissionArea is something I left in there, but is commented out so as not to alarm someone when first placing the MissionArea through the Editor. Initial placement is quite wonky and if I recall correctly the MissionArea box doesn't render -- although I believe there was a forum post that showed how to get it to draw while in the Editor.

If you want to display an additional HUD image (such as a warning or out-of-bounds graphic you would place a commandToClient call in the GameConnection methods to enable/disable the relevant hud/gui as needed.

Stopping the player when he/she reaches the MissionArea boundary will need some code added to the player callbacks. Check out this Resource which implements a bounceback approach through script, as well as a simulated forcefield effect using particle effects. You could easily modify this to simply stop the player and preventing further movement or even teleport the player to another location (useful for warping to other side of MissionArea.

EDIT: another alternative is to use Triggers or PhysicalZones.
#4
08/01/2010 (7:00 pm)
Yeah, searching the forum really is an issue of its own.

BTW, IIRC there is (or at least was) some example mission in T3D that made use of MissionArea and the onEnter/onLeave callbacks to display a warning and hurt the player. Might come in handy.

As for pushing the player back into the area, I think PhysicalZones really are the easiest solution.

//Edit: posted in parallel with Michael's post above.
#5
08/01/2010 (7:01 pm)
Thanks for the detailed reply Michael. I'll give it a go..
#6
08/01/2010 (7:01 pm)

And there you go... Great post Michael :)
#7
08/01/2010 (7:04 pm)
Quote:
there is (or at least was) some example mission in T3D that made use of MissionArea and the onEnter/onLeave callbacks to display a warning and hurt the player. Might come in handy.
The Out-of-bounds GUI warning (with sound) and damage is something that existed in the FPS Genre Kit but they were removed when it was stripped down to the FPS Example and Full Template.
#8
08/01/2010 (7:34 pm)
Thanks for the heads up Rene, I'll have a look at that also.

Edit: thanks for clearing that one up Michael. Ahh yes I remember the force field resource.. I was going to use that on my monorail some time back, but never actially got around to finishing it.
#9
11/02/2010 (5:37 pm)
Hey guys, do you know how I'd apply this to Wheeled Vehicles as they go straight through mission boundries?
#10
11/02/2010 (6:45 pm)
The code appears to be there already for mission boundry on vehicles, but can't get it to work.

Edit: my mistake - it wasn't, at least until I added it some time back after looking at my change log :)
#11
11/02/2010 (7:24 pm)
Quote:The code appears to be there already for mission boundry on vehicles, but can't get it to work.
Is it? I found a thread or resource somewhere on this site once on how to do this, just don't remember where =/. Anyways, maybe this old resource can help you out, not sure if it is the same as the one i mentioned tho (linky).

If it doesn't work, compare the player's mission area functions with the vehicle's.
#12
11/02/2010 (7:30 pm)
Thanks Marcus. I did find that resource and just comparing things.. not sure if I need to use VehicleData or Vehicle for the function calls. The enginge code is there, but not the function calls in vehicle.cs - I'll post an update if I get it working :)
#13
11/02/2010 (7:46 pm)
all working now... :) thanks for the resource some of that is useful.