Ir para conteúdo
Banner com Efeitos

Featured Replies

Postado

Estou com seguinte problema em um código!

 

Estou tentando fazer com que seja possivel conjurar runas na backpack (atualmente só e possível realizar isso se você estiver com ela nas mãos).

 

Não estou conseguindo implementar de maneira alguma...

 

Segue o bloco do código em questão:

 

Spells.cpp

bool ConjureSpell::conjureItem(Creature* creature) const
{
	Player* player = creature->getPlayer();
	if (!player) {
		return false;
	}

	const uint32_t conjureCost = getManaCost(player);
	const uint32_t soulCost = getSoulCost();

	if (reagentId != 0) {
		bool foundReagent = false;

		Item* item = player->getInventoryItem(CONST_SLOT_LEFT);
		if (item && item->getID() == reagentId) {
			foundReagent = true;

			// left arm conjure
			int32_t index = player->getThingIndex(item);
			g_game.internalRemoveItem(item);

			Item* newItem = Item::CreateItem(conjureId, conjureCount);
			if (!newItem) {
				return false;
			}

			ReturnValue ret = g_game.internalAddItem(player, newItem, index);
			if (ret != RETURNVALUE_NOERROR) {
				delete newItem;
				return false;
			}

			g_game.startDecay(newItem);

			Spell::postCastSpell(player, conjureCost, soulCost);
		}

		item = player->getInventoryItem(CONST_SLOT_RIGHT);
		if (item && item->getID() == reagentId && player->getMana() >= conjureCost) {
			foundReagent = true;

			// right arm conjure
			int32_t index = player->getThingIndex(item);
			g_game.internalRemoveItem(item);

			Item* newItem = Item::CreateItem(conjureId, conjureCount);
			if (!newItem) {
				return false;
			}

			ReturnValue ret = g_game.internalAddItem(player, newItem, index);
			if (ret != RETURNVALUE_NOERROR) {
				delete newItem;
				return false;
			}

			g_game.startDecay(newItem);

			Spell::postCastSpell(player, conjureCost, soulCost);
		}

		if (!foundReagent) {
			player->sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL);
			g_game.addMagicEffect(player->getPosition(), CONST_ME_POFF);
			return false;
		}
	} else {
		Item* newItem = Item::CreateItem(conjureId, conjureCount);
		if (!newItem) {
			return false;
		}

		ReturnValue ret = g_game.internalPlayerAddItem(player, newItem);
		if (ret != RETURNVALUE_NOERROR) {
			delete newItem;
			return false;
		}

		g_game.startDecay(newItem);
		Spell::postCastSpell(player, conjureCost, soulCost);
	}

	postCastSpell(player, true, false);
	g_game.addMagicEffect(player->getPosition(), CONST_ME_MAGIC_RED);
	return true;
}



 

No signature.

 

 

 

Postado

pq você nao faz em lua mesmo?

Toda terça-feira um tópico novo:

Descanso para curar mana (Spell): https://tibiaking.com/forums/topic/94615-spell-descanso-para-curar-mana/

Peça sua spell (Suporte):                https://tibiaking.com/forums/topic/84162-peça-sua-spell/                        

Chuva de flechas (Spell):                https://tibiaking.com/forums/topic/72232-chuva-de-flechas-spell/

Doom (Spell):                                https://tibiaking.com/forums/topic/51622-doom-spell/

Utilização do VS Code (Infra)       https://tibiaking.com/forums/topic/94463-utilizando-o-visual-studio-code-notepad-nunca-mais/

SD com Combo (Spell):                 https://tibiaking.com/forums/topic/94520-sd-modificada/

Alteração attack speed (C++):        https://tibiaking.com/forums/topic/94714-c-attack-speed-spells-itens-e-onde-você-quiser/  

Bônus de Speed (NPC)                  https://tibiaking.com/forums/topic/94809-npc-concede-bônus-aos-players/
 

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo