Jump to content

Placement like Eventhelper


Go to solution Solved by Sanchez,

Recommended Posts

  • Premium

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
Share on other sites

  • Premium
  • Solution

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
Share on other sites

  • Premium

 

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
Share on other sites

  • Bronze

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
Link to comment
Share on other sites

  • Premium

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
Share on other sites

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.