SHOW:
|
|
- or go back to the newest paste.
| 1 | diff --git a/head-src/com/l2jfrozen/gameserver/ai/special/manager/AILoader.java b/head-src/com/l2jfrozen/gameserver/ai/special/manager/AILoader.java | |
| 2 | index afa63fc..b5cbb5d 100644 | |
| 3 | --- a/head-src/com/l2jfrozen/gameserver/ai/special/manager/AILoader.java | |
| 4 | +++ b/head-src/com/l2jfrozen/gameserver/ai/special/manager/AILoader.java | |
| 5 | @@ -45,6 +45,8 @@ | |
| 6 | import com.l2jfrozen.gameserver.ai.special.ZombieGatekeepers; | |
| 7 | import com.l2jfrozen.gameserver.thread.ThreadPoolManager; | |
| 8 | ||
| 9 | +import custom.AugmentShop.AugmentShop; | |
| 10 | + | |
| 11 | /** | |
| 12 | * @author qwerty | |
| 13 | */ | |
| 14 | @@ -57,6 +59,9 @@ | |
| 15 | {
| |
| 16 | LOGGER.info("AI load:");
| |
| 17 | ||
| 18 | + LOGGER.info(" - AugmentShop_l2j");
| |
| 19 | + ThreadPoolManager.getInstance().scheduleAi(new AugmentShop(-1, "AugmentShop", "ai"), 50); | |
| 20 | + | |
| 21 | LOGGER.info(" - Antharas_l2j");
| |
| 22 | ThreadPoolManager.getInstance().scheduleAi(new Antharas(-1, "antharas", "ai"), 100); | |
| 23 | ||
| 24 | diff --git a/head-src/custom/AugmentShop/AugmentShop.java b/head-src/custom/AugmentShop/AugmentShop.java | |
| 25 | new file mode 100644 | |
| 26 | index 0000000..1cb657d | |
| 27 | --- /dev/null | |
| 28 | +++ b/head-src/custom/AugmentShop/AugmentShop.java | |
| 29 | @@ -0,0 +1,158 @@ | |
| 30 | +package custom.AugmentShop; | |
| 31 | + | |
| 32 | +import java.sql.Connection; | |
| 33 | +import java.sql.PreparedStatement; | |
| 34 | + | |
| 35 | +import com.l2jfrozen.gameserver.model.Inventory; | |
| 36 | +import com.l2jfrozen.gameserver.model.actor.instance.L2ItemInstance; | |
| 37 | +import com.l2jfrozen.gameserver.model.actor.instance.L2NpcInstance; | |
| 38 | +import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance; | |
| 39 | +import com.l2jfrozen.gameserver.model.quest.Quest; | |
| 40 | +import com.l2jfrozen.gameserver.model.quest.QuestState; | |
| 41 | +import com.l2jfrozen.util.database.L2DatabaseFactory; | |
| 42 | + | |
| 43 | +/** | |
| 44 | + * | |
| 45 | + * @author Sarada Adapted | |
| 46 | + * | |
| 47 | + */ | |
| 48 | +public class AugmentShop extends Quest implements Runnable | |
| 49 | +{
| |
| 50 | + private final static int ITEM_ID = 57; | |
| 51 | + private final static int ITEM_COUNT = 1000000; | |
| 52 | + private final static String qn = "AugmentShop"; | |
| 53 | + private final static int NPC = 666667; | |
| 54 | + | |
| 55 | + public AugmentShop(int questId, String name, String descr) | |
| 56 | + {
| |
| 57 | + super(questId, name, descr); | |
| 58 | + | |
| 59 | + addStartNpc(NPC); | |
| 60 | + addTalkId(NPC); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @Override | |
| 64 | + public String onAdvEvent(String event, L2NpcInstance npc, L2PcInstance player) | |
| 65 | + {
| |
| 66 | + String htmltext = ""; | |
| 67 | + | |
| 68 | + if (event.equalsIgnoreCase("active1"))
| |
| 69 | + {
| |
| 70 | + htmltext = "active1.htm"; | |
| 71 | + } | |
| 72 | + | |
| 73 | + else if (event.equalsIgnoreCase("active2"))
| |
| 74 | + {
| |
| 75 | + htmltext = "active2.htm"; | |
| 76 | + } | |
| 77 | + | |
| 78 | + else if (event.equalsIgnoreCase("passive1"))
| |
| 79 | + {
| |
| 80 | + htmltext = "passive1.htm"; | |
| 81 | + } | |
| 82 | + | |
| 83 | + else if (event.equalsIgnoreCase("passive2"))
| |
| 84 | + {
| |
| 85 | + htmltext = "passive2.htm"; | |
| 86 | + } | |
| 87 | + | |
| 88 | + else if (event.equalsIgnoreCase("main"))
| |
| 89 | + {
| |
| 90 | + htmltext = "main.htm"; | |
| 91 | + } | |
| 92 | + | |
| 93 | + else | |
| 94 | + {
| |
| 95 | + | |
| 96 | + updateAugment(player, Integer.parseInt(event.substring(0,5)), Integer.parseInt(event.substring(6,10)), Integer.parseInt(event.substring(11,13))); | |
| 97 | + } | |
| 98 | + | |
| 99 | + | |
| 100 | + return htmltext; | |
| 101 | + } | |
| 102 | + | |
| 103 | + @Override | |
| 104 | + public String onTalk(L2NpcInstance npc, L2PcInstance player) | |
| 105 | + {
| |
| 106 | + String htmltext = ""; | |
| 107 | + QuestState qs = player.getQuestState(qn); | |
| 108 | + if (qs == null) | |
| 109 | + qs = newQuestState(player); | |
| 110 | + htmltext = "main.htm"; | |
| 111 | + return htmltext; | |
| 112 | + } | |
| 113 | + | |
| 114 | + public static void main(String[] args) | |
| 115 | + {
| |
| 116 | + new AugmentShop(-1, qn, "AugmentShop"); | |
| 117 | + } | |
| 118 | + | |
| 119 | + | |
| 120 | + @SuppressWarnings("null")
| |
| 121 | + private static void updateAugment(L2PcInstance player, int attributes, int skill, int level) | |
| 122 | + {
| |
| 123 | + L2ItemInstance item = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND); | |
| 124 | + if (player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) == null) | |
| 125 | + | |
| 126 | + {
| |
| 127 | + player.sendMessage("You have to equip a weapon.");
| |
| 128 | + return; | |
| 129 | + } | |
| 130 | + | |
| 131 | + if (player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).isAugmented()) | |
| 132 | + {
| |
| 133 | + player.sendMessage("The weapon is already augmented.");
| |
| 134 | + return; | |
| 135 | + } | |
| 136 | + | |
| 137 | + if (player.getInventory().getInventoryItemCount(ITEM_ID, -1) < ITEM_COUNT) | |
| 138 | + {
| |
| 139 | + player.sendMessage("You dont have enough item.");
| |
| 140 | + return; | |
| 141 | + } | |
| 142 | + | |
| 143 | + Connection con = null; | |
| 144 | + try | |
| 145 | + {
| |
| 146 | + player.destroyItemByItemId("Consume", ITEM_ID, ITEM_COUNT, player, true);
| |
| 147 | + con = L2DatabaseFactory.getInstance().getConnection(); | |
| 148 | + PreparedStatement statement = con.prepareStatement("REPLACE INTO augmentations VALUES(?,?,?,?)");
| |
| 149 | + statement.setInt(1, item.getObjectId()); | |
| 150 | + | |
| 151 | + statement.setInt(2, attributes*65536+1); | |
| 152 | + statement.setInt(3, skill); | |
| 153 | + statement.setInt(4, level); | |
| 154 | + | |
| 155 | + statement.executeUpdate(); | |
| 156 | + player.sendMessage("Succesfully augmented. You have to relog now.");
| |
| 157 | + statement.close(); | |
| 158 | + | |
| 159 | + } | |
| 160 | + catch (Exception e) | |
| 161 | + {
| |
| 162 | + LOGGER.info("Could not augment item: "+item.getObjectId()+" ", e);
| |
| 163 | + } | |
| 164 | + finally | |
| 165 | + {
| |
| 166 | + try | |
| 167 | + {
| |
| 168 | + | |
| 169 | + /*L2DatabaseFactory.close(con);*/ | |
| 170 | + con.close(); | |
| 171 | + } | |
| 172 | + catch (Exception e) | |
| 173 | + {
| |
| 174 | + } | |
| 175 | + } | |
| 176 | + } | |
| 177 | + | |
| 178 | + /* (non-Javadoc) | |
| 179 | + * @see java.lang.Runnable#run() | |
| 180 | + */ | |
| 181 | + @Override | |
| 182 | + public void run() | |
| 183 | + {
| |
| 184 | + } | |
| 185 | + | |
| 186 | + | |
| 187 | +} | |
| 188 | \ No newline at end of file | |
| 189 |