#region :knife <user>
case "knife":
{
using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
{
virtualUser User = userManager.getUser(args[1]);
if (roomUser.walkLock == true)
{
sendData("BK" + "Nice try, but you are either stunned or cuffed and carnt stabb them.");
}
else
{
if (punchCdLooper != null)
{
Room.sendWhisper(roomUser, _Username, "*attempts to stab at " + User._Username + ", but is out of energy*");
}
else
{
int isArrested = dbClient.getInt("SELECT arrested FROM users WHERE name = '" + _Username + "'");
int canHit = dbClient.getInt("SELECT violence FROM rooms WHERE id = '" + _roomID + "'");
int isAfk = dbClient.getInt("SELECT afk FROM users WHERE name = '" + User._Username + "'");
if (isAfk == 1)
{
sendData("BK" + "Sorry, but this user is AFK.");
}
else
{
if (isArrested < 1)
{
if (canHit == 1)
{
sendData("BK" + "Sorry, but this room has been declared a no fighting zone So no fighting.");
}
else
{
if (User._roomID == _roomID && (roomUser.Y == User.roomUser.Y && roomUser.X == User.roomUser.X) || (roomUser.Y + 1 == User.roomUser.Y && roomUser.X == User.roomUser.X) || (roomUser.Y - 1 == User.roomUser.Y && roomUser.X == User.roomUser.X) || (roomUser.Y == User.roomUser.Y && roomUser.X + 1 == User.roomUser.X) || (roomUser.Y == User.roomUser.Y && roomUser.X - 1 == User.roomUser.X))
{
//db queries
int myHealth = dbClient.getInt("SELECT health FROM users WHERE name = '" + User._Username + "'");
int knife_mod = dbClient.getInt("SELECT str FROM users WHERE name = '" + _Username + "'");
//generates a random number
Random randNum = new Random();
int hit_dif_0 = randNum.Next(10, 30);
int hit_dif_1 = randNum.Next(30, 60);
//what a user hits
int hit = knife_mod * hit_dif_0 + hit_dif_1;
int getHit = myHealth - hit;
if (getHit < 1 && _Username == User._Username)
{
sendData("BK" + "Sorry, but you can not knock yourself out by stabbing.");
}
else
{
dbClient.runQuery("UPDATE users SET health = health - '" + hit + "' WHERE name = '" + User._Username + "'");
dbClient.runQuery("UPDATE users SET hits = hits + 1 WHERE name = '" + _Username + "'");
int health_db_ko = dbClient.getInt("SELECT health FROM users WHERE name = '" + User._Username + "'");
Room.sendShout(roomUser, "*Swings at " + args[1] + ", causing " + hit + " damage*");
ThreadStart punchCdStarter = new ThreadStart(punchCoolDown);
punchCdLooper = new Thread(punchCdStarter);
punchCdLooper.Priority = ThreadPriority.Lowest;
punchCdLooper.Start();
//if the user has 0 or less helth left
if (health_db_ko < 1)
{
if (User._Mission == "[Game] Deathmatch" || User._Mission == "[Game] Brawl")
{
Room.sendShout(roomUser, "*Knocks out " + args[1] + ", sending them to the lobby*");
if (User._Mission == "[Game] Deathmatch")
{
if (_Mission == "[Game] Deathmatch")
{
dbClient.runQuery("UPDATE users SET game_dm = game_dm + '10' WHERE name = '" + _Username + "'");
}
User.sendData("D^" + "H" + Encoding.encodeVL64(272));
User.sendData("BK" + "Thank you for playing deathmatch.");
}
if (User._Mission == "[Game] Brawl")
{
if (_Mission == "[Game] Brawl")
{
dbClient.runQuery("UPDATE users SET game_brawl = game_brawl + '10' WHERE name = '" + _Username + "'");
}
User.sendData("D^" + "H" + Encoding.encodeVL64(181));
User.sendData("BK" + "Thank you for playing brawl.");
}
User.refreshAppearance(true, true, true);
dbClient.runQuery("UPDATE users SET health = '100' WHERE name = '" + User._Username + "'");
}
else
{
User.sendData("D^" + "H" + Encoding.encodeVL64(153));
User.sendData("BK" + "You have been knocked out by another user and sent to the hospital.");
Room.sendShout(roomUser, "*Knocks out " + args[1] + ", sending them to the hospital*");
dbClient.runQuery("UPDATE users SET kills = kills + 1 WHERE name = '" + _Username + "'");
dbClient.runQuery("UPDATE users SET deaths = deaths + 1, dead = '1', time_dead = '10' WHERE name = '" + User._Username + "'");
User._Mission = "Dead";
refreshAppearance(true, true, true);
ThreadStart koStarter = new ThreadStart(User.knockOut);
User.deadLooper = new Thread(koStarter);
User.deadLooper.Priority = ThreadPriority.Lowest;
User.deadLooper.Start();
User.roomUser.walkLock = true;
}
}
}
}
else
{
if (User._roomID == _roomID && (roomUser.Y + 1 == User.roomUser.Y && roomUser.X + 1 == User.roomUser.X) || (roomUser.Y - 1 == User.roomUser.Y && roomUser.X - 1 == User.roomUser.X) || (roomUser.Y - 1 == User.roomUser.Y && roomUser.X + 1 == User.roomUser.X) || (roomUser.Y + 1 == User.roomUser.Y && roomUser.X - 1 == User.roomUser.X))
{
Room.sendShout(roomUser, "*stabs at " + args[1] + ", but misses*");
}
}
}
}
}
}
}
}
break;
}
#endregion