Skip to content

Commit

Permalink
Stigma equip with skill update. Stigma remove is not updating stigma …
Browse files Browse the repository at this point in the history
…slot correctly (need relog or level update for now).
  • Loading branch information
ATracer authored and ATracer committed Apr 18, 2010
1 parent 9adac9c commit 4ba8071
Show file tree
Hide file tree
Showing 16 changed files with 316 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ public void onDialogSelect(int dialogId, final Player player, int questId)
break;
case 4:
// stigma
PacketSendUtility.sendPacket(player, new SM_MESSAGE(0, null, "This feature is not available yet",
ChatType.ANNOUNCEMENTS));
PacketSendUtility.sendPacket(player, new SM_DIALOG_WINDOW(targetObjectId, 1));
break;
case 5:
// create legion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void act(Player player, Item parentItem, Item targetItem)
// item is equipped, so need broadcast packet
if (player.getEquipment().getEquippedItemByObjId(targetItem.getObjectId()) != null)
{
PacketSendUtility.broadcastPacket(player, new SM_UPDATE_PLAYER_APPEARANCE(player.getObjectId(), player.getEquipment().getEquippedItems()), true);
PacketSendUtility.broadcastPacket(player, new SM_UPDATE_PLAYER_APPEARANCE(player.getObjectId(), player.getEquipment().getEquippedItemsWithoutStigma()), true);
player.getEquipment().setPersistentState(PersistentState.UPDATE_REQUIRED);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,41 +46,55 @@ public Equipment(Player player)
this.owner = player;
}

public boolean equipItem(int itemUniqueId, int slot)
/**
*
* @param itemUniqueId
* @param slot
* @return item or null in case of failure
*/
public Item equipItem(int itemUniqueId, int slot)
{
synchronized(equipment)
{
Item item = owner.getInventory().getItemByObjId(itemUniqueId);

if(item == null)
{
return false;
}
return null;

//don't allow to wear items of higher level
if(item.getItemTemplate().getLevel() > owner.getCommonData().getLevel())
{
PacketSendUtility.sendPacket(owner,
SM_SYSTEM_MESSAGE.STR_CANNOT_USE_ITEM_TOO_LOW_LEVEL_MUST_BE_THIS_LEVEL(
item.getItemTemplate().getLevel(), new DescriptionId(Integer.parseInt(item.getName()))));
return false;
return null;
}

int itemSlotToEquip = 0;

switch(item.getItemTemplate().getEquipmentType())
switch(item.getEquipmentType())
{
case ARMOR:
if(!validateEquippedArmor(item))
return false;
return null;
break;
case WEAPON:
if(!validateEquippedWeapon(item))
return false;
return null;
break;
}

//check whether there is already item in specified slot
int itemSlotMask = item.getItemTemplate().getItemSlot();
int itemSlotMask = 0 ;
switch(item.getEquipmentType())
{
case STIGMA:
itemSlotMask = slot;
break;
default:
item.getItemTemplate().getItemSlot();
break;
}

List<ItemSlot> possibleSlots = ItemSlot.getSlotsFor(itemSlotMask);
for(ItemSlot possibleSlot : possibleSlots)
Expand All @@ -98,7 +112,7 @@ public boolean equipItem(int itemUniqueId, int slot)
}

if(itemSlotToEquip == 0)
return false;
return null;

//remove item first from inventory to have at least one slot free
owner.getInventory().removeFromBag(item, false);
Expand All @@ -108,9 +122,9 @@ public boolean equipItem(int itemUniqueId, int slot)
unEquip(itemSlotToEquip);

equip(itemSlotToEquip, item);
}
setPersistentState(PersistentState.UPDATE_REQUIRED);
return true;
setPersistentState(PersistentState.UPDATE_REQUIRED);
return item;
}
}

private void equip(int slot, Item item)
Expand Down Expand Up @@ -139,15 +153,14 @@ private void equip(int slot, Item item)
*
* @param itemUniqueId
* @param slot
* @return true or false
* @return item or null in case of failure
*/
public boolean unEquipItem(int itemUniqueId, int slot)
public Item unEquipItem(int itemUniqueId, int slot)
{
//if inventory is full unequip action is disabled
if(owner.getInventory().isFull())
{
return false;
}
return null;

synchronized(equipment)
{
Item itemToUnequip = null;
Expand All @@ -161,9 +174,7 @@ public boolean unEquipItem(int itemUniqueId, int slot)
}

if(itemToUnequip == null || !itemToUnequip.isEquipped())
{
return false;
}
return null;

//if unequip bow - unequip arrows also
if(itemToUnequip.getItemTemplate().getWeaponType() == WeaponType.BOW)
Expand All @@ -173,7 +184,7 @@ public boolean unEquipItem(int itemUniqueId, int slot)
{
//TODO more wise check here is needed
if(owner.getInventory().getNumberOfFreeSlots() < 1)
return false;
return null;
unEquip(ItemSlot.SUB_HAND.getSlotIdMask());
}
}
Expand All @@ -184,7 +195,7 @@ public boolean unEquipItem(int itemUniqueId, int slot)
if(ohWeapon != null && ohWeapon.getItemTemplate().isWeapon())
{
if(owner.getInventory().getNumberOfFreeSlots() < 2)
return false;
return null;
else
unEquip(ItemSlot.SUB_HAND.getSlotIdMask());
}
Expand All @@ -198,8 +209,8 @@ public boolean unEquipItem(int itemUniqueId, int slot)
}

unEquip(itemToUnequip.getEquipmentSlot());
}
return true;
return itemToUnequip;
}
}

private void unEquip(int slot)
Expand Down Expand Up @@ -408,6 +419,22 @@ public List<Item> getEquippedItems()

return equippedItems;
}

/**
*
* @return List<Item>
*/
public List<Item> getEquippedItemsWithoutStigma()
{
List<Item> equippedItems = new ArrayList<Item>();
for(Item item : equippedItems)
{
if(item.getEquipmentSlot() < ItemSlot.STIGMA1.getSlotIdMask())
equippedItems.addAll(equipment.values());
}

return equippedItems;
}

/**
* @return Number of parts equipped belonging to requested itemset
Expand Down Expand Up @@ -593,10 +620,9 @@ private void decreaseEquippedItemCount(int itemObjId, int count)
}

/**
*
* @return true or false
* Switch OFF and MAIN hands
*/
public boolean switchHands()
public void switchHands()
{
Item mainHandItem = equipment.get(ItemSlot.MAIN_HAND.getSlotIdMask());
Item subHandItem = equipment.get(ItemSlot.SUB_HAND.getSlotIdMask());
Expand Down Expand Up @@ -665,7 +691,6 @@ else if(item.getEquipmentSlot() == ItemSlot.SUB_OFF_HAND.getSlotIdMask())

owner.getLifeStats().updateCurrentStats();
setPersistentState(PersistentState.UPDATE_REQUIRED);
return true;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,22 @@ public synchronized boolean addSkill(Player player, int skillId, int skillLevel,
}
return true;
}

/**
* @param skill
*/
public void addSkill(SkillListEntry skill)
{
skills.put(skill.getSkillId(), skill);
}

/**
*
* @param player
* @param skillId
* @param xpReward
* @return
*/
public boolean addSkillXp(Player player, int skillId, int xpReward)
{
SkillListEntry skillEntry = getSkillEntry(skillId);
Expand Down Expand Up @@ -201,6 +216,11 @@ public int getSkillLevel(int skillId)
return skills.get(skillId).getSkillLevel();
}

/**
*
* @param skillId
* @return
*/
public synchronized boolean removeSkill(int skillId)
{
SkillListEntry entry = skills.get(skillId);
Expand All @@ -221,6 +241,11 @@ public int getSize()
return skills.size();
}

/**
*
* @param player
* @param skillId
*/
private void sendMessage(Player player , int skillId)
{
switch (skillId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,114 @@ protected void writeGeneralItemInfo(ByteBuffer buf, Item item, boolean privateSt
if(!mail)
writeH(buf, item.getEquipmentSlot()); // not equipable items
}

protected void writeStigmaInfo(ByteBuffer buf, Item item)
{
writeH(buf, 325); //length of details 45 01
writeC(buf, 0x6);
if(item.isEquipped())
writeD(buf, item.getEquipmentSlot());
else
writeD(buf, 0);
writeC(buf, 0x7);
writeH(buf, 702); //skill id
writeD(buf, 0);
writeH(buf, 0);
writeD(buf, 0x3c); //0x3c

writeD(buf, 0);
writeD(buf, 0);

writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);

writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 1);//1
writeD(buf, 0);

writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);

writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeH(buf, 0);
writeH(buf, 0x0b); //0b


writeC(buf, 0);
writeD(buf, item.getItemTemplate().getTemplateId());

writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeC(buf, 0);

writeD(buf, 82750); //3E 43 01 00

writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeD(buf, 0);
writeC(buf, 0);

writeC(buf, 0x22); // 22
writeH(buf, 0);
}

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected void writePlayerInfo(ByteBuffer buf, PlayerAccountData accPlData)

int itemsDataSize = 0;
//TODO figure out this part when fully equipped
List<Item> items = accPlData.getEquipment().getEquippedItems();
List<Item> items = accPlData.getEquipment().getEquippedItemsWithoutStigma();

for(Item item : items) {

Expand Down
Loading

0 comments on commit 4ba8071

Please sign in to comment.