Thursday, August 30, 2007

Quick Teleporter




First of all there is a resource that has been around for some time click here. I have never used it, so I do not know how it works.

Also I have been working on a generic trigger call teleporter, it should be a cheap way to achieve similar results. This will not show fancy particle emitter or lights. You can add it on top of this later

This particular trigger assumes that you will have a single dynamic field that will contain the coordinates.

First of all go to your server directory server/scripts/triggers.cs and add this code at the end of the file:


datablock TriggerData(Teleporter)
{
tickPeriodMS = 100;
};

//-----------------------------------------------------------------------------
function Teleporter::onEnterTrigger(%this,%trigger,%obj)
{
echo("Teleporter::onEnterTrigger --IN");
Parent::onEnterTrigger(%this,%trigger,%obj);

// Print out some debug info ;)
// Get the number of dynamic field in the trigger
echo("# Of Indx : " @ %trigger.getDynamicFieldCount());
// in my case I just have one so I use the first index
echo("Index 0 : " @ %trigger.getDynamicField(0));

// here is where we do the real work
%str = %trigger.getDynamicField(0);
// it should remove the name of the dynamic field and leave the coordinates
%coords = removeField(%str, 0);

// for educational purposes print out the string and the coordinates
echo("The String : " @ %str);
echo("Coordinates : " @ %coords);

// this transform will take you to the place that you want!!
%obj.setTransform(%coords);
}
//-----------------------------------------------------------------------------

function Teleporter::onLeaveTrigger(%this,%trigger,%obj)
{
Parent::onLeaveTrigger(%this,%trigger,%obj);
}

function Teleporter::onTickTrigger(%this,%trigger)
{

Parent::onTickTrigger(%this,%trigger);
}


The trigger should look like this on your *.mis file where coord is the dynamic data field


new Trigger(TestTrigger) {
canSaveDynamicFields = "1";
position = "647.288 -1344.81 112.729";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "Teleporter";
polyhedron = "0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000000 0.0000000 -1.0000000 0.0000000 0.0000000 0.0000000 1.0000000";
coord = "-9 -1414 50 0 0 1 0";
};



Hope it helps

Juanma

Edited on Aug 30, 2007 11:30

No comments: