Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Code “FullmoonAttack” #823

Open
angelk727 opened this issue May 26, 2023 · 0 comments
Open

Fix Code “FullmoonAttack” #823

angelk727 opened this issue May 26, 2023 · 0 comments

Comments

@angelk727
Copy link

Old Code:

protected virtual void FullmoonAttack(int damage, int delay = 500, DefenceType defenceType = DefenceType.ACAgility, int pushDistance = -1, int distance = 1)
{
MirDirection dir = Direction;

        bool pushed = false;

        for (int j = 1; j <= distance; j++)
        {
            for (int i = 0; i < 8; i++)
            {
                dir = Functions.NextDir(dir);
                Point point = Functions.PointMove(CurrentLocation, dir, j);

                if (!CurrentMap.ValidPoint(point)) continue;

                Cell cell = CurrentMap.GetCell(point);

                if (cell.Objects == null) continue;

                for (int o = 0; o < cell.Objects.Count; o++)
                {
                    MapObject ob = cell.Objects[o];
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero) continue;
                    if (!ob.IsAttackTarget(this)) continue;

                    if (pushDistance > 0 && !pushed)
                    {
                        ob.Pushed(this, Direction, pushDistance);
                        pushed = true;
                    }

                    DelayedAction action = new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, defenceType);
                    ActionList.Add(action);
                    break;
                }
            }
        }     
    }

Code after repair:Increase judgment on direction

    protected virtual void FullmoonAttack(int damage, int delay = 500, DefenceType defenceType = DefenceType.ACAgility, int pushDistance = -1, int distance = 1) //修改推动的方向问题
    {
        MirDirection dir = Direction;
        List<MapObject> targets = new List<MapObject>();

        for (int j = 1; j <= distance; j++)
        {
            for (int i = 0; i < 8; i++)
            {
                dir = Functions.NextDir(dir);
                Point point = Functions.PointMove(CurrentLocation, dir, j);

                if (!CurrentMap.ValidPoint(point)) continue;

                Cell cell = CurrentMap.GetCell(point);

                if (cell.Objects == null) continue;

                foreach (MapObject ob in cell.Objects)
                {
                    if (ob.Race != ObjectType.Player && ob.Race != ObjectType.Monster && ob.Race != ObjectType.Hero) continue;
                    if (!ob.IsAttackTarget(this)) continue;
                    targets.Add(ob);
                }
            }
        }

        foreach (MapObject ob in targets)
        {
            MirDirection pushDir;

            if (distance == 1)
            {
                pushDir = Functions.ReverseDirection(dir);
            }
            else
            {
                pushDir = Functions.DirectionFromPoint(CurrentLocation, ob.CurrentLocation);
            }

            if (pushDistance > 0 && !ob.InSafeZone)
            {
                ob.Pushed(this, pushDir, pushDistance);
            }

            ActionList.Add(new DelayedAction(DelayedType.Damage, Envir.Time + delay, ob, damage, defenceType));
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant