caanmasu Posted October 9, 2022 Report Share Posted October 9, 2022 borrar Marcos Pinheiro, ππΏπ²π and josepiti1 2 1 Quote Link to comment Share on other sites More sharing options...
ππΏπ²π Posted October 9, 2022 Report Share Posted October 9, 2022 En 9/10/2022 a las 6:37, caanmasu dijo: Hola He hecho un fix a una función, es algo sutil pero verán la diferencia. Cuando usas en una quest la función: game.drop_item(item_vnum, count) o su variante game.drop_item_with_ownership, es para que caiga un objeto al suelo, ya sea sin nombre o con nombre. Pero encontré un problema, resulta que en un evento había que matar a un jefe, y el jefe botaba objetos sin nombre para el que pudiera tomarlos. Se supone que el jefe bota los objetos debajo de él, pero el problema es que si matas al jefe desde lejos, van a caer los objetos debajo de ti. La razón es esta: questlua_game.cpp ALUA(game_drop_item) { // // Syntax: game.drop_item(50050, 1) // LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); DWORD item_vnum = (DWORD) lua_tonumber(L, 1); int count = (int) lua_tonumber(L, 2); long x = ch->GetX(); long y = ch->GetY(); LPITEM item = ITEM_MANAGER::instance().CreateItem(item_vnum, count); if (!item) { sys_err("cannot create item vnum %d count %d", item_vnum, count); return 0; } PIXEL_POSITION pos; pos.x = x + number(-200, 200); pos.y = y + number(-200, 200); item->AddToGround(ch->GetMapIndex(), pos); item->StartDestroyEvent(); return 0; } La instancia de quest recoge el personaje seleccionado, es decir, el personaje que dropea. Donde dice AddToGround, envía en el 2° parámetro la posición pero la posición la saca de ch->GetX(), es decir, las coordenadas del personaje. En otras palabras, el objeto caerá por debajo del personaje que mató al monstruo y no debajo del monstruo. En este caso la solución es preguntar si hay un npc seleccionado, ya que si hacemos un game.drop_item() en un when login no interesa porque el objeto no tiene un objetivo distinto que del personaje. Pero si es un when kill, tiene que caer en el personaje seleccionado. Fix: Cambia la función por esta: ALUA(game_drop_item) { // // Syntax: game.drop_item(50050, 1) // LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr(); DWORD item_vnum = (DWORD) lua_tonumber(L, 1); int count = (int) lua_tonumber(L, 2); long x = ch->GetX(); long y = ch->GetY(); LPITEM item = ITEM_MANAGER::instance().CreateItem(item_vnum, count); if (!item) { sys_err("cannot create item vnum %d count %d", item_vnum, count); return 0; } CQuestManager& q = CQuestManager::instance(); LPCHARACTER npc = q.GetCurrentNPCCharacterPtr(); PIXEL_POSITION pos; if (npc && (npc->IsMonster() || npc->IsStone())){ pos.x = npc->GetX() + number(-200, 200); pos.y = npc->GetY() + number(-200, 200); } else { pos.x = ch->GetX() + number(-200, 200); pos.y = ch->GetY() + number(-200, 200); } item->AddToGround(ch->GetMapIndex(), pos); item->StartDestroyEvent(); return 0; } Adapta también a la de game.drop_item_with_ownership(). Ya con el código pueden comparar y entender lo que he hecho. Si matan un metin o un monstruo y tienen el drop por game.drop_item... caerá el objeto sobre el mob. Un saludo. Problemas en base Revelion2 al utilizar "Lo cual muchos obejtos no caian" No recomiendo. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.