Ejemplo n.º 1
0
        public static void BeforeMoveUsed(BattleSetup setup)
        {
            try {
                ExtraStatus status;
                setup.AttackerMultiplier = 1000;
                bool sayMove = false;
                bool semiInvul = false;

                //For forcing the next attack
                //of chargeup attacks (solarbeam/skull bash/razor wind/sky attack/dig/fly/etc.
                if (setup.Attacker.VolatileStatus.GetStatus("SolarBeam") != null) {
                    setup.moveSlot = -1;
                    setup.moveIndex = 218;
                    sayMove = true;
                } else if (setup.Attacker.VolatileStatus.GetStatus("SkullBash") != null) {
                    setup.moveSlot = -1;
                    setup.moveIndex = 424;
                    sayMove = true;
                } else if (setup.Attacker.VolatileStatus.GetStatus("RazorWind") != null) {
                    setup.moveSlot = -1;
                    setup.moveIndex = 243;
                    sayMove = true;
                } else if (setup.Attacker.VolatileStatus.GetStatus("SkyAttack") != null) {
                    setup.moveSlot = -1;
                    setup.moveIndex = 345;
                    sayMove = true;
                } else if (setup.Attacker.VolatileStatus.GetStatus("FocusPunch") != null) {
                    setup.moveSlot = -1;
                    setup.moveIndex = 441;
                    sayMove = true;
                } else if (setup.Attacker.VolatileStatus.GetStatus("Bide") != null) {
                    setup.moveSlot = -1;
                    setup.moveIndex = 248;
                    sayMove = true;
                } else if (setup.Attacker.VolatileStatus.GetStatus("Avalanche") != null) {
                    setup.moveSlot = -1;
                    setup.moveIndex = 362;
                    sayMove = true;
                } else if (setup.Attacker.VolatileStatus.GetStatus("VitalThrow") != null) {
                    setup.moveSlot = -1;
                    setup.moveIndex = 321;
                    sayMove = true;
                } else if (setup.Attacker.VolatileStatus.GetStatus("SkyDrop:1") != null) {
                    setup.moveSlot = -1;
                    setup.moveIndex = 640;
                    sayMove = true;
                } else {
                    status = setup.Attacker.VolatileStatus.GetStatus("SemiInvul");
                    if (status != null) {
                        if (status.Tag == "Dig") {
                            setup.moveSlot = -1;
                            setup.moveIndex = 146;
                            sayMove = true;
                        } else if (status.Tag == "Bounce") {
                            setup.moveSlot = -1;
                            setup.moveIndex = 73;
                            sayMove = true;
                        } else if (status.Tag == "Fly") {
                            setup.moveSlot = -1;
                            setup.moveIndex = 423;
                            sayMove = true;
                        } else if (status.Tag == "ShadowForce") {
                            setup.moveSlot = -1;
                            setup.moveIndex = 42;
                            sayMove = true;
                        } else if (status.Tag == "Dive") {
                            setup.moveSlot = -1;
                            setup.moveIndex = 297;
                            sayMove = true;
                        } else if (status.Tag == "PhantomForce") {
                            setup.moveSlot = -1;
                            setup.moveIndex = 739;
                            sayMove = true;
                        }
                        RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "SemiInvul", setup.PacketStack, false);
                        semiInvul = true;
                    }
                }

                //of rampage attacks
                status = setup.Attacker.VolatileStatus.GetStatus("Rampage");
                if (status != null) {

                        setup.moveSlot = -1;
                        setup.moveIndex = status.Tag.ToInt();
                        sayMove = true;
                }

                //of rolling attacks
                status = setup.Attacker.VolatileStatus.GetStatus("Rolling");
                if (status != null) {
                    setup.moveSlot = -1;
                    setup.moveIndex = status.Tag.ToInt();
                    sayMove = true;
                }

                //cancel fury cutter multipliers if using a different move
                if (setup.Attacker.VolatileStatus.GetStatus("FuryCutter") != null) {

                        if (setup.moveIndex != 175) {
                            RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "FuryCutter", setup.PacketStack);
                        }

                }

                if (setup.moveSlot > -1 && setup.moveSlot < 4) {
                    setup.moveIndex = setup.Attacker.Moves[setup.moveSlot].MoveNum;
                    sayMove = true;
                }
                if (setup.moveIndex < 1) {
                    setup.moveIndex = -1;
                    setup.SetupMove(MoveManager.StandardAttack);
                } else {
                    setup.SetupMove(MoveManager.Moves[setup.moveIndex]);
                    if (GetBattleTagArg(setup.BattleTags, "InvokedMove", 0) != null ||
                        GetBattleTagArg(setup.BattleTags, "OrderedMove", 0) != null) {
                        sayMove = true;
                    }
                }

                //surf check
                if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit &&
                        setup.moveIndex == 462) {
                    int x = setup.Attacker.X;
                    int y = setup.Attacker.Y;
                    MoveInDirection(setup.Attacker.Direction, 1, ref x, ref y);
                    if (x >= 0 && x <= setup.AttackerMap.MaxX && y >= 0 && y <= setup.AttackerMap.MaxY) {
                        Tile tile = ((Recruit)setup.Attacker).Owner.Player.Map.Tile[x, y];
                        if (tile.Type == Enums.TileType.ScriptedSign) {
                            if (tile.Data1 == 17) {
                                Messenger.PlayerWarp(((Recruit)setup.Attacker).Owner, tile.String1.ToInt(), tile.String2.ToInt(), tile.String3.ToInt());
                                setup.Cancel = true;
                                return;
                            }
                        }
                    }
                }
                //fly check
                if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit &&
                        setup.moveIndex == 423) {
                        Tile tile = ((Recruit)setup.Attacker).Owner.Player.Map.Tile[setup.Attacker.X, setup.Attacker.Y];
                    if (tile.Type == Enums.TileType.Scripted) {
                        if (tile.Data1 == 14) {
                            //Messenger.PlayerMsg(((Recruit)setup.Attacker).Owner, "But it failed...", Text.BrightRed);
                            //setup.Cancel = true;
                            //return;
                            Messenger.PlayerWarp(((Recruit)setup.Attacker).Owner, tile.String1.ToInt(), tile.String2.ToInt(), tile.String3.ToInt());
                            setup.Cancel = true;
                            return;
                        }
                    }
                }
                //Dive check
                if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit &&
                        setup.moveIndex == 297) {
                        Tile tile = ((Recruit)setup.Attacker).Owner.Player.Map.Tile[setup.Attacker.X, setup.Attacker.Y];
                    if (tile.Type == Enums.TileType.Scripted) {
                        if (tile.Data1 == 76) {
                            //Messenger.PlayerMsg(((Recruit)setup.Attacker).Owner, "But it failed...", Text.BrightRed);
                            //setup.Cancel = true;
                            //return;
                            Messenger.PlayerWarp(((Recruit)setup.Attacker).Owner, tile.String1.ToInt(), tile.String2.ToInt(), tile.String3.ToInt());
                            setup.Cancel = true;
                            return;
                        }
                    }
                }
                //rock climb check
                if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit &&
                        setup.moveIndex == 456) {
                    int x = setup.Attacker.X;
                    int y = setup.Attacker.Y;
                    MoveInDirection(setup.Attacker.Direction, 1, ref x, ref y);
                    if (x >= 0 && x <= setup.AttackerMap.MaxX && y >= 0 && y <= setup.AttackerMap.MaxY) {
                        Tile tile = ((Recruit)setup.Attacker).Owner.Player.Map.Tile[x, y];
                        if (tile.Type == Enums.TileType.ScriptedSign) {
                            if (tile.Data1 == 20) {
                                setup.Attacker.X = x;
                                setup.Attacker.Y = y;
                                PacketBuilder.AppendPlayerXY(((Recruit)setup.Attacker).Owner, setup.PacketStack);
                                setup.Cancel = true;
                                return;
                            }
                        }
                    }
                }

                //unfinished move check
                if (setup.moveIndex > 0) {
                    if (MoveManager.Moves[setup.moveIndex].Name.EndsWith("\'") || MoveManager.Moves[setup.moveIndex].Name.EndsWith("`")) {
                        if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit && Ranks.IsAllowed(((Recruit)setup.Attacker).Owner, Enums.Rank.Moniter)) {

                        } else {
                            setup.Cancel = true;
                            return;
                        }
                    }

                }

                if (sayMove) {
                    setup.Move.Name = setup.Attacker.Name + " used " + setup.Move.Name + "!";
                } else {
                    setup.Move.Name = "";
                }

                if (GetBattleTagArg(setup.BattleTags, "InvokedMove", 0) == null) {
                    //check against cooldown
                    if (GetBattleTagArg(setup.BattleTags, "OrderedMove", 0) == null) {
                        if (setup.Attacker.PauseTimer == null) {
                            setup.Attacker.PauseTimer = new TickCount(Core.GetTickCount().Tick);
                        }
                        if (setup.Attacker.PauseTimer.Tick > Core.GetTickCount().Tick) {
                            setup.Cancel = true;
                            return;
                        }
                        if (setup.Attacker.AttackTimer == null ||
                            setup.Move.AdditionalEffectData1 == 9 ||
                            setup.Move.AdditionalEffectData1 == 128 ||
                            setup.Move.AdditionalEffectData1 == 132) {
                            setup.Attacker.AttackTimer = new TickCount(Core.GetTickCount().Tick);
                        }
                        if (setup.Attacker.AttackTimer.Tick > Core.GetTickCount().Tick) {
                            setup.Cancel = true;
                            return;
                        }
                    }

                    //check against freeze/paralyze/sleep
                    if (setup.Attacker.StatusAilment == Enums.StatusAilment.Freeze) {
                        if (Server.Math.Rand(0, 3) == 0 && !CheckStatusProtection(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK.ToString(), false, setup.PacketStack)) {
                            SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK, 0, setup.PacketStack);
                        } else if ((setup.Move.AdditionalEffectData1 == 37 || setup.Move.AdditionalEffectData1 == 38) && !CheckStatusProtection(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK.ToString(), true, setup.PacketStack)) {

                            SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK, 0, setup.PacketStack);
                        } else {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " is frozen solid!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Cancel = true;
                            return;
                        }
                    } else if (setup.Attacker.StatusAilment == Enums.StatusAilment.Paralyze) {
                        if (Server.Math.Rand(0, 5) == 0) {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " is paralyzed!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateSoundPacket("magic184.wav"));
                            setup.Cancel = true;
                            return;
                        }
                    } else if (setup.Attacker.StatusAilment == Enums.StatusAilment.Sleep) {
                        setup.Attacker.StatusAilmentCounter--;
                        if (setup.Attacker.StatusAilmentCounter <= 0 && !CheckStatusProtection(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK.ToString(), false, setup.PacketStack)) {
                            SetStatusAilment(setup.Attacker, setup.AttackerMap, Enums.StatusAilment.OK, 0, setup.PacketStack);
                        } else if (setup.Move.AdditionalEffectData1 == 35 || setup.Move.Data1 == 36) {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " is fast asleep...", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                        } else {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " is fast asleep...", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Cancel = true;
                            return;
                        }
                    }

                    //check against wrapping (victim)
                    int trapdmg;
                    status = setup.Attacker.VolatileStatus.GetStatus("Bind:0");
                    if (status != null) {
                        status.Counter--;
                        if (status.Target == null) {
                            setup.Attacker.VolatileStatus.Remove(status);
                        } else if (status.Counter <= 0 || !MoveProcessor.IsInAreaRange(1, setup.Attacker.X, setup.Attacker.Y, status.Target.X, status.Target.Y) ||
                            status.Target.MapID != setup.AttackerMap.MapID || setup.Move.AdditionalEffectData1 == 85) {
                            RemoveBondedExtraStatus(setup.Attacker, setup.AttackerMap, "Bind:0", setup.PacketStack, true);
                        } else {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " is struggling to get free!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Cancel = true;
                            return;
                        }
                    }
                    status = setup.Attacker.VolatileStatus.GetStatus("Bind:1");
                    if (status != null) {
                        if (status.Target == null) {
                            setup.Attacker.VolatileStatus.Remove(status);
                        } else if (!MoveProcessor.IsInAreaRange(1, setup.Attacker.X, setup.Attacker.Y, status.Target.X, status.Target.Y) ||
                            status.Target.MapID != setup.AttackerMap.MapID) {
                            RemoveBondedExtraStatus(setup.Attacker, setup.AttackerMap, "Bind:1", setup.PacketStack, true);
                        } else {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s attack continues!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            if (status.Tag == "1") {
                                trapdmg = status.Target.MaxHP / 12;
                            } else {
                                trapdmg = status.Target.MaxHP / 16;
                            }
                            if (trapdmg < 1) trapdmg = 1;
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                DamageCharacter(status.Target, MapManager.RetrieveActiveMap(status.Target.MapID), trapdmg, Enums.KillType.Player, setup.PacketStack, true);
                            } else if (setup.Attacker.CharacterType == Enums.CharacterType.MapNpc) {
                                DamageCharacter(status.Target, MapManager.RetrieveActiveMap(status.Target.MapID), trapdmg, Enums.KillType.Npc, setup.PacketStack, true);
                            }
                            setup.Cancel = true;
                            return;
                        }
                    }

                    status = setup.Attacker.VolatileStatus.GetStatus("Clamp:0");
                    if (status != null) {
                        status.Counter--;
                        if (status.Counter <= 0 ||
                            !MoveProcessor.IsInAreaRange(1, setup.Attacker.X, setup.Attacker.Y, status.Target.X, status.Target.Y) ||
                            status.Target.MapID != setup.AttackerMap.MapID ||
                            setup.Move.AdditionalEffectData1 == 85) {
                            RemoveBondedExtraStatus(setup.Attacker, setup.AttackerMap, "Clamp:0", setup.PacketStack, true);
                        } else {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " is struggling to get free!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Cancel = true;
                            return;
                        }
                    }
                    status = setup.Attacker.VolatileStatus.GetStatus("Clamp:1");
                    if (status != null) {
                        if (status.Target == null) {
                            setup.Attacker.VolatileStatus.Remove(status);
                        } else if (!MoveProcessor.IsInAreaRange(1, setup.Attacker.X, setup.Attacker.Y, status.Target.X, status.Target.Y) ||
                            status.Target.MapID != setup.AttackerMap.MapID) {
                            RemoveBondedExtraStatus(setup.Attacker, setup.AttackerMap, "Clamp:1", setup.PacketStack, true);
                        } else {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s attack continues!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            if (status.Tag == "1") {
                                trapdmg = status.Target.MaxHP / 12;
                            } else {
                                trapdmg = status.Target.MaxHP / 16;
                            }
                            if (trapdmg < 1) trapdmg = 1;
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                DamageCharacter(status.Target, MapManager.RetrieveActiveMap(status.Target.MapID), trapdmg, Enums.KillType.Player, setup.PacketStack, true);
                            } else if (setup.Attacker.CharacterType == Enums.CharacterType.MapNpc) {
                                DamageCharacter(status.Target, MapManager.RetrieveActiveMap(status.Target.MapID), trapdmg, Enums.KillType.Npc, setup.PacketStack, true);
                            }
                            setup.Cancel = true;
                            return;
                        }
                    }

                    status = setup.Attacker.VolatileStatus.GetStatus("Wrap:0");
                    if (status != null) {
                        status.Counter--;
                        if (status.Counter <= 0 || !MoveProcessor.IsInAreaRange(1, setup.Attacker.X, setup.Attacker.Y, status.Target.X, status.Target.Y) ||
                            status.Target.MapID != setup.AttackerMap.MapID || setup.Move.AdditionalEffectData1 == 85) {
                            RemoveBondedExtraStatus(setup.Attacker, setup.AttackerMap, "Wrap:0", setup.PacketStack, true);
                        } else {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " is struggling to get free!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Cancel = true;
                            return;
                        }
                    }
                    status = setup.Attacker.VolatileStatus.GetStatus("Wrap:1");
                    if (status != null) {
                        if (status.Target == null) {
                            setup.Attacker.VolatileStatus.Remove(status);
                        } else if (!MoveProcessor.IsInAreaRange(1, setup.Attacker.X, setup.Attacker.Y, status.Target.X, status.Target.Y) ||
                            status.Target.MapID != setup.AttackerMap.MapID) {
                            RemoveBondedExtraStatus(setup.Attacker, setup.AttackerMap, "Wrap:1", setup.PacketStack, true);
                        } else {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + "'s attack continues!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            if (status.Tag == "1") {
                                trapdmg = status.Target.MaxHP / 12;
                            } else {
                                trapdmg = status.Target.MaxHP / 16;
                            }
                            if (trapdmg < 1) trapdmg = 1;
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                DamageCharacter(status.Target, MapManager.RetrieveActiveMap(status.Target.MapID), trapdmg, Enums.KillType.Player, setup.PacketStack, true);
                            } else if (setup.Attacker.CharacterType == Enums.CharacterType.MapNpc) {
                                DamageCharacter(status.Target, MapManager.RetrieveActiveMap(status.Target.MapID), trapdmg, Enums.KillType.Npc, setup.PacketStack, true);
                            }
                            setup.Cancel = true;
                            return;
                        }
                    }

                    status = setup.Attacker.VolatileStatus.GetStatus("SkyDrop:0");
                    if (status != null) {
                        status.Counter--;
                        if (status.Counter <= 0 || !MoveProcessor.IsInAreaRange(1, setup.Attacker.X, setup.Attacker.Y, status.Target.X, status.Target.Y) ||
                            status.Target.MapID != setup.AttackerMap.MapID) {
                            RemoveBondedExtraStatus(setup.Attacker, setup.AttackerMap, "SkyDrop:0", setup.PacketStack, true);
                        } else {
                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " is struggling to get free!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Cancel = true;
                            return;
                        }
                    }
                    status = setup.Attacker.VolatileStatus.GetStatus("SkyDrop:1");
                    if (status != null) {
                        if (status.Target == null) {
                            setup.Attacker.VolatileStatus.Remove(status);
                        } else if (!MoveProcessor.IsInAreaRange(1, setup.Attacker.X, setup.Attacker.Y, status.Target.X, status.Target.Y) ||
                            status.Target.MapID != setup.AttackerMap.MapID) {
                            RemoveBondedExtraStatus(setup.Attacker, setup.AttackerMap, "SkyDrop:1", setup.PacketStack, true);
                        } else {
                            RemoveBondedExtraStatus(setup.Attacker, setup.AttackerMap, "SkyDrop:1", setup.PacketStack, false);
                            //execute the move
                            setup.BattleTags.Add("SkyDrop");
                        }
                    }

                //check against confusion
                    status = setup.Attacker.VolatileStatus.GetStatus("Confusion");
                if (status != null) {
                    status.Counter -= 2;
                    if (status.Counter <= 0) {
                        RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "Confusion", setup.PacketStack, true);
                    } else if (Server.Math.Rand(0, 2) == 0 && !(HasAbility(setup.Attacker, "Tangled Feet") && HasAbility(setup.Attacker, "Own Tempo"))) {
                        setup.moveSlot = -1;
                        setup.moveIndex = -1;
                        setup.SetupMove(MoveManager.StandardAttack);
                        setup.Move.TargetType = Enums.MoveTarget.User;
                        setup.Move.Name = setup.Attacker.Name + " attacked itself in confusion!";
                    }
                }

                    //check against attraction
                status = setup.Attacker.VolatileStatus.GetStatus("Attract");
                    if (status != null) {
                        status.Counter--;
                        if (status.Counter <= 0) {
                            RemoveBondedExtraStatus(setup.Attacker, setup.AttackerMap, "Attract", setup.PacketStack, true);
                        } else {

                            setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " is immobilized by love!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                            setup.Cancel = true;
                            return;
                        }
                    }

                    if (setup.moveSlot > -1 && setup.moveSlot < 4) {
                        if (setup.Attacker.Moves[setup.moveSlot].CurrentPP <= 0) {
                            bool noMovesLeft = true;
                            for (int i = 0; i < Constants.MAX_PLAYER_MOVES; i++) {
                                if (setup.Attacker.Moves[i].CurrentPP > 0 && !setup.Attacker.Moves[i].Sealed) {
                                    noMovesLeft = false;
                                    break;
                                }
                            }
                            if (noMovesLeft) {
                                setup.moveSlot = -1;
                                setup.moveIndex = 466;//struggle
                                setup.SetupMove(MoveManager.Moves[setup.moveIndex]);
                                setup.Move.Name = setup.Attacker.Name + " used " + setup.Move.Name + "!";
                            } else {
                                if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                    setup.PacketStack.AddPacket(((Recruit)setup.Attacker).Owner, PacketBuilder.CreateBattleMsg("There's no PP left for that move!", Text.BrightRed));
                                    PacketBuilder.AppendMovePPUpdate(((Recruit)setup.Attacker).Owner, setup.PacketStack, setup.moveSlot);
                                }
                                setup.Cancel = true;
                                return;
                            }

                        } else if (setup.Attacker.Moves[setup.moveSlot].Sealed) {
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                setup.PacketStack.AddPacket(((Recruit)setup.Attacker).Owner, PacketBuilder.CreateBattleMsg("The move is sealed!  It can't be used!", Text.BrightRed));
                                PacketBuilder.AppendPlayerMoves(((Recruit)setup.Attacker).Owner, setup.PacketStack);
                            }
                            setup.Cancel = true;
                            return;

                        } else {
                            bool deductPP = true;
                            if (setup.Attacker.HasActiveItem(340)) deductPP = false;

                            if (Server.Math.Rand(0, 4) <= 0 && HasActiveBagItem(setup.Attacker, 13, 0, 0)) {
                                deductPP = false;
                            }
                            if (deductPP) setup.Attacker.Moves[setup.moveSlot].CurrentPP--;

                            status = setup.Attacker.VolatileStatus.GetStatus("LastUsedMoveSlot");
                            if (status == null || status.Counter != setup.moveSlot) {
                                AddExtraStatus(setup.Attacker, setup.AttackerMap, "LastUsedMoveSlot", setup.moveSlot, null, "", setup.PacketStack);
                                AddExtraStatus(setup.Attacker, setup.AttackerMap, "TimesLastMoveUsed", 1, null, "", setup.PacketStack);
                            } else {
                                status = setup.Attacker.VolatileStatus.GetStatus("TimesLastMoveUsed");
                                if (status != null) {
                                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "TimesLastMoveUsed", status.Counter + 1, null, "", setup.PacketStack);
                                } else {
                                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "TimesLastMoveUsed", 1, null, "", setup.PacketStack);
                                }
                            }

                            //send PP update to players
                            if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                                PacketBuilder.AppendMovePPUpdate(((Recruit)setup.Attacker).Owner, setup.PacketStack, setup.moveSlot);
                            }

                            if (setup.Attacker.HasActiveItem(256) || setup.Attacker.HasActiveItem(257) || setup.Attacker.HasActiveItem(258)) {
                                for (int i = 0; i < Constants.MAX_PLAYER_MOVES; i++) {
                                    if (i != setup.moveSlot) {
                                        AddExtraStatus(setup.Attacker, setup.AttackerMap, "MoveSeal:" + i, 0, null, "", setup.PacketStack, false);
                                    }
                                }
                            }

                        }
                    }// else if (setup.Move.EffectType == Enums.MoveType.SubHP) {
                    //    switch (setup.Move.Data2) {
                    //        case 1: {
                    //                if (setup.Attacker.CharacterType == Enums.CharacterType.Recruit) {
                    //                    ((Recruit)setup.Attacker).Owner.Player.TakeItem(setup.Move.Data3, 1);
                    //                }
                    //                break;
                    //            }

                    //    }
                    //}

                }

                //For the charging of chargeup attacks (solarbeam/skull bash/razor wind/sky attack/dig/fly/etc.
                if (setup.Attacker.VolatileStatus.GetStatus("SolarBeam") != null) {
                    RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "SolarBeam", setup.PacketStack);
                } else if (setup.Attacker.VolatileStatus.GetStatus("SkullBash") != null) {
                    RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "SkullBash", setup.PacketStack);
                } else if (setup.Attacker.VolatileStatus.GetStatus("RazorWind") != null) {
                    RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "RazorWind", setup.PacketStack);
                } else if (setup.Attacker.VolatileStatus.GetStatus("SkyAttack") != null) {
                    RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "SkyAttack", setup.PacketStack);
                } else if (setup.Attacker.VolatileStatus.GetStatus("FocusPunch") != null) {
                    RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "FocusPunch", setup.PacketStack, false);
                } else if (setup.Attacker.VolatileStatus.GetStatus("Bide") != null) {
                    setup.Move.Data1 = 30;
                    setup.Move.Data2 = setup.Attacker.VolatileStatus.GetStatus("Bide").Counter * 2;
                    RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "Bide", setup.PacketStack);
                } else if (setup.Attacker.VolatileStatus.GetStatus("Avalanche") != null) {
                    if (GetBattleTagArg(setup.BattleTags, "Avalanche", 0) != null) {
                        setup.Move.Data1 *= 2;
                    }
                    RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "Avalanche", setup.PacketStack);
                } else if (setup.Attacker.VolatileStatus.GetStatus("VitalThrow") != null) {
                    RemoveExtraStatus(setup.Attacker, setup.AttackerMap, "VitalThrow", setup.PacketStack);
                    if (GetBattleTagArg(setup.BattleTags, "VitalThrow", 0) != null) {

                    } else {
                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " gave up on Vital Throw!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                        setup.Cancel = true;
                        return;
                    }
                } else if (semiInvul) {

                } else {
                    if (setup.Move.AdditionalEffectData1 == 60 && setup.Attacker.VolatileStatus.GetStatus("SuperCharge") == null) {
                        switch (setup.Move.AdditionalEffectData2) {
                            case 1: {//solarbeam
                                    if (GetCharacterWeather(setup.Attacker) != Enums.Weather.Sunny) {
                                        AddExtraStatus(setup.Attacker, setup.AttackerMap, "SolarBeam", 0, null, "", setup.PacketStack);
                                        setup.Cancel = true;
                                        return;
                                    }
                                }
                                break;
                            case 2: {//skull bash
                                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "SkullBash", 0, null, "", setup.PacketStack);
                                    setup.Cancel = true;
                                    return;
                                }
                                break;
                            case 3: {//razor wind
                                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "RazorWind", 0, null, "", setup.PacketStack);
                                    setup.Cancel = true;
                                    return;
                                }
                                break;
                            case 4: {//sky attack
                                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "SkyAttack", 0, null, "", setup.PacketStack);
                                    setup.Cancel = true;
                                    return;
                                }
                                break;
                            case 5: {//focus punch
                                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "FocusPunch", 0, null, "", setup.PacketStack);
                                    setup.Cancel = true;
                                    return;
                                }
                                break;
                            case 6: {//Dig
                                    bool passable = false;
                                    Tile tile = setup.AttackerMap.Tile[setup.Attacker.X, setup.Attacker.Y];
                                    if (tile.Type == Enums.TileType.Arena) {
                                        passable = true;
                                    } else if (tile.Type == Enums.TileType.Walkable || tile.Type == Enums.TileType.Hallway || tile.Type == Enums.TileType.NPCAvoid) {
                                        if (tile.Data1 == 0) passable = true;
                                    } else if (tile.Type == Enums.TileType.MobileBlock) {
                                        if (tile.Data1 <= 0) passable = true;
                                    }
                                    if (passable) {
                                        AddExtraStatus(setup.Attacker, setup.AttackerMap, "SemiInvul", 20, null, "Dig", setup.PacketStack);
                                    } else {
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " can't dig here!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    setup.Cancel = true;
                                    return;
                                }
                                break;
                            case 7: {//Bounce
                                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "SemiInvul", 8, null, "Bounce", setup.PacketStack);
                                    setup.Cancel = true;
                                    return;
                                }
                                break;
                            case 8: {//Fly
                                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "SemiInvul", 12, null, "Fly", setup.PacketStack);
                                    setup.Cancel = true;
                                    return;
                                }
                                break;
                            case 9: {//Shadow Force
                                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "SemiInvul", 14, null, "ShadowForce", setup.PacketStack);
                                    setup.Cancel = true;
                                    return;
                                }
                                break;
                            case 10: {//Dive
                                    bool passable = false;
                                    Tile tile = setup.AttackerMap.Tile[setup.Attacker.X, setup.Attacker.Y];
                                    if (tile.Type == Enums.TileType.Arena) {
                                        passable = true;
                                    } else if (tile.Type == Enums.TileType.Walkable || tile.Type == Enums.TileType.Hallway) {
                                        if (tile.Data1 == 1) passable = true;
                                    } else if (tile.Type == Enums.TileType.MobileBlock) {
                                        if (tile.Data1 == 2) passable = true;
                                    }
                                    if (passable) {
                                        AddExtraStatus(setup.Attacker, setup.AttackerMap, "SemiInvul", 20, null, "Dive", setup.PacketStack);
                                    } else {
                                        setup.PacketStack.AddPacketToMap(setup.AttackerMap, PacketBuilder.CreateBattleMsg(setup.Attacker.Name + " can't dive here!", Text.BrightRed), setup.Attacker.X, setup.Attacker.Y, 10);
                                    }
                                    setup.Cancel = true;
                                    return;
                                }
                                break;
                            case 11: {//Phantom Force
                                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "SemiInvul", 14, null, "PhantomForce", setup.PacketStack);
                                    setup.Cancel = true;
                                    return;
                                }
                                break;
                        }
                    } else if (setup.Move.EffectType == Enums.MoveType.Scripted && setup.Move.Data1 == 68) {
                        AddExtraStatus(setup.Attacker, setup.AttackerMap, "Bide", 0, null, "", setup.PacketStack);
                        setup.Cancel = true;
                        return;
                    } else if (setup.Move.AdditionalEffectData1 == 186) {
                        AddExtraStatus(setup.Attacker, setup.AttackerMap, "Avalanche", 0, null, "", setup.PacketStack);
                        setup.Cancel = true;
                        return;
                    } else if (setup.Move.AdditionalEffectData1 == 187) {
                        AddExtraStatus(setup.Attacker, setup.AttackerMap, "VitalThrow", 0, null, "", setup.PacketStack);
                        setup.Cancel = true;
                        return;
                    } else if (setup.Move.AdditionalEffectData1 == 197 && GetBattleTagArg(setup.BattleTags, "SkyDrop", 0) == null) {//sky drop
                        setup.Move.Name = "";
                    }
                }

                if (HasAbility(setup.Attacker, "Protean") && setup.Move.Element != Enums.PokemonType.None
                    && (setup.Move.Element != setup.Attacker.Type1 && setup.Attacker.Type1 != Enums.PokemonType.None || setup.Move.Element != setup.Attacker.Type2 && setup.Attacker.Type2 != Enums.PokemonType.None)) {
                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "Type1", (int)setup.Move.Element, null, "", setup.PacketStack);
                    AddExtraStatus(setup.Attacker, setup.AttackerMap, "Type2", 0, null, "", setup.PacketStack);
                }
            } catch (Exception ex) {
                Messenger.AdminMsg("Error: BeforeMoveUsed", Text.Black);
                Messenger.AdminMsg("Slot: " + setup.moveSlot + ", Name: " + MoveManager.Moves[setup.moveIndex].Name, Text.Black);
                Messenger.AdminMsg("Map: " + setup.AttackerMap.MapID + " Name: " + setup.AttackerMap.Name, Text.Black);
                Messenger.AdminMsg(ex.ToString(), Text.Black);
            }
        }
Ejemplo n.º 2
0
        public void UseMoveOnFoes(BattleSetup setup, TargetCollection targets)
        {
            Parties.Party party = null;
            if (owner.Player.IsInParty()) {
                party = Parties.PartyManager.FindPlayerParty(owner);
            }

            //List<ICharacter> targets = MoveProcessor.GetTargetsInRange(setup.Move.RangeType, setup.Move.Range, setup.AttackerMap, this, owner.Player.X, owner.Player.Y, owner.Player.Direction);

            Move move = setup.SetdownMove();

            foreach (ICharacter i in targets.Foes) {
                // Don't attack allies
                if (i.CharacterType == Enums.CharacterType.Recruit) {
                    Recruit recruit = i as Recruit;
                    if (Ranks.IsAllowed(recruit.Owner, Enums.Rank.Moniter) && !recruit.Owner.Player.Hunted
                        || (recruit.Owner.Player.Map.Tile[recruit.Owner.Player.X, recruit.Owner.Player.Y].Type == Enums.TileType.Arena) != (Owner.Player.Map.Tile[X, Y].Type == Enums.TileType.Arena)) {

                    } else {
                        setup.Defender = i;
                        BattleProcessor.MoveHitCharacter(setup);
                        setup.SetupMove(move);
                        if (setup.Cancel) {
                            return;
                        }
                    }
                } else if (i.CharacterType == Enums.CharacterType.MapNpc && (((MapNpc)i).Num <= 0 || ((MapNpc)i).HP <= 0)) {
                } else if (i.CharacterType == Enums.CharacterType.MapNpc) {
                    MapNpc npc = i as MapNpc;
                    if (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Scripted) {
                        if (setup.moveIndex == -1) {
                            Scripting.ScriptManager.InvokeSub("ScriptedNpc", setup.Attacker, Npcs.NpcManager.Npcs[npc.Num].AIScript, npc.Num, owner.Player.Map, i);
                        }
                    } else if (!string.IsNullOrEmpty(Npcs.NpcManager.Npcs[npc.Num].AttackSay) && (Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Friendly || Npcs.NpcManager.Npcs[npc.Num].Behavior == Enums.NpcBehavior.Shopkeeper)) {
                        if (setup.moveIndex == -1) {
                            Stories.Story story = new Stories.Story();
                            Stories.StoryBuilderSegment segment = Stories.StoryBuilder.BuildStory();
                            Stories.StoryBuilder.AppendSaySegment(segment, Npcs.NpcManager.Npcs[npc.Num].Name.Trim() + ": " + Npcs.NpcManager.Npcs[npc.Num].AttackSay.Trim(),
                                Npcs.NpcManager.Npcs[npc.Num].Species, 0, 0);
                            segment.AppendToStory(story);
                            Stories.StoryManager.PlayStory(owner, story);
                        }
                    } else {
                        setup.Defender = i;
                        BattleProcessor.MoveHitCharacter(setup);
                        setup.SetupMove(move);
                        if (setup.Cancel) {
                            return;
                        }
                    }
                } else {
                    setup.Defender = i;
                    BattleProcessor.MoveHitCharacter(setup);
                    setup.SetupMove(move);
                    if (setup.Cancel) {
                        return;
                    }
                }

            }
        }
Ejemplo n.º 3
0
        public void UseMoveOnFoes(BattleSetup setup, TargetCollection targets)
        {
            // Attack any players that are on the map
            //List<ICharacter> targets = MoveProcessor.GetTargetsInRange(setup.Move.RangeType, setup.Move.Range, setup.AttackerMap, this, X, Y, Direction);
            Move move = setup.SetdownMove();

            foreach (ICharacter i in targets.Foes) {
                setup.Defender = i;
                BattleProcessor.MoveHitCharacter(setup);
                setup.SetupMove(move);
                if (setup.Cancel) {
                    return;
                }
            }
        }
Ejemplo n.º 4
0
 public void UseMoveOnAllies(BattleSetup setup, TargetCollection targets)
 {
     Parties.Party party = null;
     if (owner.Player.IsInParty()) {
         party = Parties.PartyManager.FindPlayerParty(owner);
     }
     //List<ICharacter> targets = MoveProcessor.GetTargetsInRange(setup.Move.RangeType, setup.Move.Range, setup.AttackerMap, this, owner.Player.X, owner.Player.Y, owner.Player.Direction);
     Move move = setup.SetdownMove();
     // Attack any players that are on the map
     foreach (ICharacter i in targets.Friends) {
         if (i.CharacterType == Enums.CharacterType.Recruit && Ranks.IsAllowed(((Recruit)i).Owner, Enums.Rank.Moniter)
                 && !((Recruit)i).Owner.Player.Hunted && !((Recruit)i).Owner.Player.Dead) {
         } else {
             setup.Defender = i;
             BattleProcessor.MoveHitCharacter(setup);
             setup.SetupMove(move);
             if (setup.Cancel) {
                 return;
             }
         }
     }
 }
Ejemplo n.º 5
0
        public void UseMoveOnAllies(BattleSetup setup, TargetCollection targets)
        {
            //List<ICharacter> targets = MoveProcessor.GetTargetsInRange(setup.Move.RangeType, setup.Move.Range, setup.AttackerMap, this, X, Y, Direction);
            Move move = setup.SetdownMove();

            foreach (ICharacter i in targets.Friends) {
                if (i.CharacterType == Enums.CharacterType.MapNpc && ((MapNpc)i).Num <= 0) {

                } else {
                    setup.Defender = i;
                    BattleProcessor.MoveHitCharacter(setup);
                    setup.SetupMove(move);
                    if (setup.Cancel) {
                        return;
                    }
                }
            }
        }