Game Development Community

Working on a game in a 8 mile diameter/ how to implement it

by Jerry Moore · in Torque Game Engine · 07/18/2006 (9:24 am) · 2 replies

We are working a pretty good sized island.It is composed of two mile square mission areas set in a 4X4 array we're using the mission area as our trigger and modifying the exit mission area function. Now it was working, but right right now is not. No compile errors. However we have been getting run time errors.We have a 16 case switch statement to trigger on the mission number. What we need is a way of generating a value of %x=0
What we need to determine is whether a player is moving N,S,E,or west so that we can increment our mission number by + or - 1. If the character is moving east or west or + or - 4 if the character is moving North or south. Here is the exit mission code found in the game.cs.

function GameConnection::onLeaveMissionArea(%this)
{
%longitude = getword(MissionArea.Area,0);
%latitude = getword(MissionArea.Area,1);
%width = getword(MissionArea.Area,2);
%height = getword(MissionArea.Area,3);

%tf = %this.player.getTransform();
%x = getword(%tf,0);
%y = getword(%tf,1);
%rotation = getwords(%tf,3,6);

if (%x < %longitude)
 %x += %width;
else if (%x > (%longitude + %width))
%x -= %width;
if (%y < %latitude)
 %y += %height;
else if (%y > (%latitude + %height))
 %y -=  %height;

%found = ContainerRayCast (%x SPC %y SPC "1000", %x SPC %y SPC "-1000",
                                        $TypeMasks::TerrainObjectType, %this.player);
%newPosition = getwords(%found,1,3);
%this.player.setTransform(%newPosition SPC %rotation);

//%missionNum = %oldMission + (%x * 1 ) + (%y * 4 );
 
switch(%missionNum)
{
case 0:  $scene ="fps/data/missions/m1.mis";
case 1:  $scene ="fps/data/missions/m1.mis";
case 2:  $scene ="fps/data/missions/m2.mis";	
case 3:  $scene ="fps/data/missions/m3.mis";	
case 4:  $scene ="fps/data/missions/m4.mis";	
case 5:  $scene ="fps/data/missions/m5.mis";	
case 6:  $scene ="fps/data/missions/m6.mis";
case 7:  $scene ="fps/data/missions/m7.mis";	
case 8:  $scene ="fps/data/missions/m8.mis";	
case 9:  $scene ="fps/data/missions/m9.mis";
case 10: $scene ="fps/data/missions/m10.mis";	
case 11: $scene ="fps/data/missions/m11.mis"; 	
case 12: $scene ="fps/data/missions/m12.mis";	
case 13: $scene ="fps/data/missions/m13.mis";	
case 14: $scene ="fps/data/missions/m14.mis";	
case 15: $scene ="fps/data/missions/m15.mis";	
case 16: $scene ="fps/data/missions/m16.mis";	
default: $scene ="fps/data/missions/m1.mis";
}
%oldMission= %missionNum;
       
LaunchMission( $scene, 0,0 );

}

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

any suggestions or help would be appreciated.

#1
07/18/2006 (3:32 pm)
This is exactly what I have been asking about on the tread Large Worlds. Using GameConnection::onLeaveMissionArea(%this) to trigger missionLoading. What is the difference in using GameConnection::onLeaveMissionArea AND Player:: onLeaveMissionArea? Any advice about using onLeaveMissionArea would be helpful.

Try:
Leaveing Mission North (y > 0 && ((x > west limit) &&(x < east limit)))
Leaveing Mission South( y < 0 && ((x > west limit) &&(x < east limit)))
Leaveing Mission East (x > 0 && ((y > south limit) &&(y < north limit)))
Leaveing Mission West (x < 0 && ((y > south limit) &&(y < north limit)))

Thanks Jesse
#2
07/26/2006 (1:29 pm)
@Jerry

Are you still having problems?

switch(%missionNum)
{
case 0: $scene ="fps/data/missions/m1.mis";
case 1: $scene ="fps/data/missions/m1.mis";
case 2: $scene ="fps/data/missions/m2.mis";
case 3: $scene ="fps/data/missions/m3.mis";
case 4: $scene ="fps/data/missions/m4.mis";
case 5: $scene ="fps/data/missions/m5.mis";
case 6: $scene ="fps/data/missions/m6.mis";
case 7: $scene ="fps/data/missions/m7.mis";
case 8: $scene ="fps/data/missions/m8.mis";
case 9: $scene ="fps/data/missions/m9.mis";
case 10: $scene ="fps/data/missions/m10.mis";
case 11: $scene ="fps/data/missions/m11.mis";
case 12: $scene ="fps/data/missions/m12.mis";
case 13: $scene ="fps/data/missions/m13.mis";
case 14: $scene ="fps/data/missions/m14.mis";
case 15: $scene ="fps/data/missions/m15.mis";
case 16: $scene ="fps/data/missions/m16.mis";
default: $scene ="fps/data/missions/m1.mis";
}

The switch statement can be changed to the following:
%missionNum++;
$scene ="fps/data/missions/m" @ %missionNum @ ".mis";

Jesse