Bypass BZFS API - Teleportation - Enable instant movement with nearly no negative effects

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
User avatar
Zehra
Private First Class
Private First Class
Posts: 921
Joined: Sun Oct 18, 2015 3:36 pm
Location: Within the BZFS API and Beyond it
Contact:

Bypass BZFS API - Teleportation - Enable instant movement with nearly no negative effects

Post by Zehra »

I've seen a lot of really nice stuff over the years, but perhaps this will be my favorite one of this year.

You can now teleport players or spawn them elsewhere without needing to "kill" them. (Useful for not flooding the chat console.) The only real drawback which is currently held, is simply the flag dropped and flag grabbed messages. (Which if no flags are being held, zero messages will appear... in essence true teleportation.)

As for what uses this can have, it will be covered right after the initial guide on how to do it:

For the additional headers needed to make this work are: bzfs.h and GameKeeper.h

The way I compile stuff causes it to look like this:

Code: Select all

#include "bzfsAPI.h"
#include "../src/bzfs/bzfs.h"
#include "../src/bzfs/GameKeeper.h"
Keep in mind that you simply can't do things as is, since there is by default no utility functions to set the player status to dead.

Here is what I use to do it:

Code: Select all

int SetPlayerDead(int playerID) {
    int status = 0;
    GameKeeper::Player *p = GameKeeper::Player::getPlayerByIndex(playerID);
    if (p == NULL) {
        status= -1;
    } else {
        if (p->player.isObserver()) {
            status= -2;
        } else {
            if (p->player.isAlive()) {
                status=1;
                p->player.setDead();
                p->player.setRestartOnBase(false);
            } else {
                status=2;
            }
        }
    }
    return status;
}
This may possibly be simplified much more, but this does prove to be useful when debugging some aspects.

Note: A spawn event is always triggered upon this version of "teleportation". If you wish to customize the spawns, the bz_eGetPlayerSpawnPosEventfollowing event must be registered in the Init section of your plug-in:

Code: Select all

void Sample::Init( const char* /*commandLine*/ )
{
    Register(bz_eGetPlayerSpawnPosEvent);
}
If you do not modify the spawn, the "teleportation" will be the spawning system.

For the teleport itself, this is done via the following:

Code: Select all

SetPlayerDead(playerID);
playerAlive(playerID);
And this is how the teleportation aspect works. (Note: In this case, the playerAlive() function is used to force spawn the player.)

---

Since this doesn't quite explain what is possible, we now have the options of creating previously impossible game modes. Objects which can be accessed per-team, horizontal teleporters, instant teleportation, flags with kickback..etc

We can expect to see some very interesting game modes and concepts rolled out in 2024. (And new maps to go with them.)

-Zehra
Those who are critical of me, I'll likely be the same of them. ~Zehra
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra

See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.

Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
Post Reply