Exemplo n.º 1
0
        private void AssociateLiving(CharacterItemRecord livingObject, CharacterItemRecord targeted)
        {
            LivingObjectRecord record = LivingObjectRecord.GetLivingObjectDatas(livingObject.GId);

            if (record != null)
            {
                if (record.ItemType == targeted.Template.TypeId)
                {
                    targeted.AddEffectDice(EffectsEnum.Effect_LivingObjectId,
                                           livingObject.Template.Id,
                                           livingObject.Template.Id,
                                           livingObject.Template.Id);

                    foreach (var effect in livingObject.Effects)
                    {
                        targeted.AddEffect(effect);
                    }

                    OnItemModified(targeted);
                    RefreshWeight();

                    if (targeted.PositionEnum != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED)
                    {
                        UpdateItemAppearence(targeted, livingObject.AppearanceId);
                        Character.RefreshActorOnMap();
                    }

                    RemoveItem(livingObject, livingObject.Quantity);
                }
            }
        }
        public static void InitLivingObject(CharacterItemRecord item, Character character)
        {
            if (item.Effects.Count == 3)
            {
                LivingObjectRecord livingObjectDatas = LivingObjectRecord.GetLivingObjectDatas(item.GId);

                if (livingObjectDatas != null)
                {
                    item.Effects.Clear();

                    item.Effects.Add(new EffectInteger((ushort)EffectsEnum.Effect_LivingObjectLevel, 361));
                    item.Effects.Add(new EffectInteger((ushort)EffectsEnum.Effect_LivingObjectCategory, livingObjectDatas.ItemType));
                    item.Effects.Add(new EffectInteger((ushort)EffectsEnum.Effect_LivingObjectMood, 0));
                    item.Effects.Add(new EffectInteger((ushort)EffectsEnum.Effect_LivingObjectSkin, 1));

                    if (livingObjectDatas.Skinnable)
                    {
                        item.AppearanceId = livingObjectDatas.Skins.FirstOrDefault();
                    }
                }
                else
                {
                    logger.Error("Cannot initialize living object, no template:  " + item.Template.Name);
                }
            }
        }
Exemplo n.º 3
0
        public void ChangeLivingObjectSkin(CharacterItemRecord item, ushort skinIndex, CharacterInventoryPositionEnum characterInventoryPositionEnum)
        {
            if (item.Quantity > 1)
            {
                return;
            }

            EffectInteger effect = item.FirstEffect <EffectInteger>(EffectsEnum.Effect_LivingObjectSkin);

            if (effect != null)
            {
                LivingObjectRecord record = LivingObjectRecord.IsLivingObject(item.GId)
                                                ? LivingObjectRecord.GetLivingObjectDatas(item.GId)
                                                : LivingObjectRecord.GetLivingObjectDatas(item.FirstEffect <EffectDice>(EffectsEnum.Effect_LivingObjectId).Const);


                if (record.Skinnable)
                {
                    ushort skin = record.GetSkin(skinIndex);

                    if (characterInventoryPositionEnum != CharacterInventoryPositionEnum.INVENTORY_POSITION_NOT_EQUIPED)
                    {
                        this.UpdateItemAppearence(item, skin);
                    }
                    else
                    {
                        item.AppearanceId = skin;
                    }

                    Character.RefreshActorOnMap();
                }


                effect.Value = skinIndex;
                OnItemModified(item);
                RefreshWeight();
                item.UpdateElement();
            }
            else
            {
                Character.ReplyError("unable to modify item skin..he is not a valid living object.");
            }
        }