Пример #1
0
        public void Run(NWObject target, params object[] args)
        {
            int             roll        = RandomService.Random(0, 100);
            ResourceQuality quality     = ResourceQuality.Low;
            string          qualityName = "Low Quality";

            const int NormalQualityChance   = 20;
            const int HighQualityChance     = 10;
            const int VeryHighQualityChance = 2;

            var dbArea  = DataService.Single <Area>(x => x.Resref == target.Area.Resref);
            int tier    = dbArea.ResourceQuality;
            int maxTier = dbArea.MaxResourceQuality;

            if (tier <= 0)
            {
                Console.WriteLine("WARNING: Area '" + target.Area.Name + "' has resources but the RESOURCE_QUALITY variable is not set. Edit the area properties and add this value to set up resources.");
                return;
            }

            if (roll <= VeryHighQualityChance)
            {
                quality     = ResourceQuality.VeryHigh;
                qualityName = "Very High Quality";
            }
            else if (roll <= HighQualityChance)
            {
                quality     = ResourceQuality.High;
                qualityName = "High Quality";
            }
            else if (roll <= NormalQualityChance)
            {
                quality     = ResourceQuality.Normal;
                qualityName = "Normal Quality";
            }


            roll = RandomService.Random(0, 100);
            if (roll <= 2)
            {
                tier++;
            }

            if (tier > 10)
            {
                tier = 10;
            }

            if (tier > maxTier)
            {
                tier = maxTier;
            }

            target.SetLocalInt("RESOURCE_QUALITY", (int)quality);
            target.SetLocalInt("RESOURCE_TIER", tier);
            target.SetLocalInt("RESOURCE_COUNT", RandomService.Random(3, 10));
            target.SetLocalString("RESOURCE_RESREF", GetResourceResref(tier));
            target.SetLocalString("RESOURCE_QUALITY_NAME", qualityName);
        }
        public void CopyVariables(NWObject oSource, NWObject oCopy)
        {
            int variableCount = _nwnxObject.GetLocalVariableCount(oSource);

            for (int variableIndex = 0; variableIndex < variableCount - 1; variableIndex++)
            {
                LocalVariable stCurVar = _nwnxObject.GetLocalVariable(oSource, variableIndex);

                switch (stCurVar.Type)
                {
                case LocalVariableType.Int:
                    oCopy.SetLocalInt(stCurVar.Key, oSource.GetLocalInt(stCurVar.Key));
                    break;

                case LocalVariableType.Float:
                    oCopy.SetLocalFloat(stCurVar.Key, oSource.GetLocalFloat(stCurVar.Key));
                    break;

                case LocalVariableType.String:
                    oCopy.SetLocalString(stCurVar.Key, oSource.GetLocalString(stCurVar.Key));
                    break;

                case LocalVariableType.Object:
                    oCopy.SetLocalObject(stCurVar.Key, oSource.GetLocalObject(stCurVar.Key));
                    break;

                case LocalVariableType.Location:
                    oCopy.SetLocalLocation(stCurVar.Key, oSource.GetLocalLocation(stCurVar.Key));
                    break;
                }
            }
        }
Пример #3
0
        public bool OnModuleExamine(NWPlayer examiner, NWObject target)
        {
            string backupDescription = target.GetLocalString("BACKUP_DESCRIPTION");

            if (!string.IsNullOrWhiteSpace(backupDescription))
            {
                target.UnidentifiedDescription = backupDescription;
            }

            if (!examiner.IsDM || !target.IsPlayer || target.IsDM)
            {
                return(false);
            }

            backupDescription = target.IdentifiedDescription;
            target.SetLocalString("BACKUP_DESCRIPTION", backupDescription);

            Player playerEntity    = _data.Single <Player>(x => x.ID == target.GlobalID);
            NWArea area            = NWModule.Get().Areas.Single(x => x.Resref == playerEntity.RespawnAreaResref);
            string respawnAreaName = area.Name;

            StringBuilder description =
                new StringBuilder(
                    _color.Green("ID: ") + target.GlobalID + "\n" +
                    _color.Green("Character Name: ") + target.Name + "\n" +
                    _color.Green("Respawn Area: ") + respawnAreaName + "\n" +
                    _color.Green("Skill Points: ") + playerEntity.TotalSPAcquired + " (Unallocated: " + playerEntity.UnallocatedSP + ")" + "\n" +
                    _color.Green("FP: ") + playerEntity.CurrentFP + " / " + playerEntity.MaxFP + "\n" +
                    _color.Green("Skill Levels: ") + "\n\n");

            List <PCSkill> pcSkills = _skill.GetAllPCSkills(target.Object);

            foreach (PCSkill pcSkill in pcSkills)
            {
                Skill skill = _skill.GetSkill(pcSkill.SkillID);
                description.Append(skill.Name).Append(" rank ").Append(pcSkill.Rank).AppendLine();
            }

            description.Append("\n\n").Append(_color.Green("Perks: ")).Append("\n\n");

            var pcPerks = _data.Where <PCPerk>(x => x.PlayerID == target.GlobalID);

            foreach (PCPerk pcPerk in pcPerks)
            {
                var perk = _data.Get <Data.Entity.Perk>(pcPerk.PerkID);
                description.Append(perk.Name).Append(" Lvl. ").Append(pcPerk.PerkLevel).AppendLine();
            }

            description.Append("\n\n").Append(_color.Green("Description: \n\n")).Append(backupDescription).AppendLine();
            target.UnidentifiedDescription = description.ToString();

            return(true);
        }
        public bool OnModuleExamine(NWPlayer examiner, NWObject target)
        {
            string backupDescription = target.GetLocalString("BACKUP_DESCRIPTION");

            if (!string.IsNullOrWhiteSpace(backupDescription))
            {
                target.UnidentifiedDescription = backupDescription;
            }

            if (!examiner.IsDM || !target.IsPlayer || target.IsDM)
            {
                return(false);
            }

            backupDescription = target.IdentifiedDescription;
            target.SetLocalString("BACKUP_DESCRIPTION", backupDescription);

            PlayerCharacter playerEntity    = _db.PlayerCharacters.Single(x => x.PlayerID == target.GlobalID);
            string          respawnAreaName = _.GetName(_.GetObjectByTag(playerEntity.RespawnAreaTag));

            StringBuilder description =
                new StringBuilder(
                    _color.Green("ID: ") + target.GlobalID + "\n" +
                    _color.Green("Character Name: ") + target.Name + "\n" +
                    _color.Green("Respawn Area: ") + respawnAreaName + "\n" +
                    _color.Green("Skill Points: ") + playerEntity.TotalSPAcquired + " (Unallocated: " + playerEntity.UnallocatedSP + ")" + "\n" +
                    _color.Green("Nourishment: ") + playerEntity.CurrentHunger + " / " + playerEntity.MaxHunger + "\n" +
                    _color.Green("Mana: ") + playerEntity.CurrentMana + " / " + playerEntity.MaxMana + "\n" +
                    _color.Green("Skill Levels: ") + "\n\n");

            List <PCSkill> pcSkills = _db.PCSkills.Where(x => x.PlayerID == target.GlobalID && x.Skill.IsActive).ToList();

            foreach (PCSkill skill in pcSkills)
            {
                description.Append(skill.Skill.Name).Append(" rank ").Append(skill.Rank).AppendLine();
            }

            description.Append("\n\n").Append(_color.Green("Perks: ")).Append("\n\n");

            List <PCPerkHeader> pcPerks = _db.StoredProcedure <PCPerkHeader>("GetPCPerksForMenuHeader",
                                                                             new SqlParameter("PlayerID", target.GlobalID));

            foreach (PCPerkHeader perk in pcPerks)
            {
                description.Append(perk.Name).Append(" Lvl. ").Append(perk.Level).AppendLine();
            }

            description.Append("\n\n").Append(_color.Green("Description: \n\n")).Append(backupDescription).AppendLine();
            target.UnidentifiedDescription = description.ToString();

            return(true);
        }
Пример #5
0
        private static void OnStoreClosed()
        {
            NWObject store            = Object.OBJECT_SELF;
            int      playersAccessing = store.GetLocalInt("STORE_SERVICE_PLAYERS_ACCESSING") - 1;

            if (playersAccessing <= 0)
            {
                playersAccessing = 0;
                // We don't want to immediately clean it,
                // to give players a grace period to come back and buy back something they mistakenly sold.
                // So we'll track the current timestamp and later check it on the heartbeat event.
                DateTime now       = DateTime.UtcNow;
                string   nowString = now.ToString(CultureInfo.InvariantCulture);
                store.SetLocalString("STORE_SERVICE_LAST_CLOSE_DATE", nowString);
            }
            store.SetLocalInt("STORE_SERVICE_PLAYERS_ACCESSING", playersAccessing);
        }
Пример #6
0
        public void Run(NWObject target, params object[] args)
        {
            int             roll        = RandomService.Random(0, 100);
            ResourceQuality quality     = ResourceQuality.Low;
            string          qualityName = "Low Quality";

            var dbArea  = DataService.Area.GetByResref(target.Area.Resref);
            int tier    = dbArea.ResourceQuality;
            int maxTier = dbArea.MaxResourceQuality;

            if (tier <= 0)
            {
                Console.WriteLine("WARNING: Area '" + target.Area.Name + "' has resources but the RESOURCE_QUALITY variable is not set. Edit the area properties and add this value to set up resources.");
                return;
            }


            int NormalQualityChance;
            int HighQualityChance;
            int VeryHighQualityChance;

            switch (tier)
            {
            case 1:
                NormalQualityChance   = 20;
                HighQualityChance     = 0;
                VeryHighQualityChance = 0;
                break;

            case 2:
                NormalQualityChance   = 20;
                HighQualityChance     = 2;
                VeryHighQualityChance = 0;
                break;

            case 3:
            case 4:
            case 5:
                NormalQualityChance   = 20;
                HighQualityChance     = 2;
                VeryHighQualityChance = 1;
                break;

            case 6:
            case 7:
            case 8:
                NormalQualityChance   = 20;
                HighQualityChance     = 10;
                VeryHighQualityChance = 3;
                break;

            case 9:
            case 10:
                NormalQualityChance   = 20;
                HighQualityChance     = 12;
                VeryHighQualityChance = 5;
                break;

            default:
                NormalQualityChance   = 0;
                HighQualityChance     = 0;
                VeryHighQualityChance = 0;
                break;
            }


            if (roll <= VeryHighQualityChance)
            {
                quality     = ResourceQuality.VeryHigh;
                qualityName = "Very High Quality";
            }
            else if (roll <= HighQualityChance)
            {
                quality     = ResourceQuality.High;
                qualityName = "High Quality";
            }
            else if (roll <= NormalQualityChance)
            {
                quality     = ResourceQuality.Normal;
                qualityName = "Normal Quality";
            }

            roll = RandomService.Random(0, 100);
            if (roll <= 3)
            {
                tier++;
            }

            if (tier > 10)
            {
                tier = 10;
            }

            if (tier > maxTier)
            {
                tier = maxTier;
            }

            target.SetLocalInt("RESOURCE_QUALITY", (int)quality);
            target.SetLocalInt("RESOURCE_TIER", tier);
            target.SetLocalInt("RESOURCE_COUNT", RandomService.Random(3, 10));
            target.SetLocalString("RESOURCE_RESREF", GetResourceResref(tier));
            target.SetLocalString("RESOURCE_QUALITY_NAME", qualityName);
        }
Пример #7
0
        public void Run(NWObject target, params object[] args)
        {
            int             roll        = _random.Random(0, 100);
            ResourceQuality quality     = ResourceQuality.Low;
            string          qualityName = "Sparse";

            const int NormalQualityChance   = 20;
            const int HighQualityChance     = 10;
            const int VeryHighQualityChance = 2;

            var dbArea  = _data.Single <Area>(x => x.Resref == target.Area.Resref);
            int tier    = dbArea.ResourceQuality;
            int maxTier = dbArea.MaxResourceQuality;

            if (tier <= 0)
            {
                Console.WriteLine("WARNING: Area '" + target.Area.Name + "' has resources but the RESOURCE_QUALITY variable is not set. Edit the area properties and add this value to set up resources.");
                return;
            }

            if (roll <= VeryHighQualityChance)
            {
                quality     = ResourceQuality.VeryHigh;
                qualityName = "Very Dense";
            }
            else if (roll <= HighQualityChance)
            {
                quality     = ResourceQuality.High;
                qualityName = "Dense";
            }
            else if (roll <= NormalQualityChance)
            {
                quality     = ResourceQuality.Normal;
                qualityName = "Thick";
            }

            roll = _random.Random(0, 100);
            if (roll <= 3)
            {
                tier++;
            }

            if (tier > 10)
            {
                tier = 10;
            }

            if (tier > maxTier)
            {
                tier = maxTier;
            }

            string resref   = GetResourceResref(tier);
            int    quantity = _random.Random(3, 10);

            roll = _random.Random(0, 100);

            if (roll <= 2)
            {
                string[] coloredResrefs = { "p_crystal_red", "p_crystal_green", "p_crystal_blue", "p_crystal_yellow" };

                roll   = _random.Random(0, 3);
                resref = coloredResrefs[roll];
            }

            target.SetLocalInt("RESOURCE_QUALITY", (int)quality);
            target.SetLocalInt("RESOURCE_TIER", tier);
            target.SetLocalInt("RESOURCE_COUNT", quantity);
            target.SetLocalString("RESOURCE_RESREF", resref);
            target.SetLocalString("RESOURCE_QUALITY_NAME", qualityName);
        }