Файл: area.php
Строк: 175
<?php
include_once("settings.php");
include_once("game_header.php");
include_once("room.php");
include_once("creature.php");
include_once("player_battle.php");
include_once("players.php");
include_once("player_thing.php");
include_once("drop.php");
include_once("player_chat.php");
if(!isset($_REQUEST["mode"])){
    $mode="";
}else{
    $mode = $_REQUEST["mode"];
}
//check city
if($mode==""){
    switch($room_id)
    {
        case CITY_MAIN:
        case CITY_DARKTIME:
        header("Location: city.php");
        break;
    }
}
$room = new CRoom($db);
$creature = new CCreature($db);
$drop = new CDrop($db,$room_id,$vnum);
$player_chat = new CPlayerChat($db,$vnum);
switch($mode){
    case 'say'://chat message
        $already_say=$player_chat->getLastMessageUser($room_id);
        if($already_say!=$say_text){ 
            $player_chat->addMessage($room_id,$say_text);
        }
        header("Location: area.php");
    break;
    case 'msg_del'://delete chat mgs
        if($player->getChatAngel()==1){
            $player_chat->hideMsg($vnum_msg,$player_name);
        }
        header("Location: area.php");
        break;
    case 'go':
    //player try go in next room
    if(!isset($_REQUEST['r']) || !isset($_REQUEST['d'])) break;
    $r = $_REQUEST['r'];
    $d = $_REQUEST['d'];
    $room->setVnum($r);
    $r_link = $room->getLinkRoom($d);
    if($r_link==-1) break;//wrong room
    $player->setRoom($r_link);
    header("Location: area.php");
    break;
    case 'start_battle':
    //player start battle
    if(!isset($_REQUEST['mob'])) break;
    $mob = $_REQUEST['mob'];
    $player_battle = new CPlayerBattle($db,$vnum);
    $player_battle->startBattle($mob);
    $creature = new CCreature($db,$mob);
    $creature->setState(STATE_COMBAT);
    $creature_name=$creature->getName();
    
    //start log meassage
    $uuid=getUniqValue();
    $player->setUuid($uuid);
    //add log messages
    $log_player = new CLogPlayers($db,$vnum,$uuid);
    $msg="чЩ ОБРБМЙ ОБ НПОУФТБ $creature_name.";
    $log_player->addLogMsg($msg);
    
    header("Location: battle_mobs.php");
    break;
    exit();
}
checkPlayerState($player);
//get weapon in hand
$player_things = new CPlayerThings($db,$vnum);
$things_wear = $player_things->getWearThingsInHand();
if(isset($things_wear[WEAR_TWO_HAND])){
    $weapon_id=$player_things->getThingID($things_wear[WEAR_TWO_HAND]);
    $dur_cur=$player_things->getDurability($things_wear[WEAR_TWO_HAND]);
    $dur_max=$player_things->getDurabilityMax($things_wear[WEAR_TWO_HAND]);
    $smarty->assign('LH_CUR',$dur_cur);
    $smarty->assign('LH_MAX',$dur_max);
    $smarty->assign('RH_CUR',$dur_cur);
    $smarty->assign('RH_MAX',$dur_max);
    $smarty->assign('LH_IMAGE',"images/items/weapon/".$weapon_id."s.gif");
    $smarty->assign('RH_IMAGE',"images/items/weapon/".$weapon_id."s.gif");
}else{
    //check left hand
    if(isset($things_wear[WEAR_LEFT_HAND])){
        $weapon_id=$player_things->getThingID($things_wear[WEAR_LEFT_HAND]);
        $dur_cur=$player_things->getDurability($things_wear[WEAR_LEFT_HAND]);
        $dur_max=$player_things->getDurabilityMax($things_wear[WEAR_LEFT_HAND]);
        $smarty->assign('LH_CUR',$dur_cur);
        $smarty->assign('LH_MAX',$dur_max);
        $smarty->assign('LH_IMAGE',"images/items/weapon/".$weapon_id."s.gif");
    }else{
        $smarty->assign('LH_CUR',0);
        $smarty->assign('LH_MAX',0);
        $smarty->assign('LH_IMAGE',"images/items/weapon/kul_left.gif");
    }
    //check right hand
    if(isset($things_wear[WEAR_RIGHT_HAND])){
        $weapon_id=$player_things->getThingID($things_wear[WEAR_RIGHT_HAND]);
        $dur_cur=$player_things->getDurability($things_wear[WEAR_RIGHT_HAND]);
        $dur_max=$player_things->getDurabilityMax($things_wear[WEAR_RIGHT_HAND]);
        $smarty->assign('RH_CUR',$dur_cur);
        $smarty->assign('RH_MAX',$dur_max);
        $smarty->assign('RH_IMAGE',"images/items/weapon/".$weapon_id."s.gif");
    }else{
        $smarty->assign('RH_CUR',0);
        $smarty->assign('RH_MAX',0);
        $smarty->assign('RH_IMAGE',"images/items/weapon/kul_right.gif");
    }
}
//get players in room
$players = new CPlayers($db);
$players_in_room=$players->getPlayersInRoomAndName($room_id);
foreach($players_in_room as $v){
    $skill->setVnum($v['vnum']);
    $player_level=$skill->getSkillLevel(SKILL_HP);
    $smarty->append("players_in_room",array(
    'VNUM' => $v['vnum'],
    'NAME' => $v['name'],
    'LEVEL' => $player_level,
    'COLOR' => $v['online']==1?"blue":"gray",
    'TIME_ACTIVE' => getTimes($v['active']),
    ));
}
//get room info
$room->setVnum($room_id);
$description = $room->getRoomDesc();
$caption = $room->getRoomCaption();
$smarty->assign('CAPTION',$caption);
$smarty->assign('DESCRIPTION',$description);
//get room exits
$exits = $room->getRoomExits();
foreach($exits as $v)
{
    $D = "D".$v['direction'];
    $smarty->assign($D,$v['direction']);
}
//get mobs in room
$mobs = $creature->getMobsInRoom($room_id);
foreach($mobs as $v)
{
    $creature->setVnum($v['vnum']);
    $creature_name=$creature->getName();
    $player_name="None";
    //remove reset battle
    if($v['state']!=STATE_STAND)
    {
        $player_mob = $creature->getPlayerFightMobs();
        if($player_mob!=0 && $player_mob['online'] == 1){
            $player_name=$player_mob['name'];
        }else{
            //reset mob state
            $creature->setState(STATE_STAND);
            header("Location: area.php");
        }
    }
    $smarty->append("creatures",array(
    'VNUM_CREATURE' => $v['vnum_mob'],
    'CREATURE_NAME' => $creature_name,
    'VNUM' => $v['vnum'],
    'STATE' => $v['state'],
    'PLAYER_NAME' => $player_name,
    ));
}
//get chat messages
$chat_msg=$player_chat->getLastMessage($room_id,15);
foreach($chat_msg as $k => $v){
    $chat_msg[$k]['pdata']=getChatTime($v['pdata']);
}
$smarty->assign_by_ref("chat_msg",$chat_msg);
//get drop things in room
$things_drop=$drop->getCountThingsInRoom();
$smarty->assign("THINGS_DROP",$things_drop);
$area_txt=$smarty->fetch($templ_path.'/area.tpl');
$smarty->assign('MAIN',$area_txt);
$smarty->display($templ_path.'/game.tpl');
include_once("free_all.php");
?>