Jump to content
  • 0
Sign in to follow this  
Evor

When hit makes me crazy

Question

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

Share this post


Link to post

6 answers to this question

Recommended Posts

  • 0

I looked but I'm not really experienced in this sorry

Share this post


Link to post
  • 0

Oh okey. Have to find another way ;p (maybe do in the src directly)

Share this post


Link to post
  • 0

I think you must make a call

quest::CQuestManager::instance().Hit(pkKiller->GetPlayerID(), quest::QUEST_NO_NPC);

somewhere in char_battle.cpp

Share this post


Link to post
  • 0

I think you have to put your code into this function in battle.cpp:
 

int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim)

Try it.

Share this post


Link to post
  • 0

I think you have to put your code into this function in battle.cpp:

int battle_melee_attack(LPCHARACTER ch, LPCHARACTER victim)
Try it.
Yea. Game is triggering hit properly, but quest has some problems with reading it. I exactly do as penger suggest, but no such luck either.

Share this post


Link to post

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
Sign in to follow this  
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • 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.