PlayerVar - Per-Player Variables!

Expand and mod your server.
Post Reply
User avatar
SkillDude
Private First Class
Private First Class
Posts: 336
Joined: Sun Apr 01, 2007 4:50 pm
Location: United States

PlayerVar - Per-Player Variables!

Post by SkillDude » Sat Jul 14, 2012 1:34 pm

This is something I have wanted for a long time. trepan introduced veldrv awhile back for the 2.0.X servers which allowed for a physics driver to be specified with differing speeds. However, I felt this was limiting in that we did not have the power to modify any variable (Technically we did), so I decided to make a plugin with a more generic use.

Here is a plugin derived from trepan's for the 2.4.X servers. It is mostly a template for usage in further plugins.

What it does: Lets you send a Set Variable message to an individual client/player. This means that everyone can have a different set of variables running on their client! This opens up the possibility for many things, including player handicaps based on score (Slow down or speed up tanks), different bullet speeds. on a per player basis, along with even different effects showing up per player (Want the red team to see a red sky while the blue team sees a blue one?) Many new venues open up with the ability to change everyone's variables to a different set!

I would like to also mention how useful this could be for future custom flags. Give a flag that actually does slow tanks down, speed them up, faster/slower reloads, momentum, and more!

There is a limitation you have to keep in mind, the client actually sees the new variables with each change to them, but they aren't applied immediately. That is what is actually happening. So say we tried giving everyone different _shockOutRadius values. This won't work, since the shots look at what the current _shockOutRadius value is, and since it changes, it will be the same for everyone anyways. But values such as _tankSpeed, _tankAngVel, _wingsJumpCount, _friction, _skyColor, _radarLimit, and so on are only set when they are triggered by a variable modification notice. At least that is my understanding, so those can be set on a per-client basis. You can experiment to see which combinations work. There may be more fun hidden things I haven't found yet.

Enjoy, hope everyone finds it useful in some way or form or shape!

Below is a plugin sample showing how the skyColor is set to one of 5 picked colors whenever a player joins, so everyone sees a different color! Take this power and warp to your will!

You'll need bzfs.h to compile this, which brings up a few other dependencies you will need. They all come from the src/bzfs folder, so if you really want to, just take all those header file suckers and put them in the include/ directory before compile and you should be set.

Prototypes for the function are:

Code: Select all

sendPlayerBZDB(int playerID,string variable,string value);
sendPlayerBZDB(int playerID,string variable,float value);
Simply call one of these and boom, variable change gets sent to that player.

Here is a screenshot showing two clients on the same server playing with different sky colors:
Image

Released under the Public Domain, do what you will with it and harness the powers of variable changing! You can expect some very interesting things from me with this in the future.

[EDIT]: Thanks to blast for clarifying that the plugin is not able to be compiled with Windows due to its external dependencies outside of the BZFlag API. This had to be used in order to overcome such a feature.
Attachments
PlayerVar.cpp
PlayerVar - Random Sky Color on Join
(2.51 KiB) Downloaded 168 times
Last edited by SkillDude on Sat Jul 14, 2012 3:00 pm, edited 1 time in total.

User avatar
blast
General
General
Posts: 4736
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: PlayerVar - Per-Player Variables!

Post by blast » Sat Jul 14, 2012 2:07 pm

Keep in mind that changing variables per-player can cause issues since clients assume that everyone has the same set of variables. So, the clients make assumptions about various events. Changing graphical things like the sky color should not be a problem, however.

Also, this plugin bypasses the plugin API, so it will never work on Windows, and some day may not work on other operating systems if we were to utilize the 'visibility' feature of g++.
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image

User avatar
SkillDude
Private First Class
Private First Class
Posts: 336
Joined: Sun Apr 01, 2007 4:50 pm
Location: United States

Re: PlayerVar - Per-Player Variables!

Post by SkillDude » Sun Jul 15, 2012 12:26 am

In order to clarify some of the possibilities and functionality for using the plugin, I have attached a pdf document containing a list of all variables that have some impact in the game and whether or not they can be changed on a per-client basis.

The ones in dark green are 100% safe to use. Light green ones are safe to use but have a small catch to them, usually listed in the description. I wouldn't mess with anything of the yellow color variety unless you really have a reason to. Red ones are dysfunctional or almost impossible to use.

Most variables dealing with basic properties of tanks such as jumping, movement speeds, and flags, or the environment / graphics variables are able to be changed, which is more than enough to add quite a number of possibilities. Hope that users find the document useful if they plan to try and do anything with it.

Also, for users that want to throw down some client variables for testing (Basically, using what I used to test these), you can get a second plugin of mine attached below. It allows any user to perform the following command (Didn't care for permissions since it was, after all, for testing):

Code: Select all

/var # variable value

Ex. /var 1 _wingsJumpCount 15
Where # is the player slot number to send the variable to. (Just the number, no pound(#) sign in front) Variable is the variable name, and value is the actual value.

Anyways, that should be it for this plugin (Public Domain, of course). Just some finishing details for anyone that's curious about trying to use it.

I didn't consider it before, but the fact that some of the variables cause bullets not to shoot anymore could actually be used to take advantage of preventing players from shooting. Just a thought...
Attachments
VarModify.cpp
VarModify
(2.5 KiB) Downloaded 142 times
VarModify.pdf
VarModify Test Results Document
(240.14 KiB) Downloaded 189 times

User avatar
gnu-sense
Private First Class
Private First Class
Posts: 78
Joined: Wed Nov 22, 2006 1:21 am

Re: PlayerVar - Per-Player Variables!

Post by gnu-sense » Thu Jul 26, 2012 6:27 pm

Wow. The idea of this plugin... freaks me out. Apart form that it's so, um, hackish (because of the issues of different clients having different settings that blast mentions), it's that it stretches the idea of the game in a way that I have trouble with. While having different decorations (sky color) for different players may not be so much of an issue (they can do that with settings anyway), having different gameplay for different clients sounds like a bad idea, unless the server is arbiter of all of game state, which currently is not in the architecture. It's true that lag can mean that different players on the same server see "different games", but this could really push it to the extreme. I don't want to mention the c-word, but I am having trouble suppressing fears about that too.

Just thinking out loud.

gnu-sense

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests