Looking for someone that is decent with particles.

Discussion in 'Plugin Development' started by MCnumi, Jul 5, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    MCnumi

    Hi, as the title says, I'm looking for someone that is good with,
    or even decent, at using particles.
    By that i mean making shapes out of them like helixes, domes, ect.

    Now I'm sure I'm going to get like 10 messages saying
    "learn math" or something, but the thing is,
    I'm going into 10th grade this year.

    I've never even touched upon anything past Pythagorean Theorem or learned trigonometry. If someone would help out with my project and make some small custom particle effects, It would be a great help :D

    Thanks.
     
  2. Offline

    Zombie_Striker

    @MCnumi
    Before I can help you, I would need to know what exactly you need to know how to do; What shape are you trying to make (as each requires their own formulas), and what have you tried?
     
  3. Offline

    MCnumi

    I'm trying to make a of veil, so it would be like this: I hit the player, and a curtain of smoke appears instantly over all sides of the damagers body. It does not matter if the player moves, because he will be teleported away while the veil is there.

    I've tried using DarkBlade's particle effect lib, I understand it, I just don't have the math capability. I've also watched some videos from Steezy on youtube, but again, that math was beyond me.
     
  4. Offline

    Zombie_Striker

    @MCnumi
    From what I think you want, you can break that shape down into two sections: A cylinder from the player's feet to some point towards the head, and a semi-sphere on top of the cylinder.

    For the cylinder, all you need to do is make an XYZ loop, and check if the distance from the center axis of the player to the XZ value where both y values are the same is equal to the radius. You can use Location.distance() to get the radius between two points. For this shape, you do not need to do anything with the Y values.

    For the SemiSphere, you will need to store the point right above the center of the player's head. This will be the center of the sphere. After that, you do the same as the above, but check if the distance between the point and the XYZ value are equal to the radius.
     
  5. Offline

    MCnumi

    I honestly have no clue how to interpret that.
    Could you include some code examples (not spoonfeed) so i understand the methods
    you're talking about?

    EDIT: I am trying to follow this, but what do you mean by an XYZ loop? I keep looping to find the xyz coords? @Zombie_Striker
     
    Last edited: Jul 5, 2016
  6. I belive @ChipDev likes to mess with this kind of stuff.
     
  7. Offline

    MCnumi

    Thanks for tagging him. here, have a huggle.
     
  8. Offline

    Zombie_Striker

    @MCnumi
    Code:
    double radius = 5;
    
    //This is for the cylinder.
    for(double x = players x - radius; x < x +radius;x+=0.25){// By increment only by 0.25, allows for more precise mersurement.
    //Same for Y
    //Same for X;
    Location loc = new Location(world,x,y,z)
    Location playerloc = new Location(world,players x,  y , players z)
    //NOTE: Player loc's Y should be the same as locs'
    if(loc.distance(playerloc) > radius-0.15 &&loc.distance(playerloc) > radius+0.15 )
    //Spawn particle.
    
    
    }
    //This is for the Semi Sphere
    for(double x = players x - radius; x < x +radius;x+=0.25){// By increment only by 0.25, allows for more precise mersurement.
    //Same for Y
    //Same for X;
    Location loc = new Location(world,x,y,z)
    Location playerloc = new Location(world,players x,  player's y , players z)
    //NOTE: Player loc's Y needs to be the point right at the max Y from the for loop above.
    if(loc.distance(playerloc) > radius-0.15 &&loc.distance(playerloc) > radius+0.15 )
    //Spawn particle.
    
    }
     
  9. Offline

    MCnumi

    sorry for making you write all that :(
    I'll try my best to replicate and work out your example :D

    EDIT: when spawning the particles, I use the 'loc' variable, correct?
     
  10. Offline

    Zombie_Striker

  11. Offline

    ChipDev

    So can you make an image or something explaining what you want to do? ;)
     
  12. Offline

    MCnumi

    Read my reply above ;)

    EDIT: @Zombie_Striker this crashed my server:
    Code (open)

    Code:
                    double radius = 5;
                    
                    //This is for the cylinder.
                    for(double x = damager.getLocation().getX() - radius; x < x +radius;x+=0.25){// By increment only by 0.25, allows for more precise mersurement.
                    double y = damager.getLocation().getY() - radius;
                    double z = damager.getLocation().getZ() - radius;
                    Location loc = new Location(damagerLoc.getWorld(),x,y,z);
                    Location playerloc = new Location(damagerLoc.getWorld(), damagerLoc.getX(),  y , damagerLoc.getZ());
                    //NOTE: Player loc's Y should be the same as locs'
                    if(loc.distance(playerloc) > radius-0.15 &&loc.distance(playerloc) > radius+0.15 ) {
                        PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(EnumParticle.SPELL_WITCH, true, (float) (damagerLoc.getX() + x), (float) (damagerLoc.getY() + y), (float) (damagerLoc.getZ() + z), 0, 0, 0, 0, 1, null);                      
                        ((CraftPlayer)damager).getHandle().playerConnection.sendPacket(packet);
                                     
                    }
                   
                    }
                    //This is for the Semi Sphere
                    for(double x1 =  damager.getLocation().getX() - radius; x1 < x1 +radius;x1+=0.25){// By increment only by 0.25, allows for more precise mersurement.
                    double y1 =  damager.getLocation().getY() - radius;
                    double z1 =  damager.getLocation().getZ() - radius;
                    Location loc1 = new Location(damager.getLocation().getWorld(),x1,y1,z1);
                    Location playerloc1 = new Location(damagerLoc.getWorld(), damagerLoc.getX(),  y1 , damagerLoc.getZ());
                    //NOTE: Player loc's Y needs to be the point right at the max Y from the for loop above.
                    if(loc1.distance(playerloc1) > radius - 0.15 && loc1.distance(playerloc1) > radius + 0.15 ) {
                        PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(EnumParticle.SPELL_WITCH, true, (float) damagerLoc.getX(), (float) damagerLoc.getY(), (float) damagerLoc.getZ(), 0, 0, 0, 0, 1, null);                      
                        ((CraftPlayer)damager).getHandle().playerConnection.sendPacket(packet);
                    
                    }
                    
                    }

    didn't even give an error
     
    Last edited: Jul 5, 2016
  13. Offline

    I Al Istannen

    @MCnumi
    Do you know anything about Polar coordinates? I am in 10th form too, we didn't touch it yet, but we sure did trigonometry. And polar coordinates are not that hard! You can do it! ;)
    Maybe this will help? Was just something I found on youtube and the first few minutes looked promising :p

    Using them you can make circles reaally easily. And if you have a circle, a cylinder is the same. Just draw circles at different y coordinates.

    I can only speak for myself, but I find the polar coordinate comprehensible. If you have any questions, feel free to ask and I will try to answer them to the extent my knowledge allows.

    Could you maybe draw a bad paint picture to better describe what you want to do? Just a curtain?
    In this case the things above should be enough.

    If you also want to draw a sphere, it starts to get more complex.

    @Zombie_Striker
    Your way will work too, but I think understanding polar coordinates is worth it. Makes it a whole lot easier to create other things, imho.
     
  14. Offline

    MCnumi

    I will try out that website, but what I want is literally a box around the player. (made of particles)
     
  15. Offline

    I Al Istannen

    @MCnumi
    Oh, just a box? No cylinder?

    A box is a whole lot easier and doesn't involve trigonometry at all. Just some plain old for loops. Have a look here.
     
  16. Offline

    MCnumi

    I don't understand how that post has to do with this topic.
     
  17. Offline

    I Al Istannen

    @MCnumi
    This post tells you how to create such a shape:
    [​IMG]

    Which is what you need. A box around a center. Or do you want something else?
     
    Zombie_Striker and ChipDev like this.
Thread Status:
Not open for further replies.

Share This Page