Exemple #1
0
function battle_wrapper(&$pa, &$pd, $active)
{
    if (eval(__MAGIC__)) {
        return $___RET_VALUE;
    }
    battle_prepare($pa, $pd, $active);
    battle($pa, $pd, $active);
    battle_finish($pa, $pd, $active);
    //写回数据库
    eval(import_module('sys', 'logger', 'player', 'metman'));
    if ($active) {
        if ($pd['hp'] <= 0 && $pa['hp'] > 0) {
            $pa['action'] = 'corpse' . $pd['pid'];
        }
        if ($pa['hp'] <= 0 && $pd['hp'] > 0 && $pd['action'] == '' && $pd['type'] == 0) {
            $pd['action'] = 'pacorpse' . $pa['pid'];
        }
    } else {
        if ($pd['hp'] <= 0 && $pa['hp'] > 0 && $pa['action'] == '' && $pa['type'] == 0) {
            $pa['action'] = 'pacorpse' . $pd['pid'];
        }
        if ($pa['hp'] <= 0 && $pd['hp'] > 0) {
            $pd['action'] = 'corpse' . $pa['pid'];
        }
    }
    if ($active) {
        $edata = $pd;
        \player\player_save($pa);
        \player\player_save($pd);
        \metman\metman_load_playerdata($pd);
        if ($pd['type'] == 0) {
            save_enemy_battlelog($pd);
        }
        \player\load_playerdata($pa);
    } else {
        $edata = $pa;
        \player\player_save($pa);
        \player\player_save($pd);
        \metman\metman_load_playerdata($pa);
        if ($pa['type'] == 0) {
            save_enemy_battlelog($pa);
        }
        \player\load_playerdata($pd);
    }
    $battle_title = '战斗发生';
    $main = MOD_METMAN_MEETMAN;
    \metman\init_battle(1);
    if (substr($action, 0, 6) == 'corpse') {
        \corpse\findcorpse($edata);
    } else {
        include template(MOD_BATTLE_BATTLERESULT);
        $cmd = ob_get_contents();
        ob_clean();
        $action = '';
    }
    if (defined('MOD_CLUBBASE')) {
        include template(MOD_CLUBBASE_NPCSKILLPAGE);
    }
}
Exemple #2
0
function act()
{
    if (eval(__MAGIC__)) {
        return $___RET_VALUE;
    }
    eval(import_module('sys', 'map', 'player', 'logger', 'metman', 'input'));
    if ($mode == 'combat') {
        if ($command == 'back') {
            $log .= "你逃跑了。";
            $action = '';
            $mode = 'command';
            return;
        }
        $enemyid = str_replace('enemy', '', $action);
        if (!$enemyid || strpos($action, 'enemy') === false) {
            $log .= "<span class=\"yellow\">你没有遇到敌人,或已经离开战场!</span><br>";
            $action = '';
            $mode = 'command';
            return;
        }
        $result = $db->query("SELECT * FROM {$tablepre}players WHERE pid='{$enemyid}'");
        if (!$db->num_rows($result)) {
            $log .= "对方不存在!<br>";
            $action = '';
            $mode = 'command';
            return;
        }
        $edata = \player\fetch_playerdata_by_pid($enemyid);
        extract($edata, EXTR_PREFIX_ALL, 'w');
        if ($edata['pls'] != $pls) {
            $log .= "<span class=\"yellow\">" . $edata['name'] . "</span>已经离开了<span class=\"yellow\">{$plsinfo[$pls]}</span>。<br>";
            $action = '';
            $mode = 'command';
            return;
        } elseif ($edata['hp'] <= 0) {
            $log .= "<span class=\"red\">" . $edata['name'] . "</span>已经死亡,不能被攻击。<br>";
            if (\corpse\check_corpse_discover($edata)) {
                $action = 'corpse' . $edata['pid'];
                \corpse\findcorpse($edata);
            }
            return;
        }
        \player\update_sdata();
        $ldata = $sdata;
        battle_wrapper($ldata, $edata, 1);
        return;
    }
    $chprocess();
}