TRBizeps 49 Posted January 17, 2018 Share Posted January 17, 2018 I'm looking for a function that checks if slot WEAR_PET (WEAR_NUM=28) is equipped, if it's not equiped it should return false. Could someone help me :)? Link to comment Share on other sites More sharing options...
Premium Speachless 765 Posted January 17, 2018 Premium Share Posted January 17, 2018 In char_item.cpp you have case ITEM_SPECIAL_DS: if (!item->IsEquipped()) EquipItem(item); else UnequipItem(item); break; 1 Link to comment Share on other sites More sharing options...
TRBizeps 49 Posted January 17, 2018 Author Share Posted January 17, 2018 vor 32 Minuten schrieb Dobrescu Sebastian: In char_item.cpp you have case ITEM_SPECIAL_DS: if (!item->IsEquipped()) EquipItem(item); else UnequipItem(item); break; This is not what i'm searching for but thanks i need to check (with a questfunction i believe) if the used item with wear_pet is in slot <- if not it should unsummon the pet :/ Link to comment Share on other sites More sharing options...
Tasho 244 Posted January 17, 2018 Share Posted January 17, 2018 //@questlib.lua function pet.is_equipped() --[[ pc.get_wear(bCell); Returns: [1] lua_pushnumber: The equipped item vnum of the specific [cell]. [1] lua_pushnil: nil --]] local WEAR_PET = 27 -- ../common/length.h / enum EWearPositions [0 ~ WEAR_MAX - 1] return pc.get_wear(WEAR_PET) ~= nil; -- Returns: True or False end //@Quest: if not pet.is_equipped() then say('Pet isn't equipped.') return end 1 Link to comment Share on other sites More sharing options...
TRBizeps 49 Posted January 17, 2018 Author Share Posted January 17, 2018 vor 20 Minuten schrieb Tasho: //@questlib.lua function pet.is_equipped() --[[ pc.get_wear(bCell); Returns: [1] lua_pushnumber: The equipped item vnum of the specific [cell]. [1] lua_pushnil: nil --]] local WEAR_PET = 27 -- ../common/length.h / enum EWearPositions [0 ~ WEAR_MAX - 1] return pc.get_wear(WEAR_PET) ~= nil; -- Returns: True or False end //@Quest: if not pet.is_equipped() then say('Pet isn't equipped.') return end thanks very much! That's definitly a progress, now if i use the Item it summons the Pet - but if i unequip it, the pet does not unsummon until i use it again. So i use it -> == Pet.is_summon Unequip & use again == pet.unsummon <- Link to comment Share on other sites More sharing options...
Active+ Member Abel(Tiger) 1206 Posted January 17, 2018 Active+ Member Share Posted January 17, 2018 I already told you some days ago you can't do that with actual metin2 quest events. You need new quest events for that like "equip" and "unequip"... Or try with "use" event, It might work. Link to comment Share on other sites More sharing options...
TRBizeps 49 Posted January 17, 2018 Author Share Posted January 17, 2018 vor 6 Minuten schrieb Abel(Tiger): I already told you some days ago you can't do that with actual metin2 quest events. You need new quest events for that like "equip" and "unequip"... Or try with "use" event, It might work. Thanks for your advice, if i could've understand c++ a bit, i'd try something but :/ Link to comment Share on other sites More sharing options...
Tasho 244 Posted January 17, 2018 Share Posted January 17, 2018 //@../game/questlua_pc.cpp //1.)Search for: int pc_warp_exit(lua_State * L) { CQuestManager::instance().GetCurrentCharacterPtr()->ExitToSavedLocation(); return 0; } //1.)Add after: int pc_equip(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); LPITEM item = ch->GetInventoryItem(lua_tonumber(L, 1)); if (item) ch->EquipItem(item); return 0; } int pc_unequip(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); LPITEM item = ch->GetWear(lua_tonumber(L, 1)); if (item) ch->UnequipItem(item); return 0; } //2.)Search for: { "get_race", pc_get_race }, //2.)Add after: { "equip", pc_equip }, { "unequip", pc_unequip }, //quest_function: pc.equip pc.unequip //quest: pc.equip(item.get_cell()) pc.unequip(WEAR_PET) 1 Link to comment Share on other sites More sharing options...
TRBizeps 49 Posted January 17, 2018 Author Share Posted January 17, 2018 vor 21 Minuten schrieb Tasho: //@../game/questlua_pc.cpp //1.)Search for: int pc_warp_exit(lua_State * L) { CQuestManager::instance().GetCurrentCharacterPtr()->ExitToSavedLocation(); return 0; } //1.)Add after: int pc_equip(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); LPITEM item = ch->GetInventoryItem(lua_tonumber(L, 1)); if (item) ch->EquipItem(item); return 0; } int pc_unequip(lua_State* L) { LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); LPITEM item = ch->GetWear(lua_tonumber(L, 1)); if (item) ch->UnequipItem(item); return 0; } //2.)Search for: { "get_race", pc_get_race }, //2.)Add after: { "equip", pc_equip }, { "unequip", pc_unequip }, //quest_function: pc.equip pc.unequip //quest: pc.equip(item.get_cell()) pc.unequip(WEAR_PET) i've implemented those functions, but i can't imagine how they could be useful for my problem. here is my pet_system.quest quest pet_system begin state start begin function get_pet_info(itemVnum) pet_info_map = { -- [ITEM VNUM] MOB_VNUM, DEFAULT NAME [53001] = { 34001, gameforge.pet_system._010_say ,1}, [53002] = { 34002, gameforge.pet_system._020_say ,1}, [53003] = { 34003, gameforge.pet_system._040_say ,1}, [53004] = { 34009, gameforge.pet_system._050_say ,1}, [53005] = { 34004, gameforge.pet_system._050_say, 1}, [53006] = { 34006, gameforge.pet_system._090_say, 1}, [53007] = { 34008, gameforge.pet_system._060_say, 1}, [53008] = { 34007, gameforge.pet_system._070_say, 1}, [53009] = { 34005, gameforge.pet_system._080_say, 1}, [53010] = { 34010, gameforge.pet_system._100_say, 1}, [53011] = { 34011, gameforge.pet_system._110_say, 1}, [53012] = { 34012, gameforge.pet_system._120_say, 1}, [53013] = { 34032, gameforge.pet_system._210_say, 1}, } itemVnum = tonumber(itemVnum) return pet_info_map[itemVnum] end function get_spawn_effect_file(idx) effect_table = { [0] = nil, [1] = "d:\\\\ymir work\\\\effect\\\\etc\\\\appear_die\\\\npc2_appear.mse", } return effect_table [idx] end when login begin local vnum = pet.is_equipped() if false != vnum then local pet_info = pet_system.get_pet_info(vnum) if null != pet_info then local mobVnum = pet_info[1] local petName = pet_info[2] local spawn_effect_file_name = pet_system.get_spawn_effect_file(pet_info[3]) if pet.count_summoned() < 1 then pet.summon(mobVnum, petName, false) else syschat(gameforge.pet_system._030_chat) end if spawn_effect_file_name != nil then pet.spawn_effect (mobVnum, spawn_effect_file_name) end end end end when 53001.use or 53002.use or 53003.use or 53004.use or 53005.use or 53006.use or 53007.use or 53008.use or 53009.use or 53010.use or 53011.use or 53012.use or 53013.use or begin local pet_info = pet_system.get_pet_info(item.vnum) if null != pet_info then local mobVnum = pet_info[1] local petName = pet_info[2] local spawn_effect_file_name = pet_system.get_spawn_effect_file(pet_info[3]) if not pet.is_equipped() then if true == pet.is_summon(34001) then pet.unsummon(34001) end end if not pet.is_equipped() and pet.is_summon(mobVnum) then if spawn_effect_file_name != nil then pet.spawn_effect (mobVnum, spawn_effect_file_name) end pet.unsummon(mobVnum) else if pet.count_summoned() < 1 then pet.summon(mobVnum, petName, false) else syschat(gameforge.pet_system._030_chat) end if spawn_effect_file_name != nil then pet.spawn_effect (mobVnum, spawn_effect_file_name) end end --end -- if pet.is_summon end -- if null != pet_info end -- when end -- state end -- quest Link to comment Share on other sites More sharing options...
Active+ Member Abel(Tiger) 1206 Posted January 17, 2018 Active+ Member Share Posted January 17, 2018 "equip" and "unequip" EVENTS not FUNCTIONS ... when 19.equip begin syschat("You equiped a weapon.") end when 19.unequip begin syschat("You unequiped a weapon.") end Spoiler // Hint number 1 :) CHARACTER::UnequipItem // Hint number 2 :) quest::CQuestManager::instance().UnequipItem(GetPlayerID(), item); // Or use one event already existing quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false); 1 Link to comment Share on other sites More sharing options...
TRBizeps 49 Posted January 18, 2018 Author Share Posted January 18, 2018 vor 15 Stunden schrieb Abel(Tiger): "equip" and "unequip" EVENTS not FUNCTIONS ... when 19.equip begin syschat("You equiped a weapon.") end when 19.unequip begin syschat("You unequiped a weapon.") end Unsichtbaren Inhalt anzeigen // Hint number 1 :) CHARACTER::UnequipItem // Hint number 2 :) quest::CQuestManager::instance().UnequipItem(GetPlayerID(), item); // Or use one event already existing quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false); (my type is: ITEM_PETS) do i need to edit questmanager? I really dont know how i should write the event. bool CQuestManager::UseItem(unsigned int pc, LPITEM item, bool bReceiveAll) { if (test_server) sys_log( 0, "questmanager::UseItem Start : itemVnum : %d PC : %d", item->GetOriginalVnum(), pc); PC* pPC; if ((pPC = GetPC(pc))) { if (!CheckQuestLoaded(pPC)) { LPCHARACTER ch = CHARACTER_MANAGER::instance().FindByPID(pc); if (ch) { ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Äù½ºÆ®¸¦ ·ÎµåÇÏ´Â ÁßÀÔ´Ï´Ù. Àá½Ã¸¸ ±â´Ù·Á ÁֽʽÿÀ.")); } return false; } // call script SetCurrentItem(item); /* if (test_server) { sys_log( 0, "Quest UseItem Start : itemVnum : %d PC : %d", item->GetOriginalVnum(), pc); itertype(m_mapNPC) it = m_mapNPC.begin(); itertype(m_mapNPC) end = m_mapNPC.end(); for( ; it != end ; ++it) { sys_log( 0, "Quest UseItem : vnum : %d item Vnum : %d", it->first, item->GetOriginalVnum()); } } if(test_server) sys_log( 0, "questmanager:useItem: mapNPCVnum : %d\n", m_mapNPC[item->GetVnum()].GetVnum()); */ return m_mapNPC[item->GetVnum()].OnUseItem(*pPC, bReceiveAll); } else { //cout << "no such pc id : " << pc; sys_err("QUEST USE_ITEM_EVENT no such pc id : %d", pc); return false; } } Andere Medien einfügen this event e.g. is for *.use how can i modify it for *.unequip? Link to comment Share on other sites More sharing options...
TRBizeps 49 Posted January 19, 2018 Author Share Posted January 19, 2018 Is there any friendly developer who can help? I'm pretty sure it'd help a lot of people here. Link to comment Share on other sites More sharing options...
TRBizeps 49 Posted January 21, 2018 Author Share Posted January 21, 2018 bump Link to comment Share on other sites More sharing options...
TRBizeps 49 Posted January 23, 2018 Author Share Posted January 23, 2018 bump Link to comment Share on other sites More sharing options...
TRBizeps 49 Posted January 24, 2018 Author Share Posted January 24, 2018 Bump zu dem B.u.m.p 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