Пример #1
0
        public object[] ReflectiveWard(CombatResult owner, CombatResult target)
        {
            if (target.SentHit)
            {
                if (Program.Chance(tier))
                {
                    long totalDamage = 0;
                    for (int i = 0; i < target.baseDamage.Length; i++)
                    {
                        totalDamage += NumbersM.FloorParse <long>
                                           ((target.baseDamage[i]
                                             + target.bonusDamage[i]) *
                                           target.damageMultiplier[i]);

                        target.damageMultiplier[i] = 0;
                    }
                    long returned = NumbersM.FloorParse <long>(totalDamage *
                                                               (5.00 + tier) / 100);
                    target.character.TakeDamage(returned);
                    owner.perkProcs.Add($"Returned {returned} damage to {target.Name}");
                }
            }

            return(R(owner, target));
        }
Пример #2
0
 static long UpgradeStat(long stat, double increase)
 {
     if (stat > 0)
     {
         stat = Verify.Min(NumbersM.FloorParse <long>(stat * increase), stat + 1);
     }
     else if (stat < 0)
     {
         stat = Verify.Min(NumbersM.FloorParse <long>(stat * increase), stat - 1);
     }
     return(stat);
 }
Пример #3
0
 static int UpgradeStat(int stat, double increase)
 {
     if (stat > 0)
     {
         stat = Verify.Min(NumbersM.FloorParse <int>(stat * increase), stat + 1);
     }
     else if (stat < 0)
     {
         stat = Verify.Min(NumbersM.FloorParse <int>(stat * increase), stat - 1);
     }
     return(stat);
 }
Пример #4
0
        internal Item ScaleArmor(Item item, int target)
        {
            double m = ((double)target) / item.tier;
            double n = m - 1;

            #region Excluded stats
            long l = 0;
            foreach (int r in item.damage)
            {
                l += r > 0 ? NumbersM.CeilParse <long>(n * r * damage) : 0;
            }
            l += NumbersM.CeilParse <long>(
                +(item.durability + item.agility
                  + Convert.ToInt64(item.critChance)
                  + Convert.ToInt64(item.critMult)
                  + (item.perk != null ? (item.perk.tier + 1) * perk : 0)
                  ) * n);

            #endregion

            #region Included Stats
            long i =
                (item.healthBuff != 0 ? health : 0)
                + (item.staminaBuff != 0 ? stamina : 0);
            foreach (var d in item.resistance)
            {
                i += d != 0 ? resistance : 0;
            }
            #endregion

            //Update stats
            item.healthBuff = item.healthBuff != 0 ?
                              item.healthBuff = NumbersM.CeilParse <long>(
                (item.healthBuff * m) +
                ((health * (l + 0.00) / i) / health)) : 0;

            item.staminaBuff = item.staminaBuff != 0 ?
                               item.staminaBuff = NumbersM.CeilParse <int>(
                (item.staminaBuff * m) +
                ((stamina * (l + 0.00) / i) / stamina)) : 0;

            for (int k = 0; k < item.resistance.Length; k++)
            {
                if (item.resistance[k] != 0)
                {
                    item.resistance[k] = NumbersM.FloorParse <int>(
                        (item.resistance[k] * m) +
                        ((resistance * (l + 0.00) / i) / resistance));
                }
            }

            return(item);
        }
Пример #5
0
        public async Task RecruitNPC()
        {
            Player player = Player.Load(Context.BotUser);

            if (!player.IsEncounter("NPC"))
            {
                await DUtils.DeleteBothMsg(Context, await ReplyAsync($"{player.name} is not in an encounter with an NPC"));
            }
            else if (player.Party == null)
            {
                await DUtils.DeleteBothMsg(Context, await ReplyAsync($"{player.name} must be in a Party to recruit an NPC"));
            }
            else if (player.Party.UpdateFollower(player.Encounter.npc))
            {
                await DUtils.DeleteBothMsg(Context, await ReplyAsync($"This NPC is already in your party."));
            }
            else if (player.Encounter.npc.profession == ReferenceData.Profession.Peasant)
            {
                await DUtils.DeleteBothMsg(Context, await ReplyAsync($"```{Dialog.GetDialog(player.Encounter.npc, Dialog.peasantRecruit)}```"));
            }
            else if (player.Party.MemberCount >= 4)
            {
                await DUtils.DeleteBothMsg(Context, await ReplyAsync($"{player.name}'s party is full."));
            }
            else
            {
                NPC n = player.Encounter.npc;
                if ((player.level * 0.9) - player.stats.GetCHA() > n.level && player.userid != 201875246091993088)
                {
                    await DUtils.DeleteBothMsg(Context, await ReplyAsync(
                                                   $"```{Dialog.GetDialog(n, Dialog.weakRecruit)}```"));
                }
                else
                {
                    long cost = NumbersM.FloorParse <long>(((player.level + player.Rank() + n.level + n.Rank()) * 39)
                                                           * (1.00 - (Stats.recruitPricePerCha * player.stats.GetCHA())));

                    if (player.KCoins < cost)
                    {
                        await DUtils.DeleteBothMsg(Context, await ReplyAsync(
                                                       $"{player.name} does not have the required coins to recruit {n.displayName}. " +
                                                       $"Missing {cost - player.KCoins} from total {cost}"));
                    }
                    else
                    {
                        await ComfirmRecruitNPC(player, cost, Context.Channel);
                    }
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Return the health status
        /// </summary>
        /// <param name="result">Health status string</param>
        /// <param name="getLiveAprox">Get the name of the living state instead of exact hp</param>
        /// <returns>
        /// >= 0 Is alive
        /// -1 is Down, -2 Fainted, -3 Unconscious, -4 Dead, -5 Vaporized
        /// </returns>
        internal int HealthStatus(out string result, bool getLiveAprox = false)
        {
            var    mhp     = Health();
            double percent = ((double)health / mhp) * 100.00;

            if (IsDead())
            {
                result = EUI.brokenhealth;
                if (percent <= -100)
                {
                    result += " Vaporized";
                    return(-5);
                }
                else if (percent <= -80)
                {
                    result += " Dead";
                    return(-4);
                }
                else if (percent <= -60)
                {
                    result += " Unconscious";
                    return(-3);
                }
                else if (percent <= -45)
                {
                    result += " Fainted";
                    return(-2);
                }
                else
                {
                    result += " Down";
                    return(-1);
                }
            }
            else
            {
                if (getLiveAprox)
                {
                    result = GetAproxHealth(mhp);
                }
                else
                {
                    result = $"{EUI.health} {Utils.Display(health)}/{Utils.Display(mhp)}";
                }
            }
            return(NumbersM.FloorParse <int>(percent / 10));
        }
Пример #7
0
        public static string Exploit(Player player, string tool, string item)
        {
            Tools tools = player.Tools;
            int   level = player.Area.GetAreaFloorLevel(Program.rng, player.AreaInfo.floor);

            (int tier, int tlevel, string name) = tools.CanUse(player, tool);

            player.NewEncounter(Encounter.Names.Loot, true);
            double mult = Collect(player, item, level, tier * tlevel);

            long xp = NumbersM.FloorParse <long>((player.level + level) * mult);

            tools.AfterCollect(player, tool, xp);

            player.SaveFileMongo();
            return($"+{xp} {name} xp");
        }
Пример #8
0
        private static EmbedFieldBuilder RestRecover(CharacterMotherClass character, double totalSeconds)
        {
            long maxHealth  = character.Health();
            int  maxStamina = character.Stamina();

            int dex = character.stats.GetDEX();

            double hpps       = RestorePerSeconds(dex, true);
            long   hpRestored = Math.Min(maxHealth - character.health,
                                         NumbersM.FloorParse <long>(maxHealth * hpps * totalSeconds));

            character.health += hpRestored;

            double spps       = RestorePerSeconds(dex, false);
            int    spRestored = Math.Min(maxStamina - character.stamina,
                                         NumbersM.FloorParse <int>(maxStamina * spps * totalSeconds));

            character.stamina += spRestored;

            return(DUtils.NewField(character.name,
                                   $"Restored {hpRestored} Health and {spRestored} Stamina", true));
        }
Пример #9
0
 internal static int IndexFromRate(int length, double rng)
 => NumbersM.FloorParse <int>(Math.Pow(length, 0.01 * rng) - 1);
Пример #10
0
        public async Task EventShop(SocketReaction reaction, IUserMessage msg)
        {
            string emote = reaction.Emote.ToString();

            if (emote == EUI.uturn)
            {
                if (data != null)
                {
                    await OngoingEvent.Ongoing.OpenShop(player, msg.Channel);
                }

                else
                {
                    await player.NewUI(await msg.Channel.SendMessageAsync(
                                           embed: OngoingEvent.Ongoing.EmbedInfo()), MsgType.Event);
                }

                return;
            }

            int i = data != null?int.Parse(data) : EUI.GetNum(emote) - 1;

            if (data == null)
            {
                await OngoingEvent.Ongoing.OpenShop(player, msg.Channel, i, true);
            }
            else if (i >= 0 && i < OngoingEvent.Ongoing.eventinfo.shop.stock.Length) //Is buying an item by count
            {
                //Drop from start 1 to index
                int amount   = 0;
                var shop     = OngoingEvent.Ongoing.eventinfo.shop;
                int currency = player.Currency.Get(shop.currency);

                if (emote == EUI.GetLetter(8))
                {
                    amount = 1;
                }
                else if (emote == EUI.GetLetter(21))
                {
                    amount = 5;
                }
                else if (emote == EUI.GetLetter(23))
                {
                    amount = 10;
                }
                else if (emote == EUI.GetLetter(12))
                {
                    amount = NumbersM.FloorParse <int>(
                        ((double)currency) / shop.stock[i].count);
                }

                if (currency < shop.stock[i].count * amount)
                {
                    await msg.Channel.SendMessageAsync($"Missing {shop.stock[i].count * amount - currency} {shop.currency} for this purchase");
                }
                else
                {
                    string collected = "";
                    if (shop.Stackable(i))
                    {
                        StackedItems item = new StackedItems(shop.ParseItem(i, player.level), amount);
                        item.item.Scale(player.level);
                        if (player.CollectItem(item, true))
                        {
                            int price = shop.stock[i].count * amount;
                            collected += $"Bought {item} for {price} {shop.currency}";
                            player.Currency.Mod(shop.currency, -price);
                        }
                        else
                        {
                            collected = $"Inventory may not contain {item}";
                        }
                    }
                    else
                    {
                        string warning = null;
                        collected = null;
                        for (int k = 0; k < amount; k++)
                        {
                            Item item = shop.ParseItem(i, player.level);
                            item.Scale(player.level);
                            if (player.CollectItem(item, 1, true))
                            {
                                collected += $"Bought {item} for {shop.stock[i].count} {shop.currency}" + Environment.NewLine;
                            }
                            else
                            {
                                warning = $"Inventory full! Bought {k}/{amount} items";
                                amount  = k;
                            }
                        }

                        if (collected != null)
                        {
                            collected = $"```{collected}```" + warning;
                        }
                        else if (warning != null)
                        {
                            collected = warning;
                        }

                        if (amount > 0)
                        {
                            player.Currency.Mod(shop.currency, -(amount * shop.stock[i].count));
                        }
                    }

                    if (collected != null)
                    {
                        await msg.Channel.SendMessageAsync(collected);
                    }
                    await OngoingEvent.Ongoing.OpenShop(player, msg.Channel, i, true);
                }
            }
        }