mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 07:18:37 +00:00
[Quest API] Add EVENT_DAMAGE_GIVEN and EVENT_DAMAGE_TAKEN to Perl/Lua. (#2804)
* [Quest API] Add EVENT_DAMAGE_GIVEN and EVENT_DAMAGE_TAKEN to Perl/Lua. # Perl - Add `EVENT_DAMAGE_GIVEN`. - Add `EVENT_DAMAGE_TAKEN`. - Both events export `$entity_id`, `$damage`, `$spell_id`, `$skill_id`, `$is_damage_shield`, `$is_avoidable`, `$buff_slot`, `$is_buff_tic`, `$special_attack`. # Lua - Add `event_damage_given`. - Add `event_damage_taken`. - Both events export `e.entity_id`, `e.damage`, `e.spell_id`, `e.skill_id`, `e.is_damage_shield`, `e.is_avoidable`, `e.buff_slot`, `e.is_buff_tic`, `e.special_attack`, and `e.other`. # Notes - These events allow operators to have events fire based on damage given or taken, as well as keep better track of a Bot, Client, or NPC's damage per second or otherwise. - Special Attack is only useful for NPCs, but allows you to see if the attack is Rampage, AERampage, or Chaotic Stab. * Cleanup.
This commit is contained in:
+119
-13
@@ -453,6 +453,50 @@ void handle_npc_despawn_zone(
|
||||
lua_setfield(L, -2, "other");
|
||||
}
|
||||
|
||||
void handle_npc_damage(
|
||||
QuestInterface *parse,
|
||||
lua_State* L,
|
||||
NPC* npc,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
lua_pushnumber(L, std::stoul(sep.arg[0]));
|
||||
lua_setfield(L, -2, "entity_id");
|
||||
|
||||
lua_pushnumber(L, std::stoll(sep.arg[1]));
|
||||
lua_setfield(L, -2, "damage");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[2]));
|
||||
lua_setfield(L, -2, "spell_id");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[3]));
|
||||
lua_setfield(L, -2, "skill_id");
|
||||
|
||||
lua_pushboolean(L, std::stoi(sep.arg[4]) == 0 ? false : true);
|
||||
lua_setfield(L, -2, "is_damage_shield");
|
||||
|
||||
lua_pushboolean(L, std::stoi(sep.arg[5]) == 0 ? false : true);
|
||||
lua_setfield(L, -2, "is_avoidable");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[6]));
|
||||
lua_setfield(L, -2, "buff_slot");
|
||||
|
||||
lua_pushboolean(L, std::stoi(sep.arg[7]) == 0 ? false : true);
|
||||
lua_setfield(L, -2, "is_buff_tic");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[8]));
|
||||
lua_setfield(L, -2, "special_attack");
|
||||
|
||||
Lua_Mob l_mob(init);
|
||||
luabind::adl::object l_mob_o = luabind::adl::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
}
|
||||
|
||||
// Player
|
||||
void handle_player_say(
|
||||
QuestInterface *parse,
|
||||
@@ -1168,6 +1212,51 @@ void handle_player_bot_create(
|
||||
lua_setfield(L, -2, "bot_gender");
|
||||
}
|
||||
|
||||
void handle_player_damage(
|
||||
QuestInterface *parse,
|
||||
lua_State* L,
|
||||
Client* client,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
) {
|
||||
Seperator sep(data.c_str());
|
||||
|
||||
lua_pushnumber(L, std::stoul(sep.arg[0]));
|
||||
lua_setfield(L, -2, "entity_id");
|
||||
|
||||
lua_pushnumber(L, std::stoll(sep.arg[1]));
|
||||
lua_setfield(L, -2, "damage");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[2]));
|
||||
lua_setfield(L, -2, "spell_id");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[3]));
|
||||
lua_setfield(L, -2, "skill_id");
|
||||
|
||||
lua_pushboolean(L, std::stoi(sep.arg[4]) == 0 ? false : true);
|
||||
lua_setfield(L, -2, "is_damage_shield");
|
||||
|
||||
lua_pushboolean(L, std::stoi(sep.arg[5]) == 0 ? false : true);
|
||||
lua_setfield(L, -2, "is_avoidable");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[6]));
|
||||
lua_setfield(L, -2, "buff_slot");
|
||||
|
||||
lua_pushboolean(L, std::stoi(sep.arg[7]) == 0 ? false : true);
|
||||
lua_setfield(L, -2, "is_buff_tic");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[8]));
|
||||
lua_setfield(L, -2, "special_attack");
|
||||
|
||||
if (extra_pointers && extra_pointers->size() >= 1) {
|
||||
Lua_Mob l_mob(std::any_cast<Mob*>(extra_pointers->at(1)));
|
||||
luabind::adl::object l_mob_o = luabind::adl::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
}
|
||||
}
|
||||
|
||||
// Item
|
||||
void handle_item_click(
|
||||
QuestInterface *parse,
|
||||
@@ -1977,7 +2066,7 @@ void handle_bot_equip_item(
|
||||
lua_setfield(L, -2, "item");
|
||||
}
|
||||
|
||||
void handle_bot_unequip_item(
|
||||
void handle_bot_damage(
|
||||
QuestInterface *parse,
|
||||
lua_State* L,
|
||||
Bot* bot,
|
||||
@@ -1986,22 +2075,39 @@ void handle_bot_unequip_item(
|
||||
uint32 extra_data,
|
||||
std::vector<std::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::stoul(sep.arg[0]));
|
||||
lua_setfield(L, -2, "entity_id");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[1]));
|
||||
lua_setfield(L, -2, "slot_id");
|
||||
lua_pushnumber(L, std::stoll(sep.arg[1]));
|
||||
lua_setfield(L, -2, "damage");
|
||||
|
||||
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");
|
||||
lua_pushnumber(L, std::stoi(sep.arg[2]));
|
||||
lua_setfield(L, -2, "spell_id");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[3]));
|
||||
lua_setfield(L, -2, "skill_id");
|
||||
|
||||
lua_pushboolean(L, std::stoi(sep.arg[4]) == 0 ? false : true);
|
||||
lua_setfield(L, -2, "is_damage_shield");
|
||||
|
||||
lua_pushboolean(L, std::stoi(sep.arg[5]) == 0 ? false : true);
|
||||
lua_setfield(L, -2, "is_avoidable");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[6]));
|
||||
lua_setfield(L, -2, "buff_slot");
|
||||
|
||||
lua_pushboolean(L, std::stoi(sep.arg[7]) == 0 ? false : true);
|
||||
lua_setfield(L, -2, "is_buff_tic");
|
||||
|
||||
lua_pushnumber(L, std::stoi(sep.arg[8]));
|
||||
lua_setfield(L, -2, "special_attack");
|
||||
|
||||
Lua_Mob l_mob(init);
|
||||
luabind::adl::object l_mob_o = luabind::adl::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user