mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 11:28:25 +00:00
Changed EVENT_TRADE to pass iteminst instead of variable ids, perl will not have changed at all but lua now passes the iteminsts in the trade object. Also redid a bunch of the spell quest stuff
This commit is contained in:
+105
-33
@@ -21,7 +21,8 @@
|
||||
#include "lua_parser_events.h"
|
||||
|
||||
//NPC
|
||||
void handle_npc_event_say(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_event_say(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
npc->DoQuestPause(init);
|
||||
|
||||
Lua_Client l_client(reinterpret_cast<Client*>(init));
|
||||
@@ -36,7 +37,8 @@ void handle_npc_event_say(QuestInterface *parse, lua_State* L, NPC* npc, Mob *in
|
||||
lua_setfield(L, -2, "language");
|
||||
}
|
||||
|
||||
void handle_npc_event_trade(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_event_trade(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
Lua_Client l_client(reinterpret_cast<Client*>(init));
|
||||
luabind::object l_client_o = luabind::object(L, l_client);
|
||||
l_client_o.push(L);
|
||||
@@ -45,28 +47,18 @@ void handle_npc_event_trade(QuestInterface *parse, lua_State* L, NPC* npc, Mob *
|
||||
lua_createtable(L, 0, 0);
|
||||
std::stringstream ident;
|
||||
ident << npc->GetNPCTypeID();
|
||||
|
||||
if(items) {
|
||||
for(size_t i = 0; i < items->size(); ++i) {
|
||||
std::string prefix = "item" + std::to_string(i + 1);
|
||||
Lua_ItemInst l_inst = items->at(i);
|
||||
luabind::object l_inst_o = luabind::object(L, l_inst);
|
||||
l_inst_o.push(L);
|
||||
|
||||
for(int i = 1; i <= 4; ++i) {
|
||||
std::string prefix = "item" + std::to_string(i);
|
||||
|
||||
std::string cur = prefix;
|
||||
lua_pushinteger(L, std::stoul(parse->GetVar(prefix + "." + ident.str())));
|
||||
lua_setfield(L, -2, prefix.c_str());
|
||||
|
||||
lua_pushinteger(L, std::stoul(parse->GetVar(prefix + ".charges." + ident.str())));
|
||||
lua_setfield(L, -2, std::string(prefix + "_charges").c_str());
|
||||
|
||||
lua_pushboolean(L, std::stoul(parse->GetVar(prefix + ".attuned." + ident.str())));
|
||||
lua_setfield(L, -2, std::string(prefix + "_attuned").c_str());
|
||||
|
||||
for(int j = 1; j <= 5; ++j) {
|
||||
std::string augment = "augment" + std::to_string(j);
|
||||
|
||||
lua_pushinteger(L, std::stoul(parse->GetVar(prefix + "." + augment + "." + ident.str())));
|
||||
lua_setfield(L, -2, std::string(prefix + "_" + augment).c_str());
|
||||
lua_setfield(L, -2, prefix.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
lua_pushinteger(L, std::stoul(parse->GetVar("platinum." + ident.str())));
|
||||
lua_setfield(L, -2, "platinum");
|
||||
|
||||
@@ -81,7 +73,8 @@ void handle_npc_event_trade(QuestInterface *parse, lua_State* L, NPC* npc, Mob *
|
||||
lua_setfield(L, -2, "trade");
|
||||
}
|
||||
|
||||
void handle_npc_event_hp(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_event_hp(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
if(extra_data == 1) {
|
||||
lua_pushinteger(L, -1);
|
||||
lua_setfield(L, -2, "hp_event");
|
||||
@@ -97,28 +90,32 @@ void handle_npc_event_hp(QuestInterface *parse, lua_State* L, NPC* npc, Mob *ini
|
||||
}
|
||||
}
|
||||
|
||||
void handle_npc_single_mob(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_single_mob(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
Lua_Mob l_mob(init);
|
||||
luabind::object l_mob_o = luabind::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
}
|
||||
|
||||
void handle_npc_single_client(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_single_client(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
Lua_Client l_client(reinterpret_cast<Client*>(init));
|
||||
luabind::object l_client_o = luabind::object(L, l_client);
|
||||
l_client_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
}
|
||||
|
||||
void handle_npc_single_npc(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_single_npc(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
Lua_NPC l_npc(reinterpret_cast<NPC*>(init));
|
||||
luabind::object l_npc_o = luabind::object(L, l_npc);
|
||||
l_npc_o.push(L);
|
||||
lua_setfield(L, -2, "other");
|
||||
}
|
||||
|
||||
void handle_npc_popup(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_popup(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
Lua_Mob l_mob(init);
|
||||
luabind::object l_mob_o = luabind::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
@@ -128,7 +125,8 @@ void handle_npc_popup(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init,
|
||||
lua_setfield(L, -2, "popup_id");
|
||||
}
|
||||
|
||||
void handle_npc_waypoint(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_waypoint(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
Lua_Mob l_mob(init);
|
||||
luabind::object l_mob_o = luabind::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
@@ -138,7 +136,8 @@ void handle_npc_waypoint(QuestInterface *parse, lua_State* L, NPC* npc, Mob *ini
|
||||
lua_setfield(L, -2, "wp");
|
||||
}
|
||||
|
||||
void handle_npc_hate(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_hate(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
Lua_Mob l_mob(init);
|
||||
luabind::object l_mob_o = luabind::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
@@ -149,17 +148,20 @@ void handle_npc_hate(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, s
|
||||
}
|
||||
|
||||
|
||||
void handle_npc_signal(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_signal(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
lua_pushinteger(L, std::stoi(data));
|
||||
lua_setfield(L, -2, "signal_id");
|
||||
}
|
||||
|
||||
void handle_npc_timer(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_timer(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
lua_pushstring(L, data.c_str());
|
||||
lua_setfield(L, -2, "timer");
|
||||
}
|
||||
|
||||
void handle_npc_death(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_death(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
Lua_Mob l_mob(init);
|
||||
luabind::object l_mob_o = luabind::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
@@ -186,7 +188,24 @@ void handle_npc_death(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init,
|
||||
lua_setfield(L, -2, "skill_id");
|
||||
}
|
||||
|
||||
void handle_npc_null(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
|
||||
void handle_npc_cast(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
int spell_id = std::stoi(data);
|
||||
if(IsValidSpell(spell_id)) {
|
||||
Lua_Spell l_spell(&spells[spell_id]);
|
||||
luabind::object l_spell_o = luabind::object(L, l_spell);
|
||||
l_spell_o.push(L);
|
||||
lua_setfield(L, -2, "spell");
|
||||
} else {
|
||||
Lua_Spell l_spell(nullptr);
|
||||
luabind::object l_spell_o = luabind::object(L, l_spell);
|
||||
l_spell_o.push(L);
|
||||
lua_setfield(L, -2, "spell");
|
||||
}
|
||||
}
|
||||
|
||||
void handle_npc_null(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init, std::string data, uint32 extra_data,
|
||||
std::vector<ItemInst*> *items) {
|
||||
}
|
||||
|
||||
//Player
|
||||
@@ -351,6 +370,24 @@ void handle_player_task_complete(QuestInterface *parse, lua_State* L, Client* cl
|
||||
lua_setfield(L, -2, "task_id");
|
||||
}
|
||||
|
||||
void handle_player_command(QuestInterface *parse, lua_State* L, Client* client, std::string data, uint32 extra_data) {
|
||||
Seperator sep(data.c_str(), ' ', 10, 100, true);
|
||||
std::string command(sep.arg[0] + 1);
|
||||
lua_pushstring(L, command.c_str());
|
||||
lua_setfield(L, -2, "command");
|
||||
|
||||
luabind::object args = luabind::newtable(L);
|
||||
int max_args = sep.GetMaxArgNum();
|
||||
for(int i = 1; i < max_args; ++i) {
|
||||
if(strlen(sep.arg[0]) > 0) {
|
||||
args[i] = sep.arg[i];
|
||||
}
|
||||
}
|
||||
|
||||
args.push(L);
|
||||
lua_setfield(L, -2, "args");
|
||||
}
|
||||
|
||||
void handle_player_null(QuestInterface *parse, lua_State* L, Client* client, std::string data, uint32 extra_data) {
|
||||
}
|
||||
|
||||
@@ -365,8 +402,43 @@ void handle_item_null(QuestInterface *parse, lua_State* L, Client* client, ItemI
|
||||
|
||||
//Spell
|
||||
void handle_spell_effect(QuestInterface *parse, lua_State* L, NPC* npc, Client* client, uint32 spell_id, uint32 extra_data) {
|
||||
if(npc) {
|
||||
Lua_NPC l_npc(npc);
|
||||
luabind::object l_npc_o = luabind::object(L, l_npc);
|
||||
l_npc_o.push(L);
|
||||
} else if(client) {
|
||||
Lua_Client l_client(client);
|
||||
luabind::object l_client_o = luabind::object(L, l_client);
|
||||
l_client_o.push(L);
|
||||
} else {
|
||||
Lua_Mob l_mob(nullptr);
|
||||
luabind::object l_mob_o = luabind::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
}
|
||||
lua_setfield(L, -2, "target");
|
||||
|
||||
lua_pushinteger(L, extra_data);
|
||||
lua_setfield(L, -2, "caster_id");
|
||||
lua_setfield(L, -2, "caster_id");
|
||||
}
|
||||
|
||||
void handle_spell_fade(QuestInterface *parse, lua_State* L, NPC* npc, Client* client, uint32 spell_id, uint32 extra_data) {
|
||||
if(npc) {
|
||||
Lua_NPC l_npc(npc);
|
||||
luabind::object l_npc_o = luabind::object(L, l_npc);
|
||||
l_npc_o.push(L);
|
||||
} else if(client) {
|
||||
Lua_Client l_client(client);
|
||||
luabind::object l_client_o = luabind::object(L, l_client);
|
||||
l_client_o.push(L);
|
||||
} else {
|
||||
Lua_Mob l_mob(nullptr);
|
||||
luabind::object l_mob_o = luabind::object(L, l_mob);
|
||||
l_mob_o.push(L);
|
||||
}
|
||||
lua_setfield(L, -2, "target");
|
||||
|
||||
lua_pushinteger(L, extra_data);
|
||||
lua_setfield(L, -2, "buff_slot");
|
||||
}
|
||||
|
||||
void handle_spell_null(QuestInterface *parse, lua_State* L, NPC* npc, Client* client, uint32 spell_id, uint32 extra_data) {
|
||||
|
||||
Reference in New Issue
Block a user