Browse Source

strip temporary item enchants when transfered

lakebane-strongholds
FatBoy-DOTC 4 months ago
parent
commit
1fe242a284
  1. 3
      src/engine/objects/CharacterItemManager.java
  2. 24
      src/engine/objects/Item.java

3
src/engine/objects/CharacterItemManager.java

@ -610,6 +610,8 @@ public class CharacterItemManager {
if (i == null) if (i == null)
return false; return false;
i.stripCastableEnchants();
if (!this.doesCharOwnThisItem(i.getObjectUUID())) if (!this.doesCharOwnThisItem(i.getObjectUUID()))
return false; return false;
@ -2009,6 +2011,7 @@ public class CharacterItemManager {
if (item.getItemBase().getType().equals(ItemType.GOLD)) { if (item.getItemBase().getType().equals(ItemType.GOLD)) {
int amt = item.getNumOfItems(); int amt = item.getNumOfItems();
item.setNumOfItems(0); item.setNumOfItems(0);
item.stripCastableEnchants();
MobLoot ml = new MobLoot(this.absCharacter, amt); MobLoot ml = new MobLoot(this.absCharacter, amt);
ml.zeroItem(); ml.zeroItem();
ml.containerType = Enum.ItemContainerType.INVENTORY; ml.containerType = Enum.ItemContainerType.INVENTORY;

24
src/engine/objects/Item.java

@ -23,6 +23,7 @@ import engine.net.client.ClientConnection;
import engine.net.client.msg.DeleteItemMsg; import engine.net.client.msg.DeleteItemMsg;
import engine.powers.EffectsBase; import engine.powers.EffectsBase;
import engine.powers.effectmodifiers.AbstractEffectModifier; import engine.powers.effectmodifiers.AbstractEffectModifier;
import engine.powers.effectmodifiers.WeaponProcEffectModifier;
import engine.powers.poweractions.AbstractPowerAction; import engine.powers.poweractions.AbstractPowerAction;
import engine.server.MBServerStatics; import engine.server.MBServerStatics;
import org.pmw.tinylog.Logger; import org.pmw.tinylog.Logger;
@ -816,8 +817,29 @@ public class Item extends AbstractWorldObject {
return ownerID; return ownerID;
} }
public void stripCastableEnchants(){
ArrayList<String> keys =new ArrayList<>();
for(String eff : this.effects.keySet()){
for(AbstractEffectModifier mod : this.effects.get(eff).getEffectsBase().getModifiers()){
if(mod.modType.equals(ModType.WeaponProc)){
keys.add(eff);
}
}
}
for(String eff : keys){
try {
this.effects.get(eff).endEffect();
this.effects.remove(eff);
}catch(Exception e){
}
}
}
//Only to be used for trading //Only to be used for trading
public void setOwnerID(int ownerID) { public void setOwnerID(int ownerID) {
this.stripCastableEnchants();
this.ownerID = ownerID; this.ownerID = ownerID;
} }
@ -841,6 +863,7 @@ public class Item extends AbstractWorldObject {
public boolean setOwner(AbstractGameObject owner) { public boolean setOwner(AbstractGameObject owner) {
if (owner == null) if (owner == null)
return false; return false;
this.stripCastableEnchants();
if (owner.getObjectType().equals(GameObjectType.NPC)) if (owner.getObjectType().equals(GameObjectType.NPC))
this.ownerType = OwnerType.Npc; this.ownerType = OwnerType.Npc;
else if (owner.getObjectType().equals(GameObjectType.PlayerCharacter)) else if (owner.getObjectType().equals(GameObjectType.PlayerCharacter))
@ -1099,6 +1122,7 @@ public class Item extends AbstractWorldObject {
this.ownerID = 0; this.ownerID = 0;
this.ownerType = null; this.ownerType = null;
this.containerType = Enum.ItemContainerType.INVENTORY; this.containerType = Enum.ItemContainerType.INVENTORY;
this.stripCastableEnchants();
return true; return true;
} }

Loading…
Cancel
Save