mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 16:51:29 +00:00
[Quest API] Add EVENT_EQUIP_ITEM_CLIENT and EVENT_UNEQUIP_ITEM_CLIENT to Perl/Lua. (#2015)
- These events allow more customization beyond forcing operators to use a script file for each and every item they want to have some sort of functionality for these events. - Perl event exports $item_id, $item_quantity, and $slot_id. - Lua event exports item_id, item_quantity, slot_id, and item.
This commit is contained in:
parent
3c35e9bbc8
commit
bfd1cf9379
@ -125,7 +125,9 @@ const char *QuestEventSubroutines[_LargestEventID] = {
|
|||||||
"EVENT_COMBINE",
|
"EVENT_COMBINE",
|
||||||
"EVENT_CONSIDER",
|
"EVENT_CONSIDER",
|
||||||
"EVENT_CONSIDER_CORPSE",
|
"EVENT_CONSIDER_CORPSE",
|
||||||
"EVENT_LOOT_ZONE"
|
"EVENT_LOOT_ZONE",
|
||||||
|
"EVENT_EQUIP_ITEM_CLIENT",
|
||||||
|
"EVENT_UNEQUIP_ITEM_CLIENT"
|
||||||
};
|
};
|
||||||
|
|
||||||
PerlembParser::PerlembParser() : perl(nullptr)
|
PerlembParser::PerlembParser() : perl(nullptr)
|
||||||
@ -1689,6 +1691,15 @@ void PerlembParser::ExportEventVariables(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case EVENT_EQUIP_ITEM_CLIENT:
|
||||||
|
case EVENT_UNEQUIP_ITEM_CLIENT: {
|
||||||
|
Seperator sep(data);
|
||||||
|
ExportVar(package_name.c_str(), "item_id", extradata);
|
||||||
|
ExportVar(package_name.c_str(), "item_quantity", sep.arg[0]);
|
||||||
|
ExportVar(package_name.c_str(), "slot_id", sep.arg[1]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,6 +94,8 @@ typedef enum {
|
|||||||
EVENT_CONSIDER,
|
EVENT_CONSIDER,
|
||||||
EVENT_CONSIDER_CORPSE,
|
EVENT_CONSIDER_CORPSE,
|
||||||
EVENT_LOOT_ZONE,
|
EVENT_LOOT_ZONE,
|
||||||
|
EVENT_EQUIP_ITEM_CLIENT,
|
||||||
|
EVENT_UNEQUIP_ITEM_CLIENT,
|
||||||
_LargestEventID
|
_LargestEventID
|
||||||
} QuestEventID;
|
} QuestEventID;
|
||||||
|
|
||||||
|
|||||||
@ -2205,20 +2205,52 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
|
|||||||
if (src_slot_id <= EQ::invslot::EQUIPMENT_END) {
|
if (src_slot_id <= EQ::invslot::EQUIPMENT_END) {
|
||||||
if(src_inst) {
|
if(src_inst) {
|
||||||
parse->EventItem(EVENT_UNEQUIP_ITEM, this, src_inst, nullptr, "", src_slot_id);
|
parse->EventItem(EVENT_UNEQUIP_ITEM, this, src_inst, nullptr, "", src_slot_id);
|
||||||
|
|
||||||
|
std::string export_string = fmt::format(
|
||||||
|
"{} {}",
|
||||||
|
src_inst->IsStackable() ? src_inst->GetCharges() : 1,
|
||||||
|
src_slot_id
|
||||||
|
);
|
||||||
|
|
||||||
|
parse->EventPlayer(EVENT_UNEQUIP_ITEM_CLIENT, this, export_string, src_inst->GetItem()->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dst_inst) {
|
if(dst_inst) {
|
||||||
parse->EventItem(EVENT_EQUIP_ITEM, this, dst_inst, nullptr, "", src_slot_id);
|
parse->EventItem(EVENT_EQUIP_ITEM, this, dst_inst, nullptr, "", src_slot_id);
|
||||||
|
|
||||||
|
std::string export_string = fmt::format(
|
||||||
|
"{} {}",
|
||||||
|
dst_inst->IsStackable() ? dst_inst->GetCharges() : 1,
|
||||||
|
src_slot_id
|
||||||
|
);
|
||||||
|
|
||||||
|
parse->EventPlayer(EVENT_EQUIP_ITEM_CLIENT, this, export_string, dst_inst->GetItem()->ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dst_slot_id <= EQ::invslot::EQUIPMENT_END) {
|
if (dst_slot_id <= EQ::invslot::EQUIPMENT_END) {
|
||||||
if(dst_inst) {
|
if(dst_inst) {
|
||||||
parse->EventItem(EVENT_UNEQUIP_ITEM, this, dst_inst, nullptr, "", dst_slot_id);
|
parse->EventItem(EVENT_UNEQUIP_ITEM, this, dst_inst, nullptr, "", dst_slot_id);
|
||||||
|
|
||||||
|
std::string export_string = fmt::format(
|
||||||
|
"{} {}",
|
||||||
|
dst_inst->IsStackable() ? dst_inst->GetCharges() : 1,
|
||||||
|
dst_slot_id
|
||||||
|
);
|
||||||
|
|
||||||
|
parse->EventPlayer(EVENT_UNEQUIP_ITEM_CLIENT, this, export_string, dst_inst->GetItem()->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(src_inst) {
|
if(src_inst) {
|
||||||
parse->EventItem(EVENT_EQUIP_ITEM, this, src_inst, nullptr, "", dst_slot_id);
|
parse->EventItem(EVENT_EQUIP_ITEM, this, src_inst, nullptr, "", dst_slot_id);
|
||||||
|
|
||||||
|
std::string export_string = fmt::format(
|
||||||
|
"{} {}",
|
||||||
|
src_inst->IsStackable() ? src_inst->GetCharges() : 1,
|
||||||
|
dst_slot_id
|
||||||
|
);
|
||||||
|
|
||||||
|
parse->EventPlayer(EVENT_EQUIP_ITEM_CLIENT, this, export_string, src_inst->GetItem()->ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4212,7 +4212,9 @@ luabind::scope lua_register_events() {
|
|||||||
luabind::value("test_buff", static_cast<int>(EVENT_TEST_BUFF)),
|
luabind::value("test_buff", static_cast<int>(EVENT_TEST_BUFF)),
|
||||||
luabind::value("consider", static_cast<int>(EVENT_CONSIDER)),
|
luabind::value("consider", static_cast<int>(EVENT_CONSIDER)),
|
||||||
luabind::value("consider_corpse", static_cast<int>(EVENT_CONSIDER_CORPSE)),
|
luabind::value("consider_corpse", static_cast<int>(EVENT_CONSIDER_CORPSE)),
|
||||||
luabind::value("loot_zone", static_cast<int>(EVENT_LOOT_ZONE))
|
luabind::value("loot_zone", static_cast<int>(EVENT_LOOT_ZONE)),
|
||||||
|
luabind::value("equip_item_client", static_cast<int>(EVENT_EQUIP_ITEM_CLIENT)),
|
||||||
|
luabind::value("unequip_item_client", static_cast<int>(EVENT_UNEQUIP_ITEM_CLIENT))
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -136,7 +136,9 @@ const char *LuaEvents[_LargestEventID] = {
|
|||||||
"event_combine",
|
"event_combine",
|
||||||
"event_consider",
|
"event_consider",
|
||||||
"event_consider_corpse",
|
"event_consider_corpse",
|
||||||
"event_loot_zone"
|
"event_loot_zone",
|
||||||
|
"event_equip_item_client",
|
||||||
|
"event_unequip_item_client"
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Zone *zone;
|
extern Zone *zone;
|
||||||
@ -227,7 +229,8 @@ LuaParser::LuaParser() {
|
|||||||
PlayerArgumentDispatch[EVENT_WARP] = handle_player_warp;
|
PlayerArgumentDispatch[EVENT_WARP] = handle_player_warp;
|
||||||
PlayerArgumentDispatch[EVENT_COMBINE] = handle_player_quest_combine;
|
PlayerArgumentDispatch[EVENT_COMBINE] = handle_player_quest_combine;
|
||||||
PlayerArgumentDispatch[EVENT_CONSIDER] = handle_player_consider;
|
PlayerArgumentDispatch[EVENT_CONSIDER] = handle_player_consider;
|
||||||
PlayerArgumentDispatch[EVENT_CONSIDER_CORPSE] = handle_player_consider_corpse;
|
PlayerArgumentDispatch[EVENT_EQUIP_ITEM_CLIENT] = handle_player_equip_item;
|
||||||
|
PlayerArgumentDispatch[EVENT_UNEQUIP_ITEM_CLIENT] = handle_player_equip_item;
|
||||||
|
|
||||||
ItemArgumentDispatch[EVENT_ITEM_CLICK] = handle_item_click;
|
ItemArgumentDispatch[EVENT_ITEM_CLICK] = handle_item_click;
|
||||||
ItemArgumentDispatch[EVENT_ITEM_CLICK_CAST] = handle_item_click;
|
ItemArgumentDispatch[EVENT_ITEM_CLICK_CAST] = handle_item_click;
|
||||||
|
|||||||
@ -760,6 +760,24 @@ void handle_translocate_finish(QuestInterface *parse, lua_State* L, NPC* npc, Cl
|
|||||||
lua_setfield(L, -2, "target");
|
lua_setfield(L, -2, "target");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handle_player_equip_item(QuestInterface *parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector<EQ::Any> *extra_pointers) {
|
||||||
|
lua_pushnumber(L, extra_data);
|
||||||
|
lua_setfield(L, -2, "item_id");
|
||||||
|
|
||||||
|
Seperator sep(data.c_str());
|
||||||
|
|
||||||
|
lua_pushnumber(L, std::stoi(sep.arg[0]));
|
||||||
|
lua_setfield(L, -2, "item_quantity");
|
||||||
|
|
||||||
|
lua_pushnumber(L, std::stoi(sep.arg[1]));
|
||||||
|
lua_setfield(L, -2, "slot_id");
|
||||||
|
|
||||||
|
Lua_ItemInst l_item(extra_data);
|
||||||
|
luabind::adl::object l_item_o = luabind::adl::object(L, l_item);
|
||||||
|
l_item_o.push(L);
|
||||||
|
lua_setfield(L, -2, "item");
|
||||||
|
}
|
||||||
|
|
||||||
void handle_spell_null(QuestInterface *parse, lua_State* L, NPC* npc, Client* client, uint32 spell_id, std::string data, uint32 extra_data, std::vector<EQ::Any> *extra_pointers) { }
|
void handle_spell_null(QuestInterface *parse, lua_State* L, NPC* npc, Client* client, uint32 spell_id, std::string data, uint32 extra_data, std::vector<EQ::Any> *extra_pointers) { }
|
||||||
|
|
||||||
void handle_encounter_timer(QuestInterface *parse, lua_State* L, Encounter* encounter, std::string data, uint32 extra_data,
|
void handle_encounter_timer(QuestInterface *parse, lua_State* L, Encounter* encounter, std::string data, uint32 extra_data,
|
||||||
|
|||||||
@ -113,6 +113,8 @@ void handle_player_consider(QuestInterface* parse, lua_State* L, Client* client,
|
|||||||
std::vector<EQ::Any>* extra_pointers);
|
std::vector<EQ::Any>* extra_pointers);
|
||||||
void handle_player_consider_corpse(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data,
|
void handle_player_consider_corpse(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data,
|
||||||
std::vector<EQ::Any>* extra_pointers);
|
std::vector<EQ::Any>* extra_pointers);
|
||||||
|
void handle_player_equip_item(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data,
|
||||||
|
std::vector<EQ::Any>* extra_pointers);
|
||||||
|
|
||||||
//Item
|
//Item
|
||||||
void handle_item_click(QuestInterface *parse, lua_State* L, Client* client, EQ::ItemInstance* item, Mob *mob, std::string data, uint32 extra_data,
|
void handle_item_click(QuestInterface *parse, lua_State* L, Client* client, EQ::ItemInstance* item, Mob *mob, std::string data, uint32 extra_data,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user