private void updateFirstFeedingWaiting() { int s = Taming.durationAfterFirstFeeding(speciesIndex, (int)nudLevel.Value, foodDepletion); if (s > 0) { firstFeedingWaiting = "\n\n" + String.Format(Loc.s("waitingAfterFirstFeeding"), Utils.duration(s)); } else { firstFeedingWaiting = ""; } }
private void updateFirstFeedingWaiting() { int s = Taming.durationAfterFirstFeeding(speciesIndex, (int)nudLevel.Value, foodDepletion); if (s > 0) { firstFeedingWaiting = "\n\nWaiting time after first feeding: ~" + Utils.duration(s); } else { firstFeedingWaiting = ""; } }
private void updateKOCounting() { bool knockoutNeeded; labelKOCount.Text = Taming.knockoutInfo(speciesIndex, (int)nudLevel.Value, chkbDmLongneck.Checked ? (double)nudWDmLongneck.Value / 100 : 0, chkbDmCrossbow.Checked ? (double)nudWDmCrossbow.Value / 100 : 0, chkbDmBow.Checked ? (double)nudWDmBow.Value / 100 : 0, chkbDmSlingshot.Checked ? (double)nudWDmSlingshot.Value / 100 : 0, chkbDmClub.Checked ? (double)nudWDmClub.Value / 100 : 0, chkbDmProd.Checked ? (double)nudWDmProd.Value / 100 : 0, out knockoutNeeded, out koNumbers); labelKOCount.ForeColor = knockoutNeeded ? SystemColors.ControlText : SystemColors.GrayText; if (!knockoutNeeded) { koNumbers = ""; } }
private void numericUpDownCurrentTorpor_ValueChanged(object sender, EventArgs e) { var duration = new TimeSpan(0, 0, Taming.SecondsUntilWakingUp(selectedSpecies, (int)nudLevel.Value, (double)numericUpDownCurrentTorpor.Value)); lbTimeUntilWakingUp.Text = string.Format(Loc.S("lbTimeUntilWakingUp"), Utils.Duration(duration)); if (duration.TotalSeconds < 30) { lbTimeUntilWakingUp.ForeColor = Color.DarkRed; } else if (duration.TotalSeconds < 120) { lbTimeUntilWakingUp.ForeColor = Color.DarkGoldenrod; } else { lbTimeUntilWakingUp.ForeColor = Color.Black; } wakeUpTime = DateTime.Now.Add(duration); }
private void numericUpDownCurrentTorpor_ValueChanged(object sender, EventArgs e) { var duration = new TimeSpan(0, 0, Taming.secondsUntilWakingUp(speciesIndex, (int)nudLevel.Value, (double)numericUpDownCurrentTorpor.Value)); labelTimeUntilWakingUp.Text = "Time until wake-up: " + Utils.duration(duration); if (duration.TotalSeconds < 30) { labelTimeUntilWakingUp.ForeColor = Color.DarkRed; } else if (duration.TotalSeconds < 120) { labelTimeUntilWakingUp.ForeColor = Color.DarkGoldenrod; } else { labelTimeUntilWakingUp.ForeColor = Color.Black; } wakeUpTime = DateTime.Now.Add(duration); }
private void comboBoxSpecies_SelectedIndexChanged(object sender, EventArgs e) { int sI = comboBoxSpecies.SelectedIndex; if (sI >= 0 && Values.V.species[sI].taming != null) { TamingData td = Values.V.species[sI].taming; this.SuspendLayout(); foreach (TamingFoodControl f in foodControls) { Controls.Remove(f); } foodControls.Clear(); TamingFoodControl tf; int i = 0; foreach (string f in td.eats) { tf = new TamingFoodControl(f); if (f == "Kibble") { tf.foodNameDisplay = "Kibble (" + td.favoriteKibble + " Egg)"; } if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity.ToString() + "× " + tf.foodNameDisplay; } tf.Location = new Point(20, 80 + 45 * i); tf.valueChanged += new TamingFoodControl.ValueChangedEventHandler(updateTamingData); tf.Clicked += new TamingFoodControl.ClickedEventHandler(onlyOneFood); foodControls.Add(tf); Controls.Add(tf); i++; } this.ResumeLayout(); if (foodControls.Count > 0) { foodControls[0].amount = Taming.foodAmountNeeded(sI, (int)nudLevel.Value, foodControls[0].foodName, td.nonViolent); } } }
private void UpdateKOCounting(double boneDamageAdjuster = 0) { if (boneDamageAdjuster == 0) { boneDamageAdjuster = currentBoneDamageAdjuster; } lbKOInfo.Text = Taming.KnockoutInfo(selectedSpecies, (int)nudLevel.Value, chkbDmLongneck.Checked ? (double)nudWDmLongneck.Value / 100 : 0, chkbDmCrossbow.Checked ? (double)nudWDmCrossbow.Value / 100 : 0, chkbDmBow.Checked ? (double)nudWDmBow.Value / 100 : 0, chkbDmSlingshot.Checked ? (double)nudWDmSlingshot.Value / 100 : 0, chkbDmClub.Checked ? (double)nudWDmClub.Value / 100 : 0, chkbDmProd.Checked ? (double)nudWDmProd.Value / 100 : 0, chkbDmHarpoon.Checked ? (double)nudWDmHarpoon.Value / 100 : 0, boneDamageAdjuster, out bool knockoutNeeded, out koNumbers) + (boneDamageAdjustersImmobilization.Length > 0 ? "\n\n" + boneDamageAdjustersImmobilization : ""); lbKOInfo.ForeColor = knockoutNeeded ? SystemColors.ControlText : SystemColors.GrayText; if (!knockoutNeeded) { koNumbers = ""; } }
private void updateTamingData() { if (updateCalculation) { int sI = comboBoxSpecies.SelectedIndex; TimeSpan duration; int narcoBerries, narcotics, bioToxines; double te; bool enoughFood; var usedFood = new List <string>(); var foodAmount = new List <int>(); var foodAmountUsed = new List <int>(); foreach (TamingFoodControl tfc in foodControls) { usedFood.Add(tfc.foodName); foodAmount.Add(tfc.amount); tfc.maxFood = Taming.foodAmountNeeded(sI, (int)nudLevel.Value, tfc.foodName, Values.V.species[sI].taming.nonViolent); } Taming.tamingTimes(sI, (int)nudLevel.Value, usedFood, foodAmount, out foodAmountUsed, out duration, out narcoBerries, out narcotics, out bioToxines, out te, out enoughFood); for (int f = 0; f < foodControls.Count; f++) { foodControls[f].foodUsed = foodAmountUsed[f]; } if (enoughFood) { int bonusLevel = (int)Math.Floor((double)nudLevel.Value * te / 2); labelResult.Text = "It takes " + duration.ToString(@"hh\:mm\:ss") + " (until " + (DateTime.Now + duration).ToShortTimeString() + ") to tame the " + comboBoxSpecies.SelectedItem.ToString() + "." + "\n\nTaming Effectiveness: " + Math.Round(100 * te, 1).ToString() + " %\nBonus-Level: " + bonusLevel + " (total level after Taming: " + (nudLevel.Value + bonusLevel).ToString() + ")" + "\n\n" + narcoBerries + " Narcoberries or\n" + narcotics + " Narcotics or\n" + bioToxines + " Bio Toxines are needed"; } else { labelResult.Text = "Not enough food to tame the creature!"; } } }
public void updateTamingData() { if (updateCalculation && speciesIndex >= 0) { updateKOCounting(); TimeSpan duration = new TimeSpan(); int narcoBerries = 0, narcotics = 0, bioToxines = 0, bonusLevel = 0; double te = 0, hunger = 0; bool enoughFood = false; var usedFood = new List <string>(); var foodAmount = new List <int>(); var foodAmountUsed = new List <int>(); quickTamingInfos = "n/a"; int level = (int)nudLevel.Value; if (Values.V.species[speciesIndex].taming.eats != null) { int foodCounter = Values.V.species[speciesIndex].taming.eats.Count; foreach (TamingFoodControl tfc in foodControls) { if (foodCounter == 0) { break; } foodCounter--; usedFood.Add(tfc.FoodName); foodAmount.Add(tfc.amount); tfc.maxFood = Taming.foodAmountNeeded(speciesIndex, level, tamingSpeedMultiplier, tfc.FoodName, Values.V.species[speciesIndex].taming.nonViolent); tfc.tamingDuration = Taming.tamingDuration(speciesIndex, tfc.maxFood, tfc.FoodName, tamingFoodRateMultiplier, Values.V.species[speciesIndex].taming.nonViolent); } Taming.tamingTimes(speciesIndex, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, usedFood, foodAmount, out foodAmountUsed, out duration, out narcoBerries, out narcotics, out bioToxines, out te, out hunger, out bonusLevel, out enoughFood); for (int f = 0; f < foodAmountUsed.Count; f++) { foodControls[f].foodUsed = foodAmountUsed[f]; } } if (enoughFood) { labelResult.Text = "It takes " + Utils.durationUntil(duration) + " to tame the " + Values.V.speciesNames[speciesIndex] + "." + "\n\n" + "Taming Effectiveness: " + Math.Round(100 * te, 1) + " %" + "\nBonus-Level: +" + bonusLevel + " (total level after Taming: " + (nudLevel.Value + bonusLevel) + ")" + "\n\n" + $"Food has to drop by {hunger:F1} units." + "\n\n" + $"{narcoBerries} Narcoberries or\n" + $"{narcotics} Narcotics or\n" + $"{bioToxines} Bio Toxines are needed" + firstFeedingWaiting; if (foodAmountUsed.Count > 0) { quickTamingInfos = Taming.quickInfoOneFood(speciesIndex, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodControls[0].FoodName, foodControls[0].maxFood, foodControls[0].foodNameDisplay); // show raw meat or mejoberries as alternative (often used) for (int i = 1; i < usedFood.Count; i++) { if (usedFood[i] == "Raw Meat" || usedFood[i] == "Mejoberry") { quickTamingInfos += "\n\n" + Taming.quickInfoOneFood(speciesIndex, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodControls[i].FoodName, foodControls[i].maxFood, foodControls[i].foodNameDisplay); break; } } quickTamingInfos += "\n\n" + koNumbers + "\n\n" + boneDamageAdjustersImmobilization + firstFeedingWaiting; } if (favoriteKibble != null) { if (Kibbles.K.kibble.ContainsKey(favoriteKibble)) { labelResult.Text += "\n\nKibble:" + Kibbles.K.kibble[favoriteKibble].RecipeAsText(); } } } else if (foodAmountUsed.Count == 0) { labelResult.Text = "no taming-data available"; } else { labelResult.Text = "Not enough food to tame the creature!"; } numericUpDownCurrentTorpor.Value = (decimal)(Values.V.species[speciesIndex].stats[7].BaseValue * (1 + Values.V.species[speciesIndex].stats[7].IncPerWildLevel * (level - 1))); // displays the time until the food has decreased enough to tame the creature in one go. var durationStarving = new TimeSpan(0, 0, (int)(hunger / foodDepletion)); lblTimeUntilStarving.Text = "Time until you can feed all needed food in one go: " + Utils.duration(durationStarving); if (Values.V.species[speciesIndex].stats[3].BaseValue * (1 + Values.V.species[speciesIndex].stats[3].IncPerWildLevel * (level / 7)) < hunger) { lblTimeUntilStarving.Text += "\nCareful: this creature could have not enough food, so you might have to feed it before this time to prevent it from starving (check its inventory)!"; lblTimeUntilStarving.ForeColor = Color.DarkRed; } else { lblTimeUntilStarving.ForeColor = SystemColors.ControlText; } starvingTime = DateTime.Now.Add(durationStarving); } }
public void setSpeciesIndex(int speciesIndex) { if (speciesIndex >= 0 && Values.V.species[speciesIndex].taming != null) { this.speciesIndex = speciesIndex; boneDamageAdjusters = Taming.boneDamageAdjustersImmobilisation(speciesIndex); updateCalculation = false; this.SuspendLayout(); TamingData td = Values.V.species[speciesIndex].taming; foodDepletion = td.foodConsumptionBase * td.foodConsumptionMult * Values.V.tamingFoodRateMultiplier; TamingFoodControl tf; int i = 0; if (td.eats != null) { for (i = 0; i < td.eats.Count; i++) { string f = td.eats[i]; if (i >= foodControls.Count) { tf = new TamingFoodControl(f); tf.Location = new Point(20, 80 + 45 * i); tf.valueChanged += new TamingFoodControl.ValueChangedEventHandler(updateTamingData); tf.Clicked += new TamingFoodControl.ClickedEventHandler(onlyOneFood); foodControls.Add(tf); Controls.Add(tf); } else { tf = foodControls[i]; tf.FoodName = f; tf.Show(); } if (f == "Kibble") { tf.foodNameDisplay = "Kibble (" + td.favoriteKibble + " Egg)"; } if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity.ToString() + "× " + tf.foodNameDisplay; } } } for (int fci = foodControls.Count - 1; fci >= i; fci--) { foodControls[fci].Hide(); } if (i > 0) { foodControls[0].amount = Taming.foodAmountNeeded(speciesIndex, (int)nudLevel.Value, evolutionEvent, foodControls[0].FoodName, td.nonViolent); } updateCalculation = true; updateFirstFeedingWaiting(); updateTamingData(); ResumeLayout(); } }
public void setSpeciesIndex(int speciesIndex) { if (speciesIndex >= 0 && Values.V.species[speciesIndex].taming != null && this.speciesIndex != speciesIndex) { SuspendLayout(); this.speciesIndex = speciesIndex; // bone damage adjusters boneDamageAdjustersImmobilization = Taming.boneDamageAdjustersImmobilization(speciesIndex, out Dictionary <double, string> boneDamageAdjusters); int ib = 0; foreach (KeyValuePair <double, string> bd in boneDamageAdjusters) { ib++; if (ib >= rbBoneDamageAdjusters.Count) { RadioButton rbBD = new RadioButton(); gbWeaponDamage.Controls.Add(rbBD); rbBD.Location = new Point(6, 199 + 19 * ib); rbBD.AutoSize = false; rbBD.Size = new Size(194, 17); rbBoneDamageAdjusters.Add(rbBD); rbBoneDamageAdjusterValues.Add(1); rbBD.CheckedChanged += rbBoneDamage_CheckedChanged; } rbBoneDamageAdjusterValues[ib] = bd.Key; rbBoneDamageAdjusters[ib].Text = $"{Loc.s(bd.Value)} ({bd.Key}×)"; rbBoneDamageAdjusters[ib].Visible = true; } for (int j = ib + 1; j < rbBoneDamageAdjusters.Count; j++) { rbBoneDamageAdjusters[j].Visible = false; } rbBoneDamageAdjusters[0].Checked = true; // bone damage adjusters adjusted updateCalculation = false; TamingData td = Values.V.species[speciesIndex].taming; kibbleRecipe = ""; if (td.favoriteKibble != null && Kibbles.K.kibble.ContainsKey(td.favoriteKibble)) { kibbleRecipe = "\n\nKibble:" + Kibbles.K.kibble[td.favoriteKibble].RecipeAsText(); } foodDepletion = td.foodConsumptionBase * td.foodConsumptionMult * tamingFoodRateMultiplier; int i = 0; if (td.eats != null) { for (i = 0; i < td.eats.Count; i++) { string f = td.eats[i]; TamingFoodControl tf; if (i >= foodControls.Count) { tf = new TamingFoodControl(f); tf.valueChanged += updateTamingData; tf.Clicked += onlyOneFood; foodControls.Add(tf); flpTamingFood.Controls.Add(tf); } else { tf = foodControls[i]; tf.FoodName = f; tf.Show(); } if (f == "Kibble") { tf.foodNameDisplay = $"Kibble ({td.favoriteKibble} {Loc.s("Egg")})"; } if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity + "× " + tf.foodNameDisplay; } } } for (int fci = foodControls.Count - 1; fci >= i; fci--) { foodControls[fci].Hide(); } if (i > 0) { foodControls[0].amount = Taming.foodAmountNeeded(speciesIndex, (int)nudLevel.Value, tamingSpeedMultiplier, foodControls[0].FoodName, td.nonViolent); } updateCalculation = true; updateFirstFeedingWaiting(); updateTamingData(); ResumeLayout(); } }
public void SetSpecies(Species species, bool forceRefresh = false) { if (species == null || (selectedSpecies == species && !forceRefresh)) { return; } selectedSpecies = species; if (species.taming == null) { NoTamingData(); return; } SuspendLayout(); string speciesName = species.name; linkLabelWikiPage.Text = "Wiki: " + speciesName; linkLabelWikiPage.Tag = speciesName; // bone damage adjusters boneDamageAdjustersImmobilization = Taming.BoneDamageAdjustersImmobilization(selectedSpecies, out Dictionary <string, double> boneDamageAdjusters); int ib = 0; foreach (KeyValuePair <string, double> bd in boneDamageAdjusters) { ib++; if (ib >= rbBoneDamageAdjusters.Count) { RadioButton rbBD = new RadioButton(); flcBodyDamageMultipliers.Controls.Add(rbBD); flcBodyDamageMultipliers.SetFlowBreak(rbBD, true); rbBD.AutoSize = true; rbBoneDamageAdjusters.Add(rbBD); rbBoneDamageAdjusterValues.Add(1); rbBD.CheckedChanged += rbBoneDamage_CheckedChanged; } rbBoneDamageAdjusterValues[ib] = bd.Value; rbBoneDamageAdjusters[ib].Text = $"{Loc.S(bd.Key)} (× {bd.Value})"; rbBoneDamageAdjusters[ib].Visible = true; } for (int j = ib + 1; j < rbBoneDamageAdjusters.Count; j++) { rbBoneDamageAdjusters[j].Visible = false; } rbBoneDamageAdjusters[0].Checked = true; // bone damage adjusters adjusted updateCalculation = false; TamingData td = species.taming; kibbleRecipe = string.Empty; // list all recipes of kibbles that give a reasonable affinity (assuming that is larger or equal than 100) foreach (var k in Kibbles.K.kibble) { var kibbleName = $"{k.Key} Kibble"; if (((td.specialFoodValues != null && td.specialFoodValues.TryGetValue(kibbleName, out var kFood)) || Values.V.defaultFoodData.TryGetValue(kibbleName, out kFood)) && kFood.affinity >= 100) { kibbleRecipe += $"\n\n{k.Key} Kibble:{k.Value.RecipeAsText()}"; } } foodDepletion = td.foodConsumptionBase * td.foodConsumptionMult * tamingFoodRateMultiplier; int i = 0; if (td.eats != null) { for (i = 0; i < td.eats.Length; i++) { string f = td.eats[i]; TamingFoodControl tf; // if Augmented are not wanted, and food control already exist, update it and hide it. if (!checkBoxAugmented.Checked && f.Contains("Augmented")) { if (i < foodControls.Count) { tf = foodControls[i]; tf.FoodName = f; tf.Hide(); } continue; } if (i >= foodControls.Count) { tf = new TamingFoodControl(f); tf.valueChanged += UpdateTamingData; tf.Clicked += OnlyOneFood; foodControls.Add(tf); flpTamingFood.Controls.Add(tf); } else { tf = foodControls[i]; tf.FoodName = f; tf.Show(); } // special cases where a creature eats multiple food items of one kind at once if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity + "× " + tf.foodNameDisplay; } } } for (int fci = foodControls.Count - 1; fci >= i; fci--) { foodControls[fci].Hide(); } if (i > 0) { foodControls[0].amount = Taming.FoodAmountNeeded(species, (int)nudLevel.Value, tamingSpeedMultiplier, foodControls[0].FoodName, td.nonViolent); } updateCalculation = true; UpdateFirstFeedingWaiting(); UpdateTamingData(); ResumeLayout(); }
private void updateTamingData() { if (updateCalculation && selectedSpecies != null) { if (selectedSpecies.taming == null) { noTamingData(); return; } this.Enabled = true; updateKOCounting(); TimeSpan duration = new TimeSpan(); int narcoBerries = 0, narcotics = 0, bioToxines = 0, bonusLevel = 0; double te = 0, hunger = 0; bool enoughFood = false; var usedFood = new List <string>(); var foodAmount = new List <int>(); var foodAmountUsed = new List <int>(); quickTamingInfos = "n/a"; int level = (int)nudLevel.Value; if (selectedSpecies.taming.eats != null) { int foodCounter = selectedSpecies.taming.eats.Count; foreach (TamingFoodControl tfc in foodControls) { if (foodCounter == 0) { break; } foodCounter--; usedFood.Add(tfc.FoodName); foodAmount.Add(tfc.amount); tfc.maxFood = Taming.foodAmountNeeded(selectedSpecies, level, tamingSpeedMultiplier, tfc.FoodName, selectedSpecies.taming.nonViolent); tfc.tamingDuration = Taming.tamingDuration(selectedSpecies, tfc.maxFood, tfc.FoodName, tamingFoodRateMultiplier, selectedSpecies.taming.nonViolent); } Taming.tamingTimes(selectedSpecies, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, usedFood, foodAmount, out foodAmountUsed, out duration, out narcoBerries, out narcotics, out bioToxines, out te, out hunger, out bonusLevel, out enoughFood); for (int f = 0; f < foodAmountUsed.Count; f++) { foodControls[f].foodUsed = foodAmountUsed[f]; } } if (enoughFood) { labelResult.Text = $"It takes {Utils.durationUntil(duration)} to tame the {selectedSpecies.name}.\n\n" + $"Taming Effectiveness: {Math.Round(100 * te, 1)} %\n" + $"Bonus-Level: +{bonusLevel} (total level after Taming: {(nudLevel.Value + bonusLevel)})\n\n" + $"Food has to drop by {hunger:F1} units.\n\n" + $"{narcoBerries} Narcoberries or\n" + $"{narcotics} Narcotics or\n" + $"{bioToxines} Bio Toxines are needed{firstFeedingWaiting}"; if (foodAmountUsed.Count > 0) { quickTamingInfos = Taming.quickInfoOneFood(selectedSpecies, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodControls[0].FoodName, foodControls[0].maxFood, foodControls[0].foodNameDisplay); // show raw meat or mejoberries as alternative (often used) for (int i = 1; i < usedFood.Count; i++) { if (usedFood[i] == "Raw Meat" || usedFood[i] == "Mejoberry") { quickTamingInfos += "\n\n" + Taming.quickInfoOneFood(selectedSpecies, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodControls[i].FoodName, foodControls[i].maxFood, foodControls[i].foodNameDisplay); break; } } quickTamingInfos += "\n\n" + koNumbers + "\n\n" + boneDamageAdjustersImmobilization + firstFeedingWaiting + kibbleRecipe; } labelResult.Text += kibbleRecipe; } else if (foodAmountUsed.Count == 0) { labelResult.Text = Loc.s("noTamingData"); } else { labelResult.Text = Loc.s("notEnoughFoodToTame"); } numericUpDownCurrentTorpor.ValueSave = (decimal)(selectedSpecies.stats[(int)StatNames.Torpidity].BaseValue * (1 + selectedSpecies.stats[(int)StatNames.Torpidity].IncPerWildLevel * (level - 1))); // displays the time until the food has decreased enough to tame the creature in one go. var durationStarving = new TimeSpan(0, 0, (int)(hunger / foodDepletion)); lbTimeUntilStarving.Text = (enoughFood ? $"{Loc.s("TimeUntilFeedingAllFood")}: {Utils.duration(durationStarving)}" : ""); nudCurrentFood.Value = (decimal)(selectedSpecies.stats[(int)StatNames.Food].BaseValue * (1 + selectedSpecies.stats[(int)StatNames.Food].IncPerWildLevel * (level / 7))); // approximating the food level if ((double)nudCurrentFood.Value < hunger) { lbTimeUntilStarving.Text += (lbTimeUntilStarving.Text.Length > 0 ? "\n" : "") + $"{Loc.s("WarningMoreStarvingThanFood")}"; lbTimeUntilStarving.ForeColor = Color.DarkRed; } else { lbTimeUntilStarving.ForeColor = SystemColors.ControlText; } starvingTime = DateTime.Now.Add(durationStarving); } }
private void UpdateTamingData() { if (!updateCalculation || selectedSpecies == null) { return; } if (selectedSpecies.taming == null) { NoTamingData(); return; } this.Enabled = true; UpdateKOCounting(); TimeSpan duration = new TimeSpan(); int narcoBerries = 0, ascerbicMushrooms = 0, narcotics = 0, bioToxines = 0, bonusLevel = 0; double te = 0; neededHunger = 0; bool enoughFood = false; var usedFood = new List <string>(); var foodAmount = new List <int>(); var foodAmountUsed = new List <int>(); quickTamingInfos = "n/a"; int level = (int)nudLevel.Value; bool tameable = selectedSpecies.taming.nonViolent || selectedSpecies.taming.violent; if (tameable && selectedSpecies.taming.eats != null) { int foodCounter = selectedSpecies.taming.eats.Length; foreach (TamingFoodControl tfc in foodControls) { if (foodCounter == 0) { break; } foodCounter--; usedFood.Add(tfc.FoodName); foodAmount.Add(tfc.amount); tfc.maxFood = Taming.FoodAmountNeeded(selectedSpecies, level, tamingSpeedMultiplier, tfc.FoodName, selectedSpecies.taming.nonViolent); tfc.tamingDuration = Taming.TamingDuration(selectedSpecies, tfc.maxFood, tfc.FoodName, tamingFoodRateMultiplier, selectedSpecies.taming.nonViolent); } Taming.TamingTimes(selectedSpecies, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, usedFood, foodAmount, out foodAmountUsed, out duration, out narcoBerries, out ascerbicMushrooms, out narcotics, out bioToxines, out te, out neededHunger, out bonusLevel, out enoughFood); for (int f = 0; f < foodAmountUsed.Count; f++) { foodControls[f].foodUsed = foodAmountUsed[f]; } } labelResult.ForeColor = SystemColors.ControlText; if (!tameable) { labelResult.Text = Loc.S("speciesNotTameable"); labelResult.ForeColor = Color.Red; } else if (enoughFood) { labelResult.Text = $"It takes {Utils.DurationUntil(duration)} to tame the {selectedSpecies.name}.\n\n" + $"Taming Effectiveness: {Math.Round(100 * te, 1)} %\n" + $"Bonus-Level: +{bonusLevel} (total level after Taming: {(nudLevel.Value + bonusLevel)})\n\n" + $"Food has to drop by {neededHunger:F1} units.\n\n" + $"{narcoBerries} Narcoberries or\n" + $"{ascerbicMushrooms} Ascerbic Mushrooms or\n" + $"{narcotics} Narcotics or\n" + $"{bioToxines} Bio Toxines are needed{firstFeedingWaiting}"; labelResult.Text += kibbleRecipe; } else if (foodAmountUsed.Count == 0) { labelResult.Text = Loc.S("noTamingData"); } else { labelResult.Text = Loc.S("notEnoughFoodToTame"); } numericUpDownCurrentTorpor.ValueSave = (decimal)(selectedSpecies.stats[(int)StatNames.Torpidity].BaseValue * (1 + selectedSpecies.stats[(int)StatNames.Torpidity].IncPerWildLevel * (level - 1))); nudTotalFood.Value = (decimal)(selectedSpecies.stats[(int)StatNames.Food].BaseValue * (1 + selectedSpecies.stats[(int)StatNames.Food].IncPerWildLevel * (level / 7))); // approximating the food level nudCurrentFood.Value = nudTotalFood.Value; UpdateTimeToFeedAll(enoughFood); //// quicktame infos if (foodAmountUsed.Any()) { quickTamingInfos = Taming.QuickInfoOneFood(selectedSpecies, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodControls[0].FoodName, foodControls[0].maxFood, foodControls[0].foodNameDisplay); // show raw meat or mejoberries as alternative (often used) for (int i = 1; i < usedFood.Count; i++) { if (usedFood[i] == "Raw Meat" || usedFood[i] == "Mejoberry") { quickTamingInfos += "\n\n" + Taming.QuickInfoOneFood(selectedSpecies, level, tamingSpeedMultiplier, tamingFoodRateMultiplier, foodControls[i].FoodName, foodControls[i].maxFood, foodControls[i].foodNameDisplay); break; } } quickTamingInfos += "\n\n" + koNumbers + "\n\n" + boneDamageAdjustersImmobilization + firstFeedingWaiting + kibbleRecipe; } }
public void SetSpecies(Species species) { if (species == null || selectedSpecies == species) { return; } selectedSpecies = species; if (species.taming == null) { NoTamingData(); return; } SuspendLayout(); string speciesName = species.name; linkLabelWikiPage.Text = "Wiki: " + speciesName; linkLabelWikiPage.Tag = speciesName; // bone damage adjusters boneDamageAdjustersImmobilization = Taming.boneDamageAdjustersImmobilization(selectedSpecies, out Dictionary <string, double> boneDamageAdjusters); int ib = 0; foreach (KeyValuePair <string, double> bd in boneDamageAdjusters) { ib++; if (ib >= rbBoneDamageAdjusters.Count) { RadioButton rbBD = new RadioButton(); gbWeaponDamage.Controls.Add(rbBD); rbBD.Location = new Point(6, 199 + 19 * ib); rbBD.AutoSize = false; rbBD.Size = new Size(194, 17); rbBoneDamageAdjusters.Add(rbBD); rbBoneDamageAdjusterValues.Add(1); rbBD.CheckedChanged += rbBoneDamage_CheckedChanged; } rbBoneDamageAdjusterValues[ib] = bd.Value; rbBoneDamageAdjusters[ib].Text = $"{Loc.s(bd.Key)} (× {bd.Value})"; rbBoneDamageAdjusters[ib].Visible = true; } for (int j = ib + 1; j < rbBoneDamageAdjusters.Count; j++) { rbBoneDamageAdjusters[j].Visible = false; } rbBoneDamageAdjusters[0].Checked = true; // bone damage adjusters adjusted updateCalculation = false; TamingData td = species.taming; kibbleRecipe = ""; // TODO replace with new kibble recipes //if (td.favoriteKibble != null && Kibbles.K.kibble.ContainsKey(td.favoriteKibble)) //{ // kibbleRecipe = "\n\nKibble:" + Kibbles.K.kibble[td.favoriteKibble].RecipeAsText(); //} foodDepletion = td.foodConsumptionBase * td.foodConsumptionMult * tamingFoodRateMultiplier; int i = 0; if (td.eats != null) { for (i = 0; i < td.eats.Count; i++) { string f = td.eats[i]; TamingFoodControl tf; if (i >= foodControls.Count) { tf = new TamingFoodControl(f); tf.valueChanged += UpdateTamingData; tf.Clicked += OnlyOneFood; foodControls.Add(tf); flpTamingFood.Controls.Add(tf); } else { tf = foodControls[i]; tf.FoodName = f; tf.Show(); } if (f == "Kibble") { tf.foodNameDisplay = $"Kibble ({td.favoriteKibble} {Loc.s("Egg")})"; } if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity + "× " + tf.foodNameDisplay; } } } for (int fci = foodControls.Count - 1; fci >= i; fci--) { foodControls[fci].Hide(); } if (i > 0) { foodControls[0].amount = Taming.foodAmountNeeded(species, (int)nudLevel.Value, tamingSpeedMultiplier, foodControls[0].FoodName, td.nonViolent); } updateCalculation = true; UpdateFirstFeedingWaiting(); UpdateTamingData(); ResumeLayout(); }
public void SetSpecies(Species species, bool forceRefresh = false) { if (species == null || (_selectedSpecies == species && !forceRefresh)) { return; } _selectedSpecies = species; if (species.taming == null) { NoTamingData(); return; } this.SuspendDrawing(); SuspendLayout(); string speciesName = species.name; linkLabelWikiPage.Text = "Wiki: " + speciesName; linkLabelWikiPage.Tag = speciesName; _tt.SetToolTip(linkLabelWikiPage, ArkWiki.WikiUrl(speciesName)); // bone damage adjusters _boneDamageAdjustersImmobilization = Taming.BoneDamageAdjustersImmobilization(_selectedSpecies, out Dictionary <string, double> boneDamageAdjusters); int ib = 0; foreach (KeyValuePair <string, double> bd in boneDamageAdjusters) { ib++; if (ib >= _rbBoneDamageAdjusters.Count) { RadioButton rbBD = new RadioButton(); flcBodyDamageMultipliers.Controls.Add(rbBD); flcBodyDamageMultipliers.SetFlowBreak(rbBD, true); rbBD.AutoSize = true; _rbBoneDamageAdjusters.Add(rbBD); _rbBoneDamageAdjusterValues.Add(1); rbBD.CheckedChanged += rbBoneDamage_CheckedChanged; } _rbBoneDamageAdjusterValues[ib] = bd.Value; _rbBoneDamageAdjusters[ib].Text = $"{Loc.S(bd.Key)} (× {bd.Value})"; _rbBoneDamageAdjusters[ib].Visible = true; } for (int j = ib + 1; j < _rbBoneDamageAdjusters.Count; j++) { _rbBoneDamageAdjusters[j].Visible = false; } _rbBoneDamageAdjusters[0].Checked = true; // bone damage adjusters adjusted _updateCalculation = false; TamingData td = species.taming; _kibbleRecipe = string.Empty; // list all recipes of kibbles that give a reasonable affinity (assuming that is larger or equal than 100) foreach (var k in Kibbles.K.kibble) { var kibbleName = $"{k.Key} Kibble"; var kibbleFood = Values.V.GetTamingFood(species, kibbleName); if (kibbleFood != null && kibbleFood.affinity >= 100) { _kibbleRecipe += $"\n\n{k.Key} Kibble:{k.Value.RecipeAsText()}"; } } _foodDepletion = td.foodConsumptionBase * td.foodConsumptionMult * _tamingFoodRateMultiplier; SetTamingFoodControls(species); _updateCalculation = true; UpdateFirstFeedingWaiting(); UpdateTamingData(); if (Properties.Settings.Default.TamingFoodOrderByTime) { SetOrderOfTamingFood(true, true); } ResumeLayout(); this.ResumeDrawing(); }
public void updateTamingData() { if (updateCalculation && speciesIndex >= 0) { updateKOCounting(); TimeSpan duration = new TimeSpan(); int narcoBerries = 0, narcotics = 0, bioToxines = 0, bonusLevel = 0; double te = 0, hunger = 0; bool enoughFood = false; var usedFood = new List <string>(); var foodAmount = new List <int>(); var foodAmountUsed = new List <int>(); quickTamingInfos = "n/a"; int level = (int)nudLevel.Value; if (Values.V.species[speciesIndex].taming.eats != null) { int foodCounter = Values.V.species[speciesIndex].taming.eats.Count; foreach (TamingFoodControl tfc in foodControls) { if (foodCounter == 0) { break; } foodCounter--; usedFood.Add(tfc.FoodName); foodAmount.Add(tfc.amount); tfc.maxFood = Taming.foodAmountNeeded(speciesIndex, level, evolutionEvent, tfc.FoodName, Values.V.species[speciesIndex].taming.nonViolent); tfc.tamingDuration = Taming.tamingDuration(speciesIndex, tfc.maxFood, tfc.FoodName, Values.V.species[speciesIndex].taming.nonViolent); } Taming.tamingTimes(speciesIndex, level, evolutionEvent, usedFood, foodAmount, out foodAmountUsed, out duration, out narcoBerries, out narcotics, out bioToxines, out te, out hunger, out bonusLevel, out enoughFood); for (int f = 0; f < foodAmountUsed.Count; f++) { foodControls[f].foodUsed = foodAmountUsed[f]; } } if (enoughFood) { labelResult.Text = "It takes " + Utils.durationUntil(duration) + " to tame the " + Values.V.speciesNames[speciesIndex] + "." + "\n\n" + "Taming Effectiveness: " + Math.Round(100 * te, 1) + " %" + "\nBonus-Level: +" + bonusLevel + " (total level after Taming: " + (nudLevel.Value + bonusLevel) + ")" + "\n\n" + $"Food has to drop by {hunger:F1} units." + "\n\n" + $"{narcoBerries} Narcoberries or\n" + $"{narcotics} Narcotics or\n" + $"{bioToxines} Bio Toxines are needed" + firstFeedingWaiting; if (foodAmountUsed.Count > 0) { quickTamingInfos = Taming.quickInfoOneFood(speciesIndex, level, evolutionEvent, foodControls[0].FoodName, foodControls[0].maxFood, foodControls[0].foodNameDisplay); // show raw meat or mejoberries as alternative (often used) for (int i = 1; i < usedFood.Count; i++) { if (usedFood[i] == "Raw Meat" || usedFood[i] == "Mejoberry") { quickTamingInfos += "\n\n" + Taming.quickInfoOneFood(speciesIndex, level, evolutionEvent, foodControls[i].FoodName, foodControls[i].maxFood, foodControls[i].foodNameDisplay); break; } } quickTamingInfos += "\n\n" + koNumbers + "\n\n" + boneDamageAdjusters + firstFeedingWaiting; } } else if (foodAmountUsed.Count == 0) { labelResult.Text = "no taming-data available"; } else { labelResult.Text = "Not enough food to tame the creature!"; } numericUpDownCurrentTorpor.Value = (decimal)(Values.V.species[speciesIndex].stats[7].BaseValue * (1 + Values.V.species[speciesIndex].stats[7].IncPerWildLevel * (level - 1))); nudCurrentFood.Value = (decimal)(Values.V.species[speciesIndex].stats[3].BaseValue * (1 + Values.V.species[speciesIndex].stats[3].IncPerWildLevel * (level / 7))); } }
public void setSpeciesIndex(int speciesIndex) { if (speciesIndex >= 0 && Values.V.species[speciesIndex].taming != null && this.speciesIndex != speciesIndex) { this.SuspendLayout(); this.speciesIndex = speciesIndex; // bone damage adjusters Dictionary <double, string> boneDamageAdjusters = new Dictionary <double, string>(); boneDamageAdjustersImmobilization = Taming.boneDamageAdjustersImmobilization(speciesIndex, out boneDamageAdjusters); int ib = 0; foreach (KeyValuePair <double, string> bd in boneDamageAdjusters) { ib++; if (ib >= rbBoneDamageAdjusters.Count) { RadioButton rbBD = new RadioButton(); gbWeaponDamage.Controls.Add(rbBD); rbBD.Location = new Point(6, 173 + 19 * ib); rbBD.AutoSize = false; rbBD.Size = new Size(194, 17); rbBoneDamageAdjusters.Add(rbBD); rbBoneDamageAdjusterValues.Add(1); rbBD.CheckedChanged += new System.EventHandler(this.rbBoneDamage_CheckedChanged); } rbBoneDamageAdjusterValues[ib] = bd.Key; rbBoneDamageAdjusters[ib].Text = bd.Value + " (" + bd.Key.ToString() + "×)"; rbBoneDamageAdjusters[ib].Visible = true; } for (int j = ib + 1; j < rbBoneDamageAdjusters.Count; j++) { rbBoneDamageAdjusters[j].Visible = false; } rbBoneDamageAdjusters[0].Checked = true; // bone damage adjusters adjusted updateCalculation = false; TamingData td = Values.V.species[speciesIndex].taming; favoriteKibble = td.favoriteKibble; foodDepletion = td.foodConsumptionBase * td.foodConsumptionMult * tamingFoodRateMultiplier; TamingFoodControl tf; int i = 0; if (td.eats != null) { for (i = 0; i < td.eats.Count; i++) { string f = td.eats[i]; if (i >= foodControls.Count) { tf = new TamingFoodControl(f); tf.Location = new Point(20, 80 + 45 * i); tf.valueChanged += new TamingFoodControl.ValueChangedEventHandler(updateTamingData); tf.Clicked += new TamingFoodControl.ClickedEventHandler(onlyOneFood); foodControls.Add(tf); Controls.Add(tf); } else { tf = foodControls[i]; tf.FoodName = f; tf.Show(); } if (f == "Kibble") { tf.foodNameDisplay = "Kibble (" + td.favoriteKibble + " Egg)"; } if (td.specialFoodValues != null && td.specialFoodValues.ContainsKey(f) && td.specialFoodValues[f].quantity > 1) { tf.foodNameDisplay = td.specialFoodValues[f].quantity.ToString() + "× " + tf.foodNameDisplay; } } } for (int fci = foodControls.Count - 1; fci >= i; fci--) { foodControls[fci].Hide(); } if (i > 0) { foodControls[0].amount = Taming.foodAmountNeeded(speciesIndex, (int)nudLevel.Value, tamingSpeedMultiplier, foodControls[0].FoodName, td.nonViolent); } updateCalculation = true; updateFirstFeedingWaiting(); updateTamingData(); ResumeLayout(); } }
/// <summary> /// Sets the taming food controls. /// </summary> private void SetTamingFoodControls(Species species) { var td = species.taming; int i = 0; if (td.eats != null) { var length = td.eats.Length; for (; i < length; i++) { string f = td.eats[i]; TamingFoodControl tf; // if Augmented are not wanted, and food control already exist, update it and hide it. if (!checkBoxAugmented.Checked && f.Contains("Augmented")) { if (i < _foodControls.Count) { tf = _foodControls[i]; tf.FoodName = f; tf.Hide(); } continue; } if (i >= _foodControls.Count) { tf = new TamingFoodControl(f); tf.valueChanged += UpdateTamingData; tf.Clicked += OnlyOneFood; _foodControls.Add(tf); flpTamingFood.Controls.Add(tf); } else { tf = _foodControls[i]; tf.FoodName = f; flpTamingFood.Controls.SetChildIndex(tf, i); tf.Show(); } // special cases where a creature eats multiple food items of one kind at once var food = Values.V.GetTamingFood(species, f); if (food != null && food.quantity > 1) { tf.foodNameDisplay = food.quantity + "× " + tf.foodNameDisplay; } } } for (int fci = _foodControls.Count - 1; fci >= i; fci--) { _foodControls[fci].FoodName = null; _foodControls[fci].Hide(); } if (i > 0) { _foodControls[0].amount = Taming.FoodAmountNeeded(species, (int)nudLevel.Value, _tamingSpeedMultiplier, _foodControls[0].FoodName, td.nonViolent); } }