private string GetChanceColor(int chance) { string message = "-" + chance + "%-"; if (chance <= 50) { return(ColorTokenService.Red(message)); } else if (chance <= 80) { return(ColorTokenService.Yellow(message)); } else { return(ColorTokenService.Green(message)); } }
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); }
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); }); }
private void LoadTaskListPage() { var player = GetPC(); var model = GetDialogCustomData <Model>(); string header = "These are our currently available tasks. Please check back periodically because our needs are always changing."; SetPageHeader("TaskListPage", header); ClearPageResponses("TaskListPage"); var lastUpdate = DataService.ServerConfiguration.Get().LastGuildTaskUpdate; var pcGP = DataService.PCGuildPoint.GetByPlayerIDAndGuildID(player.GlobalID, (int)model.Guild); // It's possible for players to have tasks which are no longer offered. // In this case, we still display them on the menu. Once they complete them, they'll disappear from the list. var questIDs = DataService.PCQuestStatus .GetAllByPlayerID(player.GlobalID) .Where(x => x.CompletionDate == null) .Select(s => s.QuestID); var expiredTasks = DataService.GuildTask .GetAll() .Where(x => !x.IsCurrentlyOffered && questIDs.Contains(x.QuestID) && x.GuildID == (int)model.Guild) .OrderByDescending(o => o.RequiredRank); foreach (var task in expiredTasks) { var quest = DataService.Quest.GetByID(task.QuestID); string status = ColorTokenService.Green("{ACCEPTED}"); AddResponseToPage("TaskListPage", quest.Name + " [Rank " + (task.RequiredRank + 1) + "] " + status + ColorTokenService.Red(" [EXPIRED]"), true, task.ID); } // Pull back all currently available tasks. This list rotates after 24 hours and a reboot occurs. var tasks = DataService.GuildTask .GetAllByCurrentlyOffered() .Where(x => x.GuildID == (int)model.Guild && x.RequiredRank <= pcGP.Rank) .OrderByDescending(o => o.RequiredRank); foreach (var task in tasks) { var quest = DataService.Quest.GetByID(task.QuestID); var questStatus = DataService.PCQuestStatus.GetByPlayerAndQuestIDOrDefault(player.GlobalID, task.QuestID); // If the player has completed the task during this task cycle, it will be excluded from this list. // The reason for this is to prevent players from repeating the same tasks over and over without impunity. if (questStatus != null && questStatus.CompletionDate >= lastUpdate) { continue; } string status = ColorTokenService.Green("{ACCEPTED}"); // Player has never accepted the quest, or they've already completed it at least once and can accept it again. if (questStatus == null || questStatus.CompletionDate != null) { status = ColorTokenService.Yellow("{Available}"); } AddResponseToPage("TaskListPage", quest.Name + " [Rank " + (task.RequiredRank + 1) + "] " + status, true, task.ID); } }
public void ApplyEffects(NWCreature user, NWItem modItem, NWObject target, Location targetLocation, CustomData customData) { NWPlayer player = (user.Object); NWItem targetItem = (target.Object); ModSlots slots = ModService.GetModSlots(targetItem); CustomItemPropertyType modType = ModService.GetModType(modItem); int modID = modItem.GetLocalInt("RUNE_ID"); string[] modArgs = modItem.GetLocalString("RUNE_VALUE").Split(','); int modLevel = modItem.RecommendedLevel; int levelIncrease = modItem.LevelIncrease; var mod = ModService.GetModHandler(modID); mod.Apply(player, targetItem, modArgs); string description = mod.Description(player, targetItem, modArgs); bool usePrismatic = false; switch (modType) { case CustomItemPropertyType.RedMod: if (slots.FilledRedSlots < slots.RedSlots) { targetItem.SetLocalInt("MOD_SLOT_RED_" + (slots.FilledRedSlots + 1), modID); targetItem.SetLocalString("MOD_SLOT_RED_DESC_" + (slots.FilledRedSlots + 1), description); player.SendMessage("Mod installed into " + ColorTokenService.Red("red") + " slot #" + (slots.FilledRedSlots + 1)); } else { usePrismatic = true; } break; case CustomItemPropertyType.BlueMod: if (slots.FilledBlueSlots < slots.BlueSlots) { targetItem.SetLocalInt("MOD_SLOT_BLUE_" + (slots.FilledBlueSlots + 1), modID); targetItem.SetLocalString("MOD_SLOT_BLUE_DESC_" + (slots.FilledBlueSlots + 1), description); player.SendMessage("Mod installed into " + ColorTokenService.Blue("blue") + " slot #" + (slots.FilledBlueSlots + 1)); } else { usePrismatic = true; } break; case CustomItemPropertyType.GreenMod: if (slots.FilledBlueSlots < slots.GreenSlots) { targetItem.SetLocalInt("MOD_SLOT_GREEN_" + (slots.FilledGreenSlots + 1), modID); targetItem.SetLocalString("MOD_SLOT_GREEN_DESC_" + (slots.FilledGreenSlots + 1), description); player.SendMessage("Mod installed into " + ColorTokenService.Green("green") + " slot #" + (slots.FilledGreenSlots + 1)); } else { usePrismatic = true; } break; case CustomItemPropertyType.YellowMod: if (slots.FilledBlueSlots < slots.YellowSlots) { targetItem.SetLocalInt("MOD_SLOT_YELLOW_" + (slots.FilledYellowSlots + 1), modID); targetItem.SetLocalString("MOD_SLOT_YELLOW_DESC_" + (slots.FilledYellowSlots + 1), description); player.SendMessage("Mod installed into " + ColorTokenService.Yellow("yellow") + " slot #" + (slots.FilledYellowSlots + 1)); } else { usePrismatic = true; } break; } if (usePrismatic) { string prismaticText = ModService.PrismaticString(); targetItem.SetLocalInt("MOD_SLOT_PRISMATIC_" + (slots.FilledPrismaticSlots + 1), modID); targetItem.SetLocalString("MOD_SLOT_PRISMATIC_DESC_" + (slots.FilledPrismaticSlots + 1), description); player.SendMessage("Mod installed into " + prismaticText + " slot #" + (slots.FilledPrismaticSlots + 1)); } targetItem.RecommendedLevel += levelIncrease; modItem.Destroy(); SkillType skillType; if (ArmorBaseItemTypes.Contains(targetItem.BaseItemType)) { skillType = SkillType.Armorsmith; } else if (WeaponsmithBaseItemTypes.Contains(targetItem.BaseItemType)) { skillType = SkillType.Weaponsmith; } else if (EngineeringBaseItemTypes.Contains(targetItem.BaseItemType)) { skillType = SkillType.Engineering; } else { return; } int rank = SkillService.GetPCSkillRank(player, skillType); int xp = (int)SkillService.CalculateRegisteredSkillLevelAdjustedXP(400, modLevel, rank); SkillService.GiveSkillXP(player, skillType, xp); }