Kevin Luzetti 42 Postado 30 de Junho Compartilhar Postado 30 de Junho Oi galera boa noite, estava com um problema na minha source, e resolvi ele da seguinte maneira: bool Player::onDeath() { Item* preventLoss = NULL; Item* preventDrop = NULL; if(getZone() == ZONE_PVP) { setDropLoot(LOOT_DROP_NONE); setLossSkill(false); } else if(skull < SKULL_RED && g_game.getWorldType() != WORLD_TYPE_PVP_ENFORCED) { Item* item = NULL; for(int32_t i = SLOT_FIRST; ((skillLoss || lootDrop == LOOT_DROP_FULL) && i < SLOT_LAST); ++i) { if(!(item = getInventoryItem((slots_t)i)) || (g_moveEvents->hasEquipEvent(item) && !isItemAbilityEnabled((slots_t)i))) continue; const ItemType& it = Item::items[item->getID()]; if(lootDrop == LOOT_DROP_FULL && it.abilities.preventDrop) { setDropLoot(LOOT_DROP_PREVENT); preventDrop = item; } if(skillLoss && !preventLoss && it.abilities.preventLoss) preventLoss = item; } } if(!Creature::onDeath()) { if(preventDrop) setDropLoot(LOOT_DROP_FULL); return false; } if(preventLoss) { setLossSkill(false); if(preventLoss->getCharges() > 1) //weird, but transform failed to remove for some hosters g_game.transformItem(preventLoss, preventLoss->getID(), std::max(0, ((int32_t)preventLoss->getCharges() - 1))); else g_game.internalRemoveItem(NULL, preventDrop); } if(preventDrop && preventDrop != preventLoss) { if(preventDrop->getCharges() > 1) //weird, but transform failed to remove for some hosters g_game.transformItem(preventDrop, preventDrop->getID(), std::max(0, ((int32_t)preventDrop->getCharges() - 1))); else g_game.internalRemoveItem(NULL, preventDrop); } removeConditions(CONDITIONEND_DEATH); if(skillLoss) { uint64_t lossExperience = getLostExperience(); removeExperience(lossExperience, false); double percent = 1. - ((double)(experience - lossExperience) / experience); //Magic level loss uint32_t sumMana = 0; uint64_t lostMana = 0; for(uint32_t i = 1; i <= magLevel; ++i) sumMana += vocation->getReqMana(i); sumMana += manaSpent; lostMana = (uint64_t)std::ceil(sumMana * ((double)(percent * lossPercent[LOSS_MANA]) / 100.)); while(lostMana > manaSpent && magLevel > 0) { lostMana -= manaSpent; manaSpent = vocation->getReqMana(magLevel); magLevel--; } manaSpent -= std::max((int32_t)0, (int32_t)lostMana); uint64_t nextReqMana = vocation->getReqMana(magLevel + 1); if(nextReqMana > vocation->getReqMana(magLevel)) magLevelPercent = Player::getPercentLevel(manaSpent, nextReqMana); else magLevelPercent = 0; //Skill loss uint32_t lostSkillTries, sumSkillTries; for(int16_t i = 0; i < 7; ++i) //for each skill { lostSkillTries = sumSkillTries = 0; for(uint32_t c = 11; c <= skills[i][SKILL_LEVEL]; ++c) //sum up all required tries for all skill levels sumSkillTries += vocation->getReqSkillTries(i, c); sumSkillTries += skills[i][SKILL_TRIES]; lostSkillTries = (uint32_t)std::ceil(sumSkillTries * ((double)(percent * lossPercent[LOSS_SKILLS]) / 100.)); while(lostSkillTries > skills[i][SKILL_TRIES]) { lostSkillTries -= skills[i][SKILL_TRIES]; skills[i][SKILL_TRIES] = vocation->getReqSkillTries(i, skills[i][SKILL_LEVEL]); if(skills[i][SKILL_LEVEL] < 11) { skills[i][SKILL_LEVEL] = 10; skills[i][SKILL_TRIES] = lostSkillTries = 0; break; } else skills[i][SKILL_LEVEL]--; } skills[i][SKILL_TRIES] = std::max((int32_t)0, (int32_t)(skills[i][SKILL_TRIES] - lostSkillTries)); } blessings = 0; loginPosition = masterPosition; if(!inventory[SLOT_BACKPACK]) __internalAddThing(SLOT_BACKPACK, Item::CreateItem(g_config.getNumber(ConfigManager::DEATH_CONTAINER))); sendIcons(); sendStats(); sendSkills(); sendReLoginWindow(); g_game.removeCreature(this, false); } else { setLossSkill(true); if(preventLoss) { loginPosition = masterPosition; sendReLoginWindow(); g_game.removeCreature(this, false); } } return true; } substitui essa parte: for(int16_t i = 0; i < 7; ++i) //for each skill { lostSkillTries = sumSkillTries = 0; for(uint32_t c = 11; c <= skills[i][SKILL_LEVEL]; ++c) //sum up all required tries for all skill levels sumSkillTries += vocation->getReqSkillTries(i, c); sumSkillTries += skills[i][SKILL_TRIES]; lostSkillTries = (uint32_t)std::ceil(sumSkillTries * ((double)(percent * lossPercent[LOSS_SKILLS]) / 100.)); while(lostSkillTries > skills[i][SKILL_TRIES]) { lostSkillTries -= skills[i][SKILL_TRIES]; skills[i][SKILL_TRIES] = vocation->getReqSkillTries(i, skills[i][SKILL_LEVEL]); if(skills[i][SKILL_LEVEL] < 11) { skills[i][SKILL_LEVEL] = 10; skills[i][SKILL_TRIES] = lostSkillTries = 0; break; } else skills[i][SKILL_LEVEL]--; } skills[i][SKILL_TRIES] = std::max((int32_t)0, (int32_t)(skills[i][SKILL_TRIES] - lostSkillTries)); } por essa: for(int16_t i = 0; i < 7; ++i) // for each skill { // Protege as skills 3 (Fishing), 4 (Shielding) e 6 (Headbutt/Torneio) if(i == 3 || i == 4 || i == 6) continue; lostSkillTries = sumSkillTries = 0; for(uint32_t c = 11; c <= skills[i][SKILL_LEVEL]; ++c) sumSkillTries += vocation->getReqSkillTries(i, c); sumSkillTries += skills[i][SKILL_TRIES]; lostSkillTries = (uint32_t)std::ceil(sumSkillTries * ((double)(percent * lossPercent[LOSS_SKILLS]) / 100.)); while(lostSkillTries > skills[i][SKILL_TRIES]) { lostSkillTries -= skills[i][SKILL_TRIES]; skills[i][SKILL_TRIES] = vocation->getReqSkillTries(i, skills[i][SKILL_LEVEL]); if(skills[i][SKILL_LEVEL] < 11) { skills[i][SKILL_LEVEL] = 10; skills[i][SKILL_TRIES] = lostSkillTries = 0; break; } else { skills[i][SKILL_LEVEL]--; } } skills[i][SKILL_TRIES] = std::max((int32_t)0, (int32_t)(skills[i][SKILL_TRIES] - lostSkillTries)); } no meu caso coloquei pra skills 3 4 e 6 n perderem xp bom é isso. 1 Link para o comentário https://tibiadevs.com/forums/topic/1167-skill-id-perdendo-xp/ Compartilhar em outros sites Mais opções de compartilhamento...
Posts Recomendados
Crie uma conta ou entre para comentar
Você precisar ser um membro para fazer um comentário
Criar uma conta
Crie uma nova conta em nossa comunidade. É fácil!
Crie uma nova contaEntrar
Já tem uma conta? Faça o login.
Entrar Agora