public static GreenThornsEffect Create(Mobile from, LandTarget land) { if (!from.Map.CanSpawnMobile(land.Location)) { return(null); } int tileID = land.TileID; foreach (TilesAndEffect taep in m_Table) { bool contains = false; for (int i = 0; !contains && i < taep.Tiles.Length; i += 2) { contains = (tileID >= taep.Tiles[i] && tileID <= taep.Tiles[i + 1]); } if (contains) { GreenThornsEffect effect = (GreenThornsEffect)Activator.CreateInstance(taep.Effect, new object[] { land.Location, from.Map, from }); return(effect); } } return(null); }
protected override void OnTarget(Mobile from, object targeted) { if (m_Thorn.Deleted) { return; } if (!m_Thorn.IsChildOf(from.Backpack)) { from.SendLocalizedMessage(1042664); // You must have the object in your backpack to use it. return; } if (!from.CanBeginAction(typeof(GreenThorns))) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061908); // * You must wait a while before planting another thorn. * return; } if (from.Map != Map.Trammel && from.Map != Map.Felucca) { from.LocalOverheadMessage(MessageType.Regular, 0x2B2, true, "No solen lairs exist on this facet. Try again in Trammel or Felucca."); return; } LandTarget land = targeted as LandTarget; if (land == null) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061912); // * You cannot plant a green thorn there! * } else { GreenThornsEffect effect = GreenThornsEffect.Create(from, land); if (effect == null) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1061913); // * You sense it would be useless to plant a green thorn there. * } else { m_Thorn.Consume(); from.LocalOverheadMessage(MessageType.Emote, 0x961, 1061914); // * You push the strange green thorn into the ground * from.NonlocalOverheadMessage(MessageType.Emote, 0x961, 1061915, from.Name); // * ~1_PLAYER_NAME~ pushes a strange green thorn into the ground. * from.BeginAction(typeof(GreenThorns)); new GreenThorns.EndActionTimer(from).Start(); effect.Start(); } } }