"Drug" effects Plugin?

Discussion in 'Archived: Plugin Requests' started by ccrock4t, Dec 20, 2011.

  1. Offline

    Fyre

    Did you figure out the MobEffects? I have methods for set/remove if you want them.
     
  2. Offline

    XepherLink

    Makes sense
     
  3. Offline

    hammale

    no i couldnt figure it out and i would LOVE if you could help :D
     
  4. Offline

    DirtyStarfish

    Its really easy. You need to add the CraftBukkit jar to your project. Then, get the relevant player variable from an event or wherever:
    Code:
    CraftPlayer cp = (CraftPlayer) player;
    cp.getHandle().addEffect(new MobEffect(id, ticks, strength);
    It takes 3 ints:
    id - The id of the effect.
    ticks - The length of time (in ticks) that the effect lasts for
    strength - The strength of the effect

    So for example, to add the portal effect (confusion, also called nausea) you would do:
    Code:
    cp.getHandle().addEffect(new MobEffect(9, 200, 2);
    Which would add the portal effect for 200 ticks, at strength level 2.

    You can find the effect id's and more information here: http://www.minecraftwiki.net/wiki/Potion_effects

    Hope this helps!
     
    hammale likes this.
  5. Offline

    amunro

    Holy crap, I had no idea you could do this! I might make a plugin like this too just so you can set these effects to commands. Would be nice to be able to give a player nightvision just by doing /nightvision etc.
     
  6. Offline

    hammale

    wow dude thats AWESOME but how did u figure it out? all the bukkit docs are just for the bukkit api...

    @DirtyStarfish ZOMG thats puuuuuurfect!!!! i already have the drunk walking code done so this is pretty much alls i need for the rest. the config stuff isnt that hard :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  7. Offline

    DirtyStarfish

    Yeah, it wouldn't be too hard, although as far as I can tell, nightvision hasn't been implemented, it didn't do anything when I tried it anyway!
    edit: Don't think the invisiblity effect works either.
    I used to use mob effects in my old drug plugin, but only a few worked and you had to write the add/remove effect methods yourself. I think since the addition of potions the method I just posted was added.
    You can do some cool stuff if you use the craftbukkit jar in your project, like that old torch plugin that gives of light from the player when you hold certain items.
     
  8. Offline

    hammale

    Ooooooo these effects r fun :D

    o cool, it would just be cool if there was a nice docs site set up somewhere. i LOVE the portal effects it goes great with the drunk walking :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  9. Offline

    DirtyStarfish

    Maybe I should write a thread in the resources section..

    The portal effect has changed though. It used to be much better imo. It didn't have the purple spiral, its still pretty good though! Glad that your making progess! Im stuck on mine!
     
    hammale likes this.
  10. Offline

    amunro

    Haha already done the /nausea! Brilliant xD
     
    DirtyStarfish likes this.
  11. Offline

    KaiBB

    If you mind my asking, for the player staggering around like they're drunk, did you just do a slight change of velocity? I'm interested in this. :3
     
  12. Offline

    hammale

    yeah but im still trying to dial it in just rite...vectors r fairly new to me :D
     
  13. Offline

    KaiBB

    Ah, I know the feeling. I was nearly pulling my hair out when I started Vectors / Velocities.
     
  14. Offline

    hammale

    wats a better name? DrugMeUp or Dr. Feelgood?
     
  15. Offline

    KaiBB

    I say DrugMeUp. IF you want you can have my name. Before I abandoned it, it was named SuperDrugs.
     
    hammale likes this.
  16. Or, even better, patch bukkit to have it in it's API and do a pull request. ;)
     
    KaiBB likes this.
  17. Offline

    KaiBB

    That would be absolutely fantastic for so many developers.
     
  18. Yea, just a simple player.setPotionEffect(POTION_EFFECT.FOO, x, y); :D
     
  19. Offline

    KaiBB

    I think that would open up so many more possibilities with plugins too. Devs could be more free with adding cool things like effects. I sure would use it a lot.
     
  20. Offline

    Fyre

    You'll want these then.
    Code:
     public void setMobEffect(LivingEntity entity, int type, int duration, int amplifier)
      {
        ((CraftLivingEntity)entity).getHandle().addEffect(new MobEffect(type, duration * 20, amplifier));
      }
    
      public void removeMobEffect(LivingEntity entity, int type)
      {
        try
        {
          if ((entity instanceof Player))
          {
            EntityPlayer player = ((CraftPlayer)entity).getHandle();
            player.netServerHandler.sendPacket(new Packet42RemoveMobEffect(player.id, new MobEffect(type, 0, 0)));
          }
          Field field = EntityLiving.class.getDeclaredField("effects");
          field.setAccessible(true);
          @SuppressWarnings("rawtypes")
        HashMap effects = (HashMap)field.get(((CraftLivingEntity)entity).getHandle());
          effects.remove(Integer.valueOf(type)); } catch (Exception e) {
        }
      }
    }
    Questions?
     
    Samkio likes this.
  21. Offline

    XepherLink

    DrugMeUp Omgmgmgmmg make it :3 I hug I hug
     
    hammale likes this.
  22. Offline

    hammale

    lolz with MobEffects u can flip the screen upside down :p
     
  23. Offline

    XepherLink

    Are you making the drug effects plugin without spout?
     
  24. Offline

    hammale

    yup this plugin is 0% SPOUT DEPENDENT!!! and might i say i was able to add a few more things :D heres some new features but i wanna get back to coding it so ill make it brief:

    * screen flipping
    * jumping very high
    * weird screen spinning look
    * walking fast/slow with weird screen
    * near blindness
    * super strength/weekness

    and more and more and more and its all 100% configible!

    @ccrock4t, @anyone_who_cares

    Ok it cant handle multiple effects per-drug yet, i dont have the bukkitDev page up yet, and there may be a few bugs here and there but its worthy of alpha testing :D To take a "drug" rite click the air with the item in the config Download it here. (dont worry, it my private domain, theres no viruses :p )

    To use:
    Just place it in your plugin folder and run the server once. after that a folder called DrugMeUp will be generated. Inside you need to open up the config.yml.

    The initial config.yml looks like this:
    Code:
    DrugIds:
          '353':
            Effect: 9
          '351':
            Effect: 9
          '40':
            Effect: 9
    
    the DrugId's are simply the data values for the drugs you want to use. you can find a complete list here. You can add however many/few drugs as you want. I just put those three in to give you a starting point.

    What is a bit more interesting and complicated is the Effect. Here are the current avaliable effects (as this is still alpha you can only assign one per drug):

    These first 3 are hard to explain, u kinda need to try them 4 urself :D

    Effect 1: Makes the world spin and makes you walk funny (needs to be fine tuned)

    Effect 2: Zooms everything in and makes you walk slow

    Effect 3: Zooms everything out and makes you walk faster

    Effect 4: SupaStrength! Makes you deal more damage and break blocks faster!

    Effect 5: Restricts view area "blinding" you

    Effect 6: makes you SUPER hungry!

    Effect 7: Makes you sick, slows down mining speed, and weaker to any damage you take

    Effect 8: Gives you the ability to jump super high!

    Effect 9: Will randomly choose an effect each time the drug is used

    Because all of these are based on random numbers each time you do a "drug", even if its the same, the effect will be slightly different. Because I dont encourage drug use :D there are a few side effects:

    * While drunk your speech is MESSED up :D you kinda have to see it to really get it

    * When you take a drug there is a chance that you will either instantly OD and explode, burst into flames, or puke out your entire inventory

    * Again because of the randomness each time you take a drug there is no set time it will take to wear off

    NOTES/BUGS:
    When you "take" the "drug" it will take one of the items from ur inventory

    While drunk doing /me <message> is not scrambled

    In the future I plan to allow multiple drug effects per drug but as of rite now you cant

    You can take near infinite amounts drugs if you just hold down the key :D

    To take a "drug" rite click the air with the item in the config

    THIS IS ALPHA SO THERE WILL BE BUGS!!! IF YOU FIND SOME LEMME KNOW! ILL GET A BUKKITDEV PAGE UP TOMORROW!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  25. Offline

    XepherLink

    Make it so you have to shift right click to eat it, or it has a questioner and asks if you want to eat it when you right click it
     
  26. Offline

    hammale

    @XepherLink sure :D i like the shift idea...gimmie a few min

    @XepherLink ok sneeking (holding shift) is now required. get it here :D

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  27. Offline

    XepherLink

    O'd explosions are destoying my server, can you like have a option for that please ^_^
     
  28. Offline

    hammale

    lolz ill change it to instant death :D gimmie a sec, BTW can i has ur server ip im boooored :p

    @XepherLink ok OD's are now just instant death w/ no boom :D same ol' link :p

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 22, 2016
  29. Offline

    undefinedarray

    plugin is awesome :D keep up the good work
     
    hammale likes this.
  30. Offline

    XepherLink

    :3 Server isn't released until we are done, we have 1 more city to go
     
    hammale likes this.

Share This Page