Plugins That Adjust Tank Physics

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
User avatar
Agatha
Private First Class
Private First Class
Posts: 26
Joined: Thu Jul 13, 2017 2:20 am

Plugins That Adjust Tank Physics

Post by Agatha »

Hi,

I am making a new plugin called "Gliders", with a new flag, "GL". Gliders function like WG but with two differences: first, GL cannot jump while already flying. Second, gravity's keyed from horizontal speed: moving faster means slower descent, and vice-versa.

I do not understand how to make that work. One thing I thought of was adjusting the new state's downward velocity within the update event:

Code: Select all

virtual void GliderFlagPlugin::Event(bz_EventData* event_data) override {
	switch (event_data->eventType) {
		//...

		case bz_ePlayerUpdateEvent: {
			bz_PlayerUpdateEventData_V1* data = static_cast<bz_PlayerUpdateEventData_V1*>(event_data);
			if ( data->state.falling && strcmp(bz_getPlayerFlag(data->playerID),"GL")==0 ) {
				float* velocity = data->state.velocity;

				float max_speed = static_cast<float>(bz_getBZDBDouble("_tankSpeed"));

				float min_sink_rate = static_cast<float>(bz_getBZDBDouble("_minGliderSinkRate"));
				float max_sink_rate = static_cast<float>(bz_getBZDBDouble("_maxGliderSinkRate"));

				float speed = std::sqrt( velocity[0]*velocity[0] + velocity[1]*velocity[1] );

				float sink_rate = lerp( max_sink_rate,min_sink_rate, speed/max_speed );
				velocity[2] = std::max( sink_rate, velocity[2] );
			}

			break;
		}

		//...
	}
}
However, that did not work (it doesn't actually adjust effective gravity and you can't drive while flying). It also occasionally crashed my test server. Not sure my code's even reasonable, because I haven't been able to see anything different...

How should I write it instead?

-A
-> Stagnation is playing the same map for literal decades. Take down Apoc/Urban/HiX/Duc!
-> "It takes losing a lot to learn how to win a little bit." / My guide to strategy.
-> My statistics and avatar artwork.
User avatar
Zehra
Private First Class
Private First Class
Posts: 915
Joined: Sun Oct 18, 2015 3:36 pm
Location: Within the BZFS API and Beyond it
Contact:

Re: Plugins That Adjust Tank Physics

Post by Zehra »

There currently is no officially supported method of doing so.

It looks like you may be attempting to do something similar to what trepan did some years back with Velocity Drivers in 2.x.
(This is similar to what was done in the "zombie" plug-in which included "team switching".)

A 2.4.x plugin exists which would allow changing up some of the "needed" variables. The PlayerVar plug-in may give some ideas on where to look, but once again, it is not something officially supported.

Also, the flag effects, such as driving in the air, are hard coded to specific flags in the current protocol, so players won't be able to "steer" their tanks in the air.

What did come to mind for some basic switching of movement variables was the API access to the "handicap" system, but it would not provide any effect for altering or adjusting gravitational values per player.

-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
User avatar
blast
General
General
Posts: 4931
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Plugins That Adjust Tank Physics

Post by blast »

There isn't even an unofficial way of doing this. It's simply not possible without forking the game and actually adding the flag directly to the code.
"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
Agatha
Private First Class
Private First Class
Posts: 26
Joined: Thu Jul 13, 2017 2:20 am

Re: Plugins That Adjust Tank Physics

Post by Agatha »

Hmmm, that's disappointing. Perhaps it would be simpler to alter ordinary WG? That would prevent WG and gliders being used together, but would only require adjusting descent rate. Perhaps that's easier?

Also, may I suggest maybe thinking about adjusting the future API so that plugins like this can be accommodated? Not solely for me, of course, but for expanding what's possible with plugins.
-> Stagnation is playing the same map for literal decades. Take down Apoc/Urban/HiX/Duc!
-> "It takes losing a lot to learn how to win a little bit." / My guide to strategy.
-> My statistics and avatar artwork.
User avatar
tainn
Private First Class
Private First Class
Posts: 278
Joined: Sun Nov 18, 2018 7:25 pm
Location: phantom_zone;

Re: Plugins That Adjust Tank Physics

Post by tainn »

For what it's worth, Wings play alone can be changed relatively a lot through adjusting the server variables that affect WG in specific. It cannot change it as much as requested in the OP, but with some clever map creation, it can already be a lot.

There's four of them, in specific:
  • _wingsGravity
  • _wingsJumpCount
  • _wingsJumpVelocity
  • _wingsSlideTime
Adjusting the gravity (low), flap count (0) and slide time (high) could somehow imitate the aspect of gliding. Jump (low) could also be adjusted so you don't have to kill the flap count entirely.
User avatar
Zehra
Private First Class
Private First Class
Posts: 915
Joined: Sun Oct 18, 2015 3:36 pm
Location: Within the BZFS API and Beyond it
Contact:

Re: Plugins That Adjust Tank Physics

Post by Zehra »

Perhaps a hybrid model may provide satisfactory results.

If we use both per-player adjustment of variables and the wings flag.

Player grabs "Glider" flag, but upon dropping it, they are given a "wings" flag with the variables set to emulate the "Glider" flag. Might want to notify either the player using the glider flag or all users, which is potentially annoying, if for all users.

Then it's simply a matter of setting the variables on certain triggers.

But then again, this is all not ideal and does have some issues which may prove to be sufficiently problematic.

-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
User avatar
blast
General
General
Posts: 4931
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Plugins That Adjust Tank Physics

Post by blast »

Per-player adjustment of BZDB isn't something that should be used. It requires bypassing the bzfs API, and that will be actively blocked in future (and current?) versions of the code through export visibility controls. It can also have unpredictable results since the game is designed around the server and all clients having the same values.
"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
Agatha
Private First Class
Private First Class
Posts: 26
Joined: Thu Jul 13, 2017 2:20 am

Re: Plugins That Adjust Tank Physics

Post by Agatha »

I did not know about those parameters of WG—very interesting. I just tried them out. Slide doesn't work how I'd expect, but the real show-stopper with altering WG with these parameters is again descent rate. Falling gliders should follow linear paths, not parabolic like WG. And even more, descent rate must be controllable (e.g. by forward velocity), because otherwise you cannot e.g. match your opponent's elevation to attack, nor drop faster to evade. That's rather the whole point of fighting with gliders.

I can think of various parameters one could add for WG that would allow me to make gliders, but AFAIK those parameters would involve changing (generalizing) the internal physics of WG. Like before, I think one should instead expose those physics details so that plugins can mess with them.
-> Stagnation is playing the same map for literal decades. Take down Apoc/Urban/HiX/Duc!
-> "It takes losing a lot to learn how to win a little bit." / My guide to strategy.
-> My statistics and avatar artwork.
User avatar
tainn
Private First Class
Private First Class
Posts: 278
Joined: Sun Nov 18, 2018 7:25 pm
Location: phantom_zone;

Re: Plugins That Adjust Tank Physics

Post by tainn »

Since you phrased this last post the way you did, perhaps you'd be interested to know that the physics of WG weren't always the way they are now. There used to be no vertical momentum on default, which made the flag even more powerful than it is now. Which says a lot, considering it is nowadays still considered to be—generally—the most powerful flag in the game.
User avatar
alfa1
Private First Class
Private First Class
Posts: 168
Joined: Tue Dec 04, 2012 10:21 pm

Re: Plugins That Adjust Tank Physics

Post by alfa1 »

Agatha: I think I understand you want to make the glider go up again but without making another flap... and, as blast said, this is not possible on this game protocol/model. A thing I undersand is that BZ is a simple game, then we have these flags which are not mean to be too complex or sophisticated; I remember it's something the maintainer wants to be kept (in example: don't make the tank turret/cabin to turn). Then, as it is a simple game, you should just be satisfied with Wings and its variables, as in creating the desired effect or an approximated one with this flag (I remember Channel Crossing had a Wings which was rather hard to use; rather similar to a glider). (In the other hand, and I am not experienced here, we are allowed to create custom flags, but within certain limits, again; like in some nowadays maps.)
User avatar
Zehra
Private First Class
Private First Class
Posts: 915
Joined: Sun Oct 18, 2015 3:36 pm
Location: Within the BZFS API and Beyond it
Contact:

Re: Plugins That Adjust Tank Physics

Post by Zehra »

Some BZDB variables do not impact the game play directly in any way.
These are some variables which would be nice if we could modify, since it would allow for more innovative game play.
I'd imagine new custom flags or being able to perform some nice effects on flag captures..etc
Sky colours vary per team on flag captures, radar enhanced "flags", seer grants more radar coverage, ground lights appear based on team strength, fog does not appear for observers, hiding team flags on radar based on custom mode.

Game play mechanics decoupled from flags was asked for, but in the next planned major release, it's decoupled from flag types, which is good, although it could be better.
Ideally we'd be able to grant or remove effects individually, regardless of flags, so as to create new possibilities, such as altering the method of advantage. (Think of slow turning lasers, quick turning, no jumping guided missiles...etc)
The idea being to allow a way for innovation to drive the next generation of game play.

BZ is a simple game, I do agree, but simplicity shouldn't be used as the argument for limiting the game play.
For instance, if we really did want simplicity, we'd go back to the style of game play of a certain trademarked name.
The thing is simplicity is used as the argument against innovation, and innovation is not complexity. (Frequently innovations tend to be complex, but that does not mean that innovation itself is complex.)

There's only so much you can do with player positions, scores, spawns, deaths, flags and world weapons.
(Personally I think the limits of server settings, variables and the API are being reached in some fields and that's what is causing the feel of where innovation has hit stagnation, since not every idea is a good one and simply a lot of what could be done, has already been done or suggested.)

-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
User avatar
tainn
Private First Class
Private First Class
Posts: 278
Joined: Sun Nov 18, 2018 7:25 pm
Location: phantom_zone;

Re: Plugins That Adjust Tank Physics

Post by tainn »

Zehra wrote: Sun Aug 16, 2020 5:41 pmThere's only so much you can do with player positions, scores, spawns, deaths, flags and world weapons.
No, there is not.

The game is BZFlag, and the platform for creation is vast. If you want something completely different, either play a different game, or better yet, create one anew.

BZFlag allows excellent diversity in different gameplay, should the map maker be talented and willing enough to deliver. The scope of what is and is not theoretically possible is limited to what BZFlag fundamentally is.

Now you have a choice. Try your creativity to deliver on a BZFlag platform, or leave for some external pursuit.
User avatar
Agatha
Private First Class
Private First Class
Posts: 26
Joined: Thu Jul 13, 2017 2:20 am

Re: Plugins That Adjust Tank Physics

Post by Agatha »

@tainn, That's extremely parochial IMO. And hostile, TBH.

Anyway, returning on topic, how about a `_terminalVelocity`, or the like, server setting that defines maximum downward speed? It's backward-compatible, makes sense for other contexts, and perhaps is not too difficult to create. Or perhaps `_tankSpeed` should take 2 (horizontal, vertical) or 4 (forward, backward, falling, jumping) speeds?
-> Stagnation is playing the same map for literal decades. Take down Apoc/Urban/HiX/Duc!
-> "It takes losing a lot to learn how to win a little bit." / My guide to strategy.
-> My statistics and avatar artwork.
User avatar
Zehra
Private First Class
Private First Class
Posts: 915
Joined: Sun Oct 18, 2015 3:36 pm
Location: Within the BZFS API and Beyond it
Contact:

Re: Plugins That Adjust Tank Physics

Post by Zehra »

tainn wrote: Sun Aug 16, 2020 9:50 pm No, there is not.

The game is BZFlag, and the platform for creation is vast. If you want something completely different, either play a different game, or better yet, create one anew.

BZFlag allows excellent diversity in different gameplay, should the map maker be talented and willing enough to deliver. The scope of what is and is not theoretically possible is limited to what BZFlag fundamentally is.

Now you have a choice. Try your creativity to deliver on a BZFlag platform, or leave for some external pursuit.
The obvious should generally not need pointing out, but in case, it seems worthwhile to do so.
The words specified would have been excessively lengthy if said as a complete documentation of every API event, function and data type provided by the BZFS API.

Also, if when reading words in their context, the meaning is quite clear.
One, the limitations of the API are being felt.
Two, this is due to what currently can be done.
Three, not every modification or plug-in would be found enjoyable or fun. (Which is a partial reason for current requests and development.)
Four, the you provided is a massive over simplification of the entire subject, so feel free to correct me if I am wrong.

Contradiction found:
So technically, if one creates, they are creating something different. So they should be playing a different game or creating a new one.
Based on the oversimplification, anyone who creates maps, scripts, plug-ins, bots, server mods, should play another game or make one themselves.

Providing a history lesson, since what was specified was regarded to the "wings" flag in regards to game play mechanics of said flag.
Around the time when "wings" was introduced to the game, some time later, the initial version of the "bzfs api" was created.
This was to encourage people to build stable server mods which did not require modifying the server to work to introduce a new feature or mode.
(This meant more stability and less "invasive" or "hacky" methods of introducing features to the game itself.)
In addition, many map makers took advantage of the new features provided by plug-ins to enhance maps and make them more fun and exciting.

It's no surprise when many are discouraged and leave. ("Create, make or leave" is what they were told.)

---

The following variables would be nice if they were opened up to modifying per player.
  • _drawCelestial
  • _drawClouds
  • _drawGround
  • _drawGroundLights
  • _drawMountains
  • _drawSky
  • _fogMode
  • _fogDensity
  • _fogNoSky
  • _fogEnd
  • _fogColor
  • _forbidHunting
  • _forbidIdentify
  • _forbidMarkers
  • _hideFlagsOnRadar
  • _hideTeamFlagsOnRadar
  • _latitude
  • _longitude
  • _noClimb
  • _radarLimit
  • _shotsKeepVerticalVelocity
  • _skyColor
-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
User avatar
macsforme
General
General
Posts: 2069
Joined: Wed Mar 01, 2006 5:43 am

Re: Plugins That Adjust Tank Physics

Post by macsforme »

As blast said, you would probably implement this new flag in the game directly, not via the API. One of the criteria for new flag designs accepted into the game is that they should be distinct from and not too similar to flags that we already have. The idea you shared sounds generally similar to Wings so far, so you may want to explore ways to make it more distinct if getting this flag into the game is a path you want to pursue.
User avatar
tainn
Private First Class
Private First Class
Posts: 278
Joined: Sun Nov 18, 2018 7:25 pm
Location: phantom_zone;

Re: Plugins That Adjust Tank Physics

Post by tainn »

Excuse me, allow me to perhaps word my previous comment differently, because it might have been misunderstood.

I am not against changes or further development of the game. Mentioning of such matters also does not bother me, nor would I ever try to beat down a person who would be trying to make a positive change to the game or the community.

What I dislike, however, is that it appears to have become a trend recently to criticize the current state of the game, saying how only a very limited amount of different gameplay is possible. As a map maker myself, I highly disagree. As mentioned in my previous post, the platform is vast. And if one is willing to juggle with different objects, their behavior, server variables, as well as possibly the most major factor of all—map built itself, then one can deliver something new. A new experience where players of this community can have fun. It is possible.

As such, I don't mind revolutionary ideas. But I dislike criticism and stating how revolutionary ideas are mandatory, when I have yet to see you utilize the current platform as is and see you show some actual creativity.

When I said the platform is BZFlag, I did not mean that it cannot or should not be changed. I meant to say that the work the predecessors have put into it should be respected, and that can be done by actually utilizing the platform through being creative, not just making something relatively dull, hitting an idea roadblock, throwing the hands in the air and saying "Well, I'd need core changes to get any further".

I'm not saying core changes wouldn't be nice to see, but they would many times be overkill for what is trying to be achieved in the first place, and even more times be a mere compensation for the creator's lack of creativity.

Also, I agree with macsforme.
User avatar
alfa1
Private First Class
Private First Class
Posts: 168
Joined: Tue Dec 04, 2012 10:21 pm

Re: Plugins That Adjust Tank Physics

Post by alfa1 »

Just to add and remind: BZFlag is, already, a mature game; it is 2.4.20 version and it is approximatedly 30 years old (same as GNU/Linux; MS Windows is about 35; Apple, about 45). "Mature" in the sense it is very usable or advanced on its usable features and has not big errors (though, software can always be improved, of course). Also, note it has its own 3D engine/structure and (IMO) it is an arcade-simulator (since it is a simulator, it has advanced features). To compare to few other known Free/Libre software versions:

Extreme Tux Racer . . . . . 0.8.0
FreedroidRPG .. . . . . . . . 1.0rc2
SuperTuxKart . . . . . . . . . 1.1
LMMS .. . . . . . . . . . . . . . 1.2.2
Wings 3D . . . . . . . . . . . . 2.2.4
Audacity . . . . . . . . . . . . 2.4.2
Blender . . . . . . . . . . . . . 2.83.4 (AFAIK: really high demand)
LibreOffice .. . . . . . . . . . 6.4.6 (AFAIK: big team/really high demand)

(Please, don't consider (crazy) Mozilla Firefox versions :D (79.0 pft!).)

Starting years:

BZFlag .. . . . . . . . . . . . . 1992
GNU/Linux .. . . . . . . . . . 1992
Microsoft Windows . . . . . 1985
Apple software .. . . . . . . 1976

By the way,... congrats and go BZFlag!!
User avatar
Zehra
Private First Class
Private First Class
Posts: 915
Joined: Sun Oct 18, 2015 3:36 pm
Location: Within the BZFS API and Beyond it
Contact:

Re: Plugins That Adjust Tank Physics

Post by Zehra »

Glider mechanics are quite different from both typical powered airplanes or the flight of birds.
Therefore players would require to learn a new skill to make effective use of a Glider type of flag.
Unlike the Wings flag which requires fine control of "lift" events to use effectively, Glider would function effectively by precise control of decent and speed rates.
The main idea is how one can properly or cleverly use a flag granting distance by flying over the field, based on speed, without being able to move upward.

---

Being critical of ideas or thoughts is fine, but going after people is not.
The word stated were contradicted by actions, since being innovative is not a bad, nor a negative thing.

And unlike what is being said, this thread is not about criticizing the game, it was about how would a certain effect be done, why it could not be done and what could be done to simulate it, the technical reason why it couldn't be done and it later began to evolve into a possible flag suggestion.
So saying to people "create, make or leave" is extremely rude and unprofessional, you might as well say "be happy or leave".
(Such arrogance is shocking, especially when previously you accuse others of the same thing.)

In addition, the claim that it is even implied that "innovation" is mandatory is surprising to say the least.
Your words even hint to the part of "if your not creative, you are doing nothing", such arrogance can not stand.(It's not said, but the tone implies as much.)
What of the untold who came up with minor improvements, did bug fixes, wrote documentation, provided help, were they not helpful?

The work in general is respected and in no way did anyone show any sign of disrespect towards the work of previous contributors.
People have been creative throughout the years and frequently tried to find a workaround or solution with any issues which did emerge.
Would they have been happier if there was a better way to do what they hoped to do? (I believe so.)
By going out of your way to tell someone "you're not doing enough", especially in an unrelated thread, is both rude to the original poster and those who post within the thread.

-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