mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-06 13:15:42 +12:00
Add the most important command and feature in the entire game,
This commit is contained in:
parent
b8242010ad
commit
5cac72f67a
4 changed files with 117 additions and 16 deletions
|
@ -160,7 +160,9 @@ namespace HISP.Game.Chat
|
|||
|
||||
else if (message.ToUpper().StartsWith("!WARP"))
|
||||
return Command.Warp(message, args, user);
|
||||
|
||||
|
||||
else if (message.ToUpper().StartsWith("!DANCE"))
|
||||
return Command.Dance(message, args, user);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -305,19 +305,21 @@ namespace HISP.Game.Chat
|
|||
formattedmessage += Messages.FailedToUnderstandLocation;
|
||||
goto sendText;
|
||||
|
||||
|
||||
|
||||
doCommand:;
|
||||
|
||||
if (args.Length <= 0)
|
||||
{
|
||||
goto cantUnderstandCommand;
|
||||
}
|
||||
else
|
||||
{
|
||||
string areaName = string.Join(" ", args).ToLower();
|
||||
foreach (GameClient client in GameServer.ConnectedClients)
|
||||
{
|
||||
if (client.LoggedIn)
|
||||
{
|
||||
if(client.LoggedinUser.Username.ToLower().Contains(args[0].ToLower()))
|
||||
if(client.LoggedinUser.Username.ToLower().Contains(areaName))
|
||||
{
|
||||
user.Teleport(client.LoggedinUser.X, client.LoggedinUser.Y);
|
||||
formattedmessage += Messages.SuccessfullyWarpedToPlayer;
|
||||
|
@ -328,7 +330,7 @@ namespace HISP.Game.Chat
|
|||
|
||||
foreach(World.Waypoint waypoint in World.Waypoints)
|
||||
{
|
||||
if(waypoint.Name.ToLower().Contains(args[0].ToLower()))
|
||||
if(waypoint.Name.ToLower().Contains(areaName))
|
||||
{
|
||||
user.Teleport(waypoint.PosX, waypoint.PosY);
|
||||
formattedmessage += Messages.SuccessfullyWarpedToLocation;
|
||||
|
@ -350,6 +352,18 @@ namespace HISP.Game.Chat
|
|||
|
||||
return true;
|
||||
}
|
||||
public static bool Dance(string message, string[] args, User user)
|
||||
{
|
||||
string moves = string.Join(" ", args).ToLower();
|
||||
string formattedmessage = Messages.FormatPlayerCommandCompleteMessage(message.Substring(1));
|
||||
|
||||
new Dance(user, moves);
|
||||
|
||||
byte[] chatPacket = PacketBuilder.CreateChat(formattedmessage, PacketBuilder.CHAT_BOTTOM_LEFT);
|
||||
user.LoggedinClient.SendPacket(chatPacket);
|
||||
return true;
|
||||
|
||||
}
|
||||
public static bool Mute(string message, string[] args, User user)
|
||||
{
|
||||
string formattedmessage = Messages.FormatPlayerCommandCompleteMessage(message.Substring(1));
|
||||
|
|
89
Horse Isle Server/HorseIsleServer/Player/Dance.cs
Normal file
89
Horse Isle Server/HorseIsleServer/Player/Dance.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
using HISP.Server;
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace HISP.Player
|
||||
{
|
||||
public class Dance : IDisposable
|
||||
{
|
||||
public const int DanceSpeed = 1000;
|
||||
private Timer danceTimer;
|
||||
public string Moves;
|
||||
public int MoveIndex;
|
||||
private User baseUser;
|
||||
|
||||
public Dance(User BaseUser, string DanceMoves)
|
||||
{
|
||||
baseUser = BaseUser;
|
||||
Moves = DanceMoves.ToLower();
|
||||
MoveIndex = -1;
|
||||
danceTimer = new Timer(new TimerCallback(onDanceTick), null, DanceSpeed, DanceSpeed);
|
||||
}
|
||||
|
||||
private void onDanceTick(object state)
|
||||
{
|
||||
|
||||
MoveIndex++;
|
||||
if (MoveIndex >= Moves.Length)
|
||||
goto done;
|
||||
|
||||
|
||||
int onHorse = 0;
|
||||
int facing = baseUser.Facing;
|
||||
while (facing >= 5)
|
||||
{
|
||||
facing -= 5;
|
||||
onHorse++;
|
||||
}
|
||||
|
||||
char moveInDir = Moves[MoveIndex];
|
||||
|
||||
int direction;
|
||||
|
||||
switch(moveInDir)
|
||||
{
|
||||
case 'u':
|
||||
direction = PacketBuilder.DIRECTION_UP;
|
||||
break;
|
||||
case 'd':
|
||||
direction = PacketBuilder.DIRECTION_DOWN;
|
||||
break;
|
||||
case 'l':
|
||||
direction = PacketBuilder.DIRECTION_LEFT;
|
||||
break;
|
||||
case 'r':
|
||||
direction = PacketBuilder.DIRECTION_RIGHT;
|
||||
break;
|
||||
default:
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
||||
baseUser.Facing = direction + (onHorse * 5);
|
||||
|
||||
byte[] moveResponse = PacketBuilder.CreateMovementPacket(baseUser.X, baseUser.Y, baseUser.CharacterId, baseUser.Facing, PacketBuilder.DIRECTION_NONE, false);
|
||||
baseUser.LoggedinClient.SendPacket(moveResponse);
|
||||
|
||||
GameServer.UpdateUserFacingAndLocation(baseUser);
|
||||
|
||||
done:;
|
||||
if (MoveIndex < Moves.Length)
|
||||
{
|
||||
danceTimer.Change(DanceSpeed, DanceSpeed);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
baseUser = null;
|
||||
Moves = null;
|
||||
danceTimer.Dispose();
|
||||
danceTimer = null;
|
||||
MoveIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4142,7 +4142,7 @@ namespace HISP.Server
|
|||
sender.SendPacket(chatPacket);
|
||||
|
||||
UpdateArea(sender);
|
||||
UpdateUserInfo(sender.LoggedinUser);
|
||||
UpdateUserFacingAndLocation(sender.LoggedinUser);
|
||||
}
|
||||
else if (method == PacketBuilder.SECCODE_AWARD)
|
||||
{
|
||||
|
@ -4659,7 +4659,7 @@ namespace HISP.Server
|
|||
int facing = sender.LoggedinUser.Facing;
|
||||
while (facing >= 5)
|
||||
{
|
||||
facing = facing - 5;
|
||||
facing -= 5;
|
||||
onHorse++;
|
||||
}
|
||||
byte direction = 0;
|
||||
|
@ -5390,6 +5390,7 @@ namespace HISP.Server
|
|||
|
||||
if (message == "")
|
||||
return;
|
||||
|
||||
|
||||
if (Chat.ProcessCommand(sender.LoggedinUser, message))
|
||||
{
|
||||
|
@ -6768,7 +6769,7 @@ namespace HISP.Server
|
|||
if (client.LoggedinUser.Id != userId)
|
||||
client.SendPacket(loginMessageBytes);
|
||||
|
||||
UpdateUserInfo(sender.LoggedinUser);
|
||||
UpdateUserFacingAndLocation(sender.LoggedinUser);
|
||||
|
||||
}
|
||||
else
|
||||
|
@ -7066,7 +7067,7 @@ namespace HISP.Server
|
|||
if(!nearbyUser.MetaPriority)
|
||||
UpdateArea(nearbyUser.LoggedinClient);
|
||||
|
||||
UpdateUserInfo(client.LoggedinUser);
|
||||
UpdateUserFacingAndLocation(client.LoggedinUser);
|
||||
}
|
||||
|
||||
public static void UpdateDrawingForAll(string id, GameClient sender, string drawing, bool includingSender=false)
|
||||
|
@ -7150,21 +7151,16 @@ namespace HISP.Server
|
|||
byte[] PlayerData = PacketBuilder.CreatePlayerData(forClient.LoggedinUser.Money, GameServer.GetNumberOfPlayers(), forClient.LoggedinUser.MailBox.MailCount);
|
||||
forClient.SendPacket(PlayerData);
|
||||
}
|
||||
public static void UpdateUserInfo(User user)
|
||||
public static void UpdateUserFacingAndLocation(User user)
|
||||
{
|
||||
byte[] playerInfoBytes = PacketBuilder.CreatePlayerInfoUpdateOrCreate(user.X, user.Y, user.Facing, user.CharacterId, user.Username);
|
||||
|
||||
|
||||
|
||||
List<User> users = new List<User>();
|
||||
foreach (GameClient client in ConnectedClients)
|
||||
if (client.LoggedIn)
|
||||
{
|
||||
if (client.LoggedinUser.Id != user.Id)
|
||||
client.SendPacket(playerInfoBytes);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static void UpdateAreaForAll(int x, int y, bool ignoreMetaPrio=false, User exceptMe=null)
|
||||
{
|
||||
|
@ -7348,7 +7344,7 @@ namespace HISP.Server
|
|||
byte[] rideHorsePacket = PacketBuilder.CreateHorseRidePacket(sender.LoggedinUser.X, sender.LoggedinUser.Y, sender.LoggedinUser.CharacterId, sender.LoggedinUser.Facing, 10, true);
|
||||
sender.SendPacket(rideHorsePacket);
|
||||
|
||||
UpdateUserInfo(sender.LoggedinUser);
|
||||
UpdateUserFacingAndLocation(sender.LoggedinUser);
|
||||
}
|
||||
public static void StopRidingHorse(GameClient sender)
|
||||
{
|
||||
|
@ -7363,7 +7359,7 @@ namespace HISP.Server
|
|||
sender.SendPacket(rideHorsePacket);
|
||||
sender.LoggedinUser.NoClip = false;
|
||||
|
||||
UpdateUserInfo(sender.LoggedinUser);
|
||||
UpdateUserFacingAndLocation(sender.LoggedinUser);
|
||||
}
|
||||
public static bool ProcessMapCodeWithArg(GameClient forClient, World.SpecialTile tile)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue