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); } }
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); } }