Example #1
0
        public static void FinalizeAction(BattleSetup setup, PacketHitList parent)
        {
            Scripting.ScriptManager.InvokeSub("AfterActionTaken", setup);

            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                if (setup.AttackerMap.MapType == Enums.MapType.Standard) {
                    setup.ExpGained /= 2;
                }
                if (setup.ExpGained > 0) {

                    if (((Recruit)setup.Attacker).Owner.Player.PartyID == null) {
                        if (!(setup.Attacker.Level == Exp.ExpManager.Exp.MaxLevels)) {
                            Scripting.ScriptManager.InvokeSub("PlayerEXP", setup.packetStack, ((Recruit)setup.Attacker).Owner, setup.ExpGained);

                            CheckPlayerLevelUp(setup.PacketStack, ((Recruit)setup.Attacker).Owner);
                        }
                    } else {
                        Party party = PartyManager.FindPlayerParty(((Recruit)setup.Attacker).Owner);
                        if (party != null) {
                            party.HandoutExp(((Recruit)setup.Attacker).Owner, setup.ExpGained, setup.PacketStack);
                        }
                    }
                }
                //setup.PacketStack.AddPacket(((Recruit)setup.Attacker).Owner, PacketBuilder.CreateBattleDivider());
            }

            // Disable caching and build the hitlist to allow for post-processing
            setup.PacketStack.CachingEnabled = false;

            for (int i = 0; i < setup.PacketStack.HitList.Count; i++) {
                if (setup.PacketStack.HitList.ValueByIndex(i).ContainsPacket("battlemsg") && parent == null) {
                    setup.PacketStack.AddPacket(setup.PacketStack.HitList.KeyByIndex(i), PacketBuilder.CreateBattleDivider());
                }

            }

            if (parent != null) {
                parent.AddHitList(setup.PacketStack);
            } else {
                PacketHitList.MethodEnded(ref setup.packetStack);
            }
        }