Better Teletriggers

Suggestions you have for the Annihilation mod.

Moderator: Moderators

Post Reply
Perrinoia
Suggestion bot 10,000
Posts: 11185
Joined: Sat May 04, 2002 11:00 pm
Location: Rhode Island

Better Teletriggers

Post by Perrinoia » Sat Nov 21, 2009 8:10 am

The following code does not require map makers to edit their mission files in a text editor to use. You don't even need to add teleport prefabs to the editor. All the mappers have to do is put a trigger and a drop point in the same group, and name the trigger "Teleport". They can also name the DropPointMarker what ever message they want the teleported players to recieve (including a custom sound effect). Also, the teleport won't lead to drop points that are blocked off by deployables, mines, players etc...

Code: Select all

function GroupTrigger::onEnter(%this, %that)
{
    %type = getObjectType(%that);
    if(%type == Player && %type == Vehicle)
    {
        if(!eval(Object::getName(%this) @"::onEnter("@ %this @", "@ %that @");"))
            Group::iterateRecursive(getGroup(%this), GameBase::virtual, "onTrigEnter", %that, %this);
    }
}

function Teleport::onEnter(%this, %that)
{
    %Group = getGroup(%this);
    %Owner = Player::getClient(%that);
    %Count = Group::objectCount(%Group);
    %Drops = newObject("DropPoints", SimSet);
    for(%= 0; %< %Count; %i++)
    {
        %Point = Group::getObject(%Group, %i);
        %Place = GameBase::getPosition(%Point);
        %Block = newObject("Obstructions", SimSet);
        %Masks = $SimPlayerObjectType | $StaticObjectType | $MineObjectType;
        if(GameBase::getDataName(%Point) == DropPointMarker && containerBoxFillSet(%Block, %Masks, %Place, 2, 2, 2, 0) < 1)
            addToSet(%Drops, %Point);
        deleteObject(%Block);
    }
    %Count = Group::objectCount(%Drops);
    if(< %Count)
    {
        %Point = Group::getObject(%Drops, floor(getRandom() * %Count));
        %State = Object::getName(%Point);
        GameBase::playSound(%that, ForceFieldOpen, 0);
        GameBase::playSound(%Point, ForceFieldOpen, 0);
        if(%State != "Drop Point1")
            Client::sendMessage(%Owner, 2, %State);
        else
            Client
::sendMessage(%Owner, 2, "You have been teleported!~wShieldHit.wav");
        GameBase::setPosition(%that, GameBase::getPosition(%Point));
        GameBase::setRotation(%that, "0 0 "@ getWord(GameBase::getRotation(%Point), 2));
        GameBase::startFadeIn(%that);
    }
    else
        Client
::sendMessage(%Owner, 2, "Teleport malfunction: No unobstructed waypoints.~wError_Message.wav");
    deleteObject(%Drops);
}
 


Oh, and mappers will be able to define their own custom trigger functions too, for instance:

Code: Select all

function KillZone::onEnter(%this, %that)
{
    
GameBase::applyDamage(%that$CrushDamageTypeGameBase::getDataName(%that).maxDamageGameBase::getPosition(%this), "0 0 0""0 0 0", %this);
    
Item::setVelocity(%thatVector::neg(Item::getVelocity(%that)));
}
 

Post Reply