Premium Juice 526 Posted August 1, 2014 Premium Share Posted August 1, 2014 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 More sharing options...
Premium Solution Sanchez 2479 Posted August 1, 2014 Premium Solution Share Posted August 1, 2014 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); 2 Link to comment Share on other sites More sharing options...
Premium Juice 526 Posted August 1, 2014 Author Premium Share Posted August 1, 2014 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 More sharing options...
Premium Sanchez 2479 Posted August 1, 2014 Premium Share Posted August 1, 2014 You can set the target mapindex as second argument. DWORD dwVnum, long lMapIndex, long x, long y, long z, bool bSpawnMotion, int iRot, bool bShow 1 Link to comment Share on other sites More sharing options...
Active Member ATAG 312 Posted August 1, 2014 Active Member Share Posted August 1, 2014 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/ 2 Link to comment Share on other sites More sharing options...
Premium Juice 526 Posted August 1, 2014 Author Premium Share Posted August 1, 2014 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 More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now