Example #1
0
        public static void Read(BinaryReader reader)
        {
            if (Main.netMode == NetmodeID.MultiplayerClient)
            {
                ProceduralStaff staff = (ProceduralStaff)Main.item[reader.ReadInt32()].modItem;

                staff.Staff = Staff.Staffs[reader.ReadInt32()];

                staff.Gem      = StaffGem.Gems[reader.ReadInt32()];
                staff.Ornament = StaffOrnament.Ornament[reader.ReadInt32()];
                staff.Dps      = reader.ReadSingle();
                staff.EnemyDef = reader.ReadInt32();
                staff.Initialize();
            }
        }
Example #2
0
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            Message msg = (Message)reader.ReadByte();
            Dictionary <DataTag, object> tags = new Dictionary <DataTag, object>();

            foreach (DataTag tag in dataTags[msg])
            {
                tags.Add(tag, tag.read(reader));
            }
            switch (msg)
            {
            //case Message.InitProjEleDmg:
            //    if (!Main.projectile.IndexInRange((int)tags[DataTag.projId])) break;
            //    Projectile p = Main.projectile[(int)tags[DataTag.projId]];
            //    try
            //    {
            //        kProjectile proj = p.GetGlobalProjectile<kProjectile>();
            //        proj.elementalDamage = new Dictionary<ELEMENT, int>()
            //        {
            //            { ELEMENT.FIRE, (int)tags[DataTag.fire] },
            //            { ELEMENT.COLD, (int)tags[DataTag.cold] },
            //            { ELEMENT.LIGHTNING, (int)tags[DataTag.lightning] },
            //            { ELEMENT.SHADOW, (int)tags[DataTag.shadow] }
            //        };
            //    }
            //    catch (SystemException e)
            //    {
            //        Main.NewText(e.ToString());
            //    }
            //    break;
            case Message.SyncStats:
                if (Main.netMode == 2)
                {
                    PlayerCharacter character = Main.player[(int)tags[DataTag.playerId]].GetModPlayer <PlayerCharacter>();
                    character.level = (int)tags[DataTag.amount];
                    character.baseStats[STAT.RESILIENCE] = (int)tags[DataTag.resilience];
                    character.baseStats[STAT.QUICKNESS]  = (int)tags[DataTag.quickness];
                    character.baseStats[STAT.POTENCY]    = (int)tags[DataTag.potency];
                    character.baseStats[STAT.WITS]       = (int)tags[DataTag.wits];
                }
                break;

            case Message.SyncLevel:
                if (Main.netMode == 2)
                {
                    Main.player[(int)tags[DataTag.playerId]].GetModPlayer <PlayerCharacter>().level = (int)tags[DataTag.amount];
                }
                break;

            case Message.CreateProjectile:
                if (Main.netMode == 2)
                {
                    Projectile projectile = Main.projectile[(int)tags[DataTag.projId]];
                    projectile.owner = (int)tags[DataTag.playerId];
                    ProceduralSpellProj ps = (ProceduralSpellProj)projectile.modProjectile;
                    ps.source.glyphs[(byte)GLYPHTYPE.STAR].SetDefaults((int)tags[DataTag.glyph_star], true);
                    ps.source.glyphs[(byte)GLYPHTYPE.CROSS].SetDefaults((int)tags[DataTag.glyph_cross], true);
                    ps.source.glyphs[(byte)GLYPHTYPE.MOON].SetDefaults((int)tags[DataTag.glyph_moon], true);
                    projectile.damage = (int)tags[DataTag.damage];
                    int modifierCount = (int)tags[DataTag.modifierCount];
                    List <GlyphModifier> modifiers = new List <GlyphModifier>();
                    for (int i = 0; i < modifierCount; i += 1)
                    {
                        modifiers.Add(GlyphModifier.modifiers[reader.ReadInt32()]);
                    }
                    ps.source.modifierOverride = modifiers;
                    foreach (Item item in ps.source.glyphs)
                    {
                        Glyph glyph = (Glyph)item.modItem;
                        if (glyph.GetAIAction() != null)
                        {
                            ps.ai.Add(glyph.GetAIAction());
                        }
                        if (glyph.GetInitAction() != null)
                        {
                            ps.init.Add(glyph.GetInitAction());
                        }
                        if (glyph.GetImpactAction() != null)
                        {
                            ps.impact.Add(glyph.GetImpactAction());
                        }
                        if (glyph.GetKillAction() != null)
                        {
                            ps.kill.Add(glyph.GetKillAction());
                        }
                    }
                    foreach (GlyphModifier modifier in modifiers)
                    {
                        if (modifier.impact != null)
                        {
                            ps.impact.Add(modifier.impact);
                        }
                        if (modifier.draw != null)
                        {
                            ps.draw.Add(modifier.draw);
                        }
                        if (modifier.init != null)
                        {
                            ps.init.Add(modifier.init);
                        }
                    }
                    ps.Initialize();
                }
                break;

            case Message.AddXP:
                if (Main.netMode == 1)
                {
                    //Player player = Main.player[Main.myPlayer];
                    //if (Vector2.Distance(player.Center, Main.npc[(int)tags[DataTag.npcId]].Center) > 1024)
                    //    break;
                    PlayerCharacter character = Main.LocalPlayer.GetModPlayer <PlayerCharacter>();
                    character.AddXP((int)tags[DataTag.amount]);
                }
                break;

            case Message.SyncSpear:
                ProceduralSpear spear = (ProceduralSpear)Main.projectile[(int)tags[DataTag.projId]].modProjectile;
                spear.blade  = SwordBlade.blades[(int)tags[DataTag.partPrimary]];
                spear.hilt   = SwordHilt.hilts[(int)tags[DataTag.partSecondary]];
                spear.accent = SwordAccent.accents[(int)tags[DataTag.partTertiary]];
                if (Main.netMode == 1)
                {
                    spear.Initialize();
                }
                break;

            case Message.SwordInit:
                if (Main.netMode == 1)
                {
                    ProceduralSword sword = (ProceduralSword)Main.item[(int)tags[DataTag.itemId]].modItem;
                    sword.blade  = SwordBlade.blades[(int)tags[DataTag.partPrimary]];
                    sword.hilt   = SwordHilt.hilts[(int)tags[DataTag.partSecondary]];
                    sword.accent = SwordAccent.accents[(int)tags[DataTag.partTertiary]];
                    sword.dps    = (float)tags[DataTag.itemDps];
                    Main.NewText(sword.dps.ToString());
                    sword.enemyDef = (int)tags[DataTag.itemDef];
                    sword.Initialize();
                }
                break;

            case Message.StaffInit:
                if (Main.netMode == 1)
                {
                    ProceduralStaff staff = (ProceduralStaff)Main.item[(int)tags[DataTag.itemId]].modItem;
                    staff.staff    = Staff.staves[(int)tags[DataTag.partPrimary]];
                    staff.gem      = StaffGem.gems[(int)tags[DataTag.partSecondary]];
                    staff.ornament = StaffOrnament.ornament[(int)tags[DataTag.partTertiary]];
                    staff.dps      = (float)tags[DataTag.itemDps];
                    staff.enemyDef = (int)tags[DataTag.itemDef];
                    staff.Initialize();
                }
                break;

            case Message.BowInit:
                if (Main.netMode == 1)
                {
                    RangedWeapon bow = (RangedWeapon)Main.item[(int)tags[DataTag.itemId]].modItem;
                    bow.dps      = (float)tags[DataTag.itemDps];
                    bow.enemyDef = (int)tags[DataTag.itemDef];
                    bow.Initialize();
                }
                break;

            case Message.SyncHit:
                if (Main.netMode == 1)
                {
                    PlayerCharacter character = Main.player[(int)tags[DataTag.playerId]].GetModPlayer <PlayerCharacter>();
                    character.accuracyCounter = (float)tags[DataTag.amount_single];
                }
                break;

            case Message.SyncCritHit:
                if (Main.netMode == 1)
                {
                    PlayerCharacter character = Main.player[(int)tags[DataTag.playerId]].GetModPlayer <PlayerCharacter>();
                    character.critAccuracyCounter = (float)tags[DataTag.amount_single];
                }
                break;
            }
        }
Example #3
0
        public override void NPCLoot(NPC npc)
        {
            for (var i = 0; i < modifiers.Count; i++)
            {
                modifiers[i].NPCLoot(npc);
            }

            if (npc.lifeMax < 10)
            {
                return;
            }
            if (npc.friendly)
            {
                return;
            }
            if (npc.townNPC)
            {
                return;
            }

            if (Main.rand.Next(2500) < GetLevel(npc.type))
            {
                if (Main.rand.Next(8) == 0)
                {
                    Item.NewItem(npc.position, mod.ItemType <BlacksmithCrown>());
                }
                else
                {
                    Item.NewItem(npc.position, mod.ItemType <PermanenceCrown>());
                }
            }

            int level = GetLevel(npc.netID);

            Player player = Array.Find(Main.player, p => p.active);

            if (Main.netMode == 0)
            {
                player = Main.LocalPlayer;
            }
            else if (Main.player[npc.target].active)
            {
                player = Main.player[npc.target];
            }
            else
            {
                PlayerCharacter c = player.GetModPlayer <PlayerCharacter>();
                foreach (Player p in Main.player)
                {
                    if (p != null)
                    {
                        if (p.active)
                        {
                            if (p.GetModPlayer <PlayerCharacter>() != null)
                            {
                                if (p.GetModPlayer <PlayerCharacter>().level > c.level)
                                {
                                    player = p;
                                }
                            }
                        }
                    }
                }
            }
            PlayerCharacter character = player.GetModPlayer <PlayerCharacter>();
            int             life      = npc.type == NPCID.SolarCrawltipedeTail || npc.type == NPCID.SolarCrawltipedeBody || npc.type == NPCID.SolarCrawltipedeHead ? npc.lifeMax / 8 : npc.lifeMax;
            int             defFactor = (npc.defense < 0) ? 1 : npc.defense * life / (character.level + 10);
            int             baseExp   = Main.rand.Next((life + defFactor) / 5) + (life + defFactor) / 6;
            int             scaled    = Main.expertMode ? (int)(baseExp * 0.5) : baseExp;

            if (Main.netMode == 2)
            {
                ModPacket packet = mod.GetPacket();
                packet.Write((byte)Message.AddXP);
                packet.Write(scaled);
                packet.Write(npc.target);
                packet.Send();
            }
            else
            {
                character.AddXP(scaled);
            }

            if (level < Math.Min(character.level - 17, 70))
            {
                return;
            }

            float dps        = Math.Min((float)(Math.Pow(1.04, Math.Min(130, character.level)) * 9f), (float)(Math.Pow(1.023, level) * 15) + 14);
            int   assumedDef = !Main.hardMode ? 5 : character.level / 3;

            if (npc.FullName.Contains("Green Slime"))
            {
                if (Main.rand.Next(22) == 0)
                {
                    ProceduralSword.NewSword(mod, npc.position, SwordHilt.RandomHilt(SWORDTHEME.GENERIC), SwordBlade.slimeGreen, Main.rand.Next(3) < 1 ? SwordAccent.RandomAccent() : SwordAccent.none, dps, assumedDef);
                }
            }

            else if (npc.FullName.Contains("Blue Slime"))
            {
                if (Main.rand.Next(30) == 0)
                {
                    ProceduralSword.NewSword(mod, npc.position, SwordHilt.RandomHilt(SWORDTHEME.GENERIC), SwordBlade.slimeBlue, Main.rand.Next(2) < 1 ? SwordAccent.RandomAccent() : SwordAccent.none, dps, assumedDef);
                }
            }

            else if (Main.rand.Next((character.level < 5 ? 5 : (character.level < 10 ? 8 : 20))) == 0)
            {
                if (Main.rand.Next(5) == 0)
                {
                    Item.NewItem(npc.position, RangedWeapon.NewRangedWeapon(mod, npc.position, level, character.level, dps, assumedDef), Main.rand.Next(30, 90));
                }
                else if (Main.rand.Next(9) < 5)
                {
                    ProceduralSword.GenerateSword(mod, npc.position, GetTheme(player), dps, assumedDef);
                }
                else
                {
                    ProceduralStaff.GenerateStaff(mod, npc.position, GetStaffTheme(player), dps * 1.2f, assumedDef);
                }
            }

            else if (Main.rand.Next(40) == 0)
            {
                Item item = Main.item[Item.NewItem(new Rectangle((int)npc.position.X, (int)npc.position.Y, npc.width, npc.height), mod.ItemType(Glyph.GetRandom()))];
                if (item.modItem is Glyph && Main.netMode == 0)
                {
                    ((Glyph)item.modItem).Randomize();
                }
            }

            else if (npc.FullName.EndsWith(" Eye") && level < 20)
            {
                if (Main.rand.Next(20) == 0)
                {
                    ProceduralSword.NewSword(mod, npc.position, SwordHilt.RandomHilt(SWORDTHEME.MONSTROUS), SwordBlade.demonEye, Main.rand.Next(5) < 2 ? SwordAccent.RandomAccent() : SwordAccent.none, dps, assumedDef);
                }
                else if (Main.rand.Next(15) == 0)
                {
                    ProceduralSword.NewSword(mod, npc.position, SwordHilt.RandomHilt(SWORDTHEME.GENERIC), SwordBlade.demonEye, SwordAccent.none, dps, assumedDef);
                }
            }
        }
Example #4
0
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            Message msg = (Message)reader.ReadByte();
            Dictionary <DataTag, object> tags = new Dictionary <DataTag, object>();

            foreach (DataTag tag in dataTags[msg])
            {
                tags.Add(tag, tag.read(reader));
            }
            switch (msg)
            {
            //case Message.InitProjEleDmg:
            //    if (!Main.projectile.IndexInRange((int)tags[DataTag.projId])) break;
            //    Projectile p = Main.projectile[(int)tags[DataTag.projId]];
            //    try
            //    {
            //        kProjectile proj = p.GetGlobalProjectile<kProjectile>();
            //        proj.elementalDamage = new Dictionary<ELEMENT, int>()
            //        {
            //            { ELEMENT.FIRE, (int)tags[DataTag.fire] },
            //            { ELEMENT.COLD, (int)tags[DataTag.cold] },
            //            { ELEMENT.LIGHTNING, (int)tags[DataTag.lightning] },
            //            { ELEMENT.SHADOW, (int)tags[DataTag.shadow] }
            //        };
            //    }
            //    catch (SystemException e)
            //    {
            //        Main.NewText(e.ToString());
            //    }
            //    break;
            case Message.NPCEleDmg:
                if (Main.netMode == 1)
                {
                    NPC  npc = Main.npc[(int)tags[DataTag.npcId]];
                    kNPC kn  = npc.GetGlobalNPC <kNPC>();
                    Dictionary <ELEMENT, bool> haselement = new Dictionary <ELEMENT, bool>()
                    {
                        { ELEMENT.FIRE, (bool)tags[DataTag.flag] },
                        { ELEMENT.COLD, (bool)tags[DataTag.flag2] },
                        { ELEMENT.LIGHTNING, (bool)tags[DataTag.flag3] },
                        { ELEMENT.SHADOW, (bool)tags[DataTag.flag4] }
                    };
                    int count = 0;
                    foreach (ELEMENT element in Enum.GetValues(typeof(ELEMENT)))
                    {
                        if (haselement[element])
                        {
                            count += 1;
                        }
                    }
                    int portionsize = (int)Math.Round((double)npc.damage * kNPC.ELE_DMG_MODIFIER / 2.0 / count);
                    foreach (ELEMENT element in Enum.GetValues(typeof(ELEMENT)))
                    {
                        if (haselement[element])
                        {
                            kn.elementalDamage[element] = Math.Max(1, portionsize);
                        }
                    }
                    kn.dealseledmg = count > 0;
                }
                break;

            case Message.PrefixNPC:
                if (Main.netMode == 1)
                {
                    NPC  npc = Main.npc[(int)tags[DataTag.npcId]];
                    kNPC kn  = npc.GetGlobalNPC <kNPC>();
                    for (int i = 0; i < (int)tags[DataTag.amount]; i += 1)
                    {
                        NPCModifier modifier = kn.modifierFuncs[reader.ReadInt32()].Invoke(kn, npc);
                        modifier.Read(reader);
                        modifier.Apply();
                        kn.modifiers.Add(modifier);
                    }
                    kn.MakeNotable(npc);
                }
                break;

            case Message.SyncStats:
                if (Main.netMode == 2)
                {
                    PlayerCharacter character = Main.player[(int)tags[DataTag.playerId]].GetModPlayer <PlayerCharacter>();
                    character.level = (int)tags[DataTag.amount];
                    character.baseStats[STAT.RESILIENCE] = (int)tags[DataTag.resilience];
                    character.baseStats[STAT.QUICKNESS]  = (int)tags[DataTag.quickness];
                    character.baseStats[STAT.POTENCY]    = (int)tags[DataTag.potency];
                    character.baseStats[STAT.WITS]       = (int)tags[DataTag.wits];
                }
                break;

            case Message.SyncLevel:
                if (Main.netMode == 2)
                {
                    Main.player[(int)tags[DataTag.playerId]].GetModPlayer <PlayerCharacter>().level = (int)tags[DataTag.amount];
                }
                break;

            case Message.CreateProjectile:
                try
                {
                    if (Main.netMode == 1)
                    {
                        if ((int)tags[DataTag.playerId] == Main.myPlayer)
                        {
                            break;
                        }
                    }

                    int modifierCount = (int)tags[DataTag.modifierCount];
                    List <GlyphModifier> modifiers = new List <GlyphModifier>();
                    for (int i = 0; i < modifierCount; i += 1)
                    {
                        modifiers.Add(GlyphModifier.modifiers[reader.ReadInt32()]);
                    }

                    Projectile projectile = Main.projectile[(int)tags[DataTag.projId]];
                    if (projectile == null)
                    {
                        break;
                    }
                    projectile.owner = (int)tags[DataTag.playerId];
                    if (!(projectile.modProjectile is ProceduralSpellProj))
                    {
                        break;
                    }
                    ProceduralSpellProj ps = (ProceduralSpellProj)projectile.modProjectile;
                    ps.source        = new ProceduralSpell(mod);
                    ps.source.glyphs = new Item[3];
                    for (int i = 0; i < ps.source.glyphs.Length; i += 1)
                    {
                        ps.source.glyphs[i] = new Item();
                        ps.source.glyphs[i].SetDefaults(0, true);
                    }
                    ps.source.glyphs[(byte)GLYPHTYPE.STAR].SetDefaults((int)tags[DataTag.glyph_star], true);
                    ps.source.glyphs[(byte)GLYPHTYPE.CROSS].SetDefaults((int)tags[DataTag.glyph_cross], true);
                    ps.source.glyphs[(byte)GLYPHTYPE.MOON].SetDefaults((int)tags[DataTag.glyph_moon], true);
                    projectile.damage = (int)tags[DataTag.damage];
                    projectile.minion = (bool)tags[DataTag.flag];
                    try
                    {
                        if (projectile.minion)
                        {
                            ps.caster = Main.projectile[(int)tags[DataTag.entityId]];
                        }
                        else if (projectile.hostile)
                        {
                            ps.caster = Main.npc[(int)tags[DataTag.entityId]];
                        }
                        else
                        {
                            ps.caster = Main.player[(int)tags[DataTag.entityId]];
                        }
                    }
                    catch (SystemException e)
                    {
                        ErrorLogger.Log("Source-assignment failed, aborting...");
                        break;
                    }
                    ps.source.modifierOverride = modifiers;
                    foreach (Item item in ps.source.glyphs)
                    {
                        if (item != null)
                        {
                            Glyph glyph = (Glyph)item.modItem;
                            if (glyph.GetAIAction() != null)
                            {
                                ps.ai.Add(glyph.GetAIAction());
                            }
                            if (glyph.GetInitAction() != null)
                            {
                                ps.init.Add(glyph.GetInitAction());
                            }
                            if (glyph.GetImpactAction() != null)
                            {
                                ps.impact.Add(glyph.GetImpactAction());
                            }
                            if (glyph.GetKillAction() != null)
                            {
                                ps.kill.Add(glyph.GetKillAction());
                            }
                        }
                    }
                    foreach (GlyphModifier modifier in modifiers)
                    {
                        if (modifier.impact != null)
                        {
                            ps.impact.Add(modifier.impact);
                        }
                        if (modifier.draw != null)
                        {
                            ps.draw.Add(modifier.draw);
                        }
                        if (modifier.init != null)
                        {
                            ps.init.Add(modifier.init);
                        }
                    }
                    ps.Initialize();

                    if (Main.netMode == 2)
                    {
                        ModPacket packet = mod.GetPacket();
                        packet.Write((byte)Message.CreateProjectile);
                        packet.Write(projectile.owner);
                        packet.Write(projectile.whoAmI);
                        packet.Write(ps.source.glyphs[(byte)GLYPHTYPE.STAR].type);
                        packet.Write(ps.source.glyphs[(byte)GLYPHTYPE.CROSS].type);
                        packet.Write(ps.source.glyphs[(byte)GLYPHTYPE.MOON].type);
                        packet.Write(projectile.damage);
                        packet.Write(projectile.minion);
                        packet.Write(ps.caster.whoAmI);
                        List <GlyphModifier> mods = modifiers;
                        packet.Write(mods.Count);
                        for (int j = 0; j < mods.Count; j += 1)
                        {
                            packet.Write(mods[j].id);
                        }
                        packet.Send();
                    }
                }
                catch (SystemException e)
                {
                    ErrorLogger.Log("Error handling packet: " + msg.ToString() + " on " + (Main.netMode == 2 ? "serverside" : "clientside") + ", full error trace: " + e.ToString());
                }
                break;

            case Message.AddXP:
                if (Main.netMode == 1)
                {
                    //Player player = Main.player[Main.myPlayer];
                    //if (Vector2.Distance(player.Center, Main.npc[(int)tags[DataTag.npcId]].Center) > 1024)
                    //    break;
                    PlayerCharacter character = Main.LocalPlayer.GetModPlayer <PlayerCharacter>();
                    character.AddXP((int)tags[DataTag.amount]);
                }
                break;

            case Message.SyncSpear:
                ProceduralSpear spear = (ProceduralSpear)Main.projectile[(int)tags[DataTag.projId]].modProjectile;
                spear.blade  = SwordBlade.blades[(int)tags[DataTag.partPrimary]];
                spear.hilt   = SwordHilt.hilts[(int)tags[DataTag.partSecondary]];
                spear.accent = SwordAccent.accents[(int)tags[DataTag.partTertiary]];
                if (Main.netMode == 1)
                {
                    spear.Initialize();
                }
                break;

            case Message.SwordInit:
                if (Main.netMode == 1)
                {
                    ProceduralSword sword = (ProceduralSword)Main.item[(int)tags[DataTag.itemId]].modItem;
                    sword.blade  = SwordBlade.blades[(int)tags[DataTag.partPrimary]];
                    sword.hilt   = SwordHilt.hilts[(int)tags[DataTag.partSecondary]];
                    sword.accent = SwordAccent.accents[(int)tags[DataTag.partTertiary]];
                    sword.dps    = (float)tags[DataTag.itemDps];
                    Main.NewText(sword.dps.ToString());
                    sword.enemyDef = (int)tags[DataTag.itemDef];
                    sword.Initialize();
                }
                break;

            case Message.StaffInit:
                if (Main.netMode == 1)
                {
                    ProceduralStaff staff = (ProceduralStaff)Main.item[(int)tags[DataTag.itemId]].modItem;
                    staff.staff    = Staff.staves[(int)tags[DataTag.partPrimary]];
                    staff.gem      = StaffGem.gems[(int)tags[DataTag.partSecondary]];
                    staff.ornament = StaffOrnament.ornament[(int)tags[DataTag.partTertiary]];
                    staff.dps      = (float)tags[DataTag.itemDps];
                    staff.enemyDef = (int)tags[DataTag.itemDef];
                    staff.Initialize();
                }
                break;

            case Message.BowInit:
                if (Main.netMode == 1)
                {
                    RangedWeapon bow = (RangedWeapon)Main.item[(int)tags[DataTag.itemId]].modItem;
                    bow.dps      = (float)tags[DataTag.itemDps];
                    bow.enemyDef = (int)tags[DataTag.itemDef];
                    bow.Initialize();
                }
                break;

            case Message.SyncHit:
                if (Main.netMode == 1)
                {
                    PlayerCharacter character = Main.player[(int)tags[DataTag.playerId]].GetModPlayer <PlayerCharacter>();
                    character.accuracyCounter = (float)tags[DataTag.amount_single];
                }
                break;

            case Message.SyncCritHit:
                if (Main.netMode == 1)
                {
                    PlayerCharacter character = Main.player[(int)tags[DataTag.playerId]].GetModPlayer <PlayerCharacter>();
                    character.critAccuracyCounter = (float)tags[DataTag.amount_single];
                }
                break;
            }
        }