Command Suggestion - /Grapple

Conor

Member
Joined
Dec 12, 2012
Messages
34
Reaction score
103
Hello. I have a command suggestion for you, with some code I have put together.

Basically, a player would shoot a grapple out, and if it makes contact with a player it will drag them back to the position the grapple was sent out. This would be cool for strategic play... i.e. a player could place a TNT block / some sort of weapon where they are and then grapple a player to their location.

As you have weapon upgrades, you could give the grapple a specific length. So maybe a length of 30 within the grapple line to begin with, which could upgrade to 40-50; as an idea. If the grapple doesn't find a player after its length is reached, or it hits a solid black, it will return back to the player like normal - just without a player attached to the end!

If you want to look at the actual command, I'll put it in my own software so you can come along to a server and take a look. You can pm me for a URL as I don't want to advertise. Its a pretty weird idea I know, please criticise and reject it by any means xD

So here is some code, feel free to use/modify it in any shape or form.

Code:
using System;
using System.Threading;
using System.Collections.Generic;
 
namespace BlockTopiaTNT // Not sure what namespace/software you're using.
{
    public class CmdGrapple : Command
    {
        public struct CatchPos { public ushort x, y, z; }
        public struct Pos { public ushort x, y, z; }
 
        public override string name { get { return "grapple"; } }
        public override string shortcut { get { return  "grap"; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
        public CmdGrapple() { }
 
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/grapple - shoot a grapple and pull a player back to your position!");
        }
 
        public override void Use(Player p, string message)
        {
            Player.SendMessage(p, "Grapple shooting in 1.5 seconds...");
            Thread.Sleep(1000);
            Player.SendMessage(p, "Grapple shooting...");
            Thread.Sleep(500);
            // Could replace the above with a glass aim box like /gun if preferred.
 
            double aVal = Math.Sin(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
            double bVal = Math.Cos(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
            double cVal = Math.Cos(((double)(p.rot[1] + 64) / 256) * 2 * Math.PI);
 
            double maxOut = 30;
            bool foundPlayer = false;
 
            List<CatchPos> added = new List<CatchPos>();
            CatchPos pos, trueStart;
 
            Thread grappleThread = new Thread(new ThreadStart(delegate
            {
                ushort posX = (ushort)(p.pos[0] / 32);
                ushort posY = (ushort)(p.pos[1] / 32);
                ushort posZ = (ushort)(p.pos[2] / 32);
 
                trueStart.x = p.pos[0]; trueStart.y = p.pos[1]; trueStart.z = p.pos[2];
 
                for (double d = 3; d < maxOut + 3; d++)
                {
                    pos.x = (ushort)Math.Round((double)(aVal * d) + posX);
                    pos.y = (ushort)Math.Round((double)(cVal * d) + posY);
                    pos.z = (ushort)Math.Round((double)(bVal * d) + posZ);
 
                    if (p.level.GetTile(pos.x, pos.y, pos.z) != Block.air && !added.Contains(pos))
                    {
                        added.Reverse();
                        for (int i = 0; i < added.Count; i++)
                        {
                            Thread.Sleep(21);
                            p.level.Blockchange(added[i].x, added[i].y, added[i].z, Block.air);
                        }
                        return;
                    }
                    else
                    {
                        Player.players.ForEach(delegate(Player who)
                        {
                            if (who.level == p.level && !who.hidden && !who.referee && !foundPlayer)
                            {
                                if ((ushort)(who.pos[0] / 32) == pos.x || (ushort)(who.pos[0] / 32 + 1) == pos.x || (ushort)(who.pos[0] / 32 - 1) == pos.x)
                                {
                                    if ((ushort)(who.pos[1] / 32) == pos.y || (ushort)(who.pos[1] / 32 + 1) == pos.y || (ushort)(who.pos[1] / 32 - 1) == pos.y)
                                    {
                                        if ((ushort)(who.pos[2] / 32) == pos.z || (ushort)(who.pos[2] / 32 + 1) == pos.z || (ushort)(who.pos[2] / 32 - 1) == pos.z)
                                        {
                                            Player.SendMessage(who, p.color + p.name + c.red + " has hooked you onto their " + c.black + "grapple!");
                                            Player.SendMessage(p, c.red + "You hooked " + who.color + who.name + c.red + " onto your " + c.black + "grapple!");
                                            Thread.Sleep(100);
 
                                            added.Reverse();
                                            for (int i = 0; i < added.Count; i++)
                                            {
                                                Thread.Sleep(21);
                                                if (i == added.Count - 1)
                                                {
                                                    unchecked { who.SendPos((byte)-1, (ushort)(added[i].x * 32), (ushort)(added[i].y * 32), (ushort)(added[i].z * 32), who.rot[0], who.rot[1]); }
                                                    Thread.Sleep(15);
                                                    unchecked { who.SendPos((byte)-1, (ushort)(trueStart.x * 32), (ushort)(trueStart.y * 32), (ushort)(trueStart.z * 32), who.rot[0], who.rot[1]); }
                                                }
                                                else if (i > 1)
                                                {
                                                    unchecked { who.SendPos((byte)-1, (ushort)(added[i - 1].x * 32), (ushort)(added[i - 1].y * 32), (ushort)(added[i - 1].z * 32), who.rot[0], who.rot[1]); }
                                                }
                                                p.level.Blockchange(added[i].x, added[i].y, added[i].z, Block.air);
                                            }
                                            foundPlayer = true;
                                        }
                                    }
                                }
                            }
                        });
                    }
                    if (!foundPlayer)
                    {
                        Thread.Sleep(21);
                        p.level.Blockchange(p, pos.x, pos.y, pos.z, Block.darkgrey);
                        added.Add(pos);
                    }
                }
                try
                {
                    // Clear up any potential mess
                    added.Reverse();
                    for (int i = 0; i < added.Count; i++)
                    {
                        Thread.Sleep(21);
                        p.level.Blockchange(added[i].x, added[i].y, added[i].z, Block.air);
                    }
                }
                catch { }
            }));
            grappleThread.Start();
        }
    }
}
 

Conor

Member
Joined
Dec 12, 2012
Messages
34
Reaction score
103
That is a very good point. Maybe the grapple could be cheaper? Or maybe you could spice it up a little bit to make it its own little weapon. For example, it could freeze the player when they are grappled back to the starting position for 2-3 seconds, making them vulnerable to attack.

Like I said though, it is a pretty weird idea :L
 

Pikmon2

Member
Joined
Jan 26, 2012
Messages
915
Reaction score
1,282
That is a very good point. Maybe the grapple could be cheaper? Or maybe you could spice it up a little bit to make it its own little weapon. For example, it could freeze the player when they are grappled back to the starting position for 2-3 seconds, making them vulnerable to attack.

Like I said though, it is a pretty weird idea :L
Then it should be called a stun gun of sorts ;)

So, like, place tnt, then grapple a player to it? Interesting...
Now this is a bit more practical overall. Since grapple would take more time then just say, shooting a pistol, grabbing the player to a TNT would be pretty interesting, especially if it could grab multiple people at once (in a line).
 

superstein

Ex-Admin
Contributor
Joined
Mar 31, 2012
Messages
1,503
Reaction score
2,998
Hello. I have a command suggestion for you, with some code I have put together.

Basically, a player would shoot a grapple out, and if it makes contact with a player it will drag them back to the position the grapple was sent out. This would be cool for strategic play... i.e. a player could place a TNT block / some sort of weapon where they are and then grapple a player to their location.

As you have weapon upgrades, you could give the grapple a specific length. So maybe a length of 30 within the grapple line to begin with, which could upgrade to 40-50; as an idea. If the grapple doesn't find a player after its length is reached, or it hits a solid black, it will return back to the player like normal - just without a player attached to the end!

If you want to look at the actual command, I'll put it in my own software so you can come along to a server and take a look. You can pm me for a URL as I don't want to advertise. Its a pretty weird idea I know, please criticise and reject it by any means xD

So here is some code, feel free to use/modify it in any shape or form.

Code:
using System;
using System.Threading;
using System.Collections.Generic;
 
namespace BlockTopiaTNT // Not sure what namespace/software you're using.
{
    public class CmdGrapple : Command
    {
        public struct CatchPos { public ushort x, y, z; }
        public struct Pos { public ushort x, y, z; }
 
        public override string name { get { return "grapple"; } }
        public override string shortcut { get { return  "grap"; } }
        public override string type { get { return "other"; } }
        public override bool museumUsable { get { return true; } }
        public override LevelPermission defaultRank { get { return LevelPermission.Guest; } }
        public CmdGrapple() { }
 
        public override void Help(Player p)
        {
            Player.SendMessage(p, "/grapple - shoot a grapple and pull a player back to your position!");
        }
 
        public override void Use(Player p, string message)
        {
            Player.SendMessage(p, "Grapple shooting in 1.5 seconds...");
            Thread.Sleep(1000);
            Player.SendMessage(p, "Grapple shooting...");
            Thread.Sleep(500);
            // Could replace the above with a glass aim box like /gun if preferred.
 
            double aVal = Math.Sin(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
            double bVal = Math.Cos(((double)(128 - p.rot[0]) / 256) * 2 * Math.PI);
            double cVal = Math.Cos(((double)(p.rot[1] + 64) / 256) * 2 * Math.PI);
 
            double maxOut = 30;
            bool foundPlayer = false;
 
            List<CatchPos> added = new List<CatchPos>();
            CatchPos pos, trueStart;
 
            Thread grappleThread = new Thread(new ThreadStart(delegate
            {
                ushort posX = (ushort)(p.pos[0] / 32);
                ushort posY = (ushort)(p.pos[1] / 32);
                ushort posZ = (ushort)(p.pos[2] / 32);
 
                trueStart.x = p.pos[0]; trueStart.y = p.pos[1]; trueStart.z = p.pos[2];
 
                for (double d = 3; d < maxOut + 3; d++)
                {
                    pos.x = (ushort)Math.Round((double)(aVal * d) + posX);
                    pos.y = (ushort)Math.Round((double)(cVal * d) + posY);
                    pos.z = (ushort)Math.Round((double)(bVal * d) + posZ);
 
                    if (p.level.GetTile(pos.x, pos.y, pos.z) != Block.air && !added.Contains(pos))
                    {
                        added.Reverse();
                        for (int i = 0; i < added.Count; i++)
                        {
                            Thread.Sleep(21);
                            p.level.Blockchange(added[i].x, added[i].y, added[i].z, Block.air);
                        }
                        return;
                    }
                    else
                    {
                        Player.players.ForEach(delegate(Player who)
                        {
                            if (who.level == p.level && !who.hidden && !who.referee && !foundPlayer)
                            {
                                if ((ushort)(who.pos[0] / 32) == pos.x || (ushort)(who.pos[0] / 32 + 1) == pos.x || (ushort)(who.pos[0] / 32 - 1) == pos.x)
                                {
                                    if ((ushort)(who.pos[1] / 32) == pos.y || (ushort)(who.pos[1] / 32 + 1) == pos.y || (ushort)(who.pos[1] / 32 - 1) == pos.y)
                                    {
                                        if ((ushort)(who.pos[2] / 32) == pos.z || (ushort)(who.pos[2] / 32 + 1) == pos.z || (ushort)(who.pos[2] / 32 - 1) == pos.z)
                                        {
                                            Player.SendMessage(who, p.color + p.name + c.red + " has hooked you onto their " + c.black + "grapple!");
                                            Player.SendMessage(p, c.red + "You hooked " + who.color + who.name + c.red + " onto your " + c.black + "grapple!");
                                            Thread.Sleep(100);
 
                                            added.Reverse();
                                            for (int i = 0; i < added.Count; i++)
                                            {
                                                Thread.Sleep(21);
                                                if (i == added.Count - 1)
                                                {
                                                    unchecked { who.SendPos((byte)-1, (ushort)(added[i].x * 32), (ushort)(added[i].y * 32), (ushort)(added[i].z * 32), who.rot[0], who.rot[1]); }
                                                    Thread.Sleep(15);
                                                    unchecked { who.SendPos((byte)-1, (ushort)(trueStart.x * 32), (ushort)(trueStart.y * 32), (ushort)(trueStart.z * 32), who.rot[0], who.rot[1]); }
                                                }
                                                else if (i > 1)
                                                {
                                                    unchecked { who.SendPos((byte)-1, (ushort)(added[i - 1].x * 32), (ushort)(added[i - 1].y * 32), (ushort)(added[i - 1].z * 32), who.rot[0], who.rot[1]); }
                                                }
                                                p.level.Blockchange(added[i].x, added[i].y, added[i].z, Block.air);
                                            }
                                            foundPlayer = true;
                                        }
                                    }
                                }
                            }
                        });
                    }
                    if (!foundPlayer)
                    {
                        Thread.Sleep(21);
                        p.level.Blockchange(p, pos.x, pos.y, pos.z, Block.darkgrey);
                        added.Add(pos);
                    }
                }
                try
                {
                    // Clear up any potential mess
                    added.Reverse();
                    for (int i = 0; i < added.Count; i++)
                    {
                        Thread.Sleep(21);
                        p.level.Blockchange(added[i].x, added[i].y, added[i].z, Block.air);
                    }
                }
                catch { }
            }));
            grappleThread.Start();
        }
    }
}
We use iCraft (which I believe we're the only one left? D: ) and it's coded in python as far as I know, might be better to talk to KingSam about this, or destroyerx1 (our developer) if he pops in.

And on to the actual idea, I like it, but it seems impractical. It would require a lot of tweaking to zones or the weapon in itself to actually function right, but it could be a cool addition.

Also, I love how you coded the suggestion. You're pretty talented :)
 

superstein

Ex-Admin
Contributor
Joined
Mar 31, 2012
Messages
1,503
Reaction score
2,998
Well, I wish I could code like you still :p
But yeah, because of the coding in Python there are only so many people that can code it, plus the fact that iCraft is pretty much impossible to get a hold of now, and is much different from MCLawl/MCZombie/MCForge/MCOtherones.
But thanks for your suggestion, seems interesting looking at the code (not that I can understand any of it!)
 

pjaj

Member
Joined
Oct 4, 2011
Messages
85
Reaction score
87
hihihilolHI said:
Nonono, actually the idea still is good, it just needs some refinement. How about making it go further and be wider, like a fat pistol that drags people in front of you?
multi hook upgrade? so like a shotgun's shape? neat idea overall, though :)
 

Conor

Member
Joined
Dec 12, 2012
Messages
34
Reaction score
103
To answer your question Dah_Bomb, it shoots where the player is aiming (that may be a diagonal, or a straight line), but it will last for 20 theoretical blocks in length, then return back to the player.
 

Kattzen

Kattzen!
Joined
Aug 6, 2011
Messages
250
Reaction score
378
If it returns back to the player, can someone walk into the line of the shot when it's returning and still get grappled by it? That would be very interesting. Also, how would you distinguish the grapple line from a pistol or a laser? Maybe make the line water or something.

All in all, very interesting idea and I'd like to see if it can be modified to actually be able to be implemented into the game. Still needs some modifications and whatnot but it has potential. c:
 

Conor

Member
Joined
Dec 12, 2012
Messages
34
Reaction score
103
You could easily make it capable of grappling multiple players, and the block used for the grapple can easily be changed to something that people prefer. My code above doesn't allow multiple players to be caught although that doesn't really matter as my code wouldn't work with your server anyway; if you would go ahead with the command it would have to be made by your awesome developers! So they could make it a lot more interesting if they wanted to use the idea.
 

pjaj

Member
Joined
Oct 4, 2011
Messages
85
Reaction score
87
how about brown mushrooms as a 'chain' maybe with a block at the end? also, if it went exactly where you were looking, it would hit a block cause you would have to place something...
 

Conor

Member
Joined
Dec 12, 2012
Messages
34
Reaction score
103
how about brown mushrooms as a 'chain' maybe with a block at the end? also, if it went exactly where you were looking, it would hit a block cause you would have to place something...
That is a very awesome idea!

You don't have to place a block for it, it could be designed to be activated in two ways;

One being an instant use of the grapple, a few seconds after the command is entered (so the grapple is shot where you are aiming).

Secondly is the option of creating an 'aiming box'. If you have ever used the /gun command you will know what I am talking about. It is a small glass box that stays in front of you, when you hit it, a chain could be shot in the direction you were facing.
 

Razinao

:_;
Joined
Aug 6, 2011
Messages
834
Reaction score
757
Like the rocket, grenade [upgraded] and mortar [upgraded], the aim is done by the angle you place the block down at.

Now my field isn't making new weapons. My field is the interactivity of maps, such as clicking a block producing the CTF element or standing in an area producing a KOTH element. This is out of my jurisdiction, unfortunately.
 
Top