public void ApplyEffects(CreatureEntity target, InvokeMode invokeMode, EffectExt extData) { try { ItemEntry.EffectEntry[] effects = fEntry.Effects; if (effects == null) { return; } int num = effects.Length; for (int i = 0; i < num; i++) { ItemEntry.EffectEntry eff = fEntry.Effects[i]; EffectExt ext; if (invokeMode < InvokeMode.im_UseBegin || invokeMode >= InvokeMode.im_ItSelf) { ext = extData; } else { ext = new EffectExt(); ext.SetParam(EffectParams.ep_ItemExt, eff.ExtData); } ((NWCreature)target).UseEffect(eff.EffID, this, invokeMode, ext); } } catch (Exception ex) { Logger.Write("Item.applyEffects(): " + ex.Message); } }
protected override void Dispose(bool disposing) { if (disposing) { if (Ext != null) { Ext.Dispose(); Ext = null; } } base.Dispose(disposing); }
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); } }
public TargetObj() { Ext = null; }
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 override void UseEffect(EffectID effectID, object source, InvokeMode invokeMode, EffectExt ext) { bool paramsValid = Effect.InitParams(effectID, this, source, invokeMode, ref ext); if (paramsValid) { base.UseEffect(effectID, source, invokeMode, ext); } else { GlobalVars.nwrWin.InitTarget(effectID, source, invokeMode, ext); } }
public MapEffect(GameSpace space, object owner, EffectID eID, object source, EffectAction actionKind, int duration, int magnitude) : base(space, owner, eID, source, actionKind, duration, magnitude) { Ext = null; }
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); } }