[Help] Making a targeting beam magic weapon

Started by PyroBoo on

Topic category: Advanced modding

Last seen on 13:19, 24. Apr 2023
Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Help] Making a targeting beam magic weapon

Hello there MCreators!

So, uh, I've been working on an RPG mod for some time now, and I found myself getting stuck during the process of creating a custom magic weapon. I was wondering if perhaps someone had any idea how to create the procedure for it and, if so, could provide me with either an explanation, images and/or an example workspace. Thanks in advance to anyone that partakes in this undertaking!

 

The magic weapon in question is called "Transfusion", and it needs to do the following:

*In order for casting to be successful, the player needs to be continuously looking at an entity, as well as holding the right mouse button: there should be a continuous test for right-clicking, as well as raycasting to find the closest entity the player is looking at.

*While the above is true, a beam of particles that goes from the player to the entity should be rendered.

*after a given cast time, the entity should take damage (the player should also regenerate health. I added this portion just to give a result assuming the above conditions are true. I know how to do this, the main problems I encountered are regarding the first two points).

Last seen on 12:45, 25. Apr 2024
Joined Apr 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can use something…
Sun, 04/16/2023 - 13:45

You can use something similar to this procedure, I made it for a slightly different problem so you will need to change some things:

Create a custom number variable called range, and a custom logic variable called foundtarget, then use the following procedure

Every different procedure block is placed within ( ) and sub-components that you can modify that are not blocks will be listed within [ ]  if a procedure block should not be changed from what I say, it will be marked with * if a line needs to be continued it will end with...

(If(Not(Is provided world client-side)))*
do:(Play[block.beacon.deactivate] at x:(X)y:(Y)z:(Z) Level:(1)pitch:(1.8)Category:[player])

      (Set[local: range] to: (1))*

      (Set[Local: foundtarget] to: (false))*

      (Repeat (40) times)

      do:(for each entity as (Entity iterator) at x:(look X position of (Event/target entity) with raytrace distance (Get[Local: range])...

...fluid mode [NONE] block mode [OUTLINE]) y:(look Y position of (Event/target entity) with raytrace distance (Get[Local: range...

])...fluid mode [NONE] block mode [OUTLINE]) z:(look Z position of (Event/target entity) with raytrace distance (Get[Local: rang...

e])...fluid mode [NONE] block mode [OUTLINE]) in square cube with size (1.5)*

            do:(if((Is (Entity iterator) (sub)type of [Living entity]) AND (not((Event/target entity) = (Entity iterator))))*

                  do:(if((get [local: foundtarget]) = (false)))

                        do:(Play[block.beacon.activate] at  x:(look X position of (Event/target entity) with raytrace distance (Get[Local: ra...

...nge])fluid mode [NONE] block mode [OUTLINE]) y:(look Y position of (Event/target entity) with raytrace distance (Get[Local: r...

ange])...fluid mode [NONE] block mode [OUTLINE]) z:(look Z position of (Event/target entity) with raytrace distance (Get[Local:...

 range])...fluid mode [NONE] block mode [OUTLINE]) Level:(1)pitch:(1.8)Category:[player])

                              (Deal ((10) * ((1) - ((armor value of (Entity iterator)) / (30)))) damage to (entity iterator) type:[generic])

                              (Spawn (30) particles on server-side at x:(look X position of (Event/target entity) with raytrace distance (Get[L...

...ocal: range])fluid mode [NONE] block mode [OUTLINE]) y:(look Y position of (Event/target entity) with raytrace distance (Get[...

Local: range])...fluid mode [NONE] block mode [OUTLINE]) z:(look Z position of (Event/target entity) with raytrace distance (Ge...

t[Local: range])...fluid mode [NONE] block mode [OUTLINE]) in area dx: (1) dy: (1) dz: (1) with speed (0) type:[CRIT])

                              (Set [Local: foundtarget] to (true))

                              (if(not(Is(Get entity (Entity iterator) is targeting for attack) (sub)type of [Living entity])))*

                              do:(Set the attack target of (Entity iterator) to (event/target entity))

            (if((Get [Local: foundtarget]) = (false))

            do:(Spawn (3) particles on server-side at x:(look X position of (Event/target entity) with raytrace distance (Get[Local: ra...

...nge])fluid mode [NONE] block mode [OUTLINE]) y:(look Y position of (Event/target entity) with raytrace distance (Get[Local: r...

ange])...fluid mode [NONE] block mode [OUTLINE]) z:(look Z position of (Event/target entity) with raytrace distance (Get[Local:...

 range])...fluid mode [NONE] block mode [OUTLINE]) in area dx: (0.6) dy: (0.6) dz: (0.6) with speed (0) type:[CRIT])*

            do:(Set [Local: range] to: ((Get [Local: range]) + (1))

      (Cooldown (Provided itemstack) for (30) ticks for (Event/target entity))

      (Deal (1) damage to (Provided itemstack))

 

 

 

 

You can also try to use nbt tags to store certain pieces of information, including the uuid of the entity you are targeting if you use [Plugin] Damage Source Plugin (Forge 1.16.5, 1.18.2, 1.19.2) so you can force players to attack the same entity.

What you are trying to do is very complex so I don't have an exact guide for it, all I can do is give you some advice on things that you could possibly use.

Last seen on 13:19, 24. Apr 2023
Joined Nov 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Well, I can't say I was…
Sun, 04/16/2023 - 15:19

Well, I can't say I was disappointed. I must really thank you a lot, Catnip! This was basically what I was looking for!

Now I have to figure out how to create the beam going from one entity to the other, but other than that, this was just what I needed!