Exemplo n.º 1
0
        public ShrineChanceData(ShrineChanceBehavior shrine)
        {
            var purchaseInteraction = shrine.GetComponent <PurchaseInteraction>();

            transform = new SerializableTransform(shrine.transform);
            successfulPurchaseCount = shrine.GetFieldValue <int>("successfulPurchaseCount");
            cost      = purchaseInteraction.cost;
            available = purchaseInteraction.available;
        }
Exemplo n.º 2
0
        private void CalculateSuccess(ShrineChanceBehavior instance)
        {
            var p = Convert.ToSingle(PercentageConfig.Value);

            // Turn mod off if value has no effect
            if (p == 100)
            {
                return;
            }

            ++count;
            var success    = instance.GetFieldValue <int>("successfulPurchaseCount");
            var fail       = count - success;
            var percentage = p / 100f;
            var chance     = instance.failureWeight / (instance.failureWeight + 12.2f) * 100;
            var chancemsg  = Mathf.Round(chance).ToString();

            if (p < 100 && instance.maxPurchaseCount < 3)
            {
                var newfailureWeight = 10.1f * Mathf.Pow(percentage, fail);

                if (MessageConfig.Value)
                {
                    if (instance.failureWeight != newfailureWeight)
                    {
                        sendChatMessage("<color=#e7543a>Lose! </color><color=#8296ae>with a </color><color=#ffffff>" + chancemsg + "% </color><color=#8296ae>chance to fail.</color>");
                    }
                    else
                    {
                        sendChatMessage("<color=#efeb1c>Win! </color><color=#8296ae>with a </color><color=#ffffff>" + chancemsg + "% </color><color=#8296ae>chance to fail.</color>");
                    }
                }

                instance.failureWeight = newfailureWeight;
            }
            // InfiniteChance support
            else
            {
                if (MessageConfig.Value)
                {
                    sendChatMessage("<color=#efeb1c>" + chancemsg + "% </color><color=#8296ae>chance to fail.</color>");
                }

                instance.failureWeight *= percentage;
            }

            if (success >= instance.maxPurchaseCount)
            {
                count = 0;
            }
        }