[Guide] Custom Weapons

Tutorials and guides for Plazma Burst and community features.

[Guide] Custom Weapons

Postby xElijah » 21 November 2020, 22:45

Writing a step-by-step tutorial for newbies would take too much time and I doubt that newbies are capable of making custom weapons anyway, so I'll just post an open source map and write a small guide for people who are experienced enough to understand. If you have any questions, please ask. Also remember that having custom weapons in your map would most likely make it more popular. Because players like custom weapons.

Map ID: xelijah-test
Map Page Link: https://www.plazmaburst2.com/?s=9&a=&m= ... &id=998595
Map Demo Link: https://www.plazmaburst2.com/?s=2&map=xelijah-test
Map Description: Open Source map with custom weapons. I'll be adding more weapons from time to time.

Guide:
Spoiler: Show More
Basic hints:
1) Your firearm must have a muzzle flash effect if you want it to look good in game.
2) When you start making a custom weapon, add decorations in specific order: gun's decoration -> muzzle flash 2 decoration -> muzzle flash 1 decoration. This will make decoration overlapping work properly in game.
3) When you add a gun's decoration, always remember to set its "Draw in front" parameter to "Yes" otherwise it will not always be visible in game. Same for muzzle flash decoration.
4) When editing decoration's scale with triggers, use both actions: change X scale and change Y scale to create the most realistic and suitable for game gun size.
5) Always change gun and muzzle flash decoration's X and Y offset to make them look good in player's hands. While testing the offset, increase game zoom to get a better view. Remember that putting a negative Y value will make the decoration go up, not down.
6) Activate an infinitely called timer that makes decoration follow the gun ONLY AFTER you changed the model scale and other stats, otherwise some bugs may appear in game like gun gettng flipped over.

Gun stats triggers:
1) "Gun length" changes the distance between two hitboxes of a gun object. Value "25" is approx 1 centimeter in game (value 50 = 2cm, value 75 = 3cm, etc). It also changes the bullet spawn location. When you increase the value, gun's right hitbox grows to the right direction while its left hitbox always remains at the same place.
2) "Arm offset" changes the way how your character holds the gun in game. "Arm 1" is the only arm that actually holds the gun while "Arm 2" is more like a backgrounds decoration. The recommended offset for two-handed weapons (like rifles) is "0.6" for "Arm 1" and "1" for "Arm 2", for one-handed weapons (like pistols): "0.9" for "Arm 1" and "1" for "Arm 2". However you can choose any other value that you think look good in game.
3) "Gun speed multiplier" changes the shooting speed in game relative to gun's default speed stat. Don't make it too big because fast shooting guns add more lag to the map.
4) "Projectile power" changes the damage your gun can deal in game. Value "1" would make following damage in game: head - 55 hitpoints, chest - 25 hitpoints, arms - 20 hitpoints, hip & calf - 30 hitpoints, feet - 15 hitpoints. Value "2": head - 110, chest - 50, arms - 40, hip & calf - 60, feet - 30; and so on. "Projectile power" changes the target knockback too, so the bigger value is - the stronger it will push other players and objects in game. It also changes the wall penetration: projectile power of value "0.58" penetrates 1 wall, value "0.59" - 2 walls, value "0.88" - 3 walls, value "1.18" - 4 walls. Changing power to bigger value won't allow to penetrate 5 walls ever. Other note: each in game wall penetration reduces the penetration ability of a bullet to penetrate next wall and also reduces its damage. There is one more interesting thing about "projectile power": changing it to "0" will make gun turn into melee weapon and changing it to "4.01" or higher will make the bullet fly really fast (useful for sniper rifles).
5) "Target knockback multiplier" reduces and increases the push power of a bullet. If the "projectile power" or "gun speed multiplier" is too high, make sure you change knockback multiplier to a lower value like "0.7" or "0.4" or less to compensate and balance the gun overall power.
6) "Gun recoil multiplier" changes the way how your character handles the gun when it's shooting. If the gun is too powerful or fast it can make your character lose stability or even fly when you shoot it. So to avoid that you can set "gun recoil multiplier" to a lower value like "0.7" or "0.4" or less.
7) "Gun accuracy" is the default accuracy of your gun in degrees. Value "0" or "1" will make the gun very accurate while values like "45" or "150" will make it very inaccurate.
8) "Added spread accuracy" adds extra accuracy loss on each new shot you make in game. It counts in radians, not degrees, which is not really convenient. And it seems to be bugged and I'm trying to figure out how to convert radians into degrees. In real life 1 radian equals approx 57 degrees, but in PB2 1 radian equals 220 degrees for some reason. Here are some tested values you can put in level editor: 0.1 radian = 5 degrees, 0.2 radian = 10 degrees, 0.3 radian = 30 degrees, 0.4 radian = 40 degrees, 0.5 radian = 50 degrees.
9) "Max spread accuracy" is the max possible spread in radians you can achieve by using "added spread accuracy" trigger action. "Added spread accuracy" will never reach a bigger spread in game than the one specified in "max spread" value. Make sure "added spread accuracy" has a smaller value than "max spread accuracy" if you want the gun to gradually lose accuracy while shooting and not instantly after first shot. For example if you set "max spread" to "0.4" and "added spread" to "0.1" it would mean that gun will reach the most inaccurate state in 4 shots.
10) "Subtracted spread accuracy over time" reduces the spread over time. It's the best to put a very low value here because it reduces the spread very fast (30 spread updates per 1 second). For example if you set "max spread" to "0.3", "added spread" to "0.1" and "subtracted spread" to "0.01", then gun will reach the most inaccurate state after 3 shots, and when you stop shooting, it will take 1 second for the gun to return to its most accurate state.
11) "Gun accuracy" and "Max/Add/Subtract spread" triggers affect each other. In fact they are summed when you are using them in combination with each other. For example if "Gun accuracy" is set to 45 degrees and "Max spread" is set to 0.45 radian (which equals 45 degrees in PB2), then overall gun accuracy in game will be 90 degrees.
12) "Max/Add/Subtract spread" trigger actions should also be used with slow firing weapons like shotguns and knives if you want player's cursor size to increase and decrease when you shoot them ("max/add/subtract spread" triggers are responsible for cursor size change effect). It would simply look better in game if cursor's size changed each time you shoot a gun. In order to make the "increase/decrease cursor" system working without actual gun accuracy loss, set "max spread" to a relatively small value (like "0.3" radian), set "added spread" to the same value (in this case - "0.3"), and set "subtracted spread" to a smaller value, but so it would be enough for the cursor to retrieve its initial size quickly (in this case - "0.04"). If your weapon has a low rate of fire, this system would allow cursor to change its size but the weapon won't lose any accuracy while shooting. It won't work as good for fast firing weapons though because fast firing weapons will actually lose accuracy on each shot. This is how cursor size change work with knife in "xelijah-test": image.

Muzzle flash info:
1) It's the best to use a "multiframe muzzle flash" system instead of "1-frame muzzle flash" or "2-frame muzzle flash" systems because it works good in all game modes and with any gun speed. Map "xelijah-test" contains it. "Multiframe muzzle flash" uses "double function" type of trigger system. Each time you activate the initial trigger, it activates two other triggers in turn. First one changes muzzle flash to one model, and second trigger changes muzzle flash to other model. It works really good for fast firing weapons like miniguns.
2) Due to special "network delay compensation" feature that Eric added to the game, the trigger on shot (trigger that is activated first when you shoot a gun) should not run any timers (like ones responsible for muzzle flash disappearance), but it should execute (with trigger action: "Execute trigger A") an extra trigger which will run the timers. Because if first initial trigger on shot runs the timer it will execute the target trigger too quickly in multiplayer making muzzle flash barely visible for other players.
3) Sometimes trigger on shot doesn't get activated so the muzzle flash doesn't appear. It usually happens with fast firing guns. It's not map's/trigger system's fault. It's a bug that happens because of how PB2 game/server works. I think it happens when your client sends too many commands to the server so some of them are getting "ignored" by it.
4) Sometimes the shot and muzzle flash appear not at the same time. This is a PB2 "desync" issue that probably cannot be fixed by players, but only by game developer. The game cannot even sync the proper amount of bullets you shot. It works like this: On your screen you shot 1 time, but on the screen of other player you shot 2 or 3 times. This desync is a serious issue that will most likely only be solved in PB3. Right now there is no other option than to take this bug as unavoidable. Get used to it.

Melee wepons info:
1) To avoid bugs in game, you need to set melee's "weapon's projectile count" to "0" by default, then change it to "1" with trigger on shot's "player-specific" actions. "Player-specific" actions are actions only executed in player-initiator's client. New PB2 sync allows to use "player-specific" actions to do damage in multiplayer. If you want to read more about using "player-specific" actions while creating melee weapons, visit my other tutorial topic: "Combining firearms and melee weapons in one map w/o bugs". Map "xelijah-test" contains this player-specific system. Firearms and melee weapons can work together in one multiplayer map without bugs if you stick to this system.
2) "Trigger on shot" should change "Max bullet life" parameter to "0" in order to reduce firearm's attack range to a melee range.
3) "Trigger on shot" can also reduce "bullet speed" value in order to make melee's attack range even smaller and more realistic.
4) Timer that sets the "arm 1 offset" back to default value after the attack should be ran by an extra trigger due to "network delay compensation" feature mentioned earlier.
5) Since melee's "projectile power" is high, its attacks are able to penetrate walls. In order to fix it and make your melee weapon act more realistic in game you will need to manually set "bullet penetration factor" to "0" with its trigger on shot's "player-specific" action.
Last edited by xElijah on 30 November 2020, 11:40, edited 5 times in total.
User avatar
xElijah
Usurpation Soldier [50]
 
Posts: 96
Joined: 3 October 2020, 15:43

Re: [Guide] Custom Weapons

Postby Stryde » 24 November 2020, 17:04

Take this as a bump to your topic and as a warning. You don't need to constantly post updates to your topic if you can edit your previous post because no one else has replied to the topic yet.

You've made 3 replies to this topic within the span of 3 hours, edit your posts instead of excessive bumping.

Do not reply to this message.

Stryde
Moderator
 
Posts: 361
Joined: 9 November 2015, 02:17


Return to Tutorials

Who is online

Users browsing this forum: No registered users