tobaJK

aCis spawn guards arround target

Dec 11th, 2018 (edited)
397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.51 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSpawn.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSpawn.java (revision 3)
  6. +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminSpawn.java (working copy)
  7. @@ -23,6 +23,7 @@
  8.  import net.sf.l2j.gameserver.model.actor.instance.Fence;
  9.  import net.sf.l2j.gameserver.model.actor.instance.Player;
  10.  import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  11. +import net.sf.l2j.gameserver.model.location.Location;
  12.  import net.sf.l2j.gameserver.network.SystemMessageId;
  13.  import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  14.  import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
  15. @@ -52,6 +53,7 @@
  16.         "admin_spawnday",
  17.         "admin_spawnfence",
  18.         "admin_deletefence",
  19. +       "admin_spawnguards",
  20.         "admin_listfence"
  21.     };
  22.    
  23. @@ -250,6 +252,19 @@
  24.         }
  25.         else if (command.startsWith("admin_listfence"))
  26.             listFences(activeChar);
  27. +       else if (command.startsWith("admin_spawnguards"))
  28. +       {
  29. +           if (activeChar.getTarget() == null || !(activeChar.getTarget() instanceof Npc))
  30. +           {
  31. +               activeChar.sendMessage("Npc not found.");
  32. +               return false;
  33. +           }
  34. +           final Npc npc = (Npc) activeChar.getTarget();
  35. +           final Location npcLoc = new Location(npc.getX(), npc.getY(), npc.getZ());
  36. +           spawnGuards(30382, 10, npcLoc, 250);
  37. +           spawnGuards(30381, 5, npcLoc, 120);
  38. +          
  39. +       }
  40.         else if (command.startsWith("admin_spawn"))
  41.         {
  42.             StringTokenizer st = new StringTokenizer(command, " ");
  43. @@ -272,6 +287,36 @@
  44.         return true;
  45.     }
  46.    
  47. +   private static void spawnGuards(int npcId, int count, Location npcLoc, int rad)
  48. +   {
  49. +       double angle = 2 * Math.PI / count;
  50. +      
  51. +       for (int i = 0; i < count; i++)
  52. +       {
  53. +           int x = npcLoc.getX() + (int) (Math.cos(angle * i) * rad);
  54. +           int y = npcLoc.getY() + (int) (Math.sin(angle * i) * rad);
  55. +           customSpawn(npcId, x, y, npcLoc);
  56. +       }
  57. +   }
  58. +  
  59. +   private static void customSpawn(int npcId, int x, int y, Location loc)
  60. +   {
  61. +       final NpcTemplate template = NpcData.getInstance().getTemplate(npcId);
  62. +       try
  63. +       {
  64. +           L2Spawn spawn = new L2Spawn(template);
  65. +           spawn.setLoc(x, y, loc.getZ(), 0);
  66. +           spawn.setRespawnDelay(10);
  67. +           SpawnTable.getInstance().addNewSpawn(spawn, false);
  68. +           spawn.doSpawn(false);
  69. +           spawn.setRespawnState(false);
  70. +       }
  71. +       catch (Exception e)
  72. +       {
  73. +       }
  74. +   }
  75. +  
  76.     @Override
  77.     public String[] getAdminCommandList()
  78.     {
Add Comment
Please, Sign In to add comment