Working on last of Mob:: that can be implemented atm, added safety checks to the lua functions that will be optional later in dev mode. Also changed quest return types to integers instead of doubles as that was non-intuitive

This commit is contained in:
KimLS 2013-05-13 14:29:50 -07:00
parent 2445576ae8
commit 7b23c8dc75
16 changed files with 1375 additions and 593 deletions

View File

@ -28,12 +28,12 @@ class NPC;
class QuestInterface {
public:
virtual double EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { return 100.0; }
virtual double EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { return 100.0; }
virtual double EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { return 100.0; }
virtual double EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { return 100.0; }
virtual double EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) { return 100.0; }
virtual double EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) { return 100.0; }
virtual int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { return 0; }
virtual int EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) { return 0; }
virtual int EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { return 0; }
virtual int EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { return 0; }
virtual int EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) { return 0; }
virtual int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) { return 0; }
virtual bool HasQuestSub(uint32 npcid, const char *subname) { return false; }
virtual bool HasGlobalQuestSub(const char *subname) { return false; }

View File

@ -215,13 +215,21 @@ bool QuestParserCollection::ItemHasQuestSub(ItemInst *itm, const char *subname)
return false;
}
double QuestParserCollection::EventNPC(QuestEventID evt, NPC *npc, Mob *init, std::string data, uint32 extra_data) {
double ret = EventNPCLocal(evt, npc, init, data, extra_data);
EventNPCGlobal(evt, npc, init, data, extra_data);
return ret;
int QuestParserCollection::EventNPC(QuestEventID evt, NPC *npc, Mob *init, std::string data, uint32 extra_data) {
int rl = EventNPCLocal(evt, npc, init, data, extra_data);
int rg = EventNPCGlobal(evt, npc, init, data, extra_data);
//Local quests returning non-default values have priority over global quests
if(rl != 0) {
return rl;
} else if(rg != 0) {
return rg;
}
return 0;
}
double QuestParserCollection::EventNPCLocal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
int QuestParserCollection::EventNPCLocal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
std::map<uint32, uint32>::iterator iter = _npc_quest_status.find(npc->GetNPCTypeID());
if(iter != _npc_quest_status.end()) {
//loaded or failed to load
@ -240,33 +248,42 @@ double QuestParserCollection::EventNPCLocal(QuestEventID evt, NPC* npc, Mob *ini
_npc_quest_status[npc->GetNPCTypeID()] = QuestFailedToLoad;
}
}
return 100.0;
return 0;
}
void QuestParserCollection::EventNPCGlobal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
int QuestParserCollection::EventNPCGlobal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
if(_global_npc_quest_status != QuestUnloaded && _global_npc_quest_status != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(_global_npc_quest_status);
qiter->second->EventGlobalNPC(evt, npc, init, data, extra_data);
return qiter->second->EventGlobalNPC(evt, npc, init, data, extra_data);
} else {
std::string filename;
QuestInterface *qi = GetQIByGlobalNPCQuest(filename);
if(qi) {
_global_npc_quest_status = qi->GetIdentifier();
qi->LoadGlobalNPCScript(filename);
qi->EventGlobalNPC(evt, npc, init, data, extra_data);
return qi->EventGlobalNPC(evt, npc, init, data, extra_data);
} else {
_global_npc_quest_status = QuestFailedToLoad;
}
}
return 0;
}
double QuestParserCollection::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
double ret = EventPlayerLocal(evt, client, data, extra_data);
EventPlayerGlobal(evt, client, data, extra_data);
return ret;
int QuestParserCollection::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
int rl = EventPlayerLocal(evt, client, data, extra_data);
int rg = EventPlayerGlobal(evt, client, data, extra_data);
//Local quests returning non-default values have priority over global quests
if(rl != 0) {
return rl;
} else if(rg != 0) {
return rg;
}
return 0;
}
double QuestParserCollection::EventPlayerLocal(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
int QuestParserCollection::EventPlayerLocal(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
if(_player_quest_status == QuestUnloaded) {
std::string filename;
QuestInterface *qi = GetQIByPlayerQuest(filename);
@ -281,27 +298,28 @@ double QuestParserCollection::EventPlayerLocal(QuestEventID evt, Client *client,
return iter->second->EventPlayer(evt, client, data, extra_data);
}
}
return 100.0;
return 0;
}
void QuestParserCollection::EventPlayerGlobal(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
int QuestParserCollection::EventPlayerGlobal(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
if(_global_player_quest_status == QuestUnloaded) {
std::string filename;
QuestInterface *qi = GetQIByGlobalPlayerQuest(filename);
if(qi) {
_global_player_quest_status = qi->GetIdentifier();
qi->LoadGlobalPlayerScript(filename);
qi->EventGlobalPlayer(evt, client, data, extra_data);
return qi->EventGlobalPlayer(evt, client, data, extra_data);
}
} else {
if(_global_player_quest_status != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator iter = _interfaces.find(_global_player_quest_status);
iter->second->EventGlobalPlayer(evt, client, data, extra_data);
return iter->second->EventGlobalPlayer(evt, client, data, extra_data);
}
}
return 0;
}
double QuestParserCollection::EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) {
int QuestParserCollection::EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) {
std::string item_script;
if(evt == EVENT_SCALE_CALC || evt == EVENT_ITEM_ENTERZONE) {
item_script = item->GetItem()->CharmFile;
@ -330,10 +348,10 @@ double QuestParserCollection::EventItem(QuestEventID evt, Client *client, ItemIn
_item_quest_status[item_script] = QuestFailedToLoad;
}
}
return 100.0;
return 0;
}
double QuestParserCollection::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) {
int QuestParserCollection::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) {
std::map<uint32, uint32>::iterator iter = _spell_quest_status.find(spell_id);
if(iter != _spell_quest_status.end()) {
//loaded or failed to load
@ -352,7 +370,7 @@ double QuestParserCollection::EventSpell(QuestEventID evt, NPC* npc, Client *cli
_spell_quest_status[spell_id] = QuestFailedToLoad;
}
}
return 100.0;
return 0;
}
QuestInterface *QuestParserCollection::GetQIByNPCQuest(uint32 npcid, std::string &filename) {

View File

@ -48,10 +48,10 @@ public:
bool SpellHasQuestSub(uint32 spell_id, const char *subname);
bool ItemHasQuestSub(ItemInst *itm, const char *subname);
double EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
double EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
double EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data);
double EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data);
int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
int EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
int EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data);
int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data);
private:
bool HasQuestSubLocal(uint32 npcid, const char *subname);
@ -59,10 +59,10 @@ private:
bool PlayerHasQuestSubLocal(const char *subname);
bool PlayerHasQuestSubGlobal(const char *subname);
double EventNPCLocal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
void EventNPCGlobal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
double EventPlayerLocal(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
void EventPlayerGlobal(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
int EventNPCLocal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
int EventNPCGlobal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
int EventPlayerLocal(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
int EventPlayerGlobal(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
QuestInterface *GetQIByNPCQuest(uint32 npcid, std::string &filename);
QuestInterface *GetQIByGlobalNPCQuest(std::string &filename);

View File

@ -1425,7 +1425,7 @@ void Client::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_
if(dead)
return; //cant die more than once...
if(parse->EventPlayer(EVENT_DEATH, this, "", 0) <= 0.0) {
if(parse->EventPlayer(EVENT_DEATH, this, "", 0) == 1) {
return;
}
@ -2041,6 +2041,15 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski
_ZP(NPC_Death);
mlog(COMBAT__HITS, "Fatal blow dealt by %s with %d damage, spell %d, skill %d", killerMob->GetName(), damage, spell, attack_skill);
Mob *oos = nullptr;
if(killerMob) {
Mob *oos = killerMob->GetOwnerOrSelf();
if(parse->EventNPC(EVENT_DEATH, this, oos, "", 0) != 0)
{
return;
}
}
if (this->IsEngaged())
{
zone->DelAggroMob();
@ -2064,7 +2073,6 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski
Death_Struct* d = (Death_Struct*)app->pBuffer;
d->spawn_id = GetID();
d->killer_id = killerMob ? killerMob->GetID() : 0;
// d->unknown12 = 1;
d->bindzoneid = 0;
d->spell_id = spell == SPELL_UNKNOWN ? 0xffffffff : spell;
d->attack_skill = SkillDamageTypes[attack_skill];
@ -2348,22 +2356,19 @@ void NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski
entity_list.RemoveFromXTargets(this);
// Parse quests even if we're killed by an NPC
if(killerMob) {
Mob *oos = killerMob->GetOwnerOrSelf();
parse->EventNPC(EVENT_DEATH, this, oos, "", 0);
if(oos) {
mod_npc_killed(oos);
uint16 emoteid = this->GetEmoteID();
if(emoteid != 0)
this->DoNPCEmote(ONDEATH,emoteid);
this->DoNPCEmote(ONDEATH, emoteid);
if(oos->IsNPC())
{
parse->EventNPC(EVENT_NPC_SLAY, oos->CastToNPC(), this, "", 0);
uint16 emoteid = oos->GetEmoteID();
if(emoteid != 0)
oos->CastToNPC()->DoNPCEmote(KILLEDNPC,emoteid);
killerMob->TrySpellOnKill(killed_level,spell);
oos->CastToNPC()->DoNPCEmote(KILLEDNPC, emoteid);
killerMob->TrySpellOnKill(killed_level, spell);
}
}

View File

@ -196,34 +196,34 @@ void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * d
HandleQueue();
}
double PerlembParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
int PerlembParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
EventCommon(evt, npc->GetNPCTypeID(), data.c_str(), npc, nullptr, init, extra_data, false);
return 100.0;
return 0;
}
double PerlembParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
int PerlembParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
EventCommon(evt, npc->GetNPCTypeID(), data.c_str(), npc, nullptr, init, extra_data, true);
return 100.0;
return 0;
}
double PerlembParser::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
int PerlembParser::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
EventCommon(evt, 0, data.c_str(), nullptr, nullptr, client, extra_data, false);
return 100.0;
return 0;
}
double PerlembParser::EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
int PerlembParser::EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
EventCommon(evt, 0, data.c_str(), nullptr, nullptr, client, extra_data, true);
return 100.0;
return 0;
}
double PerlembParser::EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) {
int PerlembParser::EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) {
EventCommon(evt, objid, nullptr, nullptr, item, client, extra_data, false);
return 100.0;
return 0;
}
double PerlembParser::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) {
int PerlembParser::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) {
EventCommon(evt, 0, itoa(spell_id), npc, nullptr, client, extra_data, false);
return 100.0;
return 0;
}
bool PerlembParser::HasQuestSub(uint32 npcid, const char *subname) {

View File

@ -55,12 +55,12 @@ public:
PerlembParser();
~PerlembParser();
virtual double EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
virtual double EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
virtual double EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
virtual double EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
virtual double EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data);
virtual double EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data);
virtual int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
virtual int EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
virtual int EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
virtual int EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
virtual int EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data);
virtual int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data);
virtual bool HasQuestSub(uint32 npcid, const char *subname);
virtual bool HasGlobalQuestSub(const char *subname);

View File

@ -12,6 +12,14 @@ public:
Lua_Client() { d_ = nullptr; }
Lua_Client(Client *d) { d_ = d; }
virtual ~Lua_Client() { }
operator Client* () {
if(d_) {
return reinterpret_cast<Client*>(d_);
}
return nullptr;
}
};
#endif

View File

@ -6,68 +6,72 @@
#include "lua_client.h"
#include "lua_npc.h"
bool Lua_Entity::NullPtr() {
bool Lua_Entity::Null() {
return d_ == nullptr;
}
bool Lua_Entity::Valid() {
return d_ != nullptr;
}
bool Lua_Entity::IsClient() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->IsClient();
Lua_Safe_Call_Bool(Entity);
return self->IsClient();
}
bool Lua_Entity::IsNPC() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->IsNPC();
Lua_Safe_Call_Bool(Entity);
return self->IsNPC();
}
bool Lua_Entity::IsMob() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->IsMob();
Lua_Safe_Call_Bool(Entity);
return self->IsMob();
}
bool Lua_Entity::IsMerc() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->IsMerc();
Lua_Safe_Call_Bool(Entity);
return self->IsMerc();
}
bool Lua_Entity::IsCorpse() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->IsCorpse();
Lua_Safe_Call_Bool(Entity);
return self->IsCorpse();
}
bool Lua_Entity::IsPlayerCorpse() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->IsPlayerCorpse();
Lua_Safe_Call_Bool(Entity);
return self->IsPlayerCorpse();
}
bool Lua_Entity::IsNPCCorpse() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->IsNPCCorpse();
Lua_Safe_Call_Bool(Entity);
return self->IsNPCCorpse();
}
bool Lua_Entity::IsObject() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->IsObject();
Lua_Safe_Call_Bool(Entity);
return self->IsObject();
}
bool Lua_Entity::IsDoor() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->IsDoor();
Lua_Safe_Call_Bool(Entity);
return self->IsDoor();
}
bool Lua_Entity::IsTrap() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->IsTrap();
Lua_Safe_Call_Bool(Entity);
return self->IsTrap();
}
bool Lua_Entity::IsBeacon() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->IsBeacon();
Lua_Safe_Call_Bool(Entity);
return self->IsBeacon();
}
int Lua_Entity::GetID() {
Entity *ent = reinterpret_cast<Entity*>(d_);
return ent->GetID();
Lua_Safe_Call_Bool(Entity);
return self->GetID();
}
Lua_Client Lua_Entity::CastToClient() {

View File

@ -11,11 +11,18 @@ class Lua_Mob;
//class Lua_Object;
//class Lua_Doors;
//class Lua_Trap;
//class Lua_Beacon;
//class Lua_Item;
#define Lua_Safe_Cast(type, m, other) \
type *m = nullptr; \
m = reinterpret_cast<type*>(other.d_);
//TODO: Remove the error checking by a flag since this adds significant overhead to each c call
#define Lua_Safe_Call_Void(Type) if(!d_) { return; } Type *self = reinterpret_cast<Type*>(d_);
#define Lua_Safe_Call_Bool(Type) if(!d_) { return false; } Type *self = reinterpret_cast<Type*>(d_);
#define Lua_Safe_Call_Int(Type) if(!d_) { return 0; } Type *self = reinterpret_cast<Type*>(d_);
#define Lua_Safe_Call_Real(Type) if(!d_) { return 0.0; } Type *self = reinterpret_cast<Type*>(d_);
#define Lua_Safe_Call_String(Type) if(!d_) { return ""; } Type *self = reinterpret_cast<Type*>(d_);
#define Lua_Safe_Call_Entity(Type) if(!d_) { return Lua_Entity(); } Type *self = reinterpret_cast<Type*>(d_);
#define Lua_Safe_Call_Mob(Type) if(!d_) { return Lua_Mob(); } Type *self = reinterpret_cast<Type*>(d_);
#define Lua_Safe_Call_NPC(Type) if(!d_) { return Lua_NPC(); } Type *self = reinterpret_cast<Type*>(d_);
#define Lua_Safe_Call_Client(Type) if(!d_) { return Lua_Client(); } Type *self = reinterpret_cast<Type*>(d_);
class Lua_Entity
{
@ -24,7 +31,16 @@ public:
Lua_Entity(Entity *d) : d_(d) { }
virtual ~Lua_Entity() { }
bool NullPtr();
operator Entity* () {
if(d_) {
return reinterpret_cast<Entity*>(d_);
}
return nullptr;
}
bool Null();
bool Valid();
bool IsClient();
bool IsNPC();
bool IsMob();

File diff suppressed because it is too large Load Diff

View File

@ -13,8 +13,15 @@ public:
Lua_Mob(Mob *d) { d_ = d; }
virtual ~Lua_Mob() { }
const char *GetName();
operator Mob* () {
if(d_) {
return reinterpret_cast<Mob*>(d_);
}
return nullptr;
}
const char *GetName();
void Depop();
void Depop(bool start_spawn_timer);
void RogueAssassinate(Lua_Mob other);
@ -166,148 +173,183 @@ public:
void Emote(const char *message);
void InterruptSpell();
void InterruptSpell(int spell_id);
//CastSpell
//SpellFinished
//IsImmuneToSpell
//BuffFadeBySpellID
//BuffFadeByEffect
//BuffFadeAll
//BuffFadeBySlot
//CanBuffStack
//IsCasting
//CastingSpellID
//SetAppearance
//GetAppearance
//GetRunAnimSpeed
//SetRunAnimSpeed
//SetPetID
//GetPetID
//SetOwnerID
//GetOwnerID
//GetPetType
//GetBodyType
//Stun
//Spin
//Kill
//SetInvul
//GetInvul
//SetExtraHaste
//GetHaste
//GetMonkHandToHandDamage
//CanThisClassDoubleAttack
//CanThisClassDualWield
//CanThisClassRiposte
//CanThisClassDodge
//CanThisClassParry
//GetMonkHandToHandDelay
//GetClassLevelFactor
//Mesmerize
//IsMezzed
//IsStunned
//StartEnrage
//IsEnraged
//GetReverseFactionCon
//IsAIControlled
//GetAggroRange
//GetAssistRange
//SetPetOrder
//GetPetOrder
//IsRoamer
//IsRooted
//AddToHateList
//SetHate
//GetHateAmount
//GetDamageAmount
//GetHateTop
//GetHateDamageTop
//GetHateRandom
//IsEngaged
//HateSummon
//FaceTarget
//SetHeading
//WipeHateList
//CheckAggro
//CalculateHeadingToTarget
//CalculateNewPosition
//CalculateNewPosition2
//CalculateDistance
//SendTo
//SendToFixZ
//NPCSpecialAttacks
//DontHealMeBefore
//DontBuffMeBefore
//DontDotMeBefore
//DontRootMeBefore
//DontSnareMeBefore
//GetResist
//GetShieldTarget
//SetShieldTarget
//Charmed
//GetLevelHP
//GetZoneID
//CheckAggroAmount
//CheckHealAggroAmount
//GetAA
//DivineAura
//AddFeignMemory
//RemoveFromFeignMemory
//ClearFeignMemory
//SetOOCRegen
//GetEntityVariable
//SetEntityVariable
//EntityVariableExists
//GetHateList
//SignalClient
//CombatRange
//DoSpecialAttackDamage
//CheckLoS
//CheckLoSToLoc
//FindGroundZ
//ProjectileAnim
//HasNPCSpecialAtk
//SendAppearanceEffect
//SetFlyMode
//SetTexture
//SetRace
//SetGender
//SendIllusion
//MakeTempPet
//QuestReward
//CameraEffect
//SpellEffect
//TempName
//GetItemStat
//SetGlobal
//TarGlobal
//DelGlobal
//SetSlotTint
//WearChange
//DoKnockback
//RemoveNimbusEffect
//IsRunning
//SetRunning
//SetBodyType
//SetDeltas
//SetLD
//SetTargetDestSteps
//SetTargetable
//MakeTempPet
//ModSkillDmgTaken
//GetModSkillDmgTaken
//GetSkillDmgTaken
//SetAllowBeneficial
//GetAllowBeneficial
//IsBeneficialAllowed
//ModVulnerability
//GetModVulnerability
//DoMeleeSkillAttackDmg
//DoArcheryAttackDmg
//DoThrowingAttackDmg
//SetDisableMelee
//IsMeleeDisabled
//SetFlurryChance
//GetFlurryChance
/*bool CastSpell(int spell_id, int target_id);
bool CastSpell(int spell_id, int target_id, int slot);
bool CastSpell(int spell_id, int target_id, int slot, int cast_time);
bool CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost);
bool CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot);
bool CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot, int timer, int timer_duration);
bool CastSpell(int spell_id, int target_id, int slot, int cast_time, int mana_cost, int item_slot, int timer, int timer_duration,
int resist_adjust);
bool SpellFinished(int spell_id, Lua_Mob target);
bool SpellFinished(int spell_id, Lua_Mob target, int slot);
bool SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used);
bool SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used, uint32 inventory_slot);
bool SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used, uint32 inventory_slot, int resist_adjust);
bool SpellFinished(int spell_id, Lua_Mob target, int slot, int mana_used, uint32 inventory_slot, int resist_adjust, bool proc);
void SpellEffect(Lua_Mob caster, int spell_id, double partial);
bool IsImmuneToSpell(int spell_id, Lua_Mob caster);
void BuffFadeBySpellID(int spell_id);
void BuffFadeByEffect(int effect_id, int skip_slot);
void BuffFadeAll();
void BuffFadeDetrimental();
void BuffFadeBySlot(int slot, bool recalc_bonuses);
void BuffFadeDetrimentalByCaster(Lua_Mob caster);
void BuffFadeBySitModifier();
void BuffModifyDurationBySpellID(int spell_id, int new_duration);
int CanBuffStack(int spell_id, int caster_level, bool fail_if_overwrite);
bool IsCasting();
int CastingSpellID();
void SetAppearance(int app);
void SetAppearance(int app, bool ignore_self);
int GetAppearance();
int GetPetID();
int GetOwnerID();
void SetPetType(int type);
int GetPetType();
int GetBodyType();
void SetBodyType(int type);
void Stun(int duration);
void UnStun();
void Spin();
void Kill();
void SetInvul(bool invul);
bool GetInvul();
void SetExtraHaste(int haste);
int GetHaste();
int GetMonkHandToHandDamage();
int GetMonkHandToHandDelay();
bool CanThisClassDoubleAttack();
bool CanThisClassDualWield();
bool CanThisClassRiposte();
bool CanThisClassDodge();
bool CanThisClassParry();
bool CanThisClassBlock();
int GetClassLevelFactor();
void Mesmerize();
bool IsMezzed();
bool IsStunned();
void StartEnrage();
bool IsEnraged();
int GetReverseFactionCon(Lua_Mob other);
bool IsAIControlled();
double GetAggroRange();
double GetAssistRange();
void SetPetOrder(int order);
int GetPetOrder();
bool IsRoamer();
bool IsRooted();
void AddToHateList(Lua_Mob other);
void AddToHateList(Lua_Mob other, int hate);
void AddToHateList(Lua_Mob other, int hate, int damage);
void AddToHateList(Lua_Mob other, int hate, int damage, bool yell_for_help);
void AddToHateList(Lua_Mob other, int hate, int damage, bool yell_for_help, bool frenzy);
void AddToHateList(Lua_Mob other, int hate, int damage, bool yell_for_help, bool frenzy, bool buff_tic);
bool RemoveFromHateList(Lua_Mob mob);
void SetHate(Lua_Mob other);
void SetHate(Lua_Mob other, int hate);
void SetHate(Lua_Mob other, int hate, int damage);
uint32 GetHateAmount(Lua_Mob tmob);
uint32 GetHateAmount(Lua_Mob tmob, bool is_damage);
uint32 GetDamageAmount(Lua_Mob tmob);
Lua_Mob GetHateTop();
Lua_Mob GetHateDamageTop(Lua_Mob other);
Lua_Mob GetHateRandom();
Lua_Mob GetHateMost();
bool IsEngaged();
bool HateSummon();
void FaceTarget();
void FaceTarget(Lua_Mob mob_to_face);
void SetHeading(double new_h);
void WipeHateList();
double CalculateHeadingToTarget(double x, double y);
double CalculateDistance(double x, double y, double z);
void SendTo(double new_x, double new_y, double new_z);
void SendToFixZ(double new_x, double new_y, double new_z);
void NPCSpecialAttacks(const char* parse, int permtag);
void NPCSpecialAttacks(const char* parse, int permtag, bool reset);
void NPCSpecialAttacks(const char* parse, int permtag, bool reset, bool remove);
int GetResist(int type);
bool Charmed();
uint32 GetLevelHP(int level);
uint32 GetAA(int level);
int CheckAggroAmount(int spell_id);
int CheckAggroAmount(int spell_id, bool is_proc);
int CheckHealAggroAmount(int spell_id);
int CheckHealAggroAmount(int spell_id, uint32 heal_possible);
bool DivineAura();
void SetOOCRegen(int new_regen);
const char* GetEntityVariable(const char *id);
void SetEntityVariable(const char *id, const char *m_var);
bool EntityVariableExists(const char *id);
bool CombatRange(Lua_Mob other);
void DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage);
void DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage, int hate_override);
void DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage, int hate_override, int reuse_time);
void DoSpecialAttackDamage(Lua_Mob who, int skill, int max_damage, int min_damage, int hate_override, int reuse_time, bool hit_chance);
void DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse);
void DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse, int chance_mod);
void DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse, int chance_mod, int focus);
void DoMeleeSkillAttackDmg(Lua_Mob other, int weapon_damage, int skillinuse, int chance_mod, int focus, bool can_riposte);
bool CheckLoS(Lua_Mob other); // make sure this is CheckLoSFN
bool CheckLoSToLoc(double x, double y, double z);
bool CheckLoSToLoc(double x, double y, double z, double mob_size);
double FindGroundZ(double new_x, double new_y);
double FindGroundZ(double new_x, double new_y, double z_offset);
void ProjectileAnimation(Lua_Mob to, int item_id);
void ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow);
void ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed);
void ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed, double angle);
void ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed, double angle, double tilt);
void ProjectileAnimation(Lua_Mob to, int item_id, bool is_arrow, double speed, double angle, double tilt, double arc);
bool HasNPCSpecialAtk(const char* parse);
void SendAppearanceEffect(uint32 parm1, uint32 parm2, uint32 parm3, uint32 parm4, uint32 parm5);
void SendAppearanceEffect(uint32 parm1, uint32 parm2, uint32 parm3, uint32 parm4, uint32 parm5, Lua_Client client);
void SetFlyMode(int value);
void SetTexture(int value);
void SetRace(int value);
void SetGender(int value);
void SendIllusionPacket(int in_race, int in_gender, int in_texture, int in_helmtexture, int in_haircolor, int in_beardcolor,
int in_eyecolor1, int in_eyecolor2, int in_hairstyle, int in_luclinface, int in_beard, int in_aa_title,
uint32 in_drakkin_heritage, uint32 in_drakkin_tattoo, uint32 in_drakkin_details, double in_size);
void QuestReward(Lua_Client c);
void QuestReward(Lua_Client c, uint32 silver);
void QuestReward(Lua_Client c, uint32 silver, uint32 gold);
void QuestReward(Lua_Client c, uint32 silver, uint32 gold, uint32 platinum);
void CameraEffect(uint32 duration, uint32 intensity);
void SendSpellEffect(uint32 effect, uint32 duration, uint32 finish_delay, bool zone_wide, uint32 unk20, bool perm_effect,
Lua_Client client);
void TempName(const char *new_name);
void SetGlobal(const char *var_name, const char *new_value, int options, const char *duration);
void SetGlobal(const char *var_name, const char *new_value, int options, const char *duration, Lua_Mob other);
void TarGlobal(const char *var_name, const char *value, const char *duration, int npc_id, int char_id, int zone_id);
void DelGlobal(const char *var_name);
void SetSlotTint(int slot, int red, int green, int blue);
void WearChange(int material_slot, int texture, uint32 color);
void DoKnockback(Lua_Mob caster, uint32 pushback, uint32 pushup);
void RemoveNimbusEffect(int effect_id);
bool IsRunning();
void SetRunning(bool v);
void SetTargetable(bool v);
void ModSkillDmgTaken(int skill_num, int value);
int GetModSkillDmgTaken(int skill_num);
int GetSkillDmgTaken(int skill_num);
void SetAllowBeneficial(bool v);
bool GetAllowBeneficial();
bool IsBeneficialAllowed(Lua_Mob target);
void ModVulnerability(int resist, int value);
int GetModVulnerability(int resist);
void SetDisableMelee(bool v);
bool IsMeleeDisabled();
void SetFlurryChance(int v);
int GetFlurryChance();
*/
//GetHateList - Requires classes not yet exported
//SignalClient - Gonna do this differently
//DoArcheryAttackDmg - Requires classes not yet exported
//DoThrowingAttackDmg - Requires classes not yet exported
};
#endif

View File

@ -12,6 +12,14 @@ public:
Lua_NPC() { d_ = nullptr; }
Lua_NPC(NPC *d) { d_ = d; }
virtual ~Lua_NPC() { }
operator NPC* () {
if(d_) {
return reinterpret_cast<NPC*>(d_);
}
return nullptr;
}
};
#endif

View File

@ -83,23 +83,23 @@ LuaParser::~LuaParser() {
ClearStates();
}
double LuaParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
int LuaParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
if(evt >= _LargestEventID) {
return 100.0;
return 0;
}
if(!npc) {
return 100.0;
return 0;
}
if(evt != EVENT_SPAWN && evt != EVENT_SAY) {
return 100.0;
return 0;
}
const char *sub_name = LuaEvents[evt];
if(!HasQuestSub(npc->GetNPCTypeID(), sub_name)) {
return 100.0;
return 0;
}
std::stringstream package_name;
@ -108,7 +108,7 @@ double LuaParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string da
lua_State *L = nullptr;
auto iter = states_.find(package_name.str());
if(iter == states_.end()) {
return 100.0;
return 0;
}
L = iter->second;
@ -136,40 +136,40 @@ double LuaParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string da
if(lua_pcall(L, arg_count, ret_count, 0)) {
printf("Error: %s\n", lua_tostring(L, -1));
return 100.0;
return 0;
}
if(lua_isnumber(L, -1)) {
double ret = lua_tonumber(L, -1);
int ret = static_cast<int>(lua_tointeger(L, -1));
return ret;
}
} catch(std::exception &ex) {
printf("%s\n", ex.what());
return 100.0;
return 0;
}
return 100.0;
return 0;
}
double LuaParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
return 100.0;
int LuaParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data) {
return 0;
}
double LuaParser::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
return 100.0;
int LuaParser::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
return 0;
}
double LuaParser::EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
return 100.0;
int LuaParser::EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
return 0;
}
double LuaParser::EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) {
return 100.0;
int LuaParser::EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data) {
return 0;
}
double LuaParser::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) {
return 100.0;
int LuaParser::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) {
return 00;
}
bool LuaParser::HasQuestSub(uint32 npc_id, const char *subname) {
@ -343,7 +343,8 @@ void LuaParser::MapFunctions(lua_State *L) {
[
luabind::class_<Lua_Entity>("Entity")
.def(luabind::constructor<>())
.def("NullPtr", &Lua_Entity::NullPtr)
.property("null", &Lua_Entity::Null)
.property("valid", &Lua_Entity::Valid)
.def("IsClient", &Lua_Entity::IsClient)
.def("IsNPC", &Lua_Entity::IsNPC)
.def("IsMob", &Lua_Entity::IsMob)

View File

@ -17,12 +17,12 @@ public:
LuaParser();
~LuaParser();
virtual double EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
virtual double EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
virtual double EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
virtual double EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
virtual double EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data);
virtual double EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data);
virtual int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
virtual int EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data);
virtual int EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
virtual int EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data);
virtual int EventItem(QuestEventID evt, Client *client, ItemInst *item, uint32 objid, uint32 extra_data);
virtual int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data);
virtual bool HasQuestSub(uint32 npc_id, const char *subname);
virtual bool HasGlobalQuestSub(const char *subname);

View File

@ -693,38 +693,38 @@ public:
void ProcessFlee();
void CheckFlee();
inline bool CheckAggro(Mob* other) {return hate_list.IsOnHateList(other);}
float CalculateHeadingToTarget(float in_x, float in_y);
bool CalculateNewPosition(float x, float y, float z, float speed, bool checkZ = false);
virtual bool CalculateNewPosition2(float x, float y, float z, float speed, bool checkZ = true);
float CalculateDistance(float x, float y, float z);
float GetGroundZ(float new_x, float new_y, float z_offset=0.0);
void SendTo(float new_x, float new_y, float new_z);
void SendToFixZ(float new_x, float new_y, float new_z);
void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false);
inline uint32 DontHealMeBefore() const { return pDontHealMeBefore; }
inline uint32 DontBuffMeBefore() const { return pDontBuffMeBefore; }
inline uint32 DontDotMeBefore() const { return pDontDotMeBefore; }
inline uint32 DontRootMeBefore() const { return pDontRootMeBefore; }
inline uint32 DontSnareMeBefore() const { return pDontSnareMeBefore; }
inline uint32 DontCureMeBefore() const { return pDontCureMeBefore; }
void SetDontRootMeBefore(uint32 time) { pDontRootMeBefore = time; }
void SetDontHealMeBefore(uint32 time) { pDontHealMeBefore = time; }
void SetDontBuffMeBefore(uint32 time) { pDontBuffMeBefore = time; }
void SetDontDotMeBefore(uint32 time) { pDontDotMeBefore = time; }
void SetDontSnareMeBefore(uint32 time) { pDontSnareMeBefore = time; }
void SetDontCureMeBefore(uint32 time) { pDontCureMeBefore = time; }
inline bool CheckAggro(Mob* other) {return hate_list.IsOnHateList(other);}
float CalculateHeadingToTarget(float in_x, float in_y);
bool CalculateNewPosition(float x, float y, float z, float speed, bool checkZ = false);
virtual bool CalculateNewPosition2(float x, float y, float z, float speed, bool checkZ = true);
float CalculateDistance(float x, float y, float z);
float GetGroundZ(float new_x, float new_y, float z_offset=0.0);
void SendTo(float new_x, float new_y, float new_z);
void SendToFixZ(float new_x, float new_y, float new_z);
void NPCSpecialAttacks(const char* parse, int permtag, bool reset = true, bool remove = false);
inline uint32 DontHealMeBefore() const { return pDontHealMeBefore; }
inline uint32 DontBuffMeBefore() const { return pDontBuffMeBefore; }
inline uint32 DontDotMeBefore() const { return pDontDotMeBefore; }
inline uint32 DontRootMeBefore() const { return pDontRootMeBefore; }
inline uint32 DontSnareMeBefore() const { return pDontSnareMeBefore; }
inline uint32 DontCureMeBefore() const { return pDontCureMeBefore; }
void SetDontRootMeBefore(uint32 time) { pDontRootMeBefore = time; }
void SetDontHealMeBefore(uint32 time) { pDontHealMeBefore = time; }
void SetDontBuffMeBefore(uint32 time) { pDontBuffMeBefore = time; }
void SetDontDotMeBefore(uint32 time) { pDontDotMeBefore = time; }
void SetDontSnareMeBefore(uint32 time) { pDontSnareMeBefore = time; }
void SetDontCureMeBefore(uint32 time) { pDontCureMeBefore = time; }
// calculate interruption of spell via movement of mob
void SaveSpellLoc() {spell_x = x_pos; spell_y = y_pos; spell_z = z_pos; }
inline float GetSpellX() const {return spell_x;}
inline float GetSpellY() const {return spell_y;}
inline float GetSpellZ() const {return spell_z;}
inline bool IsGrouped() const { return isgrouped; }
inline bool IsGrouped() const { return isgrouped; }
void SetGrouped(bool v);
inline bool IsRaidGrouped() const { return israidgrouped; }
void SetRaidGrouped(bool v);
inline bool IsLooting() const { return islooting; }
inline bool IsLooting() const { return islooting; }
void SetLooting(bool val) { islooting = val; }
bool CheckWillAggro(Mob *mob);

View File

@ -25,27 +25,6 @@
Pet(NPCType *type_data, Mob *owner, PetType type, uint16 spell_id, int16 power);
};
/*
* I dont have the patience to take on this project today....
class Pet : public NPC {
public:
enum eStandingPetOrder { SPO_Follow, SPO_Sit, SPO_Guard };
const uint16 pet_spell_id;
inline void SetPetOrder(eStandingPetOrder i) { pStandingPetOrder = i; }
inline eStandingPetOrder GetPetOrder() const { return pStandingPetOrder; }
// void SetPetType(uint16 in_type) { typeofpet = in_type; } // put this here because only NPCs can be anything but charmed pets
void GetPetState(SpellBuff_Struct *buffs, uint32 *items, char *name);
void SetPetState(SpellBuff_Struct *buffs, uint32 *items);
protected:
// uint16 typeofpet; // 0xFF = charmed
eStandingPetOrder pStandingPetOrder;
bool taunting;
Timer taunt_timer; //for pet taunting
};*/
#endif