[Quest] kill event error

07/22/2019 16:32 nexusadmin#1
Hello!

Suppose that I have this snippet:
Code:
when kill with npc.is_pc() begin
   syschat(npc.get_vid())
end
The problem is that when I kill someone the quest does not work until the character kills me first and after that I kill it.

1. When I kill a character the npc.is_pc() function returns false
2. When that character kills me and after I kill it again the npc.is_pc() returns true and the script runs

questmanager.cpp
Code:
void CQuestManager::Kill(unsigned int pc, unsigned int npc)
	{
		//m_CurrentNPCRace = npc;
		PC * pPC;

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

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

			/* [hyo] �� kill�� �ߺ� ī���� �̽� ������ ��������
			   quest script�� when 171.kill begin ... ���� �ڵ�� ���Ͽ� ��ũ��Ʈ�� ó���Ǿ�����
			   �ٷ� return���� �ʰ� �ٸ� �˻絵 �����ϵ��� ������. (2011/07/21)
			*/   
			// call script
			if(npc > 0)
			{
				m_mapNPC[npc].OnKill(*pPC);
			}

			LPCHARACTER ch = GetCurrentCharacterPtr();
			LPPARTY pParty = ch->GetParty();
			LPCHARACTER leader = pParty ? pParty->GetLeaderCharacter() : ch;

			if (leader)
			{
				m_pCurrentPartyMember = ch;

				if (m_mapNPC[npc].OnPartyKill(*GetPC(leader->GetPlayerID())))
					return;

				pPC = GetPC(pc);
			}

			if (m_mapNPC[QUEST_NO_NPC].OnKill(*pPC))
				return;

			if (leader)
			{
				m_pCurrentPartyMember = ch;
				m_mapNPC[QUEST_NO_NPC].OnPartyKill(*GetPC(leader->GetPlayerID()));
			}
		}
		else
			sys_err("QUEST: no such pc id : %d", pc);
	}
char_battle.cpp Dead function
Code:
quest::CQuestManager::instance().Kill(pkKiller->GetPlayerID(), quest::QUEST_NO_NPC);
char_battle.cpp Reward function
Code:
quest::CQuestManager::instance().Kill(pkAttacker->GetPlayerID(), GetRaceNum());
Syslog:
Code:
Jul 22 19:56:49.534963 :: CQuestManager::Kill QUEST_KILL_EVENT (pc=70120, npc=0)
I'm not sure that npc should be 0 here, but I don't see any weird in the implementation of Kill event. Everything default and normal I think.

Does anyone experienced it before?


----------------------------------------------------------------------------------------------------


[SOLVED][C++][Source]

Adding these lines fixed my problem:

char_battle.cpp Reward function after pkAttacker->SetQuestNPCID(GetVID()); line:
Code:
SetQuestNPCID(pkAttacker->GetVID());
char_battle.cpp Dead function after pkKiller->SetQuestNPCID(GetVID()); line:
Code:
SetQuestNPCID(pkKiller->GetVID());