Attacking a Player with RemoteEntities

Discussion in 'Plugin Development' started by MrRedstone3000, Nov 23, 2014.

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

    MrRedstone3000

    Hello Everybody,
    i am having some problems with the RemoteEntities Library :

    I want a Player (RemoteEntityType.Human) to go up to the "real" Player and attack him.
    I am at this Point:


    Code:java
    1. package me.MrRedstone3000;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.Location;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.LivingEntity;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11. import org.bukkit.potion.PotionEffect;
    12. import org.bukkit.potion.PotionEffectType;
    13.  
    14. import de.kumpelblase2.remoteentities.CreateEntityContext;
    15. import de.kumpelblase2.remoteentities.EntityManager;
    16. import de.kumpelblase2.remoteentities.RemoteEntities;
    17. import de.kumpelblase2.remoteentities.api.RemoteEntity;
    18. import de.kumpelblase2.remoteentities.api.RemoteEntityType;
    19.  
    20.  
    21.  
    22. public class main extends JavaPlugin implements Listener {
    23.  
    24. private EntityManager manager;
    25.  
    26. public void onDisable() {
    27.  
    28. }
    29.  
    30. public void onEnable() {
    31.  
    32.  
    33. manager = RemoteEntities.createManager(this);
    34. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    35.  
    36. }
    37.  
    38.  
    39.  
    40.  
    41. public void spawnNPC(String name, Location loc) {
    42. CreateEntityContext c = manager
    43. .prepareEntity(RemoteEntityType.Human)
    44. .asPushable(true)
    45. .asStationary(false)
    46. .atLocation(loc)
    47. .withMaxHealth(40) //<--- kinda playing around with the args....
    48.  
    49. .withName(name);
    50.  
    51.  
    52.  
    53. RemoteEntity re = c.create();
    54.  
    55. LivingEntity NPC = re.getBukkitEntity();
    56. NPC.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 10, 100));
    57.  
    58.  
    59.  
    60.  
    61.  
    62. }
    63.  
    64.  
    65. public boolean onCommand(CommandSender sender, Command cmd, String Lable, String[] args) {
    66. Player p = (Player) sender;
    67. if(cmd.getName().equalsIgnoreCase("attack")) {
    68. spawnNPC(p.getPlayer().getName(), p.getPlayer().getLocation());
    69.  
    70. }
    71. return false;
    72.  
    73. }
    74.  
    75. }
    76.  



    Thanks for reading...
    and a helpfull replay woold be cool :)
     
  2. Offline

    Jaaakee224

    MrRedstone3000
    You're having some problems.. with what? Please give us more information with stack traces, etc.
     
  3. Offline

    sethrem

    Yo what version of craftbukkit are you using?
     
  4. Jaaakee224
    Doesn't look like he has any problems, rather he needs help with what to do next.

    sethrem
    Does that matter at all?

    MrRedstone3000
    Have you tried searching if remote entities has this feature already? If not, you will have to create a pseudo-attacking system. Move the entity to the player, maybe force it to do a swing animation, then damage the target using Entity#damage().
     
  5. Offline

    MrRedstone3000

    So, right now i dont realy have problem with my code (it works fine...).
    I just wanted to know how i can go on from here.
    What and wich code i need to put where in order to make it work... i am new on this Remote Etities stuff...
    There is a "DesireMoveAndMeleeAttack" i just dont realy understand how to put it in...(http://docs.infinityblade.de/remote...ities/api/thinking/goals/package-summary.html)
    By the way my craftbukkit is 1.7.2.

    Thanks a lot for replying ;)




     
  6. Offline

    sethrem

    MrRedstone3000 Hey what version of craftbukkit are you using? This is off topic but I'm trying to use remote entities aswell, but it doesn't see to work for my version.
     
  7. Offline

    MrRedstone3000

  8. Offline

    sethrem

    MrRedstone3000 So is mine but I always get an error with my entitymanager.
     
  9. Offline

    MrRedstone3000

    You have "depend: remote Etities" in your plugin.yml? Yust to be shure...
     
  10. Offline

    sethrem

    MrRedstone3000 yea but mine is spelled differently and spaced differently than yours
     
  11. Offline

    MrRedstone3000

    sethrem yes... its :
    Code:
    depend: [RemoteEntities]
    what is your error (what the console prints)?
     
  12. You can give the entity a desire using its Mind class.
    Code:
    LivingEntity target = ...;
    re.getMind().addTargetingDesire(new DesireKillTarget(target), 1);
    Change the DesireKillTarget to whatever desire you want (e.g. DesireMoveAndMeleeAttack).
     
  13. Offline

    MrRedstone3000

    So, i tried some ways out and i ended up with this result wich still doesnt attack the player... :

    Code:java
    1. package me.MrRedstone3000;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.Location;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.entity.LivingEntity;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11. import de.kumpelblase2.remoteentities.CreateEntityContext;
    12. import de.kumpelblase2.remoteentities.EntityManager;
    13. import de.kumpelblase2.remoteentities.RemoteEntities;
    14. import de.kumpelblase2.remoteentities.api.RemoteEntity;
    15. import de.kumpelblase2.remoteentities.api.RemoteEntityType;
    16. import de.kumpelblase2.remoteentities.api.thinking.goals.DesireMoveAndMeleeAttack;
    17.  
    18. public class main extends JavaPlugin implements Listener {
    19.  
    20. private EntityManager manager;
    21.  
    22. public void onDisable() {
    23.  
    24. }
    25.  
    26. public void onEnable() {
    27.  
    28.  
    29. manager = RemoteEntities.createManager(this);
    30. Bukkit.getServer().getPluginManager().registerEvents(this, this);
    31. }
    32.  
    33.  
    34. public void spawnNPC(String name, Location loc) {
    35. CreateEntityContext c = manager
    36. .prepareEntity(RemoteEntityType.Human)
    37. .asPushable(true)
    38. .asStationary(false)
    39. .atLocation(loc)
    40.  
    41. .withName(name);
    42.  
    43.  
    44.  
    45. RemoteEntity re = c.create();
    46.  
    47. //LivingEntity NPC = re.getBukkitEntity();
    48.  
    49.  
    50. re.getMind().addMovementDesire(new DesireMoveAndMeleeAttack(Player.class, true), 4);
    51.  
    52.  
    53.  
    54. }
    55.  
    56. public boolean onCommand(CommandSender sender, Command cmd, String Lable, String[] args) {
    57. Player p = (Player) sender;
    58. if(cmd.getName().equalsIgnoreCase("attack")) {
    59. spawnNPC(p.getPlayer().getName(), p.getPlayer().getLocation());
    60.  
    61. }
    62. return false;
    63.  
    64. }
    65.  
    66. }
    67.  



    I did it like this because the DesireMoveAndMeleeAttack needs : Class<?> inToAttack, boolean inIgnoreSight)

    Thanks
     
  14. Offline

    sethrem

    MrRedstone3000 Yea this is my error.
    Code:java
    1. [14:27:45 ERROR]: Could not load 'plugins\Hub.jar' in folder 'plugins'
    2. org.bukkit.plugin.UnknownDependencyException: RemoteEntities
    3. at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:196) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    4. at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.java:255) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    5. at org.bukkit.craftbukkit.v1_7_R1.CraftServer.reload(CraftServer.java:628) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    6. at org.bukkit.Bukkit.reload(Bukkit.java:279) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    7. at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:23) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    8. at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:196) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    9. at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:542) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10. at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchServerCommand(CraftServer.java:529) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    11. at net.minecraft.server.v1_7_R1.DedicatedServer.aw(DedicatedServer.java:286) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    12. at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:251) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    13. at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    14. at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    15. at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    16.  
     
  15. Offline

    MrRedstone3000

    Ok, he doesnt get the dependency right...
    Make shure that every thing is correcly spelled.
     
Thread Status:
Not open for further replies.

Share This Page