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.
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();
}
}
}