mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
Hate list stuff, need to make it more efficient
This commit is contained in:
parent
3ddc61420b
commit
1f265af1e7
@ -8,6 +8,7 @@ class Entity;
|
||||
class Lua_Client;
|
||||
class Lua_NPC;
|
||||
class Lua_Mob;
|
||||
struct Lua_HateList;
|
||||
//class Lua_Merc;
|
||||
//class Lua_Corpse;
|
||||
//class Lua_Object;
|
||||
@ -24,7 +25,8 @@ class Lua_Mob;
|
||||
#define Lua_Safe_Call_Entity() if(!d_) { return Lua_Entity(); } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Mob() if(!d_) { return Lua_Mob(); } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_NPC() if(!d_) { return Lua_NPC(); } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_Client() if(!d_) { return Lua_Client(); } NativeType *self = reinterpret_cast<Type*>(d_)
|
||||
#define Lua_Safe_Call_Client() if(!d_) { return Lua_Client(); } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
#define Lua_Safe_Call_HateList() if(!d_) { return Lua_HateList(); } NativeType *self = reinterpret_cast<NativeType*>(d_)
|
||||
|
||||
class Lua_Entity : public Lua_Ptr
|
||||
{
|
||||
|
||||
19
zone/lua_hate_entry.h
Normal file
19
zone/lua_hate_entry.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef EQEMU_LUA_HATE_ENTRY_H
|
||||
#define EQEMU_LUA_HATE_ENTRY_H
|
||||
#ifdef LUA_EQEMU
|
||||
|
||||
class Lua_Mob;
|
||||
|
||||
struct Lua_HateEntry
|
||||
{
|
||||
Lua_HateEntry() { }
|
||||
virtual ~Lua_HateEntry() { }
|
||||
|
||||
Lua_Mob ent;
|
||||
int damage;
|
||||
int hate;
|
||||
bool frenzy;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
11
zone/lua_hate_list.h
Normal file
11
zone/lua_hate_list.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef EQEMU_LUA_HATE_LIST_H
|
||||
#define EQEMU_LUA_HATE_LIST_H
|
||||
#ifdef LUA_EQEMU
|
||||
|
||||
struct Lua_HateList
|
||||
{
|
||||
std::vector<Lua_HateEntry> entries;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
#include "masterentity.h"
|
||||
#include "lua_mob.h"
|
||||
#include "lua_hate_entry.h"
|
||||
#include "lua_hate_list.h"
|
||||
#include "lua_client.h"
|
||||
|
||||
const char *Lua_Mob::GetName() {
|
||||
@ -751,5 +753,25 @@ Lua_Mob Lua_Mob::GetOwner() {
|
||||
return Lua_Mob(self->GetOwner());
|
||||
}
|
||||
|
||||
Lua_HateList Lua_Mob::GetHateList() {
|
||||
Lua_Safe_Call_HateList();
|
||||
Lua_HateList ret;
|
||||
|
||||
std::list<tHateEntry*> h_list;
|
||||
self->GetHateList(h_list);
|
||||
auto iter = h_list.begin();
|
||||
while(iter != h_list.end()) {
|
||||
tHateEntry *ent = (*iter);
|
||||
Lua_HateEntry e;
|
||||
e.ent = Lua_Mob(ent->ent);
|
||||
e.damage = ent->damage;
|
||||
e.hate = ent->hate;
|
||||
e.frenzy = ent->bFrenzy;
|
||||
ret.entries.push_back(e);
|
||||
++iter;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include "lua_entity.h"
|
||||
|
||||
class Mob;
|
||||
struct Lua_HateList;
|
||||
|
||||
class Lua_Mob : public Lua_Entity
|
||||
{
|
||||
@ -172,6 +173,7 @@ public:
|
||||
void SpellEffect(Lua_Mob caster, int spell_id, double partial);
|
||||
Lua_Mob GetPet();
|
||||
Lua_Mob GetOwner();
|
||||
Lua_HateList GetHateList();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -2,21 +2,26 @@
|
||||
|
||||
#include "lua.hpp"
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
#include <boost/any.hpp>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include "masterentity.h"
|
||||
#include "../common/spdat.h"
|
||||
#include "../common/seperator.h"
|
||||
#include "lua_entity.h"
|
||||
#include "lua_mob.h"
|
||||
#include "lua_hate_entry.h"
|
||||
#include "lua_hate_list.h"
|
||||
#include "lua_client.h"
|
||||
#include "lua_npc.h"
|
||||
#include "lua_item.h"
|
||||
#include "lua_spell.h"
|
||||
#include "zone.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include "lua_parser.h"
|
||||
|
||||
const char *LuaEvents[_LargestEventID] = {
|
||||
@ -888,6 +893,7 @@ void LuaParser::MapFunctions(lua_State *L) {
|
||||
.def("SpellFinished", (bool(Lua_Mob::*)(int,Lua_Mob,int,int,uint32,int))&Lua_Mob::SpellFinished)
|
||||
.def("SpellFinished", (bool(Lua_Mob::*)(int,Lua_Mob,int,int,uint32,int,bool))&Lua_Mob::SpellFinished)
|
||||
.def("SpellEffect", &Lua_Mob::SpellEffect)
|
||||
.def("GetHateList", &Lua_Mob::GetHateList)
|
||||
,
|
||||
|
||||
luabind::class_<Lua_Client, Lua_Mob>("Client")
|
||||
@ -896,29 +902,19 @@ void LuaParser::MapFunctions(lua_State *L) {
|
||||
luabind::class_<Lua_NPC, Lua_Mob>("NPC")
|
||||
.def(luabind::constructor<>()),
|
||||
|
||||
//luabind::class_<Lua_Trade>("Trade")
|
||||
// .def(luabind::constructor<>())
|
||||
// .def_readwrite("item1", &Lua_Trade::item1_)
|
||||
// .def_readwrite("item2", &Lua_Trade::item2_)
|
||||
// .def_readwrite("item3", &Lua_Trade::item3_)
|
||||
// .def_readwrite("item4", &Lua_Trade::item4_)
|
||||
// .def_readwrite("item1_charges", &Lua_Trade::item1_charges_)
|
||||
// .def_readwrite("item2_charges", &Lua_Trade::item2_charges_)
|
||||
// .def_readwrite("item3_charges", &Lua_Trade::item3_charges_)
|
||||
// .def_readwrite("item4_charges", &Lua_Trade::item4_charges_)
|
||||
// .def_readwrite("item1_attuned", &Lua_Trade::item1_attuned_)
|
||||
// .def_readwrite("item2_attuned", &Lua_Trade::item2_attuned_)
|
||||
// .def_readwrite("item3_attuned", &Lua_Trade::item3_attuned_)
|
||||
// .def_readwrite("item4_attuned", &Lua_Trade::item4_attuned_)
|
||||
// .def_readwrite("platinum", &Lua_Trade::platinum_)
|
||||
// .def_readwrite("gold", &Lua_Trade::gold_)
|
||||
// .def_readwrite("silver", &Lua_Trade::silver_)
|
||||
// .def_readwrite("copper", &Lua_Trade::copper_),
|
||||
|
||||
luabind::class_<Lua_Item>("Item")
|
||||
.def(luabind::constructor<>())
|
||||
.property("null", &Lua_Entity::Null)
|
||||
.property("valid", &Lua_Entity::Valid)
|
||||
.property("valid", &Lua_Entity::Valid),
|
||||
|
||||
luabind::class_<Lua_HateEntry>("HateEntry")
|
||||
.def_readwrite("ent", &Lua_HateEntry::ent)
|
||||
.def_readwrite("damage", &Lua_HateEntry::damage)
|
||||
.def_readwrite("hate", &Lua_HateEntry::hate)
|
||||
.def_readwrite("frenzy", &Lua_HateEntry::frenzy),
|
||||
|
||||
luabind::class_<Lua_HateList>("HateList")
|
||||
.def_readwrite("entries", &Lua_HateList::entries, luabind::return_stl_iterator)
|
||||
];
|
||||
|
||||
} catch(std::exception &ex) {
|
||||
|
||||
@ -2576,29 +2576,6 @@ void Merc::CheckHateList() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*std::list<tHateEntry*> their_hate_list;
|
||||
npc->GetHateList(their_hate_list);
|
||||
std::list<tHateEntry*>::iterator hateEntryIter = their_hate_list.begin();
|
||||
|
||||
while(hateEntryIter != their_hate_list.end())
|
||||
{
|
||||
tHateEntry *entry = (*hateEntryIter);
|
||||
|
||||
if(g->IsGroupMember(entry->ent)) {
|
||||
if(!hate_list.IsOnHateList(npc)) {
|
||||
float range = g->HasRole(entry->ent, RolePuller) ? RuleI(Mercs, AggroRadiusPuller) : RuleI(Mercs, AggroRadius);
|
||||
range *= range;
|
||||
if(entry->ent->DistNoRootNoZ(*this) < range) {
|
||||
hate_list.Add(entry->ent, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hateEntryIter++;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user