public static int GetAutoCreatedNPCID(EntityLists.Entity entity)
        {
            foreach (Tuple <EntityLists.Entity, string, int> tuple in AutoCreatedNPCDictionary.Keys)
            {
                if (tuple.Item1 == entity)
                {
                    return(AutoCreatedNPCDictionary[tuple].npcID);
                }
            }

            return(-1);
        }
        public static int GetAutoCreatedNPCID(string identifier)
        {
            EntityLists.Entity entity = EntityLists.Entity.None;

            if (!Enum.TryParse <EntityLists.Entity>(identifier, true, out entity))
            {
                foreach (Tuple <EntityLists.Entity, string, int> tuple in AutoCreatedNPCDictionary.Keys)
                {
                    if (tuple.Item2 == identifier)
                    {
                        return(AutoCreatedNPCDictionary[tuple].npcID);
                    }
                }
            }
            else
            {
                return(GetAutoCreatedNPCID(entity));
            }

            return(-1);
        }
        public bool OnCast(Character caster, string args)
        {
            // There is no power level to this spell. Only one demon may be controlled, and if the caster has
            // any pets the spell will flail. The demon will be very powerful, this it's why it is a skill 17 spell.

            // First gather a list of unnamed demons.

            if (caster.Pets != null && caster.Pets.Count > 0 && (caster is PC) && (caster as PC).ImpLevel < Globals.eImpLevel.DEVJR)
            {
                caster.WriteToDisplay("Summoning a demon requires your full concentration.");
                return(false);
            }

            List <EntityLists.Entity> availableDemons = new List <EntityLists.Entity>();

            foreach (EntityLists.Entity entity in EntityLists.DEMONS)
            {
                if (!EntityLists.NAMED_DEMONS.Contains(entity))
                {
                    availableDemons.Add(entity);
                }
            }

            NPC demon = NPC.LoadNPC(Item.ID_SUMMONEDMOB, caster.FacetID, caster.LandID, caster.MapID, caster.X, caster.Y, caster.Z, -1);

            EntityLists.Entity chosenDemon = availableDemons[Rules.Dice.Next(availableDemons.Count)];

            EntityBuilder builder = new EntityBuilder();

            demon.Level  = caster.Level + Rules.RollD(3, 4);
            demon.entity = chosenDemon;
            List <Character.ClassType> allowedProfessions = new List <Character.ClassType>
            {
                Character.ClassType.Fighter,
                Character.ClassType.Ravager,
                //Character.ClassType.Sorcerer,
                //Character.ClassType.Thaumaturge,
                Character.ClassType.Thief,
                Character.ClassType.Wizard,
            };

            demon.BaseProfession = allowedProfessions[Rules.Dice.Next(0, allowedProfessions.Count - 1)];

            builder.SetOnTheFlyVariables(demon);
            EntityBuilder.SetVisualKey(demon.entity, demon);
            builder.SetName(demon, demon.BaseProfession.ToString().ToLower());
            builder.SetDescriptions("summoned", demon, caster.Map.ZPlanes[caster.Z], demon.BaseProfession.ToString().ToLower());
            EntityBuilder.SetGender(demon, caster.Map.ZPlanes[caster.Z]);
            EntityBuilder.SetVisualKey(demon.entity, demon);

            if (demon.IsSpellUser)
            {
                NPC.CreateGenericSpellList(demon);
                GameSpell.FillSpellLists(demon);
            }

            if (EntityLists.IsHumanOrHumanoid(demon))
            {
                demon.wearing.Clear();

                List <int> armorToWear = Autonomy.ItemBuilding.ArmorSets.ArmorSet.ArmorSetDictionary[Autonomy.ItemBuilding.ArmorSets.ArmorSet.FULL_STEEL].GetArmorList(demon);

                foreach (int id in armorToWear)
                {
                    Item armor = Item.CopyItemFromDictionary(id);
                    armor.special += " " + Item.EXTRAPLANAR;
                    demon.WearItem(armor);
                }
            }

            if (EntityLists.IsHumanOrHumanoid(demon) || EntityLists.ANIMALS_WIELDING_WEAPONS.Contains(demon.entity))
            {
                List <int> weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(demon, true);
                if (weaponsList.Count > 0)
                {
                    demon.EquipRightHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)]));
                }
                weaponsList = Autonomy.ItemBuilding.LootManager.GetBasicWeaponsFromArmory(demon, false);
                if (weaponsList.Count > 0)
                {
                    demon.EquipLeftHand(Item.CopyItemFromDictionary(weaponsList[Rules.Dice.Next(weaponsList.Count - 1)]));
                }

                if (demon.RightHand != null)
                {
                    demon.RightHand.special += " " + Item.EXTRAPLANAR;
                }
                if (demon.LeftHand != null)
                {
                    demon.LeftHand.special += " " + Item.EXTRAPLANAR;
                }
            }

            demon.castMode = NPC.CastMode.Limited;

            demon.Hits    = demon.HitsFull;
            demon.Mana    = demon.ManaFull;
            demon.Stamina = demon.StaminaFull;

            demon.Alignment = Globals.eAlignment.ChaoticEvil;
            demon.race      = "Hell";

            //demon.aiType = NPC.AIType.EmptySlot;
            demon.Age     = 0;
            demon.special = "despawn";
            int fiveMinutes = Utils.TimeSpanToRounds(new TimeSpan(0, 5, 0));

            // 5 minutes plus 1 minute per magic skill level
            demon.RoundsRemaining = fiveMinutes + Skills.GetSkillLevel(caster.magic) * Utils.TimeSpanToRounds(new TimeSpan(0, 1, 0));
            demon.species         = Globals.eSpecies.Demon; // this may need to be changed for AI to work properly
            demon.Alignment       = caster.Alignment;
            demon.canCommand      = true;
            demon.IsMobile        = true;
            demon.IsSummoned      = true;
            demon.IsUndead        = EntityLists.UNDEAD.Contains(demon.entity);

            demon.FollowID = caster.UniqueID;

            demon.PetOwner = caster;
            caster.Pets.Add(demon);

            if (demon.CurrentCell != caster.CurrentCell)
            {
                demon.CurrentCell = caster.CurrentCell;
            }

            demon.EmitSound(demon.idleSound);

            demon.AddToWorld();

            return(true);
        }
        public static bool BuildNewEntities(out int spawnZonesCount)
        {
            spawnZonesCount = 0;

            foreach (Facet facet in World.Facets)
            {
                foreach (Land land in facet.Lands)
                {
                    foreach (Map map in land.Maps)
                    {
                        foreach (ZPlane zPlane in map.ZPlanes.Values)
                        {
                            try
                            {
                                if (zPlane.zAutonomy != null && zPlane.zAutonomy.entities != null && zPlane.zAutonomy.entities.Length > 0)
                                {
                                    // name(class|class2),name,name,name(class|class|class)
                                    string[] critters = zPlane.zAutonomy.entities.Split(",".ToCharArray());

                                    List <Tuple <string, EntityLists.Entity, string> > creatureDescProfessionTuples = new List <Tuple <string, EntityLists.Entity, string> >();

                                    #region Create list of Tuples with EntityLists.Entity and profession or profession synonym string.
                                    foreach (string s in critters)
                                    {
                                        EntityLists.Entity cr = EntityLists.Entity.Alligator;

                                        string desc = "";

                                        // adjective(s) for descriptive, and other purposes
                                        if (s.StartsWith("["))
                                        {
                                            desc = s.Substring(s.IndexOf("[") + 1, s.IndexOf("]") - s.IndexOf("[") - 1);
                                        }

                                        string critterType = "";

                                        if (s.Contains("(")) // various professions
                                        {
                                            if (s.StartsWith("["))
                                            {
                                                critterType = s.Substring(s.IndexOf("]") + 1, s.IndexOf("(") - s.IndexOf("]") - 1);
                                            }
                                            else
                                            {
                                                critterType = s.Substring(0, s.IndexOf("("));
                                            }

                                            if (!Enum.TryParse(critterType, true, out cr))
                                            {
                                                Utils.Log("Error parsing CreatureLists.Creature (" + critterType + ") from zPlane: " + zPlane.ToString(), Utils.LogType.SystemWarning);
                                                continue;
                                            }

                                            string[] classesList = s.Substring(s.IndexOf("(") + 1, s.IndexOf(")") - s.IndexOf("(") - 1).Split("|".ToCharArray());

                                            foreach (string cl in classesList)
                                            {
                                                Tuple <string, EntityLists.Entity, string> tuple = Tuple.Create(desc, cr, cl);

                                                if (!creatureDescProfessionTuples.Contains(tuple))
                                                {
                                                    creatureDescProfessionTuples.Add(tuple);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (s.StartsWith("["))
                                            {
                                                critterType = s.Substring(s.IndexOf("]") + 1, s.Length - s.IndexOf("]") - 1);
                                            }
                                            else
                                            {
                                                critterType = s;
                                            }

                                            if (!Enum.TryParse(critterType, true, out cr))
                                            {
                                                Utils.Log("Error parsing CreatureLists.Creature ( " + critterType + " ) from zPlane: " + zPlane.ToString(), Utils.LogType.SystemWarning);
                                                continue;
                                            }

                                            Tuple <string, EntityLists.Entity, string> tuple = Tuple.Create(desc, cr, "Fighter");

                                            if (!creatureDescProfessionTuples.Contains(tuple))
                                            {
                                                creatureDescProfessionTuples.Add(tuple);
                                            }
                                        }
                                    }
                                    #endregion

                                    NPC        npc       = null;
                                    List <int> NPCIDList = new List <int>();
                                    List <int> WaterDwellingNPCIDList = new List <int>();
                                    Dictionary <int, Tuple <int, int> > SpawnGroupAmounts      = new Dictionary <int, Tuple <int, int> >();
                                    Dictionary <int, Tuple <int, int> > WaterSpawnGroupAmounts = new Dictionary <int, Tuple <int, int> >();

                                    foreach (Tuple <string, EntityLists.Entity, string> tuple in creatureDescProfessionTuples)
                                    {
                                        npc = null;

                                        #region Check if an entity/profession, in the same level range, has already been built. If so, choose it for the SpawnZone.
                                        foreach (Tuple <EntityLists.Entity, string, int> createdNPC in AutoCreatedNPCDictionary.Keys)
                                        {
                                            // if an Entity/profession pair has already been created, check level and use if within range.
                                            if (createdNPC.Item1 == tuple.Item2 && createdNPC.Item2 == tuple.Item3 && AutoCreatedNPCDictionary[createdNPC].shortDesc.Contains(tuple.Item1))
                                            {
                                                if (AutoCreatedNPCDictionary[createdNPC].Level >= zPlane.zAutonomy.minimumSuggestedLevel &&
                                                    AutoCreatedNPCDictionary[createdNPC].Level <= zPlane.zAutonomy.maximumSuggestedLevel)
                                                {
                                                    npc = AutoCreatedNPCDictionary[createdNPC].CloneNPC();
                                                    break;
                                                }
                                            }
                                        }
                                        #endregion

                                        if (npc == null)
                                        {
                                            if (EntityLists.IsMerchant(tuple.Item2))
                                            {
                                                npc = new Merchant();

                                                if (EntityLists.TRAINER_SPELLS.Contains(tuple.Item2))
                                                {
                                                    (npc as Merchant).trainerType = Merchant.TrainerType.Spell;
                                                }
                                                else if (EntityLists.TRAINER_ANIMAL.Contains(tuple.Item2))
                                                {
                                                    (npc as Merchant).trainerType = Merchant.TrainerType.Animal;
                                                }

                                                if (EntityLists.MENTOR.Contains(tuple.Item2))
                                                {
                                                    (npc as Merchant).interactiveType = Merchant.InteractiveType.Mentor;
                                                }

                                                if (!EntityLists.MOBILE.Contains(tuple.Item2))
                                                {
                                                    npc.IsMobile = false;
                                                }
                                            }
                                            else
                                            {
                                                npc = new NPC();
                                            }

                                            EntityBuilder builder = new EntityBuilder();

                                            if (!builder.BuildEntity(tuple.Item1, tuple.Item2, npc, zPlane, tuple.Item3))
                                            {
                                                // Log an issue with building a new entity, move on to next.
                                                Utils.Log("Failed to build entity: " + tuple.Item1.ToString() + ", " + tuple.Item2.ToString() + " ZPlane: " + zPlane.ToString(), Utils.LogType.SystemWarning);
                                                continue;
                                            }
                                            else
                                            {
                                                // Built a new entity (NPC), add it to the dictionary.
                                                AutoCreatedNPCDictionary.Add(Tuple.Create(tuple.Item2, tuple.Item3, npc.npcID), npc);
                                            }
                                        }

                                        if (npc != null)
                                        {
                                            if (!NPCIDList.Contains(npc.npcID))
                                            {
                                                if (!npc.IsWaterDweller)
                                                {
                                                    NPCIDList.Add(npc.npcID);
                                                }
                                                else
                                                {
                                                    WaterDwellingNPCIDList.Add(npc.npcID);
                                                }

                                                // Currently limiting social groups of spell warming professions to humans only.
                                                // Let's say other humanoid casters don't work well together as there is too much of a power struggle.
                                                // Maybe in the future there will be exceptions to this rule.
                                                if (EntityLists.SOCIAL.Contains(tuple.Item2) && ((npc.IsSpellWarmingProfession && EntityLists.HUMAN.Contains(tuple.Item2)) || !npc.IsSpellWarmingProfession) &&
                                                    !SpawnGroupAmounts.ContainsKey(npc.npcID))
                                                {
                                                    int low  = 2;
                                                    int high = 4;

                                                    // Animals typically have more members in a group.
                                                    if (EntityLists.ANIMAL.Contains(tuple.Item2))
                                                    {
                                                        high += Rules.Dice.Next(0, Rules.RollD(1, 2));
                                                    }

                                                    // Humanoids and humans have a chance to be alone.
                                                    if (EntityLists.IsHumanOrHumanoid(npc) && Rules.RollD(1, 100) < 15)
                                                    {
                                                        low  = 1;
                                                        high = 2;
                                                    }

                                                    if (!npc.IsWaterDweller)
                                                    {
                                                        SpawnGroupAmounts.Add(npc.npcID, Tuple.Create(low, high));
                                                    }
                                                    else
                                                    {
                                                        WaterSpawnGroupAmounts.Add(npc.npcID, Tuple.Create(low, high));
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                Utils.Log("NPC ID already exists in SpawnZone NPCIDList in BuildNewEntities(). NPC: " + npc.GetLogString() + " ZPlane: " + zPlane.ToString(), Utils.LogType.SystemWarning);
                                            }
                                        }
                                    }

                                    if (NPCIDList.Count > 0)
                                    {
                                        SpawnZone szl = new SpawnZone(facet, NPCIDList[0], NPCIDList, SpawnGroupAmounts, land.LandID, map.MapID, zPlane.zCord, false);
                                        facet.Add(szl);
                                        if (!SpawnZone.Spawns.ContainsKey(szl.ZoneID))
                                        {
                                            SpawnZone.Spawns.Add(szl.ZoneID, szl);
                                        }
                                        spawnZonesCount++;
                                    }
                                    else if (WaterDwellingNPCIDList.Count > 0)
                                    {
                                        SpawnZone szl = new SpawnZone(facet, WaterDwellingNPCIDList[0], NPCIDList, SpawnGroupAmounts, land.LandID, map.MapID, zPlane.zCord, true);
                                        facet.Add(szl);
                                        if (!SpawnZone.Spawns.ContainsKey(szl.ZoneID))
                                        {
                                            SpawnZone.Spawns.Add(szl.ZoneID, szl);
                                        }
                                        spawnZonesCount++;
                                    }
                                }

                                if (zPlane.zAutonomy != null && zPlane.zAutonomy.uniqueEntities.Count > 0)
                                {
                                    EntityBuilder builder = new EntityBuilder();

                                    foreach (ZUniqueEntity zUnique in zPlane.zAutonomy.uniqueEntities)
                                    {
                                        NPC npc;

                                        if (EntityLists.IsMerchant(zUnique.entity))
                                        {
                                            npc = new Merchant();

                                            if (EntityLists.TRAINER_SPELLS.Contains(zUnique.entity))
                                            {
                                                (npc as Merchant).trainerType = Merchant.TrainerType.Spell;
                                            }
                                            else if (EntityLists.TRAINER_ANIMAL.Contains(zUnique.entity))
                                            {
                                                (npc as Merchant).trainerType = Merchant.TrainerType.Animal;
                                            }

                                            if (EntityLists.MENTOR.Contains(zUnique.entity))
                                            {
                                                (npc as Merchant).interactiveType = Merchant.InteractiveType.Mentor;
                                            }

                                            if (!EntityLists.MOBILE.Contains(zUnique.entity))
                                            {
                                                npc.IsMobile = false;
                                            }
                                        }
                                        else
                                        {
                                            npc = new NPC();
                                        }

                                        npc.lairCritter = zUnique.hasLair;
                                        npc.lairCells   = zUnique.lairCells;

                                        if (!builder.BuildEntity(zUnique.description, zUnique.entity, npc, zPlane, zUnique.profession))
                                        {
                                            // Log an issue with building a new unique entity, move on to next.
                                            Utils.Log("Failed to build unique entity: " + zUnique.description + ", " + zUnique.entity + " ZPlane: " + zPlane.ToString(), Utils.LogType.SystemWarning);
                                            continue;
                                        }
                                        else
                                        {
                                            // Built a new unique entity (NPC), add it to the dictionary.
                                            AutoCreatedNPCDictionary.Add(Tuple.Create(zUnique.entity, zUnique.profession, npc.npcID), npc);
                                        }

                                        // add spawn zone
                                        SpawnZone szl = new SpawnZone(facet, zUnique, npc, land.LandID, map.MapID, zPlane.zCord, npc.IsWaterDweller);
                                        facet.Add(szl);
                                        if (!SpawnZone.Spawns.ContainsKey(szl.ZoneID))
                                        {
                                            SpawnZone.Spawns.Add(szl.ZoneID, szl);
                                        }
                                        spawnZonesCount++;
                                    }
                                }
                            }
                            catch (Exception e)
                            {
                                Utils.Log("EntityCreationManager.BuildNewEntities issue with map:" + map.Name + " zPlane:" + zPlane.name + ". Check autonomous tags and info.", Utils.LogType.ExceptionDetail);
                                Utils.LogException(e);
                            }
                        }
                    }
                }
            }

            return(true);
        }
Beispiel #5
0
        public ZUniqueEntity(EntityLists.Entity uniqueEntity, IEnumerable <XElement> elements)
        {
            entity = uniqueEntity;

            foreach (XElement elem in elements)
            {
                if (elem.Name == "x")
                {
                    this.xCord = Convert.ToInt32(elem.Value.ToString());
                }
                else if (elem.Name == "y")
                {
                    this.yCord = Convert.ToInt32(elem.Value.ToString());
                }
                else if (elem.Name == "spawnTimer")
                {
                    this.spawnTimer = Convert.ToInt32(elem.Value);
                }
                else if (elem.Name == "spawnMessage")
                {
                    this.spawnMessage = elem.Value.ToString();
                }
                else if (elem.Name == "description")
                {
                    this.description = elem.Value.ToString();
                }
                else if (elem.Name == "profession")
                {
                    this.profession = elem.Value.ToString();
                }
                else if (elem.Name == "spawnRadius")
                {
                    this.spawnRadius = Convert.ToInt32(elem.Value.ToString());
                }
                else if (elem.Name == "lairCells")
                {
                    this.hasLair   = true;
                    this.lairCells = elem.Value.ToString();
                }
                else if (elem.Name == "zRange")
                {
                    this.zRange = elem.Value.ToString();
                }
            }

            if (description == null)
            {
                description = "";
            }
            if (profession == null || profession == "")
            {
                profession = Character.ClassType.Fighter.ToString();
            }
            if (spawnMessage == null)
            {
                spawnMessage = "";
            }
            if (spawnTimer <= 0)
            {
                spawnTimer = 120;
            }
        }
Beispiel #6
0
        public bool OnCommand(Character chr, string args)
        {
            if (String.IsNullOrEmpty(args))
            {
                chr.WriteToDisplay(
                    "Format: impcreate [ entity <entity> <profession> <description> | npc <npc id> | item <item id> | coin <amount> | scroll <spell command> ]");
                return(true);
            }

            //if (chr == null)
            //    chr = new Character();

            try
            {
                var sArgs = args.Split(" ".ToCharArray());

                if (sArgs[0].ToLower().Equals("adventurer") || sArgs[0].ToLower().Equals("adv"))
                {
                    #region Adventurer
                    // impcreate adv0 level1 entity2 profession3

                    if (sArgs.Length < 2 || !int.TryParse(sArgs[1], out int level))
                    {
                        chr.WriteToDisplay("Format: impcreate adv [level]");
                        return(true);
                    }

                    EntityLists.Entity entity = EntityLists.Entity.Fighter;

                    if (sArgs.Length < 3 || !Enum.TryParse <EntityLists.Entity>(sArgs[2], true, out entity))
                    {
                        chr.WriteToDisplay("Unable to parse profession type. Used default of " + Utils.FormatEnumString(entity.ToString()));
                    }

                    string profession = sArgs.Length >= 4 ? sArgs[3] : Utils.FormatEnumString(entity.ToString());

                    EntityBuilder builder    = new EntityBuilder();
                    NPC           createdNPC = builder.BuildEntity("perplexed", entity, chr.Map.ZPlanes[chr.Z], profession);

                    var cloneList = DAL.DBWorld.GetScoresWithoutSP(createdNPC.BaseProfession, 40, true, "", false);

                    // quickly randomize the list
                    int    n   = cloneList.Count;
                    Random rnd = new Random();
                    while (n > 1)
                    {
                        int k = (rnd.Next(0, n) % n);
                        n--;
                        PC value = cloneList[k];
                        cloneList[k] = cloneList[n];
                        cloneList[n] = value;
                    }

                    foreach (PC clone in cloneList)
                    {
                        if (clone.Level == level && clone.ImpLevel == Globals.eImpLevel.USER)
                        {
                            Adventurer newAdventurer = new Adventurer(clone, createdNPC);

                            Utils.Log(newAdventurer.GetLogString() + " manually created from " + clone.GetLogString(), Utils.LogType.Adventurer);
                            chr.WriteToDisplay(newAdventurer.GetLogString() + " created from " + clone.GetLogString());

                            newAdventurer.SpawnZoneID = -1;
                            newAdventurer.CurrentCell = chr.CurrentCell;
                            newAdventurer.AddToWorld();
                            newAdventurer.RoundTimer.Start();
                            newAdventurer.ThirdRoundTimer.Start();

                            createdNPC.CurrentCell = null;
                            createdNPC.RemoveFromWorld();
                            return(true);
                        }
                    }
                    return(true);

                    #endregion
                }

                if (sArgs[0].ToLower().Equals("entity"))
                {
                    #region Entity
                    // sArgs[1] = entity
                    // sArgs[2] = profession
                    // sArgs[3] = description

                    EntityLists.Entity entity     = EntityLists.Entity.None;
                    string             desc       = "gigantic";
                    string             profession = "fighter";

                    if (sArgs.Length < 2 || !Enum.TryParse <EntityLists.Entity>(sArgs[1], true, out entity))
                    {
                        chr.WriteToDisplay("Entity does not exist.");
                        return(false);
                    }

                    if (sArgs.Length >= 3)
                    {
                        profession = sArgs[2];
                    }
                    if (sArgs.Length >= 4)
                    {
                        desc = sArgs[3];
                    }

                    EntityBuilder builder    = new EntityBuilder();
                    NPC           createdNPC = builder.BuildEntity(desc, entity, chr.Map.ZPlanes[chr.Z], profession);

                    if (createdNPC != null)
                    {
                        createdNPC.UniqueID = GameWorld.World.GetNextNPCUniqueID();

                        LootTable lootTable = LootManager.GetLootTable(createdNPC, chr.Map.ZPlanes[chr.Z]);
                        LootManager.GiveLootToNPC(createdNPC, lootTable);

                        createdNPC.CurrentCell = chr.CurrentCell;
                        createdNPC.AddToWorld();
                        createdNPC.RoundTimer.Start();
                        createdNPC.ThirdRoundTimer.Start();
                    }

                    return(true);

                    #endregion
                }

                if (sArgs[0].ToLower().Equals("item"))
                {
                    #region Item
                    var itemNum = Convert.ToInt32(sArgs[1]);
                    var item    = Item.CopyItemFromDictionary(itemNum);

                    if (item == null)
                    {
                        chr.WriteToDisplay("Item " + sArgs[1] + " not found in item catalog.");
                        return(false);
                    }

                    if (item.vRandLow > 0)
                    {
                        item.coinValue = Rules.Dice.Next(item.vRandLow, item.vRandHigh);
                    }
                    item.whoCreated = chr.GetLogString();
                    bool wasImmortal = chr.IsImmortal;
                    if (item.attuneType != Globals.eAttuneType.None)
                    {
                        chr.IsImmortal = true; // this is done to prevent binding the weapon to the dev creator
                    }
                    chr.EquipEitherHandOrDrop(item);
                    if (!wasImmortal)
                    {
                        chr.IsImmortal = false;
                    }
                    chr.WriteToDisplay(item.notes + " created.");
                    return(true);

                    #endregion
                }

                if (sArgs[0].ToLower().Equals("scroll"))
                {
                    #region Scroll
                    var scroll = ScrollManager.CreateSpellScroll(Spells.GameSpell.GetSpell(sArgs[1]));
                    scroll.whoCreated = chr.GetLogString();
                    chr.CurrentCell.Add(scroll);
                    chr.WriteToDisplay(scroll.notes + " created.");
                    return(true);

                    #endregion
                }

                if (sArgs[0].ToLower().Equals("npc"))
                {
                    #region NPC
                    try
                    {
                        NPC createdNPC = NPC.LoadNPC(Convert.ToInt32(sArgs[1]), chr.FacetID, chr.LandID, chr.MapID, chr.X, chr.Y, chr.Z, -1);
                        createdNPC.AddToWorld();
                        chr.WriteToDisplay("NPC created.");
                    }
                    catch
                    {
                        // sArgs[1] will be entity or profession
                        int entityID = EntityCreationManager.GetAutoCreatedNPCID(sArgs[1]);
                        if (entityID != -1)
                        {
                            NPC createdNPC = NPC.LoadNPC(Convert.ToInt32(sArgs[1]), chr.FacetID, chr.LandID, chr.MapID, chr.X, chr.Y, chr.Z, -1);
                            createdNPC.AddToWorld();
                            chr.WriteToDisplay("NPC created.");
                        }
                    }
                    return(true);

                    #endregion
                }

                if (sArgs[0].ToLower() == "coin" || sArgs[0].ToLower() == "coins")
                {
                    #region Coins
                    var coins = Item.CopyItemFromDictionary(Item.ID_COINS);

                    double amount;

                    if (!Double.TryParse(sArgs[1], out amount) || amount <= 0)
                    {
                        chr.WriteToDisplay("Invalid coin amount.");
                        return(false);
                    }

                    coins.coinValue = amount;
                    chr.CurrentCell.Add(coins);
                    chr.WriteToDisplay(amount + " coins created.");
                    return(true);

                    #endregion
                }
            }
            catch (Exception e)
            {
                Utils.LogException(e);
            }

            // failure to impcreate
            chr.WriteToDisplay(
                "Format: impcreate [ entity <entity> <profession> <description> | <npc <npc id> | item <item id> | coin <amount> | scroll <spell command> ]");

            return(false);
        }