public void Process(int start, int length, int num, int whoAmI, byte[] readBuffer, byte bufferData)
        {
            short projectileIdentity = BitConverter.ToInt16(readBuffer, num);
            num += 2;
            float x = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            float y = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            float vX = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            float vY = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            float knockBack = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            short damage = BitConverter.ToInt16(readBuffer, num);
            num += 2;

            byte projectileOwner = readBuffer[num++];
            byte type = readBuffer[num++];

            if (type > 55)
            {
                Netplay.slots[whoAmI].Kick ("Invalid projectile.");
                return;
            }
            else if (type == (int)ProjectileType.FEATHER_HARPY || type == (int)ProjectileType.STINGER || type == (int)ProjectileType.SICKLE_DEMON)
            {
                Netplay.slots[whoAmI].Kick ("Projectile cheat detected.");
                return;
            }
            else if (type == (int)ProjectileType.HARPOON)
            {
                if (damage == 99)
                    ProgramLog.Debug.Log ("{0} sent a HARPOON projectile with damage 99.", Main.players[whoAmI].Name);
                //Netplay.slots[whoAmI].Kick("Harpoon hack detected.");
                return;
            }

            float[] aiInfo = new float[Projectile.MAX_AI];
            for (int i = 0; i < Projectile.MAX_AI; i++)
            {
                aiInfo[i] = BitConverter.ToSingle(readBuffer, num);
                num += 4;
            }

            int projectileIndex = getProjectileIndex(projectileOwner, projectileIdentity);
            Projectile oldProjectile = Main.projectile[projectileIndex];
            Projectile projectile = Registries.Projectile.Create(type);
            if (!projectile.Active || projectile.type != oldProjectile.type)
            {
                Netplay.slots[whoAmI].spamProjectile += 1f;
            }

            projectile.identity = projectileIdentity;
            projectile.Position.X = x;
            projectile.Position.Y = y;
            projectile.Velocity.X = vX;
            projectile.Velocity.Y = vY;
            projectile.damage = damage;
            projectile.Owner = projectileOwner;
            projectile.knockBack = knockBack;

            PlayerProjectileEvent playerEvent = new PlayerProjectileEvent();
            playerEvent.Sender = Main.players[whoAmI];
            playerEvent.Projectile = projectile;
            Program.server.PluginManager.processHook(Hooks.PLAYER_PROJECTILE, playerEvent);
            if (playerEvent.Cancelled || (!Program.properties.AllowExplosions && (type == 28 || type == 29 || type == 37) && !Main.players[whoAmI].Op))
            {
                // erase the projectile client-side
                projectile.Position.X = -1000;
                projectile.Position.Y = -1000;
                projectile.type = ProjectileType.UNKNOWN;

                var msg = NetMessage.PrepareThreadInstance ();
                msg.Projectile (projectile);
                msg.Send (whoAmI);

                return;
            }

            Main.projectile[projectileIndex] = projectile;

            for (int i = 0; i < Projectile.MAX_AI; i++)
            {
                projectile.ai[i] = aiInfo[i];
            }
            NetMessage.SendData(27, -1, whoAmI, "", projectileIndex);
        }
Exemplo n.º 2
0
 public override void onPlayerProjectileUse(PlayerProjectileEvent Event)
 {
     Event.Cancelled = CancelEvent(Event.Sender.Name);
     base.onPlayerProjectileUse(Event);
 }
        public override void onPlayerProjectileUse(PlayerProjectileEvent Event)
        {
            Program.tConsole.WriteLine("Projectile Thrown");

            if (isEnabled == false) { return; }
            if (!explosives)
            {

                int type = Event.Projectile.type;
                if (type == 28 || type == 29 || type == 37)
                {
                    Event.Cancelled = true;
                    Program.tConsole.WriteLine("[Plugin] Cancelled Explosive usage of Player: " + ((Player)Event.Sender).Name);
                }
            }

            if (isEnabled == false || explosives == false)
            {
                Event.Cancelled = true;
            }
        }
        public override void onPlayerProjectileUse(PlayerProjectileEvent Event)
        {
            if (Enabled && !explosivesAllowed) {

                int type = Event.Projectile.Type;
                if (type == 28 || type ==  29 || type == 37)
                {
                    Event.Cancelled = true;
                    ProgramLog.Log("[TSDM Plugin] Cancelled Explosive usage of Player: " + ((Player)Event.Sender).Name);
                }
            }
        }
 public override void onPlayerProjectileUse(PlayerProjectileEvent Event)
 {
     foreach (Region.Region rgn in regionManager.Regions)
         {
             if (rgn.HasPoint(Event.Projectile.Position / 16))
             {
                 if (rgn.IsRestrictedForUser(Event.Player))
                 {
                     Event.Cancelled = true;
                     Event.Player.sendMessage("You cannot edit this area!", ChatColour.Red);
                     return;
                 }
             }
         }
 }
 /// <summary>
 /// Hook method for all player projectile firing
 /// </summary>
 /// <param name="Event">PlayerProjectileEvent info</param>
 public virtual void onPlayerProjectileUse(PlayerProjectileEvent Event)
 {
 }
        public void Process(int start, int length, int num, int whoAmI, byte[] readBuffer, byte bufferData)
        {
            short projectileIdentity = BitConverter.ToInt16(readBuffer, num);
            num += 2;
            float x = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            float y = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            float vX = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            float vY = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            float knockBack = BitConverter.ToSingle(readBuffer, num);
            num += 4;
            short damage = BitConverter.ToInt16(readBuffer, num);
            num += 2;

            byte projectileOwner = readBuffer[num++];
            byte type = readBuffer[num++];

            float[] aiInfo = new float[Projectile.MAX_AI];
            for (int i = 0; i < Projectile.MAX_AI; i++)
            {
                aiInfo[i] = BitConverter.ToSingle(readBuffer, num);
                num += 4;
            }

            int projectileIndex = getProjectileIndex(projectileOwner, projectileIdentity);
            Projectile oldProjectile = Main.projectile[projectileIndex];
            Projectile projectile = Registries.Projectile.Create(type);
            if (!projectile.Active || projectile.type != oldProjectile.type)
            {
                Netplay.slots[whoAmI].spamProjectile += 1f;
            }

            projectile.identity = projectileIdentity;
            projectile.Position.X = x;
            projectile.Position.Y = y;
            projectile.Velocity.X = vX;
            projectile.Velocity.Y = vY;
            projectile.damage = damage;
            projectile.Owner = projectileOwner;
            projectile.knockBack = knockBack;

            PlayerProjectileEvent playerEvent = new PlayerProjectileEvent();
            playerEvent.Sender = Main.players[whoAmI];
            playerEvent.Projectile = Main.projectile[projectileIndex];
            Program.server.PluginManager.processHook(Hooks.PLAYER_PROJECTILE, playerEvent);
            if (playerEvent.Cancelled)
            {
                return;
            }

            Main.projectile[projectileIndex] = projectile;

            for (int i = 0; i < Projectile.MAX_AI; i++)
            {
                projectile.ai[i] = aiInfo[i];
            }
            NetMessage.SendData(27, -1, whoAmI, "", projectileIndex);
        }
Exemplo n.º 8
0
 public override void onPlayerProjectileUse(PlayerProjectileEvent Event)
 {
     if (isEnabled == false || configPlayerProjectile == false)
     {
         return;
     }
     else
     {
         Player Player = (Player)Event.Sender;
         ProjectileType type = Event.Projectile.type;
         //Program.tConsole.WriteLine("[" + base.Name + "] " + Event.Sender.Name + " Launched Projectile of type " + type + "(" + Event.Projectile.Name + ")");
         if (type == ProjectileType.DYNAMITE || type == ProjectileType.GRENADE || type == ProjectileType.BOMB || type == ProjectileType.BOMB_STICKY)
         {
             Event.Cancelled = true;
             Player.sendMessage("You are not allowed to use explosives on this server.", 255, 255, 0, 0);
             Program.tConsole.WriteLine("[" + base.Name + "] Cancelled Projectile Use of Player: " + ((Player)Event.Sender).Name);
         }
     }
 }
        public override void onPlayerProjectileUse(PlayerProjectileEvent Event)
        {
            if (isEnabled == false) { return; }
            if(!explosivesAllowed) {

                int type = Event.getProjectile().type;
                if (type == 28 || type ==  29 || type == 37)
                {
                    Event.setCancelled(true);
                    Program.tConsole.WriteLine("[TSDM Plugin] Cancelled Explosive usage of Player: " + ((Player)Event.getSender()).name);
                }
            }
        }