Ir para conteúdo
  • Cadastre-se

Mathias Kenfi

Membro
  • Total de itens

    233
  • Registro em

  • Última visita

  • Dias Ganhos

    7

Histórico de Curtidas

  1. Gostei
    Mathias Kenfi recebeu reputação de thekilleron em [Novos Atributos] Critical/Dodge/Life e Mana Leech/Life e Mana Absorb   
    Esse sistema foi feito utilizando a source disponibilizada neste link
    Pode funcionar em TFS 0.4, OTX 2.X e, talvez, em TFS 0.4 só que a probabilidade erros é maior por ter diferentes nomes de funções e variáveis.
     
    Fiz um vídeo seguindo o passo a passo abaixo para facilitar o processo de instalação do sistema.
     
    Hoje estarei ensinando a instalar os seguintes novos atributos/sistemas em sua source
    CriticalHitChance e DodgeChance -- (Funciona da mesma maneira que o critical básico de script, porém sem bugs de callstack) Life e Mana Absorb -- (Regenera, de acordo com a % atribuida, a partir de dano recebido) Life e Mana Leech -- (Regenera, de acordo com a % atribuida, a partir do dano causado) Exemplo de como vai ficar
    Primeiro e antes de tudo, você terá de desativar o critical padrão do Tibia (Você pode pular essa parte se quiser)
     
    Vamos lá! Vá em items.cpp e procure por:
    attackSpeed = 0; Abaixo coloque:
    criticalHitChance = dodgeChance = lifeAbsorb = manaAbsorb = lifeLeech = manaLeech = 0; Depois, ainda em items.cpp, procure por:
    else if(tmpStrValue == "extradefense" || tmpStrValue == "extradef") { if(readXMLInteger(itemAttributesNode, "chance", intValue)) it.extraDefenseChance = intValue; if(readXMLInteger(itemAttributesNode, "value", intValue)) it.extraDefense = intValue; if(readXMLInteger(itemAttributesNode, "random_min", intValue)) it.extraDefenseRndMin = intValue; if(readXMLInteger(itemAttributesNode, "random_max", intValue)) it.extraDefenseRndMax = intValue; } Abaixo coloque:
    else if(tmpStrValue == "criticalhitchance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.criticalHitChance = intValue; } else if(tmpStrValue == "dodgechance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.dodgeChance = intValue; } else if(tmpStrValue == "lifeabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeAbsorb = intValue; } else if(tmpStrValue == "manaabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaAbsorb = intValue; } else if(tmpStrValue == "lifeleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeLeech = intValue; } else if(tmpStrValue == "manaleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaLeech = intValue; } Agora vá em items.h e procure por:
    int32_t attack, extraAttack, defense, extraDefense, armor, breakChance, hitChance, maxHitChance, runeLevel, runeMagLevel, lightLevel, lightColor, decayTo, rotateTo, alwaysOnTopOrder; Abaixo coloque:
    int32_t criticalHitChance, dodgeChance, lifeAbsorb, manaAbsorb, lifeLeech, manaLeech;  
     
    Agora vá em item.cpp e procure por:
    case ATTR_ATTACK: { int32_t attack; if(!propStream.getLong((uint32_t&)attack)) return ATTR_READ_ERROR; setAttribute("attack", attack); break; } Acima coloque:
    case ATTR_CRITICALHITCHANCE: { int32_t criticalHitChance; if(!propStream.getLong((uint32_t&)criticalHitChance)) return ATTR_READ_ERROR; setAttribute("criticalhitchance", criticalHitChance); break; } case ATTR_DODGECHANCE: { int32_t dodgeChance; if(!propStream.getLong((uint32_t&)dodgeChance)) return ATTR_READ_ERROR; setAttribute("dodgechance", dodgeChance); break; } case ATTR_LIFEABSORB: { int32_t lifeAbsorb; if(!propStream.getLong((uint32_t&)lifeAbsorb)) return ATTR_READ_ERROR; setAttribute("lifeabsorb", lifeAbsorb); break; } case ATTR_MANAABSORB: { int32_t manaAbsorb; if(!propStream.getLong((uint32_t&)manaAbsorb)) return ATTR_READ_ERROR; setAttribute("manaabsorb", manaAbsorb); break; } case ATTR_LIFELEECH: { int32_t lifeLeech; if(!propStream.getLong((uint32_t&)lifeLeech)) return ATTR_READ_ERROR; setAttribute("lifeleech", lifeLeech); break; } case ATTR_MANALEECH: { int32_t manaLeech; if(!propStream.getLong((uint32_t&)manaLeech)) return ATTR_READ_ERROR; setAttribute("manaleech", manaLeech); break; } Procure por:
    if(it.weaponType == WEAPON_DIST && it.ammoType != AMMO_NONE) { begin = false; s << " (Range:" << int32_t(item ? item->getShootRange() : it.shootRange); if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { s << ", Atk " << std::showpos << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } if(it.hitChance != -1 || (item && item->getHitChance() != -1)) s << ", Hit% " << std::showpos << (item ? item->getHitChance() : it.hitChance) << std::noshowpos; } else if(it.weaponType != WEAPON_AMMO && it.weaponType != WEAPON_WAND) { if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { begin = false; s << " (Atk:"; if(it.abilities.elementType != COMBAT_NONE && it.decayTo < 1) { s << std::max((int32_t)0, int32_t((item ? item->getAttack() : it.attack) - it.abilities.elementDamage)); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; s << " physical + " << it.abilities.elementDamage << " " << getCombatName(it.abilities.elementType); } else { s << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } } if(it.defense || it.extraDefense || (item && (item->getDefense() || item->getExtraDefense()))) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Def:" << int32_t(item ? item->getDefense() : it.defense); if(it.extraDefense || (item && item->getExtraDefense())) s << " " << std::showpos << int32_t(item ? item->getExtraDefense() : it.extraDefense) << std::noshowpos; } } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Procure por:
    int32_t tmp = it.armor; if(item) tmp = item->getArmor(); bool begin = true; if(tmp) { s << " (Arm:" << tmp; begin = false; } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Agora vá em item.h e procure por:
    ATTR_DUALWIELD = 43, Abaixo coloque:
    ATTR_CRITICALHITCHANCE = 44, ATTR_DODGECHANCE = 45, ATTR_LIFEABSORB = 46, ATTR_MANAABSORB = 47, ATTR_LIFELEECH = 48, ATTR_MANALEECH = 49, Procure por:
    int32_t getExtraDefense() const; Abaixo coloque:
    int32_t getCriticalHitChance() const; int32_t getDodgeChance() const; int32_t getLifeAbsorb() const; int32_t getManaAbsorb() const; int32_t getLifeLeech() const; int32_t getManaLeech() const; Procure por:
    inline int32_t Item::getExtraDefense() const { bool ok; int32_t v = getIntegerAttribute("extradefense", ok); if(ok) return v; return items[id].extraDefense; } Abaixo coloque:
    inline int32_t Item::getCriticalHitChance() const { bool ok; int32_t v = getIntegerAttribute("criticalhitchance", ok); if(ok) return v; return items[id].criticalHitChance; } inline int32_t Item::getDodgeChance() const { bool ok; int32_t v = getIntegerAttribute("dodgechance", ok); if(ok) return v; return items[id].dodgeChance; } inline int32_t Item::getLifeAbsorb() const { bool ok; int32_t v = getIntegerAttribute("lifeabsorb", ok); if(ok) return v; return items[id].lifeAbsorb; } inline int32_t Item::getManaAbsorb() const { bool ok; int32_t v = getIntegerAttribute("manaabsorb", ok); if(ok) return v; return items[id].manaAbsorb; } inline int32_t Item::getLifeLeech() const { bool ok; int32_t v = getIntegerAttribute("lifeleech", ok); if(ok) return v; return items[id].lifeLeech; } inline int32_t Item::getManaLeech() const { bool ok; int32_t v = getIntegerAttribute("manaleech", ok); if(ok) return v; return items[id].manaLeech; }  
     
    Agora vá em player.cpp e procure por:
    int32_t Player::getArmor() const { int32_t i = SLOT_FIRST, armor = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) armor += item->getArmor(); } if(vocation->getMultiplier(MULTIPLIER_ARMOR) != 1.0) return int32_t(armor * vocation->getMultiplier(MULTIPLIER_ARMOR)); return armor; } Abaixo coloque:
    int32_t Player::getCriticalHitChance() const { int32_t i = SLOT_FIRST, crit = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) crit += item->getCriticalHitChance(); } return crit; } int32_t Player::getDodgeChance() const { int32_t i = SLOT_FIRST, dodge = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) dodge += item->getDodgeChance(); } return dodge; } int32_t Player::getLifeAbsorb() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeAbsorb(); } return life; } int32_t Player::getManaAbsorb() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaAbsorb(); } return mana; } int32_t Player::getLifeLeech() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeLeech(); } return life; } int32_t Player::getManaLeech() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaLeech(); } return mana; } Agora vá em player.h e procure por:
    virtual int32_t getDefense() const; Abaixo coloque:
    virtual int32_t getCriticalHitChance() const; virtual int32_t getDodgeChance() const; virtual int32_t getLifeAbsorb() const; virtual int32_t getManaAbsorb() const; virtual int32_t getLifeLeech() const; virtual int32_t getManaLeech() const;  
     
    Agora vá em luascript.cpp e procure por:
    //getCreatureHealth(cid) lua_register(m_luaState, "getCreatureHealth", LuaInterface::luaGetCreatureHealth); Abaixo coloque:
    //getPlayerCriticalHitChance(cid) lua_register(m_luaState, "getPlayerCriticalHitChance", LuaInterface::luaGetPlayerCriticalHitChance); //getPlayerDodgeChance(cid) lua_register(m_luaState, "getPlayerDodgeChance", LuaInterface::luaGetPlayerDodgeChance); //getPlayerLifeAbsorb(cid) lua_register(m_luaState, "getPlayerLifeAbsorb", LuaInterface::luaGetPlayerLifeAbsorb); //getPlayerManaAbsorb(cid) lua_register(m_luaState, "getPlayerManaAbsorb", LuaInterface::luaGetPlayerManaAbsorb); //getPlayerLifeLeech(cid) lua_register(m_luaState, "getPlayerLifeLeech", LuaInterface::luaGetPlayerLifeLeech); //getPlayerManaLeech(cid) lua_register(m_luaState, "getPlayerManaLeech", LuaInterface::luaGetPlayerManaLeech); Procure por:
    int32_t LuaInterface::luaGetCreatureMaxHealth(lua_State* L) { //getCreatureMaxHealth(cid[, ignoreModifiers = false]) bool ignoreModifiers = false; if(lua_gettop(L) > 1) ignoreModifiers = popBoolean(L); ScriptEnviroment* env = getEnv(); if(Creature* creature = env->getCreatureByUID(popNumber(L))) lua_pushnumber(L, creature->getPlayer() && ignoreModifiers ? creature->healthMax : creature->getMaxHealth()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Abaixo coloque:
    int32_t LuaInterface::luaGetPlayerCriticalHitChance(lua_State* L) { //getPlayerCriticalHitChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getCriticalHitChance()); else { errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerDodgeChance(lua_State* L) { //getPlayerDodgeChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getDodgeChance()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeAbsorb(lua_State* L) { //getPlayerLifeAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaAbsorb(lua_State* L) { //getPlayerManaAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeLeech(lua_State* L) { //getPlayerLifeLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaLeech(lua_State* L) { //getPlayerManaLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Agora vá em luascript.h e procure por:
    static int32_t luaGetPlayerSpentMana(lua_State* L); Abaixo coloque:
    static int32_t luaGetPlayerCriticalHitChance(lua_State* L); static int32_t luaGetPlayerDodgeChance(lua_State* L); static int32_t luaGetPlayerLifeAbsorb(lua_State* L); static int32_t luaGetPlayerManaAbsorb(lua_State* L); static int32_t luaGetPlayerLifeLeech(lua_State* L); static int32_t luaGetPlayerManaLeech(lua_State* L);  
    As funções Lua adicionadas foram
    getPlayerCriticalHitChance(cid) getPlayerDodgeChance(cid) getPlayerLifeAbsorb(cid) getPlayerManaAbsorb(cid) getPlayerLifeLeech(cid) getPlayerManaLeech(cid)  
    Agora a parte do game.cpp. (Esta é uma parte opcional, você pode optar por não adicioná-la)
    Créditos: ~Mathias Kenfi
  2. Obrigado
    Mathias Kenfi recebeu reputação de FeeTads em [Novos Atributos] Critical/Dodge/Life e Mana Leech/Life e Mana Absorb   
    Esse sistema foi feito utilizando a source disponibilizada neste link
    Pode funcionar em TFS 0.4, OTX 2.X e, talvez, em TFS 0.4 só que a probabilidade erros é maior por ter diferentes nomes de funções e variáveis.
     
    Fiz um vídeo seguindo o passo a passo abaixo para facilitar o processo de instalação do sistema.
     
    Hoje estarei ensinando a instalar os seguintes novos atributos/sistemas em sua source
    CriticalHitChance e DodgeChance -- (Funciona da mesma maneira que o critical básico de script, porém sem bugs de callstack) Life e Mana Absorb -- (Regenera, de acordo com a % atribuida, a partir de dano recebido) Life e Mana Leech -- (Regenera, de acordo com a % atribuida, a partir do dano causado) Exemplo de como vai ficar
    Primeiro e antes de tudo, você terá de desativar o critical padrão do Tibia (Você pode pular essa parte se quiser)
     
    Vamos lá! Vá em items.cpp e procure por:
    attackSpeed = 0; Abaixo coloque:
    criticalHitChance = dodgeChance = lifeAbsorb = manaAbsorb = lifeLeech = manaLeech = 0; Depois, ainda em items.cpp, procure por:
    else if(tmpStrValue == "extradefense" || tmpStrValue == "extradef") { if(readXMLInteger(itemAttributesNode, "chance", intValue)) it.extraDefenseChance = intValue; if(readXMLInteger(itemAttributesNode, "value", intValue)) it.extraDefense = intValue; if(readXMLInteger(itemAttributesNode, "random_min", intValue)) it.extraDefenseRndMin = intValue; if(readXMLInteger(itemAttributesNode, "random_max", intValue)) it.extraDefenseRndMax = intValue; } Abaixo coloque:
    else if(tmpStrValue == "criticalhitchance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.criticalHitChance = intValue; } else if(tmpStrValue == "dodgechance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.dodgeChance = intValue; } else if(tmpStrValue == "lifeabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeAbsorb = intValue; } else if(tmpStrValue == "manaabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaAbsorb = intValue; } else if(tmpStrValue == "lifeleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeLeech = intValue; } else if(tmpStrValue == "manaleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaLeech = intValue; } Agora vá em items.h e procure por:
    int32_t attack, extraAttack, defense, extraDefense, armor, breakChance, hitChance, maxHitChance, runeLevel, runeMagLevel, lightLevel, lightColor, decayTo, rotateTo, alwaysOnTopOrder; Abaixo coloque:
    int32_t criticalHitChance, dodgeChance, lifeAbsorb, manaAbsorb, lifeLeech, manaLeech;  
     
    Agora vá em item.cpp e procure por:
    case ATTR_ATTACK: { int32_t attack; if(!propStream.getLong((uint32_t&)attack)) return ATTR_READ_ERROR; setAttribute("attack", attack); break; } Acima coloque:
    case ATTR_CRITICALHITCHANCE: { int32_t criticalHitChance; if(!propStream.getLong((uint32_t&)criticalHitChance)) return ATTR_READ_ERROR; setAttribute("criticalhitchance", criticalHitChance); break; } case ATTR_DODGECHANCE: { int32_t dodgeChance; if(!propStream.getLong((uint32_t&)dodgeChance)) return ATTR_READ_ERROR; setAttribute("dodgechance", dodgeChance); break; } case ATTR_LIFEABSORB: { int32_t lifeAbsorb; if(!propStream.getLong((uint32_t&)lifeAbsorb)) return ATTR_READ_ERROR; setAttribute("lifeabsorb", lifeAbsorb); break; } case ATTR_MANAABSORB: { int32_t manaAbsorb; if(!propStream.getLong((uint32_t&)manaAbsorb)) return ATTR_READ_ERROR; setAttribute("manaabsorb", manaAbsorb); break; } case ATTR_LIFELEECH: { int32_t lifeLeech; if(!propStream.getLong((uint32_t&)lifeLeech)) return ATTR_READ_ERROR; setAttribute("lifeleech", lifeLeech); break; } case ATTR_MANALEECH: { int32_t manaLeech; if(!propStream.getLong((uint32_t&)manaLeech)) return ATTR_READ_ERROR; setAttribute("manaleech", manaLeech); break; } Procure por:
    if(it.weaponType == WEAPON_DIST && it.ammoType != AMMO_NONE) { begin = false; s << " (Range:" << int32_t(item ? item->getShootRange() : it.shootRange); if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { s << ", Atk " << std::showpos << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } if(it.hitChance != -1 || (item && item->getHitChance() != -1)) s << ", Hit% " << std::showpos << (item ? item->getHitChance() : it.hitChance) << std::noshowpos; } else if(it.weaponType != WEAPON_AMMO && it.weaponType != WEAPON_WAND) { if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { begin = false; s << " (Atk:"; if(it.abilities.elementType != COMBAT_NONE && it.decayTo < 1) { s << std::max((int32_t)0, int32_t((item ? item->getAttack() : it.attack) - it.abilities.elementDamage)); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; s << " physical + " << it.abilities.elementDamage << " " << getCombatName(it.abilities.elementType); } else { s << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } } if(it.defense || it.extraDefense || (item && (item->getDefense() || item->getExtraDefense()))) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Def:" << int32_t(item ? item->getDefense() : it.defense); if(it.extraDefense || (item && item->getExtraDefense())) s << " " << std::showpos << int32_t(item ? item->getExtraDefense() : it.extraDefense) << std::noshowpos; } } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Procure por:
    int32_t tmp = it.armor; if(item) tmp = item->getArmor(); bool begin = true; if(tmp) { s << " (Arm:" << tmp; begin = false; } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Agora vá em item.h e procure por:
    ATTR_DUALWIELD = 43, Abaixo coloque:
    ATTR_CRITICALHITCHANCE = 44, ATTR_DODGECHANCE = 45, ATTR_LIFEABSORB = 46, ATTR_MANAABSORB = 47, ATTR_LIFELEECH = 48, ATTR_MANALEECH = 49, Procure por:
    int32_t getExtraDefense() const; Abaixo coloque:
    int32_t getCriticalHitChance() const; int32_t getDodgeChance() const; int32_t getLifeAbsorb() const; int32_t getManaAbsorb() const; int32_t getLifeLeech() const; int32_t getManaLeech() const; Procure por:
    inline int32_t Item::getExtraDefense() const { bool ok; int32_t v = getIntegerAttribute("extradefense", ok); if(ok) return v; return items[id].extraDefense; } Abaixo coloque:
    inline int32_t Item::getCriticalHitChance() const { bool ok; int32_t v = getIntegerAttribute("criticalhitchance", ok); if(ok) return v; return items[id].criticalHitChance; } inline int32_t Item::getDodgeChance() const { bool ok; int32_t v = getIntegerAttribute("dodgechance", ok); if(ok) return v; return items[id].dodgeChance; } inline int32_t Item::getLifeAbsorb() const { bool ok; int32_t v = getIntegerAttribute("lifeabsorb", ok); if(ok) return v; return items[id].lifeAbsorb; } inline int32_t Item::getManaAbsorb() const { bool ok; int32_t v = getIntegerAttribute("manaabsorb", ok); if(ok) return v; return items[id].manaAbsorb; } inline int32_t Item::getLifeLeech() const { bool ok; int32_t v = getIntegerAttribute("lifeleech", ok); if(ok) return v; return items[id].lifeLeech; } inline int32_t Item::getManaLeech() const { bool ok; int32_t v = getIntegerAttribute("manaleech", ok); if(ok) return v; return items[id].manaLeech; }  
     
    Agora vá em player.cpp e procure por:
    int32_t Player::getArmor() const { int32_t i = SLOT_FIRST, armor = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) armor += item->getArmor(); } if(vocation->getMultiplier(MULTIPLIER_ARMOR) != 1.0) return int32_t(armor * vocation->getMultiplier(MULTIPLIER_ARMOR)); return armor; } Abaixo coloque:
    int32_t Player::getCriticalHitChance() const { int32_t i = SLOT_FIRST, crit = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) crit += item->getCriticalHitChance(); } return crit; } int32_t Player::getDodgeChance() const { int32_t i = SLOT_FIRST, dodge = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) dodge += item->getDodgeChance(); } return dodge; } int32_t Player::getLifeAbsorb() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeAbsorb(); } return life; } int32_t Player::getManaAbsorb() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaAbsorb(); } return mana; } int32_t Player::getLifeLeech() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeLeech(); } return life; } int32_t Player::getManaLeech() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaLeech(); } return mana; } Agora vá em player.h e procure por:
    virtual int32_t getDefense() const; Abaixo coloque:
    virtual int32_t getCriticalHitChance() const; virtual int32_t getDodgeChance() const; virtual int32_t getLifeAbsorb() const; virtual int32_t getManaAbsorb() const; virtual int32_t getLifeLeech() const; virtual int32_t getManaLeech() const;  
     
    Agora vá em luascript.cpp e procure por:
    //getCreatureHealth(cid) lua_register(m_luaState, "getCreatureHealth", LuaInterface::luaGetCreatureHealth); Abaixo coloque:
    //getPlayerCriticalHitChance(cid) lua_register(m_luaState, "getPlayerCriticalHitChance", LuaInterface::luaGetPlayerCriticalHitChance); //getPlayerDodgeChance(cid) lua_register(m_luaState, "getPlayerDodgeChance", LuaInterface::luaGetPlayerDodgeChance); //getPlayerLifeAbsorb(cid) lua_register(m_luaState, "getPlayerLifeAbsorb", LuaInterface::luaGetPlayerLifeAbsorb); //getPlayerManaAbsorb(cid) lua_register(m_luaState, "getPlayerManaAbsorb", LuaInterface::luaGetPlayerManaAbsorb); //getPlayerLifeLeech(cid) lua_register(m_luaState, "getPlayerLifeLeech", LuaInterface::luaGetPlayerLifeLeech); //getPlayerManaLeech(cid) lua_register(m_luaState, "getPlayerManaLeech", LuaInterface::luaGetPlayerManaLeech); Procure por:
    int32_t LuaInterface::luaGetCreatureMaxHealth(lua_State* L) { //getCreatureMaxHealth(cid[, ignoreModifiers = false]) bool ignoreModifiers = false; if(lua_gettop(L) > 1) ignoreModifiers = popBoolean(L); ScriptEnviroment* env = getEnv(); if(Creature* creature = env->getCreatureByUID(popNumber(L))) lua_pushnumber(L, creature->getPlayer() && ignoreModifiers ? creature->healthMax : creature->getMaxHealth()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Abaixo coloque:
    int32_t LuaInterface::luaGetPlayerCriticalHitChance(lua_State* L) { //getPlayerCriticalHitChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getCriticalHitChance()); else { errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerDodgeChance(lua_State* L) { //getPlayerDodgeChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getDodgeChance()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeAbsorb(lua_State* L) { //getPlayerLifeAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaAbsorb(lua_State* L) { //getPlayerManaAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeLeech(lua_State* L) { //getPlayerLifeLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaLeech(lua_State* L) { //getPlayerManaLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Agora vá em luascript.h e procure por:
    static int32_t luaGetPlayerSpentMana(lua_State* L); Abaixo coloque:
    static int32_t luaGetPlayerCriticalHitChance(lua_State* L); static int32_t luaGetPlayerDodgeChance(lua_State* L); static int32_t luaGetPlayerLifeAbsorb(lua_State* L); static int32_t luaGetPlayerManaAbsorb(lua_State* L); static int32_t luaGetPlayerLifeLeech(lua_State* L); static int32_t luaGetPlayerManaLeech(lua_State* L);  
    As funções Lua adicionadas foram
    getPlayerCriticalHitChance(cid) getPlayerDodgeChance(cid) getPlayerLifeAbsorb(cid) getPlayerManaAbsorb(cid) getPlayerLifeLeech(cid) getPlayerManaLeech(cid)  
    Agora a parte do game.cpp. (Esta é uma parte opcional, você pode optar por não adicioná-la)
    Créditos: ~Mathias Kenfi
  3. Curtir
    Mathias Kenfi recebeu reputação de TheKronOs em [Novos Atributos] Critical/Dodge/Life e Mana Leech/Life e Mana Absorb   
    Esse sistema foi feito utilizando a source disponibilizada neste link
    Pode funcionar em TFS 0.4, OTX 2.X e, talvez, em TFS 0.4 só que a probabilidade erros é maior por ter diferentes nomes de funções e variáveis.
     
    Fiz um vídeo seguindo o passo a passo abaixo para facilitar o processo de instalação do sistema.
     
    Hoje estarei ensinando a instalar os seguintes novos atributos/sistemas em sua source
    CriticalHitChance e DodgeChance -- (Funciona da mesma maneira que o critical básico de script, porém sem bugs de callstack) Life e Mana Absorb -- (Regenera, de acordo com a % atribuida, a partir de dano recebido) Life e Mana Leech -- (Regenera, de acordo com a % atribuida, a partir do dano causado) Exemplo de como vai ficar
    Primeiro e antes de tudo, você terá de desativar o critical padrão do Tibia (Você pode pular essa parte se quiser)
     
    Vamos lá! Vá em items.cpp e procure por:
    attackSpeed = 0; Abaixo coloque:
    criticalHitChance = dodgeChance = lifeAbsorb = manaAbsorb = lifeLeech = manaLeech = 0; Depois, ainda em items.cpp, procure por:
    else if(tmpStrValue == "extradefense" || tmpStrValue == "extradef") { if(readXMLInteger(itemAttributesNode, "chance", intValue)) it.extraDefenseChance = intValue; if(readXMLInteger(itemAttributesNode, "value", intValue)) it.extraDefense = intValue; if(readXMLInteger(itemAttributesNode, "random_min", intValue)) it.extraDefenseRndMin = intValue; if(readXMLInteger(itemAttributesNode, "random_max", intValue)) it.extraDefenseRndMax = intValue; } Abaixo coloque:
    else if(tmpStrValue == "criticalhitchance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.criticalHitChance = intValue; } else if(tmpStrValue == "dodgechance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.dodgeChance = intValue; } else if(tmpStrValue == "lifeabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeAbsorb = intValue; } else if(tmpStrValue == "manaabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaAbsorb = intValue; } else if(tmpStrValue == "lifeleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeLeech = intValue; } else if(tmpStrValue == "manaleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaLeech = intValue; } Agora vá em items.h e procure por:
    int32_t attack, extraAttack, defense, extraDefense, armor, breakChance, hitChance, maxHitChance, runeLevel, runeMagLevel, lightLevel, lightColor, decayTo, rotateTo, alwaysOnTopOrder; Abaixo coloque:
    int32_t criticalHitChance, dodgeChance, lifeAbsorb, manaAbsorb, lifeLeech, manaLeech;  
     
    Agora vá em item.cpp e procure por:
    case ATTR_ATTACK: { int32_t attack; if(!propStream.getLong((uint32_t&)attack)) return ATTR_READ_ERROR; setAttribute("attack", attack); break; } Acima coloque:
    case ATTR_CRITICALHITCHANCE: { int32_t criticalHitChance; if(!propStream.getLong((uint32_t&)criticalHitChance)) return ATTR_READ_ERROR; setAttribute("criticalhitchance", criticalHitChance); break; } case ATTR_DODGECHANCE: { int32_t dodgeChance; if(!propStream.getLong((uint32_t&)dodgeChance)) return ATTR_READ_ERROR; setAttribute("dodgechance", dodgeChance); break; } case ATTR_LIFEABSORB: { int32_t lifeAbsorb; if(!propStream.getLong((uint32_t&)lifeAbsorb)) return ATTR_READ_ERROR; setAttribute("lifeabsorb", lifeAbsorb); break; } case ATTR_MANAABSORB: { int32_t manaAbsorb; if(!propStream.getLong((uint32_t&)manaAbsorb)) return ATTR_READ_ERROR; setAttribute("manaabsorb", manaAbsorb); break; } case ATTR_LIFELEECH: { int32_t lifeLeech; if(!propStream.getLong((uint32_t&)lifeLeech)) return ATTR_READ_ERROR; setAttribute("lifeleech", lifeLeech); break; } case ATTR_MANALEECH: { int32_t manaLeech; if(!propStream.getLong((uint32_t&)manaLeech)) return ATTR_READ_ERROR; setAttribute("manaleech", manaLeech); break; } Procure por:
    if(it.weaponType == WEAPON_DIST && it.ammoType != AMMO_NONE) { begin = false; s << " (Range:" << int32_t(item ? item->getShootRange() : it.shootRange); if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { s << ", Atk " << std::showpos << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } if(it.hitChance != -1 || (item && item->getHitChance() != -1)) s << ", Hit% " << std::showpos << (item ? item->getHitChance() : it.hitChance) << std::noshowpos; } else if(it.weaponType != WEAPON_AMMO && it.weaponType != WEAPON_WAND) { if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { begin = false; s << " (Atk:"; if(it.abilities.elementType != COMBAT_NONE && it.decayTo < 1) { s << std::max((int32_t)0, int32_t((item ? item->getAttack() : it.attack) - it.abilities.elementDamage)); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; s << " physical + " << it.abilities.elementDamage << " " << getCombatName(it.abilities.elementType); } else { s << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } } if(it.defense || it.extraDefense || (item && (item->getDefense() || item->getExtraDefense()))) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Def:" << int32_t(item ? item->getDefense() : it.defense); if(it.extraDefense || (item && item->getExtraDefense())) s << " " << std::showpos << int32_t(item ? item->getExtraDefense() : it.extraDefense) << std::noshowpos; } } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Procure por:
    int32_t tmp = it.armor; if(item) tmp = item->getArmor(); bool begin = true; if(tmp) { s << " (Arm:" << tmp; begin = false; } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Agora vá em item.h e procure por:
    ATTR_DUALWIELD = 43, Abaixo coloque:
    ATTR_CRITICALHITCHANCE = 44, ATTR_DODGECHANCE = 45, ATTR_LIFEABSORB = 46, ATTR_MANAABSORB = 47, ATTR_LIFELEECH = 48, ATTR_MANALEECH = 49, Procure por:
    int32_t getExtraDefense() const; Abaixo coloque:
    int32_t getCriticalHitChance() const; int32_t getDodgeChance() const; int32_t getLifeAbsorb() const; int32_t getManaAbsorb() const; int32_t getLifeLeech() const; int32_t getManaLeech() const; Procure por:
    inline int32_t Item::getExtraDefense() const { bool ok; int32_t v = getIntegerAttribute("extradefense", ok); if(ok) return v; return items[id].extraDefense; } Abaixo coloque:
    inline int32_t Item::getCriticalHitChance() const { bool ok; int32_t v = getIntegerAttribute("criticalhitchance", ok); if(ok) return v; return items[id].criticalHitChance; } inline int32_t Item::getDodgeChance() const { bool ok; int32_t v = getIntegerAttribute("dodgechance", ok); if(ok) return v; return items[id].dodgeChance; } inline int32_t Item::getLifeAbsorb() const { bool ok; int32_t v = getIntegerAttribute("lifeabsorb", ok); if(ok) return v; return items[id].lifeAbsorb; } inline int32_t Item::getManaAbsorb() const { bool ok; int32_t v = getIntegerAttribute("manaabsorb", ok); if(ok) return v; return items[id].manaAbsorb; } inline int32_t Item::getLifeLeech() const { bool ok; int32_t v = getIntegerAttribute("lifeleech", ok); if(ok) return v; return items[id].lifeLeech; } inline int32_t Item::getManaLeech() const { bool ok; int32_t v = getIntegerAttribute("manaleech", ok); if(ok) return v; return items[id].manaLeech; }  
     
    Agora vá em player.cpp e procure por:
    int32_t Player::getArmor() const { int32_t i = SLOT_FIRST, armor = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) armor += item->getArmor(); } if(vocation->getMultiplier(MULTIPLIER_ARMOR) != 1.0) return int32_t(armor * vocation->getMultiplier(MULTIPLIER_ARMOR)); return armor; } Abaixo coloque:
    int32_t Player::getCriticalHitChance() const { int32_t i = SLOT_FIRST, crit = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) crit += item->getCriticalHitChance(); } return crit; } int32_t Player::getDodgeChance() const { int32_t i = SLOT_FIRST, dodge = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) dodge += item->getDodgeChance(); } return dodge; } int32_t Player::getLifeAbsorb() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeAbsorb(); } return life; } int32_t Player::getManaAbsorb() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaAbsorb(); } return mana; } int32_t Player::getLifeLeech() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeLeech(); } return life; } int32_t Player::getManaLeech() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaLeech(); } return mana; } Agora vá em player.h e procure por:
    virtual int32_t getDefense() const; Abaixo coloque:
    virtual int32_t getCriticalHitChance() const; virtual int32_t getDodgeChance() const; virtual int32_t getLifeAbsorb() const; virtual int32_t getManaAbsorb() const; virtual int32_t getLifeLeech() const; virtual int32_t getManaLeech() const;  
     
    Agora vá em luascript.cpp e procure por:
    //getCreatureHealth(cid) lua_register(m_luaState, "getCreatureHealth", LuaInterface::luaGetCreatureHealth); Abaixo coloque:
    //getPlayerCriticalHitChance(cid) lua_register(m_luaState, "getPlayerCriticalHitChance", LuaInterface::luaGetPlayerCriticalHitChance); //getPlayerDodgeChance(cid) lua_register(m_luaState, "getPlayerDodgeChance", LuaInterface::luaGetPlayerDodgeChance); //getPlayerLifeAbsorb(cid) lua_register(m_luaState, "getPlayerLifeAbsorb", LuaInterface::luaGetPlayerLifeAbsorb); //getPlayerManaAbsorb(cid) lua_register(m_luaState, "getPlayerManaAbsorb", LuaInterface::luaGetPlayerManaAbsorb); //getPlayerLifeLeech(cid) lua_register(m_luaState, "getPlayerLifeLeech", LuaInterface::luaGetPlayerLifeLeech); //getPlayerManaLeech(cid) lua_register(m_luaState, "getPlayerManaLeech", LuaInterface::luaGetPlayerManaLeech); Procure por:
    int32_t LuaInterface::luaGetCreatureMaxHealth(lua_State* L) { //getCreatureMaxHealth(cid[, ignoreModifiers = false]) bool ignoreModifiers = false; if(lua_gettop(L) > 1) ignoreModifiers = popBoolean(L); ScriptEnviroment* env = getEnv(); if(Creature* creature = env->getCreatureByUID(popNumber(L))) lua_pushnumber(L, creature->getPlayer() && ignoreModifiers ? creature->healthMax : creature->getMaxHealth()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Abaixo coloque:
    int32_t LuaInterface::luaGetPlayerCriticalHitChance(lua_State* L) { //getPlayerCriticalHitChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getCriticalHitChance()); else { errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerDodgeChance(lua_State* L) { //getPlayerDodgeChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getDodgeChance()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeAbsorb(lua_State* L) { //getPlayerLifeAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaAbsorb(lua_State* L) { //getPlayerManaAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeLeech(lua_State* L) { //getPlayerLifeLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaLeech(lua_State* L) { //getPlayerManaLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Agora vá em luascript.h e procure por:
    static int32_t luaGetPlayerSpentMana(lua_State* L); Abaixo coloque:
    static int32_t luaGetPlayerCriticalHitChance(lua_State* L); static int32_t luaGetPlayerDodgeChance(lua_State* L); static int32_t luaGetPlayerLifeAbsorb(lua_State* L); static int32_t luaGetPlayerManaAbsorb(lua_State* L); static int32_t luaGetPlayerLifeLeech(lua_State* L); static int32_t luaGetPlayerManaLeech(lua_State* L);  
    As funções Lua adicionadas foram
    getPlayerCriticalHitChance(cid) getPlayerDodgeChance(cid) getPlayerLifeAbsorb(cid) getPlayerManaAbsorb(cid) getPlayerLifeLeech(cid) getPlayerManaLeech(cid)  
    Agora a parte do game.cpp. (Esta é uma parte opcional, você pode optar por não adicioná-la)
    Créditos: ~Mathias Kenfi
  4. Gostei
    Mathias Kenfi recebeu reputação de Gabrielx17 em Spell com storage   
    abaixo de function onCastSpell(cid, var) coloque:
    if getPlayerStorageValue(cid, 23569) <= 0 then return doPlayerSendTextMessage(cid, 22, "Você precisa ser VIP para usar esta spell"), doSendMagicEffect(getCreaturePos(cid), 2) end  
  5. Curtir
    Mathias Kenfi deu reputação a najatheus em Sistema de roleta ( Tfs 1.x )   
    Sistema funciona da seguinte maneira, ao clicar na alavanca, vai gerar um numero de 1 a quantidade de mesa ou piso que for configurado na tabela, esse numero sera a posição do item até o ponto que o player vai receber o item, assim si o player tirar o menor numero possivel ele podera ter a sorte de receber os stacks do items, vou estar deixando um video aqui em baixo mostrando o sistema

    agora vamo instalar o codigo :

    Em data/actions/script/, crie um arquivo chamado roleta.lua, dentro dele coloque : 
     
    local configuration_table = { storage_pos_item = 0; -- não mexa level_requeriment = { -- requimento para poder girar alavanca min = 1; max = 100; }; count = 0; -- não mexa count_gire_item = 0; bag_id = 1991; count_remove = 0; -- não mexa floor_id_or_table = 10449; -- id da mesa ou piso que vão ficar os item por cima items = {3000, 2012, 13042, 13045, 13047, 13051, 13044, 13041}; -- items da roleta que vai ser usado na roleta effect_item = 8; -- efeito de quando estiver gerando o item effect_addItem = 1; -- efeito de qnd o player receber o item effect_addItem_remove = 32; -- efeito de qnd o item for pro slot do player effect_removeItem = 36; -- efeito de qnd for remover os item da mesa ou piso time_create_item = 200; -- tempo para criar um a um item na mesa ou piso time_calcule_pos_item = 300; -- tempo para mover o item para a proxima posição time_count_calcule_pos_item = 1600; -- tempo para começar a mover o item ( obs o calculo min tem que ser a quantidade de mesa que vai ter x o tempo time_create_item) position = { -- configuração dos movimentos e posição create_item = { -- posição para criar os items [1] = {x = 981, y = 945, z = 7}; [2] = {x = 981, y = 946, z = 7}; [3] = {x = 982, y = 945, z = 7}; [4] = {x = 982, y = 946, z = 7}; [5] = {x = 983, y = 945, z = 7}; [6] = {x = 983, y = 946, z = 7}; [7] = {x = 984, y = 945, z = 7}; [8] = {x = 984, y = 946, z = 7}; }; roleta = { -- giros da roleta [1] = { [1] = {x = 0, y = 1, z = 0}; [2] = {x = 1, y = -1, z = 0}; [3] = {x = 0, y = 1, z = 0}; [4] = {x = 1, y = -1, z = 0}; [5] = {x = 0, y = 1, z = 0}; [6] = {x = 1, y = -1, z = 0}; [7] = {x = 0, y = 1, z = 0}; [8] = {x = 3, y = 0, z = 0}; }; [2] = { [1] = {x = 0, y = 0, z = 0}; [2] = {x = 1, y = -1, z = 0}; [3] = {x = 0, y = 1, z = 0}; [4] = {x = 1, y = -1, z = 0}; [5] = {x = 0, y = 1, z = 0}; [6] = {x = 1, y = -1, z = 0}; [7] = {x = 0, y = 1, z = 0}; [8] = {x = 3, y = 0, z = 0}; }; [3] = { [1] = {x = 0, y = 0, z = 0}; [2] = {x = 0, y = 0, z = 0}; [3] = {x = 0, y = 1, z = 0}; [4] = {x = 1, y = -1, z = 0}; [5] = {x = 0, y = 1, z = 0}; [6] = {x = 1, y = -1, z = 0}; [7] = {x = 0, y = 1, z = 0}; [8] = {x = 3, y = 0, z = 0}; }; [4] = { [1] = {x = 0, y = 0, z = 0}; [2] = {x = 0, y = 0, z = 0}; [3] = {x = 0, y = 0, z = 0}; [4] = {x = 1, y = -1, z = 0}; [5] = {x = 0, y = 1, z = 0}; [6] = {x = 1, y = -1, z = 0}; [7] = {x = 0, y = 1, z = 0}; [8] = {x = 3, y = 0, z = 0}; }; [5] = { [1] = {x = 0, y = 0, z = 0}; [2] = {x = 0, y = 0, z = 0}; [3] = {x = 0, y = 0, z = 0}; [4] = {x = 0, y = 0, z = 0}; [5] = {x = 0, y = 1, z = 0}; [6] = {x = 1, y = -1, z = 0}; [7] = {x = 0, y = 1, z = 0}; [8] = {x = 3, y = 0, z = 0}; }; [6] = { [1] = {x = 0, y = 0, z = 0}; [2] = {x = 0, y = 0, z = 0}; [3] = {x = 0, y = 0, z = 0}; [4] = {x = 0, y = 0, z = 0}; [5] = {x = 0, y = 0, z = 0}; [6] = {x = 1, y = -1, z = 0}; [7] = {x = 0, y = 1, z = 0}; [8] = {x = 3, y = 0, z = 0}; }; [7] = { [1] = {x = 0, y = 0, z = 0}; [2] = {x = 0, y = 0, z = 0}; [3] = {x = 0, y = 0, z = 0}; [4] = {x = 0, y = 0, z = 0}; [5] = {x = 0, y = 0, z = 0}; [6] = {x = 0, y = 0, z = 0}; [7] = {x = 0, y = 1, z = 0}; [8] = {x = 3, y = 0, z = 0}; }; [8] = { [1] = {x = 0, y = 0, z = 0}; [2] = {x = 0, y = 0, z = 0}; [3] = {x = 0, y = 0, z = 0}; [4] = {x = 0, y = 0, z = 0}; [5] = {x = 0, y = 0, z = 0}; [6] = {x = 0, y = 0, z = 0}; [7] = {x = 0, y = 0, z = 0}; [8] = {x = 3, y = 0, z = 0}; }; } } } local function createItemPos() if(configuration_table.count >= #configuration_table.position.create_item)then configuration_table.count = 0 return end configuration_table.count = configuration_table.count + 1 local item = Game.createItem(configuration_table.items[math.random(1, #configuration_table.items)], 1, configuration_table.position.create_item[configuration_table.count]) local pos_item = item:getPosition() pos_item:sendMagicEffect(configuration_table.effect_item) item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Item do evento da roleta") addEvent(createItemPos, configuration_table.time_create_item) end local function removeItemPos() if(configuration_table.count_remove >= #configuration_table.position.create_item)then configuration_table.count_remove = 0 return nil end configuration_table.count_remove = configuration_table.count_remove + 1 local tile = Tile(configuration_table.position.create_item[configuration_table.count_remove]) if not tile then return nil end local item = tile:getTopVisibleThing() if not item then return nil end if(item:getId() == configuration_table.floor_id_or_table)then return removeItemPos() end item:getPosition():sendMagicEffect(configuration_table.effect_removeItem) item:remove() removeItemPos() end local function addItemPlayer(player_uid) local player = Player(player_uid) if not player then return nil end local tile = Tile(configuration_table.storage_pos_item) if not tile then return nil end local item = tile:getTopVisibleThing() if not item then return nil end local player_pos = player:getPosition() local item_pos = item:getPosition() local bag = player:addItem(configuration_table.bag_id, 1, true, 1, 3) bag:addItem(item:getId(), item:getCount(), true, 1, 3) player_pos:sendMagicEffect(configuration_table.effect_addItem) item_pos:sendMagicEffect(configuration_table.effect_addItem_remove) item:remove(item:getCount()) end local function calculePosItem(value, player_uid) if(configuration_table.count_gire_item >= #configuration_table.position.create_item)then removeItemPos() addItemPlayer(player_uid) configuration_table.count_gire_item = 0 return nil end configuration_table.count_gire_item = configuration_table.count_gire_item + 1 local tile = Tile(configuration_table.position.create_item[configuration_table.count_gire_item]) if not tile then return nil end local item = tile:getTopVisibleThing() if not item then return nil end if(item:getId() == configuration_table.floor_id_or_table)then return nil end local pos = item:getPosition() local item_pos_x = pos.x local item_pos_y = pos.y local item_pos_z = pos.z local pos_ = configuration_table.position.roleta[value] local position = Position(item_pos_x + pos_[configuration_table.count_gire_item].x, item_pos_y + pos_[configuration_table.count_gire_item].y, item_pos_z) if not position then return nil end configuration_table.storage_pos_item = position item:moveTo(position) addEvent(calculePosItem, configuration_table.time_calcule_pos_item, value, player_uid) end function onUse(player, item, fromPosition, target, toPosition, isHotkey) if(player:getLevel() > configuration_table.level_requeriment.max)then return(not(player:sendTextMessage(MESSAGE_INFO_DESCR, player:getName() .. " your level(" .. player:getLevel() .. ") needs to be bigger(" .. configuration_table.level_requeriment.max .. ")"))) end if(player:getLevel() < configuration_table.level_requeriment.min)then return(not(player:sendTextMessage(MESSAGE_INFO_DESCR, player:getName() .. " your level(" .. player:getLevel() .. ") needs to be smaller(" .. configuration_table.level_requeriment.min .. ")"))) end if(configuration_table.count_gire_item >= 1) or (configuration_table.count >= 1) or (configuration_table.count_remove >= 1)then return(not(player:sendTextMessage(MESSAGE_INFO_DESCR, player:getName() .. " wait the roulette is in action, wait for it to finish"))) end local random = math.random(1, #configuration_table.position.roleta) configuration_table.storage_pos_item = 0 createItemPos() addEvent(calculePosItem, configuration_table.time_count_calcule_pos_item, random, player.uid) Game.sendAnimatedText("Spin number will be: " .. random, player:getPosition(), math.random(1, 255)) player:sendTextMessage(MESSAGE_INFO_DESCR, player:getName() .. " item of the day is on the rocks there") return true end
    Agora em data/actions/actions.xml, coloque :
     
    <action itemid="o id da alavanca do seu servidor" script="roleta.lua" />
    20211004_171313.mp4
     
  6. Curtir
    Mathias Kenfi deu reputação a najatheus em Aura Sistem ( Tfs 1.x )   
    Sistema funciona da seguinte forma, ao digitar : !aura on, a aura do player vai ligar, enquanto ela estiver ligada o player vai ficar regenerando a vida dele, ao digitar : !aura off, ela vai desligar e o player vai parar de regenerar a vida dele, vou estar deixando um video aqui em baixo 

     Agora vamos colocar o codigo

    Em data/talkactions/script/, crie um arquivo chamado aura.lua, e coloque isso dentro dele :
     
    local config_aurea = { effect = 4; -- efeito que vai ficar girando no player effect_health = 162; -- efeito qnd curar o player level_use = { -- level que vai ser usado (min/max) min = 1, max = 600, } ; health = 10; -- tanto que vai curar por time configurado pos_aurea = { -- não mexa [1] = {x = 0, y = -1}; [2] = {x = 1, y = -1}; [3] = {x = 1, y = 0}; [4] = {x = 1, y = 1}; [5] = {x = 0, y = 1}; [6] = {x = -1, y = 1}; [7] = {x = -1, y = 0}; [8] = {x = -1, y = -1}; }; storage_pos = 1547637649; -- não mexa e nem repita esse valor em outro script!! storage = 165477963; -- não mexa e nem repita esse valor em outro script!! tempo_aurea = 100; -- tempo da aurea para passar em cada posição } local function calculePosAurea(player_uid) local player = Player(player_uid) if(not(player))then return(nil) end if(player:getStorageValue(config_aurea.storage) <= 0)then return(nil) end if(player:getStorageValue(config_aurea.storage_pos) >= 8)then player:setStorageValue(config_aurea.storage_pos, 0) end player:setStorageValue(config_aurea.storage_pos, player:getStorageValue(config_aurea.storage_pos) + 1) return(player:getStorageValue(config_aurea.storage_pos)) end local function posAurea(player_uid) local player = Player(player_uid) if(not(player))then return(nil) end if(player:getStorageValue(config_aurea.storage) <= 0)then return(nil) end local pos_x = player:getPosition().x local pos_y = player:getPosition().y local pos_z = player:getPosition().z local aa = calculePosAurea(player_uid) local pos = Position(pos_x + config_aurea.pos_aurea[aa].x, pos_y + config_aurea.pos_aurea[aa].y, pos_z) if(not(pos))then return(nil) end return(pos) end local function aurea(player_uid) local player = Player(player_uid) if(not(player))then return(nil) end if(player:getStorageValue(config_aurea.storage) <= 0)then return(nil) end player:addHealth(config_aurea.health) player:getPosition():sendMagicEffect(config_aurea.effect_health) local position = posAurea(player_uid) position:sendMagicEffect(config_aurea.effect) addEvent(aurea, config_aurea.tempo_aurea, player_uid) end function onSay(player, words, param) if(words == "!aura on")then if(player:getLevel() > config_aurea.level_use.max)then return(not(player:sendTextMessage(MESSAGE_STATUS_SMALL, player:getName() .. " seu level(" .. player:getLevel() .. ") precisa ser maior(" .. config_aurea.level_use.max))) end if(player:getLevel() < config_aurea.level_use.min)then return(not(player:sendTextMessage(MESSAGE_STATUS_SMALL, player:getName() .. " seu level(" .. player:getLevel() .. ") precisa ser menor(" .. config_aurea.level_use.max))) end if(player:getStorageValue(config_aurea.storage) >= 1)then return(not(player:sendTextMessage(MESSAGE_STATUS_SMALL, player:getName() .. " Você ja esta com a aurea ligada"))) end player:setStorageValue(config_aurea.storage, 1) player:setStorageValue(config_aurea.storage_pos, 0) aurea(player.uid) elseif(words == "!aura off")then player:setStorageValue(config_aurea.storage, 0) end return(false) end
     
    Agora em data/talkactions/talkactions.xml, abra ele e coloque :

     
    <talkaction words="!aura on;!aura off" script="aura.lua"/>
    Agora em data/creaturescript/script/login.lua, abra ele e embaixo de :
     
    player:sendTextMessage(MESSAGE_STATUS_DEFAULT, loginStr)
    Coloque : 
     
    player:setStorageValue(165477963, 0) player:setStorageValue(1547637649, 0)
     
    Creditos : Sr. Naja

    20210927_210547.mp4  
  7. Curtir
    Mathias Kenfi recebeu reputação de Doidodepeda em [Novos Atributos] Critical/Dodge/Life e Mana Leech/Life e Mana Absorb   
    Esse sistema foi feito utilizando a source disponibilizada neste link
    Pode funcionar em TFS 0.4, OTX 2.X e, talvez, em TFS 0.4 só que a probabilidade erros é maior por ter diferentes nomes de funções e variáveis.
     
    Fiz um vídeo seguindo o passo a passo abaixo para facilitar o processo de instalação do sistema.
     
    Hoje estarei ensinando a instalar os seguintes novos atributos/sistemas em sua source
    CriticalHitChance e DodgeChance -- (Funciona da mesma maneira que o critical básico de script, porém sem bugs de callstack) Life e Mana Absorb -- (Regenera, de acordo com a % atribuida, a partir de dano recebido) Life e Mana Leech -- (Regenera, de acordo com a % atribuida, a partir do dano causado) Exemplo de como vai ficar
    Primeiro e antes de tudo, você terá de desativar o critical padrão do Tibia (Você pode pular essa parte se quiser)
     
    Vamos lá! Vá em items.cpp e procure por:
    attackSpeed = 0; Abaixo coloque:
    criticalHitChance = dodgeChance = lifeAbsorb = manaAbsorb = lifeLeech = manaLeech = 0; Depois, ainda em items.cpp, procure por:
    else if(tmpStrValue == "extradefense" || tmpStrValue == "extradef") { if(readXMLInteger(itemAttributesNode, "chance", intValue)) it.extraDefenseChance = intValue; if(readXMLInteger(itemAttributesNode, "value", intValue)) it.extraDefense = intValue; if(readXMLInteger(itemAttributesNode, "random_min", intValue)) it.extraDefenseRndMin = intValue; if(readXMLInteger(itemAttributesNode, "random_max", intValue)) it.extraDefenseRndMax = intValue; } Abaixo coloque:
    else if(tmpStrValue == "criticalhitchance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.criticalHitChance = intValue; } else if(tmpStrValue == "dodgechance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.dodgeChance = intValue; } else if(tmpStrValue == "lifeabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeAbsorb = intValue; } else if(tmpStrValue == "manaabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaAbsorb = intValue; } else if(tmpStrValue == "lifeleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeLeech = intValue; } else if(tmpStrValue == "manaleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaLeech = intValue; } Agora vá em items.h e procure por:
    int32_t attack, extraAttack, defense, extraDefense, armor, breakChance, hitChance, maxHitChance, runeLevel, runeMagLevel, lightLevel, lightColor, decayTo, rotateTo, alwaysOnTopOrder; Abaixo coloque:
    int32_t criticalHitChance, dodgeChance, lifeAbsorb, manaAbsorb, lifeLeech, manaLeech;  
     
    Agora vá em item.cpp e procure por:
    case ATTR_ATTACK: { int32_t attack; if(!propStream.getLong((uint32_t&)attack)) return ATTR_READ_ERROR; setAttribute("attack", attack); break; } Acima coloque:
    case ATTR_CRITICALHITCHANCE: { int32_t criticalHitChance; if(!propStream.getLong((uint32_t&)criticalHitChance)) return ATTR_READ_ERROR; setAttribute("criticalhitchance", criticalHitChance); break; } case ATTR_DODGECHANCE: { int32_t dodgeChance; if(!propStream.getLong((uint32_t&)dodgeChance)) return ATTR_READ_ERROR; setAttribute("dodgechance", dodgeChance); break; } case ATTR_LIFEABSORB: { int32_t lifeAbsorb; if(!propStream.getLong((uint32_t&)lifeAbsorb)) return ATTR_READ_ERROR; setAttribute("lifeabsorb", lifeAbsorb); break; } case ATTR_MANAABSORB: { int32_t manaAbsorb; if(!propStream.getLong((uint32_t&)manaAbsorb)) return ATTR_READ_ERROR; setAttribute("manaabsorb", manaAbsorb); break; } case ATTR_LIFELEECH: { int32_t lifeLeech; if(!propStream.getLong((uint32_t&)lifeLeech)) return ATTR_READ_ERROR; setAttribute("lifeleech", lifeLeech); break; } case ATTR_MANALEECH: { int32_t manaLeech; if(!propStream.getLong((uint32_t&)manaLeech)) return ATTR_READ_ERROR; setAttribute("manaleech", manaLeech); break; } Procure por:
    if(it.weaponType == WEAPON_DIST && it.ammoType != AMMO_NONE) { begin = false; s << " (Range:" << int32_t(item ? item->getShootRange() : it.shootRange); if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { s << ", Atk " << std::showpos << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } if(it.hitChance != -1 || (item && item->getHitChance() != -1)) s << ", Hit% " << std::showpos << (item ? item->getHitChance() : it.hitChance) << std::noshowpos; } else if(it.weaponType != WEAPON_AMMO && it.weaponType != WEAPON_WAND) { if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { begin = false; s << " (Atk:"; if(it.abilities.elementType != COMBAT_NONE && it.decayTo < 1) { s << std::max((int32_t)0, int32_t((item ? item->getAttack() : it.attack) - it.abilities.elementDamage)); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; s << " physical + " << it.abilities.elementDamage << " " << getCombatName(it.abilities.elementType); } else { s << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } } if(it.defense || it.extraDefense || (item && (item->getDefense() || item->getExtraDefense()))) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Def:" << int32_t(item ? item->getDefense() : it.defense); if(it.extraDefense || (item && item->getExtraDefense())) s << " " << std::showpos << int32_t(item ? item->getExtraDefense() : it.extraDefense) << std::noshowpos; } } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Procure por:
    int32_t tmp = it.armor; if(item) tmp = item->getArmor(); bool begin = true; if(tmp) { s << " (Arm:" << tmp; begin = false; } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Agora vá em item.h e procure por:
    ATTR_DUALWIELD = 43, Abaixo coloque:
    ATTR_CRITICALHITCHANCE = 44, ATTR_DODGECHANCE = 45, ATTR_LIFEABSORB = 46, ATTR_MANAABSORB = 47, ATTR_LIFELEECH = 48, ATTR_MANALEECH = 49, Procure por:
    int32_t getExtraDefense() const; Abaixo coloque:
    int32_t getCriticalHitChance() const; int32_t getDodgeChance() const; int32_t getLifeAbsorb() const; int32_t getManaAbsorb() const; int32_t getLifeLeech() const; int32_t getManaLeech() const; Procure por:
    inline int32_t Item::getExtraDefense() const { bool ok; int32_t v = getIntegerAttribute("extradefense", ok); if(ok) return v; return items[id].extraDefense; } Abaixo coloque:
    inline int32_t Item::getCriticalHitChance() const { bool ok; int32_t v = getIntegerAttribute("criticalhitchance", ok); if(ok) return v; return items[id].criticalHitChance; } inline int32_t Item::getDodgeChance() const { bool ok; int32_t v = getIntegerAttribute("dodgechance", ok); if(ok) return v; return items[id].dodgeChance; } inline int32_t Item::getLifeAbsorb() const { bool ok; int32_t v = getIntegerAttribute("lifeabsorb", ok); if(ok) return v; return items[id].lifeAbsorb; } inline int32_t Item::getManaAbsorb() const { bool ok; int32_t v = getIntegerAttribute("manaabsorb", ok); if(ok) return v; return items[id].manaAbsorb; } inline int32_t Item::getLifeLeech() const { bool ok; int32_t v = getIntegerAttribute("lifeleech", ok); if(ok) return v; return items[id].lifeLeech; } inline int32_t Item::getManaLeech() const { bool ok; int32_t v = getIntegerAttribute("manaleech", ok); if(ok) return v; return items[id].manaLeech; }  
     
    Agora vá em player.cpp e procure por:
    int32_t Player::getArmor() const { int32_t i = SLOT_FIRST, armor = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) armor += item->getArmor(); } if(vocation->getMultiplier(MULTIPLIER_ARMOR) != 1.0) return int32_t(armor * vocation->getMultiplier(MULTIPLIER_ARMOR)); return armor; } Abaixo coloque:
    int32_t Player::getCriticalHitChance() const { int32_t i = SLOT_FIRST, crit = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) crit += item->getCriticalHitChance(); } return crit; } int32_t Player::getDodgeChance() const { int32_t i = SLOT_FIRST, dodge = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) dodge += item->getDodgeChance(); } return dodge; } int32_t Player::getLifeAbsorb() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeAbsorb(); } return life; } int32_t Player::getManaAbsorb() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaAbsorb(); } return mana; } int32_t Player::getLifeLeech() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeLeech(); } return life; } int32_t Player::getManaLeech() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaLeech(); } return mana; } Agora vá em player.h e procure por:
    virtual int32_t getDefense() const; Abaixo coloque:
    virtual int32_t getCriticalHitChance() const; virtual int32_t getDodgeChance() const; virtual int32_t getLifeAbsorb() const; virtual int32_t getManaAbsorb() const; virtual int32_t getLifeLeech() const; virtual int32_t getManaLeech() const;  
     
    Agora vá em luascript.cpp e procure por:
    //getCreatureHealth(cid) lua_register(m_luaState, "getCreatureHealth", LuaInterface::luaGetCreatureHealth); Abaixo coloque:
    //getPlayerCriticalHitChance(cid) lua_register(m_luaState, "getPlayerCriticalHitChance", LuaInterface::luaGetPlayerCriticalHitChance); //getPlayerDodgeChance(cid) lua_register(m_luaState, "getPlayerDodgeChance", LuaInterface::luaGetPlayerDodgeChance); //getPlayerLifeAbsorb(cid) lua_register(m_luaState, "getPlayerLifeAbsorb", LuaInterface::luaGetPlayerLifeAbsorb); //getPlayerManaAbsorb(cid) lua_register(m_luaState, "getPlayerManaAbsorb", LuaInterface::luaGetPlayerManaAbsorb); //getPlayerLifeLeech(cid) lua_register(m_luaState, "getPlayerLifeLeech", LuaInterface::luaGetPlayerLifeLeech); //getPlayerManaLeech(cid) lua_register(m_luaState, "getPlayerManaLeech", LuaInterface::luaGetPlayerManaLeech); Procure por:
    int32_t LuaInterface::luaGetCreatureMaxHealth(lua_State* L) { //getCreatureMaxHealth(cid[, ignoreModifiers = false]) bool ignoreModifiers = false; if(lua_gettop(L) > 1) ignoreModifiers = popBoolean(L); ScriptEnviroment* env = getEnv(); if(Creature* creature = env->getCreatureByUID(popNumber(L))) lua_pushnumber(L, creature->getPlayer() && ignoreModifiers ? creature->healthMax : creature->getMaxHealth()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Abaixo coloque:
    int32_t LuaInterface::luaGetPlayerCriticalHitChance(lua_State* L) { //getPlayerCriticalHitChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getCriticalHitChance()); else { errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerDodgeChance(lua_State* L) { //getPlayerDodgeChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getDodgeChance()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeAbsorb(lua_State* L) { //getPlayerLifeAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaAbsorb(lua_State* L) { //getPlayerManaAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeLeech(lua_State* L) { //getPlayerLifeLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaLeech(lua_State* L) { //getPlayerManaLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Agora vá em luascript.h e procure por:
    static int32_t luaGetPlayerSpentMana(lua_State* L); Abaixo coloque:
    static int32_t luaGetPlayerCriticalHitChance(lua_State* L); static int32_t luaGetPlayerDodgeChance(lua_State* L); static int32_t luaGetPlayerLifeAbsorb(lua_State* L); static int32_t luaGetPlayerManaAbsorb(lua_State* L); static int32_t luaGetPlayerLifeLeech(lua_State* L); static int32_t luaGetPlayerManaLeech(lua_State* L);  
    As funções Lua adicionadas foram
    getPlayerCriticalHitChance(cid) getPlayerDodgeChance(cid) getPlayerLifeAbsorb(cid) getPlayerManaAbsorb(cid) getPlayerLifeLeech(cid) getPlayerManaLeech(cid)  
    Agora a parte do game.cpp. (Esta é uma parte opcional, você pode optar por não adicioná-la)
    Créditos: ~Mathias Kenfi
  8. Obrigado
    Mathias Kenfi recebeu reputação de Roy em [Novos Atributos] Critical/Dodge/Life e Mana Leech/Life e Mana Absorb   
    Esse sistema foi feito utilizando a source disponibilizada neste link
    Pode funcionar em TFS 0.4, OTX 2.X e, talvez, em TFS 0.4 só que a probabilidade erros é maior por ter diferentes nomes de funções e variáveis.
     
    Fiz um vídeo seguindo o passo a passo abaixo para facilitar o processo de instalação do sistema.
     
    Hoje estarei ensinando a instalar os seguintes novos atributos/sistemas em sua source
    CriticalHitChance e DodgeChance -- (Funciona da mesma maneira que o critical básico de script, porém sem bugs de callstack) Life e Mana Absorb -- (Regenera, de acordo com a % atribuida, a partir de dano recebido) Life e Mana Leech -- (Regenera, de acordo com a % atribuida, a partir do dano causado) Exemplo de como vai ficar
    Primeiro e antes de tudo, você terá de desativar o critical padrão do Tibia (Você pode pular essa parte se quiser)
     
    Vamos lá! Vá em items.cpp e procure por:
    attackSpeed = 0; Abaixo coloque:
    criticalHitChance = dodgeChance = lifeAbsorb = manaAbsorb = lifeLeech = manaLeech = 0; Depois, ainda em items.cpp, procure por:
    else if(tmpStrValue == "extradefense" || tmpStrValue == "extradef") { if(readXMLInteger(itemAttributesNode, "chance", intValue)) it.extraDefenseChance = intValue; if(readXMLInteger(itemAttributesNode, "value", intValue)) it.extraDefense = intValue; if(readXMLInteger(itemAttributesNode, "random_min", intValue)) it.extraDefenseRndMin = intValue; if(readXMLInteger(itemAttributesNode, "random_max", intValue)) it.extraDefenseRndMax = intValue; } Abaixo coloque:
    else if(tmpStrValue == "criticalhitchance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.criticalHitChance = intValue; } else if(tmpStrValue == "dodgechance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.dodgeChance = intValue; } else if(tmpStrValue == "lifeabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeAbsorb = intValue; } else if(tmpStrValue == "manaabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaAbsorb = intValue; } else if(tmpStrValue == "lifeleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeLeech = intValue; } else if(tmpStrValue == "manaleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaLeech = intValue; } Agora vá em items.h e procure por:
    int32_t attack, extraAttack, defense, extraDefense, armor, breakChance, hitChance, maxHitChance, runeLevel, runeMagLevel, lightLevel, lightColor, decayTo, rotateTo, alwaysOnTopOrder; Abaixo coloque:
    int32_t criticalHitChance, dodgeChance, lifeAbsorb, manaAbsorb, lifeLeech, manaLeech;  
     
    Agora vá em item.cpp e procure por:
    case ATTR_ATTACK: { int32_t attack; if(!propStream.getLong((uint32_t&)attack)) return ATTR_READ_ERROR; setAttribute("attack", attack); break; } Acima coloque:
    case ATTR_CRITICALHITCHANCE: { int32_t criticalHitChance; if(!propStream.getLong((uint32_t&)criticalHitChance)) return ATTR_READ_ERROR; setAttribute("criticalhitchance", criticalHitChance); break; } case ATTR_DODGECHANCE: { int32_t dodgeChance; if(!propStream.getLong((uint32_t&)dodgeChance)) return ATTR_READ_ERROR; setAttribute("dodgechance", dodgeChance); break; } case ATTR_LIFEABSORB: { int32_t lifeAbsorb; if(!propStream.getLong((uint32_t&)lifeAbsorb)) return ATTR_READ_ERROR; setAttribute("lifeabsorb", lifeAbsorb); break; } case ATTR_MANAABSORB: { int32_t manaAbsorb; if(!propStream.getLong((uint32_t&)manaAbsorb)) return ATTR_READ_ERROR; setAttribute("manaabsorb", manaAbsorb); break; } case ATTR_LIFELEECH: { int32_t lifeLeech; if(!propStream.getLong((uint32_t&)lifeLeech)) return ATTR_READ_ERROR; setAttribute("lifeleech", lifeLeech); break; } case ATTR_MANALEECH: { int32_t manaLeech; if(!propStream.getLong((uint32_t&)manaLeech)) return ATTR_READ_ERROR; setAttribute("manaleech", manaLeech); break; } Procure por:
    if(it.weaponType == WEAPON_DIST && it.ammoType != AMMO_NONE) { begin = false; s << " (Range:" << int32_t(item ? item->getShootRange() : it.shootRange); if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { s << ", Atk " << std::showpos << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } if(it.hitChance != -1 || (item && item->getHitChance() != -1)) s << ", Hit% " << std::showpos << (item ? item->getHitChance() : it.hitChance) << std::noshowpos; } else if(it.weaponType != WEAPON_AMMO && it.weaponType != WEAPON_WAND) { if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { begin = false; s << " (Atk:"; if(it.abilities.elementType != COMBAT_NONE && it.decayTo < 1) { s << std::max((int32_t)0, int32_t((item ? item->getAttack() : it.attack) - it.abilities.elementDamage)); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; s << " physical + " << it.abilities.elementDamage << " " << getCombatName(it.abilities.elementType); } else { s << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } } if(it.defense || it.extraDefense || (item && (item->getDefense() || item->getExtraDefense()))) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Def:" << int32_t(item ? item->getDefense() : it.defense); if(it.extraDefense || (item && item->getExtraDefense())) s << " " << std::showpos << int32_t(item ? item->getExtraDefense() : it.extraDefense) << std::noshowpos; } } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Procure por:
    int32_t tmp = it.armor; if(item) tmp = item->getArmor(); bool begin = true; if(tmp) { s << " (Arm:" << tmp; begin = false; } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Agora vá em item.h e procure por:
    ATTR_DUALWIELD = 43, Abaixo coloque:
    ATTR_CRITICALHITCHANCE = 44, ATTR_DODGECHANCE = 45, ATTR_LIFEABSORB = 46, ATTR_MANAABSORB = 47, ATTR_LIFELEECH = 48, ATTR_MANALEECH = 49, Procure por:
    int32_t getExtraDefense() const; Abaixo coloque:
    int32_t getCriticalHitChance() const; int32_t getDodgeChance() const; int32_t getLifeAbsorb() const; int32_t getManaAbsorb() const; int32_t getLifeLeech() const; int32_t getManaLeech() const; Procure por:
    inline int32_t Item::getExtraDefense() const { bool ok; int32_t v = getIntegerAttribute("extradefense", ok); if(ok) return v; return items[id].extraDefense; } Abaixo coloque:
    inline int32_t Item::getCriticalHitChance() const { bool ok; int32_t v = getIntegerAttribute("criticalhitchance", ok); if(ok) return v; return items[id].criticalHitChance; } inline int32_t Item::getDodgeChance() const { bool ok; int32_t v = getIntegerAttribute("dodgechance", ok); if(ok) return v; return items[id].dodgeChance; } inline int32_t Item::getLifeAbsorb() const { bool ok; int32_t v = getIntegerAttribute("lifeabsorb", ok); if(ok) return v; return items[id].lifeAbsorb; } inline int32_t Item::getManaAbsorb() const { bool ok; int32_t v = getIntegerAttribute("manaabsorb", ok); if(ok) return v; return items[id].manaAbsorb; } inline int32_t Item::getLifeLeech() const { bool ok; int32_t v = getIntegerAttribute("lifeleech", ok); if(ok) return v; return items[id].lifeLeech; } inline int32_t Item::getManaLeech() const { bool ok; int32_t v = getIntegerAttribute("manaleech", ok); if(ok) return v; return items[id].manaLeech; }  
     
    Agora vá em player.cpp e procure por:
    int32_t Player::getArmor() const { int32_t i = SLOT_FIRST, armor = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) armor += item->getArmor(); } if(vocation->getMultiplier(MULTIPLIER_ARMOR) != 1.0) return int32_t(armor * vocation->getMultiplier(MULTIPLIER_ARMOR)); return armor; } Abaixo coloque:
    int32_t Player::getCriticalHitChance() const { int32_t i = SLOT_FIRST, crit = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) crit += item->getCriticalHitChance(); } return crit; } int32_t Player::getDodgeChance() const { int32_t i = SLOT_FIRST, dodge = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) dodge += item->getDodgeChance(); } return dodge; } int32_t Player::getLifeAbsorb() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeAbsorb(); } return life; } int32_t Player::getManaAbsorb() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaAbsorb(); } return mana; } int32_t Player::getLifeLeech() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeLeech(); } return life; } int32_t Player::getManaLeech() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaLeech(); } return mana; } Agora vá em player.h e procure por:
    virtual int32_t getDefense() const; Abaixo coloque:
    virtual int32_t getCriticalHitChance() const; virtual int32_t getDodgeChance() const; virtual int32_t getLifeAbsorb() const; virtual int32_t getManaAbsorb() const; virtual int32_t getLifeLeech() const; virtual int32_t getManaLeech() const;  
     
    Agora vá em luascript.cpp e procure por:
    //getCreatureHealth(cid) lua_register(m_luaState, "getCreatureHealth", LuaInterface::luaGetCreatureHealth); Abaixo coloque:
    //getPlayerCriticalHitChance(cid) lua_register(m_luaState, "getPlayerCriticalHitChance", LuaInterface::luaGetPlayerCriticalHitChance); //getPlayerDodgeChance(cid) lua_register(m_luaState, "getPlayerDodgeChance", LuaInterface::luaGetPlayerDodgeChance); //getPlayerLifeAbsorb(cid) lua_register(m_luaState, "getPlayerLifeAbsorb", LuaInterface::luaGetPlayerLifeAbsorb); //getPlayerManaAbsorb(cid) lua_register(m_luaState, "getPlayerManaAbsorb", LuaInterface::luaGetPlayerManaAbsorb); //getPlayerLifeLeech(cid) lua_register(m_luaState, "getPlayerLifeLeech", LuaInterface::luaGetPlayerLifeLeech); //getPlayerManaLeech(cid) lua_register(m_luaState, "getPlayerManaLeech", LuaInterface::luaGetPlayerManaLeech); Procure por:
    int32_t LuaInterface::luaGetCreatureMaxHealth(lua_State* L) { //getCreatureMaxHealth(cid[, ignoreModifiers = false]) bool ignoreModifiers = false; if(lua_gettop(L) > 1) ignoreModifiers = popBoolean(L); ScriptEnviroment* env = getEnv(); if(Creature* creature = env->getCreatureByUID(popNumber(L))) lua_pushnumber(L, creature->getPlayer() && ignoreModifiers ? creature->healthMax : creature->getMaxHealth()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Abaixo coloque:
    int32_t LuaInterface::luaGetPlayerCriticalHitChance(lua_State* L) { //getPlayerCriticalHitChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getCriticalHitChance()); else { errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerDodgeChance(lua_State* L) { //getPlayerDodgeChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getDodgeChance()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeAbsorb(lua_State* L) { //getPlayerLifeAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaAbsorb(lua_State* L) { //getPlayerManaAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeLeech(lua_State* L) { //getPlayerLifeLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaLeech(lua_State* L) { //getPlayerManaLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Agora vá em luascript.h e procure por:
    static int32_t luaGetPlayerSpentMana(lua_State* L); Abaixo coloque:
    static int32_t luaGetPlayerCriticalHitChance(lua_State* L); static int32_t luaGetPlayerDodgeChance(lua_State* L); static int32_t luaGetPlayerLifeAbsorb(lua_State* L); static int32_t luaGetPlayerManaAbsorb(lua_State* L); static int32_t luaGetPlayerLifeLeech(lua_State* L); static int32_t luaGetPlayerManaLeech(lua_State* L);  
    As funções Lua adicionadas foram
    getPlayerCriticalHitChance(cid) getPlayerDodgeChance(cid) getPlayerLifeAbsorb(cid) getPlayerManaAbsorb(cid) getPlayerLifeLeech(cid) getPlayerManaLeech(cid)  
    Agora a parte do game.cpp. (Esta é uma parte opcional, você pode optar por não adicioná-la)
    Créditos: ~Mathias Kenfi
  9. Obrigado
    Mathias Kenfi recebeu reputação de Rogex Joyz em [Loot Channel] -- Tutorial como adicionar Loot Channel   
    [TESTADO EM OTX 2.1+] 8.60
     
    [TESTADO EM TFS 0.3.6] 8.54 ~ 8.60
     
     
     
    Créditos: ~Mathias Kenfi
  10. Gostei
    Mathias Kenfi deu reputação a Naze em Otimizado: AutoLoot in Sources for Otx(2 ou menor)   
    Uns dos problemas das maiorias dos otserv casual que estão online é o autoloot, alguns com erros e defeito na checagem dos containers e sempre consumindo muito por ser em lua fazendo checagens de tile, corpo, itens e etc. Por isso decidi da uma contribuição a essa comunidade que me evoluiu bastante um autoloot diretamente na source na função que insere os itens no corpo, otimizando em 100% na hr da entrega do item, e não tendo problemas ocasionais como corpos sobre corpos ou varias bags.
     
         Esse sistema já é bem comum quando comprado, mas gratuito acredito que ainda não tinha disponível, então fiz esse totalmente do 0 na source tfs 0.4 rev 3999 (do yan) e passei para Otx corrigindo alguns erros de compatibilidade.
        
        Atenção na instalação! Qualquer problema pra compilar que envolva as linhas presente no código verifique novamente se instalou corretamente antes de pedir ajuda para evitar flood. Qualquer bug, erro ou mal funcionamento encontrado pode postar que estarei corrigindo, mas não irei customizar a seu agrado, você consegue fazer isso sozinho com atenção e calma, e se precisa de ajuda é só posta as duvidas.
     
    Imagens do Sistema:
     
    Características: 
    -> Otimizado executando apenas funções necessarias -> Comandos simples e praticos -> !autoloot on/off //Autoloot estara sempre ligado, e caso queria desliga use '!autoloot off' -> !autoloot bank/bag //Define para onde ira o dinheiro coletado, direto banco ou no inventario -> !autoloot list //Lista todos itens adicionados para coleta -> !autoloot clear/clean //Remove todos itens da lista -> !autoloot add, name item, name item, ... //Adiciona itens na lista, podendo adicionar quantos quiser de uma vez. Ele retorna um messagem dizendo os itens que foram adicionados e os que deram erro e não foram adicionados, talvez por escrito errado, ja existente na lista, na lista de bloquados, etc. -> !autoloot remove, item name, item name, ... //Remove itens da lista, com a mesma logica do add. -> Opções configuravel pelo Config.lua -> AutoLoot_MoneyIDs //IDs dos Itens Moedas do servidor como gold coins, platinium coins, crystal coins. -> AutoLoot_BlockIDs //IDs dos itens bloqueados para autoloot -> AutoLoot_MaxItem //Quantidade maxima de itens para adicionar a lista -> Sistema livres de bugs ou logs de erros.  
    Instalação:
    Toda instalação será feita na source, exceto por 1 linha em talkactions.xml e 3 variáveis no config.lua
     
    Otx :
     
    Link para TFS -> https://tibiaking.com/forums/topic/101079-otimizado-autoloot-in-sources-for-tfs-036-tfs-04/
     
    Caso ocorra algum erro na compilação so mandar que ajudo a resolver, testei apenas em uma otx que tenho então nao sei se pode sugir outros problemas. Nas versões atual da Otx para servidores 10+ não ira funcionar pois algumas funções são diferente e não irei corrigir agora, em breve passo o mesmo pra tfs 1.3 e otx3.
     
    Esse sistema foi totalmente feito por mim, mas dou créditos também ao @Mathias Kenfi por me ajudar muito na evolução em lua/c++ e a tabela sql é a mesma usada no quick autoloot 1.3 postado por Pedriinz
  11. Gostei
    Mathias Kenfi recebeu reputação de felipepalmas em Alavanca Issavi   
    Você está equivocado, a função getSpectators faz uma checagem em uma area de acordo com os parâmetros fornecido e depois retorna um array com todas as criaturas encontradas. 
    local t = { players = { -- posições que os players devem ficar ao puxar a alavanca [1] = Position(33918,31626,8), [2] = Position(33919,31626,8), [3] = Position(33920,31626,8), [4] = Position(33921,31626,8), [5] = Position(33922,31626,8) }, boss = {name = "Urmahlullu the Weakened", create_pos = Position(33919,31648,8)}, destination = Position(33919,31657,8), -- posição para qual os players serão teleportados cooldown = {4, "hour"}, -- tempo para ser teleportado novamente. Ex.: {2, "sec"}, {5, "min"}, {10, "hour"}, {3, "day"} storage = 56482 -- storage não utilizado no seu servidor } -- Game.getSpectators(position[, multifloor = false[, onlyPlayer = false[, minRangeX = 0[, maxRangeX = 0[, minRangeY = 0[, maxRangeY = 0]]]]]]) function onUse(player, item, fromPosition, target, toPosition, isHotkey) local countPlayers = #Game.getSpectators(t.destination, false, true, 10, 10, 10, 10) -- Irá verificar se há players em um alcance de 10 por 10 com base na pos indicada no primeiro parâmetro if countPlayers > 0 then player:sendCancelMessage("Existem player emfrentando o boss, espere sua vez") return end local players, tab = {}, t.players for i = 1, #tab do local tile = Tile(tab[i]) if tile then local p = Player(tile:getTopCreature()) if p then if p:getStorageValue(t.storage) <= os.time() then players[#players + 1] = p:getId() end end end end if #players == 0 then player:sendCancelMessage("Um ou mais players devem esperar " .. getStrTime(t.cooldown) .. " para fazer novamente.") return true end for i = 1, #tab do local playerTile = Tile(tab[i]) local playerToGo = Player(playerTile:getTopCreature()) if playerToGo then if isInArray(players, playerToGo:getId()) then playerToGo:setStorageValue(t.storage, mathtime(t.cooldown) + os.time()) playerTile:relocateTo(t.destination) tab[i]:sendMagicEffect(CONST_ME_POFF) end end end t.destination:sendMagicEffect(CONST_ME_TELEPORT) Game.createMonster(t.boss.name, t.boss.create_pos) item:transform(item.itemid == 1945 and 1946 or 1945) return true end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end function getStrTime(table) -- by dwarfer local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"} return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or "")) end  
    Essa função não verifica se tem players em uma area, ela verifica se a 'pos' está entre 'fromPos' e 'toPos'
  12. Gostei
    Mathias Kenfi recebeu reputação de Unknown Beats em [Loot Channel] -- Tutorial como adicionar Loot Channel   
    Tópico atualizado!
  13. Curtir
    Mathias Kenfi recebeu reputação de Cat em Alavanca Issavi   
    Você está equivocado, a função getSpectators faz uma checagem em uma area de acordo com os parâmetros fornecido e depois retorna um array com todas as criaturas encontradas. 
    local t = { players = { -- posições que os players devem ficar ao puxar a alavanca [1] = Position(33918,31626,8), [2] = Position(33919,31626,8), [3] = Position(33920,31626,8), [4] = Position(33921,31626,8), [5] = Position(33922,31626,8) }, boss = {name = "Urmahlullu the Weakened", create_pos = Position(33919,31648,8)}, destination = Position(33919,31657,8), -- posição para qual os players serão teleportados cooldown = {4, "hour"}, -- tempo para ser teleportado novamente. Ex.: {2, "sec"}, {5, "min"}, {10, "hour"}, {3, "day"} storage = 56482 -- storage não utilizado no seu servidor } -- Game.getSpectators(position[, multifloor = false[, onlyPlayer = false[, minRangeX = 0[, maxRangeX = 0[, minRangeY = 0[, maxRangeY = 0]]]]]]) function onUse(player, item, fromPosition, target, toPosition, isHotkey) local countPlayers = #Game.getSpectators(t.destination, false, true, 10, 10, 10, 10) -- Irá verificar se há players em um alcance de 10 por 10 com base na pos indicada no primeiro parâmetro if countPlayers > 0 then player:sendCancelMessage("Existem player emfrentando o boss, espere sua vez") return end local players, tab = {}, t.players for i = 1, #tab do local tile = Tile(tab[i]) if tile then local p = Player(tile:getTopCreature()) if p then if p:getStorageValue(t.storage) <= os.time() then players[#players + 1] = p:getId() end end end end if #players == 0 then player:sendCancelMessage("Um ou mais players devem esperar " .. getStrTime(t.cooldown) .. " para fazer novamente.") return true end for i = 1, #tab do local playerTile = Tile(tab[i]) local playerToGo = Player(playerTile:getTopCreature()) if playerToGo then if isInArray(players, playerToGo:getId()) then playerToGo:setStorageValue(t.storage, mathtime(t.cooldown) + os.time()) playerTile:relocateTo(t.destination) tab[i]:sendMagicEffect(CONST_ME_POFF) end end end t.destination:sendMagicEffect(CONST_ME_TELEPORT) Game.createMonster(t.boss.name, t.boss.create_pos) item:transform(item.itemid == 1945 and 1946 or 1945) return true end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end function getStrTime(table) -- by dwarfer local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"} return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or "")) end  
    Essa função não verifica se tem players em uma area, ela verifica se a 'pos' está entre 'fromPos' e 'toPos'
  14. Obrigado
    Mathias Kenfi recebeu reputação de FlameArcixt em Alavanca Issavi   
    Você está equivocado, a função getSpectators faz uma checagem em uma area de acordo com os parâmetros fornecido e depois retorna um array com todas as criaturas encontradas. 
    local t = { players = { -- posições que os players devem ficar ao puxar a alavanca [1] = Position(33918,31626,8), [2] = Position(33919,31626,8), [3] = Position(33920,31626,8), [4] = Position(33921,31626,8), [5] = Position(33922,31626,8) }, boss = {name = "Urmahlullu the Weakened", create_pos = Position(33919,31648,8)}, destination = Position(33919,31657,8), -- posição para qual os players serão teleportados cooldown = {4, "hour"}, -- tempo para ser teleportado novamente. Ex.: {2, "sec"}, {5, "min"}, {10, "hour"}, {3, "day"} storage = 56482 -- storage não utilizado no seu servidor } -- Game.getSpectators(position[, multifloor = false[, onlyPlayer = false[, minRangeX = 0[, maxRangeX = 0[, minRangeY = 0[, maxRangeY = 0]]]]]]) function onUse(player, item, fromPosition, target, toPosition, isHotkey) local countPlayers = #Game.getSpectators(t.destination, false, true, 10, 10, 10, 10) -- Irá verificar se há players em um alcance de 10 por 10 com base na pos indicada no primeiro parâmetro if countPlayers > 0 then player:sendCancelMessage("Existem player emfrentando o boss, espere sua vez") return end local players, tab = {}, t.players for i = 1, #tab do local tile = Tile(tab[i]) if tile then local p = Player(tile:getTopCreature()) if p then if p:getStorageValue(t.storage) <= os.time() then players[#players + 1] = p:getId() end end end end if #players == 0 then player:sendCancelMessage("Um ou mais players devem esperar " .. getStrTime(t.cooldown) .. " para fazer novamente.") return true end for i = 1, #tab do local playerTile = Tile(tab[i]) local playerToGo = Player(playerTile:getTopCreature()) if playerToGo then if isInArray(players, playerToGo:getId()) then playerToGo:setStorageValue(t.storage, mathtime(t.cooldown) + os.time()) playerTile:relocateTo(t.destination) tab[i]:sendMagicEffect(CONST_ME_POFF) end end end t.destination:sendMagicEffect(CONST_ME_TELEPORT) Game.createMonster(t.boss.name, t.boss.create_pos) item:transform(item.itemid == 1945 and 1946 or 1945) return true end function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end function getStrTime(table) -- by dwarfer local unit = {["sec"] = "second",["min"] = "minute",["hour"] = "hour",["day"] = "day"} return tostring(table[1].." "..unit[table[2]]..(table[1] > 1 and "s" or "")) end  
    Essa função não verifica se tem players em uma area, ela verifica se a 'pos' está entre 'fromPos' e 'toPos'
  15. Obrigado
    Mathias Kenfi deu reputação a marcoshps11 em [otcv8] Como utilizar - Ip fixo, spr, encrypt, auto update   
    * Áudio de saudação *
     
    Neste tutorial, irei ensinar alguns passos inicias para utilizar o OTClientV8
     
    1º Passo: Como fixar ip e colocar a spr no local correto
     
    - Faço o download no link: https://github.com/OTCv8/otclientv8
    - Extraia o arquivo
    - Dentro da pasta principal, vá até o arquivo init.lua
     
    Neste trecho, precisará remover os comentários --[[ e ]]:
    Servers = { --[[ OTClientV8 = "http://otclient.ovh/api/login.php", OTClientV8c = "otclient.ovh:7171", OTClientV8Test = "http://otclient.ovh/api/login2.php", LocalTestServ = "127.0.0.1:7171:1098:110:30:93" ]] }  
    Ficando assim:
    Servers = { Meuserver = "127.0.0.1:7171:1098" } ficando na seguinte configuração NOME = "IP:PORTA:VERSÃO"
     
     
    Para fixar e não aparecer a lista de servers, basta alterar:
    ALLOW_CUSTOM_SERVERS = true -- if true it shows option ANOTHER on server list  
    Para:
    ALLOW_CUSTOM_SERVERS = false -- if true it shows option ANOTHER on server list  
     
    Caso queira trocar o nome do aplicativo é só mudar
    g_app.setName("OTCv8") trocando o "OTCv8" para o nome desejado, lembrando que isto irá alterar apenas o nome da janela do aplicativo
     
     
    Incluir a SPR/Dat:

    Para incluir, basta ir na pasta data, criar uma nova pasta e renomear com o nome "things" e depois criar uma outra pasta dentro dela com o nome da versão que desejar utilizar, exemplos:
    * 800
    * 860
    * 910
    * 1100
    dentro desta pasta, incluir as respectivas spr/dat da versão correspondente 

    Um vídeo objetivo do conteúdo citado acima:
     
     
     

     
    2º Passo: Remover campo "Token" da tela inicial
     
    Apesar de ser algo simples, vejo muitos perguntarem como remover este campo, vamos lá:

    - Vá até a pasta modules -> client_entergame
    - Abra o arquivo entergame.lua
    - Na linha 380 remova ou comente o trecho:
    enterGame:getChildById('accountTokenTextEdit'):clearText()  
    - Na linha 412 remova ou comente o trecho:
    G.authenticatorToken = enterGame:getChildById('accountTokenTextEdit'):getText()  
    - salve o arquivo
    - na mesma pasta, abra o arquivo entergame.otui
    - da linha 32 a 44 remova ou comente o seguinte trecho:
    MenuLabel !text: tr('Token') anchors.left: prev.left anchors.top: prev.bottom text-auto-resize: true margin-top: 8 TextEdit id: accountTokenTextEdit anchors.left: parent.left anchors.right: parent.right anchors.top: prev.bottom margin-top: 2  
    Um vídeo objetivo do conteúdo citado acima:
     
     

    3º Passo: como encriptar os arquivos
     
    - Recomendo inicialmente criar uma cópia da pasta que ira encriptar, pois não é reversivo
    - Copie o endereço da pasta onde estão os arquivos
    - Abra o cmd e navegue até esta pasta utilizando o comando cd (link do endereço da pasta)
    - utilize o comando otclient_dx.exe --encrypt
    - Aguarde o sistema sinalizar que os arquivos foram encriptados 
     
    PS: a pasta do modulo bot ( modules -> game_bot ) não pode ser encriptado, remova ela antes deste processo.
     
    Um vídeo objetivo do conteúdo citado acima:
     
     

    4º Passo: Utilizando o auto update
     
    IMPORTANTE:
    Este processo precisa ser feito exatamente como demonstrado, qualquer link errado o sistema não irá funcionar.
     
    - Dentro da pasta API, abra o arquivo updater_advanced.php
     
    em $files_dir = "/var/www/otclient/files"; é a pasta onde conterá os arquivos do otclient para download, lembrando que o caminho precisa estar especificada desde a pasta inicial
    em $files_url = "http://otclient.ovh/files"; é o link que você pode utilizar o navegador para acessar a pasta "files" a mesma pasta do processo anterior.
    em $checksum_update_interval = 60; é o tempo em segundos, que o update levará para checkar se há alguma atualização ( não é necesário alterar )
     
    - Na sua vps, dentro da pasta do SITE, cria uma pasta chamada API e outra pasta dentro dela chamada FILES
    - Envie o arquivo updater_advanced.php para a pasta API
    - De permissão 777 para pasta e subpasta API
     
    * voltando aos arquivos do otclient * 
     
    - Abra o arquivo init.lua
     
    aconselho alterar o "APP_NAME = "otclientv8", pois é o nome da pasta que ficará salva nos arquivos temporários, isso evitará conflitos com versões já existe no pc
    altere o campo updater, colocando o endereço apontado para o arquivo updater_advanced.php enviado para o seu site nos passos anteriores.
     
    - Após as edições anteriores, salve o arquivo 
    - Compacte os arquivos data, layout, modules e init.lua, renomeando para data.zip ( obrigatoriamente precisa ser zip )
    - Exclua os arquivos zipados e os demais desnecessários para os jogadores.
     
    Atenção: o auto update só funcionará se os arquivos estiverem zipado conforme descrito.
     
    - Envie todos os arquivos para a pasta files em sua vps ( recomendo zipar para enviar, poupara processamento e tempo de envio )
    - Após enviar, extraia os arquivos NA VPS, os arquivos no pc devem continuar zipado
    - Atenção nesta parte, as pastas e arquivo data / layout / modules / init.lua necessáriamente precisam estar na mesma pasta do executáveis, conforme time 4:20 no vídeo que deixarei disponível no final.
     
    lembrando: o update só aceitará arquivos editados após o tempo estipulado em checksum_update_interval , se fizer edições antes deste tempo, o sistema não irá considerar
     
     
    Um vídeo objetivo do conteúdo citado acima:
     
     
     
  16. Obrigado
    Mathias Kenfi deu reputação a diarmaint em [Novos Atributos] Critical/Dodge/Life e Mana Leech/Life e Mana Absorb   
    @Mathias Kenfi Achei um "bug"
    Se você estiver equipado um item com manaAbsorb
    e usar alguma magia de treinar ml "power down, chakra down " que contenha
    if getPlayerMana(cid) > 1 then             doPlayerAddSpentMana(cid, getPlayerMana(cid))             doPlayerAddMana(cid,-getPlayerMana(cid)) Irá perder e recuperar a mesma quantidade de mana .

    03:08 You lose 15000 mana.
    03:08 You are regenerated with 15000 manas.
     
  17. Curtir
    Mathias Kenfi recebeu reputação de Cat em [Novos Atributos] Critical/Dodge/Life e Mana Leech/Life e Mana Absorb   
    O tópico foi atualizado com correções de pequenos erros em game.cpp
  18. Curtir
    Mathias Kenfi deu reputação a Kyle Bellini em (AJUDA) EGG System   
    Testa desse modo, então.. Aproveitei e dei uma organizada também:
    local box = { [1] ={msg = "You Open a Box +3",np = "Contains a Ivysaur.",nm= 'Ivysaur'}, [2] ={msg = "You Open a Box +3",np = "Contains a Charmeleon.",nm= 'Charmeleon'}, [3] ={msg = "You Open a Box +3",np = 'Contains a Wartortle.',nm= 'Wartortle'}, [4] ={msg = "You Open a Box +3",np = 'Contains a Raichu.',nm= 'Raichu'}, [5] ={msg = "You Open a Box +3",np = 'Contains a Fearow.',nm= 'Fearow'}, [6] ={msg = "You Open a Box +3",np = 'Contains a Vileplume.',nm= 'Vileplume'}, [7] ={msg = "You Open a Box +3",np = 'Contains a Venomoth.',nm= 'Venomoth'}, [8] ={msg = "You Open a Box +3",np = 'Contains a Parasect.',nm= 'Parasect'}, [9] ={msg = "You Open a Box +3",np = 'Contains a Clefable.',nm= 'Clefable'}, [10] ={msg = "You Open a Box +3",np = 'Contains a Wigglytuff.',nm= 'Wigglytuff'}, [11] ={msg = "You Open a Box +3",np = 'Contains a Sandslash.',nm= 'Sandslash'}, [12] ={msg = "You Open a Box +3",np = 'Contains a Dugtrio.',nm= 'Dugtrio'}, [13] ={msg = "You Open a Box +3",np = 'Contains a Golduck.',nm= 'Golduck'}, [14] ={msg = "You Open a Box +3",np = 'Contains a Rapidash.',nm= 'Rapidash'}, [15] ={msg = "You Open a Box +3",np = 'Contains a Magneton.',nm= 'Magneton'}, [16] ={msg = "You Open a Box +3",np = 'Contains a Hypno.',nm= 'Hypno'}, [17] ={msg = "You Open a Box +3",np = 'Contains a Kingler.',nm= 'Kingler'}, [18] ={msg = "You Open a Box +3",np = 'Contains a Exeggutor.',nm= 'Exeggutor'}, [19] ={msg = "You Open a Box +3",np = 'Contains a Hitmonlee.',nm= 'Hitmonlee'}, [20] ={msg = "You Open a Box +3",np = 'Contains a Hitmonchan.',nm= 'Hitmonchan'}, [21] ={msg = "You Open a Box +3",np = 'Contains a Tangela.',nm= 'Tangela'}, [22] ={msg = "You Open a Box +3",np = 'Contains a Starmie.',nm= 'Starmie'}, [23] ={msg = "You Open a Box +3",np = 'Contains a Mr.Mime.',nm= 'Mr.Mime'}, [24] ={msg = "You Open a Box +3",np = 'Contains a Jolteon.',nm= 'Jolteon'}, [25] ={msg = "You Open a Box +3",np = 'Contains a Porygon.',nm= 'Porygon'} } function onUse(cid, item, fromPosition, itemEx, toPosition) function getTime(s) local n = math.floor(s / 60) s = s - (60 * n) return n, s end local e = box[math.random(1,25)] local incubadora = 7877 -- ID da incubadora local time = 4 -- tempo usado if itemEx.itemid == incubadora then if os.time()-getPlayerStorageValue(cid, 64231) <= 1296*60 then setPlayerStorageValue(cid, 49514, 4) minutes,seconds = getTime(1296*60-(os.time()-getPlayerStorageValue(cid, 64231))) return doPlayerSendCancel(cid, "Você precisa aguardar " .. minutes .. " minutos e " .. seconds .. " segundos.") elseif itemEx.itemid == incubadora and getPlayerStorageValue(cid, 49514) == 4 and os.time()-getPlayerStorageValue(cid, 64231) then setPlayerStorageValue(cid, 46574, 4) setPlayerStorageValue(cid, 64231, -1) setPlayerStorageValue(cid, 49514, -1) doPlayerSendTextMessage(cid, 27, "Este Egg está pronto para ser chocado.") elseif itemEx.itemid == incubadora and getPlayerStorageValue(cid, 46574) == 4 then doPlayerSendTextMessage(cid, 27, "Seu Egg acaba de chocar. Aqui está, cuide muito bem dele!") doRemoveItem(itemEx.uid,1) doPlayerSendTextMessage(cid,22,"Você abriu a incubadora, e recebeu um "..e.nm.."!") addPokeToPlayer(cid, e.nm, 0, nil, "poke") end end end  
  19. Gostei
    Mathias Kenfi deu reputação a Kyle Bellini em (Resolvido)[C]: in function 'doSendMagicEffect'   
    Caso o do amigo acima não funcione, teste com esse:
     
    local voc = {716, 717, 718, 719, 720, 721, 722, 723, 724, 725} -- ID das vocações que poderão usar o Pergaminho. local corpse = {3058} local id = 26684 -- Id do edo pergaminho local edo = { ["[EDO TENSEI] Anbu"] = {hp = 50000, maxhp = 50000, corpse = 3058, chance = 100}, -- Nome do Edo, HP do Edo quando summoned, max hp do edo , corpo do edo, chance de falhar. } function onUse(cid, item, frompos, item2, topos) if(not(isInArray(voc, getPlayerVocation(cid)))) then return doPlayerSendTextMessage(cid, 25, "Voce nao tem a vocacao nescessaria") end if(not(isInArray(corpse, item2.itemid))) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "voce precisa usar o pergaminho em um corpse") doSendMagicEffect(getThingPos(cid), 21) return true end local perga = doPlayerAddItem(cid, id, 1) for edo_tensei, v in pairs(edo) do if item2.itemid == v.corpse then if math.random(0,100) <= v.chance then doSendMagicEffect(getThingPos(cid), 21) doPlayerSendTextMessage(cid, 27, "".. edo_tensei .. " foi selado nesse pergaminho.") doRemoveItem(item.uid, 1) doRemoveItem(item2.uid, 1) doItemSetAttribute(perga, "namepet", edo_tensei) doItemSetAttribute(perga, "description", "Neste pergaminho foi selado um ".. edo_tensei ..".") doItemSetAttribute(perga, "lifepet", v.hp) doItemSetAttribute(perga, "maxlifepet", v.maxhp) else doPlayerSendTextMessage(cid, 27, "O pergaminho falhou") end end end return true end  
  20. Curtir
    Mathias Kenfi recebeu reputação de Cat em (Resolvido)[TFS1.2] Vortex Cults De Carlin   
    ERROR na linha 27
    portal2:remove(1) end, 1*60*1000, 26394, 1, posCorpo)
     
    Está apenas faltando um () 
    portal2:remove(1) end, (1*60*1000, 26394, 1, posCorpo)
     
     
  21. Curtir
    Mathias Kenfi deu reputação a Movie em Gerenciador de Quests [TFS 0.X e TFS 1.X]   
    Fala pessoal, como vocês estão?
    Na academia de codding um usuário pediu ajuda para montar um "gerenciador" de quests, para que todas ficassem no mesmo arquivo sem ficar com aquele "spam" de quests nas actions.

    Esse script foi feito para a TFS 1.X mas, usando a lib do @Mathias Kenfi, você consegue utilizar para TFS 0.X também.

    O link para as libs: https://github.com/kenfi2/KenfiLib

    Na pasta actions/scripts crie um arquivo chamado quests.lua
    config = { quests = { [7172] = { -- ActionID que será colocado no baú name = "dos Crystal Coins", -- Nome da quest rewards = { {id = 2160, count = 100}, -- Prêmio: ID - Count }, level = { active = true, -- Level minimo para pegar? min = 150, -- Se true, qual o minimo }, storage = { active = true, -- Player poderá pegar somente uma vez? key = 91143, -- Apenas uma key por quest }, effectWin = 30, -- Efeito que vai aparecer quando fizer a quest }, [7171] = { -- ActionID que será colocado no baú name = "dos Coins", -- Nome da quest rewards = { {id = 2160, count = 100}, -- Prêmio: ID - Count {id = 2152, count = 100}, -- Prêmio: ID - Count }, level = { active = true, -- Level minimo para pegar? min = 150, -- Se true, qual o minimo }, storage = { active = true, -- Player poderá pegar somente uma vez? key = 91140, -- Apenas uma key por quest }, effectWin = 29, -- Efeito que vai aparecer quando fizer a quest }, }, messages = { notExist = "Essa quest não existe.", win = "Você fez a quest %s.", notWin = "Você já fez a quest %s.", level = "Você precisa de level %d ou maior para fazer a quest %s.", }, } function onUse(cid, item, fromPosition, target, toPosition, isHotkey) local player = Player(cid) local choose = config.quests[item.actionid] if not choose then player:sendCancelMessage(config.messages.notExist) player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end if choose.level.active and player:getLevel() < choose.level.min then player:sendCancelMessage(config.messages.level:format(choose.level.min, choose.name)) player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end if choose.storage.active and player:getStorageValue(choose.storage.key) >= 0 then player:sendCancelMessage(config.messages.notWin:format(choose.name)) player:getPosition():sendMagicEffect(CONST_ME_POFF) return true end for i = 1, #choose.rewards do player:addItem(choose.rewards[i].id, choose.rewards[i].count) end player:setStorageValue(choose.storage.key, 1) player:sendCancelMessage(config.messages.win:format(choose.name)) player:getPosition():sendMagicEffect(choose.effectWin) return true end Para configurar é só utilizar ler os comentários deixados e para adicionar mais quests apenas use o mesmo padrão que deixei aí

    Utilize a tag no actions.xml desse forma
    <action fromaid="7171" toaid="7172" script="quests.lua" /> Sendo que o "fromaid" é a actionid inicial, e o "toaid" é a última actionid registrada no arquivo.

    Qualquer problema, relate nesse tópico.
  22. Curtir
    Mathias Kenfi deu reputação a Ryzor em Metamétodos   
    Metamétodos

    Bem, talvez não seja útil a todos (ou apenas não vejam a utilidade disso no começo), mas como já tinha feito um tutorial de POO em lua decidi me aprofundar mais e entrar em um assunto que não tem muita gente que sabe, ter um conhecimento intermediário sobre POO ajuda a aprender isso (saber usar a função setmetatable também), mas apenas um complementa o outro como veremos logo a seguir.


    Porque aprender ?

    Se eu dissesse que isso é necessário para programar eu estaria mentindo, mas pode acabar sendo útil, quem sabe para complementar o conhecimento de POO, mas é como eu já disse no outro tópico, aprende quem quiser.
    Metamétodos


    Metamétodos são (obviamente) associados a metatabelas, esses "métodos" são basicamente os eventos que ocorrem quando Lua (a linguagem) executa algumas operações: subtração, divisão, comparações, concatenações etc. É o que chamam em algumas linguagens de sobrecarregar operador (basicamente é a mesma coisa), cada evento tem um nome, adição é "add", exponenciação é "pow", concatenação é "concat", mais a frente eu cito todos e suas funções. Um exemplo, que caso você já saiba POO já deve ter visto é esse:



    Classe = {} function Classe:new() return setmetatable({}, { __index = self }) end Esse __index, já se perguntou o que ele faz ali ? Ele é um metamétodo também, ele simplesmente mostra que é para procurar indices(seja métodos, atributos, oque for) na tabela self (ou seja, nela mesma), e é por isso que quando você cria uma classe você consegue usar os métodos (não confunda com metamétodos), atributos dela. O 2º parametro da função setmetatable é uma tabela de metamétodos. Exemplo: metatable = {} function String(s) return setmetatable({ value = s or '' }, metatable) end function metatable.__add(a, b) return String(a.value .. b.value) end Veja que eu adicionei o metamétodo __add que se refere ao operador matemático de adição, com esse método você pode fazer isso (a seguir), tente executar e veja o resultado: s = String('Hello') print("Valor de 's' é: " .. s.value) m = s + String(' World') print("Soma de duas Strings: " .. m.value) Agora apague tudo e tente dessa maneira sem o metamétodo: metatable = {} function String(s) return setmetatable({ value = s or '' }, metatable) end s = String('Hello') print("Valor de 's' é: " .. s.value) m = s + String(' World') print("Soma de duas Strings: " .. m.value) Vai resultar em um erro. A partir disso você pode criar muitas coisas ! o exemplo acima (o que funciona) também pode ser escrito dessa maneira: function String(s) return setmetatable({ value = s or '' }, { __add = function(a,b) return String(a.value .. b.value) end }) end s = String('Hello') print("Valor de 's' é: " .. s.value) m = s + String(' World') print("Soma de duas Strings: " .. m.value) Eu pulei linha ali no setmetatable apenas pra ficar mais organizado e de fácil entendimento, não que seja necessário. Basicamente, metamétodos são os métodos que fazem operações em metatabelas lua, agora veja o mesmo exemplo acima mas sem o metamétodo: String = {} function String:new(s) return setmetatable({ value = s or '' }, { __index = self }) end function String:add(s) self.value = self.value .. s.value return self.value end s = String:new('Hello') print("Valor de 's' é: " .. s.value) m = s:add(String:new(' World')) print("Soma de duas Strings: " .. m) O uso ficaria um pouco mais complicado e não daria a liberdade de você fazer isso (em negrito): s = String('Hello') print("Valor de 's' é: " .. s.value) m = s + String(' World') + String(' and ') + String('Universe') print("Soma de quatro Strings: " .. m.value) Soma de quatro objetos String ao mesmo tempo (em negrito) --- A tabela com os metamétodos, toma-se class1 como um objeto de uma classe qualquer e class2 como um outro objeto da mesma classe de class1, ou numero, ou string, ou tabela, ou userdata, ou thread ou qualquer outro tipo de dado lua: As cores não estão ali a toa, Função/Nome = o nome e função do metamétodo; Uso = Como se deve usar; Parâmetros = Quais parâmetros o metamétodo possui; Exemplo = Exemplo de quando o metamétodo irá acontecer. Você pode encontrar todas os metamétodos junto a um exemplo nesse link http://www.lua.org/manual/5.1/pt/manual.html#2.8, mas vou citar alguns exemplos: TV = {} function TV:new(marca, polegadas) return setmetatable({ marca = marca or '', polegadas = polegadas or '' }, { __add = function (tv, n) -- Metamétodo de adição if (type(n) == 'number') then return TV:new(tv.marca, tv.polegadas + n) else return TV:new(tv.marca, tv.polegadas + n.polegadas) end end, __mul = function (tv, n) -- Metamétodo de multiplicação return TV:new(tv.marca, tv.polegadas * n) end, __eq = function (tv1, tv2) -- Metamétodo de igualdade if (tv1.marca == tv2.marca and tv1.polegadas == tv2.polegadas) then return true end return false end }) end tv1 = TV:new("LG", 21) tv2 = TV:new("Philips", 19) tv1 = tv1 + 4 -- Adiciono 3 a tv1 print(tv1.polegadas) -- tv1 fica com 25 polegadas tv2 = tv1 + tv2 -- Adiciono as polegadas da tv1 na tv2 print(tv2.polegadas) tv1 = tv1 * 2 -- Multiplico as polegadas da tv1 por 2 print(tv1.polegadas) if (tv1 == tv2) then print('tv1 é igual a tv2 !') else print('tv1 não é igual a tv2') end tv1 = tv2 -- Agora tv1 é igual a tv2 if (tv1 == tv2) then print('tv1 é igual a tv2 !') else print('tv1 não é igual a tv2') end O exemplo é ruim eu sei, mas to sem criatividade D: Explicação detalhada: Agora uma explicação passo a passo de um metamétodo, vou aproveitar o da TV: __add = function (tv, n) -- Metamétodo de adição if (type(n) == 'number') then return TV:new(tv.marca, tv.polegadas + n) else return TV:new(tv.marca, tv.polegadas + n.polegadas) end end e uma soma qualquer: tv1 = tv1 + 4





    O metamétodo tem 2 parametros, tv e n (você pode escolher o nome que quiser), tv e n referem-se a tv1 e 4 na soma respectivamente, ou seja, o __add (linha 1) vai verificar se o n é um numero (linha 2) e caso for ele vai retornar outro objeto da classe TV , com a mesma marca da tv mas com as polegadas somadas ao numero n (linha 3) , mas caso não for um numero (linha 4) vai manter a marca da tv e somar as polegadas da tv e da TV n (linha 5) . Novamente, as cores (e o negrito) não estão ali a toa.

    Bem é um pouco complicadinho, mas todos (a maioria) dos metamétodos seguem esse mesmo padrão de 2 parametros, ai facilita um pouco

    ---


    Espero que alguém tenha compreendido, tentei ser o mais claro possível, caso contrario eu refaço as partes que estão complicadas,
    Qualquer dúvida, sugestão, critica, só postar !
    Quem quiser pode me enviar sugestões de temas para tutoriais sobre scripting e programação, algum assunto que não entendeu, que não viu no forum ou que faltou algo mais detalhado.




    Creditos


    Lwkass
  23. Obrigado
    Mathias Kenfi recebeu reputação de Senju uchira em [Novos Atributos] Critical/Dodge/Life e Mana Leech/Life e Mana Absorb   
    Esse sistema foi feito utilizando a source disponibilizada neste link
    Pode funcionar em TFS 0.4, OTX 2.X e, talvez, em TFS 0.4 só que a probabilidade erros é maior por ter diferentes nomes de funções e variáveis.
     
    Fiz um vídeo seguindo o passo a passo abaixo para facilitar o processo de instalação do sistema.
     
    Hoje estarei ensinando a instalar os seguintes novos atributos/sistemas em sua source
    CriticalHitChance e DodgeChance -- (Funciona da mesma maneira que o critical básico de script, porém sem bugs de callstack) Life e Mana Absorb -- (Regenera, de acordo com a % atribuida, a partir de dano recebido) Life e Mana Leech -- (Regenera, de acordo com a % atribuida, a partir do dano causado) Exemplo de como vai ficar
    Primeiro e antes de tudo, você terá de desativar o critical padrão do Tibia (Você pode pular essa parte se quiser)
     
    Vamos lá! Vá em items.cpp e procure por:
    attackSpeed = 0; Abaixo coloque:
    criticalHitChance = dodgeChance = lifeAbsorb = manaAbsorb = lifeLeech = manaLeech = 0; Depois, ainda em items.cpp, procure por:
    else if(tmpStrValue == "extradefense" || tmpStrValue == "extradef") { if(readXMLInteger(itemAttributesNode, "chance", intValue)) it.extraDefenseChance = intValue; if(readXMLInteger(itemAttributesNode, "value", intValue)) it.extraDefense = intValue; if(readXMLInteger(itemAttributesNode, "random_min", intValue)) it.extraDefenseRndMin = intValue; if(readXMLInteger(itemAttributesNode, "random_max", intValue)) it.extraDefenseRndMax = intValue; } Abaixo coloque:
    else if(tmpStrValue == "criticalhitchance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.criticalHitChance = intValue; } else if(tmpStrValue == "dodgechance") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.dodgeChance = intValue; } else if(tmpStrValue == "lifeabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeAbsorb = intValue; } else if(tmpStrValue == "manaabsorb") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaAbsorb = intValue; } else if(tmpStrValue == "lifeleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.lifeLeech = intValue; } else if(tmpStrValue == "manaleech") { if(readXMLInteger(itemAttributesNode, "value", intValue)) it.manaLeech = intValue; } Agora vá em items.h e procure por:
    int32_t attack, extraAttack, defense, extraDefense, armor, breakChance, hitChance, maxHitChance, runeLevel, runeMagLevel, lightLevel, lightColor, decayTo, rotateTo, alwaysOnTopOrder; Abaixo coloque:
    int32_t criticalHitChance, dodgeChance, lifeAbsorb, manaAbsorb, lifeLeech, manaLeech;  
     
    Agora vá em item.cpp e procure por:
    case ATTR_ATTACK: { int32_t attack; if(!propStream.getLong((uint32_t&)attack)) return ATTR_READ_ERROR; setAttribute("attack", attack); break; } Acima coloque:
    case ATTR_CRITICALHITCHANCE: { int32_t criticalHitChance; if(!propStream.getLong((uint32_t&)criticalHitChance)) return ATTR_READ_ERROR; setAttribute("criticalhitchance", criticalHitChance); break; } case ATTR_DODGECHANCE: { int32_t dodgeChance; if(!propStream.getLong((uint32_t&)dodgeChance)) return ATTR_READ_ERROR; setAttribute("dodgechance", dodgeChance); break; } case ATTR_LIFEABSORB: { int32_t lifeAbsorb; if(!propStream.getLong((uint32_t&)lifeAbsorb)) return ATTR_READ_ERROR; setAttribute("lifeabsorb", lifeAbsorb); break; } case ATTR_MANAABSORB: { int32_t manaAbsorb; if(!propStream.getLong((uint32_t&)manaAbsorb)) return ATTR_READ_ERROR; setAttribute("manaabsorb", manaAbsorb); break; } case ATTR_LIFELEECH: { int32_t lifeLeech; if(!propStream.getLong((uint32_t&)lifeLeech)) return ATTR_READ_ERROR; setAttribute("lifeleech", lifeLeech); break; } case ATTR_MANALEECH: { int32_t manaLeech; if(!propStream.getLong((uint32_t&)manaLeech)) return ATTR_READ_ERROR; setAttribute("manaleech", manaLeech); break; } Procure por:
    if(it.weaponType == WEAPON_DIST && it.ammoType != AMMO_NONE) { begin = false; s << " (Range:" << int32_t(item ? item->getShootRange() : it.shootRange); if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { s << ", Atk " << std::showpos << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } if(it.hitChance != -1 || (item && item->getHitChance() != -1)) s << ", Hit% " << std::showpos << (item ? item->getHitChance() : it.hitChance) << std::noshowpos; } else if(it.weaponType != WEAPON_AMMO && it.weaponType != WEAPON_WAND) { if(it.attack || it.extraAttack || (item && (item->getAttack() || item->getExtraAttack()))) { begin = false; s << " (Atk:"; if(it.abilities.elementType != COMBAT_NONE && it.decayTo < 1) { s << std::max((int32_t)0, int32_t((item ? item->getAttack() : it.attack) - it.abilities.elementDamage)); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; s << " physical + " << it.abilities.elementDamage << " " << getCombatName(it.abilities.elementType); } else { s << int32_t(item ? item->getAttack() : it.attack); if(it.extraAttack || (item && item->getExtraAttack())) s << " " << std::showpos << int32_t(item ? item->getExtraAttack() : it.extraAttack) << std::noshowpos; } } if(it.defense || it.extraDefense || (item && (item->getDefense() || item->getExtraDefense()))) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Def:" << int32_t(item ? item->getDefense() : it.defense); if(it.extraDefense || (item && item->getExtraDefense())) s << " " << std::showpos << int32_t(item ? item->getExtraDefense() : it.extraDefense) << std::noshowpos; } } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Procure por:
    int32_t tmp = it.armor; if(item) tmp = item->getArmor(); bool begin = true; if(tmp) { s << " (Arm:" << tmp; begin = false; } Abaixo coloque:
    if(it.criticalHitChance || (item && item->getCriticalHitChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Crit Chance:" << std::showpos << int32_t(item ? item->getCriticalHitChance() : it.criticalHitChance) << "%"<< std::noshowpos; } if(it.dodgeChance || (item && item->getDodgeChance())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Dodge Chance:" << std::showpos << int32_t(item ? item->getDodgeChance() : it.dodgeChance) << "%"<< std::noshowpos; } if(it.lifeAbsorb || (item && item->getLifeAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Absorb:" << std::showpos << int32_t(item ? item->getLifeAbsorb() : it.lifeAbsorb) << "%"<< std::noshowpos; } if(it.manaAbsorb || (item && item->getManaAbsorb())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Absorb:" << std::showpos << int32_t(item ? item->getManaAbsorb() : it.manaAbsorb) << "%"<< std::noshowpos; } if(it.lifeLeech || (item && item->getLifeLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Life Leech:" << std::showpos << int32_t(item ? item->getLifeLeech() : it.lifeLeech) << "%"<< std::noshowpos; } if(it.manaLeech || (item && item->getManaLeech())) { if(begin) { begin = false; s << " ("; } else s << ", "; s << "Mana Leech:" << std::showpos << int32_t(item ? item->getManaLeech() : it.manaLeech) << "%"<< std::noshowpos; } Agora vá em item.h e procure por:
    ATTR_DUALWIELD = 43, Abaixo coloque:
    ATTR_CRITICALHITCHANCE = 44, ATTR_DODGECHANCE = 45, ATTR_LIFEABSORB = 46, ATTR_MANAABSORB = 47, ATTR_LIFELEECH = 48, ATTR_MANALEECH = 49, Procure por:
    int32_t getExtraDefense() const; Abaixo coloque:
    int32_t getCriticalHitChance() const; int32_t getDodgeChance() const; int32_t getLifeAbsorb() const; int32_t getManaAbsorb() const; int32_t getLifeLeech() const; int32_t getManaLeech() const; Procure por:
    inline int32_t Item::getExtraDefense() const { bool ok; int32_t v = getIntegerAttribute("extradefense", ok); if(ok) return v; return items[id].extraDefense; } Abaixo coloque:
    inline int32_t Item::getCriticalHitChance() const { bool ok; int32_t v = getIntegerAttribute("criticalhitchance", ok); if(ok) return v; return items[id].criticalHitChance; } inline int32_t Item::getDodgeChance() const { bool ok; int32_t v = getIntegerAttribute("dodgechance", ok); if(ok) return v; return items[id].dodgeChance; } inline int32_t Item::getLifeAbsorb() const { bool ok; int32_t v = getIntegerAttribute("lifeabsorb", ok); if(ok) return v; return items[id].lifeAbsorb; } inline int32_t Item::getManaAbsorb() const { bool ok; int32_t v = getIntegerAttribute("manaabsorb", ok); if(ok) return v; return items[id].manaAbsorb; } inline int32_t Item::getLifeLeech() const { bool ok; int32_t v = getIntegerAttribute("lifeleech", ok); if(ok) return v; return items[id].lifeLeech; } inline int32_t Item::getManaLeech() const { bool ok; int32_t v = getIntegerAttribute("manaleech", ok); if(ok) return v; return items[id].manaLeech; }  
     
    Agora vá em player.cpp e procure por:
    int32_t Player::getArmor() const { int32_t i = SLOT_FIRST, armor = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) armor += item->getArmor(); } if(vocation->getMultiplier(MULTIPLIER_ARMOR) != 1.0) return int32_t(armor * vocation->getMultiplier(MULTIPLIER_ARMOR)); return armor; } Abaixo coloque:
    int32_t Player::getCriticalHitChance() const { int32_t i = SLOT_FIRST, crit = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) crit += item->getCriticalHitChance(); } return crit; } int32_t Player::getDodgeChance() const { int32_t i = SLOT_FIRST, dodge = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) dodge += item->getDodgeChance(); } return dodge; } int32_t Player::getLifeAbsorb() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeAbsorb(); } return life; } int32_t Player::getManaAbsorb() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaAbsorb(); } return mana; } int32_t Player::getLifeLeech() const { int32_t i = SLOT_FIRST, life = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) life += item->getLifeLeech(); } return life; } int32_t Player::getManaLeech() const { int32_t i = SLOT_FIRST, mana = 0; for(; i < SLOT_LAST; ++i) { if(Item* item = getInventoryItem((slots_t)i)) mana += item->getManaLeech(); } return mana; } Agora vá em player.h e procure por:
    virtual int32_t getDefense() const; Abaixo coloque:
    virtual int32_t getCriticalHitChance() const; virtual int32_t getDodgeChance() const; virtual int32_t getLifeAbsorb() const; virtual int32_t getManaAbsorb() const; virtual int32_t getLifeLeech() const; virtual int32_t getManaLeech() const;  
     
    Agora vá em luascript.cpp e procure por:
    //getCreatureHealth(cid) lua_register(m_luaState, "getCreatureHealth", LuaInterface::luaGetCreatureHealth); Abaixo coloque:
    //getPlayerCriticalHitChance(cid) lua_register(m_luaState, "getPlayerCriticalHitChance", LuaInterface::luaGetPlayerCriticalHitChance); //getPlayerDodgeChance(cid) lua_register(m_luaState, "getPlayerDodgeChance", LuaInterface::luaGetPlayerDodgeChance); //getPlayerLifeAbsorb(cid) lua_register(m_luaState, "getPlayerLifeAbsorb", LuaInterface::luaGetPlayerLifeAbsorb); //getPlayerManaAbsorb(cid) lua_register(m_luaState, "getPlayerManaAbsorb", LuaInterface::luaGetPlayerManaAbsorb); //getPlayerLifeLeech(cid) lua_register(m_luaState, "getPlayerLifeLeech", LuaInterface::luaGetPlayerLifeLeech); //getPlayerManaLeech(cid) lua_register(m_luaState, "getPlayerManaLeech", LuaInterface::luaGetPlayerManaLeech); Procure por:
    int32_t LuaInterface::luaGetCreatureMaxHealth(lua_State* L) { //getCreatureMaxHealth(cid[, ignoreModifiers = false]) bool ignoreModifiers = false; if(lua_gettop(L) > 1) ignoreModifiers = popBoolean(L); ScriptEnviroment* env = getEnv(); if(Creature* creature = env->getCreatureByUID(popNumber(L))) lua_pushnumber(L, creature->getPlayer() && ignoreModifiers ? creature->healthMax : creature->getMaxHealth()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Abaixo coloque:
    int32_t LuaInterface::luaGetPlayerCriticalHitChance(lua_State* L) { //getPlayerCriticalHitChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getCriticalHitChance()); else { errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerDodgeChance(lua_State* L) { //getPlayerDodgeChance(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getDodgeChance()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeAbsorb(lua_State* L) { //getPlayerLifeAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaAbsorb(lua_State* L) { //getPlayerManaAbsorb(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaAbsorb()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerLifeLeech(lua_State* L) { //getPlayerLifeLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getLifeLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } int32_t LuaInterface::luaGetPlayerManaLeech(lua_State* L) { //getPlayerManaLeech(cid) ScriptEnviroment* env = getEnv(); if(Player* player = env->getPlayerByUID(popNumber(L))) lua_pushnumber(L, player->getManaLeech()); else { errorEx(getError(LUA_ERROR_CREATURE_NOT_FOUND)); lua_pushboolean(L, false); } return 1; } Agora vá em luascript.h e procure por:
    static int32_t luaGetPlayerSpentMana(lua_State* L); Abaixo coloque:
    static int32_t luaGetPlayerCriticalHitChance(lua_State* L); static int32_t luaGetPlayerDodgeChance(lua_State* L); static int32_t luaGetPlayerLifeAbsorb(lua_State* L); static int32_t luaGetPlayerManaAbsorb(lua_State* L); static int32_t luaGetPlayerLifeLeech(lua_State* L); static int32_t luaGetPlayerManaLeech(lua_State* L);  
    As funções Lua adicionadas foram
    getPlayerCriticalHitChance(cid) getPlayerDodgeChance(cid) getPlayerLifeAbsorb(cid) getPlayerManaAbsorb(cid) getPlayerLifeLeech(cid) getPlayerManaLeech(cid)  
    Agora a parte do game.cpp. (Esta é uma parte opcional, você pode optar por não adicioná-la)
    Créditos: ~Mathias Kenfi
  24. Gostei
    Mathias Kenfi recebeu reputação de Senju uchira em [Novos Atributos] Critical/Dodge/Life e Mana Leech/Life e Mana Absorb   
    Essa parte não tem na TFS 0.4 porque essa é a parte que você precisa implementar. Sugiro que preste atenção nas modificações que você precisa fazer, está tudo certo o passo a passo que foi testado na TFS 0.4 e na OTX 2.X que é, inclusive, baseado na TFS 0.4
     
    As linhas que não existem em algumas TFS 0.4, como attackSpeed, foram alteradas. Recomendo que para aqueles que não conseguiram, refaçam as alterações que fizeram e comecem novamente.
  25. Obrigado
    Mathias Kenfi deu reputação a MayconPhP em Implementação PicPay-Didático   
    Olá pessoal do Tibia King sou o Maycon, sou desenvolvedor Web.
    E para ajudar as pessoas que tem interesse em aprender PHP resolvi fazer 1 tutorial de como implementar o PicPay no gesior. O vídeo tem o intuito de ajudar a pessoas que tenha dúvida de como funciona o Gesior.
    OBS: o vídeo é apenas para fins didático, então para implementação você precisará fazer uma regra de negócio de acordo com o que precisa para implementação.
     
    Espero ter ajudado abraços.
     
    Video 1
    Video 2
    Video 3
    Video 4
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo