Shot location

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
Grue
Private First Class
Private First Class
Posts: 27
Joined: Tue Apr 08, 2014 12:23 am
Contact:

Shot location

Post by Grue »

Hey all,

I've recently started getting into writing custom flags, and I've been experimenting with a few new ideas.

One of the things I want to try and recreate is the Grenade flag as seen on Apocalypse, where the first shot launches the grenade and the second shot detonates it.

I understand that the first shot fires some sort of world weapon (it appears to be four phantom zone shots), and the second shot creates a world weapon shock wave at the zoned shots' location. However, I can't seem to figure out how to discern a shot's location given a shot's id. Is this even possible, or is a different approach needed?

Any help on this matter would be greatly appreciated.

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

Re: Shot location

Post by blast »

The server doesn't really know where the shots are at, so you would have to calculate that yourself in the plugin, though I can't recall if PZ shots ignore teleporters. Another thing you can't do is override the shot the client fires, so theirs would still be a normal shot that might ricochet.
"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
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: Shot location

Post by Zehra »

A different approach is needed.

The simplest one what I can think of, is grab the first shots position and tank/turret direction, fire 4 PZ shots based on the tanks position and direction and if the player fires a second shot while the first has not expired, fire a world weapon/server shot x many units in front of the tank's direction where you want it. The distance is based on the shots speed too.

So if the shot speed is 100 units, but they make a second shot in 0.5 of a second, the world weapon is fired at that position ahead of where the shot was fired from and where the shot "will be".

Note, you'll still need to hook up the server shots some way to award players points based on the shot/death or to assign the "kills" to the player, but the peference is to assign the kills as it automatically makes it clear to other players "who" made the kill. (The option of awarding points allows to you to simply list kills as made by the server in flags with additional shots or bullet trickery, useful for some custom game modes.)

The only minor suggestion is to take into account the tank speed/velocity and movement to either subtract or add to the shots distance calculations.

So something like

Code: Select all

distance = (time * (shot distance + tank speed));
Should do what you need. Just be sure that the tank can't go faster backwards than the shot can go forwards in this case.

For calculating stuff like not spawning a shot inside a building, you can have an array of some sorts to store a custom zones locations and simply check if a given shot is within or would spawn within that location and not trigger a server shot.

Collisions are a bit more tricky, but can be done by checking if a shot will fall on the path of an object and based on the shots speed when it will hit. (There's a trick for the timing IIRC, but I don't recall it at the moment, but it's mainly for those ultra small timing intervals that the tick event seems to miss when there's few players.)

Ricochets are a bit more complex to do, but simple in theory, although I don't think that exactly is what you're looking to do, although a ricocheting grenade could be fun.

Hope this helps, let me know if you need any more details on the specifics of any of the above.

-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
Grue
Private First Class
Private First Class
Posts: 27
Joined: Tue Apr 08, 2014 12:23 am
Contact:

Re: Shot location

Post by Grue »

Zehra,

Thank you so much for your reply, I understand what you're saying.

I was was worried that I might have to take this approach lol, which is basically calculating where those PZ shots are on the server's end based on the tanks' location, rotation, shot speed.

But here's the part that confuses me, and I tested this out on Apocalypse shortly before I made this post: when you fire those 4 PZ shots, and then fire the second shot to detonate them, the 4 PZ shots vanish. From my understanding of how you were saying to implement this grenade function, the PZ shots would still continue their travel because there would be no way of determining where those shots might be...

Is it possible to make a shot expire early?

Grue
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: Shot location

Post by Zehra »

Grue,

Thanks for the reply and update, I guess you can say the API makes a few things easy and not others.

Thankfully there's a few "ways" to "end" a shot early, each has their own little catch to them.

One trick is bypassing the API and sending an "endshot". This technique is used if I remember correctly in Agatha's Whacky-Weapons plug-in and custom flags.

Endshot trickery works pretty well for the most part, but it's also limited to an extent of where it doesn't work/compile on Windows, although most people run *nix servers, so this shouldn't be an issue.

I did by accident figure out how to get "infinite" lasting shots (although stationary), but interestingly enough, it seems that if you hit the limit of world weapons, it would "erase" the previous shots by overwriting the shot id. (I only did it for some nice visuals, so I never checked if was the actual case.)

So it should work fine, although it will/can mess with other world weapon based shots. The main advantage is not bypassing the API, but the main disadvantage is complexity and trickiness of getting it to work.

I've also heard if you fire a shot with the same ID, it overwrites the shot. (So in theory you probably could fire an SW with the shot id of the previously fired PZ shot and have it "overwrite" the previous shot.)

-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: Shot location

Post by blast »

We'll likely fix the issue that allows a plugin to bypass the API in a future release. We just need to work out how GCC's visibility support works.

It's also no longer possible to pick a specific shot ID when firing a world weapon.
"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
Grue
Private First Class
Private First Class
Posts: 27
Joined: Tue Apr 08, 2014 12:23 am
Contact:

Re: Shot location

Post by Grue »

Thanks so much for the help!

I got grenade working pretty nice, I decided to just do away with trying to end those PZ shots early, but everything else works flawlessly. I used your suggestion on storing the grenade's location per player and using the shot's speed and such to predict where those PZ shots are.

Thanks again,
Grue
Post Reply