Exemple #1
0
        public static void OnChestDisturbed(NWPlaceable oChest)
        {
            NWPlayer oPC = (_.GetLastDisturbed());

            if (!oPC.IsPlayer && !oPC.IsDM)
            {
                return;
            }

            string pcName      = oPC.Name;
            NWItem oItem       = (_.GetInventoryDisturbItem());
            int    disturbType = _.GetInventoryDisturbType();

            if (disturbType == _.INVENTORY_DISTURB_TYPE_ADDED)
            {
                _.CopyItem(oItem.Object, oPC.Object, _.TRUE);
                oItem.Destroy();
            }
            else if (disturbType == _.INVENTORY_DISTURB_TYPE_REMOVED)
            {
                SaveChestInventory(oPC, oChest, false);
                string itemName = oItem.Name;
                if (string.IsNullOrWhiteSpace(itemName))
                {
                    itemName = "money";
                }

                float minSearchSeconds = 1.5f;
                float maxSearchSeconds = 4.5f;
                float searchDelay      = RandomService.RandomFloat() * (maxSearchSeconds - minSearchSeconds) + minSearchSeconds;

                oPC.AssignCommand(() =>
                {
                    _.ActionPlayAnimation(_.ANIMATION_LOOPING_GET_LOW, 1.0f, searchDelay);
                });

                _.ApplyEffectToObject(_.DURATION_TYPE_TEMPORARY, _.EffectCutsceneImmobilize(), oPC.Object, searchDelay);

                // Notify party members in the vicinity

                NWPlayer player = (_.GetFirstPC());
                while (player.IsValid)
                {
                    if (_.GetDistanceBetween(oPC.Object, player.Object) <= 20.0f &&
                        player.Area.Equals(oPC.Area) &&
                        _.GetFactionEqual(player.Object, oPC.Object) == _.TRUE)
                    {
                        player.SendMessage(pcName + " found " + itemName + ".");
                    }

                    player = (_.GetNextPC());
                }
            }
        }
        public static Location GetRandomSpawnPoint(NWArea area)
        {
            var walkmeshes = AreaService.GetAreaWalkmeshes(area);
            int count      = walkmeshes.Count;
            var index      = count <= 0 ? 0 : RandomService.Random(count);

            var spawnPoint = walkmeshes[index];

            return(Location(area.Object,
                            Vector((float)spawnPoint.LocationX, (float)spawnPoint.LocationY, (float)spawnPoint.LocationZ),
                            RandomService.RandomFloat(0, 360)));
        }
Exemple #3
0
        private static void ApplyDurabilityLoss(NWPlayer player)
        {
            for (int index = 0; index < NUM_INVENTORY_SLOTS; index++)
            {
                NWItem equipped = _.GetItemInSlot(index, player);
                DurabilityService.RunItemDecay(player, equipped, RandomService.RandomFloat(0.10f, 0.50f));
            }

            foreach (var item in player.InventoryItems)
            {
                DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(0.10f, 0.50f));
            }
        }
Exemple #4
0
        public static Location GetRandomSpawnPoint(NWArea area)
        {
            Area dbArea     = DataService.Area.GetByResref(area.Resref);
            var  walkmeshes = DataService.AreaWalkmesh.GetAllByAreaID(dbArea.ID).ToList();
            int  count      = walkmeshes.Count;
            var  index      = count <= 0 ? 0 : RandomService.Random(count);

            var spawnPoint = walkmeshes[index];

            return(Location(area.Object,
                            Vector((float)spawnPoint.LocationX, (float)spawnPoint.LocationY, (float)spawnPoint.LocationZ),
                            RandomService.RandomFloat(0, 360)));
        }
Exemple #5
0
        private static void RunSearchCycle(NWPlayer oPC, NWPlaceable oChest, int iDC)
        {
            int lootTable = oChest.GetLocalInt(SearchSiteLootTableVariableName);
            int skill     = _.GetSkillRank(_.SKILL_SEARCH, oPC.Object);

            if (skill > 10)
            {
                skill = 10;
            }
            else if (skill < 0)
            {
                skill = 0;
            }

            int roll         = RandomService.Random(20) + 1;
            int combinedRoll = roll + skill;

            if (roll + skill >= iDC)
            {
                oPC.FloatingText(ColorTokenService.SkillCheck("Search: *success*: (" + roll + " + " + skill + " = " + combinedRoll + " vs. DC: " + iDC + ")"));
                ItemVO spawnItem = PickResultItem(lootTable);

                if (!string.IsNullOrWhiteSpace(spawnItem.Resref) && spawnItem.Quantity > 0)
                {
                    NWItem foundItem     = (_.CreateItemOnObject(spawnItem.Resref, oChest.Object, spawnItem.Quantity, ""));
                    float  maxDurability = DurabilityService.GetMaxDurability(foundItem);
                    if (maxDurability > -1)
                    {
                        DurabilityService.SetDurability(foundItem, RandomService.RandomFloat() * maxDurability + 1);
                    }
                }
            }
            else
            {
                oPC.FloatingText(ColorTokenService.SkillCheck("Search: *failure*: (" + roll + " + " + skill + " = " + combinedRoll + " vs. DC: " + iDC + ")"));
            }
        }