Jump to content
  • 0

Placement like Eventhelper


CHKRZ

Question

  • VIP

Hello community!

 

I wanted to ask you about the Eventhelper function in the Source.

What i mean with that is with the eventflag: "event_helper 1" the Eventhelper appears.

 

I need the function because i want to make the same thing with other Npc´s.

I am very thankfull for everyusefull answer.

Link to comment

5 answers to this question

Recommended Posts

  • 0
  • VIP

Navigate to SetEventFlag in questmanager.cpp and add the name of your event_flag to the function:

		else if (name == "your_event_flag")
		{
			Dosomething(value) // value is the value of the flag
		}

To spawn an NPC you can do it like the Event Helper:

CHARACTER_MANAGER::instance().SpawnMob(9004, p->lMapIndex, posBase.x + p->x * 100, posBase.y + p->y * 100, 0, false, -1);
  • Love 2
Link to comment
  • 0
  • VIP

 

Navigate to SetEventFlag in questmanager.cpp and add the name of your event_flag to the function:

		else if (name == "your_event_flag")
		{
			Dosomething(value) // value is the value of the flag
		}

To spawn an NPC you can do it like the Event Helper:

CHARACTER_MANAGER::instance().SpawnMob(9004, p->lMapIndex, posBase.x + p->x * 100, posBase.y + p->y * 100, 0, false, -1);

Thank you!

 

I did it like this now:

else if (name == "npc_01")
{
CHARACTER_MANAGER::instance().SpawnMob(9004, p->lMapIndex, posBase.x + p->x * 100, posBase.y + p->y * 100, 0, false, -1)(value != 0);
}

How can i just let the npc spawn on one map i want?

Link to comment
  • 0

Much easier to do it with quest (taken from event_easter.quest)

when login or enter begin
	local mapIndex = pc.get_map_index()
	if mapIndex == 1 or mapIndex == 21 or mapIndex == 41 then
		local mobid = 30129
		if (game.get_event_flag("rabbit_helper") > 0) then
		-- spawn rabbit if he is not there
			if find_npc_by_vnum(mobid) == 0 then
				if mapIndex == 1 then
					mymob_vids[1] = mob.spawn(mobid, 591, 472, 1, 1, 1))
				elseif mapIndex == 21 then
					mymob_vids[21] = mob.spawn(mobid, 517, 742, 1, 1, 1))
				elseif mapIndex == 41 then
					mymob_vids[41] mob.spawn(mobid, 306, 828, 1, 1, 1))
				end
			end
		else
		--purge rabbit if he is there
			if find_npc_by_vnum(mobid) == 1 then
				if mapIndex == 1 then
					local npc = npc.select(mymob_vids[1])
					npc.purge()
				elseif mapIndex == 21 then
					local npc = npc.select(mymob_vids[21])
					npc.purge()
				elseif mapIndex == 41 then
					local npc = npc.select(mymob_vids[41])
					npc.purge()
				end
			end
		end
	end
end

Add this to questlib.lua:

mymob_vids = {}

You HAVE to implement the npc.select function: http://metin2dev.org/board/topic/921-some-function-from-imerlib-game/

  • Love 2

$ uptime
1:26AM  up 732 days,  8:29, 1 user, load averages: 0.38, 0.31, 0.22

$ uname -srp
FreeBSD 9.1-RELEASE amd64

Link to comment
  • 0
  • VIP

Much easier to do it with quest (taken from event_easter.quest)

when login or enter begin
	local mapIndex = pc.get_map_index()
	if mapIndex == 1 or mapIndex == 21 or mapIndex == 41 then
		local mobid = 30129
		if (game.get_event_flag("rabbit_helper") > 0) then
		-- spawn rabbit if he is not there
			if find_npc_by_vnum(mobid) == 0 then
				if mapIndex == 1 then
					mymob_vids[1] = mob.spawn(mobid, 591, 472, 1, 1, 1))
				elseif mapIndex == 21 then
					mymob_vids[21] = mob.spawn(mobid, 517, 742, 1, 1, 1))
				elseif mapIndex == 41 then
					mymob_vids[41] mob.spawn(mobid, 306, 828, 1, 1, 1))
				end
			end
		else
		--purge rabbit if he is there
			if find_npc_by_vnum(mobid) == 1 then
				if mapIndex == 1 then
					local npc = npc.select(mymob_vids[1])
					npc.purge()
				elseif mapIndex == 21 then
					local npc = npc.select(mymob_vids[21])
					npc.purge()
				elseif mapIndex == 41 then
					local npc = npc.select(mymob_vids[41])
					npc.purge()
				end
			end
		end
	end
end

Add it to questlib.lua:

mymob_vids = {}

You HAVE to implement the npc.select function: http://metin2dev.org/board/topic/921-some-function-from-imerlib-game/

 I know the quest method but it has a reason why i preffer the game side (source).

But thanks for you help :)

Link to comment

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


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