How to easily make a ranged weapon with multiple amunition types and effects

Started by swelkinn_n on

Topic category: User side tutorials

Last seen on 23:20, 6. Apr 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How to easily make a ranged weapon with multiple amunition types and effects

This tutorial will be relatively simple, and most likely not the most refined, but it does work, and this seemed to be a big question I never found a lot of answers for before.

 

The Weapon

The first step is to make the weapon. Your first thought might be to make a "Ranged Weapon", but this is actually not how we're doing it. It most likely is able to be done, but I haven't played around with it yet. Instead, we make an "Item".

From here, we change things like stack size and durability (only if applicable), and go into triggers, adding one for when right clicked in air.

Now, this may suggest you don't need a Ranged Weapon in the equation, but if you're using custom projectiles or your bullets have custom effects, you are required to make a ranged weapon for them.

Procedures

For this, we'll assume you already have at least 2 ammunition items previously made.

This can go infinitely, and also has 2 methods.

Method 1
Method 1 is less smooth, and if you want it do something like, say Ammo 1 and Ammo 2 when used together shoot Bullet 3 as opposed to Bullet 1 or Bullet 2, is VERY annoying later if you decide to have many of these. We'll call these Synergies for later.

First, you want to put an "If (), Do ()" and in the "If" section, place a "Has [Entity/Target] in Inventory ()", and in the red box, set it to your "Ammo 1"

Then, in the Do section, place a "Shoot Projectile _____" block. If you want to, you can also add a swing when used, as well as a sound effect. If you want your item to disappear when used like actual ammunition, place the "Shrink _ for _" block, and change the red box to the ammo.

From here, click on the gear on the "If (). Do ()" block, and add an "Else If" for your other ammo type.

Do the same thing as you did for Ammo 1, but change Ammo 1 instances to Ammo 2, obviously.

Let's say Ammo 2 explodes upon hitting a block. Make a different ranged weapon for this. The bullet's power, damage, and knockback don't matter, as you can set these in the big Gun procedure. Go into the triggers, and add one for "When Bullet Hits Block", and put the "Explode" block on it. Set the parts accordingly.

If done correctly, in game, If you have Ammo 1,  it will shoot a normal* bullet, and if you have Ammo 2, it will explode on hitting a block. Whatever ammo type is put first in the procedure is prioritized.

Adding Synergies

Synergies, as I described above, is basically A+B=C. To do this, you need to have that third bullet type, and for this example we'll say it explodes into a poison gas cloud.

For the ranged weapon's bullet, make it so when it hits a block/entity, do this: "summon area_effect_cloud ~ ~ ~ {Radius:2f,Duration:60,Potion:"minecraft:poison"}". You can change the radius and duration, as that lasts ~3 seconds and is (I think) about a circle with a radius of 2 blocks.

For this, we'll need another "If (), Do ()" and put it in one of the two components, and replace the preexisting blocks, but do not delete them. Click on the gear on the new "If (), Do ()" and add an "Else". Under Else, put the old blocks. In the new one, put an "Has in Inventory" block, put it in an "AND" block, and put a second "Has In Inventory" block in the second part of the "AND" block. Change the slots to the 2 ammunition types.

Congrats, you've done the hard part!

From here, you can copy the blocks from any of the other ammunition, and change the effect accordingly.

 

The only issue here, is that it's slow, complicated, and very annoying once you start adding more and more items.

 

From here, take the next method as a more "I'm 99% sure this works", as I haven't yet tested this out. It should, in all fairness, work, however.

Method 2

This method involves variables.

Go to the variables page, and add as many as there are unique effects you're planning on adding. Make them all logic variables, and set them to "PLAYER_PERSISTENT", that way only one player will have the exact effects they have in their inventory.

This should, potentially, only involve one ranged weapon, and one, much smaller, procedure for bullets.

From here, in your ranged weapon's procedure, check for the variables. If (for example,)"Explode" is true, make the bullet explode when hitting a block/entity (you can put the same procedure in both). That's it. Do that for every variable you have, and you'll eventually have it so, for example,

You have Ammo 1 in your inventory-- "Explode" and "GasCloud" are False.

You have Ammo 2 in your inventory--"Explode" is true, and "GasCloud" is false.

You have Ammo 1 and 2 in your inventory. Here, you can decide if "Explode" is false and "GasCloud" is true, or if they're both true.

But, you might be asking, "How do we make the variables true?"

Go to the Ammo types, and make a procedure under "When in inventory tick", and put an "If (), Do ()", check if the matching variable is false, then set it to true if it is.

 

Closing Remarks

As I said in Method 2, it is untested as of now, but I am about to use it to prove/disprove it. If there's any issues or clarifications, please ask in the comments <3

If need be, I can set up a download link for procedures.

Last seen on 23:20, 6. Apr 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
EDIT: For Method 2, make the…
Sun, 06/06/2021 - 18:34

EDIT:

For Method 2, make the procedure for variables "If (), Do (), Else," and in the else make it set the variable to false. This makes it so you don't get infinite of that ammo type as long as you live

Last seen on 23:20, 6. Apr 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
EDIT 2: Also for Method 2,…
Sun, 06/06/2021 - 19:02

EDIT 2:

Also for Method 2, potentially make the variables "Player Lifetime", I'm trying to fix the fact they will, as I described, infinitely give you the same ammo type.

Method 1 may be the sound option here.

Last seen on 23:20, 6. Apr 2024
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
fndjhndfj just do method 1
Mon, 06/07/2021 - 20:22

fndjhndfj just do method 1

Last seen on 09:33, 11. Nov 2022
Joined Apr 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
it would be better if you…
Fri, 08/20/2021 - 14:14

it would be better if you did a video

Last seen on 14:46, 16. Apr 2024
Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yes  
Fri, 04/12/2024 - 14:27

yes