Jump to content

[duvida] Existe algum modo de ativar uma quest ao morrer


Luffy
 Share

Recommended Posts

10 horas atrás, Luffy disse:

Pessoal, eu gostaria de saber se tem algum modo de ativar uma quest ao morrer ou ser derrotado por algum player?

Function by Zonni:

 

Spoiler

questmanager.cpp

- in bool CQuestManager::Initialize() add

m_mapEventName.insert(TEventNameMap::value_type("dead", QUEST_DEAD_EVENT));

 

- add

void CQuestManager::Dead(unsigned int pc, unsigned int npc)
{
PC * pPC;
 
sys_log(0, "CQuestManager::OnDead QUEST_DEAD_EVENT (pc=%d, npc=%d)", pc, npc);
 
if ((pPC = GetPC(pc)))
{
if (!CheckQuestLoaded(pPC))
return;
m_mapNPC[npc].OnDead(*pPC);
 
if (m_mapNPC[QUEST_NO_NPC].OnDead(*pPC))
return;
}
else
sys_err("QUEST: no such pc id : %d", pc);
}
 

quest.h

[second enum] (add after QUEST_ITEM_INFORMER_EVENT,)

QUEST_DEAD_EVENT,

 

questnpc.h

bool NPC::OnDead(PC & pc)
{
if (m_vnum)
return HandleEvent(pc, QUEST_DEAD_EVENT);
else
return HandleReceiveAllEvent(pc, QUEST_DEAD_EVENT);
}
 
char_battle.cpp
in CHARACTER::Dead add
if(pkKiller && IsPC()) {
pkKiller->SetQuestNPCID(GetVID());
quest::CQuestManager::instance().Dead(GetPlayerID(), pkKiller->GetPlayerID());
}
 

 

sorry for format but it should work if you add missing functions in .h files

 

btw. that's not my work, anyway it's really easy to create events like this.

 

 

podes ver o tópico completo >>> aqui  <<<

Link to comment
Share on other sites

O pc.is_dead já existe desde o início dos 34k.

@Sinval a função é do tipo boolean, ou é verdadeiro ou falso.

A forma correta de quereres fazer algo quando morres é assim:

quest morrer begin
	state start begin
		when kill with npc.is_pc() begin
			if pc.is_dead() == true then
				syschat("Estás morto.")
			end
		end
	end
end

 

Edited by Mário.
Link to comment
Share on other sites

13 horas atrás, Mário. disse:

O pc.is_dead já existe desde o início dos 34k.

@Sinval a função é do tipo boolean, ou é verdadeiro ou falso.

A forma correta de quereres fazer algo quando morres é assim:


quest morrer begin
	state start begin
		when kill with npc.is_pc() begin
			if pc.is_dead() == true then
				syschat("Estás morto.")
			end
		end
	end
end

 

"when kill" não é apenas pra quando o player mata? Eu testei a quest e não funciono.

Link to comment
Share on other sites

19 horas atrás, Mário. disse:

O pc.is_dead já existe desde o início dos 34k.

@Sinval a função é do tipo boolean, ou é verdadeiro ou falso.

A forma correta de quereres fazer algo quando morres é assim:


quest morrer begin
	state start begin
		when kill with npc.is_pc() begin
			if pc.is_dead() == true then
				syschat("Estás morto.")
			end
		end
	end
end

 

Acredito que de ambas as maneiras funcionam, como eu citei funciona, pois já testei. 

 

6 horas atrás, Luffy disse:

"when kill" não é apenas pra quando o player mata? Eu testei a quest e não funciono.

Sim, when kill é apenas quando o jogador mata, no caso, para verificar quando o jogador está morto, se for em algum evento/guerra basta fazer um timer e ficar verificando sempre se o jogador está morto, porém não é a melhor opção, então recomendo que verifique o funcionamento da função do "Zonni", acredito que deve ser mais viável. 

Link to comment
Share on other sites

Ficheiro char_battle.cpp

Procurar por:

	if (IsPC())
	{
		if (CThreeWayWar::instance().IsThreeWayWarMapIndex(GetMapIndex()))
			isForked = true;
	}

Adicionar em cima:

	if (IsPC()){
		if (pkKiller)
			SetQuestNPCID(pkKiller->GetVID());

		quest::CQuestManager::instance().Die(GetPlayerID(), (pkKiller)?pkKiller->GetRaceNum():quest::QUEST_NO_NPC);}

 

Ficheiro quest.h

Procurar por:

QUEST_EVENT_COUNT

Adicionar em cima:

QUEST_DIE_EVENT,

 

Ficheiro questmanager.cpp

Procurar por:

m_mapEventName.insert(TEventNameMap::value_type("item_informer", QUEST_ITEM_INFORMER_EVENT));

Adicionar debaixo:

m_mapEventName.insert(TEventNameMap::value_type("die", QUEST_DIE_EVENT));

 

Procurar por:

bool CQuestManager::ServerTimer(unsigned int npc, unsigned int arg)

Adicionar em cima:

	void CQuestManager::Die(unsigned int pc, unsigned int npc){
		PC * pPC;

		sys_log(0, "CQuestManager::Kill QUEST_DIE_EVENT (pc=%d, npc=%d)", pc, npc);

		if ((pPC = GetPC(pc))){
			if (!CheckQuestLoaded(pPC))
				return;

			m_mapNPC[QUEST_NO_NPC].OnDie(*pPC);}
		else
			sys_err("QUEST: no such pc id : %d", pc);}

 

Ficheiro questmanager.h

Procurar por:

void		Kill(unsigned int pc, unsigned int npc);

Adicionar debaixo:

void		Die(unsigned int pc, unsigned int npc);

 

Ficheiro questnpc.cpp

Procurar por:

bool NPC::OnLevelUp(PC& pc)

Adicionar em cima:

bool NPC::OnDie(PC& pc){
	return HandleReceiveAllEvent(pc, QUEST_DIE_EVENT);}

 

Ficheiro questnpc.h

Procurar por:

bool	OnPartyKill(PC& pc);

Adicionar debaixo:

bool	OnDie(PC& pc);

 

Exemplo de quest:

quest morre_noob begin
	state start begin
		when die begin
			syschat("Morres-te...noob!")
		end
	end
end

__

2017-11-30_17-49-26.gif

 

Dessa maneira funcionará cada vez que morres.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...