public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; IGameUnit player = GetPlayer(args); if (StringUtil.IsNullOrEmpty(count) || count.Equals("0")) { count = "0"; } method = new SelectMethod(FreeUtil.ReplaceVar(exp, args)); if (player != null) { FreeData fd = (FreeData)player; ItemPosition[] currentItems = fd.freeInventory.Select(method); fr.TempUse("current", fd); int c = FreeUtil.ReplaceInt(count, args); for (int i = 0; i < currentItems.Length; i++) { ItemPosition ip = currentItems[i]; ip.SetCount(c); ip.GetKey().SetCount(c); ip.GetInventory().GetInventoryUI().UpdateItem(fr, ip.GetInventory(), ip); } fr.Resume("current"); } }
public static void UseItem(ItemPosition ip, FreeData fd, FreeRuleEventArgs fr) { if (ip != null) { fr.TempUse(PARA_ITEM, ip.GetKey()); if (ip.GetKey().Effect(fr)) { if (!ip.GetKey().IsGoods()) { if (ip.GetKey().IsUseClose()) { CloseInventory(ip.GetInventory(), fr); } ip.GetInventory().UseItem(fr, ip); if (ip.GetCount() <= 0 && ip.GetKey().IsConsume()) { RemoveUI(ip, fr); } } } fr.Resume(PARA_ITEM); if (!ip.GetKey().IsGoods()) { fd.freeInventory.SetCurrentItem(ip, fr); } ip.GetKey().GetParameters().AddPara(new IntPara(PARA_ITEM_USE_TIME, fr.GameContext.session.currentTimeObject.CurrentTime)); } }
private static float ReduceDamage(IEventArgs args, FreeData fd, PlayerDamageInfo damage, ItemPosition ip, int percent, ItemType itemType) { if (ip != null) { float realDamage = damage.damage; float reduce = damage.damage * percent / 100; float realReduce = reduce; damage.damage -= realReduce; fd.Player.statisticsData.Statistics.DefenseDamage += reduce; // 普通帽子不减少 if (reduce > 0) { ip.SetCount(ip.GetCount() - (int)realDamage); UpdateGamePlayData(fd, ip, itemType); args.TempUse("current", fd); if (ip.GetCount() <= 0) { ip.GetInventory().RemoveItem((FreeRuleEventArgs)args, ip); FuntionUtil.Call(args, "showBottomTip", "msg", "{desc:10075," + ip.key.GetName() + "}"); } else { ip.GetInventory().GetInventoryUI().UpdateItem((FreeRuleEventArgs)args, ip.GetInventory(), ip); } args.Resume("current"); } } return(damage.damage); }
public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message) { FreeData fd = (FreeData)player.freeData.FreeData; room.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd); string key = message.Ss[0]; int count = message.Ins[0]; if (key.StartsWith(ChickenConstant.BagDefault)) { ItemPosition ip = FreeItemManager.GetItemPosition(room.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager()); FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey()); if (ip.GetCount() > count) { ip.SetCount(ip.GetCount() - count); ip.GetInventory().GetInventoryUI().ReDraw((ISkillArgs)room.FreeArgs, ip.GetInventory(), true); } else { ip.GetInventory().RemoveItem((ISkillArgs)room.FreeArgs, ip); } room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity( (Assets.XmlConfig.ECategory)info.cat, info.id, count, fd.Player.position.Value); } room.FreeArgs.Resume(PARA_PLAYER_CURRENT); }
public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message) { FreeData fd = (FreeData)player.freeData.FreeData; room.ContextsWrapper.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd); string key = message.Ss[0]; int count = message.Ins[0]; if (key.StartsWith(ChickenConstant.BagDefault)) { ItemPosition ip = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager()); FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey()); if (ip.GetCount() > count) { if (info.cat == (int)ECategory.Weapon && SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(info.id).Type == (int)EWeaponType_Config.ThrowWeapon) { CarryClipUtil.DeleteGrenade(count, info.id, fd, room.ContextsWrapper.FreeArgs); for (int i = 0; i < count; i++) { player.WeaponController().RemoveGreande(info.id); } } else { ip.SetCount(ip.GetCount() - count); ip.GetInventory().GetInventoryUI().ReDraw((ISkillArgs)room.ContextsWrapper.FreeArgs, ip.GetInventory(), true); } } else { ip.GetInventory().RemoveItem((ISkillArgs)room.ContextsWrapper.FreeArgs, ip); } room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleObjectEntity( (ECategory)info.cat, info.id, count, fd.Player.position.Value); if (info.cat == (int)ECategory.GameItem && SingletonManager.Get <GameItemConfigManager>().GetConfigById(info.id).Type == (int)GameItemType.Bullet) { player.WeaponController().SetReservedBullet((EBulletCaliber)info.id, CarryClipUtil.GetClipCount(info.id, fd, room.ContextsWrapper.FreeArgs)); } SimpleProto sp = FreePool.Allocate(); sp.Key = FreeMessageConstant.PlaySound; sp.Ks.Add(2); sp.Ins.Add(5017); sp.Bs.Add(false); FreeMessageSender.SendMessage(fd.Player, sp); } room.ContextsWrapper.FreeArgs.Resume(PARA_PLAYER_CURRENT); }
public static void MovePosition(ItemPosition ip, ItemInventory toIn, int x, int y, ISkillArgs args) { ItemInventory fromIn = ip.GetInventory(); IInventoryUI fromUI = fromIn.GetInventoryUI(); IInventoryUI toUI = toIn.GetInventoryUI(); FreeRuleEventArgs fr = (FreeRuleEventArgs)args; Move(fromIn, toIn, ip, x, y, args, fr, fromUI, toUI); }
public static void MoveItem(string key, FreeData fd, ISkillArgs args, int x, int y, int toGlobalX, int toGlobalY, int stageWidth, int stageHeigth, int fromGlobalX, int fromGlobalY) { toGlobalY = stageHeigth - toGlobalY; fromGlobalY = stageHeigth - fromGlobalY; ItemPosition ip = GetItemPosition(args, key, fd.freeInventory.GetInventoryManager()); if (ip != null) { InventoryManager invManager = fd.freeInventory.GetInventoryManager(); ItemInventory fromInv = ip.GetInventory(); ItemInventory toInv = null; FreeUIUtil.Rectangle rec = null; foreach (string inv in invManager.GetInventoryNames()) { ItemInventory ii = invManager.GetInventory(inv); if (ii != null && ii.IsOpen()) { rec = ((SimpleInventoryUI)ii.GetInventoryUI()).GetItemRegion(args, stageWidth, stageHeigth); if (rec.In(toGlobalX, toGlobalY)) { toInv = ii; break; } } } if (toInv == fromInv || toInv == null) { ItemInventoryUtil.MovePosition(ip.GetInventory(), ip.GetInventory(), (SimpleInventoryUI)fromInv.GetInventoryUI(), (SimpleInventoryUI)fromInv.GetInventoryUI(), ip, x, y, args); } else { FreeUIUtil.Rectangle itemRec = ((SimpleInventoryUI)fromInv.GetInventoryUI()).GetItemRegion(fromInv, args, stageWidth, stageHeigth, ip); ItemInventoryUtil.MovePosition(ip.GetInventory(), invManager.GetInventory(toInv.GetName()), (SimpleInventoryUI)fromInv.GetInventoryUI(), (SimpleInventoryUI)toInv.GetInventoryUI(), ip, toGlobalX - rec.x - (fromGlobalX - itemRec.x), toGlobalY - rec.y - (fromGlobalY - itemRec.y), args); } } }
public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; IGameUnit player = GetPlayer(args); if (player != null) { if (!StringUtil.IsNullOrEmpty(item)) { IParable pe = args.GetUnit(item); if (pe != null && pe is ItemPosition) { args.TempUse("current", (FreeData)player); ItemPosition ip = (ItemPosition)pe; ip.GetInventory().RemoveItem(fr, ip); RemoveUI(ip, fr); args.Resume("current"); } } else { method = new SelectMethod(FreeUtil.ReplaceVar(exp, args)); FreeData fd = (FreeData)player; ItemPosition[] currentItems = fd.freeInventory.Select(method); if (StringUtil.IsNullOrEmpty(count)) { count = "1"; } int c = FreeUtil.ReplaceInt(count, args); for (int i = 0; i < MyMath.Min(c, currentItems.Length); i++) { args.TempUse("current", (FreeData)player); ItemPosition ip = currentItems[i]; ip.GetInventory().RemoveItem(fr, ip); RemoveUI(ip, fr); args.Resume("current"); } } } }
public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; IGameUnit player = GetPlayer(args); if (player != null) { FreeData fd = (FreeData)player; try { ItemPosition currentItem = fd.freeInventory.GetCurrentItem(); if (!StringUtil.IsNullOrEmpty(cat)) { currentItem = fd.freeInventory.GetCurrentItem(FreeUtil.ReplaceVar(cat, args)); } if (currentItem != null) { currentItem.GetInventory().RemoveItem(fr, currentItem); if (drop != null) { fr.TempUse("item", currentItem.GetKey()); drop.Act(args); fr.Resume("item"); } } } catch (Exception e) { StringPara sp = new StringPara("message", e.Message); args.GetDefault().GetParameters().TempUse(sp); if (message != null) { message.Act(args); } args.GetDefault().GetParameters().Resume("message"); } } }
public virtual string GetHotKey(IEventArgs args, ItemPosition ip) { ConditionHotKey result = null; args.TempUse("item", ip); foreach (ConditionHotKey pk in keys) { if (pk.Meet(args)) { result = pk; break; } } args.Resume("item"); FreeData fd = (FreeData)args.GetUnit("current"); if (fd != null && result != null) { fd.GetUnitSkill().RemoveSkill("skill_hotkey_" + result.key); PlayerActionSkill skill = new PlayerActionSkill(); skill.SetKey("skill_hotkey_" + result.key); SkillClickTrigger trigger = new SkillClickTrigger(); trigger.SetKey(int.Parse(result.key)); skill.SetTrigger(trigger); skill.SetEffect(new PositionHotKey.ItemHotkeyAction(this, ip, fd, ip.GetInventory().GetName())); fd.GetUnitSkill().AddSkill(skill); } if (result != null) { return(result.ui); } else { return(string.Empty); } }
public static void Move(ItemInventory fromIn, ItemInventory toIn, ItemPosition ip, int countX, int countY, ISkillArgs args, FreeRuleEventArgs fr, IInventoryUI fromUI, IInventoryUI toUI) { if (fromIn != toIn) { fr.TempUse(PARA_ITEM, ip); bool canDrop = toIn.IsCanDrop(ip, args); // 如果toIn 不可以拖入物品 if (!canDrop) { fromUI.UpdateItem(args, fromIn, ip); if (toIn.GetDropAction() != null) { toIn.GetDropAction().Act(args); } //HandleMoveAction(fromIn, toIn, fromUI, toUI, ip, args); fr.Resume(PARA_ITEM); return; } fr.Resume(PARA_ITEM); } // 已有 ItemPosition[] olds = toIn.GetItem(countX, countY, ip.GetKey().GetGridWidth(), ip.GetKey().GetGridHeight()); ItemPosition old = null; if (olds.Length == 1) { old = olds[0]; if (old != ip) { fr.TempUse(PARA_ITEM, ip); if (old.GetKey().GetKey().Equals(ip.GetKey().GetKey())) { int delta = old.GetKey().GetItemStack() - old.GetCount(); if (delta > 0) { // 堆叠物品 ChangeItemStack(delta, fromIn, toIn, fromUI, toUI, ip, old, args); } else { // 交换物品位置 ExchangeItem(fromIn, toIn, fromUI, toUI, ip, old, args); } } else { if (!ip.DragTo(args, old)) { ExchangeItem(fromIn, toIn, fromUI, toUI, ip, old, args); } else { if (ip.GetInventory() != null) { fromUI.UpdateItem(args, fromIn, ip); } } } fr.Resume(PARA_ITEM); return; } } fr.TempUse(PARA_ITEM, ip); MoveItem(countX, countY, fromIn, toIn, fromUI, toUI, ip, old, args); fr.Resume(PARA_ITEM); }
public static void DragItem(string key, FreeData fd, ISkillArgs args, string toKey) { ItemPosition ip = GetItemPosition(args, key, fd.freeInventory.GetInventoryManager()); if (ip == null) { ItemInventory inv = fd.freeInventory.GetInventoryManager().GetInventory(key.Trim()); if (inv != null && inv.GetInventoryUI() is UnityOneInventoryUi) { if (inv.posList.Count > 0) { ip = inv.posList[0]; } } } ItemPosition toIp = null; if (!StringUtil.IsNullOrEmpty(toKey)) { toIp = GetItemPosition(args, toKey, fd.freeInventory.GetInventoryManager()); } if (ip != null) { InventoryManager invManager = fd.freeInventory.GetInventoryManager(); ItemInventory fromInv = ip.GetInventory(); ItemInventory toInv = null; if (toIp != null) { toInv = toIp.GetInventory(); } else { string[] ss = toKey.Split(','); toInv = fd.freeInventory.GetInventoryManager().GetInventory(ss[0].Trim()); } int x = -1; int y = -1; if (toIp != null) { x = toIp.x; y = toIp.y; } else if (toInv != null) { if (toInv.GetName() == ChickenConstant.BagDefault) { foreach (ItemPosition old in toInv.GetItems()) { if (old.GetKey().GetKey() == ip.GetKey().GetKey() && old.GetCount() < ip.GetKey().GetItemStack()) { x = old.GetX(); y = old.GetY(); break; } } } if (x < 0) { int[] pos = toInv.GetNextEmptyPosition(ip.GetKey()); x = pos[0]; y = pos[1]; } } if (toInv != null && fromInv != toInv) { if (toInv.GetName() == ChickenConstant.BagDefault) { if (BagCapacityUtil.CanAddToBag(args, fd, ip)) { ItemInventoryUtil.Move(fromInv, toInv, ip, x, y, args, (FreeRuleEventArgs)args, fromInv.GetInventoryUI(), toInv.GetInventoryUI()); } } else { ItemInventoryUtil.Move(fromInv, toInv, ip, x, y, args, (FreeRuleEventArgs)args, fromInv.GetInventoryUI(), toInv.GetInventoryUI()); } } else { if (toInv == null) { //fromInv.GetInventoryUI().ReDraw(args, fromInv, true); } else { //fromInv.GetInventoryUI().ReDraw(args, fromInv, true); } } } }
public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message) { FreeData fd = (FreeData)player.freeData.FreeData; var freeArgs = room.ContextsWrapper.FreeArgs as FreeRuleEventArgs; freeArgs.TempUse(PARA_PLAYER_CURRENT, fd); eventKey.SetValue(message.Ss[0]); freeArgs.GetDefault().GetParameters().TempUse(eventKey); Debug.Log("drag from:" + message.Ss[0] + " to:" + message.Ss[1]); string from = message.Ss[0]; string to = message.Ss[1]; ItemPosition fromIp = FreeItemManager.GetItemPosition(freeArgs, from, fd.freeInventory.GetInventoryManager()); ItemPosition toIp = FreeItemManager.GetItemPosition(freeArgs, to, fd.freeInventory.GetInventoryManager()); // 显示拆分UI if (message.Bs[0] && from.StartsWith(ChickenConstant.BagDefault)) { PickupItemUtil.ShowSplitUI(room, fd, from); } else if (!HandleBag(from, to, room, fd)) { } else if (player.gamePlay.GameState == GameState.AirPlane || player.gamePlay.GameState == GameState.Gliding || player.gamePlay.GameState == GameState.JumpPlane) { } /*else if (from.StartsWith(ChickenConstant.BagBelt) || to.StartsWith(ChickenConstant.BagBelt)) * { * // 腰包不能做任何操作 * SimpleProto msg = FreePool.Allocate(); * msg.Key = FreeMessageConstant.ChickenTip; * msg.Ss.Add("word63"); * FreeMessageSender.SendMessage(fd.Player, msg); * }*/ else if (from.StartsWith(ChickenConstant.BagGround) && !to.StartsWith(ChickenConstant.BagGround)) { // 地面模糊操作 HandleAuto(from, to, room, fd); } else if (from.StartsWith(ChickenConstant.BagGround) || to.StartsWith(ChickenConstant.BagGround)) { /*if (from.StartsWith(Ground) && !to.StartsWith(Ground)) * { * handleFromGround(from, to, room, fd); * }*/ if (!from.StartsWith(ChickenConstant.BagGround) && to.StartsWith(ChickenConstant.BagGround)) { FreeItemInfo fromInfo = FreeItemConfig.GetItemInfo(fromIp.key.GetKey()); if (fromInfo.cat == (int)ECategory.WeaponPart && from.StartsWith("w")) { if (BagCapacityUtil.CanDemountAttachment(room, fd, fromInfo, from, true)) { handleToGround(from, to, room, fd); } } else { handleToGround(from, to, room, fd); } } } else if (from.StartsWith(ChickenConstant.BagDefault) && to.StartsWith("w")) { // 背包物品拖动到武器槽 if (fromIp != null) { FreeItemInfo info = FreeItemConfig.GetItemInfo(fromIp.key.GetKey()); if (info.cat == (int)ECategory.WeaponPart) { MovePartToWeapon(room, fd, fromIp, to, info); } else { FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, to); } } } else if (PickupItemUtil.IsDefault(from) && string.IsNullOrEmpty(to)) { // 背包物品拖动到人身上 if (fromIp != null) { FreeItemInfo info = FreeItemConfig.GetItemInfo(fromIp.key.GetKey()); if (info.cat == (int)ECategory.WeaponPart) { MovePartToWeapon(room, fd, fromIp, to, info); } else { FreeItemManager.UseItem(from, fd, room.ContextsWrapper.FreeArgs); } } } else if ((from.StartsWith("w1,") && to.StartsWith("w2,")) || (from.StartsWith("w2,") && to.StartsWith("w1,"))) { ExchangeWeapon(room.ContextsWrapper.FreeArgs, fd, from, to); } else if (from.StartsWith("w") && to.StartsWith("w") && from.IndexOf(",") == 3 && to.IndexOf(",") == 2) { if (fromIp != null && toIp != null) { WeaponBaseAgent toAgent = fd.Player.WeaponController().GetWeaponAgent((EWeaponSlotType)short.Parse(to.Substring(1, 1))); FreeItemInfo fromInfo = FreeItemConfig.GetItemInfo(fromIp.key.GetKey()); if (!toAgent.WeaponConfigAssy.IsPartMatchWeapon(WeaponPartUtil.GetWeaponFstMatchedPartId(fromInfo.id, toAgent.ConfigId))) { SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.ChickenTip; msg.Ss.Add("word77," + toAgent.WeaponConfigAssy.S_Name + "," + fromInfo.name); FreeMessageSender.SendMessage(fd.Player, msg); } else { string toPosition = to.Substring(0, 2) + from.Substring(2, 1) + ",0,0"; ItemPosition toPart = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, toPosition, fd.freeInventory.GetInventoryManager()); WeaponBaseAgent fromAgent = fd.Player.WeaponController().GetWeaponAgent((EWeaponSlotType)short.Parse(from.Substring(1, 1))); if (toPart != null) { FreeItemInfo toInfo = FreeItemConfig.GetItemInfo(toPart.key.GetKey()); if (!fromAgent.WeaponConfigAssy.IsPartMatchWeapon(WeaponPartUtil.GetWeaponFstMatchedPartId(toInfo.id, fromAgent.ConfigId))) { SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.ChickenTip; msg.Ss.Add("word77," + fromAgent.WeaponConfigAssy.S_Name + "," + toInfo.name); FreeMessageSender.SendMessage(fd.Player, msg); } else { if (BagCapacityUtil.CanExchangeAttachment(room, fd, fromInfo, toInfo, fromAgent, toAgent)) { FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, toPosition); } } } else { if (BagCapacityUtil.CanDemountAttachment(room, fd, fromInfo, from, false)) { FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, toPosition); } } } } } else if (from.StartsWith("w") && from.IndexOf(",") == 3 && PickupItemUtil.IsDefault(to)) { FreeItemInfo fromInfo = FreeItemConfig.GetItemInfo(fromIp.key.GetKey()); if (BagCapacityUtil.CanDemountAttachment(room, fd, fromInfo, from, false)) { ItemInventory fromInv = fromIp.GetInventory(); ItemInventory toInv = toIp == null?fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagDefault) : toIp.GetInventory(); int[] pos = toIp == null ? new int[] { 0, 0 } : toInv.GetNextEmptyPosition(toIp.GetKey()); ItemInventoryUtil.MoveItem(pos[0], pos[1], fromInv, toInv, fromInv.GetInventoryUI(), toInv.GetInventoryUI(), fromIp, null, room.ContextsWrapper.FreeArgs); } } else { FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, to); } room.ContextsWrapper.FreeArgs.Resume(PARA_PLAYER_CURRENT); room.ContextsWrapper.FreeArgs.GetDefault().GetParameters().Resume(PARA_EVENT_KEY); }
public static float HandleDamage(IEventArgs args, FreeData fd, PlayerDamageInfo damage) { float readDamage = damage.damage; if (damage.type != (int)EUIDeadType.Weapon && damage.type != (int)EUIDeadType.Unarmed) { return(readDamage); } PlayerEntity playerEntity = fd.Player; if (playerEntity.gamePlay.CurHelmet > 0) { var config = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(playerEntity.gamePlay.HelmetLv); if (config != null) { if (config.NewWeaponCfg.ProtectivePartsList.Contains(damage.part)) { float reduce = readDamage * config.NewWeaponCfg.DamageReduction / 100; reduce = Math.Min(playerEntity.gamePlay.CurHelmet, reduce); playerEntity.gamePlay.CurHelmet = Math.Max(0, playerEntity.gamePlay.CurHelmet - (int)readDamage); if (reduce > 0 && playerEntity.gamePlay.CurHelmet == 0) { playerEntity.gamePlay.HelmetLv = playerEntity.gamePlay.MaxHelmet = 0; SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.ChickenTip; msg.Ss.Add("word75," + config.NewWeaponCfg.Name); FreeMessageSender.SendMessage(playerEntity, msg); } ItemPosition ip = GetHelmet(fd); if (ip != null) { args.TempUse("current", (FreeData)playerEntity.freeData.FreeData); if (playerEntity.gamePlay.CurHelmet == 0) { ip.GetInventory().RemoveItem((FreeRuleEventArgs)args, ip); } else { ip.SetCount(playerEntity.gamePlay.CurHelmet); ip.GetInventory().GetInventoryUI().UpdateItem((FreeRuleEventArgs)args, ip.GetInventory(), ip); } args.Resume("current"); } damage.damage -= reduce; readDamage = damage.damage; playerEntity.statisticsData.Statistics.DefenseDamage += reduce; } } } if (playerEntity.gamePlay.CurArmor > 0) { var config = SingletonManager.Get <WeaponConfigManagement>().FindConfigById(playerEntity.gamePlay.ArmorLv); if (config != null) { if (config.NewWeaponCfg.ProtectivePartsList.Contains(damage.part)) { float reduce = readDamage * config.NewWeaponCfg.DamageReduction / 100; reduce = Math.Min(playerEntity.gamePlay.CurArmor, reduce); playerEntity.gamePlay.CurArmor = Math.Max(0, playerEntity.gamePlay.CurArmor - (int)readDamage); if (reduce > 0 && playerEntity.gamePlay.CurArmor == 0) { playerEntity.gamePlay.ArmorLv = playerEntity.gamePlay.MaxArmor = 0; SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.ChickenTip; msg.Ss.Add("word75," + config.NewWeaponCfg.Name); FreeMessageSender.SendMessage(playerEntity, msg); } ItemPosition ip = GetArmor(fd); if (ip != null) { args.TempUse("current", (FreeData)playerEntity.freeData.FreeData); if (playerEntity.gamePlay.CurArmor == 0) { ip.GetInventory().RemoveItem((FreeRuleEventArgs)args, ip); } else { ip.SetCount(playerEntity.gamePlay.CurArmor); ip.GetInventory().GetInventoryUI().UpdateItem((FreeRuleEventArgs)args, ip.GetInventory(), ip); } args.Resume("current"); } damage.damage -= reduce; readDamage = damage.damage; playerEntity.statisticsData.Statistics.DefenseDamage += reduce; } } } return(readDamage); }