public override void Execute()
        {
            NWCreature self = (NWCreature)Self;
            ExtPoint   iPos = Position;

            if (self.IsSeen(iPos.X, iPos.Y, true) && !(self.CurrentMap.FindItem(iPos.X, iPos.Y) is Item))
            {
                IsComplete = true;
            }
            else
            {
                if (MathHelper.Distance(self.Location, iPos) == 0)
                {
                    self.PickupAll();
                    IsComplete = true;
                }
                else
                {
                    ExtPoint next = self.GetStep(iPos);
                    if (!next.IsEmpty)
                    {
                        Brain.StepTo(next.X, next.Y);
                    }
                    else
                    {
                        IsComplete = true;
                    }
                }
            }
        }
        public override void Execute()
        {
            NWCreature self = (NWCreature)Self;

            try {
                Building house   = self.FindHouse();
                Door     gp      = null;
                int      dist    = 0;
                bool     outside = false;
                house.IsNearestDoor(self.PosX, self.PosY, ref gp, ref dist, ref outside);

                if (outside && gp != null)
                {
                    if (dist == 1)
                    {
                        Brain.StepTo(gp.X, gp.Y);
                    }
                    else
                    {
                        ExtPoint tempPos = new ExtPoint();
                        tempPos.X = gp.X + Directions.Data[gp.Dir].DX;
                        tempPos.Y = gp.Y + Directions.Data[gp.Dir].DY;
                        ExtPoint next = self.GetStep(tempPos);
                        if (!next.IsEmpty)
                        {
                            Brain.StepTo(next.X, next.Y);
                        }
                    }
                }
                else
                {
                    ExtPoint next = self.GetStep(Position);
                    if (!next.IsEmpty)
                    {
                        Brain.StepTo(next.X, next.Y);
                    }
                }

                IsComplete = self.Location.Equals(Position);
            } catch (Exception ex) {
                Logger.Write("ShopReturnGoal.execute(): " + ex.Message);
            }
        }
        public override void Execute()
        {
            NWCreature self = (NWCreature)Self;

            ExtPoint next = self.GetStep(Position);

            if (!next.IsEmpty)
            {
                Brain.StepTo(next.X, next.Y);
            }
            IsComplete = (self.Location.Equals(Position));
        }
        public override void Execute()
        {
            NWCreature self = (NWCreature)Self;

            ExtRect r = Area.Clone();

            r.Inflate(-1, -1);

            if (!r.Contains(self.PosX, self.PosY))
            {
                ExtPoint pos = new ExtPoint();
                pos.X = RandomHelper.GetBoundedRnd(r.Left, r.Right);
                pos.Y = RandomHelper.GetBoundedRnd(r.Top, r.Bottom);
                ExtPoint next = self.GetStep(pos);
                if (!next.IsEmpty)
                {
                    Brain.StepTo(next.X, next.Y);
                }
            }

            IsComplete = false;
            //refComplete.argValue = this.Area.Contains(self.getPosX(), self.getPosY());
        }
Esempio n. 5
0
        public override void Execute()
        {
            NWCreature self     = (NWCreature)Self;
            ExtPoint   playerPt = self.Space.Player.Location;

            if (MathHelper.Distance(playerPt, self.Location) == 1)
            {
                int    idx = RandomHelper.GetBoundedRnd(RS.rs_Diary_First, RS.rs_Diary_Last);
                string s   = BaseLocale.Format(RS.rs_RavenSaid, BaseLocale.GetStr(idx));
                GlobalVars.nwrWin.ShowText(self, s, new LogFeatures(LogFeatures.lfDialog));

                self.State = CreatureState.Dead;
                IsComplete = true;
            }
            else
            {
                ExtPoint next = self.GetStep(playerPt);
                if (!next.IsEmpty)
                {
                    Brain.StepTo(next.X, next.Y);
                }
            }
        }
Esempio n. 6
0
        public override void Execute()
        {
            NWCreature self = (NWCreature)Self;

            try {
                int dist = MathHelper.Distance(self.Location, Debtor.Location);
                if (dist == 1)
                {
                    GlobalVars.nwrWin.ShowText(self, BaseLocale.GetStr(RS.rs_GiveMeTheMoney));
                    GlobalVars.nwrWin.ShowInventory(self);
                }
                else
                {
                    ExtPoint next = self.GetStep(Debtor.Location);
                    if (!next.IsEmpty)
                    {
                        Brain.StepTo(next.X, next.Y);
                    }
                }
            } catch (Exception ex) {
                Logger.Write("TraderBrain.ExecuteDebtTakeGoal(): " + ex.Message);
            }
        }
        public override void Attack(CreatureEntity aEnemy, bool onlyRemote)
        {
            try {
                NWCreature self  = (NWCreature)fSelf;
                NWCreature enemy = (NWCreature)aEnemy;

                int dist = MathHelper.Distance(self.Location, aEnemy.Location);

                bool shooting = false;
                int  highestDamage;
                Item weapon = null;

                if (self.Entry.Flags.Contains(CreatureFlags.esMind) && (self.Entry.Flags.Contains(CreatureFlags.esUseItems)))
                {
                    bool canShoot = self.CanShoot(enemy);

                    BestWeaponSigns bw = new BestWeaponSigns();
                    if (canShoot)
                    {
                        bw.Include(BestWeaponSigns.CanShoot);
                    }
                    if (onlyRemote)
                    {
                        bw.Include(BestWeaponSigns.OnlyShoot);
                    }

                    highestDamage = self.CheckEquipment((float)dist, bw);

                    weapon = self.GetItemByEquipmentKind(BodypartType.bp_RHand);
                    ItemFlags ifs = (weapon != null) ? weapon.Flags : new ItemFlags();

                    shooting = (canShoot && weapon != null && (ifs.HasIntersect(ItemFlags.if_ThrowWeapon, ItemFlags.if_ShootWeapon)));
                }
                else
                {
                    highestDamage = self.DamageBase;
                }

                int     skDamage      = 0;
                SkillID sk            = self.GetAttackSkill(dist, ref skDamage);
                bool    attackBySkill = (sk != SkillID.Sk_None && (skDamage > highestDamage || AuxUtils.Chance(15)));

                if (attackBySkill)
                {
                    EffectExt ext = new EffectExt();
                    ext.SetParam(EffectParams.ep_Creature, aEnemy);
                    self.UseSkill(sk, ext);
                }
                else
                {
                    if (shooting)
                    {
                        self.ShootTo(enemy, weapon);
                    }
                    else
                    {
                        if (!onlyRemote)
                        {
                            if (dist == 1)
                            {
                                self.AttackTo(AttackKind.Melee, enemy, null, null);
                            }
                            else
                            {
                                ExtPoint next = self.GetStep(aEnemy.Location);
                                if (!next.IsEmpty)
                                {
                                    StepTo(next.X, next.Y);
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.Write("BeastBrain.attack(): " + ex.Message);
            }
        }
Esempio n. 8
0
        public override void Execute()
        {
            NWCreature self       = (NWCreature)Self;
            BeastBrain beastBrain = (BeastBrain)Brain;

            int            min          = beastBrain.fNearKinsfolkDist;
            CreatureEntity nearKinsfolk = beastBrain.fNearKinsfolk;
            int            cohX         = 0;
            int            cohY         = 0;
            int            algX         = 0;
            int            algY         = 0;

            int cnt = beastBrain.Kinsfolks.Count;

            for (int i = 0; i < cnt; i++)
            {
                NWCreature cr  = beastBrain.Kinsfolks[i];
                int        dir = cr.LastDir;
                cohX += cr.PosX;
                cohY += cr.PosY;
                algX += Directions.Data[dir].DX;
                algY += Directions.Data[dir].DY;
            }

            int dX = 0;
            int dY = 0;

            if (cnt > 0)
            {
                dX = (dX + (int)Math.Round(algX / (float)cnt));
                dY = (dY + (int)Math.Round(algY / (float)cnt));
            }
            if (cnt > 0)
            {
                cohX = (int)Math.Round(cohX / (float)cnt);
                cohY = (int)Math.Round(cohY / (float)cnt);
                int dir = Directions.GetDirByCoords(self.PosX, self.PosY, cohX, cohY);
                dX += Directions.Data[dir].DX;
                dY += Directions.Data[dir].DY;
            }
            if (min <= 3 && nearKinsfolk != null)
            {
                if (nearKinsfolk.PosX > self.PosX)
                {
                    dX--;
                }
                if (nearKinsfolk.PosX < self.PosX)
                {
                    dX++;
                }
                if (nearKinsfolk.PosY > self.PosY)
                {
                    dY--;
                }
                if (nearKinsfolk.PosY < self.PosY)
                {
                    dY++;
                }
            }

            ExtPoint newPos = new ExtPoint();

            newPos.X = self.PosX + dX;
            newPos.Y = self.PosY + dY;
            ExtPoint next = self.GetStep(newPos);

            if (!next.IsEmpty)
            {
                Brain.StepTo(next.X, next.Y);
            }
        }