public void RecruitMercenary(NWCreature collocutor, NWCreature mercenary, bool byMoney) { bool res = true; if (byMoney) { int hPrice = (int)mercenary.HirePrice; if (Money < hPrice) { res = false; GlobalVars.nwrWin.ShowText(GlobalVars.nwrWin, BaseLocale.GetStr(RS.rs_NoMoney)); } else { SubMoney(hPrice); collocutor.AddMoney(hPrice); } } if (res) { mercenary.IsMercenary = true; int dist = MathHelper.Distance(Location, mercenary.Location); ExtPoint pt = GetNearestPlace(3, true); if ((dist > (int)Survey) && (!pt.IsEmpty)) { mercenary.CheckTile(false); mercenary.SetPos(pt.X, pt.Y); mercenary.CheckTile(true); } } }
public NWField(NWGameSpace space, NWLayer layer, ExtPoint coords) : base(StaticData.FieldWidth, StaticData.FieldHeight) { fSpace = space; fLayer = layer; fCoords = coords; fCreatures = new CreaturesList(this, true); fItems = new ItemsList(this, true); fEffects = new EffectsList(this, true); fEmitters = new EmitterList(); ValidCreatures = new List <int>(); if (Layer != null) { LayerEntry layerEntry = (LayerEntry)GlobalVars.nwrDB.GetEntry(Layer.EntryID); fEntry = layerEntry.GetFieldEntry(fCoords.X, fCoords.Y); EntryID = fEntry.GUID; fLandEntry = (LandEntry)GlobalVars.nwrDB.FindEntryBySign(fEntry.LandSign); LandID = fLandEntry.GUID; PrepareCreatures(); } else { fEntry = null; EntryID = -1; fLandEntry = null; LandID = -1; } }
private void ProcessHintTick(long time) { ExtPoint curPos = MousePoint; if (fPrevPos.X != curPos.X || fPrevPos.Y != curPos.Y) { HideHint(); fPrevTime = time; } else { long d = time - fPrevTime; if (d >= DefHintPause && !fHintWindow.Visible) { ShowHint(); fPrevTime = time; } if (d >= DefHintHidePause && fHintWindow.Visible) { HideHint(); fPrevTime = time; } } fPrevPos = curPos; }
private void Set3DProps(Channel channel, ExtPoint player, ExtPoint sound) { try { channel.set3DMinMaxDistance(0f, 80f); VECTOR zero, listenerpos, sourcePos; zero.x = 0.0f; zero.y = 0.0f; zero.z = 0.0f; listenerpos.x = player.X; listenerpos.y = 0.0f; listenerpos.z = player.Y; fSystem.set3DListenerAttributes(0, ref listenerpos, ref zero, ref zero, ref zero); sourcePos.x = sound.X; sourcePos.y = 0.0f; sourcePos.z = sound.Y; channel.set3DAttributes(ref sourcePos, ref zero); } catch (Exception ex) { Logger.Write("SoundEngine.set3DProps(): " + ex.Message); } }
private void InternalDraw(ChartDrawMode drawMode, BackgroundMode background) { // drawing relative offset of tree on graphics int spx = 0; int spy = 0; Size clientSize = ClientSize; ExtPoint scrollPos = new ExtPoint(Math.Abs(AutoScrollPosition.X), Math.Abs(AutoScrollPosition.Y)); if (drawMode == ChartDrawMode.dmInteractive) { spx += -scrollPos.X; spy += -scrollPos.Y; Rectangle viewPort = GetImageViewPort(); fModel.VisibleArea = ExtRect.CreateBounds(scrollPos.X, scrollPos.Y, viewPort.Width, viewPort.Height); } else { fModel.VisibleArea = ExtRect.CreateBounds(0, 0, fModel.ImageWidth, fModel.ImageHeight); } if (drawMode == ChartDrawMode.dmInteractive || drawMode == ChartDrawMode.dmStaticCentered) { if (fModel.ImageWidth < clientSize.Width) { spx += (clientSize.Width - fModel.ImageWidth) / 2; } if (fModel.ImageHeight < clientSize.Height) { spy += (clientSize.Height - fModel.ImageHeight) / 2; } } fModel.SetOffsets(spx, spy); DrawBackground(background); #if DEBUG_IMAGE using (Pen pen = new Pen(Color.Red)) { fRenderer.DrawRectangle(pen, Color.Transparent, fSPX, fSPY, fImageWidth, fImageHeight); } #endif bool hasDeep = (fSelected != null && fSelected != fModel.Root && fSelected.Rec != null); if (hasDeep && fOptions.DeepMode == DeepMode.Background) { DrawDeep(fOptions.DeepMode, spx, spy); } fRenderer.SetTranslucent(0.0f); fModel.Draw(drawMode); if (hasDeep && fOptions.DeepMode == DeepMode.Foreground) { DrawDeep(fOptions.DeepMode, spx, spy); } }
public static void ExDragTo(ExtPoint Pos) { if (DragObject.ActiveDrag || Math.Abs(DragObject.DragStartPos.X - Pos.X) >= MouseDragThreshold || Math.Abs(DragObject.DragStartPos.Y - Pos.Y) >= MouseDragThreshold) { BaseMainWindow mainWnd = DragControl.MainWindow; BaseControl Target = mainWnd.GetSubControl(Pos.X, Pos.Y); DragObject.ActiveDrag = true; if (!Target.Equals(DragObject.DragTarget)) { ExDoDragOver(DRAGSTATE_LEAVE); if (DragObject == null) { return; } DragObject.DragTarget = Target; DragObject.DragPos = Pos; ExDoDragOver(DRAGSTATE_ENTER); if (DragObject == null) { return; } } DragObject.DragPos = Pos; DragObject.Accepted = ExDoDragOver(DRAGSTATE_MOVE); } }
public override void Execute() { NWCreature self = (NWCreature)Self; bool ex = (self.CurrentField).Creatures.IndexOf(Enemy) >= 0; if (ex) { if (!CanMove) { Brain.Attack(Enemy, true); } else { int chn = RandomHelper.GetRandom(5); // 20% chance if (chn == 0) { if (Risk == AttackRisk.Evade) { Brain.Attack(Enemy, true); } } else { ExtPoint res = Brain.GetEvadePos(Enemy); if (!res.IsEmpty) { Brain.StepTo(res.X, res.Y); } } } } IsComplete = (!ex || !self.IsAvailable(Enemy, true)); }
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; } } } }
private MouseActionRet GetMouseAction(MouseEventArgs e, MouseEvent mouseEvent) { MouseAction action = MouseAction.maNone; TreeChartPerson person = null; ExtPoint offsets = fModel.GetOffsets(); int aX = e.X - offsets.X; int aY = e.Y - offsets.Y; int num = fModel.Persons.Count; for (int i = 0; i < num; i++) { TreeChartPerson p = fModel.Persons[i]; ExtRect persRt = p.Rect; if (persRt.Contains(aX, aY)) { person = p; if (e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meDown) { action = MouseAction.maSelect; break; } else if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meUp) { action = MouseAction.maProperties; break; } else if (mouseEvent == MouseEvent.meMove) { action = MouseAction.maHighlight; break; } } ExtRect expRt = TreeChartModel.GetExpanderRect(persRt); if ((e.Button == MouseButtons.Left && mouseEvent == MouseEvent.meUp) && expRt.Contains(aX, aY)) { person = p; action = MouseAction.maExpand; break; } } if (action == MouseAction.maNone && person == null) { if (e.Button == MouseButtons.Right && mouseEvent == MouseEvent.meDown) { action = MouseAction.maDrag; } } return(new MouseActionRet(action, person)); }
protected override void DoPaintEvent(BaseScreen screen) { base.DoPaintEvent(screen); int ax = 8; int ay = 8; screen.DrawImage(ax, ay, 0, 0, (int)fImage.Width, (int)fImage.Height, fImage, 255); screen.Font = CtlCommon.BgFont; screen.DrawText(ax + 40, ay + 25, BaseLocale.GetStr(RS.rs_WorldsTree), 0); screen.Font = CtlCommon.SmFont; int num = GlobalVars.nwrGame.LayersCount; for (int i = 0; i < num; i++) { NWLayer layer = GlobalVars.nwrGame.GetLayer(i); LayerEntry lre = layer.Entry; for (int y = 0; y < layer.H; y++) { for (int x = 0; x < layer.W; x++) { if (layer.GetField(x, y).Visited) { GlobalVars.nwrWin.Resources.DrawImage(screen, ax + lre.MSX + (x << 5), ay + lre.MSY + y * 30, lre.IconsIndex + (y * lre.W + x), 255); } } } } Player player = GlobalVars.nwrGame.Player; LayerEntry layerEntry = ((LayerEntry)GlobalVars.nwrDB.GetEntry(player.LayerID)); if (fMapCursor) { NWField fld = (NWField)player.CurrentMap; ExtPoint f = fld.Coords; GlobalVars.nwrWin.Resources.DrawImage(screen, ax + layerEntry.MSX + (f.X << 5), ay + layerEntry.MSY + f.Y * 30, StaticData.dbItfElements[(int)ItfElement.id_Cursor].ImageIndex, 255); } if (fMapHint.CompareTo("") != 0) { int tw = CtlCommon.SmFont.GetTextWidth(fMapHint); CtlCommon.SmFont.Color = Colors.Navy; //screen.drawText(ax + 304 + ((288 - tw) / 2), ay + 410, this.fMapHint, 0); screen.DrawText(ax + 58 + ((582 - tw) / 2), ay + 445, fMapHint, 0); } }
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)); }
/// <summary> /// 设置图象 /// </summary> protected void SetBitmap(Bitmap bitmap, byte opacity = 255) { if (bitmap.PixelFormat != PixelFormat.Format32bppArgb) { throw new ApplicationException("The bitmap must be 32bpp with alpha-channel."); } this.ClientSize = new Size(bitmap.Width, bitmap.Height); // The idea of this is very simple, // 1. Create a compatible DC with screen; // 2. Select the bitmap with 32bpp with alpha-channel in the compatible DC; // 3. Call the UpdateLayeredWindow. IntPtr screenDc = GetDC(IntPtr.Zero); IntPtr memDc = CreateCompatibleDC(screenDc); IntPtr hBitmap = IntPtr.Zero; IntPtr oldBitmap = IntPtr.Zero; try { hBitmap = bitmap.GetHbitmap(Color.FromArgb(0)); // Grab a GDI handle from this GDI+ bitmap oldBitmap = SelectObject(memDc, hBitmap); ExtSize size = new ExtSize(bitmap.Width, bitmap.Height); ExtPoint pointSource = new ExtPoint(0, 0); ExtPoint topPos = new ExtPoint(this.Left, this.Top); ExtBlendFunction blend = new ExtBlendFunction { BlendOp = AC_SRC_OVER, BlendFlags = 0, SourceConstantAlpha = opacity, AlphaFormat = AC_SRC_ALPHA }; UpdateLayeredWindow(Handle, screenDc, ref topPos, ref size, memDc, ref pointSource, 0, ref blend, ULW_ALPHA); } finally { ReleaseDC(IntPtr.Zero, screenDc); if (hBitmap != IntPtr.Zero) { SelectObject(memDc, oldBitmap); // The documentation says that we have to use the Windows.DeleteObject... // but since there is no such method I use the normal DeleteObject from Win32 GDI // and it's working fine without any resource leak. // // Windows.DeleteObject(hBitmap); DeleteObject(hBitmap); } DeleteDC(memDc); } bitmap.Dispose(); }
protected BaseMainWindow(int width, int height) : base(null) { fPrevPos = new ExtPoint(); fFrameCount = 0; fFrameStartTime = 0; FPS = 0f; fSystem = new SDL2System(this, width, height, false); Bounds = ExtRect.Create(0, 0, width - 1, height - 1); fHintWindow = CreateHintWindow(this); }
public void SetPerson(TreeChartPerson person) { if (person == null) { return; } fPerson = person; ExtPoint offsets = fChart.GetOffsets(); ExtRect rt = fPerson.Rect.GetOffset(offsets.X, offsets.Y); rt = ExtRect.CreateBounds(rt.Right, rt.Top, 40, rt.Height); fDestRect = rt; }
public void Test_ExtPoint() { var pt = new ExtPoint(9, 9); Assert.AreEqual(9, pt.X); Assert.AreEqual(9, pt.Y); pt.Offset(2, 3); Assert.AreEqual(11, pt.X); Assert.AreEqual(12, pt.Y); Assert.IsFalse(pt.IsEmpty); Assert.AreEqual("{X=11,Y=12}", pt.ToString()); }
public override bool IsAwareOfEmitter(Emitter emitter) { NWCreature iSelf = (NWCreature)fSelf; ExtPoint ePos = emitter.Position; bool result = false; switch (emitter.EmitterKind) { case EmitterKind.ek_Unknown: { break; } case EmitterKind.ek_Damaged: { result = (emitter.SourceID == fSelf.UID); break; } case EmitterKind.ek_Combat: case EmitterKind.ek_BloodSpatter: case EmitterKind.ek_DeadBody: case EmitterKind.ek_Creature: case EmitterKind.ek_Item: case EmitterKind.ek_AngryTownsman: case EmitterKind.ek_UpsetTownsman: { result = (emitter.SourceID != fSelf.UID && iSelf.IsSeen(ePos.X, ePos.Y, true)); break; } case EmitterKind.ek_BattleSounds: case EmitterKind.ek_Missile: case EmitterKind.ek_GuardAlarm: case EmitterKind.ek_Call: { result = (emitter.SourceID != fSelf.UID && MathHelper.Distance(fSelf.Location, ePos) < (int)((NWCreature)iSelf).Hear); break; } default: { Logger.Write("BeastBrain.isAwareOfEmitter(): Emitter not recognized: " + Convert.ToString((int)emitter.EmitterKind)); result = false; break; } } return(result); }
public void AddGate(ushort tileID, int posX, int posY, int targetLayer, ExtPoint targetField, ExtPoint targetPos) { NWTile tile = (NWTile)GetTile(posX, posY); tile.Foreground = tileID; Gate gate = new Gate(fSpace, this); gate.CLSID = tileID; gate.SetPos(posX, posY); gate.TargetLayer = targetLayer; gate.TargetField = targetField.Clone(); gate.TargetPos = targetPos.Clone(); Features.Add(gate); }
public void SpreadTiles(ushort tileID, float density) { try { int tsz = 0; List <ExtPoint> bounds = new List <ExtPoint>(); for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++) { NWTile tile = (NWTile)GetTile(x, y); if (tile.BackBase != tileID) { int cnt = GetBackTilesCount(x, y, (short)tileID); if (cnt > 0) { bounds.Add(new ExtPoint(x, y)); } } else { tsz++; } } } int xcnt = RandomHelper.GetBoundedRnd(1, Math.Max(1, (int)Math.Round(bounds.Count * density))); for (int i = 1; i <= xcnt; i++) { int idx = RandomHelper.GetRandom(bounds.Count); ExtPoint pt = bounds[idx]; bounds.RemoveAt(idx); ChangeTile(pt.X, pt.Y, tileID, false); } tsz += xcnt; // ALERT: change genBackTiles for compatibility with changeTile() float min = AreaRect.Square * 0.1f; if ((float)tsz < min) { UniverseBuilder.GenBackTiles(this, (int)(min - tsz), tileID); } Normalize(); } catch (Exception ex) { Logger.Write("NWField.spreadTiles(): " + ex.Message); } }
public void SetPerson(TreeChartPerson person) { if (person == null) { return; } fPerson = person; ExtPoint offsets = fChart.GetOffsets(); ExtRect rt = fPerson.Rect.GetOffset(offsets.X, offsets.Y); Rectangle rect = UIHelper.Rt2Rt(rt); rect.X = rect.Right; rect.Width = 40; fDestRect = rect; }
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); } }
private void PrepareTravel() { try { NWCreature self = (NWCreature)fSelf; if (FindGoalByKind(GoalKind.gk_Travel) == null) { ExtPoint res = self.GetNearestPlace(self.Survey, true); if (!res.IsEmpty) { TravelGoal goal = (TravelGoal)CreateGoal(GoalKind.gk_Travel); goal.Position = res; goal.Duration = 25; } } } catch (Exception ex) { Logger.Write("BeastBrain.prepareTravel(): " + ex.Message); } }
public override void TransferTo(int layerID, int fX, int fY, int pX, int pY, ExtRect area, bool obligatory, bool controlled) { try { NWField field = Space.GetField(layerID, fX, fY); bool withoutParty = (field.LandID == GlobalVars.Land_Crossroads) || Sail; bool globalMove = (LayerID != layerID || Field.X != fX || Field.Y != fY); bool partyMove = (globalMove && controlled && !withoutParty); base.TransferTo(layerID, fX, fY, pX, pY, area, obligatory, controlled); /*if (globalMove) { * // ??? * }*/ if (partyMove) { try { LeaderBrain party = (LeaderBrain)fBrain; int num = party.Members.Count; for (int i = 1; i < num; i++) { NWCreature member = party.Members[i]; ExtPoint pt = member.GetNearestPlace(Location, 4, true); if (!pt.IsEmpty) { member.TransferTo(layerID, fX, fY, pt.X, pt.Y, area, obligatory, true); } else { Logger.Write("Player.transferTo().transferParty().getNearestPlace() failed"); } } } catch (Exception ex) { Logger.Write("Player.transferTo().transferParty(): " + ex.Message); } } } catch (Exception ex) { Logger.Write("Player.transferTo(): " + ex.Message); throw ex; } }
public static void ExDragDone(bool Drop) { if (DragObject != null && !DragObject.Cancelling) { BaseDragObject DragSave = DragObject; try { try { DragObject.Cancelling = true; ExtPoint TargetPos = ExtPoint.Empty; if (DragObject.DragTarget != null && DragObject.DragTarget != null) { TargetPos = DragObject.DragPos; } bool Accepted = (DragObject.DragTarget != null & Drop) && DragObject.ActiveDrag && ExDoDragOver(DRAGSTATE_LEAVE); if (Accepted) { DragControl.DoDragEndEvent(DragObject.DragTarget, TargetPos.X, TargetPos.Y); DragObject.DragTarget.DoDragDropEvent(DragControl, TargetPos.X, TargetPos.Y); } } finally { if (DragSave != null) { DragSave.Cancelling = false; } DragObject = null; } } finally { DragControl = null; if (DragSave != null) { DragSave = null; } } } }
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()); }
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); } } }
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 void SetPointGuardGoal(ExtPoint value) { PointGuardGoal goal = (PointGuardGoal)CreateGoal(GoalKind.gk_PointGuard); goal.Position = value; }
public override ExtPoint GetEvadePos(CreatureEntity enemy) { ExtPoint result = ExtPoint.Empty; NWCreature self = (NWCreature)fSelf; if (Flock && fNearKinsfolk != null) { int epX = fNearKinsfolk.PosX; int epY = fNearKinsfolk.PosY; bool res = self.CanMove(self.CurrentField, epX, epY); if (res) { return(new ExtPoint(epX, epY)); } } Directions dangerDirs = new Directions(); if (enemy.PosX > self.PosX) { dangerDirs.Include(Directions.DtEast); } if (enemy.PosX < self.PosX) { dangerDirs.Include(Directions.DtWest); } if (enemy.PosY > self.PosY) { dangerDirs.Include(Directions.DtSouth); } if (enemy.PosY < self.PosY) { dangerDirs.Include(Directions.DtNorth); } if (dangerDirs.ContainsAll(Directions.DtNorth, Directions.DtWest)) { dangerDirs.Include(Directions.DtNorthWest); } if (dangerDirs.ContainsAll(Directions.DtNorth, Directions.DtEast)) { dangerDirs.Include(Directions.DtNorthEast); } if (dangerDirs.ContainsAll(Directions.DtSouth, Directions.DtWest)) { dangerDirs.Include(Directions.DtSouthWest); } if (dangerDirs.ContainsAll(Directions.DtSouth, Directions.DtEast)) { dangerDirs.Include(Directions.DtSouthEast); } for (int dir = Directions.DtFlatFirst; dir <= Directions.DtFlatLast; dir++) { if (!dangerDirs.Contains(dir)) { int epX = self.PosX + Directions.Data[dir].DX; int epY = self.PosY + Directions.Data[dir].DY; if (self.CanMove(self.CurrentField, epX, epY)) { return(new ExtPoint(epX, epY)); } } } return(result); }
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); } }
public RecallPos(object owner) : base(owner) { Field = new ExtPoint(); Pos = new ExtPoint(); }