// This will be called by ZoneServer at startup after loading all Spawns/Vendors etc.
 // The Character parameter is not used here, but has to be defined (yet)
 public void Init(Character ch)
 {
     NonPlayerCharacterClass target = (NonPlayerCharacterClass)FindDynel.FindDynelById(50000, 100001);
     if (target != null)
     {
         target.KnuBot = new KnuBotNPC100001(target);
         Console.WriteLine("Registered KnuBot100001 Script with NPC");
     }
 }
Exemplo n.º 2
0
        public bool ExecuteEvent(
            Character ch,
            Character caller,
            AOEvents eve,
            bool dolocalstats,
            bool tosocialtab,
            int location,
            CheckReqs doreqs)
        {
            Character chartarget = (Character)FindDynel.FindDynelById(ch.Target.Type, ch.Target.Instance);
            Boolean reqs_met;
            if (ch != null)
            {
                foreach (AOFunctions aof in eve.Functions)
                {
                    if (doreqs == CheckReqs.doCheckReqs)
                    {
                        reqs_met = this.CheckRequirements(ch, aof, true);
                    }
                    else if (doreqs == CheckReqs.doEquipCheckReqs)
                    {
                        reqs_met = this.CheckRequirements(ch, aof, false);
                        ch.AddTimer(-9, DateTime.Now, aof, true);
                        continue;
                    }
                    else
                    {
                        reqs_met = true;
                    }

                    if (reqs_met)
                    {
                        if (eve.EventType == Constants.EventtypeOnWear)
                        {
                            AOFunctions aofcopy = aof.ShallowCopy();
                            aofcopy.Arguments.Add(location);
                            ch.AddTimer(-9, DateTime.Now, aofcopy, dolocalstats);
                        }
                        else
                        {
                            ch.AddTimer(-9, DateTime.Now, aof, dolocalstats);
                        }
                    }
                }
            }
            return true;
        }
Exemplo n.º 3
0
        public bool CheckRequirements(Character ch, AOFunctions aof, bool checkAll)
        {
            Character reqtarget = null;
            bool requirementsMet = true;
            int childOperator = -1; // Starting value
            bool foundCharRelated = (aof.FunctionType == Constants.FunctiontypeHairMesh)
                                    || (aof.FunctionType == Constants.FunctiontypeBackMesh)
                                    || (aof.FunctionType == Constants.FunctiontypeTexture)
                                    || (aof.FunctionType == Constants.FunctiontypeAttractorMesh)
                                    || (aof.FunctionType == Constants.FunctiontypeCatMesh)
                                    || (aof.FunctionType == Constants.FunctiontypeChangeBodyMesh)
                                    || (aof.FunctionType == Constants.functiontype_shouldermesh)
                                    || (aof.FunctionType == Constants.FunctiontypeHeadMesh);

            foreach (AORequirements aor in aof.Requirements)
            {
                switch (aor.Target)
                {
                    case Constants.ItemtargetUser:
                        {
                            reqtarget = ch;
                            break;
                        }
                    case Constants.ItemtargetWearer:
                        {
                            reqtarget = ch;
                            break;
                        }
                    case Constants.ItemtargetTarget:
                        {
                            // TODO: pass on target 
                            break;
                        }
                    case Constants.ItemtargetFightingtarget:
                        {
                            reqtarget = ch.FightingCharacter();
                            break;
                        }
                    case Constants.ItemtargetSelectedtarget:
                        {
                            reqtarget = ch.TargetCharacter();
                            break;
                        }
                    case Constants.ItemtargetSelf:
                        {
                            reqtarget = ch;
                            break;
                        }
                    default:
                        {
                            reqtarget = null;
                            break;
                        }
                }

                if (reqtarget == null)
                {
                    return false;
                    // Target not found, cant check reqs -> FALSE
                }

                int statval = reqtarget.stats.StatValueByName(aor.Statnumber);
                bool reqresult = true;
                switch (aor.Operator)
                {
                    case Constants.OperatorAnd:
                        {
                            reqresult = ((statval & aor.Value) != 0);
                            break;
                        }
                    case Constants.OperatorOr:
                        {
                            reqresult = ((statval | aor.Value) != 0);
                            break;
                        }
                    case Constants.OperatorEqualTo:
                        {
                            reqresult = (statval == aor.Value);
                            break;
                        }
                    case Constants.OperatorLessThan:
                        {
                            reqresult = (statval < aor.Value);
                            break;
                        }
                    case Constants.OperatorGreaterThan:
                        {
                            reqresult = (statval > aor.Value);
                            break;
                        }
                    case Constants.OperatorUnequal:
                        {
                            reqresult = (statval != aor.Value);
                            break;
                        }
                    case Constants.OperatorTrue:
                        {
                            reqresult = true;
                            break;
                        }
                    case Constants.OperatorFalse:
                        {
                            reqresult = false;
                            break;
                        }
                    case Constants.OperatorBitAnd:
                        {
                            reqresult = ((statval & aor.Value) != 0);
                            break;
                        }
                    case Constants.OperatorBitOr:
                        {
                            reqresult = ((statval | aor.Value) != 0);
                            break;
                        }

                    default:
                        {
                            // TRUE for now
                            reqresult = true;
                            break;
                        }
                }

                switch (childOperator)
                {
                    case Constants.OperatorAnd:
                        {
                            requirementsMet &= reqresult;
                            break;
                        }
                    case Constants.OperatorOr:
                        {
                            requirementsMet &= reqresult;
                            break;
                        }
                    case -1:
                        {
                            requirementsMet = reqresult;
                            break;
                        }
                    default:
                        break;
                }
                childOperator = aor.ChildOperator;
            }

            if (!checkAll)
            {
                if (foundCharRelated)
                {
                    requirementsMet &= foundCharRelated;
                }
                else
                {
                    requirementsMet = true;
                }
            }

            return requirementsMet;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Unequip item
        /// </summary>
        /// <param name="it">Item</param>
        /// <param name="ch">Character</param>
        /// <param name="fromsocialtab">unequip from social tab?</param>
        /// <param name="location">Location</param>
        public void UnequipItem(AOItem it, Character ch, bool fromsocialtab, int location)
        {
            this.CalculateSkills();
            return;
            /* lock (ch)
            {
                int counter = 0;
                int f;

                // Set Weaponmesh
                if (it.ItemType == Constants.itemtype_Weapon)
                {
                    counter = 0;
                    f = -1;
                    while (counter < it.Stats.Count)
                    {
                        if (it.Stats[counter].Stat == 209)
                        {
                            f = counter;
                            break;
                        }
                        counter++;
                    }
                    if (f != -1)
                    {
                        if (!fromsocialtab)
                        {
                            if (location == 6)
                            {
                                Stats.WeaponMeshRight.Set(0); // Weaponmesh
                                ch.MeshLayer.RemoveMesh(2, it.Stats[f].Stat, 0, Misc.MeshLayers.GetLayer(location));
                            }
                            else
                            {
                                Stats.WeaponMeshLeft.Set(0);
                                ch.MeshLayer.RemoveMesh(2, it.Stats[f].Stat, 0, Misc.MeshLayers.GetLayer(location));
                            }
                        }
                        else
                        {
                            if (location == 61)
                            {
                                ch.SocialMeshLayer.RemoveMesh(2, it.Stats[f].Stat, 0, Misc.MeshLayers.GetLayer(location));
                            }
                            else
                            {
                                ch.SocialMeshLayer.RemoveMesh(2, it.Stats[f].Stat, 0, Misc.MeshLayers.GetLayer(location));
                            }
                        }
                    }
                }
            }
             */
        }
Exemplo n.º 5
0
        /// <summary>
        /// Fake equip, don't pass effects to local stats
        /// </summary>
        /// <param name="it">Item</param>
        /// <param name="ch">Character</param>
        /// <param name="tosocialtab">should it be equipped to social tab</param>
        /// <param name="location">Location</param>
        public void FakeEquipItem(AOItem it, Character ch, bool tosocialtab, int location)
        {
            int counter = 0;
            int f;
            lock (ch)
            {
                while (counter < it.Events.Count)
                {
                    if (it.Events[counter].EventType == Constants.EventtypeOnWear)
                    {
                        this.ExecuteEvent(
                            this, this, it.Events[counter], false, tosocialtab, location, CheckReqs.doEquipCheckReqs);
                    }
                    counter++;
                }

                // TODO check if still needed
                // Set Weaponmesh
                // Todo: another packet has to be sent, defining how to hold the weapon
                if (it.ItemType == Constants.itemtype_Weapon)
                {
                    this.stats.WeaponsStyle.Value |= it.GetWeaponStyle();
                    if (tosocialtab)
                    {
                        this.stats.WeaponsStyle.Value = it.GetWeaponStyle();
                    }

                    counter = 0;
                    f = -1;
                    while (counter < it.Stats.Count)
                    {
                        if (it.Stats[counter].Stat == 209)
                        {
                            f = counter; // found Weapon mesh attribute
                            break;
                        }
                        counter++;
                    }
                    if (f != -1)
                    {
                        if (!tosocialtab)
                        {
                            if (location == 6)
                            {
                                this.stats.WeaponMeshRight.Set((uint)it.Stats[f].Value); // Weaponmesh
                                this.meshLayer.AddMesh(1, it.Stats[f].Value, 0, 4);
                            }
                            else
                            {
                                this.stats.WeaponMeshLeft.Set((uint)it.Stats[f].Value); // Weaponmesh
                                this.meshLayer.AddMesh(2, it.Stats[f].Value, 0, 4);
                            }
                        }
                        else
                        {
                            if (location == 61)
                            {
                                if (this.SocialTab.ContainsKey(1006))
                                {
                                    this.SocialTab[1006] = it.Stats[f].Value;
                                }
                                else
                                {
                                    this.SocialTab.Add(1006, it.Stats[f].Value);
                                }
                                this.socialMeshLayer.AddMesh(1, it.Stats[f].Value, 0, 4);
                            }
                            else
                            {
                                if (this.SocialTab.ContainsKey(1007))
                                {
                                    this.SocialTab[1007] = it.Stats[f].Value;
                                }
                                else
                                {
                                    this.SocialTab.Add(1007, it.Stats[f].Value);
                                }
                                this.socialMeshLayer.AddMesh(2, it.Stats[f].Value, 0, 4);
                            }
                        }
                    }
                }
            }
        }
 public KnuBotNPC100001(Character target, NonPlayerCharacterClass _parent)
     : base(target, _parent)
 {
 }
 public void applyon(Character ch, int eventnum, bool dolocal, bool tosocialtab, int placement)
 {
     foreach (AOEvents ae in ItemEvents)
     {
         if (ae.EventType == eventnum)
         {
             foreach (AOFunctions af in ae.Functions)
             {
                 FunctionPack.func_do(ch, af, dolocal, tosocialtab, placement);
             }
         }
     }
 }
 public void KnuBotFinishTrade(Character character, int decline)
 {
     if (decline == 1)
     {
         this.KnuBotDeclineTrade(character);
     }
     else
     {
         this.KnuBotAcceptTrade(character);
     }
 }
 public void KnuBotStartTrade(Character character)
 {
     if (this.KnuBot != null)
     {
         this.KnuBot.KnuBotStartTrade(character);
     }
 }
 public void KnuBotCloseChatWindow(Character character)
 {
     if (this.KnuBot != null)
     {
         this.KnuBot.KnuBotCloseChatWindow(character);
     }
 }
 public void KnuBotDeclineTrade(Character character)
 {
     if (this.KnuBot != null)
     {
         this.KnuBot.KnuBotDeclineTrade(character);
     }
 }
 public void KnuBotAnswer(Character ch, Int32 answer)
 {
     if (this.KnuBot != null)
     {
         this.KnuBot.KnuBotAnswer(ch, answer);
     }
 }
            public static bool func_do(Character ch, AOFunctions func, bool dolocalstats, bool tosocialtab, int placement, bool doreqs)
            {
                int c;
                int r;
                Character chartarget = (Character)Misc.FindDynel.FindDynelByID(ch.Target.Type, ch.Target.Instance);
                Boolean reqs_met;
                Character ftarget = null;
                int statval;
                Boolean reqresult;
                if (ch != null)
                {
                    for (c = 0; c < func.TickCount; c++)
                    {
                        reqs_met = true;
                        int childop = -1;
                        if (!doreqs)
                        {
                            for (r = 0; r < func.Requirements.Count; r++)
                            {
                                switch (func.Requirements[r].Target)
                                {
                                    case itemtarget_user:
                                        ftarget = ch;
                                        break;
                                    case itemtarget_wearer:
                                        ftarget = ch;
                                        break;
                                    case itemtarget_target:
                                        ftarget = chartarget;
                                        break;
                                    case itemtarget_fightingtarget:
                                        // Fighting target
                                        break;
                                    case itemtarget_self:
                                        ftarget = ch;
                                        break;
                                    case itemtarget_selectedtarget:
                                        ftarget = chartarget;
                                        break;
                                }
                                if (ftarget == null)
                                {
                                    reqs_met = false;
                                    return false;
                                }
                                statval = ftarget.Stats.Get(func.Requirements[r].Statnumber);
                                switch (func.Requirements[r].Operator)
                                {
                                    case operator_and:
                                        reqresult = ((statval & func.Requirements[r].Value) != 0);
                                        break;
                                    case operator_or:
                                        reqresult = ((statval | func.Requirements[r].Value) != 0);
                                        break;
                                    case operator_equalto:
                                        reqresult = (statval == func.Requirements[r].Value);
                                        break;
                                    case operator_lessthan:
                                        reqresult = (statval < func.Requirements[r].Value);
                                        break;
                                    case operator_greaterthan:
                                        reqresult = (statval > func.Requirements[r].Value);
                                        break;
                                    case operator_unequal:
                                        reqresult = (statval != func.Requirements[r].Value);
                                        break;
                                    case operator_true:
                                        reqresult = (statval != 0);
                                        break;
                                    case operator_false:
                                        reqresult = (statval == 0);
                                        break;
                                    case operator_bitand:
                                        reqresult = ((statval & func.Requirements[r].Value) != 0);
                                        break;
                                    case operator_bitor:
                                        reqresult = ((statval | func.Requirements[r].Value) != 0);
                                        break;
                                    default:
                                        reqresult = true;
                                        break;
                                }

                                switch (childop)
                                {
                                    case operator_and:
                                        reqs_met &= reqresult;
                                        break;
                                    case operator_or:
                                        reqs_met |= reqresult;
                                        break;
                                    case -1:
                                        reqs_met = reqresult;
                                        break;
                                    default:
                                        break;
                                }
                                childop = func.Requirements[r].ChildOperator;
                            }
                        }

                        if (!reqs_met)
                        {
                            return reqs_met;
                        }

                        switch (func.FunctionType)
                        {
                            // Set new Texture
                            case ItemHandler.functiontype_texture:
                                SqlWrapper ms = new SqlWrapper();
                                if (!tosocialtab)
                                {
                                    ms.SqlUpdate("Update " + ch.getSQLTablefromDynelType() + " set Textures" + func.Arguments[1].ToString() + "=" + func.Arguments[0].ToString() + " WHERE ID=" + ch.ID.ToString());
                                    AOTextures ao = new AOTextures((int)func.Arguments[1], (int)func.Arguments[0]);
                                    ch.Textures.Add(ao);
                                }
                                else
                                {
                                    int texnum = Int32.Parse(func.Arguments[1].ToString());
                                    int texval = Int32.Parse(func.Arguments[0].ToString());
                                    if (ch.SocialTab.ContainsKey(texnum))
                                    {
                                        ch.SocialTab[texnum] = texval;
                                    }
                                    else
                                    {
                                        ch.SocialTab.Add(texnum, texval);
                                    }
                                    ch.SaveSocialTab();
                                }

                                break;
                            // Set Headmesh
                            case ItemHandler.functiontype_headmesh:
                                if (!tosocialtab)
                                {
                                    ch.Stats.HeadMesh.StatModifier = (Int32)((Int32)func.Arguments[1] - ch.Stats.HeadMesh.StatBaseValue); // Headmesh
                                    ch.MeshLayer.AddMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], 0);
                                }
                                else
                                {
                                    if (ch.SocialTab.ContainsKey(ch.Stats.HeadMesh.StatNumber))
                                    {
                                        ch.SocialTab[ch.Stats.HeadMesh.StatNumber] = (Int32)func.Arguments[0];
                                        ch.SocialMeshLayer.AddMesh(0, (Int32)func.Arguments[0], (Int32)func.Arguments[1], 0);
                                    }
                                    else
                                    {
                                        ch.SocialTab.Add(ch.Stats.HeadMesh.StatNumber, (Int32)func.Arguments[0]);
                                        ch.SocialMeshLayer.AddMesh(0, (Int32)func.Arguments[0], (Int32)func.Arguments[1], 0);
                                    }
                                    ch.SaveSocialTab();
                                }
                                break;
                            // Set Shouldermesh
                            case ItemHandler.functiontype_shouldermesh:
                                if ((placement == 19) || (placement == 51))
                                {
                                    if (!tosocialtab)
                                    {
                                        ch.Stats.ShoulderMeshRight.Set((Int32)func.Arguments[1]);
                                        ch.Stats.ShoulderMeshLeft.Set((Int32)func.Arguments[1]);
                                        ch.MeshLayer.AddMesh(3, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        ch.MeshLayer.AddMesh(4, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                    }
                                    else
                                    {
                                        ch.SocialMeshLayer.AddMesh(3, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        ch.SocialMeshLayer.AddMesh(4, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                    }
                                }
                                else
                                {
                                    if (!tosocialtab)
                                    {
                                        if (placement == 20)
                                        {
                                            ch.Stats.ShoulderMeshLeft.Set((Int32)func.Arguments[1]);
                                            ch.MeshLayer.AddMesh(3, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        }
                                        if (placement == 22)
                                        {
                                            ch.Stats.ShoulderMeshLeft.Set((Int32)func.Arguments[1]);
                                            ch.MeshLayer.AddMesh(4, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        }
                                    }
                                    else
                                    {
                                        if (placement == 52)
                                        {
                                            ch.Stats.ShoulderMeshRight.Set((Int32)func.Arguments[1]);
                                            ch.SocialMeshLayer.AddMesh(3, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        }
                                        if (placement == 54)
                                        {
                                            ch.Stats.ShoulderMeshLeft.Set((Int32)func.Arguments[1]);
                                            ch.SocialMeshLayer.AddMesh(4, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        }
                                    }


                                }
                                break;
                            // Set Backmesh
                            case ItemHandler.functiontype_backmesh:
                                if (!tosocialtab)
                                {
                                    ch.Stats.BackMesh.Set((Int32)func.Arguments[0]); // Shouldermesh
                                    ch.MeshLayer.AddMesh(5, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                else
                                {
                                    ch.SocialMeshLayer.AddMesh(5, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                break;
                            // Set Hairmesh
                            case ItemHandler.functiontype_hairmesh:
                                if (!tosocialtab)
                                {
                                    ch.Stats.HairMesh.Set((Int32)func.Arguments[0]); // HairMesh
                                    ch.MeshLayer.AddMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                else
                                {
                                    ch.SocialMeshLayer.AddMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                break;
                            case ItemHandler.functiontype_attractormesh:
                                if (!tosocialtab)
                                {
                                    ch.Stats.HairMesh.Set((Int32)func.Arguments[0]); // HairMesh
                                    ch.MeshLayer.AddMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                else
                                {
                                    ch.SocialMeshLayer.AddMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                break;
                            case ItemHandler.functiontype_modify:
                                // TODO: req check for OE
                                if (dolocalstats)
                                {
                                    if (!tosocialtab)
                                    {
                                        ch.Stats.SetModifier((Int32)func.Arguments[0], ch.Stats.GetModifier((Int32)func.Arguments[0]) + (Int32)func.Arguments[1]);
                                    }
                                }
                                break;
                            case ItemHandler.functiontype_modifypercentage:
                                // TODO: req check for OE
                                if (dolocalstats)
                                {
                                    if (!tosocialtab)
                                    {
                                        ch.Stats.SetPercentageModifier((Int32)func.Arguments[0], ch.Stats.GetPercentageModifier((Int32)func.Arguments[0]) + (Int32)func.Arguments[1]);
                                    }
                                }
                                break;
                            case ItemHandler.functiontype_uploadnano:
                                ch.UploadNano((Int32)func.Arguments[0]);
                                Packets.UploadNanoupdate.Send(ch, 53019, (Int32)func.Arguments[0]);
                                break;
                            case ItemHandler.functiontype_shophash:
                                // Do nothing, it's covered in 
                                break;
                            default:
                                break;
                        }
                    }
                }
                return false;
            }
 public static bool func_do(Character ch, AOFunctions func, bool dolocalstats, bool tosocialtab, int placement)
 {
     return func_do(ch, func, dolocalstats, tosocialtab, placement, true);
 }
Exemplo n.º 15
0
        /// <summary>
        /// Fake equip, don't pass effects to local stats
        /// </summary>
        /// <param name="it">Item</param>
        /// <param name="ch">Character</param>
        /// <param name="tosocialtab">should it be equipped to social tab</param>
        /// <param name="location">Location</param>
        public void FakeEquipItem(ItemHandler.Item it, Character ch, bool tosocialtab, int location)
        {
            int counter = 0;
            int f;
            lock (ch)
            {
                while (counter < it.ItemEvents.Count)
                {
                    if (it.ItemEvents[counter].EventType == ItemHandler.eventtype_onwear)
                    {
                        f = 0;
                        while (f < it.ItemEvents[counter].Functions.Count)
                        {
                            ItemHandler.FunctionPack.func_do(ch, it.ItemEvents[counter].Functions[f], false, tosocialtab, location, false);
                            f++;
                        }
                    }
                    counter++;
                }

                // Set Weaponmesh
                // Todo: another packet has to be sent, defining how to hold the weapon
                if (it.itemtype == ItemHandler.itemtype_Weapon)
                {
                    Stats.WeaponsStyle.Value |= it.GetWeaponStyle();
                    if (tosocialtab)
                    {
                        Stats.WeaponsStyle.Value = it.GetWeaponStyle();
                    }

                    counter = 0;
                    f = -1;
                    while (counter < it.ItemAttributes.Count)
                    {
                        if (it.ItemAttributes[counter].Stat == 209)
                        {
                            f = counter; // found Weapon mesh attribute
                            break;
                        }
                        counter++;
                    }
                    if (f != -1)
                    {
                        if (!tosocialtab)
                        {
                            if (location == 6)
                            {
                                Stats.WeaponMeshRight.Set((uint)it.ItemAttributes[f].Value); // Weaponmesh
                                MeshLayer.AddMesh(1, (Int32)it.ItemAttributes[f].Value, 0, 4);
                            }
                            else
                            {
                                Stats.WeaponMeshLeft.Set((uint)it.ItemAttributes[f].Value); // Weaponmesh
                                MeshLayer.AddMesh(2, (Int32)it.ItemAttributes[f].Value, 0, 4);
                            }
                        }
                        else
                        {
                            if (location == 61)
                            {
                                if (SocialTab.ContainsKey(1006))
                                {
                                    SocialTab[1006] = (int)it.ItemAttributes[f].Value;
                                }
                                else
                                {
                                    SocialTab.Add(1006, (int)it.ItemAttributes[f].Value);
                                }
                                SocialMeshLayer.AddMesh(1, (Int32)it.ItemAttributes[f].Value, 0, 4);
                            }
                            else
                            {
                                if (SocialTab.ContainsKey(1007))
                                {
                                    SocialTab[1007] = (int)it.ItemAttributes[f].Value;
                                }
                                else
                                {
                                    SocialTab.Add(1007, (int)it.ItemAttributes[f].Value);
                                }
                                SocialMeshLayer.AddMesh(2, (Int32)it.ItemAttributes[f].Value, 0, 4);
                            }
                        }
                    }
                }
            }
        }
 public void KnuBotTrade(Character character, AOItem item)
 {
     if (this.KnuBot != null)
     {
         this.KnuBot.KnuBotTrade(character, item);
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Unequip item
 /// </summary>
 /// <param name="it">Item</param>
 /// <param name="ch">Character</param>
 /// <param name="fromsocialtab">unequip from social tab?</param>
 /// <param name="location">Location</param>
 public void UnequipItem(ItemHandler.Item it, Character ch, bool fromsocialtab, int location)
 {
     lock (ch)
     {
         int counter = 0;
         int f;
         AOFunctions fx;
         while (counter < it.ItemEvents.Count)
         {
             if (it.ItemEvents[counter].EventType == ItemHandler.eventtype_onwear)
             {
                 f = 0;
                 while (f < it.ItemEvents[counter].Functions.Count)
                 {
                     fx = it.ItemEvents[counter].Functions[f];
                     ItemHandler.FunctionPack.func_revert(ch, it.ItemEvents[counter].Functions[f], fromsocialtab, location);
                     f++;
                 }
             }
             counter++;
         }
         // Set Weaponmesh
         if (it.itemtype == ItemHandler.itemtype_Weapon)
         {
             counter = 0;
             f = -1;
             while (counter < it.ItemAttributes.Count)
             {
                 if (it.ItemAttributes[counter].Stat == 209)
                 {
                     f = counter;
                     break;
                 }
                 counter++;
             }
             if (f != -1)
             {
                 if (!fromsocialtab)
                 {
                     if (location == 6)
                     {
                         Stats.WeaponMeshRight.Set(0); // Weaponmesh
                         ch.MeshLayer.RemoveMesh(2, it.ItemAttributes[f].Stat, 0, Misc.MeshLayers.GetLayer(location));
                     }
                     else
                     {
                         Stats.WeaponMeshLeft.Set(0);
                         ch.MeshLayer.RemoveMesh(2, it.ItemAttributes[f].Stat, 0, Misc.MeshLayers.GetLayer(location));
                     }
                 }
                 else
                 {
                     if (location == 61)
                     {
                         ch.SocialMeshLayer.RemoveMesh(2, it.ItemAttributes[f].Stat, 0, Misc.MeshLayers.GetLayer(location));
                     }
                     else
                     {
                         ch.SocialMeshLayer.RemoveMesh(2, it.ItemAttributes[f].Stat, 0, Misc.MeshLayers.GetLayer(location));
                     }
                 }
             }
         }
         if (!fromsocialtab)
         {
             CalculateSkills();
         }
     }
 }
            public static bool func_revert(Character ch, AOFunctions func, bool fromsocialtab, int placement)
            {
                int c;

                if (ch != null)
                {
                    for (c = 0; c < func.TickCount; c++)
                    {
                        switch (func.FunctionType)
                        {
                            case ItemHandler.functiontype_texture:
                                // Todo: check for second Arm item
                                SqlWrapper ms = new SqlWrapper();
                                if (!fromsocialtab)
                                {
                                    ms.SqlUpdate("Update " + ch.getSQLTablefromDynelType() + " set Textures" + func.Arguments[1].ToString() + "=0 WHERE ID=" + ch.ID.ToString() + " AND Textures" + func.Arguments[1].ToString() + "=" + func.Arguments[0].ToString());
                                    int ct = ch.Textures.Count - 1;
                                    while (ct >= 0)
                                    {
                                        if (ch.Textures[ct].place == (int)func.Arguments[1])
                                        {
                                            ch.Textures.RemoveAt(ct);
                                            break;
                                        }
                                        ct--;
                                    }
                                }
                                else
                                {
                                    if (ch.SocialTab.ContainsKey((Int32)func.Arguments[1]))
                                    {
                                        ch.SocialTab[(Int32)func.Arguments[1]] = 0;
                                    }
                                    else
                                    {
                                        ch.SocialTab.Add((Int32)func.Arguments[1], 0);
                                    }
                                }
                                break;
                            case ItemHandler.functiontype_headmesh:
                                if (!fromsocialtab)
                                {
                                    ch.Stats.HeadMesh.StatModifier = 0;
                                    ch.MeshLayer.RemoveMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                else
                                {
                                    ch.SocialMeshLayer.RemoveMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                // Reverting the Head modification
                                break;
                            case ItemHandler.functiontype_shouldermesh:
                                // TODO: check for second shoulder item
                                if (!fromsocialtab)
                                {
                                    if (placement == 19)
                                    {
                                        ch.MeshLayer.RemoveMesh(4, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                        ch.MeshLayer.RemoveMesh(3, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                    }
                                    if (placement == 20) // Right
                                    {
                                        ch.Stats.ShoulderMeshRight.Set(0); // Shouldermesh Right
                                        ch.MeshLayer.RemoveMesh(3, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                    }
                                    if (placement == 22) // Left
                                    {
                                        ch.Stats.ShoulderMeshLeft.Set(0); // Shouldermesh Left
                                        ch.MeshLayer.RemoveMesh(4, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                    }
                                }
                                else
                                {
                                    if (placement == 52) // Right
                                    {
                                        ch.SocialMeshLayer.RemoveMesh(3, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                    }
                                    if (placement == 54) // Left
                                    {
                                        ch.SocialMeshLayer.RemoveMesh(4, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                    }
                                }
                                break;
                            case ItemHandler.functiontype_backmesh:
                                if (!fromsocialtab)
                                {
                                    ch.Stats.BackMesh.Set(0); // Backmesh
                                    ch.MeshLayer.RemoveMesh(5, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                else
                                {
                                    ch.SocialMeshLayer.RemoveMesh(5, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                break;
                            case ItemHandler.functiontype_attractormesh:
                                if (!fromsocialtab)
                                {
                                    ch.Stats.HairMesh.Set(0); // Attractormesh
                                    ch.MeshLayer.RemoveMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                else
                                {
                                    if (ch.SocialTab.ContainsKey(32))
                                    {
                                        ch.SocialTab[32] = 0;
                                    }
                                    else
                                    {
                                        ch.SocialTab.Add(32, 0);
                                    }
                                    ch.SocialMeshLayer.RemoveMesh(0, (Int32)func.Arguments[1], (Int32)func.Arguments[0], Misc.MeshLayers.GetLayer(placement));
                                }
                                break;
                            default:
                                break;
                        }
                    }
                }
                return false;
            }