You may only view posts in an undeveloped area if you are currently there. This is to keep people from finding resources without actually exploring with their character.
';
} else {
$currentRoom = getInfo(room,users,"WHERE id='$userId'");
if (((!getInfo(hidden,rooms,"WHERE id='$id'")) && (!getInfo(view,rooms,"WHERE id='$id'"))) || ($currentRoom == $id) || ($user_name == "Irshad") || (getInfo(id,viewing,"WHERE room='$currentRoom' and room2='$id'"))) {
# START PROCESSING OF COMMANDS OSHI-
if (($_POST['mode'] == "post") && (!getInfo(post,bans,"WHERE user='$account'"))) {
$fighting = false;
$result = getRows(users,"WHERE room='$id' and (status='unconscious' or status='conscious')");
while ($row = mysql_fetch_array($result)) {
$name = $row['id'];
if (isFighting($name)) $fighting = true;
}
$post = nl2br($_POST['post']);
if ($_POST['command'] == "buy1") $_POST['command'] = "buy";
if (($post) || ($_POST['command'] == "move")) {
$post = validate($post);
$post_count = explode(' ',$post);
$post_count = count($post_count);
if (html_format($post)) $failure = "Please remove the HTML from the post.";
$command = $_POST['command'];
if (($command == "basic") || ($command == "door") || ($command == "shop") || ($command == "blank") || ($command == "fighting") || ($command == "slave") || ($command == "guarding") || ($command == "avatar")) $failure = "You selected an invalid command.";
if ((getInfo(room,users,"WHERE id='$userId'") != $id) && (!admin($user_name))) $failure = "You are not in this room.";
if (doublePost($userId,$post)) $failure = "You have already posted this exact message.";
if (($post_count < 30) && ($command != "move") && ($command != "ooc")) $failure = "Your post is too short. To deter people from making several abrupt posts, we have made it mandatory for all RP posts to be at least thirty words. Your post was only ".$post_count." words.";
if ((!getInfo(base,users,"WHERE id='$userId'")) && ($command != "ooc")) $failure = "You must set up your avatar with a base before you post.";
if ((getInfo(id,holds,"WHERE user='$userId'")) && (!isFighting($userId))) {
$hold = getInfo(id,holds,"WHERE user='$userId'");
$hold_user = getInfo(user2,holds,"WHERE user='$userId'");
if (getInfo(type,holds,"WHERE id='$hold'") == "pickpocket") $failure = "You may not post until $hold_user has reacted to your pickpocket attempt.";
if (getInfo(type,holds,"WHERE id='$hold'") == "startfire") $failure = "You may not post until $hold_user has created to your setting their building ablaze.";
}
if (!$failure) {
if ($command) {
#OOC
if ($command == "ooc") {
$ooc = "ooc";
}
#Whisper
if ($command == "whisper") {
$user = $_POST['whisperUser'];
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "The user is not in this room.";
$status = getInfo(status,users,"WHERE id='$userId'");
if (($status != "conscious") && ($status != "immobilized")) $failure = "You are not conscious.";
$status = getInfo(status,users,"WHERE id='$user'");
if (($status != "conscious") && ($status != "immobilized")) $failure = "That user is not conscious.";
if (isFighting($user)) $failure = "That user is fighting.";
if (isFighting($userId)) $failure = "You are currently fighting.";
if (isTied($userId)) $failure = "You are currently being immobilized.";
if (isTied($user)) $failure = "That user is currently being immobilized.";
if (!$failure) {
$whisper = $user;
$success = "You have successfully whispered to ".getInfo(username,users,"WHERE id='$user'").". Only the two of you will be able to see that post.";
}
}
#CONSUME
if ($command == "consume") {
if (isFighting($userId)) $failure = "You are currently being attacked, and must react to that, before you can do anything else.";
$food1 = $_POST['consumeFood1'];
$food2 = $_POST['consumeFood2'];
$food3 = $_POST['consumeFood3'];
if ((!$food1) && (!$food2) && (!$food3)) $failure = "You have not selected an item to eat.";
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$arrayInventory = explode('.',$inventory);
if ((!inArray($food1,$arrayInventory)) && ($food1)) $failure = "You have tried to eat or drink an item that you are not carrying.";
if ((!inArray($food2,$arrayInventory)) && (!$food2)) $failure = "You have tried to eat or drink an item that you are not carrying.";
if ((!inArray($food3,$arrayInventory)) && (!$food3)) $failure = "You have tried to eat or drink an item that you are not carrying.";
if (!$failure) {
for ($i = 1;$i <= 3;$i++) {
$current = "food".$i;
$food = $$current;
if ($food) {
$stat = getInfo("stat",user_items,"WHERE id='$food'");
$portions = getInfo(portions,user_items,"WHERE id='$food'");
$poison = explode(':',getInfo(poison,user_items,"WHERE id='$food'"));
$pdamage = $poison[0];
$pturns = $poison[1];
$type = getInfo(type,user_items,"WHERE id='$food'");
$maxstat = statmax($userId);
$amount = $_POST['consumeAmount'.$i];
$foodName = getInfo(name,user_items,"WHERE id='$food'");
$portions = getInfo(portions,user_items,"WHERE id='$food'");
if ($portions - $amount < 0) {
$amount = $portions;
$portions = 0;
} else {
$portions -= $amount;
}
if ($type == "food") {
$health = getInfo(health,users,"WHERE id='$userId'");
if ($pdamage > 0) {
if (!getInfo(user,poison,"WHERE user='$userId'")) {
sendMessage($user_name,"Poison","You have been poisoned. For more information on how to deal with this affliction, please consult The Poison Article in the player's guide.","God");
$query = "INSERT INTO poison VALUES('','$userId','$pdamage','$pturns')";
mysql_query($query);
} else {
$damage = getInfo(damage,poison,"WHERE user='$userId'");
$damage += $poison * $amount;
$query = "UPDATE poison SET damage='$damage' WHERE user='$userId'";
mysql_query($query);
}
}
$foodName = getInfo(name,user_items,"WHERE id='$food'");
$success = "You have eaten ".$foodName.".";
$hunger = getInfo(hunger,users,"WHERE id='$userId'");
$hunger += $stat * $amount;
if ($hunger > 100) $hunger = 100;
$query = "UPDATE users SET hunger='$hunger' WHERE id='$userId'";
mysql_query($query);
}
if ($type == "drink") {
$mana = getInfo(mana,users,"WHERE id='$userId'");
$health = getInfo(health,users,"WHERE id='$userId'");
if ($pdamage > 0) {
if (!getInfo(user,poison,"WHERE user='$userId'")) {
sendMessage($user_name,"Poison","You have been poisoned. For more information on how to deal with this affliction, please consult The Poison Article in the player's guide.","God");
$query = "INSERT INTO poison VALUES('','$userId','$pdamage','$pturns')";
mysql_query($query);
} else {
$damage = getInfo(damage,poison,"WHERE user='$userId'");
$damage += $poison * $amount;
$query = "UPDATE poison SET damage='$damage' WHERE user='$userId'";
mysql_query($query);
}
} else {
if ($mana < $maxstat) {
$mana += $stat * $amount;
if ($mana > $maxstat) $mana = $maxstat;
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
}
}
$foodName = getInfo(name,user_items,"WHERE id='$food'");
$success = "You drank ".$foodName.".";
}
if ($type == "poison") {
$health = getInfo(health,users,"WHERE id='$userId'");
if ($health > 0) {
if (!getInfo(user,poison,"WHERE user='$userId'")) {
sendMessage($user_name,"Poison","You have been poisoned. For more information on how to deal with this affliction, please consult The Poison Article in the player's guide.","God");
$query = "INSERT INTO poison VALUES('','$userId','$pdamage','$pturns')";
mysql_query($query);
} else {
$damage = getInfo(damage,poison,"WHERE user='$userId'");
$damage += $poison * $amount;
$query = "UPDATE poison SET damage='$damage' WHERE user='$userId'";
mysql_query($query);
}
}
$foodName = getInfo(name,user_items,"WHERE id='$food'");
$success = "You have eaten poison.";
}
if ($type == "alcohol") {
$dex = getInfo(dex,users,"WHERE id='$userId'");
if ($dex < 100) {
if (getInfo(personal,users,"WHERE id='$userId'") == "drunk") $dex += round(($stat / 8) * $amount);
else $dex += round(($stat / 4) * $amount);
if ($dex > 50) {
$dex = 50;
$wake = time() + 3600;
$sleep = time();
$query = "UPDATE users SET regeneration='$wake' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET sleep='$sleep' WHERE id='$userId'";
mysql_query($query);
$passedout = true;
}
$query = "UPDATE users SET dex='$dex' WHERE id='$userId'";
mysql_query($query);
}
$health = getInfo(health,users,"WHERE id='$userId'");
if ($pdamage > 0) {
if (!getInfo(user,poison,"WHERE user='$userId'")) {
sendMessage($user_name,"Poison","You have been poisoned. For more information on how to deal with this affliction, please consult The Poison Article in the player's guide.","God");
$query = "INSERT INTO poison VALUES('','$userId','$pdamage','$pturns')";
mysql_query($query);
} else {
$damage = getInfo(damage,poison,"WHERE user='$userId'");
$damage += $poison * $amount;
$query = "UPDATE poison SET damage='$damage' WHERE user='$userId'";
mysql_query($query);
}
}
$foodName = getInfo(name,user_items,"WHERE id='$food'");
$hunger = getInfo(hunger,users,"WHERE id='$userId'");
$hunger += $stat * $amount;
if ($hunger > 100) $hunger = 100;
$query = "UPDATE users SET hunger='$hunger' WHERE id='$userId'";
mysql_query($query);
}
if ($portions == 0) {
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$inventory = removeElement($food,$inventory,'.');
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$query = "DELETE FROM user_items WHERE id='$food'";
mysql_query($query);
} else {
$query = "UPDATE user_items SET portions='$portions' WHERE id='$food'";
mysql_query($query);
$query = "UPDATE user_items SET poison='' WHERE id='$food'";
mysql_query($query);
}
$query = "UPDATE users SET vulnerability='0' WHERE id='$userId'";
mysql_query($query);
$ate_portions[] = $amount;
$ate_food[] = $foodName;
}
}
$max = count($ate_food);
for ($i = 0;$i < $max;$i++) {
$amount = $ate_portions[$i];
$foodName = $ate_food[$i];
if ($foodName) $ate[] = "$amount portions of $foodName";
}
$ate = implode(', ',$ate);
$success = "You have eaten/drunk $ate.";
$post .= "
[Ate/Drank $ate]";
if ($passedout) $post .= "
[Passed out]";
}
}
if ($command == "mount_hold") {
if (!getInfo(id,mount_throw,"WHERE user='$userId'")) $failure = "You are not currently being thrown from your mount.";
if (!getInfo(mount,users,"WHERE id='$userId'")) $failure = "You are not currently mounted.";
$mount = getInfo(mount,users,"WHERE id='$userId'");
$mountname = getInfo(username,users,"WHERE id='$mount'");
if (!$failure) {
$skill = getInfo(riding,users,"WHERE id='$userId'");
if (getInfo(personal,users,"WHERE id='$userId'") == "rider") $skill += 25;
$mood = getInfo(mood,mounts,"WHERE npc='$mount'");
$roll = getInfo(roll,mount_throw,"WHERE user='$userId' and mount='$mount'");
$wordcount = count(explode(' ',$post));
$userRoll = floor($wordcount / 2) + $skill + $mood;
echo "Roll: $roll ";
echo "User Roll: $wordcount/2 + $skill + $mood = $userRoll ";
if ($userRoll >= $roll) {
$god = "$user_name successfully managed to stay on $mountname.";
$success = "You have successfully managed to stay on $mountname.";
$owner = getInfo(NPC,users,"WHERE id='$mount'");
if ((admin($owner)) || ($owner == 1)) {
$query = "UPDATE users SET NPC='$userId' WHERE id='$mount'";
mysql_query($query);
$success .= "The mount is now your NPC.";
$query = "UPDATE npcs SET npcgroup='' WHERE name='$mount'";
mysql_query($query);
}
} else {
$query = "UPDATE users SET mount='' WHERE id='$userId'";
mysql_query($query);
$damage = rand(40,60);
$absorb = itemStat($userId,"armour",$damage);
$damage -= $absorb;
$status = damage($userId,$damage);
$god = "$user_name was thrown from $mountname's back and lost $damage health ($absorb damage absorbed by armour).";
if ($status == "unconscious") $god .= " $user_name is now unconscious.";
$success = "You were thrown from $mountname's back and lost $damage health ($absorb damage absorbed by armour).";
}
$skill++;
$query = "UPDATE users SET riding='$skill' WHERE id='$userId'";
mysql_query($query);
$query = "DELETE FROM mount_throw WHERE user='$userId'";
mysql_query($query);
}
}
if ($command == "mount") {
$mount = $_POST['mountNPC'];
$mountname = getInfo(username,users,"WHERE id='$mount'");
if (!getInfo(id,mounts,"WHERE npc='$mount'")) $failure = "You may not mount this NPC.";
if (getInfo(room,users,"WHERE id='$mount'") != $id) $failure = "That NPC is not in this room.";
if (getInfo(status,users,"WHERE id='$mount'") != "conscious") $failure = "That NPC is not conscious.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not currently conscious.";
if (getInfo(id,users,"WHERE mount='$mount'")) $failure = "There is already someone riding this NPC.";
if (!$failure) {
$query = "UPDATE users SET mount='$mount' WHERE id='$userId'";
mysql_query($query);
$skill = getInfo(riding,users,"WHERE id='$userId'");
if (getInfo(personal,users,"WHERE id='$userId'") == "rider") $skill += 25;
$riding = getInfo(riding,mounts,"WHERE npc='$mount'");
$mood = getInfo(mood,mounts,"WHERE npc='$mount'");
if (rand(1,100) <= $riding + $skill + $mood) {
$success = "You have successfully gotten onto the mount without any trouble.";
$owner = getInfo(NPC,users,"WHERE id='$mount'");
if ((admin($owner)) || ($owner == 1)) {
$query = "UPDATE users SET NPC='$userId' WHERE id='$mount'";
mysql_query($query);
$success .= "The mount is now your NPC.";
$query = "UPDATE npcs SET npcgroup='' WHERE name='$mount'";
mysql_query($query);
}
} else {
$success = "You have successfully gotten onto the mount, but you have made the creature uncomfortable. It is now trying to throw you off.";
$god = "$mountname is attempting to throw $user_name off its back.";
$roll = rand(1,100) - (getInfo(dex,users,"WHERE id='$mount'"));
$fatigue = getInfo(fatigue,users,"WHERE id='$mount'");
if ($fatigue < 50) {
$roll -= 50 - $fatigue;
}
$query = "INSERT INTO mount_throw VALUES('','$userId','$mount','$roll')";
mysql_query($query);
}
$riding++;
$query = "UPDATE mounts SET riding='$riding' WHERE npc='$mount'";
mysql_query($query);
$skill++;
$query = "UPDATE users SET riding='$skill' WHERE id='$userId'";
mysql_query($query);
$post .= "
[Climbed onto $mountname]";
}
}
if ($command == "whip") {
$mount = getInfo(mount,users,"WHERE id='$userId'");
if (!$mount) $failure = "You are not riding a mount.";
$mountname = getInfo(username,users,"WHERE id='$mount'");
if (!$failure) {
$mood = getInfo(mood,mounts,"WHERE npc='$mount'");
$temper = getInfo(temper,mounts,"WHERE npc='$mount'");
$damage = rand(2,3);
$mood -= ($damage * 2);
if ($mood < -25) $mood = -25;
$query = "UPDATE mounts SET mood='$mood' WHERE npc='$mount'";
mysql_query($query);
$temper -= ($damage * 2 / 5);
if ($temper < -25) $temper = -25;
$query = "UPDATE mounts SET temper='$temper' WHERE npc='$mount'";
mysql_query($query);
if (rand(1,100) < $mood * 4) {
$success = "You have successfully whipped your mount. In an attempt to retaliate, it is trying to throw you off its back.";
$god = "$mountname is attempting to throw $user_name off its back.";
$roll = rand(1,100) - (getInfo(dex,users,"WHERE id='$mount'"));
$fatigue = getInfo(fatigue,users,"WHERE id='$mount'");
if ($fatigue < 50) {
$roll -= 50 - $fatigue;
}
$query = "INSERT INTO mount_throw VALUES('','$userId','$mount','$roll')";
mysql_query($query);
} else $success = "You have successfully whipped your mount.";
$riding = getInfo(riding,mounts,"WHERE npc='$mount'");
$pain = getInfo(pain,mounts,"WHERE npc='$mount'");
$speed = getInfo(speed,mounts,"WHERE npc='$mount'");
$roll = getInfo(roll,mounts,"WHERE npc='$mount'");
$damage = getInfo(damage,mounts,"WHERE npc='$mount'");
$riding += 1;
$pain += 1;
$speed += 0.7;
$roll += 0.3;
$damage += 0.08;
$time = time() + (12 * 3600);
$query = "UPDATE mounts SET riding='$riding', pain='$pain', speed='$speed', roll='$roll', whipping='$time', damage='$damage' WHERE npc='$mount'";
mysql_query($query);
$post .= "
[Whipped $mountname]";
}
}
if ($command == "dismount") {
$mount = getInfo(mount,users,"WHERE id='$userId'");
if (!$mount) $failure = "You are not riding a mount.";
$mountname = getInfo(username,users,"WHERE id='$mount'");
if (!$failure) {
$query = "UPDATE users SET mount='' WHERE id='$userId'";
mysql_query($query);
$success = "You have successfully dismounted.";
$post .= "
[Dismounted from $mountname]";
}
}
if ($command == "rumour") {
$npc = $_POST['rumourUser'];
$rumour = $_POST['rumourRumour'];
if (!$rumour) $failure = "You have not entered a rumour.";
if (!getInfo(id,npc_citizens,"WHERE npc='$npc'")) $failure = "The NPC you chose is not an NPC citizen.";
if ((getInfo(status,users,"WHERE id='$npc'") != "conscious") && (getInfo(status,users,"WHERE id='$npc'") != "immobilized")) $failure = "That NPC is not awake.";
if (!$npc) $failure = "You have not chosen an NPC.";
$last = substr($rumour,-1);
if (($last == "!") || ($last == ".") || ($last == "?")) {
$rumour = substr($rumour,0,-1);
}
if (!$failure) {
$success = "You have successfully spread a rumour to the NPC.";
$time = time();
$date = date('g:i A F jS Y');
$query = "INSERT INTO npc_rumours VALUES('','$userId','$rumour','$time','$date')";
mysql_query($query);
$rumour = numRows(npc_rumours);
$rumours = getInfo(rumours,npc_citizens,"WHERE npc='$npc'");
if ($rumours) $rumours .= '.'.$rumour;
else $rumours = $rumour;
$query = "UPDATE npc_citizens SET rumours='$rumours' WHERE npc='$npc'";
mysql_query($query);
$response_npc = $npc;
$npc_response = getInfo(post,citizen_posts,"WHERE type='spreadrumour' ORDER BY rand()");
$npc_response = translateRumour($npc_response,$npc,$userId,'');
}
}
if ($command == "talk") {
$npc = $_POST['talknpc'];
$response_npc = $npc;
$npcname = getInfo(username,users,"WHERE id='$npc'");
$question = $_POST['talkquestion'.$npc];
$questionArray = explode('.',$question);
if ($questionArray[0] == "memory") {
$memory = $questionArray[1];
$command = getInfo(command,npc_memories,"WHERE id='$memory'");
$resistance = getInfo(resistance,npc_citizens,"WHERE npc='$npc'");
if ($command == "attack") $resistance = 25;
if ($command == "beat") $resistance = 25;
if ($command == "slay") $resistance = 40;
if ($command == "loot") $resistance = 15;
if ($command == "enslave") $resistance = 25;
if ($command == "dismember") $resistance = 25;
if ($command == "pickpocket") $resistance = 0;
if ($command == "startfire") $resistance = 10;
if ($command == "breakdown") $resistance = 0;
if ($command == "lockpick") $resistance = 0;
if ($command == "throwWeapon") $resistance = 15;
if ($command == "suicide") $resistance = 0;
if ($command == "pay") $resistance = 0;
if ($command == "give") $resistance = 0;
if ($command == "carry") $resistance = 0;
if (fnmatch("spell_*",$command)) $resistance = 10;
$health_diff = statmax($npc) - getInfo(health,users,"WHERE id='$npc'");
$intox = getInfo(dex,users,"WHERE id='$npc'");
$current_bribe = getInfo(current,npc_bribes,"WHERE user='$userId' and npc='$npc'");
$total_bribe = getInfo(total,npc_bribes,"WHERE user='$userId' and npc='$npc'");
$resistance -= $health_diff + $intox + floor($current_bribe / 5) + floor($total_bribe / 50);
if ($resistance > 0) {
$god = "$npcname refused to speak.";
$success = "You have successfully spoken to the NPC, but they have refused to tell you what they know. Try giving the NPC money, getting them drunk, or smacking them around a bit.";
} else {
$user1 = getInfo(user1,npc_memories,"WHERE id='$memory'");
$var = getInfo('var',npc_memories,"WHERE id='$memory'");
$avatar1 = getInfo(avatar1,npc_memories,"WHERE id='$memory'");
$avatar2 = getInfo(avatar2,npc_memories,"WHERE id='$memory'");
$user1name = getInfo(username,users,"WHERE id='$user1'");
$user2name = getInfo(username,users,"WHERE id='$user2'");
$roomname = getInfo(name,rooms,"WHERE id='$var'");
$place = getInfo(place,rooms,"WHERE id='$var'");
$placename = getInfo(name,places,"WHERE id='$place'");
$room1 = getInfo(room,doors,"WHERE id='$var'");
$room1name = getInfo(name,rooms,"WHERE id='$room1'");
$place1 = getInfo(place,rooms,"WHERE id='$room1'");
$place1name = getInfo(name,places,"WHERE id='$place1'");
$room2 = getInfo(room2,doors,"WHERE id='$var'");
if ($room2 == "out") {
$room2name = "Outside";
$place2name = "";
} else {
$room2name = getInfo(name,rooms,"WHERE id='$room2'");
$place2 = getInfo(place,rooms,"WHERE id='$room2'");
$place2name = getInfo(name,places,"WHERE id='$place2'");
}
if ($command == "attack") $message = "$npcname tells $user_name in a hushed tone, how this person attacked this person.";
if ($command == "beat") $message = "$npcname tells $user_name in a hushed tone, how this person beat this person while they were defenseless.";
if ($command == "slay") $message = "$npcname tells $user_name in a hushed tone, how this person murdered this person in cold blood.";
if ($command == "loot") $message = "$npcname tells $user_name in a hushed tone, how this person robbed this person.";
if ($command == "enslave") $message = "$npcname tells $user_name in a hushed tone, how this person enslaved this person.";
if ($command == "dismember") $message = "$npcname tells $user_name in a hushed tone, how this person tore apart the corpse of this person.";
if ($command == "pickpocket") $message = "$npcname tells $user_name in a hushed tone, how this person tried to pick-pocket this person.";
if ($command == "startfire") $message = "$npcname tells $user_name in a hushed tone, how this person tried to start a fire in $roomname, in $placename.";
if ($command == "breakdown") $message = "$npcname tells $user_name in a hushed tone, how this person tried to break down the door between $room1name ($place1name) and $room2name ($place2name)";
if ($command == "lockpick") $message = "$npcname tells $user_name in a hushed tone, how this person tried to pick the lock of the door between $room1name ($place1name) and $room2name ($place2name)";
if ($command == "throwWeapon") $message = "$npcname tells $user_name in a hushed tone, how this person threw a weapon at this person.";
if (($command == "suicide") && ($var == "fail")) $message = "$npcname tells $user_name in a hushed tone, how this person attempted to commit suicide, but failed.";
if (($command == "suicide") && ($var == "success")) $message = "$npcname tells $user_name in a hushed tone, how this person committed suicide.";
if ($command == "pay") $message = "$npcname tells $user_name in a hushed tone, how this person gave this person an unknown number of gold coins.";
if ($command == "give") $message = "$npcname tells $user_name in a hushed tone, how this person gave this person an object.";
if (($command == "carry") && ($var == "all")) $message = "$npcname tells $user_name in a hushed tone, how this person carried off several unconscious and/or dead people off somewhere.";
if (($command == "carry") && ($var != "all")) $message = "$npcname tells $user_name in a hushed tone, how this person carried this person off somewhere.";
if (fnmatch("spell_*",$command)) $message = "$npcname tells $user_name in a hushed tone about the stunning spell they saw this person perform.";
$god = $message;
$success = "You have successfully spoken to the NPC, and they have told you what they know on the matter.";
}
} elseif ($questionArray[0] == "rumour") {
$rumours = getInfo(rumours,npc_citizens,"WHERE npc='$npc'");
if ($rumours) {
$rumours = explode('.',$rumours);
$rumour = $rumours[rand(0,count($rumours) - 1)];
$npc_response = getInfo(post,citizen_posts,"WHERE type='rumours' ORDER BY rand()");
$npc_response = translateRumour($npc_response,$npc,$userId,$rumour);
} else {
$npc_response = getInfo(post,citizen_posts,"WHERE type='norumours' ORDER BY rand()");
$npc_response = translateRumour($npc_response,$npc,$userId,'');
}
} else {
$npcname = getInfo(username,users,"WHERE id='$npc'");
$npcgroup = getInfo(npcgroup,npcs,"WHERE name='$npc'");
$tribe = getInfo(id,tribes,"WHERE hunters='$npcgroup' or villagers='$npcgroup'");
$sex = getInfo(sex,users,"WHERE id='$userId'");
$inventory = explode('.',getInfo(inventory,users,"WHERE id='$userId'"));
$rank = rank($userId);
$animal = getInfo(animal,npcs,"WHERE name='$npc'");
if (getInfo(id,tribal,"WHERE tribe='$tribe' and user='$userId'")) {
$status = "captive";
}
if (!$tribe) {
$tribe = getInfo(tribe,npcs,"WHERE name='$npc'");
$status = "captured";
} else {
if (getInfo(status,users,"WHERE id='$npc'") == "immobilized") $status = "captured";
}
if ($tribe) {
if (($status) && (getInfo(status,tribe_questions,"WHERE id='$question'") != $status)) $failure = "You may not ask this question to this NPC.";
$cost = getInfo(cost,tribe_questions,"WHERE id='$question'");
if ($cost) {
$money = getInfo(money,users,"WHERE id='$userId'");
$npcMoney = getInfo(money,users,"WHERE id='$npc'");
$money -= $cost;
$npcMoney += $cost;
if ($money < 0) $failure = "You do not have enough money.";
}
$door = getInfo(id,doors,"WHERE block='$npc' or block2='$npc'");
if (!$door) $result = getRows(tribe_responses,"WHERE question='$question' and ((sex = '' or sex='$sex') and (rank='' or rank='$rank')) and (sex!='' or rank!='' or item!='' or previous!='' or asked!='' or recognize!='') and command!='escort'");
else $result = getRows(tribe_responses,"WHERE question='$question' and ((sex = '' or sex='$sex') and (rank='' or rank='$rank')) and (sex!='' or rank!='' or item!='' or previous!='' or asked!='' or recognize!='')");
while ($row = mysql_fetch_array($result)) {
$item = $row['item'];
$previous = $row['previous'];
$asked = $row['asked'];
$recognize = $row['recognize'];
$sex = $row['sex'];
$rank = $row['rank'];
if (((hasItem($userId,$item,1)) || (!$item)) && ((getInfo(id,interactions,"WHERE npc='$npc' and user='$userId' and question='$previous'")) || (!$previous)) && ((numRowsConditions(interactions,"WHERE npc='$npc and user='$userId' and question='$question'") >= $asked) || (!$asked)) && ((getInfo(id,interactions,"WHERE npc='$npc' and user='$userId'")) || (!$recognize))) $responses[] = $row['id'];
if ((!hasItem($npc,$item,1)) && ($item)) $failure = "The NPC is not carrying the item it is supposed to be giving you.";
}
if (!$responses) {
$door = getInfo(id,doors,"WHERE block='$npc' or block2='$npc'");
if (!$door) $result = getRows(tribe_responses,"WHERE question='$question' and sex='' and rank='' and item='' and previous='' and asked='' and recognize='' and command!='escort'");
else $result = getRows(tribe_responses,"WHERE question='$question' and sex='' and rank='' and item='' and previous='' and asked='' and recognize=''");
while ($row = mysql_fetch_array($result)) {
$responses[] = $row['id'];
}
}
} else {
$cost = getInfo(cost,questions,"WHERE id='$question'");
if ($cost) {
$money = getInfo(money,users,"WHERE id='$userId'");
$npcMoney = getInfo(money,users,"WHERE id='$npc'");
$money -= $cost;
$npcMoney += $cost;
if ($money < 0) $failure = "You do not have enough money.";
}
$door = getInfo(id,doors,"WHERE block='$npc' or block2='$npc'");
if (!$door) $result = getRows(responses,"WHERE question='$question' and ((sex = '' or sex='$sex') and (rank='' or rank='$rank')) and (sex!='' or rank!='' or item!='' or previous!='' or asked!='' or recognize!='') and command!='escort'");
else $result = getRows(responses,"WHERE question='$question' and ((sex = '' or sex='$sex') and (rank='' or rank='$rank')) and (sex!='' or rank!='' or item!='' or previous!='' or asked!='' or recognize!='')");
while ($row = mysql_fetch_array($result)) {
$item = $row['item'];
$previous = $row['previous'];
$asked = $row['asked'];
$recognize = $row['recognize'];
$sex = $row['sex'];
$rank = $row['rank'];
if (((hasItem($userId,$item,1)) || (!$item)) && ((getInfo(id,interactions,"WHERE npc='$npc' and user='$userId' and question='$previous'")) || (!$previous)) && ((numRowsConditions(interactions,"WHERE npc='$npc and user='$userId' and question='$question'") >= $asked) || (!$asked)) && ((getInfo(id,interactions,"WHERE npc='$npc' and user='$userId'")) || (!$recognize))) $responses[] = $row['id'];
if ((!hasItem($npc,$item,1)) && ($item)) $failure = "The NPC is not carrying the item it is supposed to be giving you.";
}
if (!$responses) {
$door = getInfo(id,doors,"WHERE block='$npc' or block2='$npc'");
if (!$door) $result = getRows(responses,"WHERE question='$question' and sex='' and rank='' and item='' and previous='' and asked='' and recognize='' and command!='escort'");
else $result = getRows(responses,"WHERE question='$question' and sex='' and rank='' and item='' and previous='' and asked='' and recognize=''");
while ($row = mysql_fetch_array($result)) {
$responses[] = $row['id'];
}
}
}
if (!$responses) $failure = "The NPC does not know how to respond - its owner likely has recently made a change.";
if (!$npc) $failure = "You have not selected an npc to speak to.";
if (!$question) $failure = "You have not selected a question.";
if ((getInfo(status,users,"WHERE id='$npc'") != "conscious") && (getInfo(status,users,"WHERE id='$npc'") != "immobilized")) $failure = "The NPC is not conscious.";
if (!$failure) {
if ($cost) {
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET money='$npcMoney' WHERE id='$npc'";
mysql_query($query);
$post .= "
[Escorted $user_name into $doorname]";
}
} elseif (getInfo(command,responses,"WHERE id='$response'") == "attack") {
$god = npcattack($npc,$userId);
}
}
}
}
$command = $_POST['command'];
if ($command == "secretdoor") {
$answer = strtolower($_POST['secretdoorAnswer']);
if (!$answer) $failure = "You did not enter a word.";
if (!$failure) {
$success = "You have failed to find any hidden doorways.";
$result = getRows(doors,"WHERE (room='$id' and secret1!='') or (room2='$id' and secret2!='')");
while ($row = mysql_fetch_array($result)) {
$door = $row['id'];
if ($answer == strtolower(getInfo(word,secret_doors,"WHERE door='$door'"))) {
$time = time() + (60 * 20);
$query = "UPDATE secret_doors SET open='open', time='$time' WHERE door='$door'";
mysql_query($query);
$success = "You have successfully uncovered a hidden doorway.";
$god = getInfo(action,secret_doors,"WHERE door='$door'");
}
}
}
}
if ($command == "knock") {
$destination = $_POST['knockDoor'];
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
if (isFighting($userId)) $failure = "You are currently fighting.";
if (isTied($userId)) $failure = "You are currently being tied up, or tying someone up.";
if (!getInfo(id,doors,"WHERE (room='$id' and room2='$destination') or (room='$destination' and room2='$id')")) {
$destinationPlace = getInfo(place,rooms,"WHERE id='$destination'");
if ((getInfo(entrance,places,"WHERE id='$buildingId'") == $id) && (getInfo(entrance,places,"WHERE id='$destinationPlace'") == $destination)) {
if (!sameDistrict($destinationPlace,$buildingId)) $failure = "You cannot access that room from here.";
} else $failure = "You cannot access that room from here.";
}
if (!$failure) {
post(1,"$user_name is knocking on the door to this room.",$destination,"ooc");
$success = "You have successfully knocked on the door.";
$post .= "
[Knocked on a door]";
}
}
if ($command == "move") {
$destination = $_POST['moveRoom'];
if (!$destination) $failure = "You have not selected a destination.";
if (($destination != "overboard") && (!fnmatch("travel_*",$destination))) {
$destinationPlace = getInfo(place,rooms,"WHERE id='$destination'");
$destinationName = getInfo(name,rooms,"WHERE id='$destination'");
$destinationPlaceName = getInfo(name,places,"WHERE id='$destinationPlace'");
$destinationTown = getInfo(town,places,"WHERE id='$destinationPlace'");
#CONDITIONS BEGIN
if ((inPot($userId)) || (getInfo(id,pots,"WHERE creator='$userId'"))) $failure = "You must leave the pot in which you are participating before leaving.";
if (!inArray($destination,destinations($id,$userId))) $failure = "The destination you have selected is not accessible at the current time. Certain doors may be locked, hindering your ability to reach the room. Please consult the list of destinations in move command area while posting to see which buildings/doors are locked.";
if ($destination == $id) $failure = "You are already in that room.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are unconscious, and therefore cannot move.";
if (isFighting($userId)) $failure = "You are currently being attacked, and must react to that, before you can move to another room.";
$master = getInfo(master,users,"WHERE id='$userId'");
if ((getInfo(room,users,"WHERE id='$master'") == $id) && (getInfo(status,users,"WHERE id='$master'") == "conscious") && (getInfo(chained,users,"WHERE id='$userId'"))) $failure = "With a chain and ball attached to your ankle, you have no way of moving out of the room without your master stopping you.";
$door_id = getInfo(id,doors,"WHERE (room='$id' and room2='$destination') or ( room='$destination' and room2='$id')");
if (getInfo(id,doors,"WHERE id='$door_id'")) {
$block = getInfo(block,doors,"WHERE id='$door_id'");
}
if (getInfo(id,doors,"WHERE id='$door_id'")) {
$block = getInfo(block2,doors,"WHERE id='$door_id'");
}
if ($block) {
if ((getInfo(room,users,"WHERE id='$block'") != $id) || (getInfo(status,users,"WHERE id='$block'") != "conscious") || ((getInfo(logged,users,"WHERE id='$block'") <= (time() - (3600 * 24 * 7))) && (!getInfo(NPC,users,"WHERE id='$block'")))) {
unset($block);
$door_id = $row['id'];
if (getInfo(room,doors,"WHERE id='$door_id'") == $id) $query = "UPDATE doors SET block='' WHERE id='$door_id'";
if (getInfo(room2,doors,"WHERE id='$door_id'") == $id) $query = "UPDATE doors SET block2='' WHERE id='$door_id'";
mysql_query($query);
}
}
if ($block) $failure = "This doorway is being blocked by ".getInfo(username,users,"WHERE id='$block'").".";
}
if (fnmatch("travel_*",$destination)) {
if (getInfo(id,travel_routes,"WHERE station='$buildingId'")) {
$station = getInfo(station2,travel_routes,"WHERE station='$buildingId'");
$toll = getInfo(toll,travel_routes,"WHERE station='$buildingId'");
}
if (getInfo(id,travel_routes,"WHERE station2='$buildingId'")) {
$station = getInfo(station,travel_routes,"WHERE station2='$buildingId'");
$toll = getInfo(toll2,travel_routes,"WHERE station2='$buildingId'");
}
if (getInfo(personal,users,"WHERE id='$userId'") == "traveler") $toll = round($toll / 2);
$result = getRows(users,"WHERE room='$id' and npc!=''");
$count = 0;
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if (((getInfo(mode,npcs,"WHERE name='$npc'") == "protect") || (getInfo(movement,npcs,"WHERE name='$npc'") == "follow")) && (getInfo("var",npcs,"WHERE name='$npc'") == $user) && (getInfo(status,users,"WHERE id='$npc'") == "conscious")) {
$count++;
}
}
$toll = $toll * $count;
$money = getInfo(money,users,"WHERE id='$userId'");
$money -= $toll;
$stationTown = getInfo(town,places,"WHERE id='$station'");
$stationdistrict = getInfo(district,places,"WHERE id='$station'");
$currentTown = getInfo(town,places,"WHERE id='$buildingId'");
$currentdistrict = getInfo(district,places,"WHERE id='$buildingId'");
if ((getInfo(locked,towns,"WHERE id='$currentTown'") == "locked") && (!getInfo(outskirts,districts,"WHERE id='$currentdistrict'"))) $failure = "You cannot travel there - the town walls of the town you are in are locked.";
if ((getInfo(locked,towns,"WHERE id='$stationTown'") == "locked") && (($stationTown == $currentTown) || (!getInfo(outskirts,districts,"WHERE id='$stationdistrict'")))) $failure = "You cannot travel there - the town walls are locked.";
if ($money < 0) $failure = "You do not have enough money.";
if (!$station) $failure = "This station does not lead to anything.";
}
#CONDITIONS END
if (getInfo(place,rooms,"WHERE id='$destination'") != $buildingId) {
$weight = weigh($userId);
$weightMax = maxWeight($userId);
if ($weight > $weightMax) $failure = "You are currently carrying too many things in your inventory. You are carrying $weight kilograms, and may not move with more than $weightMax kilograms.";
}
if (!$failure) {
if (getInfo(chained,users,"WHERE id='$userId'")) {
$fatigue = getInfo(fatigue,users,"WHERE id='$userId'");
$fatigue -= 25;
if ($fatigue < 0) $fatigue = 0;
$query = "UPDATE users SET fatigue='$fatigue' WHERE id='$userId'";
mysql_query($query);
}
$moves++;
$query = "UPDATE users SET moves='$moves' WHERE id='$userId'";
mysql_query($query);
if ($toll) {
$money = getInfo(money,users,"WHERE id='$userId'");
$money -= $toll;
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$owner = getInfo(owner,places,"WHERE id='$buildingId'");
$money = getInfo(money,users,"WHERE id='$owner'");
$money += $toll;
$query = "UPDATE users SET money='$money' WHERE id='$owner'";
mysql_query($query);
}
move($userId,$destination);
if (fnmatch("travel_*",$destination)) {
$success = "You have successfully travelled down the road.";
if ($post) $post .= "
[Travelled Down the Road]";
else {
if (!getInfo(hidden,rooms,"WHERE id='$destination'")) $post = "[Travelled Down the Road]";
$ooc = "ooc";
}
} else if ($destination == "overboard") {
$success = "You have successfully jumped overboard. Good job.";
if ($post) $post .= "
[Jumped overboard]";
else {
if (!getInfo(hidden,rooms,"WHERE id='$destination'")) $post = "[Jumped Overboard]";
$ooc = "ooc";
}
} else {
$success = "You have successfully moved to ".$destinationName." in ".$destinationPlaceName.". You will be forwarded there immediately.";
if ($post) {
if (!getInfo(hidden,rooms,"WHERE id='$destination'")) $post .= "
[Moved to ".$destinationName." in ".$destinationPlaceName."]";
} else {
if (!getInfo(hidden,rooms,"WHERE id='$destination'")) $post = "[Moved to ".$destinationName." in ".$destinationPlaceName."]";
$ooc = "ooc";
}
echo '';
}
}
}
if ($command == "sneak") {
$destination = $_POST['sneakRoom'];
if (getInfo(bonus,users,"WHERE id='$userId'") != "stealthy") $failure = "Your character is not stealthy enough to use this command.";
if (!$destination) $failure = "You have not selected a destination.";
if (($destination != "overboard") && (!fnmatch("travel_*",$destination))) {
$destinationPlace = getInfo(place,rooms,"WHERE id='$destination'");
$destinationName = getInfo(name,rooms,"WHERE id='$destination'");
$destinationPlaceName = getInfo(name,places,"WHERE id='$destinationPlace'");
$destinationTown = getInfo(town,places,"WHERE id='$destinationPlace'");
#CONDITIONS BEGIN
if ((inPot($userId)) || (getInfo(id,pots,"WHERE creator='$userId'"))) $failure = "You must leave the pot in which you are participating before leaving.";
if (!inArray($destination,destinations($id,$userId))) $failure = "The destination you have selected is not accessible at the current time. Certain doors may be locked, hindering your ability to reach the room. Please consult the list of destinations in move command area while posting to see which buildings/doors are locked.";
if ($destination == $id) $failure = "You are already in that room.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are unconscious, and therefore cannot move.";
$userRoom = getInfo(room,users,"WHERE id='$userId'");
if (isFighting($userId)) $failure = "You are currently being attacked, and must react to that, before you can move to another room.";
if ((getInfo(master,users,"WHERE id='$userId'")) && (getInfo(chained,users,"WHERE id='$userId'"))) $failure = "With a chain and ball attached to your ankle, it is nigh impossible to sneak around without being noticed.";
$door_id = getInfo(id,doors,"WHERE (room='$id' and room2='$destination') or ( room='$destination' and room2='$id')");
if (getInfo(id,doors,"WHERE id='$door_id'")) {
$block = getInfo(block,doors,"WHERE id='$door_id'");
}
if (getInfo(id,doors,"WHERE id='$door_id'")) {
$block = getInfo(block2,doors,"WHERE id='$door_id'");
}
if ($block) {
if ((getInfo(room,users,"WHERE id='$block'") != $id) || (getInfo(status,users,"WHERE id='$block'") != "conscious") || ((getInfo(logged,users,"WHERE id='$block'") <= (time() - (3600 * 24 * 7))) && (!getInfo(NPC,users,"WHERE id='$block'")))) {
unset($block);
$door_id = $row['id'];
if (getInfo(room,doors,"WHERE id='$door_id'") == $id) $query = "UPDATE doors SET block='' WHERE id='$door_id'";
if (getInfo(room2,doors,"WHERE id='$door_id'") == $id) $query = "UPDATE doors SET block2='' WHERE id='$door_id'";
mysql_query($query);
}
}
if ($block) $failure = "This doorway is being blocked by ".getInfo(username,users,"WHERE id='$block'").".";
}
if (fnmatch("travel_*",$destination)) {
if (getInfo(id,travel_routes,"WHERE station='$buildingId'")) {
$station = getInfo(station2,travel_routes,"WHERE station='$buildingId'");
$toll = getInfo(toll,travel_routes,"WHERE station='$buildingId'");
}
if (getInfo(id,travel_routes,"WHERE station2='$buildingId'")) {
$station = getInfo(station,travel_routes,"WHERE station2='$buildingId'");
$toll = getInfo(toll2,travel_routes,"WHERE station2='$buildingId'");
}
if (getInfo(personal,users,"WHERE id='$userId'") == "traveler") $toll = round($toll / 2);
$result = getRows(users,"WHERE room='$id' and npc!=''");
$count = 0;
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if (((getInfo(mode,npcs,"WHERE name='$npc'") == "protect") || (getInfo(movement,npcs,"WHERE name='$npc'") == "follow")) && (getInfo("var",npcs,"WHERE name='$npc'") == $user) && (getInfo(status,users,"WHERE id='$npc'") == "conscious")) {
$count++;
}
}
$toll = $toll * $count;
$money = getInfo(money,users,"WHERE id='$userId'");
$money -= $toll;
$stationTown = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(locked,towns,"WHERE id='$stationTown'") == "locked") $failure = "You cannot travel there - the town walls of the town you are in are locked.";
$stationTown = getInfo(town,places,"WHERE id='$station'");
if (getInfo(locked,towns,"WHERE id='$stationTown'") == "locked") $failure = "You cannot travel there - the town walls are locked.";
if ($money < 0) $failure = "You do not have enough money.";
if (!$station) $failure = "This station does not lead to anything.";
}
#CONDITIONS END
if (getInfo(place,rooms,"WHERE id='$destination'") != $buildingId) {
$weight = weigh($userId);
$weightMax = maxWeight($userId);
if ($weight > $weightMax) $failure = "You are currently carrying too many things in your inventory. You are carrying $weight kilograms, and may not move with more than $weightMax kilograms.";
}
if (!$failure) {
$moves++;
$query = "UPDATE users SET moves='$moves' WHERE id='$userId'";
mysql_query($query);
$class = getInfo("class",users,"WHERE id='$userId'");
if (($class == "assassin") || ($class == "thief")) {
$health = getInfo(health,users,"WHERE id='$userId'");
if ($health >= statmax($userId)) {
$query = "UPDATE users SET mode='stealth' WHERE id='$userId'";
mysql_query($query);
}
}
if ($toll) {
$money = getInfo(money,users,"WHERE id='$userId'");
$money -= $toll;
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$owner = getInfo(owner,places,"WHERE id='$buildingId'");
$money = getInfo(money,users,"WHERE id='$owner'");
$money += $toll;
$query = "UPDATE users SET money='$money' WHERE id='$owner'";
mysql_query($query);
}
move($userId,$destination);
if (fnmatch("travel_*",$destination)) {
$success = "You snuck down the road.";
} elseif ($destination == "overboard") {
$success = "You have jumped overboard.";
} else {
$success = "You have successfully moved to ".$destinationName." in ".$destinationPlaceName.". You will be forwarded there immediately.";
echo '';
}
if ($post) {
$post .= "
[Snuck Away]";
}
}
}
if ($command == "sitdown") {
$table = $_POST['sitdownTable'];
if (getInfo(id,card_hands,"WHERE user='$userId'")) $failure = "You are already sitting at a card table.";
if ((getInfo(status,card_tables,"WHERE id='$table'") != "open") && (getInfo(dealer,card_tables,"WHERE id='$table'") != $userId)) $failure = "That card table is not open.";
if (getInfo(room,card_tables,"WHERE id='$table'") != $id) $failure = "That card table is not set up in this room.";
if (!$failure) {
$query = "INSERT INTO card_hands VALUES('','$userId','$table','','','fold','','')";
mysql_query($query);
$success = "You have successfully sat down at a card table.";
$post .= "
[Sat Down at a Card Table]";
}
}
if ($command == "standup") {
$table = getInfo(cardtable,card_hands,"WHERE user='$userId'");
if (!$table) $failure = "You are not sitting at a card table.";
if (!$failure) {
$hand = fixArray(getInfo(hand_show,card_hands,"WHERE user='$userId'").'.'.getInfo(hand_show,card_hands,"WHERE user='$userId'"));
$discarded = fixArray(getInfo(discarded,card_tables,"WHERE id='$table'").'.'.$hand);
$query = "UPDATE card_tables SET discarded='$discarded' WHERE id='$table'";
mysql_query($query);
$query = "DELETE FROM card_hands WHERE user='$userId'";
mysql_query($query);
$statement = "$user_name folded their hand and stood up from the table.";
cardHistory($table,$statement);
$success = "You have successfully sat down at a card table.";
$post .= "
[Stood Up from Card Table]";
}
}
if ($command == "give") {
$item = $_POST['giveItem'];
$user = $_POST['giveUser'];
$username = getInfo(username,users,"WHERE id='$user'");
if (!$item) $failure = "You have not selected an item to give.";
if (!$user) $failure = "You have not a user.";
if (isFighting($userId)) $failure = "You are currently being attacked, and must react to that, before you can do anything else.";
if (isFighting($user)) $failure = $username." is currently being attacked, and must react to that, before you can give them anything.";
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$arrayInventory = explode('.',$inventory);
if (!inArray($item,$arrayInventory)) $failure = "You are not carrying that item.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = $username." is not in this room, and therefore cannot accept your gift.";
if (!$failure) {
$inventory = removeElement($item,$inventory,'.');
$userInventory = getInfo(inventory,users,"WHERE id='$user'");
if ($userInventory) $userInventory .= '.'.$item;
else $userInventory = $item;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET inventory='$userInventory' WHERE id='$user'";
mysql_query($query);
$success = "You have successfully given the item to ".$username.".";
$itemName = getInfo(name,user_items,"WHERE id='$item'");
$post .= "
[Gave ".$username." ".$itemName."]";
}
}
if ($command == "bribe") {
$npc = $_POST['bribeUser'];
$npcname = getInfo(username,users,"WHERE id='$npc'");
$owner = getInfo(NPC,users,"WHERE id='$npc'");
$price = getInfo(price,npcs,"WHERE name='$npc'");
if (getInfo(type,npcs,"WHERE name='$npc'") > 10) $price *= 4;
$money = getInfo(money,users,"WHERE id='$userId'");
$money -= $price;
if (getInfo(room,users,"WHERE id='$owner'") == $id) $failure = "This NPC will not divulge any information.";
if ($money < 0) $failure = "That NPC charges more money than you can afford.";
if (!$failure) {
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$money = getInfo(money,users,"WHERE id='$npc'");
$money += $price;
$query = "UPDATE users SET money='$money' WHERE id='$npc'";
mysql_query($query);
$time = time() + (3600 * 6);
$query = "INSERT INTO npc_bribes VALUES('','$userId','$npc','$time')";
mysql_query($query);
$success = "You may now view ".$npcname."'s memories, through your control panel. While you can gather knowledge from these memories, you MUST roleplay as if your character was speaking to the npc in order to be able to use that information. The ability to view the memories will expire in six hours.";
$post .= "
[Bribed $npcname]";
}
}
if ($command == "rolldice") {
$num = $_POST['rolldicenum'];
$sides = $_POST['rolldicesides'];
if (getInfo(user,dice,"WHERE user='$userId'")) $failure = "You previously chose to roll dice and hide the result - you must display or discard the result by using the respective commands.";
$hide = $_POST['rolldicehide'];
if (($hide >= $num) && ($hide != "none") && ($hide != "all")) $failure = "You have chosen to hide more dice than you are rolling. If you chose to hide the same number of dice that you rolled, please select 'Hide All' instead of the number of dice.";
$showtotal = $_POST['rolldicetotal'];
if (($num < 0) || ($num > 10)) $failure = "You have selected an invalid number of dice.";
if (!$failure) {
if ($sides == 1) $sidesword = "one";
if ($sides == 2) $sidesword = "two";
if ($sides == 3) $sidesword = "three";
if ($sides == 4) $sidesword = "four";
if ($sides == 5) $sidesword = "five";
if ($sides == 6) $sidesword = "six";
if ($sides == 7) $sidesword = "seven";
if ($sides == 8) $sidesword = "eight";
if ($sides == 9) $sidesword = "nine";
if ($sides == 10) $sidesword = "ten";
if ($sides == 11) $sidesword = "eleven";
if ($sides == 12) $sidesword = "twelve";
if ($sides == 13) $sidesword = "thirteen";
if ($sides == 14) $sidesword = "fourteen";
if ($sides == 15) $sidesword = "fifteen";
if ($sides == 16) $sidesword = "sixteen";
if ($sides == 17) $sidesword = "seventeen";
if ($sides == 18) $sidesword = "eighteen";
if ($sides == 19) $sidesword = "nineteen";
if ($sides == 20) $sidesword = "twenty";
if ($hide == "none") {
unset($rolls);
$god = "$user_name rolled $num $sidesword sided dice, and achieved the following results: ";
for ($i = 1;$i <= $num;$i++) {
$rolls[] = rand(1,$sides);
}
$total = 0;
$max = count($rolls);
for ($i = 0;$i < $max;$i++) {
$total += $rolls[$i];
}
$success = "You have rolled $num $sidesword sided dice, and achieved the following results: ".implode(', ',$rolls);
$rolls = implode(', ',$rolls);
$god .= $rolls.".";
if ($showtotal) $god .= " The sum of all the rolls is $total.";
} elseif ($hide == "all") {
unset($rolls);
$god = "$user_name rolled $num $sidesword sided dice. The results will remain hidden until $user_name chooses to display them.";
for ($i = 1;$i <= $num;$i++) {
$rolls[] = rand(1,$sides);
}
$total = 0;
$max = count($rolls);
for ($i = 0;$i < $max;$i++) {
$total += $rolls[$i];
}
$success = "You have rolled $num $sidesword sided dice, and achieved the following results: ".implode(', ',$rolls).". These results will remain hidden until you choose to display them.";
$rolls = implode('.',$rolls);
$query = "INSERT INTO dice VALUES('','$userId','$rolls')";
mysql_query($query);
if ($showtotal) $god .= " The sum of all the rolls is $total.";
} else {
unset($rolls);
unset($hidden);
$god = "$user_name rolled $num $sidesword sided dice. Only ".($num - $hide)." of the results will be shown. The other(s) will remain hidden until $user_name chooses to display them. ";
for ($i = 1;$i <= $num - $hide;$i++) {
$rolls[] = rand(1,$sides);
}
for ($i = 1;$i <= $hide;$i++) {
$hidden[] = rand(1,$sides);
}
$total = 0;
$max = count($rolls);
for ($i = 0;$i < $max;$i++) {
$total += $rolls[$i];
}
$max = count($hidden);
for ($i = 0;$i < $max;$i++) {
$total += $hidden[$i];
}
$success = "You have rolled $num $sidesword sided dice, and achieved the following results: ".implode(', ',$rolls).", ".implode(', ',$hidden).". Only the first ".($num - $hide)." are to be shown to the public; the others will remain hidden until you choose to display them.";
$rolls = implode(', ',$rolls);
$god .= $rolls.".";
if ($showtotal) $god .= " The sum of all the rolls is $total.";
$hidden = implode('.',$hidden);
$query = "INSERT INTO dice VALUES('','$userId','$hidden')";
mysql_query($query);
}
$post .= "
[Rolled $num $sidesword sided dice]";
}
}
if ($command == "showdice") {
if (!getInfo(user,dice,"WHERE user='$userId'")) $failure = "There are no records of any dice you have rolled. Either they have been already displayed, they have been discarded, or you simply have not yet rolled.";
if (!$failure) {
$sex = getInfo(sex,users,"WHERE id='$userId'");
if ($sex == "f") {
$his = "her";
$he = "she";
$His = "Her";
$He = "She";
} else {
$his = "his";
$he = "he";
$He = "He";
$His = "His";
}
$rolls = getInfo(rolls,dice,"WHERE user='$userId'");
$rolls = implode(', ',explode('.',$rolls));
$god = "$user_name has chosen to display $his rolls. $He rolled $rolls.";
$success = "You have successfully displayed your rolls.";
$query = "DELETE FROM dice WHERE user='$userId'";
mysql_query($query);
$post .= "
[Displayed hidden rolls]";
}
}
if ($command == "discarddice") {
if (!getInfo(user,dice,"WHERE user='$userId'")) $failure = "There are no records of any dice you have rolled. Either they have been already displayed, they have been discarded, or you simply have not yet rolled.";
if (!$failure) {
$sex = getInfo(sex,users,"WHERE id='$userId'");
if ($sex == "f") {
$his = "her";
$he = "she";
$His = "Her";
$He = "She";
} else {
$his = "his";
$he = "he";
$He = "He";
$His = "His";
}
$god = "$user_name has chosen to discard $his rolls.";
$success = "You have successfully discarded your rolls.";
$query = "DELETE FROM dice WHERE user='$userId'";
mysql_query($query);
$post .= "
[Discarded hidden rolls]";
}
}
if ($command == "createpot") {
$start = $_POST['createpotStart'];
$extra = $_POST['createpotExtra'];
if (getInfo(id,pots,"WHERE creator='$userId'")) $failure = "You already have a pot going.";
if ($extra < 0) $failure = "You may not enter a negative amount.";
if ($start < 0) $failure = "You may not enter a negative amount.";
$money = getInfo(money,users,"WHERE id='$userId'");
$money -= $extra;
if ($money < 0) $failure = "You do not have enough money. Please put less money in the pot.";
$result = getRows(pots,"WHERE users like '%$userId%'");
while ($row = mysql_fetch_array($result)) {
$users = explode('.',$row['users']);
if (inArray($userId,$users)) $failure = "You are already part of another pot.";
}
if (!$failure) {
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$query = "INSERT INTO pots VALUES('','$userId','','','$start','$start','$extra','','')";
mysql_query($query);
$success = "You have successfully created a pot. For anyone to join this pot, they will have to pay a starting fee of $start gold.";
$post .= "
[Created a pot]";
}
}
if ($command == "joinpot") {
$pot = $_POST['joinpotPot'];
$creator = getInfo(creator,pots,"WHERE id='$pot'");
$creatorName = getInfo(username,users,"WHERE id='$creator'");
if (getInfo(room,users,"WHERE id='$creator'") != $id) $failure = "The creator of that pot is not currently in this room.";
$result = getRows(pots,"WHERE users like '%$userId%'");
while ($row = mysql_fetch_array($result)) {
$users = explode('.',$row['users']);
if (inArray($userId,$users)) $failure = "You are already part of another pot.";
}
$money = getInfo(money,users,"WHERE id='$userId'");
$start = getInfo(start,pots,"WHERE id='$pot'");
if ($money < $start) $failure = "You cannot afford the ante.";
if (getInfo("current",pots,"WHERE id='$pot'") != getInfo(start,pots,"WHERE id='$pot'")) $failure = "You may not join this pot, as the ante has already been raised.";
if (!$failure) {
$money -= $start;
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$users = getInfo(users,pots,"WHERE id='$pot'");
$bets = getInfo(bets,pots,"WHERE id='$pot'");
if ($users) $users .= '.'.$userId;
else $users = $userId;
if ($bets) $bets .= '.'.$start;
else $bets = $start;
$query = "UPDATE pots SET users='$users' WHERE id='$pot'";
mysql_query($query);
$query = "UPDATE pots SET bets='$bets' WHERE id='$pot'";
mysql_query($query);
$success = "You have successfully joined the pot.";
$post .= "
[Joined $creatorName's pot]";
}
}
if ($command == "callpot") {
$result = getRows(pots,"WHERE users like '%$userId%'");
while ($row = mysql_fetch_array($result)) {
$users = explode('.',$row['users']);
if (inArray($userId,$users)) $pot = $row['id'];
}
if (!$pot) $failure = "You are not part of any pot.";
$allin = getInfo(allin,pots,"WHERE id='$pot'");
$allin = explode('.',$allin);
if (inArray($userId,$allin)) $failure = "You may not call this bet - you have already put all your available funds into the pot.";
$users = getInfo(users,pots,"WHERE id='$pot'");
$users = explode('.',$users);
$bets = getInfo(bets,pots,"WHERE id='$pot'");
$bets = explode('.',$bets);
$betPosition = position($userId,$users);
$bet = $bets[$betPosition];
$current = getInfo("current",pots,"WHERE id='$pot'");
$difference = $current - $bet;
if ($difference <= 0) $failure = "Your bet is already equal or higher than any other.";
$money = getInfo(money,users,"WHERE id='$userId'");
if (!$failure) {
if ($money - $difference < 0) {
$bet += $money;
$money = 0;
$bets[$betPosition] = $bet;
$bets = implode('.',$bets);
$query = "UPDATE pots SET bets='$bets' WHERE id='$pot'";
mysql_query($query);
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$allin = getInfo(allin,pots,"WHERE id='$pot'");
if ($allin) $allin .= '.'.$userId;
else $allin = $userId;
$query = "UPDATE pots SET allin='$allin' WHERE id='$pot'";
mysql_query($query);
$success = "You did not have enough money to meet the bet - so, all of your funds have been put into the pot. You will no longer be able to call or raise, and if you should win, you will be only allowed to taste a fraction of the pot.";
$post .= "
[Attempted to match the bet by putting all his gold in the pot]";
} else {
$bet = $current;
$money -= $difference;
$bets[$betPosition] = $bet;
$bets = implode('.',$bets);
$query = "UPDATE pots SET bets='$bets' WHERE id='$pot'";
mysql_query($query);
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$success = "You have successfully matched the bet.";
$post .= "
[Matched the bet]";
}
}
}
if ($command == "raisepot") {
$raise = $_POST['raisepotRaise'];
if ($raise < 1) $failure = "You must raise by at least one gold.";
$result = getRows(pots,"WHERE users like '%$userId%'");
while ($row = mysql_fetch_array($result)) {
$users = explode('.',$row['users']);
if (inArray($userId,$users)) $pot = $row['id'];
}
if (!$pot) $failure = "You are not part of any pot.";
$allin = getInfo(allin,pots,"WHERE id='$pot'");
$allin = explode('.',$allin);
if (getInfo(noraise,pots,"WHERE id='$pot'")) $failure = "You may not raise anymore.";
if (inArray($userId,$allin)) $failure = "You may not raise this bet - you have already put all your available funds into the pot.";
$money = getInfo(money,users,"WHERE id='$userId'");
$users = getInfo(users,pots,"WHERE id='$pot'");
$users = explode('.',$users);
$bets = getInfo(bets,pots,"WHERE id='$pot'");
$bets = explode('.',$bets);
$betPosition = position($userId,$users);
$bet = $bets[$betPosition];
$current = getInfo("current",pots,"WHERE id='$pot'");
$current += $raise;
$difference = $current - $bet;
if ($money - $difference < 0) $failure = "You do not have enough money to do that.";
if (!$failure) {
$money -= $difference;
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$bets[$betPosition] = $current;
$bets = implode('.',$bets);
$query = "UPDATE pots SET bets='$bets' WHERE id='$pot'";
mysql_query($query);
$query = "UPDATE pots SET current='$current' WHERE id='$pot'";
mysql_query($query);
$success = "You have successfully raised the bet.";
$post .= "
[Raised the bet by $difference gold]";
}
}
if ($command == "foldpot") {
$result = getRows(pots,"WHERE users like '%$userId%'");
while ($row = mysql_fetch_array($result)) {
$users = explode('.',$row['users']);
if (inArray($userId,$users)) $pot = $row['id'];
}
if (!$pot) $failure = "You are not part of any pot.";
$users = getInfo(users,pots,"WHERE id='$pot'");
$users = explode('.',$users);
$bets = getInfo(bets,pots,"WHERE id='$pot'");
$bets = explode('.',$bets);
$betPosition = position($userId,$users);
$bet = $bets[$betPosition];
if (!$failure) {
unset($users[$betPosition]);
unset($bets[$betPosition]);
echo $betPosition.' : ';
$extra = getInfo(extra,pots,"WHERE id='$pot'");
$extra += $bet;
$users = implode('.',$users);
$bets = implode('.',$bets);
echo $users.' : ';
print_r($users);
$query = "UPDATE pots SET users='$users' WHERE id='$pot'";
mysql_query($query);
$query = "UPDATE pots SET bets='$bets' WHERE id='$pot'";
mysql_query($query);
$query = "UPDATE pots SET extra='$extra' WHERE id='$pot'";
mysql_query($query);
$success = "You have successfully folded, and given up your bet.";
$post .= "
[Folded bet]";
}
}
if ($command == "lock") {
$door = $_POST['lockroom'];
$newdoor = getInfo(id,doors,"WHERE (room='$id' or room2='$id') and id='$door'");
if (!$newdoor) {
if (getInfo(entrance,places,"WHERE id='$buildingId'") == $id) {
$newdoor = getInfo(id,doors,"WHERE id='$door' and room2='out'");
} else {
$failure = "You cannot access that door from this room.";
}
}
$door = $newdoor;
if ($door) {
$room = getInfo(room,doors,"WHERE id='$door'");
$room2 = getInfo(room2,doors,"WHERE id='$door'");
$roomname = getInfo(name,rooms,"WHERE id='$room'");
$room2name = getInfo(name,rooms,"WHERE id='$room2'");
$place = getInfo(place,rooms,"WHERE id='$room'");
$placetype = getInfo(type,places,"WHERE id='$place'");
$placetype = getInfo(type,buildings,"WHERE id='$placetype'");
if ($placetype == "open space") $failure = "You may not lock an open space.";
$entrance = getInfo(entrance,rooms,"WHERE id='$room'");
$town = getInfo(town,places,"WHERE id='$place'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$inventory = explode('.',$inventory);
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
$type = getInfo(type,user_items,"WHERE id='$item'");
if ($type == "key") {
if (getInfo("stat",user_items,"WHERE id='$item'") == $door) $havekey = true;
}
}
if (getInfo(locked,doors,"WHERE id='$door'")) $failure = "This door is already locked.";
if (!$havekey) $failure = "You do not have the key to this room.";
}
if (!$failure) {
$query = "UPDATE doors SET locked='locked' WHERE id='$door'";
mysql_query($query);
$success = "You have locked this door.";
}
}
if ($command == "unlock") {
$door = $_POST['unlockroom'];
$room = getInfo(room,doors,"WHERE id='$door'");
$room2 = getInfo(room2,doors,"WHERE id='$door'");
$roomname = getInfo(name,rooms,"WHERE id='$room'");
$room2name = getInfo(name,rooms,"WHERE id='$room2'");
$place = getInfo(place,rooms,"WHERE id='$room'");
$entrance = getInfo(entrance,rooms,"WHERE id='$room'");
$town = getInfo(town,places,"WHERE id='$place'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$inventory = explode('.',$inventory);
$max = count($inventory);
for ($i = 0;$i < $max;$i++) {
$item = $inventory[$i];
$type = getInfo(type,user_items,"WHERE id='$item'");
if ($type == "key") {
if (getInfo("stat",user_items,"WHERE id='$item'") == $door) $havekey = true;
}
}
if (!getInfo(locked,doors,"WHERE id='$door'")) $failure = "This door is not locked.";
if (!$havekey) $failure = "You do not have the key to this room.";
if (!$failure) {
$query = "UPDATE doors SET locked='' WHERE id='$door'";
mysql_query($query);
$success = "You have unlocked this door.";
}
}
if ($command == "breakdown") {
$door = $_POST['breakdownroom'];
$room = getInfo(room,doors,"WHERE id='$door'");
$room2 = getInfo(room2,doors,"WHERE id='$door'");
$roomname = getInfo(name,rooms,"WHERE id='$room'");
$room2name = getInfo(name,rooms,"WHERE id='$room2'");
if ($room2 == "out") $room2name = "Outside";
$place = getInfo(place,doors,"WHERE id='$door'");
$placename = getInfo(name,places,"WHERE id='$place'");
$town = getInfo(town,places,"WHERE id='$place'");
if (!sameDistrict($place,$buildingId)) $failure = "You cannot reach that door from here.1";
$entrance = getInfo(entrance,places,"WHERE id='$place'");
$doorHealth = getInfo(health,doors,"WHERE id='$door'");
if ($doorHealth <= 0) $failure = "This door is already destroyed.";
$town = getInfo(town,places,"WHERE id='$place'");
if (($room != $id) && ($room2 != $id) && ($room2 != "out")) $failure = "You cannot access this door from here. $room, $id, $room2";
if (!$failure) {
$health = getInfo(health,users,"WHERE id='$userId'");
$damage = rand($health - 50,$health);
echo "$damage ";
$class = getInfo("class",users,"WHERE id='$userId'");
$intox = getInfo(dex,users,"WHERE id='$userId'");
if (($class == "barbarian") && ($intox > 0)) {
$damage_inc = 1 + ($intox / 50);
if (($class == "barbarian") && ($intox > 0)) $damage = round($damage * $damage_inc);
}
echo "$damage ";
$damage += itemStat($userId,"weapon");
echo "$damage ";
if ($damage < 0) $damage = 0;
$doorDamage = $damage;
$doorHealth -= $damage;
if ($doorHealth >= 0) {
$damage = round($damage * 0.75);
$damage -= itemStat($userId,"armour",$damage);
if ($damage < 0) $damage = 0;
$health = getInfo(health,users,"WHERE id='$userId'");
$health -= $damage;
$query = "UPDATE users SET health='$health' WHERE id='$userId'";
mysql_query($query);
$god = "$user_name attempted to break down the door between $roomname and $room2name, in $placename, but failed to destroy it completely.";
$god .= " $doorDamage damage was dealt to the door, leaving it at $doorHealth health.";
$god .= " $damage recoil damage was dealt to $user_name.";
$success = "You have failed to tear down the door completely.";
if ($health <= 0) {
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$userId'";
mysql_query($query);
$sleep = time();
$query = "UPDATE users SET sleep='$sleep' WHERE id='$userId'";
mysql_query($query);
$god .= " $user_name is now unconscious.";
}
} else {
$doorHealth = 0;
$query = "UPDATE doors SET locked='' WHERE id='$door'";
mysql_query($query);
$god = "$user_name attempted to break down the door to to $roomname, in $placename, and destroyed it.";
$god .= " $doorDamage damage was dealt to the door. It is now unlocked.";
$success = "You have successfully broken down the door.";
}
$query = "UPDATE doors SET health='$doorHealth' WHERE id='$door'";
mysql_query($query);
$post .= "
[Attempted to break down a door]";
}
}
if ($command == "block") {
$door = $_POST['blockDoor'];
$room = getInfo(room,doors,"WHERE id='$door'");
if ($room == $id) $room = getInfo(room2,doors,"WHERE id='$door'");
if ($room != "out") {
$roomplace = getInfo(place,rooms,"WHERE id='$room'");
$roomname = getInfo(name,rooms,"WHERE id='$room'").', '.getInfo(name,places,"WHERE id='$roomplace'");
} else {
$roomname = "outside";
}
$place_type = getInfo(type,places,"WHERE id='$buildingId'");
if (($roomname == "outside") && ((getInfo(label,buildings,"WHERE id='$place_type'") == "ship") || (getInfo(label,buildings,"WHERE id='$place_type'") == "caravan"))) $failure = "You may not block the door to the outside of a ship or a caravan.";
$room = getInfo(room,users,"WHERE id='$userId'");
if (!getInfo(id,doors,"WHERE (room='$id' or room2='$id') and id='$door'")) $failure = "You cannot block that door from this room.";
if (getInfo(id,doors,"WHERE block='$userId' or block2='$userId'")) $failure = "You are already blocking a door.";
if (getInfo(room,doors,"WHERE id='$door'") == $id) {
if (getInfo(block,doors,"WHERE id='$door'")) $failure = "This door is already blocked.";
} else {
if (getInfo(block2,doors,"WHERE id='$door'")) $failure = "This door is already blocked.";
}
if (!$failure) {
if (getInfo(room,doors,"WHERE id='$door'") == $id) {
$query = "UPDATE doors SET block='$userId' WHERE id='$door'";
} else {
$query = "UPDATE doors SET block2='$userId' WHERE id='$door'";
}
mysql_query($query);
$success = "You have successfully blocked the doorway to $doorname.";
$post .= "
[Blocked the doorway to $roomname.]";
}
}
if ($command == "unblock") {
$query = "UPDATE doors SET block='' WHERE block='$userId'";
mysql_query($query);
$query = "UPDATE doors SET block2='' wHERE block2='$userId'";
mysql_query($query);
$success = "You have stopped blocking a door.";
$post .= "
[Stopped blocking a door]";
}
if ($command == "lockpick") {
$door = $_POST['lockpickroom'];
$room = getInfo(room,doors,"WHERE id='$door'");
$roomname = getInfo(name,rooms,"WHERE id='$room'");
$room2 = getInfo(room2,doors,"WHERE id='$door'");
$room2name = getInfo(name,rooms,"WHERE id='$room2'");
if ($room2 == "out") $room2name = "Outside";
$place = getInfo(place,doors,"WHERE id='$door'");
$placename = getInfo(name,places,"WHERE id='$place'");
$town = getInfo(town,places,"WHERE id='$place'");
if (!sameDistrict($place,$buildingId)) $failure = "You cannot reach that door from here.";
$entrance = getInfo(entrance,places,"WHERE id='$place'");
$doorHealth = getInfo(health,doors,"WHERE id='$door'");
if (getInfo(steal,users,"WHERE id='$userId'") > time()) $failure = "You may not pick a lock yet.";
if ($doorHealth <= 0) $failure = "This door is already destroyed.";
if (!$failure) {
$pick = getInfo(pick,users,"WHERE id='$userId'");
$chance = getInfo(pick,doors,"WHERE id='$door'") + floor($pick / 5);
if (getInfo(bonus,users,"WHERE id='$userId'") == "stealthy") $chance += 30;
if (getInfo(bonus,users,"WHERE id='$userId'") == "lucky") $chance += 30;
if (rand(1,100) <= $chance) {
$pick++;
$god = "$user_name successfully picked the lock of the door between $roomname and $room2name, in $placename.";
$query = "UPDATE doors SET locked='' WHERE id='$door'";
mysql_query($query);
$query = "UPDATE users SET pick='$pick' WHERE id='$userId'";
mysql_query($query);
$success = "You have successfully picked the lock.";
} else {
$god = "$user_name failed to pick the lock of the door between $roomname and $room2name, in $placename.";
$steal = time() + 24 * 3600;
$query = "UPDATE users SET steal='$steal' WHERE id='$userId'";
mysql_query($query);
$success = "You have failed to pick the lock, and have broken your lock pick. You must wait 24 hours before you can try to pick a lock again.";
}
$post .= "
[Attempted to pick a lock]";
}
}
if ($command == "buy") {
$item1 = $_POST['buyItem1'];
$item2 = $_POST['buyItem2'];
$item3 = $_POST['buyItem3'];
$item4 = $_POST['buyItem4'];
$item5 = $_POST['buyItem5'];
$currency = $_POST['buyCurrency'];
if (($currency) && (!getInfo(id,currencies,"WHERE place='$buildingId' and item='$currency'"))) $failure = "That currency is not accepted here.";
if ((!$item1) && (!$item2) && (!$item3) && (!$item4) && (!$item5)) $failure = "You have not selected an item to buy.";
if (isFighting($userId)) $failure = "You are currently being attacked, and must react to that, before you can do anything else.";
$shop = getInfo(shop,items,"WHERE id='$item1'");
$shop = explode(':',$shop);
$shop1 = $shop[0];
$shop1_room = $shop[1];
$shop = getInfo(shop,items,"WHERE id='$item2'");
$shop = explode(':',$shop);
$shop2 = $shop[0];
$shop2_room = $shop[1];
$shop = getInfo(shop,items,"WHERE id='$item3'");
$shop = explode(':',$shop);
$shop3 = $shop[0];
$shop3_room = $shop[1];
$shop = getInfo(shop,items,"WHERE id='$item4'");
$shop = explode(':',$shop);
$shop4 = $shop[0];
$shop4_room = $shop[1];
$shop = getInfo(shop,items,"WHERE id='$item5'");
$shop = explode(':',$shop);
$shop5 = $shop[0];
$shop5_room = $shop[1];
if ((($shop1_room != $id) && ($shop1_room)) || (($shop2_room != $id) && ($shop2_room)) || (($shop3_room != $id) && ($shop3_room)) || (($shop4_room != $id) && ($shop4_room)) || (($shop5_room != $id) && ($shop5_room))) $failure = "At least one of the items is not sold in this specific room.";
if ((($shop1 != $buildingId) && ($item1)) || (($shop2 != $buildingId) && ($item2)) || (($shop3 != $buildingId) && ($item3)) || (($shop4 != $buildingId) && ($item4)) || (($shop5 != $buildingId) && ($item5))) $failure = "At least one of the items is not sold here.";
$money = getInfo(money,users,"WHERE id='$userId'");
$result = getRows(items,"WHERE shop='$buildingId' or shop='$buildingId:$id' or shop='$buildingId:'");
while ($row = mysql_fetch_array($result)) {
$stock[$row['id']] = $row['stock'];
}
$cost = 0;
$cost += $cost1 = getInfo(price,items,"WHERE id='$item1'");
$cost += $cost2 = getInfo(price,items,"WHERE id='$item2'");
$cost += $cost3 = getInfo(price,items,"WHERE id='$item3'");
$cost += $cost4 = getInfo(price,items,"WHERE id='$item4'");
$cost += $cost5 = getInfo(price,items,"WHERE id='$item5'");
if (($stock[$item1] <= 0) && ($item1)) {
$failure = "Item 1 is out of stock.";
} else $stock[$item1]--;
if (($stock[$item2] <= 0) && ($item2)) {
$failure = "Item 2 is out of stock.";
} else $stock[$item2]--;
if (($stock[$item3] <= 0) && ($item3)) {
$failure = "Item 3 is out of stock.";
} else $stock[$item3]--;
if (($stock[$item4] <= 0) && ($item4)) {
$failure = "Item 4 is out of stock.";
} else $stock[$item4]--;
if (($stock[$item5] <= 0) && ($item5)) {
$failure = "Item 5 is out of stock.";
} else $stock[$item5]--;
if (!$currency) {
$money -= $cost;
if ($money < 0) $failure = "You do not have enough money.";
} else {
$exchange = getInfo(exchange,currencies,"WHERE place='$buildingId' and item='$currency'");
$cost = ceil($cost / $exchange);
if (!hasItem($userId,$currency,$cost)) $failure = "You do not have enough of the currency.";
$currencycost = $cost;
}
if (!$failure) {
if ($_POST['server'] == "random") {
$employees = getInfo(employees,places,"WHERE id='$buildingId'");
$employees = explode('.',$employees);
$max = count($employees);
for ($i = 0;$i < $max;$i++) {
if (getInfo(status,users,"WHERE id='$userId'") != "dead") {
$employee = $employees[$i];
if ((getInfo(NPC,users,"WHERE id='$employee'")) && (getInfo(room,users,"WHERE id='$employee'") == $id) && (getInfo(mode,npcs,"WHERE name='$employee'") == "sell") && (getInfo(status,users,"WHERE id='$employee'") == "conscious")) $npcs[] = $employee;
}
}
$npc = $npcs[rand(0,count($npcs) - 1)];
}
for ($i = 1;$i <= 5;$i++) {
$storage = "item".$i;
$item = $$storage;
$storage = "cost".$i;
$cost = $$storage;
if ($item) {
if ((!$npc) && ($_POST['server'])) $npc = $_POST['server'];
if (!$npc) {
$query = "INSERT INTO purchases VALUES('','$userId','$item','$buildingId','$cost','$currency')";
mysql_query($query);
$stock = getInfo(stock,items,"WHERE id='$item'");
$stock--;
$query = "UPDATE items SET stock='$stock' WHERE id='$item'";
mysql_query($query);
} else {
if (!$currency) {
$placeMoney = getInfo(money,places,"WHERE id='$buildingId'");
$placeMoney += $cost;
$query = "UPDATE places SET money='$placeMoney' WHERE id='$buildingId'";
mysql_query($query);
} else {
$placeCurrency = getInfo(amount,currencies,"WHERE place='$buildingId' and item='$currency'");
$placeCurrency += $cost;
$query = "UPDATE currencies SET amount='$placeCurrency' WHERE place='$buildingId' and item='$currency'";
mysql_query($query);
}
$sold_items[] = getInfo(name,items,"WHERE id='$item'");
$stock = getInfo(stock,items,"WHERE id='$item'");
$stock--;
$query = "UPDATE items SET stock='$stock' WHERE id='$item'";
mysql_query($query);
$portions = getInfo(portions,items,"WHERE id='$item'");
$stat = getInfo(stat,items,"WHERE id='$item'");
$type = getInfo(type,items,"WHERE id='$item'");
$name = getInfo(name,items,"WHERE id='$item'");
$pawn = getInfo(pawn,items,"WHERE id='$item'");
if (!$pawn) $pawn = $item;
$item = createItem($pawn);
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if ($inventory) $inventory .= '.'.$item;
else $inventory = $item;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
}
}
}
if (!$currency) {
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
} else {
chargeItem($userId,$currency,$currencycost);
}
$success = "You have successfully ordered the items. Now you must wait for an employee of the store, or the owner, to sell them to you. Should they take too long, or should you want a refund, you may choose to cancel your order.";
if ($npc) {
$npcname = getInfo(username,users,"WHERE id='$npc'");
$god = $npcname." took the payment and handed ".$user_name." the following items: ".implode(', ',$sold_items);
$success = "You have successfully ordered the items. One of the NPC employees took your payment, and gave you the items.";
}
}
}
if ($command == "claim") {
if (getInfo(room,users,"WHERE id='$userId'") != $id) $failure = "You are not in this room.";
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(id,tribes,"WHERE village='$town'")) {
$hunters = getInfo(hunters,tribes,"WHERE village='$town'");
$villagers = getInfo(villagers,tribes,"WHERE village='$town'");
if (numRowsConditions(npcs,"WHERE npcgroup='$hunters' or npcgroup='$villagers'") > 0) $failure = "You may not claim any room in the village of a tribe while any tribe members still live.";
}
if (getInfo(tenant,rooms,"WHERE id='$id'")) {
$guarded = false;
$tenant = getInfo(tenant,rooms,"WHERE id='$id'");
if (getInfo(room,users,"WHERE id='$tenant'") == $id) $guarded = true;
$time = time();
$result = getRows(contracts,"WHERE boss='$tenant' and expiration<'$time'");
while ($row = mysql_fetch_array($result)) {
if ($row['room'] == $id) $guarded = true;
}
if ($guarded) $failure = "This room has already been claimed.";
}
if ((getInfo(owner,places,"WHERE id='$buildingId'")) && (!admin(getInfo(owner,places,"WHERE id='$buildingId'"))) && (getInfo(owner,places,"WHERE id='$buildingId'") != 1)) $failure = "Someone already owns this building. You may not claim a room.";
if (!$failure) {
$query = "UPDATE rooms SET tenant='$userId' WHERE id='$id'";
mysql_query($query);
$room_town = getInfo(town,places,"WHERE id='$buildingId'");
$town_developed = getInfo(developed,towns,"WHERE id='$room_town'");
if (!$town_developed) {
$query = "UPDATE rooms SET rentedit='edit' WHERE id='$id'";
mysql_query($query);
}
$success = "You have successfully claimed this room for yourself.";
}
}
if ($command == "sell") {
$order1 = $_POST['sellItem1'];
$order2 = $_POST['sellItem2'];
$order3 = $_POST['sellItem3'];
$order4 = $_POST['sellItem4'];
$order5 = $_POST['sellItem5'];
if ((!$order1) && (!$order2) && (!$order3) && (!$order4) && (!$order5)) $failure = "You have not selected an order.";
$employees = explode('.',getInfo(employees,places,"WHERE id='$buildingId'"));
if (((getInfo(shop,purchases,"WHERE id='$order1'") != $buildingId) && ($order1)) || ((getInfo(shop,purchases,"WHERE id='$order2'") != $buildingId) && ($order2)) || ((getInfo(shop,purchases,"WHERE id='$order3'") != $buildingId) && ($order3)) || ((getInfo(shop,purchases,"WHERE id='$order4'") != $buildingId) && ($order4)) || ((getInfo(shop,purchases,"WHERE id='$order5'") != $buildingId) && ($order5))) $failure = "One of these orders are not set for this shop.";
if ((!inArray($userId,$employees)) && (getInfo(owner,places,"WHERE id='$buildingId'") != $userId)) $failure == "You are not an employee of this shop.";
if (!$failure) {
for ($i = 1;$i <= 5;$i++) {
$storage = "order".$i;
$order = $$storage;
if ($order) {
$price = getInfo(price,purchases,"WHERE id='$order'");
$user = getInfo(buyer,purchases,"WHERE id='$order'");
$currency = getInfo(currency,purchases,"WHERE id='$order'");
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$item = getInfo(item,purchases,"WHERE id='$order'");
if ($user) {
$portions = getInfo(portions,items,"WHERE id='$item'");
$stat = getInfo(stat,items,"WHERE id='$item'");
$type = getInfo(type,items,"WHERE id='$item'");
$name = addslashes(getInfo(name,items,"WHERE id='$item'"));
$pawn = getInfo(pawn,items,"WHERE id='$item'");
if (!$pawn) $pawn = $item;
$item = createItem($pawn);
if ($inventory) $inventory .= '.'.$item;
else $inventory = $item;
if (!$currency) {
$money = getInfo(money,places,"WHERE id='$buildingId'");
$money += $price;
$query = "UPDATE places SET money='$money' WHERE id='$buildingId'";
mysql_query($query);
} else {
$placeCurrency = getInfo(amount,currencies,"WHERE place='$buildingId' and item='$currency'");
$placeCurrency += $cost;
$query = "UPDATE currencies SET amount='$placeCurrency' WHERE place='$buildingId' and item='$currency'";
mysql_query($query);
}
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user'";
mysql_query($query);
$query = "DELETE FROM purchases WHERE id='$order'";
mysql_query($query);
}
}
$success = "You have successfully sold the items.";
}
}
}
if ($command == "sellall") {
$result = getRows(purchases,"WHERE shop='$buildingId'");
while ($row = mysql_fetch_array($result)) {
$item = $row['item'];
$buyer = $row['buyer'];
$price = $row['price'];
$order_id = $row['id'];
$record = getRow("*",items,"WHERE id='$item'");
$name = $record['name'];
$type = $record['type'];
$portions = $record['portions'];
$stat = $record['stat'];
$currency = $row['currency'];
$inventory = getInfo(inventory,users,"WHERE id='$buyer'");
$pawn = getInfo(pawn,items,"WHERE id='$item'");
if (!$pawn) $pawn = $item;
if ($inventory) $inventory .= '.'.createItem($pawn);
else $inventory = numRows(user_items);
if (!$currency) {
$money = getInfo(money,places,"WHERE id='$buildingId'");
$money += $price;
$query = "UPDATE places SET money='$money' WHERE id='$buildingId'";
mysql_query($query);
} else {
$placeCurrency = getInfo(amount,currencies,"WHERE place='$buildingId' and item='$currency'");
$placeCurrency += $cost;
$query = "UPDATE currencies SET amount='$placeCurrency' WHERE place='$buildingId' and item='$currency'";
mysql_query($query);
}
$query = "UPDATE users SET inventory='$inventory' WHERE id='$buyer'";
mysql_query($query);
$query = "DELETE FROM purchases WHERE id='$order_id'";
mysql_query($query);
}
$success = "You have successfully sold every item that has been ordered.";
}
if ($command == "cancelOrder") {
$order = $_POST['cancelItem'];
$money = getInfo(money,users,"WHERE id='$userId'");
$price = getInfo(price,purchases,"WHERE id='$order'");
$item = getInfo(item,purchases,"WHERE id='$order'");
$stock = getInfo(stock,items,"WHERE id='$item'");
$stock++;
$query = "UPDATE items SET stock='$stock' WHERE id='$item'";
mysql_query($query);
$money += $price;
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$query = "DELETE FROM purchases WHERE id='$order'";
mysql_query($query);
$success = "You have successfully cancelled an order.";
}
if ($command == "nosell") {
$order = $_POST['nosellItem'];
if (!$order) $failure = "You have not selected an order.";
$shop = getInfo(shop,purchases,"WHERE id='$order'");
$employees = explode('.',getInfo(employees,places,"WHERE id='$buildingId'"));
$buyer = getInfo(buyer,purchases,"WHERE id='$order'");
if ($shop != $buildingId) $failure = "The user did not set an order for this shop.";
if ((!inArray($userId,$employees)) && (getInfo(owner,places,"WHERE id='$buildingId'") != $userId)) $failure == "You are not an employee of this shop.";
if (!$failure) {
$item = getInfo(item,purchases,"WHERE id='$order'");
$stock = getInfo(stock,items,"WHERE id='$item'");
$stock++;
$query = "UPDATE items SET stock='$stock' WHERE id='$item'";
mysql_query($query);
$money = getInfo(money,users,"WHERE id='$buyer'");
$price = getInfo(price,purchases,"WHERE id='$order'");
$money += $price;
$query = "UPDATE users SET money='$money' WHERE id='$buyer'";
mysql_query($query);
$query = "DELETE FROM purchases WHERE id='$order'";
mysql_query($query);
$success = "You have refused to sell the item to ".$buyer.".";
}
}
if ($command == "surrenderstock") {
$user = $_POST["surrenderstockUser"];
$username = getInfo(username,users,"WHERE id='$user'");
$employees = getInfo(employees,places,"WHERE id='$buildingId'");
$employees = explode('.',$employees);
if ((!inArray($userId,$employees)) && ($userId != getInfo(owner,places,"WHERE id='$buildingId'"))) $failure = "Only an employee or an owner may surrender the stock of their shop.";
if (!$failure) {
$result = getRows(items,"WHERE shop='$buildingId'");
while ($row = mysql_fetch_array($result)) {
$item = $row['id'];
$stock = $row['stock'];
$name = $row['name'];
$type = $row['type'];
$portions = $row['portions'];
$stat = $row['stat'];
$giveUp[] = $stock." ".$name."(s)";
for ($i = 1;$i <= $stock;$i++) {
$pawn = $row['pawn'];
if (!$pawn) $pawn = $item;
$query = "INSERT INTO user_items VALUES('','$name','$type','$pawn','$portions','$stat','','','','')";
mysql_query($query);
$stockItems[] = numRows(user_items);
}
}
$stockMoney = getInfo(money,places,"WHERE id='$buildingId'");
$name = "Pouch of ".$stockMoney." Gold Coins";
$query = "UPDATE places SET money='0' WHERE id='$buildingId'";
mysql_query($query);
$query = "UPDATE items SET stock='0' WHERE shop='$buildingId'";
mysql_query($query);
$query = "INSERT INTO user_items VALUES('','$name','money','','$stockMoney','','','','','')";
mysql_query($query);
$stockItems[] = numRows(user_items);
$stockItems = implode('.',$stockItems);
$storeName = addslashes(getInfo(name,places,"WHERE id='$buildingId'"));
$crateName = "Stock of ".$storeName;
$crateDescription = "Items stolen from ".$storeName;
$query = "INSERT INTO items VALUES('','$crateName','','$crateDescription','','','crate','$stockItems','','','','','','','','')";
mysql_query($query);
$crate_id = numRows(items);
$query = "INSERT INTO user_items VALUES('','$crateName','crate','$crate_id','0','$stockItems','0','','','')";
mysql_query($query);
$crate_id = numRows(user_items);
$inventory = getInfo(inventory,users,"WHERE id='$user'");
if ($inventory) $inventory .= '.'.$crate_id;
else $inventory = $crate_id;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user'";
mysql_query($query);
$giveUpOutput = implode(' ',$giveUp);
$success = "You have given up the following items from the store: ".$stockMoney." gold ".$giveUpOutput;
if ($user == $userId) $post .= "
[Surrendered the entire shop's stock to ".$username."]";
}
}
if ($command == "stealstock") {
$employees = getInfo(employees,places,"WHERE id='$buildingId'");
$employees = explode('.',$employees);
$owner = getInfo(owner,places,"WHERE id='$buildingId'");
$time = time() - (3600 * 7 * 24);
$result = getRows(users,"WHERE location='$buildingId' and (logged>='$time' or NPC!='') and status='conscious'");
$conditions = "(shop='$buildingId' or shop='$buildingId:' or shop='$buildingId:$id')";
while ($row = mysql_fetch_array($result)) {
if ((inArray($row['id'],$employees)) || ($row['id'] == $owner)) {
$conditions = "shop='$buildingId:$id'";
$result2 = getRows(users,"WHERE room='$id' and (logged>='$time' or NPC!='') and status='conscious'");
while ($row2 = mysql_fetch_array($result2)) {
if ((inArray($row2['id'],$employees)) || ($row2['id'] == $owner)) {
$failure = "There are conscious employees in this room. You must knock them out if they are NPCs, or attempt to threaten them if they are other players.";
break;
}
}
if (numRowsConditions(items,"WHERE shop='$buildingId:$id' and stock>'0'") <= 0) $failure = "There are no items being sold specifically in this room. In order to steal the items that are being sold all across the building, you must knock out every employee in the building.";
break;
}
}
$weight = weigh($userId);
$weightMax = maxWeight($userId);
if ($weight > $weightMax) $failure = "You cannot carry anything else in your inventory, or else it will get too heavy.";
if (!$failure) {
$weight = 0;
while ((weigh($userId) + $weight < $weightMax) && (numRowsConditions(items,"WHERE $conditions and stock>'0'") > 0)) {
$row = getRow("*",items,"WHERE $conditions and stock>'0' ORDER BY rand()");
$item = $row['id'];
$stock = $row['stock'];
$name = $row['name'];
$type = $row['type'];
$portions = $row['portions'];
$stat = $row['stat'];
$giveUp[] = $name;
$pawn = $row['pawn'];
if (!$pawn) $pawn = $item;
$query = "INSERT INTO user_items VALUES('','$name','$type','$pawn','$portions','$stat','','','','')";
mysql_query($query);
$stock--;
$query = "UPDATE items SET stock='$stock' WHERE id='$item'";
mysql_query($query);
$newItem = numRows(user_items);
$stockItems[] = $newItem;
$weight += count_items($newItem);
}
$placeMoney = getInfo(money,places,"WHERE id='$buildingId'");
unset($rooms);
$result = getRows(items,"WHERE shop like '$buildingId:%'");
while ($row = mysql_fetch_array($result)) {
$shop = $row['shop'];
$shop = explode(':',$shop);
$room = $shop[1];
if (!inArray($room,$rooms)) $rooms[] = $room;
}
$num_rooms = count($rooms);
$stockMoney = round($placeMoney / $num_rooms);
$placeMoney -= $stockMoney;
if ($placeMoney < 0) $placeMoney = 0;
$name = "Pouch of ".$stockMoney." Gold Coins";
$query = "INSERT INTO user_items VALUES('','$name','money','','$stockMoney','','','','','')";
mysql_query($query);
$query = "UPDATE places SET money='$placeMoney' WHERE id='$buildingId'";
//mysql_query($query);
$stockItems[] = numRows(user_items);
$stockItems = implode('.',$stockItems);
$storeName = getInfo(name,places,"WHERE id='$buildingId'");
$crateName = "Stock of ".addslashes($storeName);
$crateDescription = "Items stolen from ".addslashes($storeName);
$query = "INSERT INTO items VALUES('','$crateName','','$crateDescription','','','crate','$stockItems','','','','','','','','')";
mysql_query($query);
$crate_id = numRows(items);
$query = "INSERT INTO user_items VALUES('','$crateName','crate','$crate_id','0','$stockItems','0','','','')";
mysql_query($query);
$crate_id = numRows(user_items);
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if ($inventory) $inventory .= '.'.$crate_id;
else $inventory = $crate_id;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$giveUpOutput = implode(' ',$giveUp);
$success = "You have stolen the following items from the store: ".$stockMoney." gold ".$giveUpOutput;
$post .= "
[Stole from the shop's stock]";
}
}
if ($command == "pickpocket") {
$user = $_POST['pickpocketUser'];
$username = getInfo(username,users,"WHERE id='$user'");
$item = $_POST['pickpocketItem'.$user];
if ($item != "money") {
$inventory = getInfo(inventory,users,"WHERE id='$user'");
$overhead = getInfo(overhead,users,"WHERE id='$user'");
$clothes = getInfo(clothes,users,"WHERE id='$user'");
$behind = getInfo(behind,users,"WHERE id='$user'");
if (getInfo(status,users,"WHERE id='$user'") != "conscious") {
if ((!inArray($item,explode('.',$inventory))) && (!inArray($item,explode('.',$overhead))) && (!inArray($item,explode('.',$clothes))) && (!inArray($item,explode('.',$behind)))) $failure = "The character is not carrying that item.";
} else {
if (!inArray($item,explode('.',$inventory))) $failure = "The character is not carrying that item.";
}
}
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
if (isFighting($user)) $failure = "That user is currently fighting.";
if (isFighting($userId)) $failure = "You are currently fighting.";
if (isTied($user)) $failure = "That user is currently being immobilized.";
if (isTied($userId)) $failure = "You are currently being immobilized.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
if (!$failure) {
$chanceBonus = 0;
if (getInfo(bonus,users,"WHERE id='$userId'") == "stealthy") $chanceBonus += 25;
if (getInfo(bonus,users,"WHERE id='$userId'") == "lucky") $chanceBonus += 10;
if (getInfo(bonus,users,"WHERE id='$user'") == "saavy") $chanceBonus -= 25;
if (getInfo(bonus,users,"WHERE id='$user'") == "lucky") $chanceBonus -= 10;
$type = getInfo(type,user_items,"WHERE id='$item'");
$chance = 0;
$chanceBonus += floor(getInfo(pickpocket,users,"WHERE id='$userId'") / 5);
if ((getInfo("class",users,"WHERE id='$userId'") == "thief") && (getInfo(mode,users,"WHERE id='$userId'") == "stealth")) $chanceBonus += 50;
if ($item == "money") {
$chance = 20;
if (getInfo(money,users,"WHERE id='$user'") > 0) $amount = rand(1,getInfo(money,users,"WHERE id='$user'"));
else $amount = 0;
} else {
if ($type == "clothing") $chance = 15;
if ($type == "other") $chance = 40;
if ($type == "seal") $chance = 40;
if ($type == "key") $chance = 35;
if ($type == "resource") $chance= 30;
if ($type == "material") $chance= 30;
if (($type == "alcohol") || ($type == "drink") || ($type == "food")) $chance = 30;
if ($type == "arrows") $chance = 25;
if (($type == "armour") || ($type == "weapon")) $chance = 5;
if ($type == "crate") $chance = 15;
if ($type == "relic") $chance = 20;
}
$points = getInfo(pickpocket,users,"WHERE id='$userId'");
$points++;
$query = "UPDATE users SET pickpocket='$points' WHERE id='$userId'";
mysql_query($query);
$chance += $chanceBonus;
if ($chance > 80) $chance = 80;
if (getInfo(status,users,"WHERE id='$user'") != "conscious") $chance = 100;
$rand = rand(1,100);
if ($rand <= $chance) {
$pickpocketfail = false;
if ($item == "money") {
if ($amount > 0) {
if ($amount > 2000) $amount = 2000;
$userMoney = getInfo(money,users,"WHERE id='$user'");
$userMoney -= $amount;
$money = getInfo(money,users,"WHERE id='$userId'");
$money += $amount;
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET money='$userMoney' WHERE id='$user'";
mysql_query($query);
$success = "You have successfully stolen $amount gold.";
sendMessage($username,"Pickpocketing","Someone has pickpocketed $amount gold from you. They have done so discretely, and your character has not noticed. If your character reacts in any way that puts the criminal at risk of getting caught, you will be subject to the omniscient knowledge regulations and punishments. This notification is sent only to let you know that the item is no longer in your possession.","God");
} else $success = "$username is not carrying any gold.";
} else {
$checkoverhead = getInfo(overhead,users,"WHERE id='$user'");
$checkclothes = getInfo(clothes,users,"WHERE id='$user'");
$checkbehind = getInfo(behind,users,"WHERE id='$user'");
$userInventory = getInfo(inventory,users,"WHERE id='$user'");
if (inArray($item,explode('.',$userInventory))) $userInventory = removeElement($item,$userInventory,".");
if (inArray($item,explode('.',$checkoverhead))) $checkoverhead = removeElement($item,$checkoverhead,".");
if (inArray($item,explode('.',$checkclothes))) $checkclothes = removeElement($item,$checkclothes,".");
if (inArray($item,explode('.',$checkbehind))) $checkbehind = removeElement($item,$checkbehind,".");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if ($inventory) $inventory .= '.'.$item;
else $inventory = $item;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET inventory='$userInventory', overhead='$checkoverhead', clothes='$checkclothes', behind='$checkbehind' WHERE id='$user'";
mysql_query($query);
$success = "You have successfully stolen the item.";
sendMessage($username,"Pickpocketing","Someone has pickpocketed $itemName from you. They have done so discretely, and your character has not noticed. If your character reacts in any way that puts the criminal at risk of getting caught, you will be subject to the omniscient knowledge regulations and punishments. This notification is sent only to let you know that the item is no longer in your possession.","God");
}
} else {
if (!getInfo(NPC,users,"WHERE id='$user'")) {
$pickpocketfail = true;
$expire = time() + (36 * 3600);
$query = "INSERT INTO holds VALUES ('','$userId','$user','pickpocket','$expire')";
mysql_query($query);
$success = "You have failed to pickpocket $username unnoticed. You may not post until $username does so. $username has also been notified of your attempt.";
$post .= "
[Attempted to pickpocket $username and failed]";
sendMessage($username,"Warning! Someone has tried to pickpocket you","$user_name attempted to pickpocket your character. They will be unable to post until you do so - this will give you the opportunity to react to the attempted crime.","God");
} else {
$pickpocketfail = true;
$god = npcattack($user,$userId);
$success = "You have failed to pickpocket $username unnoticed.";
}
}
}
}
if ($command == "take") {
$item = $_POST['takeItem'];
$price = round(getInfo(price,items,"WHERE id='$item'") / 2);
$paid = 0;
$amount = $_POST['takeAmount'];
$money = getInfo(money,users,"WHERE id='$userId'");
if (getInfo(owner,places,"WHERE id='$buildingId'") != $userId) {
$money -= $price * $amount;
if ($money < 0) $failure = "You do not have enough money. Employees are allowed to purchase items instantly, for half price.";
$paid = $price;
}
if (!$item) $failure = "You have not selected an item to take.";
if ((!inArray($userId,$employees)) && (getInfo(owner,places,"WHERE id='$buildingId'") != $userId)) $failure == "You are not an employee of this shop.";
$shop = getInfo(shop,items,"WHERE id='$item'");
if (($shop != $buildingId) && ($shop != "$buildingId:") && ($shop != "$buildingId:$id")) $failure = "This item is not sold here.";
if (isFighting($userId)) $failure = "You are currently being attacked, and must react to that, before you can do anything else.";
if (getInfo(stock,items,"WHERE id='$item'") < $amount) $failure = "You are trying to take more of that item than there is in stock.";
if (!$failure) {
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$money = getInfo(money,places,"WHERE id='$buildingId'");
$money += $paid;
$query = "UPDATE places SET money='$money' WHERE id='$buildingId'";
mysql_query($query);
for ($i = 1;$i <= $amount;$i++) {
$name = getInfo(name,items,"WHERE id='$item'");
$type = getInfo(type,items,"WHERE id='$item'");
$portions = getInfo(portions,items,"WHERE id='$item'");
$stat = getInfo(stat,items,"WHERE id='$item'");
$pawn = getInfo(pawn,items,"WHERE id='$item'");
if (!$pawn) $pawn = $item;
$query = "INSERT INTO user_items VALUES('','$name','$type','$pawn','$portions','$stat','','','','')";
mysql_query($query);
$stock = getInfo(stock,items,"WHERE id='$item'");
$stock--;
$query = "UPDATE items SET stock='$stock' WHERE id='$item'";
mysql_query($query);
$newItem = numRows(user_items);
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if ($inventory) $inventory .= '.'.$newItem;
else $inventory = $newItem;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
}
$itemName = getInfo(name,items,"WHERE id='$item'");
$success = "You have taken ".$amount." of the item. It is now in your inventory.";
$post .= "
[Took a ".$itemName."]";
}
}
if ($command == "pay") {
$user = $_POST['payUser'];
$username = getInfo(username,users,"WHERE id='$user'");
if (!$user) $failure = "You did not select a user to pay.";
$payMoney = getInfo(money,users,"WHERE id='$user'");
$money = getInfo(money,users,"WHERE id='$userId'");
$payment = $_POST['payAmount'];
$money -= $payment;
if ($money < 0) $failure = "You do not have enough money.";
if (!$failure) {
$payMoney += $payment;
if (getInfo(id,npc_citizens,"WHERE npc='$user'")) {
if (getInfo(id,npc_bribes,"WHERE user='$userId' and npc='$user'")) {
$current = getInfo(current,npc_bribes,"WHERE user='$userId' and npc='$user'");
$current += $payment;
$query = "UPDATE npc_bribes SET current='$current' WHERE user='$userId' and npc='$user'";
mysql_query($query);
} else {
$query = "INSERT INTO npc_bribes VALUES('','$userId','$user','$payment','$payment')";
mysql_query($query);
}
}
$query = "UPDATE users SET money='$payMoney' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$success = "You have successfully given ".$username." ".$payment." gold.";
$post .= "
[Paid ".$username." ".$payment." gold]";
}
}
if ($command == "pickup") {
$item1 = $_POST['pickupItem1'];
$item2 = $_POST['pickupItem2'];
$item3 = $_POST['pickupItem3'];
$item4 = $_POST['pickupItem4'];
$item5 = $_POST['pickupItem5'];
$itemthrow = getInfo(id,pickups,"WHERE thrower='$userId'");
$weapon = getInfo(item,pickups,"WHERE id='$itemthrow'");
if (($itemthrow) && (($item1 == $weapon) || ($item2 == $weapon) || ($item3 == $weapon) || ($item4 == $weapon) || ($item5 == $weapon))) {
$target = getInfo(user,pickups,"WHERE id='$itemthrow'");
$time = time() - (7 * 24 * 3600);
if ((getInfo(logged,users,"WHERE id='$target'") >= $time) && (getInfo(conscious,users,"WHERE id='$target'"))) $failure = "You may not pick up this item. It is a weapon you threw at a user, and you must wait until that user posts or goes inactive.";
}
if ((!$item1) || (!$item2) || (!$item3) || (!$item4) || (!$item5)) $failure = "You must select at least one item.";
$roomInventory = getInfo(inventory,rooms,"WHERE id='$id'");
$roomInventoryArray = explode('.',$roomInventory);
for ($i = 1;$i <= 5;$i++) {
$store = "item".$i;
if ($$store != "Item") if (!inArray($$store,$roomInventoryArray)) $failure = "Item $i is not in the room at this time.";
}
$mult_item = false;
if (!$failure) {
for ($i = 1;$i <= 5;$i++) {
$store = 'item'.$i;
$item = $$store;
$roomInventory = getInfo(inventory,rooms,"WHERE id='$id'");
if ($item != "Item") {
if ((inArray($item,explode('.',$roomInventory))) && ($item)) {
$itemType = getInfo(type,user_items,"WHERE id='$item'");
if ($itemType == "money") {
$money = getInfo(money,users,"WHERE id='$userId'");
$money += getInfo(portions,user_items,"WHERE id='$item'");
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
mysql_query($query);
$roomInventory = removeElement($item,$roomInventory,'.');
$query = "UPDATE rooms SET inventory='$roomInventory' WHERE id='$id'";
mysql_query($query);
} else {
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if ($inventory) $inventory .= '.'.$item;
else $inventory = $item;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$roomInventory = removeElement($item,$roomInventory,'.');
$query = "UPDATE rooms SET inventory='$roomInventory' WHERE id='$id'";
mysql_query($query);
}
$itemName = getInfo(name,user_items,"WHERE id='$item'");
if ($itemName) $items[] = $itemName;
} else {
$mult_item = true;
}
}
}
$items = implode(', ',$items);
$success = "You have successfully picked up the items. It is now in your inventory.";
if ($mult_item) $success = "You have successfully picked up the items - however, you accidentally selected one or more items multiple times; therefore, not as many items as you expected may show up in your inventory.";
$post .= "
[".$user_name." picked up $items]";
}
}
if ($command == "carry") {
$user = $_POST['carryUser'];
if (sameUser($user,$userId)) $failure = "You may not interfere with your own character if they are in any position of vulnerability, as that would be unfair to the other players.";
$username = getInfo(username,users,"WHERE id='$user'");
if (!$user) $failure = "You did not select a user to carry.";
if ($user == "all") $username = "all unconscious/immobilized/dead characters";
if ((getInfo(status,users,"WHERE id='$user'") != "unconscious") && (getInfo(status,users,"WHERE id='$user'") != "dead") && (getInfo(status,users,"WHERE id='$user'") != "immobilized") && ($user != "all")) $failure = $username." is not unconscious or dead or immobilized at the moment.";
if ((getInfo(room,users,"WHERE id='$user'") != $id) && ($user != "all")) $failure = $username." is not in the same room as you.";
if ((getInfo(master,users,"WHERE id='$userId'")) && (getInfo(chained,users,"WHERE id='$userId'"))) $failure = "With a chain and ball around your ankle, it is too difficult for you to carry someone.";
if (isFighting($userId)) $failure = "You are currently being attacked, and must react to that, before you can move to another room.";
$destination = $_POST['carryRoom'];
$destinationRoomName = getInfo(name,rooms,"WHERE id='$destination'");
$destinationPlace = getInfo(place,rooms,"WHERE id='$destination'");
$destinationPlaceName = getInfo(name,places,"WHERE id='$destinationPlace'");
if ((inPot($userId)) || (getInfo(id,pots,"WHERE creator='$userId'"))) $failure = "You must leave the pot in which you are participating before leaving.";
if (!inArray($destination,destinations($id,$userId))) $failure = "The destination you have selected is not accessible at the current time. Certain doors may be locked, hindering your ability to reach the room. Please consult the list of destinations in move command area while posting to see which buildings/doors are locked.";
if (!$destination) $failure = "You have not selected a room.";
if (($destination != "overboard") && (!fnmatch("travel_*",$destination))) {
if ($destination == $id) $failure = "You are already in that room.";
$destinationPlace = getInfo(place,rooms,"WHERE id='$destination'");
$destinationTown = getInfo(town,places,"WHERE id='$destinationPlace'");
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are unconscious, and therefore cannot move.";
$userRoom = getInfo(room,users,"WHERE id='$userId'");
if ((getInfo(master,users,"WHERE id='$userId'")) && (getInfo(chained,users,"WHERE id='$userId'"))) $failure = "With a chain and ball around your ankle, it is too difficult for you to carry someone.";
if ($town) {
if ($destinationTown != $town) $failure = "You are trying to travel to a building which is in a different town. In order to go there, you must use the \"travel\" button located on the page where the different buildings of said town are listed.";
} else {
if ((getInfo(x,transport,"WHERE place='$destinationPlace'") != getInfo(x,transport,"WHERE place='$buildingId'")) || (getInfo(y,transport,"WHERE place='$destinationPlace'") != getInfo(y,transport,"WHERE place='$buildingId'"))) $failure = "You are not in the same area as your destination.";
}
$door_id = getInfo(id,doors,"WHERE (room='$id' and room2='$destination') or ( room='$destination' and room2='$id')");
if (getInfo(id,doors,"WHERE id='$door_id'")) {
$block = getInfo(block,doors,"WHERE id='$door_id'");
}
if (getInfo(id,doors,"WHERE id='$door_id'")) {
$block = getInfo(block2,doors,"WHERE id='$door_id'");
}
if ($block) {
if ((getInfo(room,users,"WHERE id='$block'") != $id) || (getInfo(status,users,"WHERE id='$block'") != "conscious") || ((getInfo(logged,users,"WHERE id='$block'") <= (time() - (3600 * 24 * 7))) && (!getInfo(NPC,users,"WHERE id='$block'")))) {
unset($block);
$door_id = $row['id'];
if (getInfo(room,doors,"WHERE id='$door_id'") == $id) $query = "UPDATE doors SET block='' WHERE id='$door_id'";
if (getInfo(room2,doors,"WHERE id='$door_id'") == $id) $query = "UPDATE doors SET block2='' WHERE id='$door_id'";
mysql_query($query);
}
}
if ($block) $failure = "This doorway is being blocked by ".getInfo(username,users,"WHERE id='$block'").".";
}
if (fnmatch("travel_*",$destination)) {
if (getInfo(id,travel_routes,"WHERE station='$buildingId'")) {
$station = getInfo(station2,travel_routes,"WHERE station='$buildingId'");
$toll = getInfo(toll,travel_routes,"WHERE station='$buildingId'");
}
if (getInfo(id,travel_routes,"WHERE station2='$buildingId'")) {
$station = getInfo(station,travel_routes,"WHERE station2='$buildingId'");
$toll = getInfo(toll2,travel_routes,"WHERE station2='$buildingId'");
}
if (getInfo(personal,users,"WHERE id='$userId'") == "traveler") $toll = round($toll / 2);
if ($user == "all") {
$money = getInfo(money,users,"WHERE id='$userId'");
$owner = getInfo(owner,places,"WHERE id='$buildingId'");
$ownermoney = getInfo(money,users,"WHERE id='$owner'");
$result2 = getRows(users,"WHERE room='$id' and status!='conscious'");
while ($row2 = mysql_fetch_array($result2)) {
$money -= $toll;
$ownermoney += $toll;
}
} else {
$money = getInfo(money,users,"WHERE id='$userId'");
$money -= ($toll * 2);
$ownermoney += ($toll * 2);
}
$stationTown = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(locked,towns,"WHERE id='$stationTown'") == "locked") $failure = "You cannot travel there - the town walls of the town you are in are locked.";
$stationTown = getInfo(town,places,"WHERE id='$station'");
if (getInfo(locked,towns,"WHERE id='$stationTown'") == "locked") $failure = "You cannot travel there - the town walls are locked.";
if ($money < 0) $failure = "You do not have enough money.";
if (!$station) $failure = "This station does not lead to anything.";
}
if (getInfo(place,rooms,"WHERE id='$destination'") != $buildingId) {
$weight = weigh($userId);
$weightMax = maxWeight($userId);
if ($weight > $weightMax) $failure = "You are currently carrying too many things in your inventory. You are carrying $weight kilograms, and may not move with more than $weightMax kilograms.";
}
if (!$failure) {
if ($toll) {
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET money='$ownermoney' WHERE id='$owner'";
mysql_query($query);
}
$moves++;
$query = "UPDATE users SET moves='$moves' WHERE id='$userId'";
mysql_query($query);
if ($user == "all") {
move($userId,$destination);
$result2 = getRows(users,"WHERE room='$id' and status!='conscious'");
while ($row2 = mysql_fetch_array($result2)) {
$user = $row2['id'];
if (!sameUser($user,$userId)) {
move($user,$destination);
}
}
if (fnmatch("travel_*",$destination)) {
$success = "You have successfully travelled down the road.";
if ($post) $post .= "
[Travelled Down the Road]";
else {
if (!getInfo(hidden,rooms,"WHERE id='$destination'")) $post = "[Carried All Unconscious Characters Down the Road]";
$ooc = "ooc";
}
} else if ($destination == "overboard") {
$success = "You have successfully jumped overboard. Good job.";
if ($post) $post .= "
[Jumped overboard]";
else {
if (!getInfo(hidden,rooms,"WHERE id='$destination'")) $post = "[Jumped Overboard With All Unconscious Users]";
$ooc = "ooc";
}
} else {
$success = "You have successfully moved to ".$destinationName." in ".$destinationPlaceName.". You will be forwarded there immediately.";
if ($post) {
if (!getInfo(hidden,rooms,"WHERE id='$destination'")) $post .= "
[Carried All Unconscious Users to ".$destinationName." in ".$destinationPlaceName."]";
}
echo '';
}
} else {
move($userId,$destination);
move($user,$destination);
if (fnmatch("travel_*",$destination)) {
$success = "Travelled Down the Road";
$post .= "
[Carried $username Down the Road]";
} elseif ($destination == "overboard") {
$success = "You have jumped overboard.";
$post .= "
[".$user_name." jumped overboard, along with ".$username."]";
} else {
$success = "You have successfully carried ".$username." to ".$destinationRoomName." in ".$destinationPlaceName.". You will be forwarded there immediately.";
$post .= "
[Carried ".$username." to ".$destinationRoomName." in ".$destinationPlaceName."]";
echo '';
}
}
}
}
if ($command == "throw") {
$user = $_POST['throwUser'];
$destination = $_POST['throwRoom'];
if (sameUser($user,$userId)) $failure = "You may not interfere with your own character if they are in any position of vulnerability, as that would be unfair to the other players.";
$username = getInfo(username,users,"WHERE id='$user'");
if ($user == "all") $username = "all unconscious/immobilized/dead characters";
if (!$user) $failure = "You did not select a user to throw.";
//echo getInfo(id,doors,"WHERE (room='$destination' and room2='$id') or (room='$id' and room2='$destination')");
if (!inArray($destination,destinations($id,$userId))) $failure = "The destination you have selected is not accessible at the current time. Certain doors may be locked, hindering your ability to reach the room. Please consult the list of destinations in move command area while posting to see which buildings/doors are locked.";
if ((getInfo(status,users,"WHERE id='$user'") != "unconscious") && (getInfo(status,users,"WHERE id='$user'") != "dead") && (getInfo(status,users,"WHERE id='$user'") != "immobilized") && ($user != "all")) $failure = $username." is not unconscious or dead or immobilized at the moment.";
if ((getInfo(room,users,"WHERE id='$user'") != $id) && ($user != "all")) $failure = $username." is not in the same room as you.";
if (!$destination) $failure = "You have not selected a room.";
if (($destination != "overboard") && (!fnmatch("travel_*",$destination))) {
if ($destination == $id) $failure = "You are already in that room.";
$destinationPlace = getInfo(place,rooms,"WHERE id='$destination'");
$destinationTown = getInfo(town,places,"WHERE id='$destinationPlace'");
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are unconscious, and therefore cannot move.";
$userRoom = getInfo(room,users,"WHERE id='$userId'");
if (isFighting($userId)) $failure = "You are currently being attacked, and must react to that, before you can throw someone.";
if ($town) {
if ($destinationTown != $town) $failure = "You are trying to throw someone into a building which is in a different town. In order to go there, you must use the \"travel\" button located on the page where the different buildings of said town are listed.";
} else {
if ((getInfo(x,transport,"WHERE place='$destinationPlace'") != getInfo(x,transport,"WHERE place='$buildingId'")) || (getInfo(y,transport,"WHERE place='$destinationPlace'") != getInfo(y,transport,"WHERE place='$buildingId'"))) $failure = "You are not in the same area as your target.";
}
$door_id = getInfo(id,doors,"WHERE (room='$id' and room2='$destination') or ( room='$destination' and room2='$id')");
if (getInfo(id,doors,"WHERE id='$door_id'")) {
$block = getInfo(block,doors,"WHERE id='$door_id'");
}
if (getInfo(id,doors,"WHERE id='$door_id'")) {
$block = getInfo(block2,doors,"WHERE id='$door_id'");
}
if ($block) {
if ((getInfo(room,users,"WHERE id='$block'") != $id) || (getInfo(status,users,"WHERE id='$block'") != "conscious") || ((getInfo(logged,users,"WHERE id='$block'") <= (time() - (3600 * 24 * 7))) && (!getInfo(NPC,users,"WHERE id='$block'")))) {
unset($block);
$door_id = $row['id'];
if (getInfo(room,doors,"WHERE id='$door_id'") == $id) $query = "UPDATE doors SET block='' WHERE id='$door_id'";
if (getInfo(room2,doors,"WHERE id='$door_id'") == $id) $query = "UPDATE doors SET block2='' WHERE id='$door_id'";
mysql_query($query);
}
}
if ($block) $failure = "This doorway is being blocked by ".getInfo(username,users,"WHERE id='$block'").".";
}
if (fnmatch("travel_*",$destination)) {
if (getInfo(id,travel_routes,"WHERE station='$buildingId'")) {
$station = getInfo(station2,travel_routes,"WHERE station='$buildingId'");
$toll = getInfo(toll,travel_routes,"WHERE station='$buildingId'");
}
if (getInfo(id,travel_routes,"WHERE station2='$buildingId'")) {
$station = getInfo(station,travel_routes,"WHERE station2='$buildingId'");
$toll = getInfo(toll2,travel_routes,"WHERE station2='$buildingId'");
}
if (getInfo(personal,users,"WHERE id='$userId'") == "traveler") $toll = round($toll / 2);
$owner = getInfo(owner,places,"WHERE id='$buildingId'");
$ownermoney = getInfo(money,users,"WHERE id='$owner'");
if ($user == "all") {
$money = getInfo(money,users,"WHERE id='$userId'");
$result2 = getRows(users,"WHERE room='$id' and status!='conscious'");
while ($row2 = mysql_fetch_array($result2)) {
$money -= $toll;
$ownermoney += $toll;
}
} else {
$money = getInfo(money,users,"WHERE id='$userId'");
$money -= ($toll * 2);
$ownermoney += ($toll * 2);
}
if ($money < 0) $failure = "You do not have enough money.";
if (!$station) $failure = "This station does not lead to anything.";
}
$moves = getInfo(moves,users,"WHERE id='$userId'");
if (!$failure) {
if ($toll) {
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET money='$ownermoney' WHERE id='$owner'";
mysql_query($query);
}
if ($user == "all") {
$result2 = getRows(users,"WHERE room='$id' and status!='conscious'");
while ($row2 = mysql_fetch_array($result2)) {
$user = $row['id'];
if (!sameUser($user,$userId)) {
move($user,$destination);
}
}
if ($destination == "overboard") {
$post .= "
[".$user_name." threw all unconscious characters down the road]";
} else {
$post .= "
[Threw all unconscious characters to ".$destinationRoomName." in ".$destinationPlaceName."]";
}
} else {
move($user,$destination);
if (fnmatch("travel_*",$destination)) {
$success = "You have thrown $username down the road.";
$post .= "
[".$user_name." threw ".$username." down the road]";
} elseif ($destination == "overboard") {
$success = "You have thrown $user overboard.";
$post .= "
[".$user_name." threw ".$username." overboard]";
} else {
$destinationPlaceName = getInfo(name,places,"WHERE id='$destinationPlace'");
$destinationRoomName = getInfo(name,rooms,"WHERE id='$destination'");
$success = "You have successfully thrown ".$username." to ".$destinationRoomName." in ".$destinationPlaceName.".";
$post .= "
[Threw ".$username." to ".$destinationRoomName." in ".$destinationPlaceName."]";
}
}
}
}
if ($command == "heal") {
$heal = $_POST['healAmount'];
$user = $_POST['healUser'];
$username = getInfo(username,users,"WHERE id='$user'");
if (isFighting($user)) $failure = "That user is fighting.";
if (isFighting($userId)) $failure = "You are fighting.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$health = getInfo(health,users,"WHERE id='$userId'");
$userHealth = getInfo(health,users,"WHERE id='$user'");
$statmax = statmax($user);
if (!$heal) $failure = "You did not state how many health points to heal.";
if (!$user) $failure = "You did not select a user to heal.";
if ($userHealth + $heal > $statmax) $heal = $statmax - $userHealth;
if ((getInfo(civic,users,"WHERE id='$userId'") == "medic") && (employed($userId,"medics"))) {
$heal1 = floor($mana / 2);
if ($heal1 > $heal) $heal1 = $heal;
$heal2 = $heal - $heal1;
$mana -= ($heal1 * 2);
$health -= $heal2;
} else {
$mana -= $heal;
$health -= $heal;
}
$userHealth += $heal;
if ($health < 1) $failure = "You cannot afford to heal this much.";
if ($mana < 0) $failure = "You cannot afford to heal this much.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = $username." is not in the same room as you.";
if ($heal < 0) $failure = "You are trying to heal ".$username." for a negative number of health points.";
if (sameUser($user,$userId)) $failure = "You may not heal your own character.";
if (!$failure) {
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET health='$health' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET health='$userHealth' WHERE id='$user'";
mysql_query($query);
if (getInfo(status,users,"WHERE id='$user'") == "unconscious") {
$query = "UPDATE users SET status='conscious' WHERE id='$user'";
mysql_query($query);
}
$query = "UPDATE users SET vulnerability='0' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET regeneration='' WHERE id='$user'";
mysql_query($query);
if ((getInfo(civic,users,"WHERE id='$userId'") == "medic") && (employed($userId,"medics"))) {
$heal = $heal + getInfo(heal,users,"WHERE id='$userId'");
$query = "UPDATE users SET heal='$heal' WHERE id='$userId'";
mysql_query($query);
$query = "DELETE FROM poison WHERE user='$user'";
mysql_query($query);
}
$success = "You have successfully healed ".$username." for ".$heal." health points.";
$post .= "
[Healed ".$username." for ".$heal." health points]";
}
}
if ($command == "revive") {
if ((getInfo(civic,users,"WHERE id='$userId'") != "medic") || (!employed($userId,"medics"))) $failure = "Only a medic may revive other users.";
$user = $_POST['reviveUser'];
$username = getInfo(username,users,"WHERE id='$user'");
$account_id = getAccount($user);
if (count(explode('.',getInfo(dead,accounts,"WHERE id='$account_id'"))) >= 5) $failure = "That user does not have a free character slot, and therefore, their character cannot be revived.";
$heal = getInfo(heal,users,"WHERE id='$userId'");
if (getInfo(status,users,"WHERE id='$user'") != "dead") $failure = "The user is not dead.";
if (getInfo(time,murders,"WHERE victim='$user' and revived=''") < time()) $failure = "You came too late. In order to revive someone, you must make your attempt no more than 12 hours after they have fallen.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not currently conscious.";
if (getInfo(room,users,"WHERE id='$userId'") != getInfo(room,users,"WHERE id='$user'")) $failure = "You are not in the same room as that user.";
if (getInfo(NPC,users,"WHERE id='$user'")) $failure = "You may not revive a dead NPC.";
if (!$failure) {
$heal = floor($heal / 5) + 50;
if (rand(1,100) <= $heal) {
if (!getInfo(NPC,users,"WHERE id='$user'")) {
$dead = getInfo(dead,accounts,"WHERE id='$account_id'");
$dead = removeElement($user,$dead,'.');
$characters = getInfo(characters,accounts,"WHERE id='$account_id'");
if ($characters) $characters .= '.'.$user;
else $characters = $user;
$query = "UPDATE accounts SET dead='$dead' WHERE id='$account_id'";
mysql_query($query);
$query = "UPDATE accounts SET characters='$characters' WHERE id='$account_id'";
mysql_query($query);
}
$query = "UPDATE users SET status='unconscious' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE murders SET revived='revived' WHERE victim='$user' and revived=''";
mysql_query($query);
$success = "You have successfully saved $username's life.";
$god = "$user_name successfully revived $username, and saved their life.";
} else {
$query = "UPDATE murders SET time='' WHERE victim='$user' and revived=''";
mysql_query($query);
$success = "You have failed to revive $username; may their soul rest in peace.";
$god = "$user_name failed to revive $username; may their soul rest in peace.";
}
}
}
if ($command == "transform") {
$transformation = $_POST['transformation'];
$transformations = getInfo(transformation,users,"WHERE id='$userId'");
if (!inArray($transformation,explode('.',$transformations))) $failure = "You do not have this transformed state.";
if (getInfo(id,spells,"WHERE spell='divineIntervention' and user='$userId'")) $failure = "You may not transform. The spell that was cast on you, divine intervention, has not yet worn off.";
if (getInfo(id,spells,"WHERE spell='demonicPossession' and user='$userId'")) $failure = "You may not transform. The spell that was cast on you, demonic possession, has not yet worn off.";
if (!$failure) {
$query = "UPDATE users SET transformed='' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET transformed='$transformation' WHERE id='$userId'";
mysql_query($query);
$success = "You have transformed.";
}
}
if ($command == "passout") {
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You cannot pass out - you are not conscious.";
if (getInfo(id,spells,"WHERE spell='insomniac' and user='$userId'")) $failure = "You may not go to sleep, because you are still under the affects of the insomniac spell that was cast on you.";
if (!$failure) {
$sleep = time();
$query = "UPDATE users SET sleep='$sleep' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$success = "You have passed out. You are now vulnerable.";
}
}
if ($command == "putoutfire") {
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You must not be unconscious or immobilized.";
if (!getInfo(id,fires,"WHERE room='$id'")) $failure = "There is no fire in this room.";
if (getInfo(permanent,fires,"WHERE room='$id'")) $failure = "The fire in this room is permanent.";
if (!$failure) {
$query = "DELETE FROM fires WHERE room='$id'";
mysql_query($query);
$post .= "
[Put Fire Out]";
}
}
if ($command == "startfire") {
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You must not be unconscious or immobilized.";
if (getInfo(id,fires,"WHERE room='$id'")) $failure = "There is already a fire in this room.";
if (getInfo(id,towns,"WHERE townsqr='$buildingId'")) {
if (numRowsConditions(places,"WHERE town='$town' and abandoned='' and id!='$buildingId' and type!='21' and type!='23'") > 0) $failure = "You must burn down all the buildings in a town before being able to destroy the town square.";
}
if ((getInfo(developed,town,"WHERE id='$town'")) && ((getInfo(type,places,"WHERE id='$buildingId'") == "15") || (getInfo(type,places,"WHERE id='$buildingId'") == "22"))) $failure = "You may not burn down open spaces in undeveloped areas.";
if (!$failure) {
$time = time() + 3600;
$query = "INSERT INTO fires VALUES('','$buildingId','$id','$time','')";
mysql_query($query);
$owner = getInfo(owner,places,"WHERE id='$buildingId'");
if (getInfo(room,users,"WHERE id='$owner'") == $id) {
$expire = time() + (36 * 3600);
$query = "INSERT INTO holds VALUES ('','$userId','$owner','startfire','$expire')";
mysql_query($query);
$success = "You have successfully set fire to this room. However, the owner of the room is currently here. Therefore, you may not post again until after the owner has had the chance to react. (If the owner does not post within two days, you will be allowed to post again)";
} else {
$success = "You have successfully set fire to the room.";
}
$post .= "
[Started a Fire]";
}
}
if ($command == "wear") {
$item = $_POST['wearClothes'];
if (((getInfo(type,user_items,"WHERE id='$item'") == "armour") || (getInfo(type,user_items,"WHERE id='$item'") == "weapon") || (getInfo(type,user_items,"WHERE id='$item'") == "epic")) && (getInfo(portions,user_items,"WHERE id='$item'") <= 0)) $failure = "This item is damaged and may not be worn until it is repaired.";
$clothes = getInfo(overhead,users,"WHERE id='$userId'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$inventoryArray = explode('.',$inventory);
if (getInfo(type,user_items,"WHERE id='$item'") == "weapon") {
$overhead = getInfo(overhead,users,"WHERE id='$userId'");
$underhead = getInfo(clothes,users,"WHERE id='$userId'");
$behind = getInfo(behind,users,"WHERE id='$userId'");
$clothing = $overhead.'.'.$underhead.'.'.$behind;
$clothing = explode('.',$clothing);
$max2 = count($clothing);
for ($ii = 0;$ii < $max;$ii++) {
if (getInfo(type,user_items,"WHERE id='$clothing[$ii]'") == "weapon") {
$failure = "You are already carrying a weapon. You may only carry one at a time.";
break;
}
if (getInfo(type,user_items,"WHERE id='$clothing[$ii]'") == "epic") {
$failure = "You are already wearing an epic item. You may not wear any armour while wearing an epic item.";
}
}
}
if (getInfo(type,user_items,"WHERE id='$item'") == "armour") {
$overhead = getInfo(overhead,users,"WHERE id='$userId'");
$underhead = getInfo(clothes,users,"WHERE id='$userId'");
$behind = getInfo(behind,users,"WHERE id='$userId'");
$clothing = $overhead.'.'.$underhead.'.'.$behind;
$clothing = explode('.',$clothing);
$max2 = count($clothing);
$armour = 0;
for ($ii = 0;$ii < $max;$ii++) {
if (getInfo(type,user_items,"WHERE id='$clothing[$ii]'") == "armour") {
$armour++;
}
if (getInfo(type,user_items,"WHERE id='$clothing[$ii]'") == "epic") {
$failure = "You are already wearing an epic item. You may not wear any armour while wearing an epic item.";
}
}
if ($armour >= 2) $failure = "You may only wear 2 items of armour at once.";
}
if (getInfo(type,user_items,"WHERE id='$item'") == "epic") {
$overhead = getInfo(overhead,users,"WHERE id='$userId'");
$underhead = getInfo(clothes,users,"WHERE id='$userId'");
$behind = getInfo(behind,users,"WHERE id='$userId'");
$clothing = $overhead.'.'.$underhead.'.'.$behind;
$clothing = explode('.',$clothing);
$max2 = count($clothing);
for ($ii = 0;$ii < $max;$ii++) {
if (getInfo(type,user_items,"WHERE id='$clothing[$ii]'") == "weapon") {
$failure = "You may not wear any armour or weapons while wearing an epic item.";
break;
}
if (getInfo(type,user_items,"WHERE id='$clothing[$ii]'") == "armour") {
$failure = "You may not wear any armour or weapons while wearing an epic item.";
}
}
}
if (!$item) $failure = "You did not select an item to wear.";
if (!inArray($item,$inventoryArray)) $failure = "You are not carrying that item.";
if (!$failure) {
if (getInfo(type,user_items,"WHERE id='$item'") == "epic") {
$query = "UPDATE users SET slay='no' WHERE id='$userId'";
mysql_query($query);
}
$inventory = removeElement($item,$inventory,'.');
if ($clothes) $clothes .= '.'.$item;
else $clothes = $item;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET overhead='$clothes' WHERE id='$userId'";
mysql_query($query);
$success = "You have successfully worn the item.";
}
}
if ($command == "removeOver") {
$remove = $_POST['removeOverClothes'];
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$overhead = getInfo(overhead,users,"WHERE id='$userId'");
$overheadArray = explode('.',$overhead);
if (!$remove) $failure = "You did not select an item to remove.";
if (!inArray($remove,$overheadArray)) $failure = "You are not wearing this item.";
if (!$failure) {
$overhead = removeElement($remove,$overhead,".");
if ($inventory) $inventory .= '.'.$remove;
else $inventory = $remove;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET overhead='$overhead' WHERE id='$userId'";
mysql_query($query);
$success = "You have successfully removed the article of clothing.";
}
}
if ($command == "removeUnder") {
$remove = $_POST['removeUnderClothes'];
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$underhead = getInfo(clothes,users,"WHERE id='$userId'");
$underheadArray = explode('.',$underhead);
if (!$remove) $failure = "You did not select an item to remove.";
if (!inArray($remove,$underheadArray)) $failure = "You are not wearing this item.";
if (!$failure) {
$underhead = removeElement($remove,$underhead,".");
if ($inventory) $inventory .= '.'.$remove;
else $inventory = $remove;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET clothes='$underhead' WHERE id='$userId'";
mysql_query($query);
$success = "You have successfully removed the article of clothing.";
}
}
if ($command == "suicide") {
if (numRowsConditions(posts,"WHERE username='$userId' and ooc=''") + numRowsConditions(archives,"WHERE username='$userId' and ooc=''") < 10) $failure = "You must make at least ten posts before committing suicide. Essentially, you must live before you may die.";
if (isFighting($userId)) $failure = "You are currently in a fight.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not currently conscious (or you are tied up).";
$fightingTime = getInfo(travel,users,"WHERE id='$userId'");
if ($fightingTime > time()) $failure = "You must wait 24 hours before committing suicide, after being hit by someone.";
if (getInfo(master,users,"WHERE id='$userId'")) $failure = "Slaves do not have the priviledge to commit suicide. Your life belongs to another, and you may not rob them of their possession.";
if (!$failure) {
if (getInfo(master,users,"WHERE id='$userId'")) $chance = 85;
else $chance = 10;
$query = "UPDATE users SET health='0' WHERE id='$userId''";
mysql_query($query);
if (rand(1,100) > $chance) {
$query = "UPDATE users SET status='dead' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET dismembered='dismembered' WHERE id='$userId'";
mysql_query($query);
$success = "You have successfully killed yourself! Go see a psychiatrist.";
$max = numRows(accounts);
for ($i = 1;$i <= $max;$i++) {
$characters = getInfo(characters,accounts,"WHERE id='$i'");
$characters = explode('.',$characters);
if (inArray($userId,$characters)) {
$characters = implode('.',$characters);
$characters = removeElement($userId,$characters,'.');
$query = "UPDATE accounts SET characters='$characters' WHERE id='$i'";
mysql_query($query);
$active = getInfo(active,accounts,"WHERE id='$i'");
if ($active == $userId) {
$query = "UPDATE accounts SET active='' WHERE id='$i'";
mysql_query($query);
}
$dead = getInfo(dead,accounts,"WHERE id='$i'");
if ($dead) $dead .= '.'.$userId;
else $dead = $userId;
$query = "UPDATE accounts SET dead='$dead' WHERE id='$i'";
mysql_query($query);
break;
}
}
$date = date('g:i A F jS Y');
$time = time() + (3600 * 12);
$query = "INSERT INTO murders VALUES('','$userId','$userId','$date','$id','','$time')";
mysql_query($query);
$post .= "
[Commited suicide]";
$suicide = "success";
} else {
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$wake = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$wake' WHERE id='$userId'";
mysql_query($query);
$success = "You have failed to commit suicide. You are unconscious.";
$post .= "
[Failed to commit suicide]";
$suicide = "fail";
}
}
}
if ($command == "sacrifice") {
$max = numRows(cults);
$cult = '';
for ($i = 1;$i <= $max;$i++) {
$members = getInfo(members,cults,"WHERE id='$i'");
$members = explode('.',$members);
if (inArray($userId,$members)) {
$cult = $i;
break;
}
}
if (!$cult) $failure = "You are not part of a cult.";
else {
$members = getInfo(members,cults,"WHERE id='$cult'");
$members = removeElement($userId,$members,'.');
}
if (getInfo(master,users,"WHERE id='$userId'")) $failure = "Slaves do not have the priviledge to commit suicide. Your life belongs to another, and you may not rob them of their possession.";
if (numRowsConditions(posts,"WHERE username='$userId' and ooc=''") + numRowsConditions(archives,"WHERE username='$userId' and ooc=''") < 30) $failure = "You must make at least thirty posts before committing suicide. Essentially, you must live before you may die.";
if (isFighting($userId)) $failure = "You are currently in a fight.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not currently conscious (or you are tied up).";
$fightingTime = getInfo(travel,users,"WHERE id='$userId'");
if ($fightingTime > time()) $failure = "You must wait 24 hours before committing suicide, after being hit by someone.";
$resurrect = getInfo(resurrect,cults,"WHERE id='$cult'");
$resurrectname = getInfo(username,users,"WHERE id='$resurrect'");
if (!$resurrect) $failure = "The cult to which you belong is not currently resurrecting anyone.";
if (!$failure) {
$query = "UPDATE users SET status='conscious' WHERE id='$resurrect'";
mysql_query($query);
$query = "UPDATE users SET master='' WHERE id='$resurrect'";
mysql_query($query);
$query = "UPDATE users SET password='' WHERE id='$resurrect'";
mysql_query($query);
$query = "UPDATE users SET health='50' WHERE id='$resurrect'";
mysql_query($query);
$query = "UPDATE cults SET resurrect='' WHERE id='$cult'";
mysql_query($query);
$query = "UPDATE cults SET bodyparts='' WHERE id='$cult'";
mysql_query($query);
$query = "UPDATE users SET health='0' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET status='dead' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE cults SET members='$members' WHERE id='$cult'";
mysql_query($query);
$max = numRows(accounts);
for ($i = 1;$i <= $max;$i++) {
$characters = getInfo(characters,accounts,"WHERE id='$i'");
$characters = explode('.',$characters);
if (inArray($userId,$characters)) {
$characters = implode('.',$characters);
$characters = removeElement($userId,$characters,'.');
$query = "UPDATE accounts SET characters='$characters' WHERE id='$i'";
mysql_query($query);
$active = getInfo(active,accounts,"WHERE id='$i'");
if ($active == $userId) {
$query = "UPDATE accounts SET active='' WHERE id='$i'";
mysql_query($query);
}
$dead = getInfo(dead,accounts,"WHERE id='$i'");
if ($dead) $dead .= '.'.$userId;
else $dead = $userId;
$query = "UPDATE accounts SET dead='$dead' WHERE id='$i'";
mysql_query($query);
break;
}
}
$date = date('g:i A F jS Y');
$query = "INSERT INTO murders VALUES('','$userId','$userId','$date','$id')";
mysql_query($query);
$success = "You have killed yourself to resurrect ".$resurrectname.". Now, the owner of ".$resurrectname." must simply reclaim them through the account control panel.";
$post .= "
[Sacrificed Self to Resurrect ".$resurrectname."]";
}
}
if ($command == "archery") {
$room = $_POST['archeryRoom'];
$user = $_POST['room'.$room];
if (!$user) $failure = "You must select a user to target.";
if ($user == $userId) $failure = "You may not shoot yourself.";
$username = getInfo(username,users,"WHERE id='$user'");
$arrow = $_POST['archeryArrow'];
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$inventory = explode('.',$inventory);
$userPlace = getInfo(location,users,"WHERE id='$user'");
$userRoom = getInfo(room,users,"WHERE id='$user'");
$roomname = getInfo(name,rooms,"WHERE id='$userRoom'");
$placename = getInfo(name,places,"WHERE id='$userPlace'");
if (isFighting($userId,"all")) $failure = "You are currently fighting.";
if (isFighting($user,"all")) $failure = "That user is currently fighting.";
if (!inArray($arrow,$inventory)) $failure = "You are not carrying that type of arrow.";
if ((getInfo(town,users,"WHERE id='$userId'") != getInfo(town,users,"WHERE id='$user'")) && ((getInfo(x,transport,"WHERE id='$userPlace'") != getInfo(x,transport,"WHERE id='$buildingId'")) || (getInfo(y,transport,"WHERE id='$userPlace'") != getInfo(y,transport,"WHERE id='$buildingId'")))) $failure = "That user is not in the same town/area as you.";
if (!$failure) {
$arrows = getInfo("portions",user_items,"WHERE id='$arrow'");
$arrows--;
if ($arrows <= 0) {
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$inventory = removeElement($arrow,$inventory,'.');
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
} else {
$query = "UPDATE user_items SET portions='$arrows' WHERE id='$arrow'";
mysql_query($query);
}
$fortification = getInfo(health,places,"WHERE id='$userPlace'");
if ($fortification > 0) {
$success = "You have successfully fired an arrow. However, due to the target building's fortifications, it did not get very far.";
$post .= "
$post";
if ($userRoom != $id) post(1,$archery_post,$userRoom,"ooc");
$post_id = nextId(posts);
if (getInfo(status,users,"WHERE id='$user'") != "conscious") {
$health = getInfo(health,users,"WHERE id='$user'");
$absorb = itemStat($userId,"armour",$damage);
$damage -= $absorb;
if ($damage <= 0) {
$damage = 0;
} else {
if ($poison) {
$poison = explode(':',$poison);
$pdamage = $poison[0];
$pturns = $poison[1];
sendMessage($user_name,"Poison","You have been poisoned. For more information on how to deal with this affliction, please consult The Poison Article in the player's guide.","God");
$query = "INSERT INTO poison VALUES('','$user','$pdamage','$pturns')";
mysql_query($query);
$query = "UPDATE user_items SET poison='' WHERE id='$arrow'";
mysql_query($query);
}
}
$health -= $damage;
if ($health > 0) {
$query = "UPDATE users SET regeneration='0' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET status='conscious' WHERE id='$user'";
mysql_query($query);
}
$query = "UPDATE users SET health='$health' WHERE id='$user'";
mysql_query($query);
} elseif (getInfo(NPC,users,"WHERE id='$user'")) {
$god = counter($user,$roll,$damage,'archery');
if (getInfo(status,users,"WHERE id='$user'") == "conscious") {
if (getInfo(counter,npcs,"WHERE name='$user'") == "run") {
$god .= react($user,$userId);
}
}
} else {
$party = getInfo(party,users,"WHERE id='$user'");
if ($party) {
$result = getRows(users,"WHERE party='$party' and room='$room'");
while ($row = mysql_fetch_array($result)) {
$party_members[] = $row['id'];
}
$party_members = implode('.',$party_members);
} else $party_members = "";
$query = "INSERT INTO fights VALUES('','$userId','$user','$roll','$damage','1','$post_id','','1','arrows','$poison','$party_members','')";
mysql_query($query);
}
$success = "You have fired an arrow at $username.";
$post .= "
[Shot an arrow at $username in $roomname, $placename]";
}
}
}
if ($command == "fire") {
$weapon = $_POST['fireWeapon'];
$ammo = $_POST['fireAmmo'.$weapon];
$target = $_POST['fireTarget'];
if (getInfo(health,places,"WHERE id='$buildingId'") <= 0) $failure = "You may not fire any weapons if the building you are in has no fortification. The building's health and the health of the weapons inside are one and the same.";
$placeTown = getInfo(town,places,"WHERE id='$buildingId'");
$weaponType = getInfo(type,arsenals,"WHERE id='$weapon'");
$ammoType = getInfo(type,ammo,"WHERE id='$ammo'");
$weaponName = getInfo(name,weapons,"WHERE id='$weaponType'");
$targetTown = getInfo(town,places,"WHERE id='$target'");
$targetType = getInfo(type,places,"WHERE id='$target'");
$types = getInfo(attack,weapons,"WHERE id='$weaponType'");
if ($types) {
$types = explode('.',$types);
if (!inArray($targetType,$types)) $failure = "This weapon cannot be used against that kind of building.";
}
if (getInfo(room,arsenals,"WHERE id='$weapon'") != $id) $failure = "This weapon is not stationed in this room.";
if (getInfo(cooldown,arsenals,"WHERE id='$weapon'") > time()) $failure = "You must wait one hour before firing this weapon again.";
if ((getInfo(amount,ammo,"WHERE id='$ammo' AND place='$buildingId'") <= 0) && (!getInfo(damage,weapons,"WHERE id='$weaponType'"))) $failure = "There is none of this type of ammunition left.";
if ($targetTown) {
$tx = getInfo(tx,towns,"WHERE id='$targetTown'");
$ty = getInfo(ty,towns,"WHERE id='$targetTown'");
} else {
$tx = getInfo(x,transport,"WHERE place='$target'");
$ty = getInfo(y,transport,"WHERE place='$target'");
}
if ($placeTown) {
$x = getInfo(tx,towns,"WHERE id='$placeTown'");
$y = getInfo(ty,towns,"WHERE id='$placeTown'");
} else {
$x = getInfo(x,transport,"WHERE place='$buildingId'");
$y = getInfo(y,transport,"WHERE place='$buildingId'");
}
if ($placeTown) {
if (getInfo(walls,towns,"WHERE id='$placeTown'") == $buildingId) {
if (($x != $tx) || ($y != $ty)) $failure = "You are trying to fire at a building that is out of range.";
} else {
if ($targetTown != $placeTown) $failure = "You are trying to fire at a building which is in a different town.";
}
} else {
if (getInfo(walls,towns,"WHERE id='$targetTown'") == $target) {
if (($x != $tx) || ($y != $ty)) $failure = "You are trying to fire at a building that is out of range.";
} else {
if (($x != $tx) || ($y != $ty) || ($targetTown)) $failure = "You are not in the same area as your target.";
}
}
if (!$target) $failure = "You have not selected a target.";
if ((!$ammo) && (!getInfo(damage,weapons,"WHERE id='$weaponType'"))) $failure = "You have not selected any ammunition to fire.";
if (!$weapon) $failure = "You have not selected a weapon to fire.";
if (!$failure) {
if (!getInfo(damage,weapons,"WHERE id='$weaponType'")) {
$currentAmmo = getInfo(amount,ammo,"WHERE id='$ammo' AND place='$buildingId'");
$currentAmmo--;
$query = "UPDATE ammo SET amount='$currentAmmo' WHERE id='$ammo' AND place='$buildingId'";
mysql_query($query);
}
$time = time() + 3600;
$query = "UPDATE arsenals SET cooldown='$time' WHERE id='$weapon'";
mysql_query($query);
if (rand(1,100) <= 5) {
$god = $user_name." attempted to use a ".$weaponName.", and misfired.";
$peopleDamage = getInfo(people,ammunition,"WHERE id='$ammoType'");
if (!getInfo(damage,weapons,"WHERE id='$weaponType'")) {
$placeDamage = getInfo(buildings,ammunition,"WHERE id='$ammoType'");
} else {
$placeDamage = getInfo(damage,weapons,"WHERE id='$weaponType'");
}
$peopleDamage = round(0.75 * $peopleDamage);
$placeDamage = round(0.75 * $placeDamage);
$placeHealth = getInfo(health,places,"WHERE id='$buildingId'");
$placeHealth -= $placeDamage;
$god .= ' The building was hit for '.$placeDamage.' damage.';
if ($placeHealth <= 0) {
$placeHealth = 0;
$query = "UPDATE places SET locked='' WHERE id='$buildingId'";
mysql_query($query);
$god .= ' All of its fortification has been depleted.';
$query = "UPDATE towns SET locked='' WHERE walls='$buildingId'";
mysql_query($query);
}
$query = "UPDATE places SET health='$placeHealth' WHERE id='$buildingId'";
mysql_query($query);
$damageAbsorb = itemStat($userId,"armour",$peopleDamage);
if ($damage - $damageAbsorb < 0) {
$damageAbsorb = $damageAbsorb - $peopleDamage;
$peopleDamage = 0;
} else $peopleDamage -= $damageAbsorb;
if ($damageAbsorb < 0) $damageAbsorb = 0;
$userHealth = getInfo(health,users,"WHERE id='$userId'");
$userHealth -= $peopleDamage;
$god .= ' '.$user_name.' was hit for '.$peopleDamage.' damage.';
if ($damageAbsorb) $god .= " [".$damageAbsorb." damage absorbed by armour]";
if ($userHealth <= 0) {
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$wake = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$wake' WHERE id='$userId'";
mysql_query($query);
$sleep = time();
$query = "UPDATE users SET sleep='$sleep' WHERE id='$userId'";
mysql_query($query);
$god .= ' '.$user_name.' is now unconscious.';
}
$query = "UPDATE users SET health='$userHealth' WHERE id='$userId'";
mysql_query($query);
$query = "DELETE FROM place_travels WHERE place='$buildingId'";
mysql_query($query);
} else {
$buildingChance = getInfo(buildings,weapons,"WHERE id='$weaponType'");
if (rand(1,100) - 10 > $buildingChance) {
$success = "Your shot missed completely.";
$god = $user_name." attempted to fire a ".$weaponName." and missed entirely.";
$query = "DELETE FROM place_travels WHERE place='$buildingId'";
mysql_query($query);
} else {
if (rand(1,100) <= 3) {
$query = "DELETE FROM place_travels WHERE place='$buildingId'";
mysql_query($query);
if ($placeTown) {
$result = getRows(places,"WHERE town='$placeTown' and abandoned='' and id!='$buildingId' and id!='$target'");
while ($row = mysql_fetch_array($result)) {
if (($row['id'] != $buildingId) && ($row['id'] != $target)) $places[] = $row['id'];
}
} else {
$x = getInfo(x,transport,"WHERE place='$buildingId'");
$y = getInfo(y,transport,"WHERE place='$buildingId'");
$result = getRows(transport,"WHERE x='$x' and y='$y' and place!='$buildingId' and place!='$target'");
while ($row = mysql_fetch_array($result)) {
if (!getInfo(abandoned,places,"WHERE id='".$row['place']."'")) $places[] = $row['place'];
}
}
$newTarget = $places[rand(0,count($places) - 1)];
if (!$newTarget) {
$currentAmmo = getInfo(amount,ammo,"WHERE type='$ammo' AND place='$buildingId'");
$currentAmmo--;
$query = "UPDATE ammo SET amount='$currentAmmo' WHERE type='$ammo' AND place='$buildingId'";
mysql_query($query);
$success = "Your shot completely missed.";
$god = $user_name." attempted to fire a ".$weaponName." and missed entirely.";
} else {
$target = $newTarget;
$query = "DELETE FROM place_travels WHERE place='$target'";
mysql_query($query);
$placeHealth = getInfo(health,places,"WHERE id='$target'");
$targetName = getInfo(name,places,"WHERE id='$target'");
$god = $user_name." attempted to fire a ".$weaponName.", and missed. Instead, they hit ".$targetName.".";
if ($placeHealth > 0) {
if (!getInfo(damage,weapons,"WHERE id='$weaponType'")) {
$damage = getInfo(buildings,ammunition,"WHERE id='$ammoType'");
} else {
$damage = getInfo(damage,weapons,"WHERE id='$weaponType'");
}
$damage = rand(1,$damage);
$placeHealth -= $damage;
$god .= ' The building was hit for '.$damage.' damage.';
if ($placeHealth <= 0) {
$placeHealth = 0;
$query = "UPDATE places SET locked='' WHERE id='$target'";
mysql_query($query);
$god .= ' All of its fortification has been depleted.';
$query = "UPDATE towns SET locked='' WHERE walls='$target'";
mysql_query($query);
}
$query = "UPDATE places SET health='$placeHealth' WHERE id='$target'";
mysql_query($query);
$recoil = rand(0,round($damage * getInfo(recoil,weapons,"WHERE id='$weaponType'")));
if ($recoil) {
$placeHealth = getInfo(health,places,"WHERE id='$buildingId'");
$placeHealth -= $recoil;
$buildingName = getInfo(name,places,"WHERE id='$buildingId'");
$god .= " $buildingName was hit for $recoil damage from the recoil.";
if ($placeHealth <= 0) {
$placeHealth = 0;
$query = "UPDATE places SET locked='' WHERE id='$buildingId'";
mysql_query($query);
$god .= " All of its fortification has been depleted.";
}
$query = "UPDATE places SET health='$placeHealth' WHERE id='$buildingId'";
mysql_query($query);
}
$success = "You fired and hit the target.";
} else {
$god = $user_name." attempted to fire a ".$weaponName.", and missed, hitting ".$targetName." instead.";
$peopleChance = getInfo(people,weapons,"WHERE id='$weaponType'");
$peopleDamage = getInfo(people,ammunition,"WHERE id='$ammoType'");
$fireChance = getInfo(fire,ammunition,"WHERE id='$ammoType'");
$result = getRows(rooms,"WHERE place='$target'");
while ($row = mysql_fetch_array($result)) {
$rooms[] = $row['id'];
}
$targetRoom = $rooms[rand(0,count($rooms) - 1)];
if ((rand(1,100) <= $fireChance) && (!getInfo(id,fires,"WHERE room='$targetRoom'")) && (!getInfo(id,towns,"WHERE townsqr='$target'"))) {
$time = time() + 3600;
$query = "INSERT INTO fires VALUES('','$target','$targetRoom','$time','')";
mysql_query($query);
$god .= " The room was set on fire.";
}
if (rand(1,100) <= $peopleChance) {
$time = time() - (7 * 24 * 3600);
$result = getRows(users,"WHERE room='$targetRoom' and logged>='$time' and status!='dead'");
while ($row = mysql_fetch_array($result)) {
$users[] = $row['id'];
}
$people_hit = getInfo(people_wound,ammunition,"WHERE id='$ammoType'");
if ($people_hit <= 0) $god .= " No one was harmed.";
if ($people_hit > count($users)) $people_hit = count($users);
for ($i = 1;$i <= $people_hit;$i++) {
do {
$targetUser = $users[rand(0,count($users) - 1)];
} while (inArray($targetUser,$targetUsers));
$targetUsers[] = $targetUser;
}
$max = count($targetUsers);
for ($i = 0;$i < $max;$i++) {
$targetUser = $targetUsers[$i];
$targetUsername = getInfo(username,users,"WHERE id='$targetUser'");
$damage = rand(1,$peopleDamage);
$damageAbsorb = itemStat($targetUser,"armour",$damage);
if ($damage - $damageAbsorb < 0) {
$damageAbsorb = $damageAbsorb - $damage;
$damage = 0;
} else $damage -= $damageAbsorb;
$god .= " ".$targetUsername;
$health = getInfo(health,users,"WHERE id='$targetUser'");
if ($health > 0) {
$health -= $damage;
if ($health <= 0) {
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$targetUser'";
mysql_query($query);
$wake = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$wake' WHERE id='$targetUser'";
mysql_query($query);
$time = time();
$query = "UPDATE users SET sleep='$time' WHERE id='$targetUser'";
mysql_query($query);
$god .= ", who is now unconscious,";
}
$query = "UPDATE users SET health='$health' WHERE id='$targetUser'";
mysql_query($query);
$god .= " was hit for ".$damage." damage.";
if ($damageAbsorb) $god .= " [".$damageAbsorb." damage absorbed by armour]";
}
}
} else {
$god .= " No one was harmed.";
}
$result = getRows(rooms,"WHERE place='$target'");
while ($row = mysql_fetch_array($result)) {
if ($row['id'] == $targetRoom) post(1,$god,$row['id'],"ooc");
else post(1,"This building is under fire.",$row['id'],"ooc");
}
$result = getRows(users,"WHERE NPC!='' and location='$target'");
while ($row = mysql_fetch_array($result)) {
$npc2 = $row['id'];
if ((!getInfo(target,npc_siege,"WHERE npc='$npc2'")) && (getInfo(npc,npc_siege,"WHERE npc='$npc2'"))) {
$query = "UPDATE npc_siege SET target='$buildingId' WHERE npc='$npc2'";
mysql_query($query);
}
if ((!getInfo(target,npc_arrow,"WHERE npc='$npc2'")) && (getInfo(npc,npc_arrow,"WHERE npc='$npc2'"))) {
$query = "UPDATE npc_arrow SET target='$npcroom' WHERE npc='$npc2'";
mysql_query($query);
}
}
}
}
} else {
$placeHealth = getInfo(health,places,"WHERE id='$target'");
$targetName = getInfo(name,places,"WHERE id='$target'");
$god = $user_name." attempted to fire a ".$weaponName.", and hit ".$targetName.".";
$query = "DELETE FROM place_travels WHERE place='$buildingId'";
mysql_query($query);
$query = "DELETE FROM place_travels WHERE place='$target'";
mysql_query($query);
if ($placeHealth > 0) {
if (!getInfo(damage,weapons,"WHERE id='$weaponType'")) {
$damage = getInfo(buildings,ammunition,"WHERE id='$ammoType'");
} else {
$damage = getInfo(damage,weapons,"WHERE id='$weaponType'");
}
$damage = rand(1,$damage);
$placeHealth -= $damage;
$god .= ' The building was hit for '.$damage.' damage.';
if ($placeHealth <= 0) {
$query = "UPDATE places SET locked='' WHERE id='$target'";
mysql_query($query);
$god .= ' All of its fortification has been depleted.';
$placeHealth = 0;
$query = "UPDATE towns SET locked='' WHERE walls='$target'";
mysql_query($query);
}
$query = "UPDATE places SET health='$placeHealth' WHERE id='$target'";
mysql_query($query);
$recoil = rand(0,round($damage * getInfo(recoil,weapons,"WHERE id='$weaponType'")));
if ($recoil) {
$placeHealth = getInfo(health,places,"WHERE id='$buildingId'");
$placeHealth -= $recoil;
$buildingName = getInfo(name,places,"WHERE id='$buildingId'");
$god .= " $buildingName was hit for $recoil damage from the recoil.";
if ($placeHealth <= 0) {
$placeHealth = 0;
$query = "UPDATE places SET locked='' WHERE id='$buildingId'";
mysql_query($query);
$god .= " All of its fortification has been depleted.";
}
$query = "UPDATE places SET health='$placeHealth' WHERE id='$buildingId'";
mysql_query($query);
}
$success = "You fired and hit the target.";
$result = getRows(rooms,"WHERE place='$target'");
while ($row = mysql_fetch_array($result)) {
if ($row['id'] == $targetRoom) post(1,$god,$row['id'],"ooc");
else post(1,"This building is under fire.",$row['id'],"ooc");
}
$result = getRows(users,"WHERE NPC!='' and location='$target'");
while ($row = mysql_fetch_array($result)) {
$npc2 = $row['id'];
if ((!getInfo(target,npc_siege,"WHERE npc='$npc2'")) && (getInfo(npc,npc_siege,"WHERE npc='$npc2'"))) {
$query = "UPDATE npc_siege SET target='$buildingId' WHERE npc='$npc2'";
mysql_query($query);
}
if ((!getInfo(target,npc_arrow,"WHERE npc='$npc2'")) && (getInfo(npc,npc_arrow,"WHERE npc='$npc2'"))) {
$query = "UPDATE npc_arrow SET target='$npcroom' WHERE npc='$npc2'";
mysql_query($query);
}
}
} else {
$god = $user_name." attempted to fire a ".$weaponName.", and hit ".$targetName.".";
$peopleChance = getInfo(people,weapons,"WHERE id='$weaponType'");
$peopleDamage = getInfo(people,ammunition,"WHERE id='$ammoType'");
$fireChance = getInfo(fire,ammunition,"WHERE id='$ammoType'");
$result = getRows(rooms,"WHERE place='$target'");
while ($row = mysql_fetch_array($result)) {
$rooms[] = $row['id'];
}
$targetRoom = $rooms[rand(0,count($rooms) - 1)];
if ((rand(1,100) <= $fireChance) && (!getInfo(id,fires,"WHERE room='$targetRoom'")) && (!getInfo(id,towns,"WHERE townsqr='$target'"))) {
$time = time() + 3600;
$query = "INSERT INTO fires VALUES('','$target','$targetRoom','$time','')";
mysql_query($query);
$god .= " The room was set on fire.";
}
if (rand(1,100) <= $peopleChance) {
$time = time() - (7 * 24 * 3600);
$result = getRows(users,"WHERE room='$targetRoom' and (logged>='$time' or NPC!='') and status!='dead'");
while ($row = mysql_fetch_array($result)) {
$users[] = $row['id'];
}
$people_hit = getInfo(people_wound,ammunition,"WHERE id='$ammoType'");
if ($people_hit > count($users)) $people_hit = count($users);
if ($people_hit <= 0) $god .= " No one was harmed.";
for ($i = 1;$i <= $people_hit;$i++) {
do {
$targetUser = $users[rand(0,count($users) - 1)];
} while (inArray($targetUser,$targetUsers));
$targetUsers[] = $targetUser;
}
$max = count($targetUsers);
for ($i = 0;$i < $max;$i++) {
$targetUser = $targetUsers[$i];
$targetUsername = getInfo(username,users,"WHERE id='$targetUser'");
$damage = rand(1,$peopleDamage);
$damageAbsorb = itemStat($targetUser,"armour",$damage);
if ($damage - $damageAbsorb < 0) {
$damageAbsorb = $damageAbsorb - $damage;
$damage = 0;
} else $damage -= $damageAbsorb;
$god .= " ".$targetUsername;
$health = getInfo(health,users,"WHERE id='$targetUser'");
if ($health > 0) {
$health -= $damage;
if ($health <= 0) {
if ((isFighting($user)) || (isTied($user))) {
$health = 1;
} else {
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$targetUser'";
mysql_query($query);
$wake = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$wake' WHERE id='$targetUser'";
mysql_query($query);
$time = time();
$query = "UPDATE users SET sleep='$time' WHERE id='$targetUser'";
mysql_query($query);
$god .= ", who is now unconscious,";
}
}
$query = "UPDATE users SET health='$health' WHERE id='$targetUser'";
mysql_query($query);
$god .= " was hit for ".$damage." damage.";
if ($damageAbsorb) $god .= " [".$damageAbsorb." damage absorbed by armour]";
}
}
} else {
$god .= " No one was harmed.";
}
$result = getRows(rooms,"WHERE place='$target'");
while ($row = mysql_fetch_array($result)) {
if ($row['id'] == $targetRoom) post(1,$god,$row['id'],"ooc");
else post(1,"This building is under fire.",$row['id'],"ooc");
}
$result = getRows(users,"WHERE NPC!='' and location='$target'");
while ($row = mysql_fetch_array($result)) {
$npc2 = $row['id'];
if ((!getInfo(target,npc_siege,"WHERE npc='$npc2'")) && (getInfo(npc,npc_siege,"WHERE npc='$npc2'"))) {
$query = "UPDATE npc_siege SET target='$buildingId' WHERE npc='$npc2'";
mysql_query($query);
}
if ((!getInfo(target,npc_arrow,"WHERE npc='$npc2'")) && (getInfo(npc,npc_arrow,"WHERE npc='$npc2'"))) {
$query = "UPDATE npc_arrow SET target='$npcroom' WHERE npc='$npc2'";
mysql_query($query);
}
}
}
}
}
}
}
if (!$success) $success = $god;
}
if ($command == "beat") {
$user = $_POST['beatUser'];
$username = getInfo(username,users,"WHERE id='$user'");
$intensity = $_POST['beatIntensity'];
if (sameUser($user,$userId)) $failure = "You may not beat your own character.";
if (getInfo(room,users,"WHERE id='$userId'") != getInfo(room,users,"WHERE id='$user'")) $failure = "You are not in the same room as the user you are trying to beat.";
if ((getInfo(status,users,"WHERE id='$user'") != "unconscious") && (getInfo(status,users,"WHERE id='$user'") != "immobilized")) $failure = "The user is not tied up or unconscious.";
if (isTied($user)) $failure = "The user you are trying to beat is currently being tied up.";
if (isTied($userId)) $failure = "You are currently being tied up.";
if (isFighting($user)) $failure = "The user you are trying to beat is fighting.";
if (isFighting($userId)) $failure = "You are currently fighting.";
if (!$intensity) $failure = "You must select an intensity.";
if (!$user) $failure = "You must select a user to beat.";
if (!$failure) {
switch ($intensity) {
case 1:
$damage = rand(1,15);
break;
case 2:
$damage = rand(16,40);
break;
case 3:
$damage = rand(41,75);
break;
}
$result = getRows(users,"WHERE room='$id' and NPC!='' and status='conscious'");
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if ((getInfo(mode,npcs,"WHERE name='$npc'") == "protect") && (getInfo("var",npcs,"WHERE name='$npc'") == $user)) $npcs[] = $npc;
}
$npc = $npcs[rand(0,count($npcs) - 1)];
if ($npc) {
$npcname = getInfo(username,users,"WHERE id='$npc'");
$health = getInfo(health,users,"WHERE id='$npc'");
$health -= round($damage / 2);
if ($health <= 0) {
$health = 0;
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$npc'";
mysql_query($query);
}
if (getInfo(status,users,"WHERE id='$user'") == "unconscious") {
$query = "UPDATE users SET status='conscious' WHERE id='$user'";
mysql_query($query);
$query = "UPDATe users SET regeneration='' WHERE id='$user'";
mysql_query($query);
}
$query = "UPDATE users SET health='$health' WHERE id='$npc'";
mysql_query($query);
$success = "You have attempted to beat ".$username.", but ".$npcname." jumped in the way and took the blow.";
$post .= "
[Tried to Beat ".$username.", but ".$npcname." took the blow. ".round($damage / 2)." damage was dealt]";
} else {
$health = getInfo(health,users,"WHERE id='$user'");
$health -= $damage;
if ($health <= 0) {
$health = 0;
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$user'";
mysql_query($query);
} else {
if (getInfo(status,users,"WHERE id='$user'") == "unconscious") {
$query = "UPDATE users SET status='conscious' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET regeneration='' WHERE id='$user'";
mysql_query($query);
}
}
$query = "UPDATE users SET health='$health' WHERE id='$user'";
mysql_query($query);
$success = "You have beaten ".$username.".";
$post .= "
[Beat ".$username." for ".$damage." damage]";
}
}
}
if ($command == "lull") {
if (getInfo(delay,users,"WHERE id='$userId'") > time()) $failure = "You may not attempt to lull anyone so soon. There is a 24 hour delay from the time you last did so.";
if (getInfo(personal,users,"WHERE id='$userId'") != "bard") $failure = "Only bards may use this command.";
if (!$failure) {
$god = "$user_name started to play a soft tune upon an instrument, or started to sing in a melodious voice.";
$time = time() - (3600 * 24 * 7);
$lulltime = time();
$delay = time() + (24 * 3600);
$result = getRows(users,"WHERE room='$id' and (logged>='$time' or NPC!='') and id!='$userId' and lull<='$lulltime'");
while ($row = mysql_fetch_array($result)) {
$fatigue = $row['fatigue'];
$mana = $row['mana'];
$user = $row['username'];
$user_id = $row['id'];
$rand = rand(1,50);
if ($fatigue < $rand) $rand = $fatigue;
$fatigue -= $rand;
$mana += $rand;
if ($mana > 100) $mana = 100;
$query = "UPDATE users SET fatigue='$fatigue', mana='$mana' WHERE id='$user_id'";
mysql_query($query);
$query = "UPDATE users SET lull='$delay' WHERE id='$user_id'";
mysql_query($query);
$god .= " $user lost $rand fatigue points.";
}
$delay = time() + (2 * 3600);
$query = "UPDATE users SET delay='$delay' WHERE id='$userId'";
mysql_query($query);
$success = "You have attempted to lull the other users in the room with music.";
$post .= "
[Attempted to lull the other users in the room with music]";
}
}
if ($command == "distract") {
if (getInfo(delay,users,"WHERE id='$userId'") > time()) $failure = "You may not attempt to distract anyone so soon. There is a 12 hour delay from the time you last did so.";
if (getInfo(personal,users,"WHERE id='$userId'") != "jester") $failure = "Only jesters may use this command.";
$user = $_POST['distractUser'];
if (getInfo(distract,users,"WHERE id='$user'") > time()) $failure = "Each person may only be distracted once every day. The effects of the last time the person was distracted have yet to wear off.";
$username = getInfo(username,users,"WHERE id='$user'");
if (!$user) $failure = "You must select a user.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in the same room as you.";
if (!$failure) {
$vulnerability = getInfo(vulnerability,users,"WHERE id='$user'");
$rand = rand(1,50);
$vulnerability += $rand;
$query = "UPDATE users SET vulnerability='$vulnerability' WHERE id='$user'";
mysql_query($query);
$vulnerability = getInfo(vulnerability,users,"WHERE id='$userId'");
$vulnerability += round($rand / 2);
$query = "UPDATE users SET vulnerability='$vulnerability' WHERE id='$userId'";
mysql_query($query);
$delay = time() + (24 * 3600);
$query = "UPDATE users SET delay='$delay' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET distract='$delay' WHERE id='$user'";
mysql_query($query);
if (getInfo(NPC,users,"WHERE id='$user'")) {
$newtime = time() + (60 * 20);
$query = "UPDATE npcs SET attack='$newtime' WHERE name='$npc'";
mysql_query($query);
}
$god = "$user_name attempted to distract $username. $username's defending roll dropped $rand points.";
$success = "You have attempted to distract $username.";
$post .= "
[Attempted to distract $username]";
}
}
if ($command == "throwWeapon") {
$weapon = $_POST['throwWeaponWeapon'];
$user = $_POST['throwWeaponUser'];
if (getInfo(NPC,users,"WHERE id='$user'")) $failure = "You may not throw a weapon at an NPC. Please attack them, and they will respond instantaneously.";
$username = getInfo(username,users,"WHERE id='$user'");
$behind = getInfo(behind,users,"WHERE id='$userId'");
$underhead = getInfo(clothes,users,"WHERE id='$userId'");
$overhead = getInfo(overhead,users,"WHERE id='$userId'");
$inventory = getInfo(behind,users,"WHERE id='$userId'").'.'.getInfo(underhead,users,"WHERE id='$userId'").'.'.getInfo(overhead,users,"WHERE id='$userId'");
$inventory = explode('.',$inventory);
if (!inArray($weapon,$inventory)) $failure = "You have not yet equipped this item.";
if (getInfo(type,user_items,"WHERE id='$weapon'") != "weapon") $failure = "The item you selected is not a weapon.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in the room.";
if (getInfo(status,users,"WHERE id='$user'") != "conscious") $failure = "That user is not conscious.";
if (getInfo(id,pickups,"WHERE thrower='$userId'")) $failure = "You may not throw another item until the person you threw the last item at posts.";
if (!$failure) {
$broken = false;
$stat = getInfo("stat",user_items,"WHERE id='$weapon'");
$health = getInfo(portions,user_items,"WHERE id='$weapon'");
if (rand(1,100) <= 75) {
$query = "UPDATE user_items SET portions='0' WHERE id='$weapon'";
mysql_query($query);
$broken = true;
} else {
$health = floor($health * 0.75);
$query = "UPDATE user_items SET portions='$health' WHERE id='$weapon'";
mysql_query($query);
}
$intox = getInfo(dex,users,"WHERE id='$userId'");
$userIntox = getInfo(dex,users,"WHERE id='$user'");
if (diceRoll($userId,sides($userId),$intox,0,3,100,1) > diceRoll($user,sides($user),$userIntox,0,3,100,1)) {
$damage = $stat * 2;
$absorb = itemStat($user,"armour",$damage);
$damage -= $absorb;
if ($damage <= 0) $damage = 0;
else {
$poison = explode(':',getInfo(poison,user_items,"WHERE id='$weapon'"));
$pdamage = $poison[0];
$pturns = $poison[1];
if ($pdamage > 0) {
sendMessage($username,"Poison","You have been poisoned. For more information on how to deal with this affliction, please consult The Poison Article in the player's guide.","God");
$query = "INSERT INTO poison VALUES('','$user','$pdamage','$pturns')";
mysql_query($query);
}
}
$userHealth = getInfo(health,users,"WHERE id='$user'");
$userHealth -= $damage;
if ($userHealth <= 0) {
$userHealth = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$user'";
mysql_query($query);
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$user'";
mysql_query($query);
$sleep = time();
$query = "UPDATE users SET sleep='$sleep' WHERE id='$user'";
mysql_query($query);
$result = getRows(rooms,"WHERE guardout='$userId' or guardin='$user'");
while ($row = mysql_fetch_array($result)) {
$guardin = $row['guardin'];
$guardout = $row['guardout'];
$i = $row['id'];
if ($guardin == $userId) {
$query = "UPDATE rooms SET guardin='' WHERE id='$i'";
mysql_query($query);
}
if ($guardout == $userId) {
$query = "UPDATE rooms SET guardout='' WHERE id='$i'";
mysql_query($query);
}
}
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(guard,users,"WHERE id='$user'") == $town) {
if (!cityGuards($town)) {
$query = "UPDATE towns SET leader='$user' WHERE id='$town'";
mysql_query($query);
$leader = getInfo(leader,towns,"WHERE id='$town'");
$leadername = getInfo(username,users,"WHERE id='$leader'");
sendMessage($leadername,"Your Town","Your town has been taken over by ".$user_name.", by knocking out your last present guard.","God");
sendMessage($user_name,"Conquering","You have conquered ".getInfo(name,towns,"WHERE id='$town'").".","God");
}
}
}
$query = "UPDATE users SET health='$userHealth' WHERE id='$user'";
mysql_query($query);
$god = "$user_name attempted ot throw a weapon at $username and hit them for $damage damage";
if ($absorb) $god .= " [$absorb damage absorbed by armour]";
if ($broken) $god .= " The weapon broke.";
if (getInfo(id,users,"WHERE mount='$user'")) {
$mountuser = getInfo(id,users,"WHERE mount='$user'");
$mountusername = getInfo(username,users,"WHERE id='$mountuser'");
if ($userHealth <= 0) {
$mountdamage = rand(40,60);
$absorb = itemStat($userId,"armour",$damage);
$mountdamage -= $absorb;
$god .= " $mountusername fell to the ground, losing $mountdamage health ($absorb damage absorbed by armour).";
if (damage($mountuser,$mountdamage) == "unconscious") $god .= " $mountusername is now unconscious.";
} else {
if (rand(1,$damage) > getInfo(pain,mounts,"WHERE npc='$user'")) {
$roll = rand(1,$damage) + 50;
$query = "INSERT INTO mount_throw VALUES('','$mountuser','$user','$roll')";
mysql_query($query);
$god .= " $npcname panicked and attempted to throw $mountusername from its back.";
}
}
}
} else {
$god = "$user_name attempted to throw a weapon at $username but missed.";
}
if (inArray($weapon,explode('.',$behind))) {
$behind = removeElement($weapon,$behind,'.');
$query = "UPDATE users SET behind='$behind' WHERE id='$userId'";
mysql_query($query);
}
if (inArray($weapon,explode('.',$underhead))) {
$underhead = removeElement($weapon,$underhead,'.');
$query = "UPDATE users SET clothes='$underhead' WHERE id='$userId'";
mysql_query($query);
}
if (inArray($weapon,explode('.',$overhead))) {
$overhead = removeElement($weapon,$overhead,'.');
$query = "UPDATE users SET overhead='$overhead' WHERE id='$userId'";
mysql_query($query);
}
$roomInventory = getInfo(inventory,rooms,"WHERE id='$id'");
if ($roomInventory) $roomInventory .= '.'.$weapon;
else $roomInventory = $weapon;
$query = "UPDATE rooms SET inventory='$roomInventory' WHERE id='$id'";
mysql_query($query);
$query = "INSERT INTO pickups VALUES('','$weapon','$userId','$user')";
mysql_query($query);
}
}
if ($command == "attack") {
$user = $_POST['attackUser'];
$username = getInfo(username,users,"WHERE id='$user'");
$destination = $_POST['attackDestination'];
$destinationPlace = getInfo(place,rooms,"WHERE id='$destination'");
if ((!inArray($destination,destinations($id,0,true,$user))) && ($destination) && ((!getInfo(id,places,"WHERE entrance='$id'")) || (!getInfo(id,towns,"WHERE townsqr='$destinationPlace'")))) $failure = "The destination you have selected is not accessible at the current time. Certain doors may be locked, hindering your ability to reach the room. Please consult the list of destinations in move command area while posting to see which buildings/doors are locked.";
$destinationTown = getInfo(town,places,"WHERE id='$destinationPlace'");
if (sameDistrict($place,$buildingId)) $failure = "You cannot reach that door from here.";
if (!$user) $failure = "You must select a user to attack.";
if (getInfo(id,users,"WHERE user='$userId' or mount='$user'")) $failure = "That user is currently busy with mount-related issues.";
if (sameUser($user,$userId)) $failure = "You may not attack one of your own characters.";
$type = $_POST['attackType'];
if (!$type) $failure = "You have not selected a type of attack.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
if ((getInfo("class",users,"WHERE id='$userId'") == "mage") || (getInfo("class",users,"WHERE id='$userId'") == "sorcerer")) {
if ($type == "melee") $failure = "Sorcerers and mages may not use melee attacks.";
$discount = 25;
}
else $discount = 0;
if ($type == "magic") {
$mana -= round((30 - $discount) * $_POST['attackattacks']);
if ($mana < 0) $failure = "You do not have enough mana.";
}
if (getInfo(room,users,"WHERE id='$userId'") != getInfo(room,users,"WHERE id='$user'")) $failure = "That user is not in the same room as you.";
if ((getInfo(offense,fights,"WHERE offense='$user'")) || (getInfo(defense,fights,"WHERE defense='$user'"))) $failure = $username." is already fighting.";
if ((getInfo(offense,fights,"WHERE offense='$userId'")) || (getInfo(defense,fights,"WHERE defense='$userId'"))) $failure = "You are already fighting.";
if (isTied($user)) $failure = "The user is currently being immobilized.";
if (isTied($userId)) $failure = "You are currently being immobilized.";
if (getInfo(status,users,"WHERE id='$user'") != "conscious") $failure = "The user is not currently conscious";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not currently conscious";
$attack = count(explode(' ',$post));
$attack_num = $_POST['attackattacks'];
$intox = getInfo(dex,users,"WHERE id='$userId'");
$intensity = 1;
$effortTotal = 0;
$weapon = items($userId,"weapon");
if ($weapon) {
$weaponHealth = getInfo(portions,user_items,"WHERE id='$weapon'");
$weaponStat = getInfo(stat,user_items,"WHERE id='$weapon'");
$weapon_attacks = 0;
for ($i = 1;$i <= $attack_num;$i++) {
if ($weaponHealth > 0) $weapon_attacks++;
$weaponHealth -= $weaponStat;
}
}
for ($i = 1;$i <= $attack_num;$i++) {
$store = "attackEffort".$i;
$$store = $_POST[$store];
if (!$$store) $failure = "You have not set the force percentage for one or more of your attacks.";
if ($weapon) {
if (($$store < (round($weaponStat * 0.6))) && ($i <= $weapon_attacks)) $$store = round($weaponStat * 0.6);
}
$effortTotal += $$store;
if ($attack_num > 1) {
$marker = "[/attack".$i."]";
if (strpos($post,$marker) === false) {
$failure = "You must, for the convenience of the person you are attacking, mark the end of each attack with a [/attack1], [/attack2], and so on, for the number of attacks you have made.";
} else {
$post = str_replace($marker,"$marker",$post);
}
}
}
if ($effortTotal > 100) $failure = "Your force total is too high. It must add up to no more than 100.";
if (($destination) && (!getInfo(guardin,rooms,"WHERE id='$id'"))) {
if ($town) {
if ($destinationTown != $town) $failure = "You are not in the same town as the place you wish to throw your opponent.";
} else {
if (((getInfo(x,transport,"WHERE place='$destinationPlace'") != getInfo(x,transport,"WHERE place='$buildingId'")) || (getInfo(y,transport,"WHERE place='$destinationPlace'") != getInfo(y,transport,"WHERE place='$buildingId'"))) && ($destination != "overboard")) $failure = "You are not in the same area as your destination.";
}
}
if (!$failure) {
$class = getInfo("class",users,"WHERE id='$userId'");
if (($class == "barbarian") && ($intox > 0)) {
$damage_inc = 1 + ($intox / 50);
}
$vuln = vuln($effortTotal);
$damageBonusTotal = 0;
for ($i = 1;$i <= $attack_num;$i++) {
$store = "attackEffort".$i;
$effort= $$store;
if ($weapon) {
if (($effort < $weaponStat) && ($i <= $weapon_attacks)) $effort = $weaponStat;
}
$efforts[] = "a $effort% force attack";
$roll = diceRoll($userId,sides($userId),$intox,wordcount($userId),1.5,100);
$lowDamage = $effort - 20;
if ($lowDamage < 1) $lowDamage = 1;
$damage = rand($lowDamage,$effort);
if (($class == "barbarian") && ($intox > 0)) $damage = round($damage * $damage_inc);
$roll = round($roll * (1 - (0.25 * ($effort / 100))));
$roll += itemStat($userId,"epic");
if ($type == "magic") {
$damageBonus = rand(1,20);
} else $damageBonus = itemStat($userId,"weapon");
$damage += $damageBonus;
$damageBonusTotal += $damageBonus;
$rolls[] = $roll;
$damages[] = $damage;
}
$poison = poisonStat($userId);
$rolls = implode('.',$rolls);
$damages = implode('.',$damages);
$post_id = nextId(posts);
if (!getInfo(NPC,users,"WHERE id='$user'")) {
$party = getInfo(party,users,"WHERE id='$user'");
if ($party) {
$result = getRows(users,"WHERE party='$party' and room='$room'");
while ($row = mysql_fetch_array($result)) {
$party_members[] = $row['id'];
}
$party_members = implode('.',$party_members);
} else $party_members = "";
$query = "INSERT INTO fights VALUES('','$userId','$user','$rolls','$damages','1','$post_id','$destination','$attack_num','','$poison','$party_members','')";
mysql_query($query);
$success = "You have successfully attacked ".$username.".";
} else {
$npcowner = getInfo(NPC,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$npcowner'") != $id) {
$result = getRows(users,"WHERE NPC!='' and room='$id' and status='conscious'");
while ($row = mysql_fetch_array($result)) {
$protector = $row['id'];
if (($protector != $user) && (getInfo(protect,npcs,"WHERE name='$protector'")) && (getInfo(type,npcs,"WHERE name='$protector'") > 10) && (((getInfo(npcgroup,npcs,"WHERE name='$protector'") == getInfo(npcgroup,npcs,"WHERE name='$user'")) && (getInfo(npcgroup,npcs,"WHERE name='$protector'"))) || (getInfo(id,npcs,"WHERE name='$protector' and var like 'all%' and mode='protect'"))) && (!isFighting($protector)) && (!isTied($protector)) && (!getInfo(id,users,"WHERE mount='$protector'"))) $group[] = $protector;
}
$protector = $group[rand(0,count($group) - 1)];
$protectorname = getInfo(username,users,"WHERE id='$protector'");
if ($protector) {
$mode = getInfo(protect,npcs,"WHERE name='$protector'");
if (getInfo(npcgroup,npcs,"WHERE name='$protector'") != getInfo(npcgroup,npcs,"WHERE name='$user'")) $mode = "full";
if ($mode == "full") {
$god = "$protectorname moved in to protect $username from the attack. ";
$god .= counter($protector,$rolls,$damages);
if (getInfo(status,users,"WHERE id='$protector'") == "conscious") {
if (getInfo(animal,npcs,"WHERE name='$protector'")) {
$npc_post = animalattack($protector,$userId);
$npc_post = $npc_post[0];
$post_npc = $protector;
if (($npc_post == "Array") || (!$npc_post)) $god .= react($protector,$userId);
} else {
$god .= react($protector,$userId);
}
}
}
if ($mode == "attack") {
$god = counter($user,$rolls,$damages);
$god .= " $protectorname jumped in to attack $user_name.";
if (getInfo(animal,npcs,"WHERE name='$protector'")) {
$npc_post = animalattack($protector,$userId);
$npc_post_ooc = $npc_post[1];
$npc_post = $npc_post[0];
$post_npc = $protector;
if (($npc_post == "Array") || (!$npc_post) || (!$npc_post_ooc)) {
$god .= npcattack($protector,$userId);
unset($npc_post);
}
} else {
$god .= npcattack($protector,$userId);
}
}
if ($mode == "defend") {
$god = "$protectorname moved in to protect $username from the attack. ";
$god .= counter($protector,$rolls,$damages);
$god .= react($user,$userId);
}
} else {
$god = counter($user,$rolls,$damages,$destination);
if (getInfo(status,users,"WHERE id='$user'") == "conscious") {
if (getInfo(animal,npcs,"WHERE name='$user'")) {
$npc_post = animalattack($user,$userId);
$npc_post_ooc = $npc_post[1];
$npc_post = $npc_post[0];
$post_npc = $user;
if (($npc_post == "Array") || (!$npc_post) || (!$npc_post_ooc)) if (getInfo(room,users,"WHERE id='$user'") == $id) {
$god .= react($user,$userId);
unset($npc_post);
}
} else {
if (getInfo(room,users,"WHERE id='$user'") == $id) $god .= react($user,$userId);
}
}
}
$success = "You have successfully attacked ".$username.". Since they are an NPC, they have automatically countered.";
} else {
$time = time();
$query = "INSERT INTO npc_combat VALUES('','$user','$npcowner','','$time')";
mysql_query($query);
$query = "INSERT INTO fights VALUES('','$userId','$user','$rolls','$damages','1','$post_id','$destination','$attack_num','','$poison','','')";
mysql_query($query);
$success = "You have successfully attacked ".$username.". Though they are an NPC, their owner is currently in the room with them. In order to keep you from fighting the user's NPCs without the user properly reacting, the NPC will not counter until its owner has signed on.";
}
}
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET vulnerability='$vuln' WHERE id='$userId'";
mysql_query($query);
$post .= "
[";
$efforts = implode(", ",$efforts);
if ($attack_num > 1) {
$post .= "Attacked $username $attack_num times; $efforts.";
$s = 's';
} else {
unset($s);
$post .= "Attacked $username once; $efforts.";
}
if ($damageBonusTotal > 0) {
if ($type == "magic") $post .= " - ".$damageBonusTotal." damage bonus from magic";
else $post .= " - ".$damageBonusTotal." damage bonus from weaponry";
}
$post .= "]";
}
}
if ($command == "counter") {
if ($_POST['counterPartyDefense']) {
$defense = $_POST['counterPartyDefense'];
$defense_user = getInfo(defense,fights,"WHERE id='$defense'");
if (sameUser($defense_user,$userId)) $failure = "You may not defend your own character.";
} else $defense_user = $userId;
$defensename = getInfo(username,users,"WHERE id='$userId'");
$conditions = "WHERE defense='$defense_user'";
$row = getRow("*",fights,$conditions);
$user = $row['offense'];
$attacks = $row['attack'];
$attack_num = $row['attacks'];
$intensity = $row['intensity'];
$damages = $row['damage'];
$damages = explode('.',$damages);
$attacks = explode('.',$attacks);
$defense = count(explode(" ",$post));
$npc = $_POST['counterNPC'];
$npcname = getInfo(username,users,"WHERE id='$npc'");
$username = getInfo(username,users,"WHERE id='$user'");
if ($npc) if ((getInfo("var",npcs,"WHERE name='$npc'") != $userId) || (getInfo(mode,npcs,"WHERE name='$npc'") != "protect")) $failure = "The NPC you chose is not set to protect you.";
if ($npc) if (getInfo(room,users,"WHERE id='$npc'") != $id) $failure = "That NPC is not in this room.";
if ($npc) if (isFighting($npc)) $failure = "That NPC is fighting.";
if ($npc) if (getInfo(status,users,"WHERE id='$npc'") != "conscious") $failure = "The NPC is not conscious.";
for ($i = 1;$i <= $attack_num;$i++) {
$store = "counterAttack".$i;
if ($_POST[$store] != "ignore") {
$counters[] = $_POST[$store];
if ($attack_num > 1) {
$marker = "[/counter".$i."]";
if (strpos($post,$marker) === false) {
$failure = "You must mark the end of each counter with a [/counter1], [/counter2], and so on, for the number of counters you have made.";
} else {
$post = str_replace($marker,"$marker",$post);
}
}
} else
break;
}
$intox = getInfo(dex,users,"WHERE id='$userId'");
if (!$failure) {
if ($npc) {
$totalDamage = 0;
$max = count($damages);
for ($i = 0;$i < $max;$i++) {
$totalDamage += $damages[$i];
}
$totalDamage = round($totalDamage / 2);
$health = getInfo(health,users,"WHERE id='$npc'");
$health -= $totalDamage;
if ($health <= 0) {
$health = 0;
if (rand(1,10) <= 60) {
$query = "UPDATE users SET status='unconscious' WHERE id='$npc'";
$status = "unconscious";
} else {
$query = "UPDATE users SET NPC='*' WHERE id='$npc'";
mysql_query($query);
$query = "UPDATE users SET status='dead' WHERE id='$npc'";
$status = "dead";
if (getInfo(animal,npcs,"WHERE name='$npc'")) {
$animal = getInfo(animal,npcs,"WHERE name='$npc'");
$query = "UPDATE users SET dismembered='$animal' WHERE id='$npc'";
mysql_query($query);
} else {
$query = "UPDATE users SET dismembered='dismembered' WHERE id='$npc'";
mysql_query($query);
}
}
mysql_query($query);
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(guard,users,"WHERE id='$npc'") == $town) {
if (!cityGuards($town)) {
$query = "UPDATE towns SET leader='$user' WHERE id='$town'";
mysql_query($query);
$leader = getInfo(leader,towns,"WHERE id='$town'");
$leadername = getInfo(username,users,"WHERE id='$leader'");
sendMessage($leadername,"Your Town","Your town has been taken over by ".$username.", by knocking out your last present guard.","God");
sendMessage($username,"Conquering","You have conquered ".getInfo(name,towns,"WHERE id='$town'").".","God");
}
}
}
$query = "UPDATE users SET health='$health' WHERE id='$npc'";
mysql_query($query);
$god = $npcname." took the blow for ".$defensename.". $totalDamage damage was dealt.";
if ($status == "unconscious") $god = $npcname." took the blow for ".$defensename." and was knocked out. $totalDamage damage was dealt.";
if ($status == "dead") $god = $npcname." took the blow for ".$defensename." and was killed. $totalDamage damage was dealt.";
$query = "DELETE FROM fights WHERE defense='$userId'";
mysql_query($query);
} else {
if ($defense_user != $userId) $outcomes[] = "$user_name moved in to counter for $defensename.";
$max = count($counters);
for ($i = 0;$i < $max;$i++) {
$counter = $counters[$i];
$attackRoll = $attacks[$i];
if ($intensity == 1) $attackRoll -= 20 * ($max - 1);
if ($intensity == 2) $attackRoll -= 20 * ($max - 1);
if ($intensity == 3) $attackRoll -= 40 * ($max - 1);
if ($counter == "dodge") {
$roll = diceRoll($userId,sides($userId),$intox,wordcount($userId),1.5,100) - getInfo(vulnerability,users,"WHERE id='$userId'");
if ($roll < 0) $roll = 0;
if ($roll >= $attackRoll) {
$hitcount = getInfo(hitcount,users,"WHERE id='$userId'");
$hitcount++;
$query = "UPDATE users SET hitcount='$hitcount' WHERE id='$userId'";
mysql_query($query);
$outcomes[] = $user_name." successfully dodged attack ".($i + 1).". ".$username." rolled ".$attackRoll." and ".$user_name." rolled ".$roll.".";
} else {
if ($attack_num > 1) {
$scan = "*/counter".$i."*] *";
if (fnmatch($scan,$post)) $seperate = "[/counter".$i."] ";
else $seperate = "[/counter".$i."]";
$post_sections = explode($seperate,$post);
$post = $post_sections[0]."[/counter".$i."]";
$failedCounter = $post_sections[1];
} else {
$failedCounter = $post;
$post = "";
}
$counter_fail = $i;
$counter_failure = true;
$counter_type = "dodge";
$dodgeRoll = $roll;
$dodgeAttackRoll = $attackRoll;
break;
}
}
if ($counter == "parry") {
$damage = $damages[$i];
if ($intensity == 1) $roll = diceRoll($userId,round(sides($userId) * 0.75),$intox,wordcount($userId),1.5,100) - getInfo(vulnerability,users,"WHERE id='$userId'");
if ($intensity == 2) $roll = diceRoll($userId,round(sides($userId) * 0.75),$intox,wordcount($userId),1.5,100) - getInfo(vulnerability,users,"WHERE id='$userId'");
if ($intensity == 3) $roll = diceRoll($userId,round(sides($userId) * 0.5),$intox,wordcount($userId),1.5,100) - getInfo(vulnerability,users,"WHERE id='$userId'");
$irsh_message = "First roll : ".$roll."\n";
if ($roll < 0) $roll = 0;
$irsh_message .= "Second Roll : ".$roll."\n";
$irsh_message .= "Vulnerability : ".getInfo(vulnerability,users,"WHERE id='$userId'")."\n";
sendMessage("Irshad","Rolls for ".$user_name,$irsh_message,"God");
if ($roll >= $attackRoll) {
$hitcount = getInfo(hitcount,users,"WHERE id='$userId'");
$hitcount++;
$query = "UPDATE users SET hitcount='$hitcount' WHERE id='$userId'";
mysql_query($query);
if ($roll >= $attackRoll + 40) {
$parry_damage += round($damage / 2);
$outcome .= $user_name." successfully parried attack ".($i + 1).". ".round($damage / 2)." damage was dealt to ".$username.". ".$username." rolled ".$attackRoll." and ".$user_name." rolled ".$roll.".";
if ($damageAbsorb) $outcome .= " [".$damageAbsorb." damage absorbed by armour]";
$outcomes[] = $outcome;
} else {
$outcomes[] = $user_name." successfully parried attack ".($i + 1).". ".$username." rolled ".$attackRoll." and ".$user_name." rolled ".$roll.".";
}
} else {
if ($attack_num > 1) {
$scan = "*/counter".$i."*] *";
if (fnmatch($scan,$post)) $seperate = "[/counter".$i."] ";
else $seperate = "[/counter".$i."]";
$post_sections = explode($seperate,$post);
$post = $post_sections[0]."[/counter".$i."]";
$failedCounter = $post_sections[1];
} else {
$failedCounter = $post;
$post = "";
}
$counter_fail = $i;
$counter_failure = true;
$counter_type = "parry";
$parryRoll = $roll;
$parryAttackRoll = $attackRoll;
break;
}
}
if ($counter == "ignore") {
break;
}
}
$query = "UPDATE users SET vulnerability='' WHERE id='$userId'";
mysql_query($query);
$damageDealt = 0;
if ($counter_failure == true) {
$travel = time() + (3600 * 24);
$query = "UPDATE users SET travel='$travel' WHERE id='$userId'";
mysql_query($query);
$hitcount = getInfo(hitcount,users,"WHERE id='$user'");
$hitcount++;
$damage = $damages[$counter_fail];
if ($counter_type == "dodge") {
$damageAbsorb = itemStat($userId,"armour",$damage);
if ($damage - $damageAbsorb< 0) {
$damageAbsorb = $damage;
$damage = 0;
} else $damage -= $damageAbsorb;
$damageDealt += $damage;
$outcome = $user_name." failed to dodge attack ".($counter_fail + 1).". ".$damage." damage was dealt. ";
$outcome .= $username." rolled ".$dodgeAttackRoll." and ".$user_name." rolled ".$dodgeRoll.".";
if ($damageAbsorb > 0) $outcome .= " [".$damageAbsorb." damage absorbed by armour]";
$outcomes[] = $outcome;
}
if ($counter_type == "parry") {
$diff = $parryAttackRoll - $parryRoll;
if ($diff < 40) {
$fullDamage = $damage;
$damage = round($damage * ($diff / 40));
$parryAbsorb = $fullDamage - $damage;
$damageAbsorb = itemStat($userId,"armour",$damage);
if ($damage - $damageAbsorb < 0) {
$damageAbsorb = $damage;
$damage = 0;
} else $damage -= $damageAbsorb;
$damageDealt += $damage;
$outcome = $user_name." failed to parry attack ".($counter_fail + 1).". ".$damage." damage was dealt. ";
$outcome .= $username." rolled ".$parryAttackRoll." and ".$user_name." rolled ".$parryRoll.".";
if ($parryAbsorb > 0) $outcome .= " [".$parryAbsorb." damage absorbed by the parry]";
if ($damageAbsorb > 0) $outcome .= " [".$damageAbsorb." damage absorbed by armour]";
$outcomes[] = $outcome;
} else {
$damageAbsorb = itemStat($userId,"armour",$damage);
$damage -= $damageAbsorb;
if ($damage < 0) {
$damageAbsorb = $damage;
$damage = 0;
}
$damageDealt += $damage;
$outcome = $user_name." failed to parry attack ".($counter_fail + 1).". ".$damage." damage was dealt. ";
$outcome .= $username." rolled ".$parryAttackRoll." and ".$user_name." rolled ".$parryRoll.".";
if ($damageAbsorb > 0) $outcome .= " [".$damageAbsorb." damage absorbed by armour]";
$outcomes[] = $outcome;
}
}
$counter_fail++;
if ($attacks[$counter_fail]) {
$max = count($attacks);
for ($i = $counter_fail;$i < $max;$i++) {
$hitcount++;
$damage = $damages[$i];
$damageAbsorb = itemStat($userId,"armour",$damage);
if ($damage - $damageAbsorb < 0) {
$damageAbsorb = $damage;
$damage = 0;
} else $damage -= $damageAbsorb;
$damageDealt += $damage;
$outcome= $user_name." was subsequently hit by attack ".($i + 1).". ".$damage." damage was dealt.";
if ($damageAbsorb > 0) $outcome .= " [".$damageAbsorb." damage absorbed by armour]";
$outcomes[] = $outcome;
}
}
$query = "UPDATE users SET hitcount='$hitcount' WHERE id='$user'";
mysql_query($query);
if (getInfo(mount,users,"WHERE id='$userId'")) {
if (rand(1,100) <= 10 + $damageDealt - getInfo(riding,users,"WHERE id='$userId'")) {
$mount_fall_damage = rand(40,60);
$query = "UPDATE users SET mount='' WHERE id='$userId'";
mysql_query($query);
}
}
if ($mount_fall_damage) {
$absorb = itemStat($userId,"armour",$mount_fall_damage);
$mount_fall_damage -= $absorb;
damage($userId,$mount_fall_damage);
$outcomes[] = "$user_name fell off their mount, getting hit for $mount_fall_damage damage ($absorb damage absorbed by armour).";
}
if ($damageDealt > 0) {
$poison = explode(':',getInfo(poison,fights,"WHERE defense='$userId'"));
$pdamage = $poison[0];
$pturns = $poison[1];
if ($pdamage > 0) {
sendMessage($user_name,"Poison","You have been poisoned. For more information on how to deal with this affliction, please consult The Poison Article in the player's guide.","God");
$query = "INSERT INTO poison VALUES('','$userId','$pdamage','$pturns')";
mysql_query($query);
}
$outcomes[] = $user_name." was hit for a total of ".($damageDealt + $mount_fall_damage)." damage.";
$health = getInfo(health,users,"WHERE id='$userId'");
$health -= $damageDealt;
if ($health <= 0) {
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$userId'";
mysql_query($query);
$sleep = time();
$query = "UPDATE users SET sleep='$sleep' WHERE id='$userId'";
mysql_query($query);
$result = getRows(rooms,"WHERE guardout='$userId' or guardin='$userId'");
while ($row = mysql_fetch_array($result)) {
$guardin = $row['guardin'];
$guardout = $row['guardout'];
$i = $row['id'];
if ($guardin == $userId) {
$query = "UPDATE rooms SET guardin='' WHERE id='$i'";
mysql_query($query);
}
if ($guardout == $userId) {
$query = "UPDATE rooms SET guardout='' WHERE id='$i'";
mysql_query($query);
}
}
$outcomes[] = $user_name." is now unconscious.";
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(guard,users,"WHERE id='$userId'") == $town) {
if (!cityGuards($town)) {
$query = "UPDATE towns SET leader='$user' WHERE id='$town'";
mysql_query($query);
$leader = getInfo(leader,towns,"WHERE id='$town'");
$leadername = getInfo(username,users,"WHERE id='$leader'");
sendMessage($leadername,"Your Town","Your town has been taken over by ".$username.", by knocking out your last present guard.","God");
sendMessage($username,"Conquering","You have conquered ".getInfo(name,towns,"WHERE id='$town'").".","God");
}
}
}
$query = "UPDATE users SET health='$health' WHERE id='$userId'";
mysql_query($query);
} else $outcomes[] = $user_name." was hit, but recieved no damage whatsoever.";
if ($parry_damage > 0) {
if (getInfo(mount,users,"WHERE id='$user'")) {
if (rand(1,100) <= $parry_damage + 10) {
$mount_parry_damage = rand(40,60);
$parry_damage += $mount_parry_damage;
$outcomes[] = "$username fell off their mount, getting hit for an extra $mount_parry_damage (before armour).";
}
}
$health = getInfo(health,users,"WHERE id='$user'");
$absorb = itemStat($user,"armour",$parry_damage);
$parry_damage -= $absorb;
if ($parry_damage < 0) $parry_damage = 0;
$health -= $parry_damage;
if ($absorb) $outcomes[] = $username." was hit for a total of ".$parry_damage." damage. [$absorb damage absorbed by armour]";
else $outcomes[] = $username." was hit for a total of ".$parry_damage." damage.";
if ($health <= 0) {
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$user'";
mysql_query($query);
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$user'";
mysql_query($query);
$sleep = time();
$query = "UPDATE users SET sleep='$sleep' WHERE id='$user'";
mysql_query($query);
$result = getRows(rooms,"WHERE guardout='$user' or guardin='$user'");
while ($row = mysql_fetch_array($result)) {
$guardin = $row['guardin'];
$guardout = $row['guardout'];
$i = $row['id'];
if ($guardin == $user) {
$query = "UPDATE rooms SET guardin='' WHERE id='$i'";
mysql_query($query);
}
if ($guardout == $user) {
$query = "UPDATE rooms SET guardout='' WHERE id='$i'";
mysql_query($query);
}
}
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(guard,users,"WHERE id='$user'") == $town) {
if (!cityGuards($town)) {
$query = "UPDATE towns SET leader='$userId' WHERE id='$town'";
mysql_query($query);
$leader = getInfo(leader,towns,"WHERE id='$town'");
$leadername = getInfo(username,users,"WHERE id='$leader'");
sendMessage($leadername,"Your Town","Your town has been taken over by ".$user_name.", by knocking out your last present guard.","God");
sendMessage($user_name,"Conquering","You have conquered ".getInfo(name,towns,"WHERE id='$town'").".","God");
}
}
$outcomes[] = $username." is now unconscious.";
}
$query = "UPDATE users SET health='$health' WHERE id='$user'";
mysql_query($query);
}
$destination = getInfo("throw",fights,"WHERE defense='$userId'");
if (($destination) && (!getInfo(guardin,rooms,"WHERE id='$id'"))) {
if ($destination == "overboard") {
move($userId,"overboard");
$outcomes[] = $user_name." was thrown overboard.";
$post .= "
[".$user_name." was thrown into ".$destinationRoomName." in ".$destinationPlaceName."]";
$outcomes[] = $user_name." was thrown into ".$destinationRoomName." in ".$destinationPlaceName.".";
}
}
if ($health <= 0) {
$unconscious = true;
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$userId'";
mysql_query($query);
$result = getRows(rooms,"WHERE guardout='$userId' or guardin='$userId'");
while ($row = mysql_fetch_array($result)) {
$guardin = $row['guardin'];
$guardout = $row['guardout'];
$i = $row['id'];
if ($guardin == $userId) {
$query = "UPDATE rooms SET guardin='' WHERE id='$i'";
mysql_query($query);
}
if ($guardout == $userId) {
$query = "UPDATE rooms SET guardout='' WHERE id='$i'";
mysql_query($query);
}
}
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(guard,users,"WHERE id='$userId'") == $town) {
if (!cityGuards($town)) {
$query = "UPDATE towns SET leader='$user' WHERE id='$town'";
mysql_query($query);
$leader = getInfo(leader,towns,"WHERE id='$town'");
$leadername = getInfo(username,users,"WHERE id='$leader'");
sendMessage($leadername,"Your Town","Your town has been taken over by ".$username.", by knocking out your last present guard.","God");
sendMessage($username,"Conquering","You have conquered ".getInfo(name,towns,"WHERE id='$town'").".","God");
}
}
}
$query = "UPDATE users SET health='$health' WHERE id='$userId'";
mysql_query($query);
$success = "You have taken the blow from ".$username."'s attack.";
$god = $user_name." took the blow from ".$username."'s attack.
".$username."'s attack did ".$damage." damage. [$armourTotal damage absorbed by armour]";
if ($unconscious) $god .= "
".$user_name." is now unconscious, and vulnerable to being robbed, captured and slain.";
$query = "DELETE FROM fights WHERE defense='$userId'";
mysql_query($query);
$travel = time() + (3600 * 24);
$query = "UPDATE users SET travel='$travel' WHERE id='$userId'";
mysql_query($query);
if (getInfo(NPC,users,"WHERE id='$user'")) {
$newtime = time() + (60 * 20);
$query = "UPDATE npcs SET attack='$newtime' WHERE name='$npc'";
mysql_query($query);
}
}
}
if ($command == "takeblowother") {
$user = $_POST['takeblowotherUser'];
if (!getInfo(defense,fights,"WHERE defense='$user'")) $failure = "That user is not currently being attacked.";
if (getInfo(offense,fights,"WHERE defense='$user'") == $userId) $failure = "You may not take the damage for your own attack.";
if (sameUser($user,$userId)) $failure = "You may not take the blow for your own characters.";
if (sameUser(getInfo(offense,fights,"WHERE defense='$user'"),$userId)) $failure = "You may not take the damage from your own attack.";
$attack = getInfo(attack,fights,"WHERE defense='$user'");
$username = getInfo(username,users,"WHERE id='$user'");
$attacker = getInfo(offense,fights,"WHERE defense='$user'");
$attackername = getInfo(username,users,"WHERE id='$attacker'");
$intensity = getInfo(intensity,fights,"WHERE defense='$user'");
if (!$failure) {
$damage = getInfo(damage,fights,"WHERE defense='$user'");
if (getInfo(attacks,fights,"WHERE defense='$user'") > 1) {
$damage = explode('.',$damage);
$max = count($damage);
for ($i = 0;$i < $max;$i++) {
$armour = itemStat($userId,"armour",$damage[$i]);
$temp = $damage[$i] - $armour;
if ($temp < 0) $temp = 0;
$damageTotal += $temp;
$armourTotal += $armour;
}
$damage = $damageTotal;
} else {
$armour = itemStat($userId,"armour",$damage[$i]);
$temp = $damage - $armour;
if ($temp < 0) $temp = 0;
$damageTotal += $temp;
$armourTotal += $armour;
}
$health = getInfo(health,users,"WHERE id='$userId'");
$health -= round($damage / 2);
$destination = getInfo("throw",fights,"WHERE defense='$user'");
if (($destination) && (!getInfo(guardin,rooms,"WHERE id='$id'"))) {
if ($destination == "overboard") {
move($userId,"overboard");
$outcomes[] = $user_name." was thrown overboard.";
$post .= "
[".$user_name." was thrown into ".$destinationRoomName." in ".$destinationPlaceName."]";
$outcomes[] = $user_name." was thrown into ".$destinationRoomName." in ".$destinationPlaceName.".";
}
}
if ($health <= 0) {
$unconscious = true;
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$userId'";
mysql_query($query);
$result = getRows(rooms,"WHERE guardout='$userId' or guardin='$userId'");
while ($row = mysql_fetch_array($result)) {
$guardin = $row['guardin'];
$guardout = $row['guardout'];
$i = $row['id'];
if ($guardin == $userId) {
$query = "UPDATE rooms SET guardin='' WHERE id='$i'";
mysql_query($query);
}
if ($guardout == $userId) {
$query = "UPDATE rooms SET guardout='' WHERE id='$i'";
mysql_query($query);
}
}
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(guard,users,"WHERE id='$userId'") == $town) {
if (!cityGuards($town)) {
$query = "UPDATE towns SET leader='$attacker' WHERE id='$town'";
mysql_query($query);
$leader = getInfo(leader,towns,"WHERE id='$town'");
$leadername = getInfo(username,users,"WHERE id='$leader'");
sendMessage($leadername,"Your Town","Your town has been taken over by ".$attackername.", by knocking out your last present guard.","God");
sendMessage($attackername,"Conquering","You have conquered ".getInfo(name,towns,"WHERE id='$town'").".","God");
}
}
}
$query = "UPDATE users SET health='$health' WHERE id='$userId'";
mysql_query($query);
$success = "You have taken the blow from ".$attackername."'s attack.";
$god = $user_name." took the blow from ".$attackername."'s attack.
".$attackername."'s attack did ".($damage / 2)." damage.";
if ($armourTotal > 0) $god .= " [$armourTotal damage absorbed by armour]";
if ($unconscious) $god .= "
".$user_name." is now unconscious, and vulnerable to being robbed, captured and slain.";
$query = "DELETE FROM fights WHERE defense='$user'";
mysql_query($query);
$query = "DELETE FROM npc_fights WHERE defense='$user'";
mysql_query($query);
$travel = time() + (3600 * 24);
$query = "UPDATE users SET travel='$travel' WHERE id='$userId'";
mysql_query($query);
if (getInfo(NPC,users,"WHERE id='$user'")) {
$newtime = time() + (60 * 20);
$query = "UPDATE npcs SET attack='$newtime' WHERE name='$npc'";
mysql_query($query);
}
}
}
if ($command == "strip") {
$user = $_POST['stripUser'];
if (sameUser($user,$userId)) $failure = "You may not loot your own character.";
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = $username." is not in this room.";
if ((getInfo(status,users,"WHERE id='$user'") != "unconscious") && (getInfo(status,users,"WHERE id='$user'") != "dead") && (getInfo(status,users,"WHERE id='$user'") != "immobilized")) $failure = $username." is not unconscious or dead or immobilized.";
if (!$user) $failure = "You have not specified a user.";
$userInventory = getInfo(inventory,users,"WHERE id='$user'");
$inventoryArray = explode('.',fixArray(getInfo(clothes,users,"WHERE id='$user'").'.'.getInfo(overhead,users,"WHERE id='$user'").'.'.getInfo(behind,users,"WHERE id='$user'")));
$max = count($inventoryArray);
for ($i = 0;$i < $max;$i++) $inventoryArray[$i] = getInfo(name,user_items,"WHERE id='".$inventoryArray[$i]."'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if (!$failure) {
$gotfamily = false;
$animal = getInfo(animal,npcs,"WHERE name='$user'");
if ((!$animal) && (getInfo(NPC,users,"WHERE id='$user'"))) $animal = getInfo(dismembered,users,"WHERE id='$user'");
if ((getInfo(inventory,npc_animals,"WHERE id='$animal'")) && (!getInfo(taken,loot_animals,"WHERE npc='$user'"))) {
$base = getInfo(base,users,"WHERE id='$userId'");
$family = getInfo(family,bases,"WHERE id='$base'");
if ($family) {
$animal_inventory = explode(';',getInfo(inventory,npc_animals,"WHERE id='$animal'"));
print_r($animal_inventory);
echo " 1";
$max = count($animal_inventory);
for ($i = 0;$i < $max;$i++) {
$a_inv = explode(':',$animal_inventory[$i]);
print_r($a_inv);
echo " 2";
if ($a_inv[0] == $family) {
$a_inv = explode('.',$a_inv[1]);
print_r($a_inv);
echo " 3";
$max2 = count($a_inv);
for ($ii = 0;$ii < $max2;$ii++) {
$item = $a_inv[$ii];
if (rand(1,100) <= 60) {
if ($inventory) $inventory .= '.'.createItem($item);
else $inventory = createItem($item);
$inventoryArray[] = getInfo(name,items,"WHERE id='$item'");
}
}
$gotfamily = true;
break;
}
}
}
if (!$gotfamily) {
$animal_inventory = explode(';',getInfo(inventory,npc_animals,"WHERE id='$animal'"));
$max = count($animal_inventory);
for ($i = 0;$i < $max;$i++) {
$a_inv = explode(':',$animal_inventory);
if ($a_inv[0] == $family) {
$a_inv = explode('.',$a_inv[1]);
$max2 = count($a_inv);
for ($ii = 0;$ii < $max2;$ii++) {
$item = $a_inv[$i];
if (rand(1,100) <= 60) {
if ($inventory) $inventory .= '.'.createItem($item);
else $inventory = createItem($item);
}
}
$gotfamily = true;
break;
}
}
}
if (!getInfo(id,loot_animals,"WHERE npc='$user'")) {
$query = "INSERT INTO loot_animals VALUES('','$user','','','','','taken')";
mysql_query($query);
} else {
$query = "UPDATE loot_animals SET taken='taken' WHERE npc='$user'";
mysql_query($query);
}
}
$inventoryList = implode(', ',$inventoryArray);
$userUnderhead = getInfo(clothes,users,"WHERE id='$user'");
$userOverhead = getInfo(overhead,users,"WHERE id='$user'");
$userBehind = getInfo(behind,users,"WHERE id='$user'");
if (($inventory) && ($userUnderhead)) $inventory .= ".".$userUnderhead;
elseif ($userUnderhead) $inventory = $userUnderhead;
if (($inventory) && ($userOverhead)) $inventory .= ".".$userOverhead;
elseif ($userOverhead) $inventory = $userOverhead;
if (($inventory) && ($userBehind)) $inventory .= ".".$userBehind;
elseif ($userBehind) $inventory = $userBehind;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET clothes='' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET overhead='' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET behind='' WHERE id='$user'";
mysql_query($query);
$success = "You have successfully stripped ".$username.". You have acquired the following items : ".$inventoryList.".";
$post .= "
[Took $username's clothing]";
}
}
if ($command == "loot") {
$user = $_POST['lootUser'];
if (sameUser($user,$userId)) $failure = "You may not loot your own character.";
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = $username." is not in this room.";
if ((getInfo(status,users,"WHERE id='$user'") != "unconscious") && (getInfo(status,users,"WHERE id='$user'") != "dead") && (getInfo(status,users,"WHERE id='$user'") != "immobilized")) $failure = $username." is not unconscious or dead or immobilized.";
if (!$user) $failure = "You have not specified a user.";
$userInventory = getInfo(inventory,users,"WHERE id='$user'");
$inventoryArray = explode('.',$userInventory);
$max = count($inventoryArray);
for ($i = 0;$i < $max;$i++) $inventoryArray[$i] = getInfo(name,user_items,"WHERE id='".$inventoryArray[$i]."'");
$inventoryList = implode(', ',$inventoryArray);
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$userMoney = getInfo(money,users,"WHERE id='$user'");
if (!$failure) {
if (($inventory) && ($userInventory)) $inventory .= ".".$userInventory;
elseif ($userInventory) $inventory = $userInventory;
$master = getInfo(master,users,"WHERE id='$userId'");
$mastername = getInfo(username,users,"WHERE id='$master'");
if ($master) {
$money = getInfo(money,users,"WHERE id='$master'");
$money += $userMoney;
$query = "UPDATE users SET money='$money' WHERE id='$master'";
mysql_query($query);
} else {
$money = getInfo(money,users,"WHERE id='$userId'");
$money += $userMoney;
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
}
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET inventory='' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET money='0' WHERE id='$user'";
mysql_query($query);
$success = "You have successfully looted ".$username.". You have acquired ".$userMoney." gold and the following items : ".$inventoryList.".";
if ($master) $success .= " Though you keep the items for now, the money has been sent directly to your master.";
$topic = "Income";
$message = $user_name." has looted ".$username.". Subsequently, ".$userMoney." gold has been acquired and sent to you.";
if ($master) sendMessage($mastername,$topic,$message,"God");
$post .= "
[Looted $username's inventory]";
}
}
if ($command == "capture") {
$user = $_POST['captureUser'];
$username = getInfo(username,users,"WHERE id='$user'");
if ((getInfo(status,users,"WHERE id='$user'") != "unconscious") && (getInfo(status,users,"WHERE id='$user'") != "immobilized")) $failure = $username." is not unconscious or immobilized.";
if ((getInfo(status,users,"WHERE id='$user'") == "unconscious") && (getInfo(health,users,"WHERE id='$user'") > 25) && (!getInfo(NPC,users,"WHERE id='$user'"
))) $failure = "You may not capture someone that has more than 25 health points left.";
if ((getInfo(NPC,users,"WHERE id='$user'")) && (getInfo(personal,users,"WHERE id='$userId'") != "slaver")) $failure = "Only a trained slaver may capture and enslave an NPC.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = $username." is not in this room.";
if (!$user) $failure = "You have not specified a user.";
$userMaster = getInfo(master,users,"wHERE id='$user'");
if ((getInfo(room,users,"WHERE id='$userMaster'") == $id) && (getInfo(status,users,"WHERE id='$userMaster'") == "conscious")) $failure = "That person's master is in this room - you may not enslave someone else's slave while they are in the room.";
if (!$failure) {
$query = "DELETE FROM npc_citizens WHERE npc='$user'";
mysql_query($query);
$query = "UPDATE npcs SET leader='' WHERE name='$user'";
mysql_query($query);
$master = getInfo(master,users,"WHERE id='$userId'");
if ($master) $new = $master;
else $new = $userId;
$result = getRows(kingdoms,"WHERE leader='$user'");
while ($row = mysql_fetch_array($result)) {
if ($kingdoms) $kingdoms .= ', '.$row['name'];
else $kingdoms = $row['name'];
$userKingdom = getInfo(id,kingdoms,"WHERE leader='$userId'");
$i = $row['id'];
if ($userKingdom) {
$query = "UPDATE kingdoms SET leader='' WHERE id='$i'";
mysql_query($query);
$query = "UPDATE kingdoms SET conquered='$userId' WHERE id='$i'";
mysql_query($query);
$result2 = getRows(users,"WHERE nationality='$i'");
while ($row2 = mysql_fetch_array($result2)) {
$ii = $row2['id'];
$query = "UPDATE users SET nationality='$userKingdom' WHERE id='$ii'";
mysql_query($query);
$nationalityUser = $row2['username'];
$kingdomName = $row['name'];
$userKingdomName = getInfo(name,kingdoms,"WHERE id='$userKingdom'");
$topic = $kingdomName.' has been conquered';
$message = $kingdomName.' has been conquered by '.$user_name.'. Because of this, all citizens of '.$kingdomName.' and all towns are now part of '.$userKingdomName.'.';
sendMessage($nationalityUser,$topic,$message,"God");
}
$result2 = getRows(towns,"WHERE kingdom='$i'");
while ($row2 = mysql_fetch_array($result2)) {
$ii = $row2['id'];
$query = "UPDATE towns SET kingdom='$userKingdom' WHERE id='$ii'";
mysql_query($query);
}
} else {
$query = "UPDATE kingdoms SET leader='$new' WHERE id='$i'";
mysql_query($query);
if ($kingdoms) $kingdoms .= ', '.$row['name'];
else $kingdoms = $row['name'];
}
}
$result = getRows(towns,"WHERE leader='$user'");
while ($row = mysql_fetch_array($result)) {
$i = $row['id'];
$query = "UPDATE towns SET leader='$new' WHERE id='$i'";
mysql_query($query);
$userNationality = getInfo(nationality,users,"WHERE id='$userId'");
$query = "UPDATE towns SET kingdom='$userNationality' WHERE id='$i'";
mysql_query($query);
if ($towns) $towns .= ', '.$row['name'];
else $towns = $row['name'];
}
$result = getRows(places,"WHERE owner='$user'");
while ($row = mysql_fetch_array($result)) {
$type = $row['type'];
$type = getInfo(label,buildings,"WHERE id='$type'");
$i = $row['id'];
if (($type == "ship") || ($type == "caravan")) {
$query = "UPDATE places SET owner='$new' WHERE id='$i'";
mysql_query($query);
$query = "UPDATE transport SET captain='$new' WHERE place='$i'";
mysql_query($query);
if ($ships) $ships .= ', '.getInfo(name,places,"WHERE id='$i'");
else $ships = getInfo(name,places,"WHERE id='$i'");
}
}
$result = getRows(transport,"WHERE captain='$user'");
while ($row = mysql_fetch_array($result)) {
$place = $row['place'];
$query = "UPDATE places SET owner='$new' WHERE id='$place'";
mysql_query($query);
$query = "UPDATE transport SET captain='$new' WHERE place='$place'";
mysql_query($query);
if ($ships) $ships .= ', '.getInfo(name,places,"WHERE id='$place'");
else $ships = getInfo(name,places,"WHERE id='$place'");
}
$result = getRows(users,"WHERE master='$user'");
while ($row = mysql_fetch_array($result)) {
$i = $row['id'];
if (!$row['NPC']) {
$query = "UPDATE users SET master='' WHERE id='$i'";
mysql_query($query);
sendMessage($row['username'],"Freedom","Your master has been enslaved or slain; You are now free.","God");
} else {
$query = "UPDATE users SET NPC='$userId' WHERE id='$i'";
mysql_query($query);
$query = "UPDATE users SET master='$userId' WHERE id='$i'";
mysql_query($query);
}
}
$query = "UPDATE npcs SET npcgroup='' WHERE name='$user'";
mysql_query($query);
$query = "UPDATE users SET master='$new' WHERE id='$user'";
mysql_query($query);
if (getInfo(NPC,users,"WHERE id='$user'")) {
$query = "UPDATE users SET NPC='$userId' WHERE id='$user'";
mysql_query($query);
}
$mastername = getInfo(username,users,"WHERE id='$master'");
$query = "UPDATE npcs SET npcgroup='' WHERE name='$user'";
mysql_query($query);
if ($master) $success = "You have successfully captured ".$username.", and they are now your master's slave.";
else $success = "You have successfully captured ".$username.". They are now your slave, and will be until you are killed, they are captured by another user, or you choose to set them free.";
$topic = "New Slave";
$message = $user_name." has captured ".$username.", who is now one of your slaves.";
if ($master) sendMessage($mastername,$topic,$message,"God");
if (($kingdoms) || ($towns)) {
if ($master) $success .= " You have also acquired the following for your master :";
else $success .= " You have also acquired the following : ";
if ($kingdoms) $success .= " Kingdom(s) : ".$kingdoms;
if ($towns) $success .= " Town(s) : ".$towns;
if ($ships) $success .= " Ships/Caravans : ".$ships;
if ($master) {
$topic = "Acquisitions";
$message = "Your slave, ".$user_name.", has enslaved ".$username.". In doing so, they have given you the rule over the following : ";
if ($kingdoms) $message .= " Kingdom(s) : ".$kingdoms;
if ($towns) $message .= " Town(s) : ".$towns;
if ($ships) $message .= " Ships/Caravans : ".$ships;
sendMessage($mastername,$topic,$message,"God");
}
}
$post .= "
[Enslaved ".$username."]";
}
}
if ($command == "devour") {
$transformation = getInfo(transformed,users,"WHERE id='$userId'");
if (getInfo(type,transformations,"WHERE id='$transformation'") != "carnivore") $failure = "This transformation is not set as carnivorous, and therefore may not use the devour command.";
$user = $_POST['devourUser'];
$username = getInfo(username,users,"WHERE id='$user'");
$status = getInfo(status,users,"WHERE id='$user'");
if ($status == "conscious") $failure = $username." is currently conscious.";
if ($status != "dead") {
if (($status == "unconscious") || ($status == "immobilized")) {
if (getInfo(health,users,"WHERE id='$user'") > 0) $failure = "$username has more than 0 health.";
} else $failure = "$username is not dead, unconscious or immobilized.";
}
if (!$failure) {
$query = "UPDATE users SET town='*', location='*', room='*' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET status='dead' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET hunger='100' WHERE id='$userId'";
mysql_query($query);
$success = "You have successfully eaten $username.";
$post .= "
[Devoured ".$username."]";
}
}
if ($command == "dismember") {
$user = $_POST['dismemberUser'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(status,users,"WHERE id='$user'") != "dead") $failure = $username." is not dead.";
$dismembered = getInfo(dismembered,users,"WHERE id='$user'");
if ((!is_numeric($dismembered)) && ($dismembered)) $failure = $username." has already been dismembered, or commit suicide - one may not dismember a character who took their own life.";
if (!$failure) {
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
$animal = $dismembered;
if ($animal) {
$bone = getInfo(bone,npc_animals,"WHERE id='$animal'");
$pelts = getInfo(pelts,npc_animals,"WHERE id='$animal'");
$meat = getInfo(meat,npc_animals,"WHERE id='$animal'");
$blood = getInfo(blood,npc_animals,"WHERE id='$animal'");
$meatItem = getInfo(meatitem,npc_animals,"WHERE id='$animal'");
$extra = createItem(121,$bone).'.'.createItem(122,$pelts).'.'.createItem($meatItem,$meat).'.'.createItem(2387,$blood);
} else {
$extra = dismember($username,"Hand","A pallid, rigid hand, still caked with clotted blood.").'.'.dismember($username,"Tongue","A tongue, in the same condition as when it was ripped from a screaming mouth.").'.'.dismember($username,"Ear","One could easily mistake this revolting mass of gore for a canine's chewtoy.").'.'.dismember($username,"Eye","Pleasantly squishy; Lets hope the new owner shows it more respect than its previous owner ever did.").'.'.dismember($username,"Calf","An odd souvenir for a slaying; looks more like a club than anything else. Either way, it would probably do the job just as well.").'.'.dismember($username,"Head","The most popular souvenir of a ruthless murder; ".$username."'s gruesome head.").'.'.dismember($username,"Heart","As if it just recently ceased its beating, ".$username."'s heart is perfectly inflated, blood still dripping from the arteries.").'.'.createItem(2387,4).createItem(3120,1);
}
if ($inventory) $inventory .= '.'.$extra;
else $inventory = $extra;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET dismembered='dismembered' WHERE id='$user'";
mysql_query($query);
$success = "You have successfully dismembered the corpse.";
$post .= "
[Dismembered ".$username."]";
}
}
if ($command == "slay") {
if ((getInfo(slay,users,"WHERE id='$userId'") == "no") || (getInfo(slay,users,"WHERE id='$userId'") >= time())) $failure = "You may not slay any user while wearing an epic item, or until a week has passed since you last wore one.";
$user = $_POST['slayUser'];
$username = getInfo(username,users,"WHERE id='$user'");
if ((getInfo(status,users,"WHERE id='$user'") == "unconscious") && (getInfo(health,users,"WHERE id='$user'") > 0)) $failure = "You may not slay someone that has health left.";
if (sameUser($user,$userId)) $failure = "You may not slay one of your own characters.";
if ((getInfo(status,users,"WHERE id='$user'") != "unconscious") && (getInfo(status,users,"WHERE id='$user'") != "immobilized")) $failure = $username." is not unconscious or immobilized.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = $username." is not in this room.";
if (!$user) $failure = "You have not specified a user.";
if (getInfo(master,users,"WHERE id='$user'") == $user_name) $failure = "You may not slay your own slave. You must first release them.";
if (!$failure) {
if (getInfo(animal,npcs,"WHERE name='$user'")) {
$animal = getInfo(animal,npcs,"WHERE name='$user'");
$query = "UPDATE users SET dismembered='$animal' WHERE id='$user'";
mysql_query($query);
}
$query = "DELETE FROM npcs WHERE name='$user'";
mysql_query($query);
$query = "DELETE FROM npc_citizens WHERE npc='$user'";
mysql_query($query);
$date = date('g:i A F jS Y');
$statmax = sides($user) + expBonus($user);
if (getInfo(NPC,users,"WHERE id='$user'")) $statmax = 0;
$time = time() + (3600 * 12);
$query = "INSERT INTO murders VALUES('','$user','$userId','$statmax','$date','$id','','$time')";
mysql_query($query);
$master = getInfo(master,users,"WHERE id='$userId'");
if ($master) $new = $master;
else $new = $userId;
$result = getRows(kingdoms,"WHERE leader='$user'");
while ($row = mysql_fetch_array($result)) {
if ($kingdoms) $kingdoms .= ', '.$row['name'];
else $kingdoms = $row['name'];
$userKingdom = getInfo(id,kingdoms,"WHERE leader='$userId'");
$i = $row['id'];
if ($userKingdom) {
$query = "UPDATE kingdoms SET leader='' WHERE id='$i'";
mysql_query($query);
$query = "UPDATE kingdoms SET conquered='$userId' WHERE id='$i'";
mysql_query($query);
$result2 = getRows(users,"WHERE nationality='$i'");
while ($row2 = mysql_fetch_array($result2)) {
$ii = $row2['id'];
$query = "UPDATE users SET nationality='$userKingdom' WHERE id='$ii'";
mysql_query($query);
$nationalityUser = $row2['username'];
$kingdomName = $row['name'];
$userKingdomName = getInfo(name,kingdoms,"WHERE id='$userKingdom'");
$topic = $kingdomName.' has been conquered';
$message = $kingdomName.' has been conquered by '.$user_name.'. Because of this, all citizens of '.$kingdomName.' and all towns are now part of '.$userKingdomName.'.';
sendMessage($nationalityUser,$topic,$message,"God");
}
$result2 = getRows(towns,"WHERE kingdom='$i'");
while ($row2 = mysql_fetch_array($result2)) {
$ii = $row2['id'];
$query = "UPDATE towns SET kingdom='$userKingdom' WHERE id='$ii'";
mysql_query($query);
}
} else {
$query = "UPDATE kingdoms SET leader='$new' WHERE id='$i'";
mysql_query($query);
if ($kingdoms) $kingdoms .= ', '.$row['name'];
else $kingdoms = $row['name'];
}
}
$result = getRows(towns,"WHERE leader='$user'");
while ($row = mysql_fetch_array($result)) {
$i = $row['id'];
$query = "UPDATE towns SET leader='$new' WHERE id='$i'";
mysql_query($query);
$userNationality = getInfo(nationality,users,"WHERE id='$userId'");
$query = "UPDATE towns SET kingdom='$userNationality' WHERE id='$i'";
mysql_query($query);
if ($towns) $towns .= ', '.$row['name'];
else $towns = $row['name'];
}
$result = getRows(places,"WHERE owner='$user'");
while ($row = mysql_fetch_array($result)) {
$type = $row['type'];
$type = getInfo(label,buildings,"WHERE id='$type'");
$i = $row['id'];
if (($type == "ship") || ($type == "caravan")) {
$query = "UPDATE places SET owner='$new' WHERE id='$i'";
mysql_query($query);
$query = "UPDATE transport SET captain='$new' WHERE place='$i'";
mysql_query($query);
if ($ships) $ships .= ', '.getInfo(name,places,"WHERE id='$i'");
else $ships = getInfo(name,places,"WHERE id='$i'");
}
}
$result = getRows(transport,"WHERE captain='$user'");
while ($row = mysql_fetch_array($result)) {
$place = $row['place'];
$query = "UPDATE places SET owner='$new' WHERE id='$place'";
mysql_query($query);
$query = "UPDATE transport SET captain='$new' WHERE place='$place'";
mysql_query($query);
if ($ships) $ships .= ', '.getInfo(name,places,"WHERE id='$place'");
else $ships = getInfo(name,places,"WHERE id='$place'");
}
$result = getRows(users,"WHERE master='$user'");
while ($row = mysql_fetch_array($result)) {
$i = $row['id'];
if (!$row['NPC']) {
$query = "UPDATE users SET master='' WHERE id='$i'";
mysql_query($query);
sendMessage($row['username'],"Freedom","Your master has been enslaved or slain; You are now free.","God");
} else {
$query = "UPDATE users SET NPC='$userId' WHERE id='$i'";
mysql_query($query);
$query = "UPDATE users SET master='$userId' WHERE id='$i'";
mysql_query($query);
}
}
$query = "UPDATE users SET status='dead' WHERE id='$user'";
mysql_query($query);
$max = numRows(accounts);
for ($i = 1;$i <= $max;$i++) {
$characters = getInfo(characters,accounts,"WHERE id='$i'");
$characters = explode('.',$characters);
if (inArray($user,$characters)) {
$characters = implode('.',$characters);
$characters = removeElement($user,$characters,'.');
$query = "UPDATE accounts SET characters='$characters' WHERE id='$i'";
mysql_query($query);
$active = getInfo(active,accounts,"WHERE id='$i'");
if ($active == $user) {
$query = "UPDATE accounts SET active='' WHERE id='$i'";
mysql_query($query);
}
$dead = getInfo(dead,accounts,"WHERE id='$i'");
if ($dead) $dead .= '.'.$user;
else $dead = $user;
$query = "UPDATE accounts SET dead='$dead' WHERE id='$i'";
mysql_query($query);
break;
} elseif (inArray(strtolower($user),$characters)) {
$characters = implode('.',$characters);
$characters = removeElement(strtolower($user),$characters,'.');
$query = "UPDATE accounts SET characters='$characters' WHERE id='$i'";
mysql_query($query);
$active = getInfo(active,accounts,"WHERE id='$i'");
if ($active == $user) {
$query = "UPDATE accounts SET active='' WHERE id='$i'";
mysql_query($query);
}
$dead = getInfo(dead,accounts,"WHERE id='$i'");
if ($dead) $dead .= '.'.$user;
else $dead = $user;
$query = "UPDATE accounts SET dead='$dead' WHERE id='$i'";
mysql_query($query);
break;
}
}
$mastername = getInfo(username,users,"WHERE id='$master'");
$success = "You have successfully slain ".$username.". A record of this act has been posted in the murder database.";
if (getInfo(NPC,users,"WHERE id='$user'")) {
$query = "UPDATE creature_names SET used='' WHERE name='$username'";
mysql_query($query);
$query = "UPDATE citizen_names SET used='' WHERE name='$username'";
mysql_query($query);
}
if (($kingdoms) || ($towns)) {
if ($master) $success .= " You have also acquired the following for your master :";
else $success .= " You have also acquired the following : ";
if ($kingdoms) $success .= " Kingdom(s) : ".$kingdoms;
if ($towns) $success .= " Town(s) : ".$towns;
if ($ships) $success .= " Ships/Caravans : ".$ships;
if ($master) {
$topic = "Acquisitions";
$message = "Your slave, ".$user_name.", has murdered ".$username.". In doing so, they have given you the rule over the following : ";
if ($kingdoms) $message .= " Kingdom(s) : ".$kingdoms;
if ($towns) $message .= " Town(s) : ".$towns;
if ($ships) $message .= " Ships/Caravans : ".$ships;
sendMessage($mastername,$topic,$message,"God");
}
}
$post .= "
[Slayed ".$username."]";
}
}
if ($command == "startmining") {
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
if (isFighting($userId)) $failure = "You are currently fighting.";
if (isTied($userId)) $failure = "You are currently being immobilized.";
if (getInfo(id,mining,"WHERE user='$userId'")) $failure = "You are already mining.";
if (!$failure) {
$query = "INSERT INTO mining VALUES('','$userId','$id')";
mysql_query($query);
$success = "You have started mining.";
$post .= "
[Started to Mine]";
}
}
if ($command == "stopmining") {
if (!getInfo(id,mining,"WHERE user='$userId'")) $failure = "You are not mining.";
if (!$failure) {
$query = "DELETE FROM mining WHERE user='$userId'";
mysql_query($query);
$success = "You have stopped mining.";
}
}
if ($command == "slap") {
$slave = $_POST['slapSlave'];
$slavename = getInfo(username,users,"WHERE id='$slave'");
if (getInfo(master,users,"WHERE id='$slave'") != $userId) $failure = $slavename." is not your slave.";
if (getInfo(room,users,"WHERE id='$slave'") != $id) $failure = $slavename." is not in this room.";
if (!$slave) $failure = "You have not selected a slave.";
if (getInfo(status,users,"WHERE id='$slave'") != "conscious") $failure = $slavename." is not conscious.";
if (!$failure) {
$health = getInfo(health,users,"WHERE id='$slave'");
$damage = rand(5,15);
$health -= $damage;
if ($health <= 0) $health = 0;
$query = "UPDATE users SET health='$health' WHERE id='$slave'";
mysql_query($query);
$success = "You have slapped ".$slavename." and caused ".$damage." damage.";
if ($health <= 0) {
$query = "UPDATE users SET status='unconscious' WHERE id='$slave'";
mysql_query($query);
$success .= " ".$slave." is now unconscious.";
$town = getInfo(town,places,"WHERE id='$buildingId'");
if (getInfo(guard,users,"WHERE id='$slave'") == $town) {
if (!cityGuards($town)) {
$query = "UPDATE towns SET leader='$userId' WHERE id='$town'";
mysql_query($query);
$leader = getInfo(leader,towns,"WHERE id='$town'");
$leadername = getInfo(username,users,"WHERE id='$leader'");
sendMessage($leadername,"Your Town","Your town has been taken over by ".$user_name.", by knocking out your last present guard.","God");
sendMessage($user_name,"Conquering","You have conquered ".getInfo(name,towns,"WHERE id='$town'").".","God");
}
}
}
}
}
if ($command == "drag") {
$user = $_POST['dragSlave'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(master,users,"WHERE id='$user'") != $userId) $failure = $username." is not your slave.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = $username." is not in this room.";
if (!$user) $failure = "You have not selected a slave.";
$destination = $_POST['dragRoom'];
$destinationRoomName = getInfo(name,rooms,"WHERE id='$destination'");
$destinationPlace = getInfo(place,rooms,"WHERE id='$destination'");
$destinationPlaceName = getInfo(name,places,"WHERE id='$destinationPlace'");
if (!$destination) $failure = "You have not selected a room.";
if ($destination == $id) $failure = "You are already in that room.";
$destinationPlace = getInfo(place,rooms,"WHERE id='$destination'");
$destinationTown = getInfo(town,places,"WHERE id='$destinationPlace'");
if ((inPot($userId)) || (getInfo(id,pots,"WHERE creator='$userId'"))) $failure = "You must leave the pot in which you are participating before leaving.";
if (!inArray($destination,destinations($id,$userId))) $failure = "The destination you have selected is not accessible at the current time. Certain doors may be locked, hindering your ability to reach the room. Please consult the list of destinations in move command area while posting to see which buildings/doors are locked.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are unconscious, and therefore cannot move.";
$userRoom = getInfo(room,users,"WHERE id='$userId'");
if (isFighting($userId)) $failure = "You are currently being attacked, and must react to that, before you can move to another room.";
if (fnmatch("travel_*",$destination)) {
if (getInfo(id,travel_routes,"WHERE station='$buildingId'")) {
$station = getInfo(station2,travel_routes,"WHERE station='$buildingId'");
$toll = getInfo(toll,travel_routes,"WHERE station='$buildingId'");
}
if (getInfo(id,travel_routes,"WHERE station2='$buildingId'")) {
$station = getInfo(station,travel_routes,"WHERE station2='$buildingId'");
$toll = getInfo(toll2,travel_routes,"WHERE station2='$buildingId'");
}
if (getInfo(personal,users,"WHERE id='$userId'") == "traveler") $toll = round($toll / 2);
$owner = getInfo(owner,places,"WHERE id='$buildingId'");
$ownermoney = getInfo(money,users,"WHERE id='$owner'");
if ($user == "all") {
$money = getInfo(money,users,"WHERE id='$userId'");
$result2 = getRows(users,"WHERE room='$id' and status!='conscious'");
while ($row2 = mysql_fetch_array($result2)) {
$money -= $toll;
$ownermoney += $toll;
}
} else {
$money = getInfo(money,users,"WHERE id='$userId'");
$money -= ($toll * 2);
$ownermoney += ($toll * 2);
}
if ($money < 0) $failure = "You do not have enough money.";
if (!$station) $failure = "This station does not lead to anything.";
} elseif ($destination != "overboard") {
if ($town) {
if ($destinationTown != $town) $failure = "You are trying to travel to a building which is in a different town. In order to go there, you must use the \"travel\" button located on the page where the different buildings of said town are listed.";
} else {
if ((getInfo(x,transport,"WHERE place='$destinationPlace'") != getInfo(x,transport,"WHERE place='$buildingId'")) || (getInfo(y,transport,"WHERE place='$destinationPlace'") != getInfo(y,transport,"WHERE place='$buildingId'"))) $failure = "You are not in the same area as your destination.";
}
$door_id = getInfo(id,doors,"WHERE (room='$id' and room2='$destination') or ( room='$destination' and room2='$id')");
if (getInfo(id,doors,"WHERE id='$door_id'")) {
$block = getInfo(block,doors,"WHERE id='$door_id'");
}
if (getInfo(id,doors,"WHERE id='$door_id'")) {
$block = getInfo(block2,doors,"WHERE id='$door_id'");
}
if ($block) {
if ((getInfo(room,users,"WHERE id='$block'") != $id) || (getInfo(status,users,"WHERE id='$block'") != "conscious") || ((getInfo(logged,users,"WHERE id='$block'") <= (time() - (3600 * 24 * 7))) && (!getInfo(NPC,users,"WHERE id='$block'")))) {
unset($block);
$door_id = $row['id'];
if (getInfo(room,doors,"WHERE id='$door_id'") == $id) $query = "UPDATE doors SET block='' WHERE id='$door_id'";
if (getInfo(room2,doors,"WHERE id='$door_id'") == $id) $query = "UPDATE doors SET block2='' WHERE id='$door_id'";
mysql_query($query);
}
}
if ($block) $failure = "This doorway is being blocked by ".getInfo(username,users,"WHERE id='$block'").".";
}
if (getInfo(place,rooms,"WHERE id='$destination'") != $buildingId) {
$weight = weigh($userId);
$weightMax = maxWeight($userId);
if ($weight > $weightMax) $failure = "You are currently carrying too many things in your inventory. You are carrying $weight kilograms, and may not move with more than $weightMax kilograms.";
}
if (!$failure) {
$moves++;
$query = "UPDATE users SET moves='$moves' WHERE id='$userId'";
mysql_query($query);
if ($toll) {
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
$query = "UPDATE users SET money='$ownermoney' WHERE id='$owner'";
mysql_query($query);
}
move($user,$destination);
move($userId,$destination);
if ($destination == "overboard") {
$success = "You have dragged ".$username." overboard.";
$post .= "
[".$user_name." dragged ".$username." overboard.]";
} elseif (fnmatch("travel_*",$destination)) {
$success = "You have dragged ".$username." down the road.";
$post .= "
[".$user_name." dragged ".$username." down the road.]";
} else {
$success = "You have successfully dragged ".$username." to ".$destinationRoomName." in ".$destinationPlaceName.". You will be forwarded there immediately.";
$post .= "
[Dragged ".$username." to ".$destinationRoomName." in ".$destinationPlaceName."]";
echo '';
}
}
}
if ($command == "chain") {
$slave = $_POST['chainSlave'];
$username = getInfo(username,users,"WHERE id='$slave'");
if (getInfo(master,users,"WHERE id='$slave'") != $userId) $failure = $username." is not your slave.";
if (getInfo(room,users,"WHERE id='$slave'") != $id) $failure = $username." is not in this room.";
if (!$slave) $failure = "You have not selected a slave.";
if (!$failure) {
$query = "UPDATE users SET chained='chained' WHERE id='$slave'";
mysql_query($query);
$success = "You have chained ".$username." to the room.";
}
}
if ($command == "unchain") {
$slave = $_POST['unchainSlave'];
$username = getInfo(username,users,"WHERE id='$slave'");
if (getInfo(master,users,"WHERE id='$slave'") != $userId) $failure = $username." is not your slave.";
if (getInfo(room,users,"WHERE id='$slave'") != $id) $failure = $username." is not in this room.";
if (!$slave) $failure = "You have not selected a slave.";
if (!$failure) {
$query = "UPDATE users SET chained='' WHERE id='$slave'";
mysql_query($query);
$success = "You have unchained ".$username.".";
}
}
if ($command == "escort") {
$user = $_POST['escortUser'];
$username = getInfo(username,users,"WHERE id='$user'");
if (!$user) $failure = "You did not select a user to escort.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = $username." is not in the same room as you.";
$destination = $_POST['escortRoom'];
if (!$destination) $failure = "You have not selected a room.";
if ($destination == $id) $failure = "You are already in that room.";
$destinationPlace = getInfo(place,rooms,"WHERE id='$destination'");
$destinationTown = getInfo(town,places,"WHERE id='$destinationPlace'");
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are unconscious, and therefore cannot move.";
if ((getInfo(guardout,rooms,"WHERE id='$destination'") != $userId) && (getInfo(guardin,rooms,"WHERE id='$id'") != $userId)) $failure = "The room you are trying to escort ".$username." into is not guarded by you.";
if (isFighting($userId)) $failure = "You are currently being attacked, and must react to that, before you can move to another room.";
if ($destinationTown != $town) $failure = "You are trying to travel to a building which is in a different town. In order to go there, you must use the \"travel\" button located on the page where the different buildings of said town are listed.";
if (!$failure) {
$destinationPlaceName = getInfo(name,places,"WHERE id='$destinationPlace'");
$destinationRoomName = getInfo(name,rooms,"WHERE id='$destination'");
move($user,$destination);
$success = "You have successfully escorted ".$username." to ".$destinationRoomName." in ".$destinationPlaceName.".";
$post .= "
[Escorted ".$username." to ".$destinationRoomName." in ".$destinationPlaceName."]";
}
}
if ($command == "abandon") {
$result = getRows(rooms,"WHERE guardin='$userId' or guardout='$userId'");
while ($row = mysql_fetch_array($result)) {
$guardin = $row['guardin'];
$guardout = $row['guardout'];
$i = $row['id'];
if ($guardin == $userId) {
$query = "UPDATE rooms SET guardin='' WHERE id='$i'";
mysql_query($query);
}
if ($guardout == $userId) {
$query = "UPDATE rooms SET guardout='' WHERE id='$i'";
mysql_query($query);
}
}
}
if ($command == "wake") {
$status = getInfo(status,users,"WHERE id='$userId'");
$regen = getInfo(regeneration,users,"WHERE id='$userId'");
$sleep = getInfo("sleep",users,"WHERE id='$userId'");
if (getInfo(fatigue,users,"WHERE id='$userId'") <= 0) $failure = "You may not wake up until your fatigue is above zero.";
$time = time();
if ($time < $regen) $failure = "You are not ready to wake up yet.";
if (($status != "unconscious") && (getInfo(health,users,"WHERE id='$userId'") > 0)) $failure = "You are not unconscious - therefore, you cannot wake up.";
if (!$failure) {
if (getInfo(status,users,"WHERE id='$userId'") == "unconscious") {
$query = "UPDATE users SET status='conscious' WHERE id='$userId'";
mysql_query($query);
}
$health = getInfo(health,users,"WHERE id='$userId'");
$sleeptime = time() - $sleep;
$heal = round($sleeptime / 3600);
$health += $heal * 5;
$intox = getInfo(dex,users,"WHERE id='$userId'");
$intox -= $heal * 10;
if ($intox < 0) $intox = 0;
$maxstat = statmax($userId);
if ($health > $maxstat) $health = $maxstat;
$success = "You have successfully woken up.";
}
}
if ($command == "immobilize") {
$user = $_POST['immoUser'];
$username = getInfo(username,users,"WHERE id='$user'");
if (!$user) $failure = "You have not selected a user.";
if (isFighting($user)) $failure = "The user you have selected is currently fighting.";
if (isFighting($userId)) $failure = "You are currently in a fight.";
if (isTied($user)) $failure = "The user is already being immobilized.";
if (isTied($userId)) $failure = "You are currently being immobilized.";
if (sameUser($userId,$user)) $failure = "You may not tie up your own character.";
if (getInfo(status,users,"WHERE id='$user'") == "immobilized") $failure = "They are already immobilized.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious at the moment.";
if (getInfo(room,users,"WHERE id='$userId'") != getInfo(room,users,"WHERE id='$user'")) $failure = "The user you have selected is not in the same room as you.";
if (!$failure) {
if (!getInfo(NPC,users,"WHERE id='$user'")) {
if (getInfo(status,users,"WHERE id='$user'") == "conscious") {
if (getInfo(master,users,"WHERE id='$user'") == $userId) {
$query = "UPDATE users SET status='immobilized' WHERE id='$user'";
mysql_query($query);
$health = getInfo(health,users,"WHERE id='$user'");
if ($health < 1) {
$query = "UPDATE users SET health='1' WHERE id='$user'";
mysql_query($query);
}
$success = "You have successfully tied up ".$username.".";
$post .= "
[Tied Up ".$username."]";
} else {
$postNum = nextId(posts);
$query = "INSERT INTO immobil VALUES('$userId','$user','$postNum')";
mysql_query($query);
$success = "You have successfully attempted to tie up ".$username.".";
$post .= "
[Attempted to Tie Up ".$username."]";
}
} else {
$result = getRows(users,"WHERE room='$id' and NPC!='' and status='conscious'");
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if ((getInfo(mode,npcs,"WHERE name='$npc'") == "protect") && (getInfo("var",npcs,"WHERE name='$npc'") == $user)) $npcs[] = $npc;
}
$npc = $npcs[rand(0,count($npcs) - 1)];
if ($npc) {
$npcname = getInfo(username,users,"WHERE id='$npc'");
$query = "UPDATE users SET status='conscious' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET regeneration='' WHERE id='$user'";
mysql_query($query);
$success = "You have attempted to tie up $username, but $npcname woke them up.";
$god = "$npcname woke $username up.";
$post .= "
[Attempted to tie up $username but failed]";
$success = "You have attempted to tie up ".$username.", but ".$npcname." stopped you. In the commotion, $username was awakened.";
} else {
if (getInfo(fatigue,users,"WHERE id='$user'") >= 20) {
$fatigue = getInfo(fatigue,users,"WHERE id='$user'");
if (rand(1,75) >= getInfo(health,users,"WHERE id='$user'")) {
$query = "UPDATE users SET status='immobilized' WHERE id='$user'";
mysql_query($query);
$health = getInfo(health,users,"WHERE id='$user'");
if ($health < 1) {
$query = "UPDATE users SET health='1' WHERE id='$user'";
mysql_query($query);
}
$success = "You have successfully tied up ".$username.".";
$post .= "
[Tied Up ".$username."]";
} else {
$query = "UPDATE users SET status='conscious' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET regeneration='' WHERE id='$user'";
mysql_query($query);
$success = "You have attempted to tie up $username, but woken them up in the process.";
$post .= "
[Attempted to tie up $username but failed]";
}
} else {
$query = "UPDATE users SET status='immobilized' WHERE id='$user'";
mysql_query($query);
$health = getInfo(health,users,"WHERE id='$user'");
if ($health < 1) {
$query = "UPDATE users SET health='1' WHERE id='$user'";
mysql_query($query);
}
$success = "You have successfully tied up ".$username.".";
$post .= "
[Tied Up ".$username."]";
}
}
}
} else {
$health = getInfo(health,users,"WHERE id='$user'");
$health = round(($health / 20) * 100);
$rand = rand(1,100);
$success = "You have successfully attempted to tie up ".$username.".";
if ($rand < $health) {
$god = "$username successfully resisted.";
} else {
$god = "$username failed to resist and was immobilized.";
$query = "UPDATE users SET status='immobilized' WHERE id='$user'";
mysql_query($query);
}
}
}
}
if ($command == "free") {
$user = $_POST['freeUser'];
$username = getInfo(username,users,"WHERE id='$user'");
if (!$user) $failure = "You have not selected a user.";
if (isFighting($userId)) $failure = "You are currently in a fight.";
if (isTied($user)) $failure = "The user is currently being immobilized, but can still resist it.";
if (getInfo(status,users,"WHERE id='$user'") != "immobilized") $failure = "The user is not immobilized at the moment.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious at the moment.";
if (getInfo(room,users,"WHERE id='$userId'") != getInfo(room,users,"WHERE id='$user'")) $failure = "The user you have selected is not in the same room as you.";
if (!$failure) {
if (getInfo(health,users,"WHERE id='$user'") > 0) {
$query = "UPDATE users SET status='conscious' WHERE id='$user'";
mysql_query($query);
} else {
$query = "UPDATE users SET status='unconscious' WHERE id='$user'";
mysql_query($query);
}
$success = "You have successfully freed ".$username.".";
}
}
if ($command == "resist") {
if (!isTied($userId)) $failure = "You are not being immobilized.";
if (!$failure) {
$health = getInfo(health,users,"WHERE id='$userId'");
if ($health < 200) {
$health = round(($health / 20) * 100);
$rand = rand(1,100);
if ($rand < $health) {
$query = "DELETE FROM immobil WHERE defense='$userId'";
mysql_query($query);
$success = "You have attempted to resist and succeeded.";
$post .= "
[Succeeded in Resisting]";
} else {
$query = "UPDATE users SET status='immobilized' WHERE id='$userId'";
mysql_query($query);
$query = "DELETE FROM immobil WHERE defense='$userId'";
mysql_query($query);
$success = "You have attempted to resist and failed.";
$post .= "
[Failed to Resist]";
}
} else {
$query = "DELETE FROM immobil WHERE defense='$userId'";
mysql_query($query);
$success = "You have attempted to resist and succeeded.";
$post .= "
[Succeeded in Resisting]";
}
}
}
if ($command == "breakfree") {
if (getInfo(status,users,"WHERE id='$userId'") != "immobilized") $failure = "You are not immobilized.";
if (!$failure) {
$result = getRows(users,"WHERE room='$id'");
$empty = true;
while ($row = mysql_fetch_array($result)) {
$empty = false;
}
$health = getInfo(health,users,"WHERE id='$userId'");
$health = round(($health / 20) * 100);
if ((rand(1,100) < $health) || ($empty)) {
$query = "UPDATE users SET status='conscious' WHERE id='$userId'";
mysql_query($query);
$success = "You have attempted to break free and succeeded.";
$post .= "
[Succeeded in Breaking Free]";
} else {
$success = "You have attempted to break free and failed.";
$post .= "
[Failed to Break Free]";
}
}
}
if ($command == "givein") {
if (!isTied($userId)) $failure = "You are not being immobilized.";
if (!$failure) {
$query = "UPDATE users SET status='immobilized' WHERE id='$userId'";
mysql_query($query);
$query = "DELETE FROM immobil WHERE defense='$userId'";
mysql_query($query);
$success = "You have been immobilized.";
$post .= "
[Gave In]";
}
}
#SPELLS
if ($command == "spell_shield") {
if (!isFighting($userId)) {
$fight = $_POST['spell_shield_defense'];
} else {
$fight = getInfo(id,fights,"WHERE defense='$userId'");
}
if (!$fight) $failure = "There is no one attacking.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$offense = getInfo(offense,fights,"WHERE id='$fight'");
$defense = getInfo(defense,fights,"WHERE id='$fight'");
if ((sameUser($defense,$userId)) && ($userId != $defense)) $failure = "You may not defend your own character.";
$offensename = getInfo(username,users,"WHERE id='$offense'");
$defensename = getInfo(username,users,"WHERE id='$defense'");
if ((getInfo(room,users,"WHERE id='$offense'") != $id) || (getInfo(room,users,"WHERE id='$defense'") != $id)) $failure = "That fight is not taking place here.";
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "spellsword") $failure = "Only sorcerers and mages may use this spell.";
if (!$failure) {
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$losemana = 1 - (floor($spellcount / 100) / 10);
if ($losemana < 0.5) $losemana = 0.5;
$post .= "
[Threw up a mana shield]";
$god = "$user_name attempted to throw up a mana shield to take the damage from $offensename's attack.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$message = "Start Mana: $mana ";
$damages = getInfo(damage,fights,"WHERE id='$fight'");
$damages = explode('.',$damages);
$max = count($damages);
$unconscious = false;
for ($i = 0;$i < $max;$i++) {
$damage = $damages[$i];
if ($mana > ($damage * $losemana)) {
$message .= "Attack $i: mana > damage: $mana, $damage * $losemana = ".($damage * $losemana)." ";
$mana -= ($damage * $losemana);
$god .= " The mana shield blocked attack ".($i + 1).".";
} elseif ($mana == ($damage * $losemana)) {
$message .= "Attack $i: mana == damage: $mana, $damage * $losemana = ".($damage * $losemana)." ";
$mana = 0;
$god .= " The mana shield managed to block attack ".($i + 1).". However, it was destroyed in the process.";
} else {
$message .= "Attack $i: mana < damage: $mana, $damage * $losemana = ".($damage * $losemana)." ";
if ($mana > 0) $god .= " The mana shield was destroyed.";
$damage -= ($mana / $losemana);
$mana = 0;
$absorb = itemStat($userId,"armour",$damage);
if ($absorb == 0) {
$health = getInfo(health,users,"WHERE id='$userId'");
$health -= $damage;
$god .= " $user_name was hit for $damage damage.";
if ($health <= 0) {
$god .= " $user_name was knocked unconscious.";
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$userId'";
mysql_query($query);
$sleep = time();
$query = "UPDATE users SET sleep='$sleep' WHERE id='$userId'";
mysql_query($query);
$unconscious = true;
}
$query = "UPDATE users SET health='$health' WHERE id='$userId'";
mysql_query($query);
} elseif ($absorb > $damage) {
$god .= " $user_name was hit by attack ".($i + 1).". [$damage damage absorbed by armour]";
} else {
$damage -= $absorb;
$god .= " $user_name was hit by attack ".($i + 1)." for $damage damage. [$absorb damage absorbed by armour]";
$health = getInfo(health,users,"WHERE id='$userId'");
$health -= $damage;
$god .= " $user_name was hit for $damage damage.";
if ($health <= 0) {
$god .= " $user_name was knocked unconscious.";
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$userId'";
mysql_query($query);
$sleep = time();
$query = "UPDATE users SET sleep='$sleep' WHERE id='$userId'";
mysql_query($query);
$unconscious = true;
}
$query = "UPDATE users SET health='$health' WHERE id='$userId'";
mysql_query($query);
}
}
if ($unconscious) break;
}
$message .= " Final Mana: $mana";
sendMessage("Irshad","Manaburn Spell Shield",$message,"God");
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$success = $god;
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 1;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
$query = "DELETE FROM fights WHERE id='$fight'";
mysql_query($query);
}
}
if ($command == "spell_disarm") {
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "spellsword") $failure = "Only sorcerers and mages may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$user = $_POST['spell_disarm_user'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
$item = items($user,"weapon");
if (!$item) $failure = "That user is not currently wielding a weapon.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
if ($mana < 20) $failure = "You do not have enough mana.";
if (!$failure) {
$mana -= 20;
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$chance = (floor($spellcount / 5) + 40);
if ((getInfo(id,murders,"WHERE murderer='$user'")) && ($bonus_skill != "mage") && (getInfo(id,murders,"WHERE murderer='$userId'"))) $chance += 20;
if (rand(1,100) <= $chance) {
$overhead = getInfo(overhead,users,"WHERE id='$user'");
$clothes = getInfo(clothes,users,"WHERE id='$user'");
$behind = getInfo(behind,users,"WHERE id='$user'");
if (inArray($item,explode('.',$overhead))) {
$overhead = removeElement($item,$overhead,'.');
$query = "UPDATE users SET overhead='$overhead' WHERE id='$user'";
mysql_query($query);
} elseif (inArray($item,explode('.',$clothes))) {
$clothes = removeElement($item,$clothes,'.');
$query = "UPDATE users SET clothes='$clothes' WHERE id='$user'";
mysql_query($query);
} elseif (inArray($item,explode('.',$behind))) {
$behind = removeElement($item,$behind,'.');
$query = "UPDATE users SET behind='$behind' WHERE id='$user'";
mysql_query($query);
}
$room_inventory = getInfo(inventory,rooms,"WHERE id='$id'");
if ($room_inventory) $room_inventory .= '.'.$item;
else $room_inventory = $item;
$query = "UPDATE rooms SET inventory='$room_inventory' WHERE id='$id'";
mysql_query($query);
$query = "INSERT INTO pickups VALUES('','$item','$userId','$user')";
mysql_query($query);
$god = "$user_name attempted to disarm $username and succeeded. The weapon is now lying on the ground.";
} else {
$god = "$user_name attempted to disarm $username but failed.";
}
$success = $god;
$post .= "
[Cast Disarm on $username]";
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 1;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_unstrapArmour") {
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "spellsword") $failure = "Only sorcerers and mages may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$user = $_POST['spell_unstrapArmour_user'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
$items = items($user,"armour");
if (!$items) $failure = "That user is not currently wearing any armour.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
if ($mana < 30) $failure = "You do not have enough mana.";
if (!$failure) {
$item1 = $items[0];
$item2 = $items[1];
$mana -= 30;
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$chance = (floor($spellcount / 5) + 40);
if ((getInfo(id,murders,"WHERE murderer='$user'")) && ($bonus_skill != "mage") && (getInfo(id,murders,"WHERE murderer='$userId'"))) $chance += 20;
if (rand(1,100) <= $chance) {
$overhead = getInfo(overhead,users,"WHERE id='$user'");
$clothes = getInfo(clothes,users,"WHERE id='$user'");
$behind = getInfo(behind,users,"WHERE id='$user'");
if (inArray($item1,explode('.',$overhead))) {
$overhead = removeElement($item1,$overhead,'.');
$query = "UPDATE users SET overhead='$overhead' WHERE id='$user'";
mysql_query($query);
} elseif (inArray($item1,explode('.',$clothes))) {
$clothes = removeElement($item1,$clothes,'.');
$query = "UPDATE users SET clothes='$clothes' WHERE id='$user'";
mysql_query($query);
} elseif (inArray($item1,explode('.',$behind))) {
$behind = removeElement($item1,$behind,'.');
$query = "UPDATE users SET behind='$behind' WHERE id='$user'";
mysql_query($query);
}
if ($item2) {
if (inArray($item2,explode('.',$overhead))) {
$overhead = removeElement($item2,$overhead,'.');
$query = "UPDATE users SET overhead='$overhead' WHERE id='$user'";
mysql_query($query);
} elseif (inArray($item2,explode('.',$clothes))) {
$clothes = removeElement($item2,$clothes,'.');
$query = "UPDATE users SET clothes='$clothes' WHERE id='$user'";
mysql_query($query);
} elseif (inArray($item2,explode('.',$behind))) {
$behind = removeElement($item2,$behind,'.');
$query = "UPDATE users SET behind='$behind' WHERE id='$user'";
mysql_query($query);
}
}
$items = implode('.',$items);
$room_inventory = getInfo(inventory,rooms,"WHERE id='$id'");
if ($room_inventory) $room_inventory .= '.'.$items;
else $room_inventory = $items;
$query = "UPDATE rooms SET inventory='$room_inventory' WHERE id='$id'";
mysql_query($query);
$query = "INSERT INTO pickups VALUES('','$item1','$userId','$user')";
mysql_query($query);
if ($item2) {
$query = "INSERT INTO pickups VALUES('','$item2','$userId','$user')";
mysql_query($query);
}
$god = "$user_name attempted to cast unstrap armour on $username and succeeded. Their armour is now lying on the ground.";
} else {
$god = "$user_name attempted to cast unstrap armour on $username but failed.";
}
$success = $god;
$post .= "
[Cast Unstrap Armour on $username]";
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 1;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_armourMelt") {
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "spellsword") $failure = "Only sorcerers and mages may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$user = $_POST['spell_armourMelt_user'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
$items = items($user,"armour");
if (!$items) $failure = "That user is not currently wearing any armour.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
if ($mana < 50) $failure = "You do not have enough mana.";
if (!$failure) {
$mana -= 50;
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$min = (floor($spellcount / 5) * 5) + 50;
if ((getInfo(id,murders,"WHERE murderer='$user'")) && ($bonus_skill != "mage") && (getInfo(id,murders,"WHERE murderer='$userId'"))) $min += 50;
$max = $min + 50;
$damage = rand($min,$max);
if ($max > 500) $max = 500;
if ($min > 500) $min = 500;
for ($i = 0;$i < count($items);$i++) {
$item = $items[$i];
$health = getInfo(portions,user_items,"WHERE id='$item'");
$health -= $damage;
if ($health <= 0) {
$health = 0;
$overhead = getInfo(overhead,users,"WHERE id='$user'");
$clothes = getInfo(clothes,users,"WHERE id='$user'");
$behind = getInfo(behind,users,"WHERE id='$user'");
if (inArray($item,explode('.',$overhead))) {
$overhead = removeElement($item,$overhead,'.');
$query = "UPDATE users SET overhead='$overhead' WHERE id='$user'";
mysql_query($query);
} elseif (inArray($item,explode('.',$clothes))) {
$clothes = removeElement($item,$clothes,'.');
$query = "UPDATE users SET clothes='$clothes' WHERE id='$user'";
mysql_query($query);
} elseif (inArray($item,explode('.',$behind))) {
$behind = removeElement($item,$behind,'.');
$query = "UPDATE users SET behind='$behind' WHERE id='$user'";
mysql_query($query);
}
$inventory = getInfo(inventory,users,"WHERE id='$user'");
if ($inventory) $inventory .= '.'.$item;
else $inventory = $item;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user'";
mysql_query($query);
}
$query = "UPDATE user_items SET portions='$health' WHERE id='$item'";
mysql_query($query);
}
$god = $success = "$user_name dealt $damage damage to each piece of armour $username was wearing.";
$post .= "
[Cast Armour Melt on $username]";
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 1;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_destroyWeapon") {
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "spellsword") $failure = "Only sorcerers and mages may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$user = $_POST['spell_armourMelt_user'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
$item = items($user,"weapon");
if (!$item) $failure = "That user is not currently wielding a weapon.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
if ($mana < 40) $failure = "You do not have enough mana.";
if (!$failure) {
$mana -= 40;
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$min = (floor($spellcount / 5) * 5) + 50;
if ((getInfo(id,murders,"WHERE murderer='$user'")) && ($bonus_skill != "mage") && (getInfo(id,murders,"WHERE murderer='$userId'"))) $min += 50;
$max = $min + 50;
if ($max > 500) $max = 500;
if ($min > 500) $min = 500;
$damage = rand($min,$max);
$health = getInfo(portions,user_items,"WHERE id='$item'");
$health -= $damage;
if ($health <= 0) {
$health = 0;
$overhead = getInfo(overhead,users,"WHERE id='$user'");
$clothes = getInfo(clothes,users,"WHERE id='$user'");
$behind = getInfo(behind,users,"WHERE id='$user'");
if (inArray($item,explode('.',$overhead))) {
$overhead = removeElement($item,$overhead,'.');
$query = "UPDATE users SET overhead='$overhead' WHERE id='$user'";
mysql_query($query);
} elseif (inArray($item,explode('.',$clothes))) {
$clothes = removeElement($item,$clothes,'.');
$query = "UPDATE users SET clothes='$clothes' WHERE id='$user'";
mysql_query($query);
} elseif (inArray($item,explode('.',$behind))) {
$behind = removeElement($item,$behind,'.');
$query = "UPDATE users SET behind='$behind' WHERE id='$user'";
mysql_query($query);
}
$inventory = getInfo(inventory,users,"WHERE id='$user'");
if ($inventory) $inventory .= '.'.$item;
else $inventory = $item;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$user'";
mysql_query($query);
}
$query = "UPDATE user_items SET portions='$health' WHERE id='$item'";
mysql_query($query);
$god = $success = "$user_name dealt $damage damage to the weapon $username was weilding.";
$post .= "
[Cast Destroy Weapon on $username]";
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 1;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_powerWell") {
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "spellsword") $failure = "Only sorcerers and mages may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$amount = $_POST['spell_powerWell_amount'];
$mana = getInfo(mana,users,"WHERE id='$userId'");
if ($mana + $amount > statmax($userId)) $amount = statmax($userId) - $mana;
$health = getInfo(health,users,"WHERE id='$userId'");
$health -= round($amount * 1.5);
if ($health <= 0) $failure = "You do not have enough health.";
if (!$failure) {
$query = "UPDATE users SET health='$health' WHERE id='$userId'";
mysql_query($query);
$mana += $amount;
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$post .= "
[Cast Power Well]";
$success = "You have successfully cast power well.";
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 1;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_revitalize") {
$cast = $_POST['spell_revitalize_cast'];
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "mage") $failure = "Only mages may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$mana -= 20;
if ($mana < 0) $failure = "You do not have enough mana.";
if ($cast == "enchant") {
$item = $_POST['spell_revitalize_item'];
$itemName = getInfo(name,user_items,"WHERE id='$item'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if (!inArray($item,explode('.',$inventory))) $failure = "You are not carrying that item.";
$type = getInfo(type,user_items,"WHERE id='$item'");
if (($type != "clothing") && ($type != "armour") && ($type != "weapon") && ($type != "other") && ($type != "misc")) $failure = "You may not enchant that kind of item.";
if (!$item) $failure = "You did not select an item.";
} else {
$user = $_POST['spell_revitalize_user'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
if (!$user) $failure = "You did not select a user.";
}
if (!hasIngredients($userId,"revitalize",$item)) $failure = "You do not have the correct ingredients for this spell.";
if (!$failure) {
chargeIngredients($userId,"revitalize",$item);
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$min = (floor($spellcount / 5) * 5) + 25;
$max = $min + 25;
if ($max > 150) $max = 150;
if ($min > 150) $min = 150;
$amount = rand($min,$max);
if ($cast == "enchant") {
$query = "INSERT INTO enchantments VALUES('','revitalize','20','$amount','','')";
mysql_query($query);
$enchantment = numRows(enchantments);
$query = "UPDATE user_items SET enchantment='$enchantment' WHERE id='$item'";
mysql_query($query);
$success = "You have successfully enchanted $itemName with revitalize. Now, any user who holds this object may cast the spell with your power.";
$post .= "
[Enchanted $itemName with Revitalize]";
} else {
$fatigue = getInfo(fatigue,users,"WHERE id='$user'");
$fatigue += $amount;
if ($fatigue > 150) $fatigue = 150;
$query = "UPDATE users SET fatigue='$fatigue' WHERE id='$user'";
mysql_query($query);
$success = "You have successfully cast revitalize.";
$post .= "
[Cast Revitalize on $username]";
}
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 2;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_calmAnimals") {
$cast = $_POST['spell_calmAnimals_cast'];
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "mage") $failure = "Only mages may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$mana -= 40;
if ($mana < 0) $failure = "You do not have enough mana.";
if ($cast == "enchant") {
$item = $_POST['spell_calmAnimals_item'];
$itemName = getInfo(name,user_items,"WHERE id='$item'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if (!inArray($item,explode('.',$inventory))) $failure = "You are not carrying that item.";
$type = getInfo(type,user_items,"WHERE id='$item'");
if (($type != "clothing") && ($type != "armour") && ($type != "weapon") && ($type != "other") && ($type != "misc")) $failure = "You may not enchant that kind of item.";
if (!$item) $failure = "You did not select an item.";
}
if (!hasIngredients($userId,"calmAnimals",$item)) $failure = "You do not have the correct ingredients for this spell.";
if (!$failure) {
chargeIngredients($userId,"calmAnimals",$item);
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$duration = floor($spellcount / 5) + 8;
if ($duration > 48) $duration = 48;
if ($cast == "enchant") {
$query = "INSERT INTO enchantments VALUES('','calmAnimals','40','$duration','','')";
mysql_query($query);
$enchantment = numRows(enchantments);
$query = "UPDATE user_items SET enchantment='$enchantment' WHERE id='$item'";
mysql_query($query);
$success = "You have successfully enchanted $itemName with calm animals. Now, any user who holds this object may cast the spell with your power.";
$post .= "
[Enchanted $itemName with Calm Animals]";
} else {
$result = getRows(users,"WHERE status!='dead' and status!='unconscious' and room='$id' and NPC!=''");
$time = time() + ($duration * 3600);
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if (getInfo(animal,npcs,"WHERE name='$npc'")) {
$query = "UPDATE npcs SET effect='calm' WHERE name='$npc'";
mysql_query($query);
$query = "UPDATE npcs SET time='$time' WHERE name='$npc'";
mysql_query($query);
}
}
$success = "You have successfully cast calm animals.";
$post .= "
[Cast Calm Animals]";
}
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 3;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_divineIntervention") {
$cast = $_POST['spell_divineIntervention_cast'];
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "mage") $failure = "Only mages may use this spell.";
if (!hasIngredients($userId,"divineIntervention")) $failure = "You do not have the correct ingredients for this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$mana -= 100;
if ($mana < 0) $failure = "You do not have enough mana.";
if ($cast == "enchant") {
$item = $_POST['spell_divineIntervention_item'];
$itemName = getInfo(name,user_items,"WHERE id='$item'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if (!inArray($item,explode('.',$inventory))) $failure = "You are not carrying that item.";
$type = getInfo(type,user_items,"WHERE id='$item'");
if (($type != "clothing") && ($type != "armour") && ($type != "weapon") && ($type != "other") && ($type != "misc")) $failure = "You may not enchant that kind of item.";
if (!$item) $failure = "You did not select an item.";
} else {
$user = $_POST['spell_divineIntervention_user'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
if (!getInfo(transformed,users,"WHERE id='$user'")) $failure = "That user is not in a transformed state.";
if (!hasHair($userId,$user)) $failure = "You are not carrying that user's hair, and therefore cannot link this very complex spell to them.";
if (!$user) $failure = "You did not select a user.";
}
if (!hasIngredients($userId,"divineIntervention",$item)) $failure = "You do not have the correct ingredients for this spell.";
if (!$failure) {
chargeIngredients($userId,"divineIntervention",$item);
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$chance = floor($spellcount / 5) + 40;
if ($chance > 100) $chance = 100;
$posts = floor($spellcount / 10) + 10;
if ($posts > 40) $posts = 40;
if ($cast == "enchant") {
$query = "INSERT INTO enchantments VALUES('','divineIntervention','100','$posts','$chance','')";
mysql_query($query);
$enchantment = numRows(enchantments);
$query = "UPDATE user_items SET enchantment='$enchantment' WHERE id='$item'";
mysql_query($query);
$success = "You have successfully enchanted $itemName with divine intervention. Now, any user who holds this object may cast the spell with your power.";
$post .= "
[Enchanted $itemName with Revitalize]";
} else {
chargeHair($userId,$user);
if (rand(1,100) <= $chance) {
$query = "UPDATE users SET transformed='' WHERE id='$user'";
mysql_query($query);
$query = "INSERT INTO spells VALUES('','divineIntervention','$user','$posts','')";
mysql_query($query);
$success = "You have successfully cast divine intervention.";
$god = "$user_name attempted to cast divine intervention on $username and successfully forced them back into their untransformed state.";
} else {
$success = "You have failed to cast divine intervention.";
$god = "$user_name attempted to cast divine intervention on $username but failed to force them back into their untransformed state.";
}
$post .= "
[Tried to Cast Divine Intervention on $username]";
}
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 4;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_protection") {
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "mage") $failure = "Only mages may use this spell.";
if (!hasIngredients($userId,"protection")) $failure = "You do not have the correct ingredients for this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$mana -= 60;
if ($mana < 0) $failure = "You do not have enough mana.";
$item = $_POST['spell_protection_item'];
$itemName = getInfo(name,user_items,"WHERE id='$item'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if (!inArray($item,explode('.',$inventory))) $failure = "You are not carrying that item.";
$type = getInfo(type,user_items,"WHERE id='$item'");
if (($type != "clothing") && ($type != "armour") && ($type != "weapon")) $failure = "You may not enchant that kind of item.";
if (!$item) $failure = "You did not select an item.";
if (!hasIngredients($userId,"protection",$item)) $failure = "You do not have the correct ingredients for this spell.";
if (!$failure) {
chargeIngredients($userId,"protection",$item);
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$chance = floor($spellcount / 5) + 60;
if ($chance > 100) $chance = 100;
$query = "INSERT INTO enchantments VALUES('','protection','60','$chance','','')";
mysql_query($query);
$enchantment = numRows(enchantments);
$query = "UPDATE user_items SET enchantment='$enchantment' WHERE id='$item'";
mysql_query($query);
$success = "You have successfully enchanted $itemName with protection. Now, any user who wears this item will have a $chance% chance of blocking any curse placed on them.";
$post .= "
[Enchanted $itemName with Protection]";
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 3;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_trace") {
$cast = $_POST['spell_trace_cast'];
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if (($bonus_skill != "mage") && ($bonus_skill != "sorcerer")) $failure = "Only sorcerers and mages may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$mana -= 30;
if ($mana < 0) $failure = "You do not have enough mana.";
if ($cast == "enchant") {
$item = $_POST['spell_trace_item'];
$itemName = getInfo(name,user_items,"WHERE id='$item'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if (!inArray($item,explode('.',$inventory))) $failure = "You are not carrying that item.";
$type = getInfo(type,user_items,"WHERE id='$item'");
if (($type != "clothing") && ($type != "armour") && ($type != "weapon") && ($type != "other") && ($type != "misc")) $failure = "You may not enchant that kind of item.";
if (!$item) $failure = "You did not select an item.";
} else {
$username = $_POST['spell_trace_user'];
$user = getInfo(id,users,"WHERE username='$user'");
if (!hasHair($userId,$user)) $failure = "You do not have this character's hair, and therefore, the spell has no way of knowing who it is you wish to search for.";
if (!$user) $failure = "That user does not exist.";
}
if (!hasIngredients($userId,"trace",$item)) $failure = "You do not have the correct ingredients for this spell.";
if (!$failure) {
chargeIngredients($userId,"trace",$item);
chargeHair($userId,$user);
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$chance = floor($spellcount / 3) + 70;
if ($chance > 100) $chance = 100;
$amount = rand($min,$max);
if ($cast == "enchant") {
$query = "INSERT INTO enchantments VALUES('','trace','30','$chance','','')";
mysql_query($query);
$enchantment = numRows(enchantments);
$query = "UPDATE user_items SET enchantment='$enchantment' WHERE id='$item'";
mysql_query($query);
$success = "You have successfully enchanted $itemName with trace. Now, any user who holds this object may cast the spell with your power.";
$post .= "
[Enchanted $itemName with Trace]";
} else {
if (rand(1,100) <= $chance) {
$place = getInfo(location,users,"WHERE id='$user'");
$town = getInfo(town,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$userId'")) {
if ($town) {
$location = "travelling on the ".getInfo(name,places,"WHERE id='$place'");
} else {
$location = "somewhere in ".getInfo(name,places,"WHERE id='$place'").", ".getInfo(name,towns,"WHERE id='$town'");
}
} else {
$destination = getInfo(destination,travels,"WHERE user='$user'");
$location = "travelling towards ".getInfo(name,towns,"WHERE id='$destination'");
}
$god = "$user_name cast trace in order to search for $username. The spell revealed that $username is $location.";
} else {
$god = "$user_name cast trace in order to search for $username. The spell, however, failed to show any information of relevance.";
}
$success = "You have successfully attempted to cast trace.";
$post .= "
[Cast Trace to search for $username]";
}
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 2;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_insomniac") {
$cast = $_POST['spell_insomniac_cast'];
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "sorcerer") $failure = "Only sorcerers may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$mana -= 25;
if ($mana < 0) $failure = "You do not have enough mana.";
if ($cast == "enchant") {
$item = $_POST['spell_insomniac_item'];
$itemName = getInfo(name,user_items,"WHERE id='$item'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if (!inArray($item,explode('.',$inventory))) $failure = "You are not carrying that item.";
$type = getInfo(type,user_items,"WHERE id='$item'");
if (($type != "clothing") && ($type != "armour") && ($type != "weapon") && ($type != "other") && ($type != "misc")) $failure = "You may not enchant that kind of item.";
if (!$item) $failure = "You did not select an item.";
} else {
$user = $_POST['spell_insomniac_user'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
if (!$user) $failure = "You did not select a user.";
}
if (!hasIngredients($userId,"insomniac",$item)) $failure = "You do not have the correct ingredients for this spell.";
if (!$failure) {
chargeIngredients($userId,"insomniac",$item);
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$min = (floor($spellcount / 5) * 5) + 25;
$max = $min + 25;
if ($max > 150) $max = 150;
if ($min > 150) $min = 150;
$amount = rand($min,$max);
if ($cast == "enchant") {
$query = "INSERT INTO enchantments VALUES('','insomniac','25','$amount','','')";
mysql_query($query);
$enchantment = numRows(enchantments);
$query = "UPDATE user_items SET enchantment='$enchantment' WHERE id='$item'";
mysql_query($query);
$success = "You have successfully enchanted $itemName with insomniac. Now, any user who holds this object may cast the spell with your power.";
$post .= "
[Enchanted $itemName with Insomniac]";
} else {
$query = "INSERT INTO spells VALUES('','insomniac','$user','$amount','')";
mysql_query($query);
$success = "You have successfully cast insomniac.";
$post .= "
[Cast Insomniac on $username]";
}
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 2;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_enrageBeasts") {
$cast = $_POST['spell_enrageBeasts_cast'];
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "sorcerer") $failure = "Only sorcerers may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$mana -= 45;
if ($mana < 0) $failure = "You do not have enough mana.";
if ($cast == "enchant") {
$item = $_POST['spell_enrageBeasts_item'];
$itemName = getInfo(name,user_items,"WHERE id='$item'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if (!inArray($item,explode('.',$inventory))) $failure = "You are not carrying that item.";
$type = getInfo(type,user_items,"WHERE id='$item'");
if (($type != "clothing") && ($type != "armour") && ($type != "weapon") && ($type != "other") && ($type != "misc")) $failure = "You may not enchant that kind of item.";
if (!$item) $failure = "You did not select an item.";
}
if (!hasIngredients($userId,"enrageBeasts",$item)) $failure = "You do not have the correct ingredients for this spell.";
if (!$failure) {
chargeIngredients($userId,"enrageBeasts",$item);
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$duration = floor($spellcount / 5) + 8;
if ($duration > 48) $duration = 48;
if ($cast == "enchant") {
$query = "INSERT INTO enchantments VALUES('','enrageBeasts','45','$duration','','')";
mysql_query($query);
$enchantment = numRows(enchantments);
$query = "UPDATE user_items SET enchantment='$enchantment' WHERE id='$item'";
mysql_query($query);
$success = "You have successfully enchanted $itemName with calm enrage beasts. Now, any user who holds this object may cast the spell with your power.";
$post .= "
[Enchanted $itemName with Enrage Beasts]";
} else {
$result = getRows(users,"WHERE status!='dead' and status!='unconscious' and room='$id' and NPC!=''");
$time = time() + ($duration * 3600);
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if (getInfo(animal,npcs,"WHERE name='$npc'")) {
$query = "UPDATE npcs SET effect='enrage' WHERE name='$npc'";
mysql_query($query);
$query = "UPDATE npcs SET time='$time' WHERE name='$npc'";
mysql_query($query);
}
}
$success = "You have successfully cast enrage beasts.";
$post .= "
[Cast Enrage Beasts]";
}
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 3;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_demonicPossession") {
$cast = $_POST['spell_demonicPossession_cast'];
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "sorcerer") $failure = "Only sorcerers may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$mana -= 100;
if ($mana < 0) $failure = "You do not have enough mana.";
if ($cast == "enchant") {
$item = $_POST['spell_demonicPossession_item'];
$itemName = getInfo(name,user_items,"WHERE id='$item'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if (!inArray($item,explode('.',$inventory))) $failure = "You are not carrying that item.";
$type = getInfo(type,user_items,"WHERE id='$item'");
if (($type != "clothing") && ($type != "armour") && ($type != "weapon") && ($type != "other") && ($type != "misc")) $failure = "You may not enchant that kind of item.";
if (!$item) $failure = "You did not select an item.";
} else {
$user = $_POST['spell_demonicPossession_user'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
if (!getInfo(transformation,users,"WHERE id='$user'")) $failure = "That user does not have a transformed state.";
if (!hasHair($userId,$user)) $failure = "You are not carrying that user's hair, and therefore cannot link this very complex spell to them.";
if (!$user) $failure = "You did not select a user.";
}
if (!hasIngredients($userId,"demonicPossession",$item)) $failure = "You do not have the correct ingredients for this spell.";
if (!$failure) {
chargeIngredients($userId,"demonicPossession",$item);
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$chance = floor($spellcount / 5) + 40;
if ($chance > 100) $chance = 100;
$posts = floor($spellcount / 10) + 10;
if ($posts > 40) $posts = 40;
if ($cast == "enchant") {
$query = "INSERT INTO enchantments VALUES('','demonicPossession','100','$posts','$chance','')";
mysql_query($query);
$enchantment = numRows(enchantments);
$query = "UPDATE user_items SET enchantment='$enchantment' WHERE id='$item'";
mysql_query($query);
$success = "You have successfully enchanted $itemName with demonic possession. Now, any user who holds this object may cast the spell with your power.";
$post .= "
[Enchanted $itemName with Demonic Possession]";
} else {
chargeHair($userId,$user);
if (rand(1,100) <= $chance) {
$transformations = getInfo(transformations,users,"WHERE id='$user'");
$transformations = explode('.',$transformations);
$transformation = $transformations[rand(0,count($transformations) - 1)];
$query = "UPDATE users SET transformed='$transformation' WHERE id='$user'";
mysql_query($query);
$query = "INSERT INTO spells VALUES('','demonicPossession','$user','$posts','')";
mysql_query($query);
$success = "You have successfully cast demonic possession";
$god = "$user_name attempted to cast demonic possession on $username and successfully forced into their transformed state.";
} else {
$success = "You have failed to cast demonic possession.";
$god = "$user_name attempted to cast demonic possession on $username but failed to force them into their transformed state.";
}
$post .= "
[Tried to Cast Divine Intervention on $username]";
}
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 4;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "spell_raiseTheDead") {
$cast = $_POST['spell_raiseTheDead_cast'];
$bonus_skill = getInfo(bonus,users,"WHERE id='$userId'");
if ($bonus_skill != "sorcerer") $failure = "Only sorcerers may use this spell.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$mana -= 100;
if ($mana < 0) $failure = "You do not have enough mana.";
if ($cast == "enchant") {
$item = $_POST['spell_raiseTheDead_item'];
$itemName = getInfo(name,user_items,"WHERE id='$item'");
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if (!inArray($item,explode('.',$inventory))) $failure = "You are not carrying that item.";
$type = getInfo(type,user_items,"WHERE id='$item'");
if (($type != "clothing") && ($type != "armour") && ($type != "weapon") && ($type != "other") && ($type != "misc")) $failure = "You may not enchant that kind of item.";
if (!$item) $failure = "You did not select an item.";
} else {
$user = $_POST['spell_raiseTheDead_user'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
if (getInfo(dismembered,users,"WHERE id='$user'") == 24) $failure = "That user was already resurrected and may not be resurrected again.";
if (!$user) $failure = "You did not select a user.";
}
if (!hasIngredients($userId,"raiseTheDead",$item)) $failure = "You do not have the correct ingredients for this spell.";
if (!$failure) {
chargeIngredients($userId,"raiseTheDead",$item);
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
$spellcount = getInfo(spellcasting,users,"WHERE id='$userId'");
$chance = floor($spellcount / 5) + 40;
if ($chance > 100) $chance = 100;
$health = (floor($spellcount / 50) * 25) + 25;
if ($health > 150) $health = 150;
if ($cast == "enchant") {
$query = "INSERT INTO enchantments VALUES('','raiseTheDead','100','$health','$chance','')";
mysql_query($query);
$enchantment = numRows(enchantments);
$query = "UPDATE user_items SET enchantment='$enchantment' WHERE id='$item'";
mysql_query($query);
$success = "You have successfully enchanted $itemName with raise the dead. Now, any user who holds this object may cast the spell with your power.";
$post .= "
[Enchanted $itemName with Raise the Dead]";
} else {
if (rand(1,100) <= $chance) {
$query = "INSERT INTO npcs VALUES('','$user','','','','$health','','','$userId','follow','fight','nothing','','24','','','','','','','','','')";
mysql_query($query);
$query = "UPDATE users SET status='conscious' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET health='$health' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET NPC='$userId' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET master='$userId' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET saturation='0.3' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET hue='80' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET species='Undead' WHERE id='$user'";
mysql_query($query);
$success = "You have successfully cast raise the dead";
$god = "$user_name attempted to cast raise the dead on $username and successfully reanimated their corpse.";
} else {
$success = "You have failed to cast raise the dead.";
$god = "$user_name attempted to cast raise the dead on $username but failed to animate their corpse.";
}
$post .= "
[Tried to Cast Raise the Dead on $username]";
}
$spell_count = getInfo(spellcasting,users,"WHERE id='$userId'");
$spell_count += 3;
$query = "UPDATE users SET spellcasting='$spell_count' WHERE id='$userId'";
mysql_query($query);
}
}
if ($command == "cast") {
$item = $_POST['cast_item'];
$enchantment = getInfo(enchantment,user_items,"WHERE id='$item'");
$var1 = getInfo(var1,enchantments,"WHERE id='$enchantment'");
$var2 = getInfo(var2,enchantments,"WHERE id='$enchantment'");
$var3 = getInfo(var3,enchantments,"WHERE id='$enchantment'");
$manaCost = getInfo(mana,enchantments,"WHERE id='$enchantment'");
$spell = getInfo(spell,enchantments,"WHERE id='$enchantment'");
if ($spell == "revitalize") {
$user = $_POST['cast_revitalize_'.$item.'_user'];
if (!$user) $failure = "You did not select a user.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
$amount = $var1;
}
if ($spell == "calmAnimals") {
$duration = $var1;
}
if ($spell == "divineIntervention") {
$user = $_POST['cast_divineIntervention_'.$item.'_user'];
if (!getInfo(transformed,users,"WHERE id='$user'")) $failure = "That user is not in a transformed state.";
if (!hasHair($userId,$user)) $failure = "You are not carrying that user's hair, and therefore cannot link this very complex spell to them.";
if (!$user) $failure = "You did not select a user.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
$posts = $var1;
$chance = $var2;
}
if ($spell == "trace") {
$username = $_POST['cast_trace_'.$item.'_user'];
$user = getInfo(id,users,"WHERE username='$username'");
if (!hasHair($userId,$user)) $failure = "You are not carrying that user's hair, and therefore cannot link this very complex spell to them.";
if (!$user) $failure = "You did not select a user.";
$chance = $var1;
}
if ($spell == "insomniac") {
$user = $_POST['cast_insomniac_'.$item.'_user'];
if (!$user) $failure = "You did not select a user.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
$amount = $var1;
}
if ($spell == "enrageBeasts") {
$duration = $var1;
}
if ($spell == "demonicPossession") {
$user = $_POST['cast_demonicPossession_'.$item.'_user'];
if (!getInfo(transformation,users,"WHERE id='$user'")) $failure = "That user does not have a transformed state.";
if (!hasHair($userId,$user)) $failure = "You are not carrying that user's hair, and therefore cannot link this very complex spell to them.";
if (!$user) $failure = "You did not select a user.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
$posts = $var1;
$chance = $var2;
}
if ($spell == "raiseTheDead") {
$user = $_POST['cast_raiseTheDead_'.$item.'_user'];
if (!$user) $failure = "You did not select a user.";
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
if (getInfo(dismembered,users,"WHERE id='$user'") == 24) $failure = "That user was already resurrected and may not be resurrected again.";
$health = $var1;
$chance = $var2;
}
$username = getInfo(username,users,"WHERE id='$user'");
if (!inArray($item,explode('.',getInfo(inventory,users,"WHERE id='$userId'").'.'.getInfo(overhead,users,"WHERE id='$userId'").'.'.getInfo(clothes,users,"WHERE id='$userId'").'.'.getInfo(behind,users,"WHERE id='$userId'")))) $failure = "You are not carrying that item.";
if ((!$enchantment) || (!$spell)) $failure = "That item is not enchanted.";
if (!$item) $failure = "You have not selected an item.";
$mana = getInfo(mana,users,"WHERE id='$userId'");
$mana -= $manaCost;
if ($mana < 0) $failure = "You do not have enough mana to cast that.";
if (!$failure) {
$query = "UPDATE users SET mana='$mana' WHERE id='$userId'";
mysql_query($query);
if ($spell == "revitalize") {
$fatigue = getInfo(fatigue,users,"WHERE id='$user'");
$fatigue += $amount;
if ($fatigue > 150) $fatigue = 150;
$query = "UPDATE users SET fatigue='$fatigue' WHERE id='$user'";
mysql_query($query);
$success = "You have successfully cast revitalize.";
$post .= "
[Cast Revitalize on $username]";
}
if ($spell == "calmAnimals") {
$result = getRows(users,"WHERE status!='dead' and status!='unconscious' and room='$id' and NPC!=''");
$time = time() + ($duration * 3600);
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if (getInfo(animal,npcs,"WHERE name='$npc'")) {
$query = "UPDATE npcs SET effect='calm' WHERE name='$npc'";
mysql_query($query);
$query = "UPDATE npcs SET time='$time' WHERE name='$npc'";
mysql_query($query);
}
}
$success = "You have successfully cast calm animals.";
$post .= "
[Cast Calm Animals]";
}
if ($spell == "divineIntervention") {
chargeHair($userId,$user);
if (rand(1,100) <= $chance) {
$query = "UPDATE users SET transformed='' WHERE id='$user'";
mysql_query($query);
$query = "INSERT INTO spells VALUES('','divineIntervention','$user','$posts','')";
mysql_query($query);
$success = "You have successfully cast divine intervention.";
$god = "$user_name attempted to cast divine intervention on $username and successfully forced them back into their untransformed state.";
} else {
$success = "You have failed to cast divine intervention.";
$god = "$user_name attempted to cast divine intervention on $username but failed to force them back into their untransformed state.";
}
$post .= "
[Tried to Cast Divine Intervention on $username]";
}
if ($spell == "trace") {
if (rand(1,100) <= $chance) {
$place = getInfo(location,users,"WHERE id='$user'");
$town = getInfo(town,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$userId'")) {
if ($town) {
$location = "somewhere in ".getInfo(name,places,"WHERE id='$place'").", ".getInfo(name,towns,"WHERE id='$town'");
} else {
$location = "travelling on the ".getInfo(name,places,"WHERE id='$place'");
}
} else {
$destination = getInfo(destination,travels,"WHERE user='$user'");
$location = "travelling towards ".getInfo(name,towns,"WHERE id='$destination'");
}
$god = "$user_name cast trace in order to search for $username. The spell revealed that $username is $location.";
} else {
$god = "$user_name cast trace in order to search for $username. The spell, however, failed to show any information of relevance.";
}
$success = "You have successfully attempted to cast trace.";
$post .= "
[Cast Trace to search for $username]";
}
if ($spell == "insomniac") {
$query = "INSERT INTO spells VALUES('','insomniac','$user','$amount','')";
mysql_query($query);
$success = "You have successfully cast insomniac.";
$post .= "
[Cast Insomniac on $username]";
}
if ($spell == "enrageBeasts") {
$result = getRows(users,"WHERE status!='dead' and status!='unconscious' and room='$id' and NPC!=''");
$time = time() + ($duration * 3600);
while ($row = mysql_fetch_array($result)) {
$npc = $row['id'];
if (getInfo(animal,npcs,"WHERE name='$npc'")) {
$query = "UPDATE npcs SET effect='enrage' WHERE name='$npc'";
mysql_query($query);
$query = "UPDATE npcs SET time='$time' WHERE name='$npc'";
mysql_query($query);
}
}
$success = "You have successfully cast enrage beasts.";
$post .= "
[Cast Enrage Beasts]";
}
if ($spell == "demonicPossession") {
chargeHair($userId,$user);
if (rand(1,100) <= $chance) {
$transformations = getInfo(transformations,users,"WHERE id='$user'");
$transformations = explode('.',$transformations);
$transformation = $transformations[rand(0,count($transformations) - 1)];
$query = "UPDATE users SET transformed='$transformation' WHERE id='$user'";
mysql_query($query);
$query = "INSERT INTO spells VALUES('','demonicPossession','$user','$posts','')";
mysql_query($query);
$success = "You have successfully cast demonic possession";
$god = "$user_name attempted to cast demonic possession on $username and successfully forced into their transformed state.";
} else {
$success = "You have failed to cast demonic possession.";
$god = "$user_name attempted to cast demonic possession on $username but failed to force them into their transformed state.";
}
$post .= "
[Tried to Cast Divine Intervention on $username]";
}
if ($spell == "raiseTheDead") {
if (rand(1,100) <= $chance) {
$query = "INSERT INTO npcs VALUES('','$user','','','','$health','','','$userId','follow','fight','nothing','','24','','','','','','','','','')";
mysql_query($query);
$query = "UPDATE users SET status='conscious' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET health='$health' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET NPC='$userId' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET master='$userId' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET saturation='0.3' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET hue='80' WHERE id='$user'";
mysql_query($query);
$query = "UPDATE users SET species='Undead' WHERE id='$user'";
mysql_query($query);
$success = "You have successfully cast raise the dead";
$god = "$user_name attempted to cast raise the dead on $username and successfully reanimated their corpse.";
} else {
$success = "You have failed to cast raise the dead.";
$god = "$user_name attempted to cast raise the dead on $username but failed to animate their corpse.";
}
$post .= "
[Tried to Cast Raise the Dead on $username]";
}
$query = "DELETE FROM enchantments WHERE id='$enchantment'";
mysql_query($query);
$query = "UPDATE user_items SET enchantment='' WHERE id='$item'";
mysql_query($query);
}
}
if ($command == "takehair") {
$user = $_POST['takehair_user'];
$username = getInfo(username,users,"WHERE id='$user'");
if (getInfo(room,users,"WHERE id='$user'") != $id) $failure = "That user is not in this room.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not fully conscious.";
if (isFighting($userId)) $failure = "You are currently fighting.";
if (isTied($userId)) $failure = "You are currently being immobilized.";
if (!$failure) {
$hair = createItem(2390,1);
$query = "UPDATE user_items SET stat='$user' WHERE id='$hair'";
mysql_query($query);
$inventory = getInfo(inventory,users,"WHERE id='$userId'");
if ($inventory) $inventory .= '.'.$hair;
else $inventory = $hair;
$query = "UPDATE users SET inventory='$inventory' WHERE id='$userId'";
mysql_query($query);
$success = "You have successfully plucked a few strands of hair from $username's body.";
$post .= "
[Plucked a few strands of hair from $username's head]";
}
}
}
}
$poison = getInfo(damage,poison,"WHERE user='$userId'");
if ($poison) {
$health = getInfo(health,users,"WHERE id='$userId'");
$health -= $poison;
if ($health <= 0) {
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$regen = time() + (3600 * 12);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$userId'";
mysql_query($query);
$sleep = time();
$query = "UPDATE users SET sleep='$sleep' WHERE id='$userId'";
mysql_query($query);
}
$query = "UPDATE users SET health='$health' WHERE id='$userId'";
mysql_query($query);
$success .= " You have lost ".$poison." health from poison damage.";
if ($health <= 0) {
$success .= " You are now unconscious.";
$post .= "
[Is now unconscious due to poisoning]";
}
if (getInfo(turns,poison,"WHERE user='$userId'") <= 1) {
$query = "DELETE FROM poison WHERE user='$userId'";
mysql_query($query);
} else {
$turns = getInfo(turns,poison,"WHERE user='$userId'");
$turns--;
$query = "UPDATE poison SET turns='$turns' WHERE user='$userId'";
mysql_query($query);
}
}
if (!$failure) {
if (!$ooc) {
if (getInfo(id,spells,"WHERE (spell='divineIntervention' or spell='demonicPossession') and user='$userId'")) {
$spell = getInfo(id,spells,"WHERE spell='divineIntervention' and user='$userId'");
$posts = getInfo(var1,spells,"WHERE id='$spell'");
$posts--;
if ($posts <= 0) {
$query = "DELETE FROM spells WHERE id='$spell'";
} else {
$query = "UPDATE spells SET var1='$posts' WHERE id='$spell'";
}
mysql_query($query);
}
$fatigue = getInfo(fatigue,users,"WHERE id='$userId'");
if (($command == "attack") || ($command == "counter") || ($command == "counterattack")) {
$fatigue -= 2;
}
$fatigue -= 1;
if (getInfo(id,fires,"WHERE room='$id'")) $fatigue -=4;
if (getInfo(id,spells,"WHERE spell='insomniac' and user='$userId'")) {
$spell = getInfo(id,spells,"WHERE spell='divineIntervention' and user='$userId'");
$posts = getInfo(var1,spells,"WHERE id='$spell'");
$posts--;
if ($posts <= 0) {
$query = "DELETE FROM spells WHERE id='$spell'";
} else {
$query = "UPDATE spells SET var1='$posts' WHERE id='$spell'";
}
mysql_query($query);
} elseif ($fatigue <= 0) {
if ((getInfo(status,users,"WHERE id='$userId'") == "conscious") && (!getInfo(offense,fights,"WHERE offense='$userId' or defense='$userId'"))) {
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$regen = time() + (12 * 3600);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$userId'";
mysql_query($query);
$sleep = time();
$query = "UPDATE users SET sleep='$sleep' WHERE id='$userId'";
mysql_query($query);
$fatigue = 0;
} else {
$fatigue = 1;
}
}
$query = "UPDATE users SET fatigue='$fatigue' WHERE id='$userId'";
mysql_query($query);
$hunger = getInfo(hunger,users,"WHERE id='$userId'");
$hunger -= 1;
if ($hunger <= 0) {
$hunger = 0;
$health = getInfo(health,users,"WHERE id='$userId'");
$health -= 5;
if ($health <= 0) {
$health = 0;
$query = "UPDATE users SET status='unconscious' WHERE id='$userId'";
mysql_query($query);
$regen = time() + (3600 * 6);
$query = "UPDATE users SET regeneration='$regen' WHERE id='$userId'";
mysql_query($query);
}
$query = "UPDATE users SET health='$health' WHERE id='$userId'";
mysql_query($query);
}
$query = "UPDATE users SET hunger='$hunger' WHERE id='$userId'";
mysql_query($query);
}
if (!$success) $success = "You have posted successfully.";
$query = "DELETE FROM holds WHERE user2='$userId'";
mysql_query($query);
post($userId,$post,$id,$ooc,$command,$whisper);
if ((!getInfo("class",users,"WHERE id='$userId'")) && (getInfo(bonus,users,"WHERE id='$userId'")) && (!$ooc) && (numRowsConditions(posts,"WHERE username='$userId' && ooc=''") >= 150)) {
$query = "UPDATE users SET class='*' WHERE id='$userId'";
mysql_query($query);
sendMessage($user_name,"Congratulations!","You have posted over 150 times. Because of this, you will now be able to upgrade your bonus skill to a character class. It is not mandatory to upgrade, and it would likely be a wise choice not to if you find that none of the upgrades suit your character. You can upgrade by clicking Edit Profile.","God");
}
//stealth
if (getInfo(mode,users,"WHERE id='$userId'") == "stealth") {
$unstealth = false;
if (($command) && (($command == "beat") || ($command == "capture") || ($command == "loot") || ($command == "dismember") || ($command == "breakdown") || ($command == "throwWeapon") || ($command == "suicide"))) $unstealth = true;
if (!$unstealth) {
$logged = time() - (7 * 24 * 3600);
$people = numRowsConditions(users,"WHERE room='$id' and status='conscious' and (logged>='$logged' or NPC!='')");
if ($people <= 5) $chance = 25;
elseif ($people <= 10) $chance = 20;
elseif ($people <= 15) $chance = 15;
else $chance = 10;
$result = getRows(users,"WHERE room='$id' and (status='conscious' or status='immobilized') and (logged>='$logged' or NPC!='')");
while ($row = mysql_fetch_array($result)) {
if (rand(1,100) <= $chance) {
$unstealth = true;
break;
}
}
}
if ($unstealth) {
$query = "UPDATE users SET mode='' WHERE id='$userId'";
mysql_query($query);
$success .= ' You have been spotted.';
}
}
if ($command) {
$result_search = getRows(users,"WHERE status='conscious' and NPC!='' and (room='$id' or id='$user')");
while ($row_search = mysql_fetch_array($result_search)) {
$npc = $row_search['id'];
if ((!getInfo(animal,npcs,"WHERE name='$npc'")) && (getInfo(id,npc_citizens,"WHERE npc='$npc'"))) {
$intox = $row_search['dex'];
$health = $row_search['health'];
$intox *= 2;
$intox_chance = 100 - $intox;
$rand2 = rand(1,100);
if (($rand2 <= $intox_chance) && ($rand2 <= $health)) {
if ($command == "attack") {
if (!getInfo(animal,npcs,"WHERE name='$user'")) {
remember_action($npc,$userId,$user,$command);
}
}
if ($command == "beat") {
if (!getInfo(animal,npcs,"WHERE name='$user'")) {
remember_action($npc,$userId,$user,$command);
}
}
if ($command == "slay") {
if (!getInfo(animal,npcs,"WHERE name='$user'")) {
remember_action($npc,$userId,$user,$command);
}
}
if ($command == "capture") {
if (!getInfo(animal,npcs,"WHERE name='$user'")) {
remember_action($npc,$userId,$user,$command);
}
}
if ($command == "loot") {
remember_action($npc,$userId,$user,$command);
}
if ($command == "dismember") {
if (!getInfo(NPC,users,"WHERE id='$user'")) {
remember_action($npc,$userId,$user,$command);
}
}
if ($pickpocketfail) {
remember_action($npc,$userId,$user,$command);
}
if ($command == "startfire") {
remember_action($npc,$userId,$id,$command);
}
if ($command == "breakdown") {
remember_action($npc,$userId,$door,$command);
}
if ($command == "lockpick") {
remember_action($npc,$userId,$door,$command);
}
if ($command == "throwWeapon") {
remember_action($npc,$userId,$user,$command);
}
if ($command == "suicide") {
remember_action($npc,$userId,$suicide,$command);
}
if (fnmatch("spell_*",$command)) {
remember_action($npc,$userId,"",$command);
}
$rand = rand(1,100);
if ($rand <= 5) {
if ($command == "pay") {
remember_action($npc,$userId,$user,$command);
}
}
$rand = rand(1,100);
if ($rand <= 5) {
if ($command == "give") {
remember_action($npc,$userId,$user,$command);
}
}
$rand = rand(1,100);
if ($rand <= 20) {
if ($command == "carry") {
remember_action($npc,$userId,$user,$command);
}
}
}
}
}
}
if (getInfo(user,expirations,"WHERE user='$userId'")) {
$query = "DELETE FROM expirations WHERE user='$userId'";
mysql_query($query);
}
if ($npc_response) post($response_npc,$npc_response,$id);
if ($failedCounter) {
post($userId,$failedCounter,$id,"failed counter");
}
if ((getInfo(id,fires,"WHERE room='$id' and permenant!=''")) && (!$ooc)) {
$health = getInfo(health,users,"WHERE id='$userId'");
$health -= rand(1,getInfo(permanent,fires,"WHERE room='$id'"));
if ($health <= 0) {
$health = 0;
$regen = time() + (3600 * 6);
$sleep = time();
$query = "UPDATE users SET status='unconscious', regeneration='$regen', sleep='$sleep' WHERE id='$userId'";
mysql_query($query);
if ((!$god) && (!$godPost)){
post(1,"$username passed out from the intense heat of the fire.",$room,"ooc");
} else {
$god .= " $username passed out from the intense heat of the fire.";
}
}
$query = "UPDATE users SET health='$health' WHERE id='$userId'";
mysql_query($query);
}
if (!$godPost) $godPost = $id;
if ($god) {
post(1,$god,$godPost,"ooc");
}
if (!$ooc) {
$query = "DELETE FROM pickups WHERE user='$userId'";
mysql_query($query);
if (getInfo(master,users,"WHERE id='$userId'")) $moneyUser = getInfo(master,users,"WHERE id='$userId'");
else $moneyUser = $userId;
$placeMoney = getInfo(money,places,"WHERE id='$buildingId'");
$placeMoney++;
$query = "UPDATE places SET money='$placeMoney' WHERE id='$buildingId'";
mysql_query($query);
$maxPost = getInfo(post,general);
$count = count(explode(' ',$post));
$count -= 30;
$postMoney = truncate($count / 5);
if (getInfo(bonus,users,"WHERE id='$userId'") == "savvy") $maxMoney = 24;
else $maxMoney = 14;
if ($postMoney > $maxMoney) $postMoney = $maxMoney;
$money = getInfo(money,users,"WHERE id='$moneyUser'");
$money += $postMoney;
$query = "UPDATE users SET money='$money' WHERE id='$moneyUser'";
mysql_query($query);
$town = getInfo(town,places,"WHERE id='$buildingId'");
$baron = getInfo(leader,towns,"WHERE id='$town'");
$kingdom = getInfo(kingdom,towns,"WHERE id='$town'");
$king = getInfo(leader,kingdoms,"WHERE id='$kingdom'");
if ($baron) {
$money = getInfo(money,users,"WHERE id='$baron'");
$money += 3;
$query = "UPDATE users SET money='$money' WHERE id='$baron'";
mysql_query($query);
}
if ($king) {
$money = getInfo(money,users,"WHERE id='$king'");
$money += 3;
$query = "UPDATE users SET money='$money' WHERE id='$king'";
mysql_query($query);
}
}
if ($npc_post) {
post($post_npc,$npc_post,$id);
}
if ((!$ooc) && ($command != "consume")) {
$intox = getInfo(dex,users,"WHERE id='$userId'");
$intox -= rand(3,5);
if ($intox < 0) $intox = 0;
$query = "UPDATE users SET dex='$intox' WHERE id='$userId'";
mysql_query($query);
$vuln = getInfo(vulnerability,users,"WHERE id='$userId'");
$vuln -= 10;
if ($vuln < 0) $vuln = 0;
$query = "UPDATE users SET vulnerability='$vuln' WHERE id='$userId'";
mysql_query($query);
}
if (($command) && ($command != "startmining")) {
$query = "DELETE FROM mining WHERE user='$userId'";
mysql_query($query);
}
echo '
';
echo '';
echo '
';
echo '
';
echo '
Success
';
echo '
';
echo '
';
echo '';
echo '';
echo '
';
echo '
';
echo '
'.$success.'
';
echo '
';
echo '
';
echo '';
echo '
';
echo ' ';
} else {
echo '
';
echo '';
echo '
';
echo '
';
echo '
Error
';
echo '
';
echo '
';
echo '';
echo '';
echo '
';
echo '
';
echo '
'.$failure.'
';
echo '
';
echo '
';
echo '';
echo '
';
echo ' ';
}
} else {
echo '
';
echo '';
echo '
';
echo '
';
echo '
Error
';
echo '
';
echo '
';
echo '';
echo '';
echo '
';
echo '
';
echo '
You haven\'t posted anything.
';
echo '
';
echo '
';
echo '';
echo '
';
echo ' ';
}
}
#The gnomes stole this comment. I'm out to get it back. Brb.
$walls_town = getInfo(id,towns,"WHERE walls='$buildingId'");
if (($_POST['mode'] == "gates") && ($walls_town)) {
$control = true;
$employees = explode('.',getInfo(employees,places,"WHERE id='$buildingId'"));
$owner = getInfo(owner,places,"WHERE id='$buildingId'");
$logged = time() - (7 * 24 * 3600);
$result = getRows(users,"WHERE room='$id' and status='conscious' and (logged>='$logged' or NPC!='')");
while ($row = mysql_fetch_array($result)) {
if (($row['id'] == $owner) || (inArray($row['id'],$employees))) $control = false;
}
if (($userId == $owner) || (inArray($userId,$employees))) $control = true;
$locked = $_POST['locked'];
if (($locked) && (getInfo(health,places,"WHERE id='$buildingId'") <= 0)) $failure = "The walls are not fortified, so the town may not be locked.";
if (!$control) $failure = "Conscious employees of the walls are in the room with you. You may not tamper with the gates.";
if (getInfo(status,users,"WHERE id='$userId'") != "conscious") $failure = "You are not conscious.";
if (!$failure) {
$query = "UPDATE towns SET locked='$locked' WHERE id='$walls_town'";
mysql_query($query);
echo '
';
echo '';
echo '
';
echo '
';
echo '
Success
';
echo '
';
echo '
';
echo '';
echo '';
echo '
';
echo '
';
echo '
You have changed the gate settings.
';
echo '
';
echo '
';
echo '';
echo '
';
echo ' ';
} else {
echo '
';
echo '';
echo '
';
echo '
';
echo '
Error
';
echo '
';
echo '
';
echo '';
echo '';
echo '
';
echo '
';
echo '
'.$failure.'
';
echo '
';
echo '
';
echo '';
echo '
';
echo ' ';
}
}
if ($_POST['mode'] == "delete") {
$post = $_POST['post'];
$postPost = getInfo(post,posts,"WHERE id='$post'");
$postPost = explode(' ',$postPost);
$postCount = count($postPost);
if ($postCount >= 40) {
$cost = $postCount - 30;
$cost = truncate($cost / 5);
if (getInfo(bonus,users,"WHERE id='$userId'") == "savvy") $maxMoney = 24;
else $maxMoney = 14;
if ($cost > $maxMoney) $cost = $maxMoney;
$money = getInfo(money,users,"WHERE id='$userId'");
$money -= $cost;
if ($money < 0) $money = 0;
$query = "UPDATE users SET money='$money' WHERE id='$userId'";
mysql_query($query);
}
$placeMoney = getInfo(money,places,"WHERE id='$buildingId'");
$placeMoney--;
if ($placeMoney < 0) $placeMoney = 0;
$query = "UPDATE places SET money='$placeMoney' WHERE id='$buildingId'";
mysql_query($query);
$query = "DELETE FROM posts WHERE id='$post'";
mysql_query($query);
echo '
NPCs currently inside : '.$npcs_inside.' ['.$npcs_count.']
';
}
if (getInfo(id,fires,"WHERE room='$id' and permenant!=''")) echo '
This room is on fire. This fire cannot be put out. For every post you make or every hour you mine in this room , you will lose between 1 and '.getInfo(permenant,fires,"WHERE room='$id' and permenant!=''").' health points.
';
if (getInfo(health,places,"WHERE id='$buildingId'")) echo '