コード例 #1
0
        public void LineProc(int x, int y, ref bool isContinue)
        {
            NWField f = ACreature.CurrentField;

            if (f.IsBarrier(x, y))
            {
                isContinue = false;
            }
            else
            {
                NWCreature cr = (NWCreature)f.FindCreature(x, y);
                isContinue = (cr == null) || (cr.Equals(AEnemy) || cr.Equals(ACreature));
            }
        }
コード例 #2
0
        public void LineProc(int aX, int aY, ref bool aContinue)
        {
            NWField f = (NWField)ACreature.CurrentMap;

            if (f.IsBarrier(aX, aY))
            {
                aContinue = false;
            }
            else
            {
                NWCreature cr = (NWCreature)f.FindCreature(aX, aY);
                if (cr == null)
                {
                    aContinue = true;
                }
                else
                {
                    aContinue = (cr.Equals(AEnemy) || cr.Equals(ACreature));
                }
            }
        }
コード例 #3
0
        private void PrepareFlock()
        {
            try {
                IsLeader = true;
                Kinsfolks.Clear();

                NWCreature self = (NWCreature)fSelf;
                NWField    fld  = self.CurrentField;

                fNearKinsfolk     = null;
                fNearKinsfolkDist = AuxUtils.MaxInt;

                int num = fld.Creatures.Count;
                for (int i = 0; i < num; i++)
                {
                    NWCreature cr   = fld.Creatures.GetItem(i);
                    int        dist = MathHelper.Distance(cr.Location, self.Location);
                    if (!cr.Equals(self) && dist <= self.Survey && cr.CLSID == self.CLSID && fld.LineOfSight(self.PosX, self.PosY, cr.PosX, cr.PosY))
                    {
                        Kinsfolks.Add(cr);
                        if (fNearKinsfolkDist > dist)
                        {
                            fNearKinsfolkDist = dist;
                            fNearKinsfolk     = cr;
                        }
                        IsLeader = (IsLeader && self.Leadership > cr.Leadership);
                    }
                }

                if (FindGoalByKind(GoalKind.gk_Flock) == null)
                {
                    GoalEntity goal = CreateGoal(GoalKind.gk_Flock);
                    goal.Duration = 25;
                }
            } catch (Exception ex) {
                Logger.Write("BeastBrain.prepareFlock(): " + ex.Message);
            }
        }
コード例 #4
0
        private void LineProc(int x, int y, ref bool refContinue)
        {
            Steps++;
            NWGameSpace space = Creature.Space;

            if (!Map.IsValid(x, y))
            {
                bool gpChanged = false;

                int fx = Map.Coords.X;
                int fy = Map.Coords.Y;
                int px = x;
                int py = y;

                GlobalPosition gpi = new GlobalPosition(fx, fy, px, py, gpChanged);
                gpi.CheckPos();
                fx        = gpi.Fx;
                fy        = gpi.Fy;
                px        = gpi.Px;
                py        = gpi.Py;
                gpChanged = gpi.GlobalChanged;

                NWLayer layer = Map.Layer;
                if (fx >= 0 && fx != layer.W && fy >= 0 && fy != layer.H && gpChanged)
                {
                    Map.Items.Extract(ProjectileItem);
                    Map = space.GetField(Creature.LayerID, fx, fy);
                    Map.Items.Add(ProjectileItem, false);
                    ProjectileItem.SetPos(px, py);
                }

                refContinue = false;
            }
            else
            {
                if (Map.IsBarrier(x, y))
                {
                    Hit         = HIT_BARRIER;
                    refContinue = false;
                }
                else if (Steps > Range)
                {
                    Hit         = HIT_NONE;
                    refContinue = false;
                }
                else
                {
                    NWCreature target = (NWCreature)Map.FindCreature(x, y);

                    if (target != null && !target.Equals(Creature))
                    {
                        Creature.AttackTo(Kind, target, Weapon, ProjectileItem);
                        ProjectileItem.SetPos(x, y);
                        Hit = HIT_BODY;

                        ProjectileItem.ApplyEffects(target, InvokeMode.im_Use, null);

                        refContinue = false;
                    }

                    if (refContinue)
                    {
                        ProjectileItem.SetPos(x, y);
                    }
                }
            }

            if (space.Player.IsSeen(x, y, false))
            {
                space.RepaintView(25);
            }
        }