コード例 #1
0
        public bool Run(params object[] args)
        {
            NWCreature oPC = (_.GetEnteringObject());

            if (!oPC.IsPlayer)
            {
                return(false);
            }

            string triggerID = _.GetLocalString(Object.OBJECT_SELF, "TRIGGER_ID");

            if (string.IsNullOrWhiteSpace(triggerID))
            {
                triggerID = Guid.NewGuid().ToString();
                _.SetLocalString(Object.OBJECT_SELF, "TRIGGER_ID", triggerID);
            }

            if (_.GetLocalInt(oPC.Object, triggerID) == 1)
            {
                return(false);
            }

            string message = _.GetLocalString(Object.OBJECT_SELF, "DISPLAY_TEXT");

            _.SendMessageToPC(oPC.Object, ColorTokenService.Cyan(message));
            _.SetLocalInt(oPC.Object, triggerID, 1);

            _.AssignCommand(oPC.Object, () => _.PlaySound("gui_prompt"));

            return(true);
        }
コード例 #2
0
        public override void Initialize()
        {
            Guid            structureID   = new Guid(_.GetLocalString(_.GetArea(GetDialogTarget()), "PC_BASE_STRUCTURE_ID"));
            PCBaseStructure structure     = DataService.PCBaseStructure.GetByID(structureID);
            PCBase          pcBase        = DataService.PCBase.GetByID(structure.PCBaseID);
            BaseStructure   baseStructure = DataService.BaseStructure.GetByID(structure.BaseStructureID);

            NWPlaceable bay = SpaceService.GetCargoBay(GetPC().Area, null);

            int currentReinforcedFuel = pcBase.ReinforcedFuel;
            int currentFuel           = pcBase.Fuel;
            int currentResources      = DataService.PCBaseStructureItem.GetAllByPCBaseStructureID(structure.ID).Count();
            int maxReinforcedFuel     = BaseService.CalculateMaxReinforcedFuel(pcBase.ID) + 25 * SpaceService.GetCargoBonus(bay, ItemPropertyType.StarshipStronidiumBonus);
            int maxFuel      = BaseService.CalculateMaxFuel(pcBase.ID) + 25 * SpaceService.GetCargoBonus(bay, ItemPropertyType.StarshipFuelBonus);
            int maxResources = BaseService.CalculateResourceCapacity(pcBase.ID);

            string locationDescription;

            if (SpaceService.IsLocationSpace(pcBase.ShipLocation))
            {
                locationDescription = "Ship is in orbit around " + ColorTokenService.Cyan(SpaceService.GetPlanetFromLocation(pcBase.ShipLocation)) + ".\n";
            }
            else if (SpaceService.IsLocationPublicStarport(pcBase.ShipLocation))
            {
                locationDescription = "Ship is docked in the public starport on " + ColorTokenService.Cyan(SpaceService.GetPlanetFromLocation(pcBase.ShipLocation)) + ".\n";
            }
            else
            {
                locationDescription = "Ship is docked on " + ColorTokenService.Cyan(SpaceService.GetPlanetFromLocation(pcBase.ShipLocation)) + ".\n";
            }

            string header = locationDescription;

            header += ColorTokenService.Green("Fuel: ") + currentFuel + " / " + maxFuel + "\n";
            header += ColorTokenService.Green("Reinforced Fuel: ") + currentReinforcedFuel + " / " + maxReinforcedFuel + "\n";
            header += ColorTokenService.Green("Resource Bay: ") + currentResources + " / " + maxResources + "\n";
            header += ColorTokenService.Green("Hull integrity: ") + structure.Durability + " / " + baseStructure.Durability + "\n";

            header += "The computer awaits your orders.";

            SetPageHeader("MainPage", header);
        }
コード例 #3
0
ファイル: MessageBoard.cs プロジェクト: Terallis/SWLOR_NWN
        private void LoadMainPage()
        {
            NWPlayer    player   = GetPC();
            NWPlaceable terminal = Object.OBJECT_SELF;
            DateTime    now      = DateTime.UtcNow;
            Guid        boardID  = new Guid(terminal.GetLocalString("MESSAGE_BOARD_ID"));
            bool        isDM     = player.IsDM;
            var         messages = DataService.Where <Message>(x => x.BoardID == boardID && x.DateExpires > now && x.DateRemoved == null)
                                   .OrderByDescending(o => o.DatePosted);

            ClearPageResponses("MainPage");
            AddResponseToPage("MainPage", ColorTokenService.Green("Create New Post"), !isDM);
            foreach (var message in messages)
            {
                string title = message.Title;
                if (message.PlayerID == player.GlobalID)
                {
                    title = ColorTokenService.Cyan(title);
                }
                AddResponseToPage("MainPage", title, true, message.ID);
            }
        }
コード例 #4
0
        public void ApplyEffects(NWCreature user, NWItem item, NWObject target, Location targetLocation, CustomData customData)
        {
            NWPlayer        player     = user.Object;
            ResourceQuality quality    = (ResourceQuality)target.GetLocalInt("RESOURCE_QUALITY");
            int             tier       = target.GetLocalInt("RESOURCE_TIER");
            int             remaining  = target.GetLocalInt("RESOURCE_COUNT") - 1;
            string          itemResref = target.GetLocalString("RESOURCE_RESREF");
            int             gemChance  = ResourceService.CalculateChanceForComponentBonus(player, tier, quality);
            int             roll       = RandomService.Random(1, 100);
            int             rank       = SkillService.GetPCSkillRank(player, SkillType.Harvesting);

            if (item.RecommendedLevel < rank)
            {
                rank = item.RecommendedLevel;
            }

            int difficulty = (tier - 1) * 10 + ResourceService.GetDifficultyAdjustment(quality);
            int delta      = difficulty - rank;

            int baseXP = 0;

            if (delta >= 6)
            {
                baseXP = 400;
            }
            else if (delta == 5)
            {
                baseXP = 350;
            }
            else if (delta == 4)
            {
                baseXP = 325;
            }
            else if (delta == 3)
            {
                baseXP = 300;
            }
            else if (delta == 2)
            {
                baseXP = 250;
            }
            else if (delta == 1)
            {
                baseXP = 225;
            }
            else if (delta == 0)
            {
                baseXP = 200;
            }
            else if (delta == -1)
            {
                baseXP = 150;
            }
            else if (delta == -2)
            {
                baseXP = 100;
            }
            else if (delta == -3)
            {
                baseXP = 50;
            }
            else if (delta == -4)
            {
                baseXP = 25;
            }

            int itemHarvestBonus = item.HarvestingBonus;
            int scanningBonus    = user.GetLocalInt(target.GlobalID.ToString());

            gemChance += itemHarvestBonus * 2 + scanningBonus * 2;

            baseXP = baseXP + scanningBonus * 5;

            // Spawn the normal resource.
            NWItem resource = CreateItemOnObject(itemResref, player);

            user.SendMessage("You harvest " + resource.Name + ".");

            // If player meets the chance to acquire a gem, create one and modify its properties.
            if (quality > ResourceQuality.Low && roll <= gemChance)
            {
                // Gemstone quality is determined by the quality of the vein.
                switch (quality)
                {
                case ResourceQuality.Normal:
                    resource = CreateItemOnObject("flawed_gemstone", player);
                    break;

                case ResourceQuality.High:
                    resource = CreateItemOnObject("gemstone", player);
                    break;

                case ResourceQuality.VeryHigh:
                    resource = CreateItemOnObject("perfect_gemstone", player);
                    break;
                }

                var ip = ResourceService.GetRandomComponentBonusIP(quality);
                BiowareXP2.IPSafeAddItemProperty(resource, ip.Item1, 0.0f, AddItemPropertyPolicy.IgnoreExisting, true, true);

                switch (ip.Item2)
                {
                case 0:
                    resource.Name = ColorTokenService.Green(resource.Name);
                    break;

                case 1:
                    resource.Name = ColorTokenService.Blue(resource.Name);
                    break;

                case 2:
                    resource.Name = ColorTokenService.Purple(resource.Name);
                    break;

                case 3:
                    resource.Name = ColorTokenService.Orange(resource.Name);
                    break;

                case 4:
                    resource.Name = ColorTokenService.LightPurple(resource.Name);
                    break;

                case 5:
                    resource.Name = ColorTokenService.Yellow(resource.Name);
                    break;

                case 6:
                    resource.Name = ColorTokenService.Red(resource.Name);
                    break;

                case 7:
                    resource.Name = ColorTokenService.Cyan(resource.Name);
                    break;
                }

                user.SendMessage("You harvest " + resource.Name + ".");
            }

            float decayMinimum = 0.03f;
            float decayMaximum = 0.07f;

            if (delta > 0)
            {
                decayMinimum += delta * 0.1f;
                decayMaximum += delta * 0.1f;
            }

            DurabilityService.RunItemDecay(player, item, RandomService.RandomFloat(decayMinimum, decayMaximum));
            int xp = baseXP;

            SkillService.GiveSkillXP(player, SkillType.Harvesting, xp);

            if (remaining <= 0)
            {
                NWPlaceable prop = target.GetLocalObject("RESOURCE_PROP_OBJ");

                if (prop.IsValid)
                {
                    prop.Destroy();
                }

                target.Destroy();
                user.DeleteLocalInt(target.GlobalID.ToString());
            }
            else
            {
                target.SetLocalInt("RESOURCE_COUNT", remaining);
            }

            ApplyEffectAtLocation(DurationType.Instant, EffectVisualEffect(VisualEffect.Vfx_Fnf_Summon_Monster_3), target.Location);
        }
コード例 #5
0
        public void ColorTokenService_NullText_ShouldThrowArgumentException()
        {
            ColorTokenService service = new ColorTokenService();

            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Black(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Blue(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Gray(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Green(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.LightPurple(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Orange(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Pink(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Purple(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Red(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.White(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Yellow(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Cyan(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Combat(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Dialog(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.DialogAction(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.DialogCheck(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.DialogHighlight(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.DialogReply(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.DM(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.GameEngine(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.SavingThrow(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Script(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Server(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Shout(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.SkillCheck(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Talk(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Tell(null);
            });
            Assert.Throws(typeof(ArgumentException), () =>
            {
                service.Whisper(null);
            });
        }