public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
 {
     Vendor v = Pool.Instance.GetObject<Vendor>(character.Playfield.Identity, target);
     if (v != null)
     {
         int pfid = character.Playfield.Identity.Instance;
         StatelData sd =
             PlayfieldLoader.PFData[pfid].Statels.FirstOrDefault(x => x.Identity.Equals(v.OriginalIdentity));
         if (sd != null)
         {
             int instance = (((sd.Identity.Instance) >> 16) & 0xff
                             | (character.Playfield.Identity.Instance << 16));
             DBVendor dbv = new DBVendor();
             dbv.Id = instance;
             dbv.Playfield = pfid;
             dbv.X = sd.X;
             dbv.Y = sd.Y;
             dbv.Z = sd.Z;
             dbv.HeadingX = sd.HeadingX;
             dbv.HeadingY = sd.HeadingY;
             dbv.HeadingZ = sd.HeadingZ;
             dbv.HeadingW = sd.HeadingW;
             dbv.Name = "New shop, please fill me";
             dbv.TemplateId = sd.TemplateId;
             dbv.Hash = "";
             VendorDao.Instance.Delete(dbv.Id);
             VendorDao.Instance.Add(dbv, dontUseId: false);
         }
     }
 }
        public Vendor(Identity parent, Identity id, string templateHash)
            : base(parent, id)
        {
            DBVendorTemplate vendorTemplate =
                VendorTemplateDao.Instance.GetWhere(new { Hash = templateHash }).FirstOrDefault();
            if (vendorTemplate == null)
            {
                LogUtil.Debug(
                    DebugInfoDetail.Shopping,
                    "Could not find a hash entry for this shop, pls check vendors table.");
            }

            this.Stats = new SimpleStatList();
            // Fallback on Advy adv. crystals shop
            this.Template = ItemLoader.ItemList[vendorTemplate != null ? vendorTemplate.ItemTemplate : 46522];
            foreach (KeyValuePair<int, int> s in this.Template.Stats)
            {
                this.Stats[s.Key].Value = s.Value;
            }
            this.BaseInventory = new VendorInventory(this);
            if (vendorTemplate != null)
            {
                this.TemplateHash = vendorTemplate.Hash;
                this.Name = vendorTemplate.Name;

                this.BaseInventory.Read();
            }
        }
 public TemporaryBag(Identity parent, Identity id, Identity shopper, Identity vendor, int vendorSlots = 255)
     : base(parent, id)
 {
     this.Shopper = shopper;
     this.Vendor = vendor;
     this.charactersBag = new OutgoingTradeInventoryPage(id, vendorSlots);
     this.vendorsBag = new KnuBotTradeInventoryPage(id);
 }
        public PlayerViewModel(Guid id, Identity remoteId, string name)
        {
            Contract.Requires<ArgumentException>(string.IsNullOrWhiteSpace(name) == false);

            this.id = id;
            this.remoteId = remoteId;
            this.name = name;
        }
        public KnuBotItemGiver(Identity identity)
            : base(identity)
        {
            this.InitializeItemSets();

            KnuBotDialogTree rootNode = new KnuBotDialogTree(
                "0",
                this.Condition0,
                new[]
                {
                    this.CAS(this.DialogGM0, "self"), this.CAS(this.TransferToRKArmorSet, "RKArmorSet"),
                    this.CAS(this.TransferToSLArmorSet, "SLArmorSet"), this.CAS(this.GoodBye, "self")
                });
            this.SetRootNode(rootNode);

            KnuBotDialogTree lastNode =
                rootNode.AddNode(
                    new KnuBotDialogTree(
                        "RKArmorSet",
                        this.Condition01,
                        new[]
                        {
                            this.CAS(this.DialogShowRKArmorSets, "self"),
                            this.CAS(this.ChooseQlFromSet, "QLChoiceRKArmorSet"), this.CAS(this.BackToRoot, "root")
                        }));

            lastNode.AddNode(
                new KnuBotDialogTree(
                    "QLChoiceRKArmorSet",
                    this.QLCondition,
                    new[]
                    {
                        this.CAS(this.ShowQLs, "self"), this.CAS(this.GiveItemSet, "root"),
                        this.CAS(this.BackToRoot, "parent")
                    }));

            lastNode =
                rootNode.AddNode(
                    new KnuBotDialogTree(
                        "SLArmorSet",
                        this.ConditionSL,
                        new[]
                        {
                            this.CAS(this.DialogShowSLArmorSets, "self"),
                            this.CAS(this.ChooseQlFromSet, "QLChoiceSLArmorSet"), this.CAS(this.BackToRoot, "root")
                        }));

            lastNode.AddNode(
                new KnuBotDialogTree(
                    "QLChoiceSLArmorSet",
                    this.QLCondition,
                    new[]
                    {
                        this.CAS(this.ShowQLs, "self"), this.CAS(this.GiveItemSet, "root"),
                        this.CAS(this.BackToRoot, "parent")
                    }));
        }
 /// <summary>
 /// </summary>
 /// <param name="pooledIn">
 /// </param>
 /// <param name="parent">
 /// </param>
 /// <param name="id">
 /// </param>
 public PooledObject(Identity parent, Identity id)
 {
     this.Identity = id;
     this.Parent = parent;
     Pool.Instance.AddObject(parent, this);
     LogUtil.Debug(
         DebugInfoDetail.Pool,
         "Created new object " + id.ToString(true) + " of " + parent.ToString(true));
 }
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            IInstancedEntity targetEntity = null;

            // Fall back to self it no target is selected
            if ((targetEntity = character.Playfield.FindByIdentity(target)) == null)
            {
                targetEntity = character;
            }

            IItemContainer container = targetEntity as IItemContainer;

            // Does this entity have a BaseInventory?
            if (container != null)
            {
                int lowId;
                int highId;
                int ql;
                if (!int.TryParse(args[1], out lowId))
                {
                    character.Playfield.Publish(ChatText.CreateIM(character, "LowId is no number"));
                    return;
                }

                if (!int.TryParse(args[2], out ql))
                {
                    character.Playfield.Publish(ChatText.CreateIM(character, "QualityLevel is no number"));
                    return;
                }

                // Determine low and high id depending on ql
                lowId = ItemLoader.ItemList[lowId].GetLowId(ql);
                highId = ItemLoader.ItemList[lowId].GetHighId(ql);

                Item item = new Item(ql, lowId, highId);
                if (ItemLoader.ItemList[lowId].IsStackable())
                {
                    item.MultipleCount = ItemLoader.ItemList[lowId].getItemAttribute(212);
                }

                InventoryError err = container.BaseInventory.TryAdd(item);
                if (err != InventoryError.OK)
                {
                    character.Playfield.Publish(
                        ChatText.CreateIM(character, "Could not add to inventory. (" + err + ")"));
                }

                if (targetEntity as Character != null)
                {
                    AddTemplate.Send((targetEntity as Character).Client, item);
                }
            }
            else
            {
                character.Playfield.Publish(ChatText.CreateIM(character, "Target has no Inventory."));
            }
        }
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            if ((character.Stats[StatIds.externaldoorinstance].Value == 0)
                || (character.Stats[StatIds.externalplayfieldinstance].Value == 0))
            {
                ChatTextMessageHandler.Default.Create(character, "Please enter a proxyfied playfield first.");
            }

            Coordinate tempCoordinate = character.Coordinates();
            PlayfieldData pfData = PlayfieldLoader.PFData[character.Playfield.Identity.Instance];
            StatelData o = null;
            foreach (StatelData s in pfData.Statels)
            {
                if (o == null)
                {
                    o = s;
                }
                else
                {
                    if (Coordinate.Distance2D(tempCoordinate, s.Coord())
                        < Coordinate.Distance2D(tempCoordinate, o.Coord()))
                    {
                        o = s;
                    }
                }
            }
            if (o == null)
            {

                ChatTextMessageHandler.Default.Create(
                    character,
                    "No statel on this playfield... Very odd, where exactly are you???");

            }
            else
            {
                DBTeleport tel = new DBTeleport();
                tel.playfield = character.Stats[StatIds.externalplayfieldinstance].Value;
                tel.statelType = 0xc748; // Door only for now
                tel.statelInstance = character.Stats[StatIds.externaldoorinstance].BaseValue;
                tel.destinationPlayfield = o.PlayfieldId;
                tel.destinationType = (int)o.Identity.Type;
                tel.destinationInstance = BitConverter.ToUInt32(BitConverter.GetBytes(o.Identity.Instance), 0);

                var temp = TeleportDao.Instance.GetWhere(new { tel.playfield, tel.statelType, tel.statelInstance });
                foreach (var t in temp)
                {
                    TeleportDao.Instance.Delete(t.Id);
                }
                TeleportDao.Instance.Add(tel);
                character.Playfield.Publish(
            ChatTextMessageHandler.Default.CreateIM(character, "Proxy saved"));

            }
        }
 public StaticDynel(Identity parent, Identity id, ItemTemplate template)
     : base(parent, id)
 {
     this.Template = template;
     this.Events = this.Template.Events;
     this.Actions = this.Template.Actions;
     foreach (KeyValuePair<int, int> s in this.Template.Stats)
     {
         this.Stats.Add(s.Key, s.Value);
     }
 }
        public static ICharacter InstantiateMobSpawn(
            DBMobSpawn mob,
            DBMobSpawnStat[] stats,
            IController npccontroller,
            IPlayfield playfield)
        {
            if (playfield != null)
            {
                Identity mobId = new Identity() { Type = IdentityType.CanbeAffected, Instance = mob.Id };
                if (Pool.Instance.GetObject(playfield.Identity, mobId) != null)
                {
                    throw new Exception("Object " + mobId.ToString(true) + " already exists!!");
                }
                Character cmob = new Character(playfield.Identity, mobId, npccontroller);
                cmob.Read();
                cmob.Playfield = playfield;
                cmob.Coordinates(new Coordinate() { x = mob.X, y = mob.Y, z = mob.Z });
                cmob.RawHeading = new Quaternion(mob.HeadingX, mob.HeadingY, mob.HeadingZ, mob.HeadingW);
                cmob.Name = mob.Name;
                cmob.FirstName = "";
                cmob.LastName = "";
                foreach (DBMobSpawnStat stat in stats)
                {
                    cmob.Stats.SetBaseValueWithoutTriggering(stat.Stat, (uint)stat.Value);
                }

                cmob.Stats.SetBaseValueWithoutTriggering((int)StatIds.visualprofession, cmob.Stats[StatIds.profession].BaseValue);
                // initiate affected stats calculation
                int temp = cmob.Stats[StatIds.level].Value;
                temp = cmob.Stats[StatIds.agility].Value;
                temp = cmob.Stats[StatIds.headmesh].Value;
                cmob.MeshLayer.AddMesh(0, cmob.Stats[StatIds.headmesh].Value, 0, 4);
                cmob.SocialMeshLayer.AddMesh(0, cmob.Stats[StatIds.headmesh].Value, 0, 4);
                List<MobSpawnWaypoint> waypoints =
                    MessagePackZip.DeserializeData<MobSpawnWaypoint>(mob.Waypoints.ToArray());
                foreach (MobSpawnWaypoint wp in waypoints)
                {
                    Waypoint mobwp = new Waypoint();
                    mobwp.Position.x = wp.X;
                    mobwp.Position.y = wp.Y;
                    mobwp.Position.z = wp.Z;
                    mobwp.Running = wp.WalkMode == 1;
                    cmob.Waypoints.Add(mobwp);
                }
                npccontroller.Character = cmob;
                if (cmob.Waypoints.Count > 2)
                {
                    cmob.Controller.State = CharacterState.Patrolling;
                }
                cmob.DoNotDoTimers = false;
                return cmob;
            }
            return null;
        }
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            Dictionary<Identity, string> list = ((Playfield)character.Playfield).ListAvailablePlayfields();
            var messList = new List<MessageBody>();
            foreach (KeyValuePair<Identity, string> pf in list)
            {
                messList.Add(ChatText.Create(character, pf.Key.Instance.ToString().PadLeft(8) + ": " + pf.Value));
            }

            character.Playfield.Publish(Bulk.CreateIM(character.Client, messList.ToArray()));
        }
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            Vector3 position = new Vector3();
            position.X = character.Coordinates().x;
            position.Y = character.Coordinates().y;
            position.Z = character.Coordinates().z;
            byte type = byte.Parse(args[1]);
            /*if (type == 2)
            {
                // Set temperature
                WeatherControlMessageHandler.Default.Send(
                    character,
                    byte.Parse(args[1]),
                    (byte)(sbyte.Parse(args[2])),
                    byte.Parse(args[3]),
                    byte.Parse(args[4]),
                    byte.Parse(args[5]),
                    byte.Parse(args[6]),
                    byte.Parse(args[7]),
                    byte.Parse(args[8]));
            }
            else*/
            {
                int ambientColor = Convert.ToInt32(args[13], 16);
                int fogColor = Convert.ToInt32(args[14], 16);

                WeatherEntry newWeather = new WeatherEntry();
                newWeather.AmbientColor = ambientColor;
                newWeather.FogColor = fogColor;
                newWeather.Position = position;
                newWeather.FadeIn = short.Parse(args[1]);
                newWeather.Duration = int.Parse(args[2]);
                newWeather.FadeOut = short.Parse(args[3]);
                newWeather.Range = Single.Parse(args[4]);
                newWeather.WeatherType = (WeatherType)byte.Parse(args[5]);
                newWeather.Intensity = byte.Parse(args[6]);
                newWeather.Wind = byte.Parse(args[7]);
                newWeather.Clouds = byte.Parse(args[8]);
                newWeather.Thunderstrikes = byte.Parse(args[9]);
                newWeather.Tremors = byte.Parse(args[10]);
                newWeather.ThunderstrikePercentage = byte.Parse(args[11]);
                newWeather.TremorPercentage = byte.Parse(args[12]);
                newWeather.ZBufferVisibility = byte.Parse(args[15]);
                newWeather.Playfield = character.Playfield.Identity;

                WeatherSettings.Instance.Add(newWeather);

                WeatherControlMessageHandler.Default.Send(character, newWeather);
            }
        }
Exemple #13
0
        /// <summary>
        /// </summary>
        /// <param name="pooledIn">
        /// </param>
        /// <param name="id">
        /// </param>
        public Dynel(Pool pooledIn, Identity id)
            : base(pooledIn, id)
        {
            this.Starting = true;
            this.DoNotDoTimers = true;

            this.Stats = new Stats(this.Identity);
            this.InitializeStats();

            this.BaseInventory = new UnitInventory(this);

            this.DoNotDoTimers = false;
            this.Starting = false;
        }
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            List<StatelData> sd = PlayfieldLoader.PFData[character.Playfield.Identity.Instance].Statels;
            var messList = new List<MessageBody>();
            foreach (StatelData s in sd)
            {
                messList.Add(
                    ChatText.Create(
                        character,
                        ((int)s.StatelIdentity.Type).ToString("X8") + ":" + s.StatelIdentity.Instance.ToString("X8")));
            }

            character.Playfield.Publish(Bulk.CreateIM(character.Client, messList.ToArray()));
        }
 /// <summary>
 /// </summary>
 /// <param name="character">
 /// </param>
 /// <param name="destination">
 /// </param>
 /// <param name="heading">
 /// </param>
 /// <param name="playfield">
 /// </param>
 /// <returns>
 /// </returns>
 public static N3TeleportMessage Create(
     ICharacter character, 
     Coordinate destination, 
     IQuaternion heading, 
     Identity playfield)
 {
     return new N3TeleportMessage()
            {
                Identity = character.Identity,
                Destination =
                    new Vector3()
                    {
                        X = destination.x,
                        Y = destination.y,
                        Z = destination.z
                    },
                Heading =
                    new Quaternion()
                    {
                        X = heading.xf,
                        Y = heading.yf,
                        Z = heading.zf,
                        W = heading.wf
                    },
                Unknown1 = 0x61,
                Playfield =
                    new Identity()
                    {
                        Type = IdentityType.Playfield1,
                        Instance = playfield.Instance
                    },
                ChangePlayfield =
                    ((playfield.Instance != character.Playfield.Identity.Instance)
                     || (playfield.Type != character.Playfield.Identity.Type))
                        ? new Identity
                          {
                              Type = IdentityType.Playfield2,
                              Instance = playfield.Instance
                          }
                        : Identity.None,
                Playfield2 =
                    new Identity
                    {
                        Type = IdentityType.Playfield3,
                        Instance = playfield.Instance
                    },
            };
 }
        public bool Add(Identity from, IItem item)
        {
            if (from.Equals(this.Shopper))
            {
                this.vendorsBag.Add(this.vendorsBag.FindFreeSlot(), item);
                LogUtil.Debug(DebugInfoDetail.Shopping, "Added Item from character " + from.ToString(true));
            }
            else
            {
                this.charactersBag.Add(from.Instance);
                LogUtil.Debug(DebugInfoDetail.Shopping, "Added Item from shop on position " + from.ToString(true));
            }

            // For now no invalid trades
            return true;
        }
        public static void SpawnVendorFromDatabaseTemplate(DBVendor vendor, IPlayfield playfield)
        {
            Identity pfIdentity = new Identity() { Type = IdentityType.Playfield, Instance = vendor.Playfield };
            Identity freeIdentity = new Identity()
                                    {
                                        Type = IdentityType.VendingMachine,
                                        Instance =
                                            Pool.Instance.GetFreeInstance<Vendor>(
                                                0x70000000,
                                                IdentityType.VendingMachine)
                                    };

            Vendor v = new Vendor(pfIdentity, freeIdentity, vendor.Hash);

            v.RawCoordinates = new Vector3(vendor.X, vendor.Y, vendor.Z);
            v.Heading = new Quaternion(vendor.HeadingX, vendor.HeadingY, vendor.HeadingZ, vendor.HeadingW);
            v.Playfield = playfield;
        }
        public InfoBotKnu(Identity identity)
            : base(identity)
        {
            KnuBotDialogTree temp = new KnuBotDialogTree(
                "0",
                this.TreeCondition0,
                new[]
                {
                    // This is the main dialog
                    this.CAS(this.MainDialog, "self"),
                    // This will be called if the player asks for commands in the main dialog
                    this.CAS(this.ChatCommands, "self"),
                    // this will be called if the player selects goodbye in the main dialog
                    this.CAS(this.GoodBye, "self")
                });

            // SetRootNode needs to be done after building the first node, so AddNode can put in neccesary information in subsequent nodes
            this.SetRootNode(temp);
        }
        public KnuBotFlappy(Identity identity)
            : base(identity)
        {
            KnuBotDialogTree temp = new KnuBotDialogTree(
                "0",
                this.TreeCondition0,
                new[]
                {
                    // This is the main dialog (send text in here)
                    this.CAS(this.StartDialog, "self"),
                    // This will be called on the first option
                    this.CAS(this.Option0_1, "01"),
                    // this will be called on the second option
                    this.CAS(this.Option0_2, "02")
                });

            // SetRootNode needs to be done after building the first node, so AddNode can put in neccesary information in subsequent nodes
            this.SetRootNode(temp);

            temp.AddNode(
                new KnuBotDialogTree(
                    "01",
                    this.TreeCondition01,
                    new[]
                    {
                        // This is the main dialog (send text in here)
                        this.CAS(this.Dialog1, "self"),
                        // This will be called on the first option
                        this.CAS(this.Option01_1, "root"),
                        // this will be called on the second option
                        this.CAS(this.Option01_2, "self")
                    }));
            temp.AddNode(
                new KnuBotDialogTree(
                    "02",
                    this.TreeCondition02,
                    new[]
                    {
                        // This sends only back to the root node
                        this.CAS(this.Dialog02, "root")
                    }));
        }
 public static void SpawnEmptyVendorFromTemplate(StatelData statelData, IPlayfield playfield, int instance)
 {
     Identity pfIdentity = new Identity() { Type = IdentityType.Playfield, Instance = statelData.PlayfieldId };
     Identity freeIdentity = new Identity()
                             {
                                 Type = IdentityType.VendingMachine,
                                 Instance =
                                     Pool.Instance.GetFreeInstance<Vendor>(
                                         0x70000000,
                                         IdentityType.VendingMachine)
                             };
     Vendor v = new Vendor(pfIdentity, freeIdentity, statelData.TemplateId);
     v.OriginalIdentity = statelData.Identity;
     v.RawCoordinates = new Vector3(statelData.X, statelData.Y, statelData.Z);
     v.Heading = new Quaternion(
         statelData.HeadingX,
         statelData.HeadingY,
         statelData.HeadingZ,
         statelData.HeadingW);
     v.Playfield = playfield;
 }
Exemple #21
0
        /// <summary>
        /// </summary>
        /// <returns>
        /// </returns>
        public int CreatePlayfields()
        {
            foreach (PlayfieldInfo playfieldInfo in Playfields.Instance.playfields)
            {
                if (!playfieldInfo.disabled)
                {
                    Identity identity = new Identity();
                    identity.Type = IdentityType.Playfield;
                    identity.Instance = playfieldInfo.id;
                    IPlayfield playfield = this.CreatePlayfield(identity);

                    foreach (DistrictInfo districtInfo in playfieldInfo.districts)
                    {
                        PlayfieldDistrict playfieldDistrict = new PlayfieldDistrict();
                        playfieldDistrict.Name = districtInfo.districtName;
                        playfieldDistrict.MinLevel = districtInfo.minLevel;
                        playfieldDistrict.MaxLevel = districtInfo.maxLevel;
                        playfieldDistrict.SuppressionGas = districtInfo.suppressionGas;
                        playfield.Districts.Add(playfieldDistrict);
                    }

                    playfield.X = playfieldInfo.x;
                    playfield.Z = playfieldInfo.z;
                    playfield.XScale = playfieldInfo.xscale;
                    playfield.ZScale = playfieldInfo.zscale;
                    playfield.Expansion = (Expansions)playfieldInfo.expansion;
                    this.playfields.Add(playfield);
                    PlayfieldWorkerHolder playfieldWorkerHolder = new PlayfieldWorkerHolder();
                    playfieldWorkerHolder.PlayfieldWorker.SetPlayfield(playfield);
                    Thread thread = new Thread(playfieldWorkerHolder.PlayfieldWorker.DoWork);
                    thread.Name = "PF" + playfield.Identity.Instance.ToString();
                    playfieldWorkerHolder.thread = thread;
                    thread.Start();
                    this.workers.Add(playfieldWorkerHolder);
                    while (!thread.IsAlive)
                    {
                        ;
                    }
                }
            }

            return this.playfields.Count;
        }
 /// <summary>
 /// </summary>
 /// <param name="character">
 /// </param>
 /// <param name="destination">
 /// </param>
 /// <param name="heading">
 /// </param>
 /// <param name="playfield">
 /// </param>
 public static void Send(ICharacter character, Coordinate destination, IQuaternion heading, Identity playfield)
 {
     // This needs to be sent immediately!
     character.Client.SendCompressed(Create(character, destination, heading, playfield));
 }
Exemple #23
0
        /// <summary>
        /// </summary>
        /// <param name="identity">
        /// </param>
        /// <returns>
        /// </returns>
        public bool InPlayfield(Identity identity)
        {
            bool result = false;
            if (this.Playfield != null)
            {
                result = this.Playfield.Identity == identity;
            }

            return result;
        }
Exemple #24
0
        /// <summary>
        /// </summary>
        /// <param name="id">
        /// </param>
        public Dynel(Identity parent, Identity id)
            : base(parent, id)
        {
            this.Starting = true;
            this.DoNotDoTimers = true;

            this.Stats = new Stats(this.Identity);
            this.InitializeStats();

            // The subclasses will initialize their own BaseInventory
            // this.BaseInventory = new UnitInventory(this, pooledIn);

            this.Starting = false;
        }
        private static Character CreateMob(
            DBMobTemplate mob,
            Identity playfieldIdentity,
            Coordinate coord,
            Quaternion heading,
            IController controller,
            int level)
        {
            IPlayfield playfield = Pool.Instance.GetObject<IPlayfield>(Identity.None, playfieldIdentity);
            if (playfield != null)
            {
                int newInstanceId = Pool.Instance.GetFreeInstance<Character>(1000000, IdentityType.CanbeAffected);
                Identity newIdentity = new Identity() { Type = IdentityType.CanbeAffected, Instance = newInstanceId };
                Character mobCharacter = new Character(playfield.Identity, newIdentity, controller);
                mobCharacter.Read();
                mobCharacter.Coordinates(coord);
                mobCharacter.Playfield = Pool.Instance.GetObject<IPlayfield>(Identity.None, playfieldIdentity);
                mobCharacter.RawHeading = new Quaternion(heading.xf, heading.yf, heading.zf, heading.wf);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.life, (uint)mob.Health);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.level, (uint)level);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.npcfamily, (uint)mob.NPCFamily);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.side, (uint)mob.Side);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.fatness, (uint)mob.Fatness);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.breed, (uint)mob.Breed);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.sex, (uint)mob.Sex);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.race, (uint)mob.Race);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.flags, (uint)mob.Flags);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.monsterdata, (uint)mob.MonsterData);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.monsterscale, (uint)mob.MonsterScale);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.profession, 15);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.accountflags, 0);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.expansion, 0);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.runspeed, 513);
                mobCharacter.Stats[StatIds.headmesh].BaseValue = (uint)mob.HeadMesh;
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.losheight, 15);
                mobCharacter.Stats.SetBaseValueWithoutTriggering((int)StatIds.visualprofession, 15);

                /*
                // For testing only, blue trousers and a helmet
                IItem trousers = new Item(1, ItemLoader.ItemList[27350].GetLowId(1),ItemLoader.ItemList[27350].GetLowId(1));
                IItem helmet = new Item(1, ItemLoader.ItemList[85534].GetLowId(1), ItemLoader.ItemList[85534].GetHighId(1));
                mobCharacter.BaseInventory.Pages[(int)IdentityType.ArmorPage].Add((int)ArmorSlots.Legs + mobCharacter.BaseInventory.Pages[(int)IdentityType.ArmorPage].FirstSlotNumber, trousers);
                mobCharacter.BaseInventory.Pages[(int)IdentityType.ArmorPage].Add((int)ArmorSlots.Head + mobCharacter.BaseInventory.Pages[(int)IdentityType.ArmorPage].FirstSlotNumber, helmet);
                */

                // Set the MeshLayers correctly ( Head mesh!! )  /!\
                // TODO: This needs to be in StatHeadmesh.cs (somehow)
                mobCharacter.MeshLayer.AddMesh(0, mob.HeadMesh, 0, 4);
                mobCharacter.SocialMeshLayer.AddMesh(0, mob.HeadMesh, 0, 4);

                mobCharacter.Name = mob.Name;
                mobCharacter.FirstName = "";
                mobCharacter.LastName = "";
                controller.Character = mobCharacter;
                return mobCharacter;
            }
            return null;
        }
Exemple #26
0
 public Player(Identity remoteId, string name)
 {
     Contract.Requires<ArgumentNullException>(name != null);
     this.remoteId = remoteId;
     this.name = name;
 }
Exemple #27
0
 /// <summary>
 /// </summary>
 /// <param name="destination">
 /// </param>
 /// <param name="heading">
 /// </param>
 /// <param name="playfield">
 /// </param>
 public void Teleport(Coordinate destination, IQuaternion heading, Identity playfield)
 {
     this.IsTeleporting = false;
     this.Playfield.Teleport(this, destination, heading, playfield);
 }
Exemple #28
0
 /// <summary>
 /// </summary>
 /// <param name="playfieldIdentity">
 /// </param>
 /// <returns>
 /// </returns>
 protected IPlayfield CreatePlayfield(Identity playfieldIdentity)
 {
     return new Playfield(playfieldIdentity);
 }
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            // Fallback to self if no target is selected
            if (target.Instance == 0)
            {
                target = character.Identity;
            }

            if (target.Type != IdentityType.CanbeAffected)
            {
                character.Playfield.Publish(ChatText.CreateIM(character, "Target must be player/monster/NPC"));
                return;
            }

            Dynel targetDynel = (Dynel)character.Playfield.FindByIdentity(target);
            if (targetDynel != null)
            {
                Character targetCharacter = (Character)targetDynel;

                // May be obsolete in the future, let it stay in comment yet
                // ch.CalculateSkills();

                // Check for numbers too, not only for names
                int statId;
                if (!int.TryParse(args[1], out statId))
                {
                    try
                    {
                        statId = StatNamesDefaults.GetStatNumber(args[1]);
                    }
                    catch (Exception)
                    {
                        statId = 1234567890;
                    }
                }

                if (statId == 1234567890)
                {
                    character.Playfield.Publish(ChatText.CreateIM(character, "Unknown Stat name " + args[1]));
                    return;
                }

                uint statValue;
                int effectiveValue;
                int trickle;
                int mod;
                int perc;
                try
                {
                    statValue = targetCharacter.Stats[statId].BaseValue;
                    effectiveValue = targetCharacter.Stats[statId].Value;
                    trickle = targetCharacter.Stats[statId].Trickle;
                    mod = targetCharacter.Stats[statId].Modifier;
                    perc = targetCharacter.Stats[statId].PercentageModifier;
                }
                catch (StatDoesNotExistException)
                {
                    character.Playfield.Publish(ChatText.CreateIM(character, "Unknown Stat Id " + statId));
                    return;
                }

                string response = "Character " + targetCharacter.Name + " (" + targetCharacter.Identity.Instance
                                  + "): Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = "
                                  + statValue;

                if (statValue != targetCharacter.Stats[statId].Value)
                {
                    response += "\r\nEffective value Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId
                                + ") = " + effectiveValue;
                }

                response += "\r\nTrickle: " + trickle + " Modificator: " + mod + " Percentage: " + perc;
                character.Playfield.Publish(ChatText.CreateIM(character, response));
            }
            else
            {
                // Shouldnt be happen again (fallback to self)
                character.Playfield.Publish(ChatText.CreateIM(character, "Unable to find target."));
            }
        }
        public static Character SpawnMobFromTemplate(
            string hash,
            Identity playfieldIdentity,
            Coordinate coord,
            Quaternion heading,
            IController controller,
            int desiredLevel = -1)
        {
            Character mobCharacter = null;

            DBMobTemplate mob = MobTemplateDao.Instance.GetMobTemplateByHash(hash);
            if (mob != null)
            {
                int level = desiredLevel;
                if (level == -1)
                {
                    // Get random inside level range
                    Random rnd = new Random();
                    level = mob.MinLvl + rnd.Next(mob.MaxLvl - mob.MinLvl);
                }
                else
                {
                    // Put it inside level range
                    level = (level < mob.MinLvl ? mob.MinLvl : level);
                    level = level > mob.MaxLvl ? mob.MaxLvl : level;
                }
                mobCharacter = CreateMob(mob, playfieldIdentity, coord, heading, controller, level);
            }
            return mobCharacter;
        }