• TibiaFace

    Tibiaface | Una comunidad Open Tibia donde encontras : mapas, scripts, Otserver, npc y amigos etc ...

    .
    demo menumenu

    Afiliados



    Votar:

    [Function] Doplayerremoveskill! TFS 0.4.0

    Compartir:

    Ver el tema anterior Ver el tema siguiente Ir abajo  Mensaje (Página 1 de 1.)

    1[Function] Doplayerremoveskill!  TFS 0.4.0 Empty [Function] Doplayerremoveskill! TFS 0.4.0 Jue Oct 25, 2018 10:22 pm

    [Admin] God Maya

    [Admin] God Maya
    Administrador
    Administrador
    Hola usuarios de tibiaface


    Bueno aqui les traigo una nueva funcion la cual remueve skills lo dejo a su creatividad a su uso.

    //doPlayerAddSkillTry(cid,skillid,n)//

    instalacion:

    luascript.cpp

    buscamos:

    Código:
    //doPlayerAddSkillTry(cid,skillid,n)
    lua_register(m_luaState, "doPlayerAddSkillTry", LuaScriptInterface::luaDoPlayerAddSkillTry);

    y abajo pegamos:

    Código:

    //doPlayerRemoveSkillTry(cid,skillid,n)
    lua_register(m_luaState, "doPlayerRemoveSkillTry", LuaScriptInterface::luaDoPlayerRemoveSkillTry);

    buscamos

    Código:

    int LuaScriptInterface::luaDoPlayerAddSkillTry(lua_State *L)
    {
    //doPlayerAddSkillTry(uid,skillid,n)
    uint32_t n = popNumber(L);
    uint32_t skillid = popNumber(L);
    uint32_t cid = popNumber(L);

    ScriptEnviroment* env = getScriptEnv();

    Player* player = env->getPlayerByUID(cid);
    if(player){
       player->addSkillAdvance((skills_t)skillid, n);
       lua_pushnumber(L, LUA_NO_ERROR);
    }
    else{
       reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
       lua_pushnumber(L, LUA_ERROR);
    }
    return 1;
    }

    y abajo agregamos

    Código:

    int LuaScriptInterface::luaDoPlayerRemoveSkillTry(lua_State *L)
    {
    //doPlayerRemoveSkillTry(uid,skillid,n)
    uint32_t n = popNumber(L);
    uint32_t skillid = popNumber(L);
    uint32_t cid = popNumber(L);

    ScriptEnviroment* env = getScriptEnv();

    Player* player = env->getPlayerByUID(cid);
    if(player){
       player->removeSkill((skills_t)skillid, n);
       lua_pushnumber(L, LUA_NO_ERROR);
    }
    else{
       reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
       lua_pushnumber(L, LUA_ERROR);
    }
    return 1;
    }

    luascript.h

    buscamos

    Código:
    static int luaDoPlayerAddSkillTry(lua_State *L);

    pegamos abajo:

    Código:
    static int luaDoPlayerRemoveSkillTry(lua_State *L);

    player.cpp

    buscamos

    Código:

    void Player::addSkillAdvance(skills_t skill, uint32_t count)
    {
    skills[skill][SKILL_TRIES] += count * g_config.getNumber(ConfigManager::RATE_SKILL);

    #if __DEBUG__
    std::cout << getName() << ", has the vocation: " << (int)getVocationId() << " and is training his " << getSkillName(skill) << "(" << skill << "). Tries: " << skills[skill][SKILL_TRIES] << "(" << vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL] + 1) << ")" << std::endl;
    std::cout << "Current skill: " << skills[skill][SKILL_LEVEL] << std::endl;
    #endif

    //Need skill up?
    if(skills[skill][SKILL_TRIES] >= vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL] + 1)){
        skills[skill][SKILL_LEVEL]++;
        skills[skill][SKILL_TRIES] = 0;
       skills[skill][SKILL_PERCENT] = 0;            
       std::stringstream advMsg;
       advMsg << "You advanced in " << getSkillName(skill) << ".";
       client->sendTextMessage(MSG_EVENT_ADVANCE, advMsg.str());
       client->sendSkills();
    }
    else{
       //update percent
       uint32_t newPercent = std::min((uint32_t)100, (100*skills[skill][SKILL_TRIES])/vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL]+1));
        if(skills[skill][SKILL_PERCENT] != newPercent){
          skills[skill][SKILL_PERCENT] = newPercent;
          client->sendSkills();
        }
    }
    }

    pegamos abajo

    Código:

    void Player::removeSkill(skills_t skill, uint32_t count)
    {
    skills[skill][SKILL_TRIES] -= count * g_config.getNumber(ConfigManager::RATE_SKILL);

    #if __DEBUG__
    std::cout << getName() << ", has the vocation: " << (int)getVocationId() << " and is training his " << getSkillName(skill) << "(" << skill << "). Tries: " << skills[skill][SKILL_TRIES] << "(" << vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL] + 1) << ")" << std::endl;
    std::cout << "Current skill: " << skills[skill][SKILL_LEVEL] << std::endl;
    #endif

    //Need skill up?
    if(skills[skill][SKILL_TRIES] >= vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL] - 1)){
        skills[skill][SKILL_LEVEL]--;
        skills[skill][SKILL_LEVEL] > 0;
        skills[skill][SKILL_TRIES] = 0;
       skills[skill][SKILL_PERCENT] = 0;            
       std::stringstream advMsg;
       advMsg << "You come back in " << getSkillName(skill) << ".";
       client->sendTextMessage(MSG_EVENT_ADVANCE, advMsg.str());
       client->sendSkills();
    }
    else{
       //update percent
       uint32_t newPercent = std::min((uint32_t)100, (100*skills[skill][SKILL_TRIES])/vocation->getReqSkillTries(skill, skills[skill][SKILL_LEVEL]-1));
        if(skills[skill][SKILL_PERCENT] != newPercent){
          skills[skill][SKILL_PERCENT] = newPercent;
          client->sendSkills();
        }
    }
    }

    player.h

    buscamos:


    Código:
    void addSkillAdvance(skills_t skill, uint32_t count);

    pegamos abajo


    Código:
    void removeSkill(skills_t skill, uint32_t count);

    creditos:a Mim(Clic)




    [Function] Doplayerremoveskill!  TFS 0.4.0 YNU5B25
    http://www.tibiaface.com

    Ver el tema anterior Ver el tema siguiente Volver arriba  Mensaje (Página 1 de 1.)

    Permisos de este foro:
    No puedes responder a temas en este foro.

     

    BienvenidosTibiaFace es una comunidad de Open Tibia. Para participar debes estar registrado (click para Regístrate).