static void PlayerPlacing(object sender, PlayerPlacingBlockEventArgs e) { if (e.Player.World != world || e.Result != CanPlaceResult.Allowed) return; if (e.NewBlock == Opposition(e.Player.Team).FlagBlock) { e.Player.Message("&sYou cannot place {0}&s blocks, you are on the {1}&s Team.", Opposition(e.Player.Team).ClassyName, e.Player.Team.ClassyName); e.Result = CanPlaceResult.CTFDenied; } else if (e.NewBlock == Block.Lava || e.NewBlock == Block.Water) { if (e.Context == BlockChangeContext.Manual) e.Player.Message("You are not allowed to place water or lava blocks in CTF."); e.Result = CanPlaceResult.CTFDenied; } else if (e.Context != BlockChangeContext.Manual) { e.Result = CanPlaceResult.CTFDenied; } else { if ((e.Coords == RedTeam.FlagPos || e.Coords == BlueTeam.FlagPos) && (e.NewBlock == RedTeam.FlagBlock || e.NewBlock == BlueTeam.FlagBlock || e.NewBlock == Block.Air)) { if (e.Coords == BlueTeam.FlagPos && e.Player.Team == RedTeam) ClickOpposingFlag(e, BlueTeam); else if (e.Coords == RedTeam.FlagPos && e.Player.Team == BlueTeam) ClickOpposingFlag(e, RedTeam); else if (e.Coords == RedTeam.FlagPos && e.Player.Team == RedTeam) ClickOwnFlag(e, BlueTeam); else if (e.Coords == BlueTeam.FlagPos && e.Player.Team == BlueTeam) ClickOwnFlag(e, RedTeam); } else if (e.Coords == RedTeam.FlagPos || e.Coords == BlueTeam.FlagPos) { e.Result = CanPlaceResult.CTFDenied; } else if (e.OldBlock == RedTeam.FlagBlock || e.OldBlock == BlueTeam.FlagBlock) { DoClickEffect(99, 75, e, Block.CobbleSlab, Block.Stone); } else if (e.OldBlock == Block.Stone) { DoClickEffect(99, 75, e, Block.Gravel, Block.Cobblestone); } else if (e.OldBlock == Block.Cobblestone) { DoClickEffect(99, 75, e, Block.Air, Block.Gravel); } else if (e.OldBlock == Block.Gravel) { DoClickEffect(75, 1000, e, Block.Air, Block.None); } else if (e.OldBlock == Block.Grass) { DoClickEffect(25, 1000, e, Block.Dirt, Block.None); } else if (e.OldBlock == Block.Water) { e.Result = CanPlaceResult.CTFDenied; } else if (e.NewBlock == Block.TNT) { HandleTNT(e.Player, e.Coords); e.Result = CanPlaceResult.CTFDenied; world.Map.QueueUpdate(new BlockUpdate(Player.Console, e.Coords, Block.Air)); world.Map.ProcessUpdates(); } else { e.Result = CanPlaceResult.Allowed; } } if (world != null) world.Map.ProcessUpdates(); }
public static void PlayerPlacingBlock ( object sender, PlayerPlacingBlockEventArgs e ) { foreach ( FeedData feed in e.Player.World.Feeds.Values ) { for ( int x = feed.StartPos.X; x <= feed.FinishPos.X; x++ ) { for ( int y = feed.StartPos.Y; y <= feed.FinishPos.Y; y++ ) { for ( int z = feed.StartPos.Z; z <= feed.FinishPos.Z; z++ ) { if ( e.Coords == new Vector3I( x, y, z ) ) { e.Result = CanPlaceResult.Revert; } } } } } }
static void ClickOpposingFlag(PlayerPlacingBlockEventArgs e, CtfTeam opposition) { if (opposition.HasFlag) { e.Player.Message("You can't capture the opposing team's flag, " + "if you're not in posession of your own flag."); e.Result = CanPlaceResult.CTFDenied; } else { e.Result = CanPlaceResult.Allowed; e.Player.Team.HasFlag = true; e.Player.IsHoldingFlag = true; world.Players.Message("{0} &sgot the {1}&s flag.", e.Player.ClassyName, opposition.ClassyName ); } }
static void ClickOwnFlag(PlayerPlacingBlockEventArgs e, CtfTeam opposition) { if (!e.Player.IsHoldingFlag) { e.Player.Message("You don't have the {0}&s flag.", opposition.ClassyName); e.Result = CanPlaceResult.CTFDenied; } else { world.Map.QueueUpdate(new BlockUpdate(Player.Console, opposition.FlagPos, opposition.FlagBlock)); CtfTeam team = e.Player.Team; team.Score++; team.HasFlag = false; e.Player.IsHoldingFlag = false; world.Players.Message("{0} &sscored a point for {1}&s team.", e.Player.ClassyName, team.ClassyName); e.Result = CanPlaceResult.CTFDenied; Check(); } }
private static void Player_PlacingBlock(object sender, Events.PlayerPlacingBlockEventArgs e) { Map map = e.Map; if (e.Map.MessageBlocks != null) { if (e.Map.MessageBlocks.Count > 0) { lock (e.Map.MessageBlocks) { foreach (MessageBlock mb in e.Map.MessageBlocks) { if (e.Coords == mb.AffectedBlock) { e.Result = CanPlaceResult.Revert; if (e.Context == BlockChangeContext.Manual) { if (mb.IsInRange(e.Coords)) { string M = mb.GetMessage(); if (M == "") { return; } if (e.Player.LastUsedMessageBlock == null) { e.Player.LastUsedMessageBlock = DateTime.UtcNow; e.Player.Message(M); return; } if ((DateTime.UtcNow - e.Player.LastUsedMessageBlock).TotalSeconds > 4) { e.Player.Message(M); e.Player.LastUsedMessageBlock = DateTime.UtcNow; } } } } } } } } }
public static void blockSquash( object sender, PlayerPlacingBlockEventArgs e ) { try { Player player = e.Player; World world = player.World; if ( null == world ) return; lock ( world.SyncRoot ) { if ( null != world.Map && world.IsLoaded && world.plantPhysics ) { if ( e.NewBlock == Block.Plant ) { world.AddPhysicsTask( new PlantTask( world, ( short )e.Coords.X, ( short )e.Coords.Y, ( short )e.Coords.Z ), PlantTask.GetRandomDelay() ); } Vector3I z = new Vector3I( e.Coords.X, e.Coords.Y, e.Coords.Z - 1 ); if ( world.Map.GetBlock( z ) == Block.Grass && e.NewBlock != Block.Air ) { world.Map.QueueUpdate( new BlockUpdate( null, z, Block.Dirt ) ); } else if ( Physics.CanSquash( world.Map.GetBlock( z ) ) && e.NewBlock != Block.Air ) { e.Result = CanPlaceResult.Revert; Player.RaisePlayerPlacedBlockEvent( player, world.Map, z, world.Map.GetBlock( z ), e.NewBlock, BlockChangeContext.Physics ); world.Map.QueueUpdate( new BlockUpdate( null, z, e.NewBlock ) ); } } } } catch ( Exception ex ) { Logger.Log( LogType.SeriousError, "BlockSquash" + ex ); } }
public static void playerPlaced(object sender, PlayerPlacingBlockEventArgs e) { try { foreach (Player p in e.Player.World.Players) { if (e.OldBlock == Block.Water || e.OldBlock == Block.Lava) { if (p.orangePortal.Contains(e.Coords) || p.bluePortal.Contains(e.Coords)) { e.Result = CanPlaceResult.Revert; } } } } catch (Exception ex) { Logger.Log(LogType.SeriousError, "PlacingInPortal: " + ex); } }
public static void PlayerPlacingPhysics(object sender, PlayerPlacingBlockEventArgs e) { World world = e.Player.World; if (e.Result != CanPlaceResult.Allowed){ return; } if (e.NewBlock == Block.Gold) { if (e.Context == BlockChangeContext.Manual) { if (e.Player.fireworkMode && world.fireworkPhysics) { if (world.FireworkCount > 10) { e.Result = CanPlaceResult.Revert; e.Player.Message("&WThere are too many active fireworks on this world"); return; } else { world.FireworkCount++; world.AddPhysicsTask(new Firework(world, e.Coords), 300); } } } } if (e.NewBlock == Block.TNT) { if (world.tntPhysics) { if (e.Context == BlockChangeContext.Manual) { lock (world.SyncRoot) { world.AddPhysicsTask(new TNTTask(world, e.Coords, e.Player, false, true), 3000); return; } } } } if (e.NewBlock == Block.Sand || e.NewBlock == Block.Gravel) { if (e.Context == BlockChangeContext.Manual) { if (world.sandPhysics) { lock (world.SyncRoot) { world.AddPhysicsTask(new SandTask(world, e.Coords, e.NewBlock), 150); return; } } } } if (Physics.CanFloat(e.NewBlock)) { if (world.waterPhysics) { if (e.Context == BlockChangeContext.Manual) { world.AddPhysicsTask(new BlockFloat(world, e.Coords, e.NewBlock), 200); return; } } } if (!Physics.CanFloat(e.NewBlock) && e.NewBlock != Block.Air && e.NewBlock != Block.Water && e.NewBlock != Block.Lava && e.NewBlock != Block.BrownMushroom && e.NewBlock != Block.RedFlower && e.NewBlock != Block.RedMushroom && e.NewBlock != Block.YellowFlower && e.NewBlock != Block.Plant) { if (e.Context == BlockChangeContext.Manual) { if (world.waterPhysics) { world.AddPhysicsTask(new BlockSink(world, e.Coords, e.NewBlock), 200); return; } } } }
private static void PlayerPlacing( object sender, PlayerPlacingBlockEventArgs e ) { World world = e.Player.World; if ( world.gameMode == GameMode.MineField ) { e.Result = CanPlaceResult.Revert; } }
internal static CanPlaceResult RaisePlayerPlacingBlockEvent( Player player, short x, short y, short h, Block oldBlock, Block newBlock, bool manual, CanPlaceResult result ) { var handler = PlayerPlacingBlock; if( handler == null ) return result; var e = new PlayerPlacingBlockEventArgs( player, x, y, h, oldBlock, newBlock, manual, result ); handler( null, e ); return e.Result; }
static void DoClickEffect(int prob1, int prob2, PlayerPlacingBlockEventArgs e, Block target1, Block target2) { int effect = rnd.Next(100); if (effect >= prob1) map.QueueUpdate(new BlockUpdate(Player.Console, e.Coords, target1)); else if (effect >= prob2) map.QueueUpdate(new BlockUpdate(Player.Console, e.Coords, target2)); e.Result = CanPlaceResult.CTFDenied; }
public static void PlayerPlacedBlock( object sender, PlayerPlacingBlockEventArgs e ) { try { foreach ( Turret t in Cache.Turrets ) { if ( e.Player.World == t.world ) { if ( t.blocks.Contains( e.Coords ) ) { e.Result = CanPlaceResult.Revert; } } } if ( GuildManager.PlayerHasGuild( e.Player.Info ) ) { if ( e.Context == BlockChangeContext.Manual ) { if ( e.NewBlock != Block.Air ) { Guild g = GuildManager.PlayersGuild( e.Player.Info ); if ( !g.Provisional ) { g.AddXP( ( int )Exp.BlockPlaced * g.BuildingModifier ); } } } } } catch ( Exception e1 ) { Logger.Log( LogType.Error, "GuildPlaceBlock: " + e1 ); } }