Advertisement
LIONN

aCis Npc Buffer

Aug 10th, 2014
992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 33.37 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/util/DDSConverter.java
  4. ===================================================================
  5. --- java/net/sf/l2j/util/DDSConverter.java  (revision 0)
  6. +++ java/net/sf/l2j/util/DDSConverter.java  (working copy)
  7. @@ -0,0 +1,348 @@
  8. +package net.sf.l2j.util;
  9. +
  10. +
  11. +import java.awt.image.BufferedImage;
  12. +import java.io.File;
  13. +import java.io.IOException;
  14. +import java.nio.ByteBuffer;
  15. +import java.nio.ByteOrder;
  16. +import java.util.logging.Logger;
  17. +
  18. +import javax.imageio.ImageIO;
  19. +
  20. +public class DDSConverter
  21. +{
  22. +    public static final Logger _log = Logger.getLogger(DDSConverter.class.getName());
  23. +
  24. +    protected static class Color
  25. +    {
  26. +
  27. +        @Override
  28. +        public boolean equals(Object obj)
  29. +        {
  30. +            if (this == obj)
  31. +            {
  32. +                return true;
  33. +            }
  34. +            if ((obj == null) || (getClass() != obj.getClass()))
  35. +            {
  36. +                return false;
  37. +            }
  38. +            Color color = (Color) obj;
  39. +            if (b != color.b)
  40. +            {
  41. +                return false;
  42. +            }
  43. +            if (g != color.g)
  44. +            {
  45. +                return false;
  46. +            }
  47. +            return r == color.r;
  48. +        }
  49. +
  50. +        @Override
  51. +        public int hashCode()
  52. +        {
  53. +            int i = r;
  54. +            i = (29 * i) + g;
  55. +            i = (29 * i) + b;
  56. +            return i;
  57. +        }
  58. +
  59. +        protected int r;
  60. +        protected int g;
  61. +        protected int b;
  62. +
  63. +        public Color()
  64. +        {
  65. +            r = g = b = 0;
  66. +        }
  67. +
  68. +        public Color(int i, int j, int k)
  69. +        {
  70. +            r = i;
  71. +            g = j;
  72. +            b = k;
  73. +        }
  74. +    }
  75. +
  76. +    public static ByteBuffer convertToDDS(File file) throws IOException
  77. +    {
  78. +        if (file == null)
  79. +        {
  80. +            String s = "nullValue.FileIsNull";
  81. +            _log.severe(s);
  82. +            throw new IllegalArgumentException(s);
  83. +        }
  84. +        if (!file.exists() || !file.canRead())
  85. +        {
  86. +            String s1 = "DDSConverter.NoFileOrNoPermission";
  87. +            _log.severe(s1);
  88. +            throw new IllegalArgumentException(s1);
  89. +        }
  90. +        BufferedImage bufferedimage = ImageIO.read(file);
  91. +        if (bufferedimage == null)
  92. +        {
  93. +            return null;
  94. +        }
  95. +        if (bufferedimage.getColorModel().hasAlpha())
  96. +        {
  97. +            return convertToDxt3(bufferedimage);
  98. +        }
  99. +        return convertToDxt1NoTransparency(bufferedimage);
  100. +    }
  101. +
  102. +    public static ByteBuffer convertToDxt1NoTransparency(BufferedImage bufferedimage)
  103. +    {
  104. +        if (bufferedimage == null)
  105. +        {
  106. +            return null;
  107. +        }
  108. +        int ai[] = new int[16];
  109. +        int i = 128 + ((bufferedimage.getWidth() * bufferedimage.getHeight()) / 2);
  110. +        ByteBuffer bytebuffer = ByteBuffer.allocate(i);
  111. +        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
  112. +        buildHeaderDxt1(bytebuffer, bufferedimage.getWidth(), bufferedimage.getHeight());
  113. +        int j = bufferedimage.getWidth() / 4;
  114. +        int k = bufferedimage.getHeight() / 4;
  115. +        for (int l = 0; l < k; l++)
  116. +        {
  117. +            for (int i1 = 0; i1 < j; i1++)
  118. +            {
  119. +                BufferedImage bufferedimage1 = bufferedimage.getSubimage(i1 * 4, l * 4, 4, 4);
  120. +                bufferedimage1.getRGB(0, 0, 4, 4, ai, 0, 4);
  121. +                Color acolor[] = getColors888(ai);
  122. +                for (int j1 = 0; j1 < ai.length; j1++)
  123. +                {
  124. +                    ai[j1] = getPixel565(acolor[j1]);
  125. +                    acolor[j1] = getColor565(ai[j1]);
  126. +                }
  127. +
  128. +                int ai1[] = determineExtremeColors(acolor);
  129. +                if (ai[ai1[0]] < ai[ai1[1]])
  130. +                {
  131. +                    int k1 = ai1[0];
  132. +                    ai1[0] = ai1[1];
  133. +                    ai1[1] = k1;
  134. +                }
  135. +                bytebuffer.putShort((short) ai[ai1[0]]);
  136. +                bytebuffer.putShort((short) ai[ai1[1]]);
  137. +                long l1 = computeBitMask(acolor, ai1);
  138. +                bytebuffer.putInt((int) l1);
  139. +            }
  140. +        }
  141. +        return bytebuffer;
  142. +    }
  143. +
  144. +    public static ByteBuffer convertToDxt3(BufferedImage bufferedimage)
  145. +    {
  146. +        if (bufferedimage == null)
  147. +        {
  148. +            return null;
  149. +        }
  150. +        if (!bufferedimage.getColorModel().hasAlpha())
  151. +        {
  152. +            return convertToDxt1NoTransparency(bufferedimage);
  153. +        }
  154. +        int ai[] = new int[16];
  155. +        int i = 128 + (bufferedimage.getWidth() * bufferedimage.getHeight());
  156. +        ByteBuffer bytebuffer = ByteBuffer.allocate(i);
  157. +        bytebuffer.order(ByteOrder.LITTLE_ENDIAN);
  158. +        buildHeaderDxt3(bytebuffer, bufferedimage.getWidth(), bufferedimage.getHeight());
  159. +        int j = bufferedimage.getWidth() / 4;
  160. +        int k = bufferedimage.getHeight() / 4;
  161. +        for (int l = 0; l < k; l++)
  162. +        {
  163. +            for (int i1 = 0; i1 < j; i1++)
  164. +            {
  165. +                BufferedImage bufferedimage1 = bufferedimage.getSubimage(i1 * 4, l * 4, 4, 4);
  166. +                bufferedimage1.getRGB(0, 0, 4, 4, ai, 0, 4);
  167. +                Color acolor[] = getColors888(ai);
  168. +                for (int j1 = 0; j1 < ai.length; j1 += 2)
  169. +                {
  170. +                    bytebuffer.put((byte) ((ai[j1] >>> 28) | (ai[j1 + 1] >>> 24)));
  171. +                }
  172. +
  173. +                for (int k1 = 0; k1 < ai.length; k1++)
  174. +                {
  175. +                    ai[k1] = getPixel565(acolor[k1]);
  176. +                    acolor[k1] = getColor565(ai[k1]);
  177. +                }
  178. +
  179. +                int ai1[] = determineExtremeColors(acolor);
  180. +                if (ai[ai1[0]] < ai[ai1[1]])
  181. +                {
  182. +                    int l1 = ai1[0];
  183. +                    ai1[0] = ai1[1];
  184. +                    ai1[1] = l1;
  185. +                }
  186. +                bytebuffer.putShort((short) ai[ai1[0]]);
  187. +                bytebuffer.putShort((short) ai[ai1[1]]);
  188. +                long l2 = computeBitMask(acolor, ai1);
  189. +                bytebuffer.putInt((int) l2);
  190. +            }
  191. +        }
  192. +        return bytebuffer;
  193. +    }
  194. +
  195. +    protected static void buildHeaderDxt1(ByteBuffer bytebuffer, int i, int j)
  196. +    {
  197. +        bytebuffer.rewind();
  198. +        bytebuffer.put((byte) 68);
  199. +        bytebuffer.put((byte) 68);
  200. +        bytebuffer.put((byte) 83);
  201. +        bytebuffer.put((byte) 32);
  202. +        bytebuffer.putInt(124);
  203. +        int k = 0xa1007;
  204. +        bytebuffer.putInt(k);
  205. +        bytebuffer.putInt(j);
  206. +        bytebuffer.putInt(i);
  207. +        bytebuffer.putInt((i * j) / 2);
  208. +        bytebuffer.putInt(0);
  209. +        bytebuffer.putInt(0);
  210. +        bytebuffer.position(bytebuffer.position() + 44);
  211. +        bytebuffer.putInt(32);
  212. +        bytebuffer.putInt(4);
  213. +        bytebuffer.put((byte) 68);
  214. +        bytebuffer.put((byte) 88);
  215. +        bytebuffer.put((byte) 84);
  216. +        bytebuffer.put((byte) 49);
  217. +        bytebuffer.putInt(0);
  218. +        bytebuffer.putInt(0);
  219. +        bytebuffer.putInt(0);
  220. +        bytebuffer.putInt(0);
  221. +        bytebuffer.putInt(0);
  222. +        bytebuffer.putInt(4096);
  223. +        bytebuffer.putInt(0);
  224. +        bytebuffer.position(bytebuffer.position() + 12);
  225. +    }
  226. +
  227. +    protected static void buildHeaderDxt3(ByteBuffer bytebuffer, int i, int j)
  228. +    {
  229. +        bytebuffer.rewind();
  230. +        bytebuffer.put((byte) 68);
  231. +        bytebuffer.put((byte) 68);
  232. +        bytebuffer.put((byte) 83);
  233. +        bytebuffer.put((byte) 32);
  234. +        bytebuffer.putInt(124);
  235. +        int k = 0xa1007;
  236. +        bytebuffer.putInt(k);
  237. +        bytebuffer.putInt(j);
  238. +        bytebuffer.putInt(i);
  239. +        bytebuffer.putInt(i * j);
  240. +        bytebuffer.putInt(0);
  241. +        bytebuffer.putInt(0);
  242. +        bytebuffer.position(bytebuffer.position() + 44);
  243. +        bytebuffer.putInt(32);
  244. +        bytebuffer.putInt(4);
  245. +        bytebuffer.put((byte) 68);
  246. +        bytebuffer.put((byte) 88);
  247. +        bytebuffer.put((byte) 84);
  248. +        bytebuffer.put((byte) 51);
  249. +        bytebuffer.putInt(0);
  250. +        bytebuffer.putInt(0);
  251. +        bytebuffer.putInt(0);
  252. +        bytebuffer.putInt(0);
  253. +        bytebuffer.putInt(0);
  254. +        bytebuffer.putInt(4096);
  255. +        bytebuffer.putInt(0);
  256. +        bytebuffer.position(bytebuffer.position() + 12);
  257. +    }
  258. +
  259. +    protected static int[] determineExtremeColors(Color acolor[])
  260. +    {
  261. +        int i = 0x80000000;
  262. +        int ai[] = new int[2];
  263. +        for (int j = 0; j < (acolor.length - 1); j++)
  264. +        {
  265. +            for (int k = j + 1; k < acolor.length; k++)
  266. +            {
  267. +                int l = distance(acolor[j], acolor[k]);
  268. +                if (l > i)
  269. +                {
  270. +                    i = l;
  271. +                    ai[0] = j;
  272. +                    ai[1] = k;
  273. +                }
  274. +            }
  275. +
  276. +        }
  277. +        return ai;
  278. +    }
  279. +
  280. +    protected static long computeBitMask(Color acolor[], int ai[])
  281. +    {
  282. +        Color acolor1[] =
  283. +        {
  284. +            null,
  285. +            null,
  286. +            new Color(),
  287. +            new Color()
  288. +        };
  289. +        acolor1[0] = acolor[ai[0]];
  290. +        acolor1[1] = acolor[ai[1]];
  291. +        if (acolor1[0].equals(acolor1[1]))
  292. +        {
  293. +            return 0L;
  294. +        }
  295. +        acolor1[2].r = ((2 * acolor1[0].r) + acolor1[1].r + 1) / 3;
  296. +        acolor1[2].g = ((2 * acolor1[0].g) + acolor1[1].g + 1) / 3;
  297. +        acolor1[2].b = ((2 * acolor1[0].b) + acolor1[1].b + 1) / 3;
  298. +        acolor1[3].r = (acolor1[0].r + (2 * acolor1[1].r) + 1) / 3;
  299. +        acolor1[3].g = (acolor1[0].g + (2 * acolor1[1].g) + 1) / 3;
  300. +        acolor1[3].b = (acolor1[0].b + (2 * acolor1[1].b) + 1) / 3;
  301. +        long l = 0L;
  302. +        for (int i = 0; i < acolor.length; i++)
  303. +        {
  304. +            int j = 0x7fffffff;
  305. +            int k = 0;
  306. +            for (int i1 = 0; i1 < acolor1.length; i1++)
  307. +            {
  308. +                int j1 = distance(acolor[i], acolor1[i1]);
  309. +                if (j1 < j)
  310. +                {
  311. +                    j = j1;
  312. +                    k = i1;
  313. +                }
  314. +            }
  315. +
  316. +            l |= k << (i * 2);
  317. +        }
  318. +        return l;
  319. +    }
  320. +
  321. +    protected static int getPixel565(Color color)
  322. +    {
  323. +        int i = color.r >> 3;
  324. +        int j = color.g >> 2;
  325. +        int k = color.b >> 3;
  326. +        return (i << 11) | (j << 5) | k;
  327. +    }
  328. +
  329. +    protected static Color getColor565(int i)
  330. +    {
  331. +        Color color = new Color();
  332. +        color.r = (int) (i & 63488L) >> 11;
  333. +        color.g = (int) (i & 2016L) >> 5;
  334. +        color.b = (int) (i & 31L);
  335. +        return color;
  336. +    }
  337. +
  338. +    protected static Color[] getColors888(int ai[])
  339. +    {
  340. +        Color acolor[] = new Color[ai.length];
  341. +        for (int i = 0; i < ai.length; i++)
  342. +        {
  343. +            acolor[i] = new Color();
  344. +            acolor[i].r = (int) (ai[i] & 0xff0000L) >> 16;
  345. +            acolor[i].g = (int) (ai[i] & 65280L) >> 8;
  346. +            acolor[i].b = (int) (ai[i] & 255L);
  347. +        }
  348. +        return acolor;
  349. +    }
  350. +
  351. +    protected static int distance(Color color, Color color1)
  352. +    {
  353. +        return ((color1.r - color.r) * (color1.r - color.r)) + ((color1.g - color.g) * (color1.g - color.g)) + ((color1.b - color.b) * (color1.b - color.b));
  354. +    }
  355. +}
  356. \ No newline at end of file
  357. Index: java/net/sf/l2j/gameserver/model/actor/instance/L2BufferArchiveInstance.java
  358. ===================================================================
  359. --- java/net/sf/l2j/gameserver/model/actor/instance/L2BufferArchiveInstance.java    (revision 0)
  360. +++ java/net/sf/l2j/gameserver/model/actor/instance/L2BufferArchiveInstance.java    (working copy)
  361. @@ -0,0 +1,339 @@
  362. + /*
  363. + * This program is free software; you can redistribute it and/or modify
  364. + * it under the terms of the GNU General Public License as published by
  365. + * the Free Software Foundation; either version 2, or (at your option)
  366. + * any later version.
  367. + *
  368. + * This program is distributed in the hope that it will be useful,
  369. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  370. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  371. + * GNU General Public License for more details.
  372. + *
  373. + * You should have received a copy of the GNU General Public License
  374. + * along with this program; if not, write to the Free Software
  375. + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  376. + * 02111-1307, USA.
  377. + *
  378. + * http://www.gnu.org/copyleft/gpl.html
  379. + */
  380. +package net.sf.l2j.gameserver.model.actor.instance;
  381. +
  382. +import java.io.File;
  383. +import java.util.StringTokenizer;
  384. +
  385. +import net.sf.l2j.Config;
  386. +import net.sf.l2j.gameserver.ai.CtrlIntention;
  387. +import net.sf.l2j.gameserver.datatables.SkillTable;
  388. +import net.sf.l2j.gameserver.model.L2Effect;
  389. +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
  390. +import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
  391. +import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
  392. +import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
  393. +import net.sf.l2j.gameserver.network.serverpackets.PledgeCrest;
  394. +import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
  395. +import net.sf.l2j.gameserver.network.serverpackets.MagicSkillUse;
  396. +import net.sf.l2j.gameserver.templates.skills.L2SkillType;
  397. +import net.sf.l2j.util.DDSConverter;
  398. +import net.sf.l2j.util.StringUtil;
  399. +
  400. +/**
  401. + * @author Elfocrash
  402. + */
  403. +public final class L2BufferArchiveInstance extends L2NpcInstance
  404. +{
  405. +    public L2BufferArchiveInstance(int objectId, NpcTemplate template)
  406. +    {
  407. +        super(objectId, template);
  408. +    }
  409. +
  410. +    int state = 0;
  411. +    @Override
  412. +    public void onAction(L2PcInstance client)
  413. +    {
  414. +        if (this != client.getTarget())
  415. +        {
  416. +            client.setTarget(this);
  417. +            client.sendPacket(new MyTargetSelected(getObjectId(), 0));
  418. +            client.sendPacket(new ValidateLocation(this));
  419. +        }
  420. +        else
  421. +        {
  422. +            client.sendPacket(new MyTargetSelected(getObjectId(), 0));
  423. +            client.getAI().setIntention(CtrlIntention.INTERACT, this);
  424. +
  425. +            if (!isInsideRadius(client, 150, false, false))
  426. +                client.sendPacket(ActionFailed.STATIC_PACKET);
  427. +            else
  428. +                showMessageWindow(client);
  429. +        }
  430. +    }
  431. +
  432. +    @Override
  433. +    public void onBypassFeedback(L2PcInstance client, String command)
  434. +    {
  435. +        if (!client.isDead())
  436. +        {
  437. +            StringTokenizer st = new StringTokenizer(command, " ");
  438. +            String actualCommand = st.nextToken();
  439. +
  440. +            int buffid = 0;
  441. +            int bufflevel = 1;
  442. +            if (st.countTokens() == 2)
  443. +            {
  444. +                buffid = Integer.valueOf(st.nextToken());
  445. +                bufflevel = Integer.valueOf(st.nextToken());
  446. +            }
  447. +            else if (st.countTokens() == 1)
  448. +                buffid = Integer.valueOf(st.nextToken());
  449. +
  450. +            if (actualCommand.equalsIgnoreCase("getbuff"))
  451. +            {
  452. +                if (buffid != 0)
  453. +                {
  454. +                    MagicSkillUse mgc = new MagicSkillUse(this, client, buffid, bufflevel, 500, 0);
  455. +                    SkillTable.getInstance().getInfo(buffid, bufflevel).getEffects(this, client);
  456. +                    showMessageWindow(client);
  457. +                    client.broadcastPacket(mgc);
  458. +                }
  459. +            }
  460. +            else if (actualCommand.equalsIgnoreCase("restore"))
  461. +            {
  462. +                MagicSkillUse mgc = new MagicSkillUse(this, client, 1258, 4, 500, 0);
  463. +                client.setCurrentHpMp(client.getMaxHp(), client.getMaxMp());
  464. +                client.setCurrentCp(client.getMaxCp());
  465. +                showMessageWindow(client);
  466. +                client.broadcastPacket(mgc);
  467. +            }
  468. +            else if (actualCommand.equalsIgnoreCase("cancel"))
  469. +            {
  470. +                MagicSkillUse mgc = new MagicSkillUse(this, client, 1056, 12, 500, 0);
  471. +                client.stopAllEffects();
  472. +                showMessageWindow(client);
  473. +                client.broadcastPacket(mgc);
  474. +            }
  475. +            else if (actualCommand.equalsIgnoreCase("setstate0"))
  476. +            {
  477. +               state = 0;
  478. +               showMessageWindow(client);
  479. +            }
  480. +            else if (actualCommand.equalsIgnoreCase("setstate1"))
  481. +            {
  482. +               state = 1;
  483. +               showMessageWindow(client);
  484. +            }
  485. +            else if (actualCommand.equalsIgnoreCase("setstate2"))
  486. +            {
  487. +               state = 2;
  488. +               showMessageWindow(client);
  489. +            }
  490. +            else if (actualCommand.equalsIgnoreCase("setstate3"))
  491. +            {
  492. +               state = 3;
  493. +               showMessageWindow(client);
  494. +            }
  495. +            else
  496. +                super.onBypassFeedback(client, command);
  497. +        }
  498. +    }
  499. +
  500. +    private static int getCurrentBuffs(L2PcInstance activechar)
  501. +    {
  502. +        int i = 0;
  503. +
  504. +        for (L2Effect e : activechar.getAllEffects())
  505. +        {
  506. +            if (e.getSkill().getSkillType() == L2SkillType.BUFF)
  507. +            i++;
  508. +    }
  509. +
  510. +    return i;
  511. +    }
  512. +
  513. +    private void showMessageWindow(L2PcInstance client)
  514. +    {
  515. +        NpcHtmlMessage html = new NpcHtmlMessage(1);
  516. +        final StringBuilder sb = StringUtil.startAppend(3500, "<html><body>");
  517. +        int imgId = 0;
  518. +        
  519. +        switch (getCurrentBuffs(client)) {
  520. +        case 0:  imgId = 20010;
  521. +                generateLogo(client, 20010);
  522. +                 break;
  523. +        case 1:  imgId = 20011;
  524. +        generateLogo(client, 20011);
  525. +                 break;
  526. +        case 2:  imgId = 20012;
  527. +        generateLogo(client, 20012);
  528. +                 break;
  529. +        case 3:  imgId = 20013;
  530. +        generateLogo(client, 20013);
  531. +                 break;
  532. +        case 4:  imgId = 20014;
  533. +        generateLogo(client, 20014);
  534. +                 break;
  535. +        case 5:  imgId = 20015;
  536. +        generateLogo(client, 20015);
  537. +                 break;
  538. +        case 6:  imgId = 20016;
  539. +        generateLogo(client, 20016);
  540. +                 break;
  541. +        case 7:  imgId = 20017;
  542. +        generateLogo(client, 20017);
  543. +                 break;
  544. +        case 8:  imgId = 20018;
  545. +        generateLogo(client, 20018);
  546. +                 break;
  547. +        case 9:  imgId = 20019;
  548. +        generateLogo(client, 20019);
  549. +                 break;
  550. +        case 10: imgId = 20020;
  551. +        generateLogo(client, 20020);
  552. +                 break;
  553. +        case 11: imgId = 20021;
  554. +        generateLogo(client, 20021);
  555. +                 break;
  556. +        case 12: imgId = 20022;
  557. +        generateLogo(client, 20022);
  558. +                 break;
  559. +        case 13:  imgId = 20023;
  560. +        generateLogo(client, 20023);
  561. +                break;
  562. +        case 14:  imgId = 20024;
  563. +        generateLogo(client, 20024);
  564. +                break;
  565. +        case 15:  imgId = 20025;
  566. +        generateLogo(client, 20025);
  567. +                break;
  568. +        case 16:  imgId = 20026;
  569. +        generateLogo(client, 20026);
  570. +                break;
  571. +        case 17:  imgId = 20027;
  572. +        generateLogo(client, 20027);
  573. +                break;
  574. +        case 18:  imgId = 20028;
  575. +        generateLogo(client, 20028);
  576. +                break;
  577. +        case 19:  imgId = 20029;
  578. +        generateLogo(client, 20029);
  579. +                break;
  580. +        case 20:  imgId = 20030;
  581. +        generateLogo(client, 20030);
  582. +                break;
  583. +        case 21:  imgId = 20031;
  584. +        generateLogo(client, 20031);
  585. +                break;
  586. +        case 22: imgId = 20032;
  587. +        generateLogo(client, 20032);
  588. +                break;
  589. +        case 23: imgId = 20033;
  590. +        generateLogo(client, 20033);
  591. +                break;
  592. +        case 24: imgId = 20034;
  593. +        generateLogo(client, 20034);
  594. +                break;
  595. +        default: imgId = 20034;
  596. +        generateLogo(client, 20034);
  597. +                 break;
  598. +    }
  599. +
  600. +
  601. +        sb.append("<center><font color=\"FF9900\">AIO Buffer Laena</font></center>");
  602. +
  603. +        sb.append("<table width=\"256\" cellpadding=\"5\" bgcolor=\"000000\"><tr><td><img src=\"Crest.crest_" + Config.SERVER_ID + "_" + imgId + "\" width=256 height=16></td></tr></table>");
  604. +
  605. +        if(state ==0)
  606. +       {
  607. +        sb.append("<br><center><font color=\"FF9900\">Buffs</font></center><table width=\"256\" cellpadding=\"5\">");
  608. +        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1204 130\" width=32 height=32 back=\"icon.skill1204\" fore=\"icon.skill1204\"></td>");
  609. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1040 130\" width=32 height=32 back=\"icon.skill1040\" fore=\"icon.skill1040\"></td>");
  610. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1068 130\" width=32 height=32 back=\"icon.skill1068\" fore=\"icon.skill1068\"></td>");
  611. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1036 130\" width=32 height=32 back=\"icon.skill1036\" fore=\"icon.skill1036\"></td><");
  612. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1035 130\" width=32 height=32 back=\"icon.skill1035\" fore=\"icon.skill1035\"></td></tr>");
  613. +        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1045 130\" width=32 height=32 back=\"icon.skill1045\" fore=\"icon.skill1045\"></td>");
  614. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1048 130\" width=32 height=32 back=\"icon.skill1048\" fore=\"icon.skill1048\"></td>");
  615. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1062 130\" width=32 height=32 back=\"icon.skill1062\" fore=\"icon.skill1062\"></td>");
  616. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1086 130\" width=32 height=32 back=\"icon.skill1086\" fore=\"icon.skill1086\"></td>");
  617. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1240 130\" width=32 height=32 back=\"icon.skill1240\" fore=\"icon.skill1240\"></td></tr>");
  618. +        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1242 130\" width=32 height=32 back=\"icon.skill1242\" fore=\"icon.skill1242\"></td>");
  619. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1077 130\" width=32 height=32 back=\"icon.skill1077\" fore=\"icon.skill1077\"></td>");
  620. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1268 130\" width=32 height=32 back=\"icon.skill1268\" fore=\"icon.skill1268\"></td>");
  621. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1087 130\" width=32 height=32 back=\"icon.skill1087\" fore=\"icon.skill1087\"></td>");
  622. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1085 130\" width=32 height=32 back=\"icon.skill1085\" fore=\"icon.skill1085\"></td></tr>");
  623. +        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1059 130\" width=32 height=32 back=\"icon.skill1059\" fore=\"icon.skill1059\"></td>");
  624. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1303 130\" width=32 height=32 back=\"icon.skill1303\" fore=\"icon.skill1303\"></td>");
  625. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1078 130\" width=32 height=32 back=\"icon.skill1078\" fore=\"icon.skill1078\"></td>");
  626. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1243 130\" width=32 height=32 back=\"icon.skill1243\" fore=\"icon.skill1243\"></td>");
  627. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1259 130\" width=32 height=32 back=\"icon.skill1259\" fore=\"icon.skill1259\"></td></tr>"
  628. +                + "<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 1304 130\" width=32 height=32 back=\"icon.skill1304\" fore=\"icon.skill1304\"></td></tr></table>");
  629. +       }
  630. +       else
  631. +           sb.append("<br><center><a action=\"bypass npc_%objectId%_setstate0\">Buffs [+]</a></center>");
  632. +
  633. +
  634. +       if(state == 1)
  635. +       {
  636. +        sb.append("<center><font color=\"FF9900\">Dances</font></center><table width=\"200\" cellpadding=\"5\">");
  637. +        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 271 130\" width=32 height=32 back=\"icon.skill0271\" fore=\"icon.skill0271\"></td>");
  638. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 274 130\" width=32 height=32 back=\"icon.skill0274\" fore=\"icon.skill0274\"></td>");
  639. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 275 130\" width=32 height=32 back=\"icon.skill0275\" fore=\"icon.skill0275\"></td>");
  640. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 272 130\" width=32 height=32 back=\"icon.skill0272\" fore=\"icon.skill0272\"></td></tr>");
  641. +        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 310 130\" width=32 height=32 back=\"icon.skill0310\" fore=\"icon.skill0310\"></td>");
  642. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 273 130\" width=32 height=32 back=\"icon.skill0273\" fore=\"icon.skill0273\"></td>");
  643. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 276 130\" width=32 height=32 back=\"icon.skill0276\" fore=\"icon.skill0276\"></td>");
  644. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 277 130\" width=32 height=32 back=\"icon.skill0277\" fore=\"icon.skill0277\"></td></tr></table>");
  645. +       }
  646. +       else
  647. +           sb.append("<br><center><a action=\"bypass npc_%objectId%_setstate1\">Dances [+]</a></center>");
  648. +
  649. +       if(state == 2)
  650. +       {
  651. +        sb.append("<center><font color=\"FF9900\">Songs</font></center><table width=\"200\" cellpadding=\"5\">");
  652. +        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 264 130\" width=32 height=32 back=\"icon.skill0264\" fore=\"icon.skill0264\"></td>");
  653. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 304 130\" width=32 height=32 back=\"icon.skill0304\" fore=\"icon.skill0304\"></td>");
  654. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 268 130\" width=32 height=32 back=\"icon.skill0268\" fore=\"icon.skill0268\"></td>");
  655. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 267 130\" width=32 height=32 back=\"icon.skill0267\" fore=\"icon.skill0267\"></td></tr>");
  656. +        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_getbuff 266 130\" width=32 height=32 back=\"icon.skill0266\" fore=\"icon.skill0266\"></td>");
  657. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 269 130\" width=32 height=32 back=\"icon.skill0269\" fore=\"icon.skill0269\"></td>");
  658. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 265 130\" width=32 height=32 back=\"icon.skill0265\" fore=\"icon.skill0265\"></td>");
  659. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_getbuff 270 130\" width=32 height=32 back=\"icon.skill0270\" fore=\"icon.skill0270\"></td></tr></table>");
  660. +       }
  661. +       else
  662. +           sb.append("<br><center><a action=\"bypass npc_%objectId%_setstate2\">Song [+]</a></center>");
  663. +
  664. +       if(state == 3)
  665. +       {
  666. +        sb.append("<center><font color=\"FF9900\">Restore/Cancel</font></center><table width=\"100\" cellpadding=\"5\">");
  667. +        sb.append("<tr><td><button action=\"bypass npc_" + getObjectId() + "_restore\" width=32 height=32 back=\"icon.skill0058\" fore=\"icon.skill0058\"></td>");
  668. +        sb.append("<td><button action=\"bypass npc_" + getObjectId() + "_cancel\" width=32 height=32 back=\"icon.skill1056\" fore=\"icon.skill1056\"></td></tr>");
  669. +       }
  670. +       else
  671. +           sb.append("<br><center><a action=\"bypass npc_%objectId%_setstate3\">Restore/Cancel [+]</a></center>");
  672. +
  673. +       // sb.append("</table>");
  674. +
  675. +
  676. +        sb.append("</body></html>");
  677. +
  678. +        html.setHtml(sb.toString());
  679. +        html.replace("%objectId%", String.valueOf(getObjectId()));
  680. +        html.replace("%charname%", client.getName());
  681. +        client.sendPacket(html);
  682. +    }
  683. +
  684. +    public static void generateLogo(L2PcInstance activeChar, int imgId)
  685. +    {
  686. +            try
  687. +            {
  688. +                
  689. +                    File captcha = new File("data/images/"+imgId+".png");
  690. +                     PledgeCrest packet = new PledgeCrest(imgId, DDSConverter.convertToDDS(captcha).array());
  691. +                     activeChar.sendPacket(packet);
  692. +        
  693. +            }
  694. +            catch (Exception e)
  695. +            {
  696. +            }
  697. +
  698. +    }
  699. +  
  700. +}
  701. \ No newline at end of file
  702. Index: java/net/sf/l2j/gameserver/network/serverpackets/PledgeCrest.java
  703. ===================================================================
  704. --- java/net/sf/l2j/gameserver/network/serverpackets/PledgeCrest.java   (revision 65)
  705. +++ java/net/sf/l2j/gameserver/network/serverpackets/PledgeCrest.java   (working copy)
  706. @@ -3,42 +3,36 @@
  707.   * the terms of the GNU General Public License as published by the Free Software
  708.   * Foundation, either version 3 of the License, or (at your option) any later
  709.   * version.
  710. - *
  711. + *
  712.   * This program is distributed in the hope that it will be useful, but WITHOUT
  713.   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  714.   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  715.   * details.
  716. - *
  717. + *
  718.   * You should have received a copy of the GNU General Public License along with
  719.   * this program. If not, see <http://www.gnu.org/licenses/>.
  720.   */
  721.  package net.sf.l2j.gameserver.network.serverpackets;
  722.  
  723. -import net.sf.l2j.gameserver.cache.CrestCache;
  724. -import net.sf.l2j.gameserver.cache.CrestCache.CrestType;
  725. -
  726.  public class PledgeCrest extends L2GameServerPacket
  727.  {
  728. -   private final int _crestId;
  729. -   private final byte[] _data;
  730. -  
  731. -   public PledgeCrest(int crestId)
  732. -   {
  733. -       _crestId = crestId;
  734. -       _data = CrestCache.getCrest(CrestType.PLEDGE, _crestId);
  735. -   }
  736. -  
  737. -   @Override
  738. -   protected final void writeImpl()
  739. -   {
  740. -       writeC(0x6c);
  741. -       writeD(_crestId);
  742. -       if (_data != null)
  743. -       {
  744. -           writeD(_data.length);
  745. -           writeB(_data);
  746. -       }
  747. -       else
  748. -           writeD(0);
  749. -   }
  750. +    private final int _crestId;
  751. +    private final byte[] _data;
  752. +    private final int _crestSize;
  753. +
  754. +     public PledgeCrest(int crestId, byte[] data)
  755. +    {
  756. +        _crestId = crestId;
  757. +        _data = data;
  758. +        _crestSize = _data.length;
  759. +    }
  760. +
  761. +    @Override
  762. +    protected final void writeImpl()
  763. +    {
  764. +        writeC(0x6c);
  765. +        writeD(_crestId);
  766. +        writeD(_crestSize);
  767. +        writeB(_data);
  768. +    }
  769.  }
  770. \ No newline at end of file
  771. Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestPledgeCrest.java
  772. ===================================================================
  773. --- java/net/sf/l2j/gameserver/network/clientpackets/RequestPledgeCrest.java    (revision 65)
  774. +++ java/net/sf/l2j/gameserver/network/clientpackets/RequestPledgeCrest.java    (working copy)
  775. @@ -3,38 +3,66 @@
  776.   * the terms of the GNU General Public License as published by the Free Software
  777.   * Foundation, either version 3 of the License, or (at your option) any later
  778.   * version.
  779. - *
  780. + *
  781.   * This program is distributed in the hope that it will be useful, but WITHOUT
  782.   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  783.   * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  784.   * details.
  785. - *
  786. + *
  787.   * You should have received a copy of the GNU General Public License along with
  788.   * this program. If not, see <http://www.gnu.org/licenses/>.
  789.   */
  790.  package net.sf.l2j.gameserver.network.clientpackets;
  791.  
  792. +import java.util.logging.Logger;
  793. +
  794. +import net.sf.l2j.Config;
  795. +import net.sf.l2j.gameserver.cache.CrestCache;
  796. +import net.sf.l2j.gameserver.cache.CrestCache.CrestType;
  797.  import net.sf.l2j.gameserver.network.serverpackets.PledgeCrest;
  798.  
  799.  public final class RequestPledgeCrest extends L2GameClientPacket
  800.  {
  801. -   private int _crestId;
  802. -  
  803. -   @Override
  804. -   protected void readImpl()
  805. -   {
  806. -       _crestId = readD();
  807. -   }
  808. -  
  809. -   @Override
  810. -   protected void runImpl()
  811. -   {
  812. -       sendPacket(new PledgeCrest(_crestId));
  813. -   }
  814. -  
  815. -   @Override
  816. -   protected boolean triggersOnActionRequest()
  817. -   {
  818. -       return false;
  819. -   }
  820. +    private static Logger _log = Logger.getLogger(RequestPledgeCrest.class.getName());
  821. +    private int _crestId;
  822. +
  823. +    @Override
  824. +    protected void readImpl()
  825. +    {
  826. +        _crestId = readD();
  827. +    }
  828. +
  829. +    @Override
  830. +    protected void runImpl()
  831. +    {
  832. +        if (_crestId == 0)
  833. +            {
  834. +                    return;
  835. +            }
  836. +            if (Config.DEBUG)
  837. +            {
  838. +                    _log.fine("crestid " + _crestId + " requested");
  839. +            }
  840. +
  841. +            byte[] data = CrestCache.getCrest(CrestType.PLEDGE, _crestId);
  842. +
  843. +            if (data != null)
  844. +            {
  845. +                    PledgeCrest pc = new PledgeCrest(_crestId, data);
  846. +                    sendPacket(pc);
  847. +            }
  848. +            else
  849. +            {
  850. +                    if (Config.DEBUG)
  851. +                    {
  852. +                            _log.fine("crest is missing:" + _crestId);
  853. +                    }
  854. +            }
  855. +    }
  856. +
  857. +    @Override
  858. +    protected boolean triggersOnActionRequest()
  859. +    {
  860. +        return false;
  861. +    }
  862.  }
  863. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement