mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* update recipes to use mutation scripts * additional refactoring * . * update proficiency code * foolproof salvage code is still needed until recipes are added * add comment * add rare foolproof * update sandstone * adding sandstone mutation * update RecipeManager_New recipes for foolproof salvage * add RecipeManager_New caching * finish removing ClearRecipe() * update comments * update defense imbues to include shields, as per base recipe * improved UpdateObject server sync
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
|
|
using ACE.Common;
|
|
using ACE.Server.WorldObjects;
|
|
|
|
namespace ACE.Server.Entity.Mutations
|
|
{
|
|
public class Mutation
|
|
{
|
|
public List<float> Chances = new List<float>();
|
|
|
|
public List<MutationOutcome> Outcomes = new List<MutationOutcome>();
|
|
|
|
public bool TryMutate(WorldObject wo, int tier, double rng)
|
|
{
|
|
// if at least 6 tiers are defined,
|
|
// if we are rolling for a higher tier,
|
|
// fall back on highest tier?
|
|
if (Chances.Count >= 6 && tier > Chances.Count)
|
|
tier = Chances.Count;
|
|
|
|
if (tier < 1 || tier > Chances.Count)
|
|
return false;
|
|
|
|
// does it pass the roll to mutate for the tier?
|
|
if (rng >= Chances[tier - 1])
|
|
return false;
|
|
|
|
// roll again to select the mutations
|
|
rng = ThreadSafeRandom.Next(0.0f, 1.0f);
|
|
|
|
var mutated = false;
|
|
foreach (var outcome in Outcomes)
|
|
mutated |= outcome.TryMutate(wo, rng);
|
|
|
|
return mutated;
|
|
}
|
|
}
|
|
}
|