Postado Novembro 23, 2016 8 anos Estou com um código que peguei em outro fórum, que é bem legal, que pode dar uma dinâmica diferente ao jogo. O código consiste em permitir que no vocations.xml, acrescente-se a cada vocação, um aumento ou diminuição da proteção contra determinado elemento a escolha do dono do server. Ex: <vocation id="1" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="5" gainhpamount="4" gainmanaticks="4" gainmanaamount="8" manamultiplier="1.1" attackspeed="1500" soulmax="100" gainsoulticks="120" fromvoc="1" energyDamage="80" fireDamage="90"> No exemplo, a vocação sorcerer está recebendo apenas 80% de dano de energy e 90% de dano de fire. Quando não acrescentados no xml, os outros danos ficam todos normais. Enfim, vamos ao código. < Spoiler Start of the code: game.cpp Add... Code: Player* targetPlayer = target->getPlayer(); if(targetPlayer) { healthChange = -healthChange; switch (combatType) { case COMBAT_FIREDAMAGE: healthChange = ( healthChange * targetPlayer->getFireDamage() ) / 100; break; case COMBAT_ENERGYDAMAGE: healthChange = ( healthChange * targetPlayer->getEnergyDamage() ) / 100; break; case COMBAT_EARTHDAMAGE: healthChange = ( healthChange * targetPlayer->getEarthDamage() ) / 100; break; case COMBAT_DROWNDAMAGE: healthChange = ( healthChange * targetPlayer->getDrownDamage() ) / 100; break; case COMBAT_PHYSICALDAMAGE: healthChange = ( healthChange * targetPlayer->getPhysicalDamage() ) / 100; break; case COMBAT_DEATHDAMAGE: healthChange = ( healthChange * targetPlayer->getDeathDamage() ) / 100; break; case COMBAT_ICEDAMAGE: healthChange = ( healthChange * targetPlayer->getIceDamage() ) / 100; break; case COMBAT_HOLYDAMAGE: healthChange = ( healthChange * targetPlayer->getHolyDamage() ) / 100; break; } healthChange = -healthChange; if ( healthChange == 0 ) return false; } ...under Code: bool Game::combatChangeHealth(CombatType_t combatType, Creature* attacker, Creature* target, int32_t healthChange) { const Position& targetPos = target->getPosition(); if(healthChange > 0) { if(target->getHealth() <= 0) return false; if(attacker && target && attacker->defaultOutfit.lookFeet == target->defaultOutfit.lookFeet && g_config.getString(ConfigManager::CANNOT_ATTACK_SAME_LOOKFEET) == "yes" && combatType != COMBAT_HEALING) return false; target->changeHealth(healthChange); } else{ SpectatorVec list; getSpectators(list, targetPos, true); if(!target->isAttackable() || Combat::canDoCombat(attacker, target) != RET_NOERROR) { addMagicEffect(list, targetPos, NM_ME_POFF); return true; } if(attacker && target && attacker->defaultOutfit.lookFeet == target->defaultOutfit.lookFeet && g_config.getString(ConfigManager::CANNOT_ATTACK_SAME_LOOKFEET) == "yes" && combatType != COMBAT_HEALING) return false; player.h Add... Code: uint32_t getFireDamage() const {return vocation->getFireDamage();} uint32_t getEnergyDamage() const {return vocation->getEnergyDamage();} uint32_t getEarthDamage() const {return vocation->getEarthDamage();} uint32_t getDrownDamage() const {return vocation->getDrownDamage();} uint32_t getPhysicalDamage() const {return vocation->getPhysicalDamage();} uint32_t getDeathDamage() const {return vocation->getDeathDamage();} uint32_t getIceDamage() const {return vocation->getIceDamage();} uint32_t getHolyDamage() const {return vocation->getHolyDamage();} ...under Code: uint32_t getAttackSpeed() const {return vocation->getAttackSpeed();} vocation.cpp Add... Code: if(readXMLInteger(p, "fireDamage", intVal)){ voc->fireDamage = intVal; } if(readXMLInteger(p, "energyDamage", intVal)){ voc->energyDamage = intVal; } if(readXMLInteger(p, "earthDamage", intVal)){ voc->earthDamage = intVal; } if(readXMLInteger(p, "drownDamage", intVal)){ voc->drownDamage = intVal; } if(readXMLInteger(p, "physicalDamage", intVal)){ voc->physicalDamage = intVal; } if(readXMLInteger(p, "deathDamage", intVal)){ voc->deathDamage = intVal; } if(readXMLInteger(p, "iceDamage", intVal)){ voc->iceDamage = intVal; } if(readXMLInteger(p, "holyDamage", intVal)){ voc->holyDamage = intVal; } ...under Code: if(readXMLInteger(p, "fromvoc", intVal)){ voc->fromVocation = intVal; } Add... Code: fireDamage = 100; energyDamage = 100; earthDamage = 100; drownDamage = 100; physicalDamage = 100; deathDamage = 100; iceDamage = 100; holyDamage = 100; ...under Code: fromVocation = 0; vocation.h Add... Code: uint32_t getFireDamage() const {return fireDamage;} uint32_t getEnergyDamage() const {return energyDamage;} uint32_t getEarthDamage() const {return earthDamage;} uint32_t getDrownDamage() const {return drownDamage;} uint32_t getPhysicalDamage() const {return physicalDamage;} uint32_t getDeathDamage() const {return deathDamage;} uint32_t getIceDamage() const {return iceDamage;} uint32_t getHolyDamage() const {return holyDamage;} ...under Code: uint32_t getFromVocation() const {return fromVocation;} Add... Code: uint32_t fireDamage; uint32_t energyDamage; uint32_t earthDamage; uint32_t drownDamage; uint32_t physicalDamage; uint32_t deathDamage; uint32_t iceDamage; uint32_t holyDamage; ...under Code: uint32_t attackSpeed; Quem puder ajudar, ficarei muito agradecido. Eu vi no outro fórum, falando que quando era dado utamo vita, o player voltava a sofrer dano normal, sem o acréscimo nem decréscimo alterado no xml. Então, se puderem ajudar nisso também, seria uma ótima Editado Novembro 23, 2016 8 anos por gabriel28 (veja o histórico de edições)
Postado Novembro 26, 2016 8 anos Solução Se eu entendi certo, para o que você quer já existe uma função para isso, pouco usada e pouco conhecida, mas acho que funciona para o que você quer. tente deixar assim e veja o resultado: <vocation id="1" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="3" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="1"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/> <absorb percentFire="10" percentEnergy="20"/> </vocation> no caso vai absorver 10% de fire e 20% de energy, no caso recebendo apenas 90% do dano sofrido de fire e apenas 80% do dano sofrido de energy. Aguardando resposta.
Postado Novembro 27, 2016 8 anos Autor Valeu, cara. Achei que essa função era apenas pra itens. Muito obrigado mesmo.
Postado Novembro 27, 2016 8 anos 1 minuto atrás, gabriel28 disse: Valeu, cara. Achei que essa função era apenas pra itens. Muito obrigado mesmo. Disponha :D, vou reportar para que fechem seu pedido, já que foi resolvido.
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.