root/branches/1.9/src/com/aionemu/gameserver/controllers/GatherableController.java
| 2325 | 2404 | ||
|---|---|---|---|
26 | import com.aionemu.gameserver.dataholders.DataManager; | 26 | import com.aionemu.gameserver.dataholders.DataManager; |
27 | import com.aionemu.gameserver.model.DescriptionId; | 27 | import com.aionemu.gameserver.model.DescriptionId; |
28 | import com.aionemu.gameserver.model.gameobjects.Gatherable; | 28 | import com.aionemu.gameserver.model.gameobjects.Gatherable; |
29 | import com.aionemu.gameserver.model.gameobjects.Item; | ||
29 | import com.aionemu.gameserver.model.gameobjects.player.Player; | 30 | import com.aionemu.gameserver.model.gameobjects.player.Player; |
30 | import com.aionemu.gameserver.model.templates.GatherableTemplate; | 31 | import com.aionemu.gameserver.model.templates.GatherableTemplate; |
31 | import com.aionemu.gameserver.model.templates.gather.Material; | 32 | import com.aionemu.gameserver.model.templates.gather.Material; |
33 | import com.aionemu.gameserver.model.templates.item.ItemTemplate; | ||
32 | import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE; | 34 | import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE; |
35 | import com.aionemu.gameserver.services.ItemService; | ||
33 | import com.aionemu.gameserver.services.RespawnService; | 36 | import com.aionemu.gameserver.services.RespawnService; |
34 | import com.aionemu.gameserver.skillengine.task.GatheringTask; | 37 | import com.aionemu.gameserver.skillengine.task.GatheringTask; |
35 | import com.aionemu.gameserver.utils.PacketSendUtility; | 38 | import com.aionemu.gameserver.utils.PacketSendUtility; |
... | ... | ||
87 | } | 90 | } |
88 | 91 | ||
89 | else | 92 | else |
90 | { | 93 | { |
94 | | ||
95 | // need space in inventory | ||
96 | long storedMaterialCount = player.getInventory().getItemCountByItemId(material.getItemid()); | ||
97 | // player doesn't have material in inventory | ||
98 | if(storedMaterialCount == 0) | ||
99 | { | ||
100 | if(player.getInventory().getNumberOfFreeSlots() == 0) | ||
101 | { | ||
102 | PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.EXTRACT_GATHER_INVENTORY_IS_FULL()); | ||
103 | return; | ||
104 | } | ||
105 | } | ||
106 | // player already has material in inventory | ||
107 | else | ||
108 | { | ||
109 | Item materialItem = ItemService.newItem(material.getItemid(), 1); | ||
110 | if(storedMaterialCount >= materialItem.getItemTemplate().getMaxStackCount() && player.getInventory().getNumberOfFreeSlots() == 0) | ||
111 | { | ||
112 | PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.EXTRACT_GATHER_INVENTORY_IS_FULL()); | ||
113 | return; | ||
114 | } | ||
115 | } | ||
116 | | ||
91 | int gatherRate = 1; // 1x rates (probably make config later, if fixed to non-linear statistic probability) | 117 | int gatherRate = 1; // 1x rates (probably make config later, if fixed to non-linear statistic probability) |
92 | float maxrate = 0; | 118 | float maxrate = 0; |
93 | int rate = 0; | 119 | int rate = 0; |
... | ... | ||
180 | int xpReward = (int)((0.008*(skillLvl+100)*(skillLvl+100)+60)*player.getRates().getGatheringXPRate()); | 206 | int xpReward = (int)((0.008*(skillLvl+100)*(skillLvl+100)+60)*player.getRates().getGatheringXPRate()); |
181 | 207 | ||
182 | if (player.getSkillList().addSkillXp(player, getOwner().getObjectTemplate().getHarvestSkill(), xpReward)) | 208 | if (player.getSkillList().addSkillXp(player, getOwner().getObjectTemplate().getHarvestSkill(), xpReward)) |
209 | { | ||
210 | PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.EXTRACT_GATHER_SUCCESS_GETEXP()); | ||
183 | player.getCommonData().addExp(xpReward); | 211 | player.getCommonData().addExp(xpReward); |
212 | } | ||
184 | else | 213 | else |
185 | PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.MSG_DONT_GET_PRODUCTION_EXP(new DescriptionId(DataManager.SKILL_DATA.getSkillTemplate(getOwner().getObjectTemplate().getHarvestSkill()).getNameId()))); | 214 | PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.MSG_DONT_GET_PRODUCTION_EXP(new DescriptionId(DataManager.SKILL_DATA.getSkillTemplate(getOwner().getObjectTemplate().getHarvestSkill()).getNameId()))); |
186 | 215 |
Download diff