Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Actual Mobs plugin - need some help

Comments in 'Plugin Development' started by Qub1, Nov 18, 2013.

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

    Qub1 New Member

    Joined:
    Nov 6, 2013
    Posts:
    16
    Minecraft User:
    Qub1
    Ok, so I'm trying to do the impossible: I'm writing a plugin that spawns and moves mobs.

    Now I've gotten the spawning to work, hostile mobs spawn at night (I've removed that and I'm going to implement spawning based on light-level, so hostile mobs will also spawn during the day in dark places) and friendly mobs spawn always. They spawn at random locations and that is all working correctly.

    However, I want to animate the mobs. What I'm doing now is I set their speedX, speedY and speedZ values and then I call the entity's update() function. This is working, however moving them by setting their speed is inaccurate and laggy. I was wondering if there is another way to manipulate their position and move them, in a gradual way, so not like they're teleporting. I've been looking around for a function but couldn't find any. I know there must be one, since the server must also use some sort of mechanism to move the player entities.

    Thanks in advance for any help!
    Last edited by a moderator: Jan 28, 2016
    DunxandMinecraft likes this.
  2. 0becca0
    Offline

    0becca0 New Member

    Joined:
    Oct 4, 2013
    Posts:
    133
    Minecraft User:
    0becca0
    thata some great work my friend!! :) I believe wies knows alot aboit this and I believe that its not possible to have the monsters move. I think thats what ive seen said bt top developers.am I able to use your plugin.? :) just spawn the monsters and feiendly. I would love it if you dont then ill understand.
  3. Qub1
    Offline

    Qub1 New Member

    Joined:
    Nov 6, 2013
    Posts:
    16
    Minecraft User:
    Qub1
    Thanks for your reply :)

    I've already gotten the mobs to actually move, so that isn't really an issue. The way I did that was by sort of "pushing" them in a direction. It works, but it isn't a very accurate system. That's why I was asking an alternative, and yeah I've seen wies a lot on these forums, can I notify him of this thread?

    Anyway I'm planning to release a first version of the plugin soon, however as of now mobs are completely motionless (so no movement or attacking), however they do have their correct health values, drops and spawn conditions. But yeah I'm hoping to be able to implement some form of motion. If I can't find any alternative I'll just go with the "pushing" system. It might not be effective, but at least it works :D

    @wies
    Darunia18 and 0becca0 like this.
  4. 0becca0
    Offline

    0becca0 New Member

    Joined:
    Oct 4, 2013
    Posts:
    133
    Minecraft User:
    0becca0
    no problem =) i would LOVE to see your plugin get super popular!!! and even if they are motionless, its still awesome because it wouldnt be so lonely in minecraft PE lol. thats great that everything works the motion is the least of things i think its disabled by pocketmine only due to the fact that it can majorly lag the server. but great job!!!! do you think i may use your plugin on my server to test it and see how people react or what they say? my server is # 3 on one list and on another list we are # 12 =)

    @wies is really really realllyyyyy smart with pocketmine, hes like the person i look up to on here.
  5. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    754
    Plugins:
    2
    Minecraft User:
    Darunia18
    I'm really excited for this to be released :D Can't wait to see it.
  6. Qub1
    Offline

    Qub1 New Member

    Joined:
    Nov 6, 2013
    Posts:
    16
    Minecraft User:
    Qub1
    Ha sure you can use it, I'm just going to make a few more tweaks to make it more stable. Currently the supported mobs are Chickens, Cows, Pigs and Sheep. Sheep will have random colors. The plugin will always keep the number of mobs at a fixed number, so when you kill some mobs, it will keep spawning until it reaches that number. Next I'm going to try and make the enemy mobs work (to make them spawn I mean, attacking and actual damage will be done later). Once I've done that I'll post a test version.
  7. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    754
    Plugins:
    2
    Minecraft User:
    Darunia18
    This sounds amazing! :D If you can get this stable enough, maybe you can work on getting Zombie Pigmen to spawn only in a world named "Nether"? This would allow it to be used with the NetherQuick plugin for anyone who has a Nether world on their server :D
  8. Qub1
    Offline

    Qub1 New Member

    Joined:
    Nov 6, 2013
    Posts:
    16
    Minecraft User:
    Qub1
    Oh yeah that sounds like a great idea :), I'll add it to my To-Do list!
    Darunia18 likes this.
  9. TrilogiForce
    Offline

    TrilogiForce Ban Evader Banned

    Joined:
    Sep 7, 2013
    Posts:
    228
    Minecraft User:
    TrilogiForce
    you know why pocketmine doesnt have mobs spawning and movement because it gives LAG!
  10. Qub1
    Offline

    Qub1 New Member

    Joined:
    Nov 6, 2013
    Posts:
    16
    Minecraft User:
    Qub1
    You would think so yet I've found a way to do it without lag. Mobs only move and do stuff when they're in sight of a player, so the server doesn't have to do excessive processing. I'm also multithreading my plugin to reduce the workload on the main thread of the server which should make everything run quite smooth.

    And even if it would give lag, why not give server owners the option? Not saying that it does, so far I've experienced no lag at all while spawning AND moving up to 50 mobs at a time.
  11. TrilogiForce
    Offline

    TrilogiForce Ban Evader Banned

    Joined:
    Sep 7, 2013
    Posts:
    228
    Minecraft User:
    TrilogiForce
    but it would la more if you do that
    and there its a plugin called mobtest
    here the file so you can get based on:

    Attached Files:

    • mob.php
      File size:
      11 KB
      Views:
      698
  12. Qub1
    Offline

    Qub1 New Member

    Joined:
    Nov 6, 2013
    Posts:
    16
    Minecraft User:
    Qub1
    Hmm, that looks interesting I'll take a look, but not now since its 2 am here and I'm going to bed.

    But thanks for the file, I think it'll help a lot.
    And if it lags so be it, its fun to work on anyways.
  13. 0becca0
    Offline

    0becca0 New Member

    Joined:
    Oct 4, 2013
    Posts:
    133
    Minecraft User:
    0becca0
    define LAG...? network lag or graphical lag?
  14. 0becca0
    Offline

    0becca0 New Member

    Joined:
    Oct 4, 2013
    Posts:
    133
    Minecraft User:
    0becca0
    why thank you :) let me know please
  15. TrilogiForce
    Offline

    TrilogiForce Ban Evader Banned

    Joined:
    Sep 7, 2013
    Posts:
    228
    Minecraft User:
    TrilogiForce
    both of them but if you have a 20+mbs speed internet and a good/gamer device and a good computer to get 10% or less lag!
  16. 0becca0
    Offline

    0becca0 New Member

    Joined:
    Oct 4, 2013
    Posts:
    133
    Minecraft User:
    0becca0
    I think my device and my computer will handle that beyond perfect ;P... my connection well ill have to let it take ots own course. my router was 250.00 and my receicer in my pc was 140.00ish after tax. pc its worth about 4000.00 USD :)
  17. TrilogiForce
    Offline

    TrilogiForce Ban Evader Banned

    Joined:
    Sep 7, 2013
    Posts:
    228
    Minecraft User:
    TrilogiForce
  18. TrilogiForce
    Offline

    TrilogiForce Ban Evader Banned

    Joined:
    Sep 7, 2013
    Posts:
    228
    Minecraft User:
    TrilogiForce
    how ever pocketmine would lag cuz it just uses 10 mbs and maximum 30 mbs and it make lag if it doesnt use more memory
  19. 0becca0
    Offline

    0becca0 New Member

    Joined:
    Oct 4, 2013
    Posts:
    133
    Minecraft User:
    0becca0
    I wish we could let it use more thsn 35ish mb.. I have 6gb DDR3 oc to 2400mhz dedicated to pocket mine and i have a total of 16GB and it obly uses up like you said 30ish. Will they be updating pocke mine?
  20. Syriamanal
    Offline

    Syriamanal Ban Evader Banned

    Joined:
    Oct 2, 2013
    Posts:
    221
    Minecraft User:
    Syriamanal
    PHP:
    }
              
    $target $p->data["target"];
              
    //if ($target->closed) {
              //  unset($p->data["target"]);
              //} else {
              
    $xdiff    $target["x"] - $p->entity->x;
              
    $ydiff    $target["y"] - $p->entity->y;
              
    $zdiff    $target["z"] - $p->entity->z;
              
    $distaway pow($xdiff2) + pow($ydiff2) + pow($zdiff2);
              
    $angle    atan2($zdiff$xdiff) + rand(-M_PI/6,M_PI/6) ;
              if (
    $p->data["npcconf"]["mobile"]) {
                if (
    $distaway and rand(0100) > 25) {
                  
    $speedX            cos($angle) * rand(1014) / 100;
                  
    $speedZ            sin($angle) * rand(1014) / 100;
                  
    $p->entity->speedX $speedX;
                  
    $p->entity->speedZ $speedZ;
                } else {
                  
    $p->entity->speedX 0;
                  
    $p->entity->speedZ 0;
                }
              } else {
                
    $p->entity->speedX 0;
                
    $p->entity->speedZ 0;
              }
              
    $p->entity->yaw = (($angle 180) / M_PI) - rand(4014);
              
    $this->fireMoveEvent($p->entity);
     
    This for movement lol
    0becca0 likes this.
Thread Status:
Not open for further replies.

Share This Page

Advertisement