コード例 #1
0
 public static void GENERAL_ITEMQUESTSTART(SkillBaseEventArgs bargument)
 {
     if (bargument.Context == Saga.Enumarations.SkillContext.ItemUsage)
     {
         ItemSkillUsageEventArgs arguments = (ItemSkillUsageEventArgs)bargument;
         arguments.Result = Saga.SkillBaseEventArgs.ResultType.Item;
         arguments.Damage = 0;
         Console.WriteLine("Start using quest: {0}", arguments.ItemInfo.quest);
     }
 }
コード例 #2
0
 public static void GENERAL_ADVENTURERPOTION(SkillBaseEventArgs bargument)
 {
     if (bargument.Context == Saga.Enumarations.SkillContext.ItemUsage)
     {
         ItemSkillUsageEventArgs arguments = (ItemSkillUsageEventArgs)bargument;
         arguments.Result = Saga.SkillBaseEventArgs.ResultType.Item;
         arguments.Damage = 0;
         arguments.Failed = false;
         Common.Skills.DoAddition(arguments.Sender as Actor, arguments.Sender, arguments.Addition);
     }
 }
コード例 #3
0
 public static void GENERAL_SWEETCOCTAIL(SkillBaseEventArgs bargument)
 {
     if (bargument.Context == Saga.Enumarations.SkillContext.ItemUsage)
     {
         ItemSkillUsageEventArgs arguments = (ItemSkillUsageEventArgs)bargument;
         arguments.Result = Saga.SkillBaseEventArgs.ResultType.Item;
         arguments.Damage = 0;
         arguments.Failed = false;
         Common.Skills.CreateAddition(arguments.Sender as Actor, arguments.Addition, 90000);
     }
 }
コード例 #4
0
ファイル: Client Skill.cs プロジェクト: virkmx/SagaRevised
        /// <summary>
        /// Occurs when using a item that uses a skill
        /// </summary>
        /// <param name="cpkt"></param>
        private void CM_ITEMTOGGLE(CMSG_ITEMTOGLE cpkt)
        {
            lock (this.character.cooldowncollection)
            {
                try
                {
                    Rag2Item  item = this.character.container[cpkt.Index];
                    MapObject target;
                    uint      skillid   = cpkt.SkillID;
                    byte      skilltype = cpkt.SkillType;
                    ItemSkillUsageEventArgs argument = null;

                    bool cancast = Regiontree.TryFind(cpkt.TargetActor, this.character, out target) &&
                                   ItemSkillUsageEventArgs.Create(item, this.character, target, out argument) &&
                                   argument.SpellInfo.casttime > -1 && (argument.SpellInfo.casttime == 0 || this.character._lastcastedskill == skillid) &&
                                   ((long)((uint)Environment.TickCount) - this.character._lastcastedtick) > 0 &&
                                   (argument.SpellInfo.delay == 0 || !this.character.cooldowncollection.IsCoolDown(skillid)) &&
                                   (argument.SpellInfo.maximumrange == 0 || argument.SpellInfo.IsInRangeOf((int)(Vector.GetDistance2D(this.character.Position, target.Position)))) &&
                                   argument.SpellInfo.requiredWeapons[this.character.weapons.GetCurrentWeaponType()] == 1 &&
                                   this.character.jlvl > argument.SpellInfo.requiredJobs[this.character.job - 1] &&
                                   argument.SpellInfo.IsTarget(this.character, target) &&
                                   item.count > 0;

                    if (cancast && argument.Use())
                    {
                        int delay = (int)(argument.SpellInfo.delay - ((character.stats.Dexterity * 2) + (character.stats.Concentration * 2)));
                        if (delay > 0)
                        {
                            this.character.cooldowncollection.Add(skillid, delay);
                        }
                        this.character.cooldowncollection.Update();

                        int newLength = this.character.container[cpkt.Index].count - 1;
                        if (newLength > 0)
                        {
                            this.character.container[cpkt.Index].count = newLength;
                            SMSG_UPDATEITEM spkt2 = new SMSG_UPDATEITEM();
                            spkt2.Amount       = (byte)newLength;
                            spkt2.UpdateReason = 8;
                            spkt2.UpdateType   = 4;
                            spkt2.Container    = 2;
                            spkt2.SessionId    = this.character.id;
                            spkt2.Index        = cpkt.Index;
                            this.Send((byte[])spkt2);
                        }
                        else
                        {
                            this.character.container.RemoveAt(cpkt.Index);
                            SMSG_DELETEITEM spkt3 = new SMSG_DELETEITEM();
                            spkt3.UpdateReason = 8;
                            spkt3.Container    = 2;
                            spkt3.Index        = cpkt.Index;
                            spkt3.SessionId    = this.character.id;
                            this.Send((byte[])spkt3);
                        }


                        //Preprocess packet
                        SMSG_ITEMTOGGLE spkt = new SMSG_ITEMTOGGLE();
                        spkt.Container    = cpkt.Container;
                        spkt.SkillMessage = (byte)argument.Result;
                        spkt.Index        = cpkt.Index;
                        spkt.SkillID      = cpkt.SkillID;
                        spkt.SkillType    = cpkt.SkillType;
                        spkt.SourceActor  = this.character.id;
                        spkt.TargetActor  = cpkt.TargetActor;
                        spkt.Value        = argument.Damage;

                        //Send packets in one-mighty blow
                        Regiontree tree = this.character.currentzone.Regiontree;
                        foreach (Character regionObject in tree.SearchActors(this.character, SearchFlags.Characters))
                        {
                            if (character.client.isloaded == false || !Point.IsInSightRangeByRadius(this.character.Position, regionObject.Position))
                            {
                                continue;
                            }
                            spkt.SessionId = target.id;
                            regionObject.client.Send((byte[])spkt);
                        }
                    }
                }
                catch (Exception)
                {
                    Trace.TraceError("Error processing item skill");
                }
            }
        }