Jump to content

When hit makes me crazy


Recommended Posts

Hello.
I want to write the new trigger function called "hit".

I was basically looking at "kill" triggering, but i place 

quest::CQuestManager::instance().Hit(pkAttacker->GetPlayerID(), pkVictim->GetRaceNum());

in battle.cpp.
Also i write some sys_log information to trigger when the function is executed etc.

Everything seems to be same as kill, but

when kill begin - works fine

when hit begin - doesn't work ;/

 

So my code:


QuestManager.cpp
	void CQuestManager::Hit(unsigned int pc, unsigned int npc){
		PC * pPC;
		sys_log(0, "CQuestManager::HIT QUEST_HIT_EVENT (pc=%d, npc=%d)", pc, npc);
		if ((pPC = GetPC(pc))){
			if (!CheckQuestLoaded(pPC))
				return;
			m_mapNPC[npc].OnHit(*pPC);
		}
		else
			sys_err("QUEST: no such pc id : %d", pc);

	}

QuestNpc.cpp

	bool NPC::OnHit(PC& pc)
	{
		sys_log(0,"NPC::OnHit QUEST_HIT_EVENT PC: %d",pc);
		if (m_vnum)
		{
			//PROF_UNIT puOnKill1("onk1");
			//return HandleEvent(pc, QUEST_HIT_EVENT);
			sys_log(0,"NPC::OnHit HandleEvent PC: %d, QUEST_HIT_EVENT",pc);
			return HandleEvent(pc, QUEST_HIT_EVENT);
		}
		else
		{
			//PROF_UNIT puOnKill2("onk2");
			//return HandleReceiveAllEvent(pc, QUEST_HIT_EVENT);
			sys_log(0,"NPC::OnHit HandleReceiveAllEvent PC: %d, QUEST_HIT_EVENT",pc);
			return HandleReceiveAllEvent(pc, QUEST_HIT_EVENT);
		}
	}

Ofc. i add QUEST_HIT_EVENT to quest.h and 

m_mapEventName.insert(TEventNameMap::value_type("hit", QUEST_HIT_EVENT)); 

to questmanager.cpp.


Help me :D
Thanks in advance!

PS. My quest

-- EVOR TESTUJE  FUNKCJE npc.

quest npc_function begin
	state start begin
		when hit begin
			chat("test") -- that dosen't work ;/
		end
		when kill begin
			chat("test kill") -- that works just fine
		end
	end
end

PS2. Syslog:

Feb 16 14:16:01.660000 :: [TEST_SERVER] Attack : EvorTest type 0, MobBattleType 0
Feb 16 14:16:01.660000 :: battle_melee_attack : [EvorTest] attack to [Głodny Wilk]
Feb 16 14:16:01.660000 :: battle_melee_attack : [EvorTest] attack to [Głodny Wilk]
Feb 16 14:16:01.660000 :: battle_melee_attack : [EvorTest] attack to [Głodny Wilk]
Feb 16 14:16:01.660000 :: battle_hit : [EvorTest] attack to [Głodny Wilk] : dam :175 type :244485752
Feb 16 14:16:01.660000 :: CQuestManager::HIT QUEST_HIT_EVENT (pc=58855, npc=172)
Feb 16 14:16:01.660000 :: NPC::OnHit QUEST_HIT_EVENT PC: 798260784
Feb 16 14:16:01.660000 :: NPC::OnHit HandleReceiveAllEvent PC: 798260784, QUEST_HIT_EVENT
Feb 16 14:16:01.660000 :: Click Quest : MatchingQuest
Feb 16 14:16:01.660000 :: Powinnno wytrigerować hit
Feb 16 14:16:01.660000 :: Bonus Exp : Ramadan Candy: 0 MallExp: 0 PointExp: 0
Feb 16 14:16:01.660000 :: CQuestManager::Kill QUEST_KILL_EVENT (pc=58855, npc=172)
Feb 16 14:16:01.660000 :: NPC::OnKill HandleReceiveAllEvent PC:798260784
Feb 16 14:16:01.660000 :: Click Quest : MatchingQuest
Feb 16 14:16:01.660000 :: Click Quest : MatchingQuest
Feb 16 14:16:01.676000 :: NPC::OnKill HandleReceiveAllEvent PC:798260784
Feb 16 14:16:01.676000 :: Click Quest : MatchingQuest
Feb 16 14:16:01.676000 :: QUEST Setting flag npc_function.__status 0

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.