mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 11:28:25 +00:00
[Bots] Add GetAugmentIDsBySlotID & AddItem with table ref Methods. (#2805)
* [Bots] Add GetAugmentIDsBySlotID & AddItem with table ref Methods. * Return invalid slots to owner.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "lua_iteminst.h"
|
||||
#include "lua_mob.h"
|
||||
#include "lua_group.h"
|
||||
#include "lua_item.h"
|
||||
|
||||
void Lua_Bot::AddBotItem(uint16 slot_id, uint32 item_id) {
|
||||
Lua_Safe_Call_Void();
|
||||
@@ -393,6 +394,66 @@ void Lua_Bot::SendSpellAnim(uint16 target_id, uint16 spell_id)
|
||||
self->SendSpellAnim(target_id, spell_id);
|
||||
}
|
||||
|
||||
luabind::object Lua_Bot::GetAugmentIDsBySlotID(lua_State* L, int16 slot_id) const {
|
||||
auto lua_table = luabind::newtable(L);
|
||||
if (d_) {
|
||||
auto self = reinterpret_cast<NativeType*>(d_);
|
||||
auto augments = self->GetInv().GetAugmentIDsBySlotID(slot_id);
|
||||
int index = 1;
|
||||
for (auto item_id : augments) {
|
||||
lua_table[index] = item_id;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return lua_table;
|
||||
}
|
||||
|
||||
void Lua_Bot::AddItem(const luabind::object& item_table) {
|
||||
Lua_Safe_Call_Void();
|
||||
if (luabind::type(item_table) != LUA_TTABLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto item_id = luabind::object_cast<uint32>(item_table["item_id"]);
|
||||
int16 charges = luabind::object_cast<uint32>(item_table["charges"]);
|
||||
uint32 augment_one = luabind::type(item_table["augment_one"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_one"]) : 0;
|
||||
uint32 augment_two = luabind::type(item_table["augment_two"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_two"]) : 0;
|
||||
uint32 augment_three = luabind::type(item_table["augment_three"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_three"]) : 0;
|
||||
uint32 augment_four = luabind::type(item_table["augment_four"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_four"]) : 0;
|
||||
uint32 augment_five = luabind::type(item_table["augment_five"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_five"]) : 0;
|
||||
uint32 augment_six = luabind::type(item_table["augment_six"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_six"]) : 0;
|
||||
bool attuned = luabind::type(item_table["attuned"]) != LUA_TNIL ? luabind::object_cast<bool>(item_table["attuned"]) : false;
|
||||
uint16 slot_id = luabind::type(item_table["slot_id"]) != LUA_TNIL ? luabind::object_cast<uint16>(item_table["slot_id"]) : EQ::invslot::slotCursor;
|
||||
|
||||
if (slot_id <= EQ::invslot::slotAmmo) {
|
||||
self->AddBotItem(
|
||||
slot_id,
|
||||
item_id,
|
||||
charges,
|
||||
attuned,
|
||||
augment_one,
|
||||
augment_two,
|
||||
augment_three,
|
||||
augment_four,
|
||||
augment_five,
|
||||
augment_six
|
||||
);
|
||||
} else {
|
||||
self->GetOwner()->CastToClient()->SummonItem(
|
||||
item_id,
|
||||
charges,
|
||||
augment_one,
|
||||
augment_two,
|
||||
augment_three,
|
||||
augment_four,
|
||||
augment_five,
|
||||
augment_six,
|
||||
attuned,
|
||||
slot_id
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
luabind::scope lua_register_bot() {
|
||||
return luabind::class_<Lua_Bot, Lua_Mob>("Bot")
|
||||
.def(luabind::constructor<>())
|
||||
@@ -405,6 +466,7 @@ luabind::scope lua_register_bot() {
|
||||
.def("AddBotItem", (void(Lua_Bot::*)(uint16,uint32,int16,bool,uint32,uint32,uint32,uint32))&Lua_Bot::AddBotItem)
|
||||
.def("AddBotItem", (void(Lua_Bot::*)(uint16,uint32,int16,bool,uint32,uint32,uint32,uint32,uint32))&Lua_Bot::AddBotItem)
|
||||
.def("AddBotItem", (void(Lua_Bot::*)(uint16,uint32,int16,bool,uint32,uint32,uint32,uint32,uint32,uint32))&Lua_Bot::AddBotItem)
|
||||
.def("AddItem", (void(Lua_Bot::*)(luabind::adl::object))&Lua_Bot::AddItem)
|
||||
.def("ApplySpell", (void(Lua_Bot::*)(int))&Lua_Bot::ApplySpell)
|
||||
.def("ApplySpell", (void(Lua_Bot::*)(int,int))&Lua_Bot::ApplySpell)
|
||||
.def("ApplySpell", (void(Lua_Bot::*)(int,int,bool))&Lua_Bot::ApplySpell)
|
||||
@@ -424,6 +486,7 @@ luabind::scope lua_register_bot() {
|
||||
.def("Fling", (void(Lua_Bot::*)(float,float,float,float,bool,bool))&Lua_Bot::Fling)
|
||||
.def("GetAugmentAt", (Lua_ItemInst(Lua_Bot::*)(int16,uint8))&Lua_Bot::GetAugmentAt)
|
||||
.def("GetAugmentIDAt", (int(Lua_Bot::*)(int16,uint8))&Lua_Bot::GetAugmentIDAt)
|
||||
.def("GetAugmentIDsBySlotID", (luabind::object(Lua_Bot::*)(lua_State* L,int16))&Lua_Bot::GetAugmentIDsBySlotID)
|
||||
.def("GetBaseAGI", (int(Lua_Bot::*)(void))&Lua_Bot::GetBaseAGI)
|
||||
.def("GetBaseCHA", (int(Lua_Bot::*)(void))&Lua_Bot::GetBaseCHA)
|
||||
.def("GetBaseDEX", (int(Lua_Bot::*)(void))&Lua_Bot::GetBaseDEX)
|
||||
|
||||
Reference in New Issue
Block a user