#Projectile recognition issues

1 messages · Page 1 of 1 (latest)

noble vortex
#

I am having problems with making my custom throwable items...
I have already made the airstike and it worked very well, no issues. BUT then I relised all eggs trigger the supply drop so I tried looping the projectiles through a list, but sadly things haven't gone well.

I have no idea how Skipt processes thrown entities, it's so bizarr.

My goal would be to add a lot of projectiles types, different throwing speeds for turrets, grenades, flashbangs and so on. The issue stems from projectiles being just eggs, not the custom item I have set and problems with item to entity conversion.

Egg is not egg :(

command /testuranium:
permission: op
trigger:
give {uraniumtoken} to player
give {uraniumnugget} to player
give {uraniumingot} to player
give {uraniumdust} to player
give {uraniumshard} to player
give {cobweblauncher} to player
give {titaniumpickaxe} to player

fallow tulip
#

why do you have 2 events and spawn another egg after you have already shot an egg

#

why not just put them into the same event and just check the name of the shooter's tool to see which custom item it is

#

@noble vortex

#

there is no need to add them into a list you can just set a metadata tag on the projectile and use conditions to change what the metadata's value is
-# this is metadata:

on shoot:
    name of player's tool is "&bshotgun"
    set metadata value "type" of projectile to "slug"

and looks like you are just spawning the cobwebs and airstrike flares to wherever the player right clicks

#

you should use the projectile hit event to check when they hit a block/entity and check their metadata value

if metadata "type" of projectile is "airstrike":
    # explode
else if metadata "type" of projectile is "cobwebs":
    # create cobwebs where the projectile landed```
#

looping all offline players also isn't smart but if you don't do the list thing it will be fine
-# looping all offline players will like cause skript to load all of the offline players into ram i think and depending on how many there are the server will crash, and the server tries to process these as soon as possible so that causes issues

#

if {projectile::%player%::%loop-index%} is {airstrikeFlare} this is also just like wrong you're adding an entity to the list not an item
add event-entity to {projectile::%player%::*}

#

if i had to guess i would assume the list isn't being cleared properly so you code is repeating a lot of times

#

@noble vortex hello bro

#
    if event-projectile is {airstrikeFlare}:
        cancel event
        #will ad code once I know what the hell im doing
        stop
    if event-projectile is {cobweblauncher}:
        cancel event
        shoot an egg from shooter at speed 1:
            add event-entity to {projectile::%player%::*}``` you are also comparing an projectile to an item for some reason? i don't know how skript is even repeating itself now
noble vortex
#

@fallow tulip ur the actual goat :) it is so cool man!

on shoot:
if name of shooter's tool is {cobweblauncher}'s name:
set {_v} to velocity of projectile
set {_v} to {_v} * 0.5
set velocity of projectile to {_v}
set metadata value "type" of projectile to "cobweblauncher"

on throw of an egg:
if metadata "type" of projectile is "airstrike":
set {_x} to x coordinate of location of event-projectile
set {_y} to y coordinate of location of event-projectile
set {_z} to z coordinate of location of event-projectile
execute command "execute positioned %{_x}% %{_y}% %{_z}% run function warcores:airstrike"
execute command "execute positioned %{_x}% %{_y}% %{_z}% run summon marker ~ ~ ~ {Tags:[airstrike.place,tnt_bombing]}"
else if metadata "type" of projectile is "cobweblauncher":
set {_loc} to location of event-projectile
loop all blocks in radius 2 around {_loc}:
if loop-block is air:
set {_scrambledcode} to random integer between 0 and 99999999999
set {cobcompact::%{_scrambledcode}%} to loop-block's location
set loop-block to cobweb

But I do have an extra question:

  • I know my code was a mess, it's usually a bit better but how and where did you learn to optimise your code? I have no idea where to start and with more than +7k lines it may be a good idea to start learning how to do that XD... I do know you can use plugins like Spark but I have never used them, how do you do ur optimising?
fallow tulip
#

i just did a lot of coding and theres way better people compared to me you can learn from someone like mibers (@karmic sage)

#

honestly the server idea warcores looks cool so i just suggested some stuff that looked like it shouldnt be the case

#

could you send a dc invite later to dms

#

i don't like specifically do optimising a lot myself but i learn from what others have said and i like look at their experiment results to see what would work the best for my case

#

i saw this earlier and i suppose you could take inspiration from it and use like timing stuff to see how good your code is performing

fallow tulip
#

also uh ur running a datapack function and spawning a marker wih tags both which you shouldn't do with console commands

fallow tulip
#

oh silly me i added mibers to the thread hi

fallow tulip
#

this is something to know about while loops and periodicals