Exemplo n.º 1
0
        public override bool TryDropPickup(Character pUser, CDrop pItem)
        {
            if (pItem.Item.Template is ConsumeItemTemplate template && template.ConsumeOnPickup)
            {
                foreach (var item in Users)
                {
                    // todo maybe clean this up

                    // add consumable effects
                    var newBuff = new BuffConsume(template.TemplateId);
                    newBuff.GenerateConsumeable(item);

                    // check required cuz calling function adds item buffs already
                    if (item.dwId == pUser.dwId)
                    {
                        continue;
                    }

                    // add real buffs
                    item.Buffs.AddItemBuff(pItem.Item.nItemID);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public void AddItemBuff(int nItemID, double durationMultiplier = 1.0)
        {
            var key = -Math.Abs(nItemID);

            if (Contains(key))
            {
                UpdateBuffInfo(this[key]);
                return;
            }

            var newBuff = new BuffConsume(nItemID);

            newBuff.Generate(durationMultiplier);

            Add(newBuff);
        }
Exemplo n.º 3
0
        /**
         * Consumeable item buffs will be routed here.
         * This includes HP/MP items along with temp stat increase items
         */
        public void UsePotion(int nItemID, short nPOS)
        {
            if (Parent.Stats.nHP <= 0)
            {
                return;
            }

            if (InventoryManipulator.GetItem(Parent, InventoryType.Consume, nPOS)?.Template is ConsumeItemTemplate template)
            {
                if (Parent.Field is CField_Battlefield bf)                 // if not remove item anyway cuz they shouldnt have it
                {
                    // TODO effects => Effect/BasicEff/ItemSkill/Success

                    if (template.BFSkill < 0)
                    {
                        if (BattlefieldData.SheepConsumable(nItemID) || BattlefieldData.WolfConsumable(nItemID))
                        {
                            var newBuff = new BuffConsume(nItemID);
                            newBuff.GenerateConsumeable(Parent);
                        }
                    }
                    else
                    {
                        switch (template.BFSkill)                         // we hardcodin' bois
                        {
                        case 0:
                            Parent.SendMessage("You cry at the Wolf, and it slows down as if it's in shock.");
                            bf.Users.ForEach(u =>
                            {
                                if (bf.GetPlayerTeam(u.dwId) == BattlefieldData.BattlefieldTeams.Wolves)
                                {
                                    u.Buffs.OnStatChangeByMobSkill(MasterManager.MobSkillTemplates[126][9], 0, 0);
                                }
                            });
                            break;

                        case 1:
                            Parent.SendMessage("You attack the Wolf. He should be momentarily stunned.");
                            bf.Users.ForEach(u =>
                            {
                                if (bf.GetPlayerTeam(u.dwId) == BattlefieldData.BattlefieldTeams.Wolves)
                                {
                                    u.Buffs.OnStatChangeByMobSkill(MasterManager.MobSkillTemplates[123][14], 0, 0);
                                }
                            });
                            break;

                        case 2:
                            Parent.Field.BroadcastNotice("The Sheep are in a state of confusion.");
                            bf.Users.ForEach(u =>
                            {
                                if (bf.GetPlayerTeam(u.dwId) != BattlefieldData.BattlefieldTeams.Wolves)
                                {
                                    u.Buffs.OnStatChangeByMobSkill(MasterManager.MobSkillTemplates[132][4], 0, 0);
                                }
                            });
                            break;

                        case 3:
                            Parent.Field.BroadcastNotice("The Wolves have slowed down.");
                            bf.Users.ForEach(u =>
                            {
                                if (bf.GetPlayerTeam(u.dwId) == BattlefieldData.BattlefieldTeams.Wolves)
                                {
                                    u.Buffs.OnStatChangeByMobSkill(MasterManager.MobSkillTemplates[126][10], 0, 0);
                                }
                            });
                            break;

                        case 4:
                            Parent.Field.BroadcastNotice("The Sheep are momentarily stunned.");
                            bf.Users.ForEach(u =>
                            {
                                if (bf.GetPlayerTeam(u.dwId) != BattlefieldData.BattlefieldTeams.Wolves)
                                {
                                    u.Buffs.OnStatChangeByMobSkill(MasterManager.MobSkillTemplates[123][15], 0, 0);
                                }
                            });
                            break;

                        case 5:
                            Parent.Field.BroadcastNotice("The Sheep have momentarily weakened.");
                            bf.Users.ForEach(u =>
                            {
                                if (bf.GetPlayerTeam(u.dwId) != BattlefieldData.BattlefieldTeams.Wolves)
                                {
                                    u.Buffs.OnStatChangeByMobSkill(MasterManager.MobSkillTemplates[122][12], 0, 0);
                                }
                            });
                            break;
                        }
                    }
                }
                else
                {
                    if (Parent.Field.Template.HasStatChangeItemLimit())
                    {
                        Parent.SendMessage("Not allowed in this map.");
                        return;
                    }

                    var newBuff = new BuffConsume(nItemID);
                    newBuff.GenerateConsumeable(Parent);
                    // buff gets added in the generator if it has bufftime
                }
            }

            InventoryManipulator.RemoveFrom(Parent, InventoryType.Consume, nPOS);             // remove regardless
        }
Exemplo n.º 4
0
        public static void Handle_SummonedSkill(WvsGameClient c, CInPacket p)
        {
            var dwSummonedID = p.Decode4();
            var item         = c.Character.Field.Summons[dwSummonedID];

            if (item is null)
            {
                return;
            }

            var nBuffSkillID = p.Decode4();

            var pSkill = item.Parent.Skills.Get(nBuffSkillID, true);

            if (pSkill is null)
            {
                item.Parent.SendMessage($"Unable to find Skill ID {nBuffSkillID}.");
                return;
            }

            var nAction = p.Decode1();

            var nIntervalMillis = SkillLogic.get_summoned_attack_delay(pSkill.nSkillID, pSkill.nSLV, (int)pSkill.X_Effect);

#if DEBUG
            item.Parent.SendMessage("Skill ID sent from summon: " + nBuffSkillID);
#endif

            if (!item.tLastBuffTime.AddedMillisExpired(nIntervalMillis))
            {
                return;
            }

            item.tLastBuffTime = DateTime.Now;

            switch ((Skills)nBuffSkillID)
            {
            case Skills.MECHANIC_HEALING_ROBOT_H_LX:
            {
                if (item.Parent.Party != null)
                {
                    item.Parent.Party.ApplyBuffToParty(item.Parent, item.Field.dwUniqueId, nBuffSkillID, pSkill.nSLV);
                }
                else if (item.Parent.Stats.nHP > 0)
                {
                    var nHealAmount = (int)(item.Parent.BasicStats.nMHP * pSkill.Template.HP(pSkill.nSLV) * 0.01);

                    item.Parent.Modify.Heal(nHealAmount);
                }
            }
            break;

            case Skills.DARKKNIGHT_BEHOLDERS_HEALING:
            {
                if (item.Parent.Stats.nHP > 0)
                {
                    var nHealAmount = pSkill.Template.HP(pSkill.nSLV);
                    item.Parent.Modify.Heal(nHealAmount);
                }
            }
            break;

            case Skills.DARKKNIGHT_BEHOLDERS_BUFF:
            {
                if (item.Parent.Stats.nHP > 0)
                {
                    var nType = p.Decode1();

                    var buffid = 2022125 + Constants.Rand.Next(0, 5);

                    if (!item.Parent.Buffs.Contains(-buffid))
                    {
                        var buff = new BuffConsume(buffid);
                        buff.GenerateBeholderBuff(item.Parent);

                        item.Parent.Buffs.Add(buff);
                    }
                }
            }
            break;

            case Skills.MECHANIC_ROBOROBO:
            {
                item.Field.Summons.CreateSummon(item.Parent, (int)Skills.MECHANIC_ROBOROBO_DUMMY,
                                                item.nSLV,
                                                item.Position.X,
                                                item.Position.Y);
            }
            break;

            default:
                item.Parent.SendMessage("Unhandled summon skill ID: " + nBuffSkillID);
                return;
            }

            var effect = new UserEffectPacket(UserEffect.SkillAffected)
            {
                nSkillID = nBuffSkillID,
                nSLV     = pSkill.nSLV,
            };

            effect.BroadcastEffect(item.Parent);                                                                  // i think this includes parent

            item.Field.Broadcast(CPacket.CSummonedPool.SummonedSkill(item, item.nSkillID, nAction), item.Parent); // i think this excludes parent
        }