public override Movements GetTileMovements(ushort tileID) { int pd = AuxUtils.GetShortLo(tileID); return(StaticData.dbPlaces[pd].Moves); }
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.bwsCanShoot); } if (onlyRemote) { bw.Include(BestWeaponSigns.bwsOnlyShoot); } 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.akMelee, 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); } }
protected override void EvaluateGoal(GoalEntity goal) { if (IsShipSail && (goal.Kind != GoalKind.gk_EnemyChase && goal.Kind != GoalKind.gk_EnemyEvade)) { goal.Value = -1.0f; return; } NWCreature self = (NWCreature)fSelf; if (self.Mercenary) { switch (goal.Kind) { case GoalKind.gk_ItemAcquire: goal.Value = 0.5f; break; case GoalKind.gk_EnemyChase: goal.Value = 0.6f; break; case GoalKind.gk_EnemyEvade: goal.Value = 0.25f; break; case GoalKind.gk_Escort: { int dist = MathHelper.Distance(self.Location, ((EscortGoal)goal).Position); goal.Value = ((0.3f + dist / 20.0f)); break; } default: base.EvaluateGoal(goal); break; } } else { switch (goal.Kind) { case GoalKind.gk_Travel: { // ekGuardAlarm if (goal.EmitterID != 0) { goal.Value = 0.55f; } break; } case GoalKind.gk_PointGuard: { int dist = MathHelper.Distance(self.Location, ((PointGuardGoal)goal).Position); goal.Value = (goal.Value + dist / 10.0f * 0.75f); break; } case GoalKind.gk_AreaGuard: { int dist = AuxUtils.CalcDistanceToArea(self.Location, ((AreaGuardGoal)goal).Area); goal.Value = ((goal.Value + dist / 100.0f)); break; } default: base.EvaluateGoal(goal); break; } } }
public void Exec(NWCreature creature, EffectID effectID, InvokeMode invokeMode, EffectExt ext, string rayMsg) { GlobalVars.nwrWin.ShowText(creature, rayMsg); int i = Effect.GetMagnitude(effectID); EffectTarget target = EffectTarget.et_None; if ((ext.ReqParams.Contains(EffectParams.ep_Direction))) { target = EffectTarget.et_Direction; } else { if ((ext.ReqParams.Contains(EffectParams.ep_Creature))) { target = EffectTarget.et_Creature; } } int x; int y; int x2; int y2; if (target != EffectTarget.et_Direction) { if (target != EffectTarget.et_Creature) { return; } x = creature.PosX; y = creature.PosY; NWCreature extCr = (NWCreature)ext.GetParam(EffectParams.ep_Creature); x2 = extCr.PosX; y2 = extCr.PosY; int dir = Directions.GetDirByCoords(x, y, x2, y2); x += Directions.Data[dir].DX; y += Directions.Data[dir].DY; } else { int dir = (int)ext.GetParam(EffectParams.ep_Direction); x = creature.PosX + Directions.Data[dir].DX; y = creature.PosY + Directions.Data[dir].DY; x2 = x + Directions.Data[dir].DX * i; y2 = y + Directions.Data[dir].DY * i; } Creature = creature; Dir = Directions.GetDirByCoords(x, y, x2, y2); EffID = effectID; Field = Creature.CurrentField; int eid = (int)effectID; EffectRec effRec = EffectsData.dbEffects[eid]; if (effRec.FrameCount > 0) { MapObject = new MapObject(creature.Space, Field); MapObject.InitByEffect(effectID); Field.Features.Add(MapObject); } else { MapObject = null; } TargetMeeted = AuxUtils.DoLine(x, y, x2, y2, LineProc, true); if (MapObject != null) { Field.Features.Remove(MapObject); } }
private void DoCommand(string cmd) { try { int tokCount = (int)AuxUtils.GetTokensCount(cmd, " "); string token = AuxUtils.GetToken(cmd, " ", 1).ToLower(); Player player = GlobalVars.nwrGame.Player; if (token.Equals("name_gen")) { for (int i = 1; i <= 10; i++) { AddMessage(GlobalVars.nwrGame.NameLib.GenerateName("ru", Gender.gMale, NamesLib.NameGen_RndSlabs)); } } else { if (token.Equals("test")) { player.Body = new HumanBody(player); } else { if (token.Equals("suicide")) { player.Death("Suicide", null); } else { if (token.Equals("set_fury")) { GlobalVars.Debug_Fury = !GlobalVars.Debug_Fury; string temp = GlobalVars.Debug_Fury ? "yes" : "no"; AddMessage(">> (fury = " + temp + ")"); } else { if (token.Equals("transform")) { if (tokCount == 1) { throw new Exception(BaseLocale.GetStr(RS.rs_NoValue)); } string temp = AuxUtils.GetToken(cmd, " ", 2); DataEntry entry = GlobalVars.nwrDB.FindEntryBySign(temp); if (entry != null) { EffectExt ext = new EffectExt(); ext.SetParam(EffectParams.ep_MonsterID, entry.GUID); player.UseEffect(EffectID.eid_Transformation, null, InvokeMode.im_ItSelf, ext); } } else { if (token.Equals("add_monster")) { if (tokCount == 1) { throw new Exception(BaseLocale.GetStr(RS.rs_NoValue)); } string temp = AuxUtils.GetToken(cmd, " ", 2); int tx; int ty; if (tokCount == 4) { tx = Convert.ToInt32(AuxUtils.GetToken(cmd, " ", 3)); ty = Convert.ToInt32(AuxUtils.GetToken(cmd, " ", 4)); } else { tx = -1; ty = -1; } DataEntry entry = GlobalVars.nwrDB.FindEntryBySign(temp); if (entry != null) { GlobalVars.nwrGame.AddCreatureEx(player.LayerID, player.Field.X, player.Field.Y, tx, ty, entry.GUID); } } else { if (token.Equals("kill_all")) { NWField fld = player.CurrentField; for (int i = fld.Creatures.Count - 1; i >= 0; i--) { NWCreature cr = fld.Creatures.GetItem(i); if (!cr.IsPlayer && !cr.Mercenary) { cr.Death("", null); } } } else { if (token.Equals("show_goals")) { ShowGoals(); } else { if (token.Equals("set_divinity")) { GlobalVars.Debug_Divinity = !GlobalVars.Debug_Divinity; string temp; if (GlobalVars.Debug_Divinity) { temp = "yes"; } else { temp = "no"; } AddMessage(">> (divinity = " + temp + ")"); } else { if (token.Equals("set_freeze")) { GlobalVars.Debug_Freeze = !GlobalVars.Debug_Freeze; string temp; if (GlobalVars.Debug_Freeze) { temp = "yes"; } else { temp = "no"; } AddMessage(">> (freeze = " + temp + ")"); } else { if (token.Equals("set_morality")) { if (tokCount == 1) { throw new Exception(BaseLocale.GetStr(RS.rs_NoValue)); } int dummy = Convert.ToInt32(AuxUtils.GetToken(cmd, " ", 2)); player.Morality = (sbyte)dummy; AddMessage(">> (Player.Morality = " + Convert.ToString(dummy) + ")"); } else { if (token.Equals("takeitem")) { if (tokCount == 1) { throw new Exception(BaseLocale.GetStr(RS.rs_NoName)); } if (tokCount == 2) { throw new Exception(BaseLocale.GetStr(RS.rs_NoCount)); } token = AuxUtils.GetToken(cmd, " ", 2); int dummy = Convert.ToInt32(AuxUtils.GetToken(cmd, " ", 3)); TakePlayerItem(player, token, dummy); } else { AddMessage(BaseLocale.GetStr(RS.rs_CommandUnknown)); } } } } } } } } } } } } } catch (Exception ex) { AddMessage(BaseLocale.GetStr(RS.rs_CommandUnknown)); AddMessage(ex.Message); } }
// FIXME: total check & tests public void Prepare() { NWField fld = (NWField)Owner; ExtRect r = Area; r.Inflate(-1, -1); int id = (int)ID; var blRec = StaticData.dbBuildings[id]; if (ID >= BuildingID.bid_MerchantShop && ID <= BuildingID.bid_WoodsmanShop) { NWCreature merchant = (NWCreature)Holder; if (merchant == null) { Item coins = new Item(fSpace, null); coins.CLSID = GlobalVars.iid_Coin; coins.Count = (ushort)RandomHelper.GetBoundedRnd(15000, 25000); int x = RandomHelper.GetBoundedRnd(r.Left, r.Right); int y = RandomHelper.GetBoundedRnd(r.Top, r.Bottom); merchant = fld.AddCreature(x, y, GlobalVars.nwrDB.FindEntryBySign(StaticData.dbSysCreatures[(int)blRec.Owner].Sign).GUID); merchant.IsTrader = true; merchant.AddItem(coins); Holder = merchant; } else { Item coins = (Item)merchant.Items.FindByCLSID(GlobalVars.iid_Coin); if (coins != null) { coins.Count = (ushort)RandomHelper.GetBoundedRnd(15000, 25000); } } ProbabilityTable <int> data = blRec.Wares; if (((data != null) ? data.Size() : 0) > 0) { for (int y = r.Top; y <= r.Bottom; y++) { for (int x = r.Left; x <= r.Right; x++) { Item item = (Item)fld.FindItem(x, y); if (item == null) { item = new Item(fSpace, this); item.CLSID = data.GetRandomItem(); item.SetPos(x, y); item.Owner = merchant; item.GenCount(); fld.Items.Add(item, false); } else { if (AuxUtils.Chance(20)) { item.CLSID = data.GetRandomItem(); item.GenCount(); } } } } } } }