let MdlTxtName = ""; 
let TxtName = "";    
let MobName = ""; 
let Nupu_command101 = Game_Interpreter.prototype.command101;
Game_Interpreter.prototype.command101 = function () {
    MdlTxtName = "";
    let _YobFaceImg = this._params[0];  
    let _WinWaku = this._params[2];     
    this._params[0] = "";
    this._params[2] = 2;
    let _ModelStr = _YobFaceImg.split("(")[0];
    let _ImgNo = 0;
    if (_YobFaceImg.split("(").length > 1) {
        _ImgNo = Number(_YobFaceImg.split("(")[1]) - 1;
    }
    Nupu_command101.call(this);
    let _MdlFlg = false; 
    for (let i = 0; i <= modelSetting.length - 1; i++) {
        if (modelSetting[i]._MdlName == _ModelStr) { 
            _MdlFlg = true;
            MdlTxtName = modelSetting[i]._Name;
            let _ExpStr = "H" + zeroPadding((this._params[1] + 1 + (_ImgNo * 8)), 2);
            console.log(_ExpStr);
            if (this._params[1] + 1 >= 100) _ExpStr = "H" + (this._params[1] + 1);
            L2dSetExp2(_ModelStr, _ExpStr);
            L2dTalkTop(_ModelStr); 
            if ($gameMessage._texts.length > 0) {
                $gameMessage._texts[0] =  "\\n<" + modelSetting[i]._Name + ">" + $gameMessage._texts[0];
            }
        }
    }
    if(_MdlFlg == false) {
        if ($gameMessage._texts.length > 0) {
            $gameMessage._texts[0] = "\\n<" + MobName + ">" + $gameMessage._texts[0];
        }
    }
    _NT_CloseFlg = false;
    let _MdlPos = "C";
    let _CkMArr = L2D_GetGameLive2D(_ModelStr);
    if(_CkMArr.length > 0){
        _MdlPos = _CkMArr[0]._FadePs;
        switch (_MdlPos){
            case "left":
                _MdlPos = "L";
                break;
            case "right":
                _MdlPos = "R";
                break;
        }
    }
    if (_MdlPos == "center") _MdlPos = "C";
    let _FukiImg = FukiPic + $gameVariables.value(VN_Fukidasi) + "_" + _MdlPos;
    if($gameSystem.Msg_ZureX == undefined) $gameSystem.Msg_ZureX = 0;
    if($gameSystem.Msg_ZureY == undefined) $gameSystem.Msg_ZureY = 0;
    this.SetPict(PN_FukiWin, _FukiImg, 0 + $gameSystem.Msg_ZureX, 405 + $gameSystem.Msg_ZureY + MsgZureY);
    let _TxtCng = "\\c[15]\\ow[0]"; 
    if ($gameSwitches.value(SW_HSceneON))
        $gameMessage._texts[0] = "\\c[0]\\oc[15]\\ow[4]" + $gameMessage._texts[0];
    else
        $gameMessage._texts[0] = _TxtCng + $gameMessage._texts[0];
    for (let i = 0; i <= $gameMessage._texts.length - 1; i++) {
        $gameMessage._texts[i] = $gameMessage._texts[i].replace("\\c[18]" , "\\c[18]\\ow[3]\\oc[15]")
        $gameMessage._texts[i] = $gameMessage._texts[i].replace("\\c[15]" , "\\c[15]\\ow[0]")
    }
    this._params[0] = _YobFaceImg;
    this._params[2] = _WinWaku;
    return false;
}
function zeroPadding(num, length) {
    return ('0000000000' + num).slice(-length);
}
