Many fixes to regressions in perl and cleaning up the final interface

This commit is contained in:
KimLS 2013-06-12 15:04:26 -07:00
parent 56b41c882b
commit c0d37b2e04
32 changed files with 438 additions and 635 deletions

View File

@ -2,7 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
SET(common_sources SET(common_sources
BasePacket.cpp BasePacket.cpp
callback_manager.cpp
classes.cpp classes.cpp
Condition.cpp Condition.cpp
crash.cpp crash.cpp
@ -94,7 +93,6 @@ SET(common_headers
BasePacket.h BasePacket.h
bodytypes.h bodytypes.h
breakdowns.h breakdowns.h
callback_manager.h
classes.h classes.h
common_profile.h common_profile.h
Condition.h Condition.h

View File

@ -65,7 +65,6 @@ ItemInst::ItemInst(const Item_Struct* item, int16 charges) {
m_color = 0; m_color = 0;
m_merchantcount = 1; m_merchantcount = 1;
m_SerialNumber = GetNextItemInstSerialNumber(); m_SerialNumber = GetNextItemInstSerialNumber();
m_on_destroy = GetEQCallback("OnItemInstDestroy");
} }
ItemInst::ItemInst(SharedDatabase *db, uint32 item_id, int16 charges) { ItemInst::ItemInst(SharedDatabase *db, uint32 item_id, int16 charges) {
@ -81,7 +80,6 @@ ItemInst::ItemInst(SharedDatabase *db, uint32 item_id, int16 charges) {
m_color = 0; m_color = 0;
m_merchantcount = 1; m_merchantcount = 1;
m_SerialNumber = GetNextItemInstSerialNumber(); m_SerialNumber = GetNextItemInstSerialNumber();
m_on_destroy = GetEQCallback("OnItemInstDestroy");
} }
ItemInstQueue::~ItemInstQueue() { ItemInstQueue::~ItemInstQueue() {
@ -172,16 +170,12 @@ ItemInst::ItemInst(const ItemInst& copy)
} }
m_SerialNumber = copy.m_SerialNumber; m_SerialNumber = copy.m_SerialNumber;
m_custom_data = copy.m_custom_data; m_custom_data = copy.m_custom_data;
m_on_destroy = copy.m_on_destroy; m_timers = copy.m_timers;
} }
// Clean up container contents // Clean up container contents
ItemInst::~ItemInst() ItemInst::~ItemInst()
{ {
if(m_on_destroy) {
m_on_destroy(this);
}
Clear(); Clear();
} }
@ -1685,7 +1679,7 @@ EvoItemInst::EvoItemInst(const EvoItemInst &copy) {
else else
m_scaledItem = nullptr; m_scaledItem = nullptr;
m_on_destroy = GetEQCallback("OnItemInstDestroy"); m_timers = copy.m_timers;
} }
EvoItemInst::EvoItemInst(const ItemInst &basecopy) { EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
@ -1725,7 +1719,7 @@ EvoItemInst::EvoItemInst(const ItemInst &basecopy) {
m_activated = false; m_activated = false;
m_evolveInfo = nullptr; m_evolveInfo = nullptr;
m_scaledItem = nullptr; m_scaledItem = nullptr;
m_on_destroy = copy->m_on_destroy; m_timers = copy->m_timers;
} }
EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) { EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) {
@ -1746,13 +1740,9 @@ EvoItemInst::EvoItemInst(const Item_Struct* item, int16 charges) {
m_activated = false; m_activated = false;
m_evolveInfo = nullptr; m_evolveInfo = nullptr;
m_scaledItem = nullptr; m_scaledItem = nullptr;
m_on_destroy = GetEQCallback("OnItemInstDestroy");
} }
EvoItemInst::~EvoItemInst() { EvoItemInst::~EvoItemInst() {
if(m_on_destroy) {
m_on_destroy(this);
}
safe_delete(m_scaledItem); safe_delete(m_scaledItem);
} }

View File

@ -37,7 +37,7 @@ class EvolveInfo; // Stores information about an evolving item family
#include "../common/eq_packet_structs.h" #include "../common/eq_packet_structs.h"
#include "../common/eq_constants.h" #include "../common/eq_constants.h"
#include "../common/item_struct.h" #include "../common/item_struct.h"
#include "callback_manager.h" #include "../common/timer.h"
// Helper typedefs // Helper typedefs
typedef std::list<ItemInst*>::const_iterator iter_queue; typedef std::list<ItemInst*>::const_iterator iter_queue;
@ -266,8 +266,6 @@ public:
m_instnodrop = false; m_instnodrop = false;
m_merchantslot = 0; m_merchantslot = 0;
m_color = 0; m_color = 0;
m_on_destroy = GetEQCallback("OnItemInstDestroy");
} }
ItemInst(const ItemInst& copy); ItemInst(const ItemInst& copy);
@ -381,6 +379,8 @@ public:
inline int32 GetSerialNumber() const { return m_SerialNumber; } inline int32 GetSerialNumber() const { return m_SerialNumber; }
inline void SetSerialNumber(int32 id) { m_SerialNumber = id; } inline void SetSerialNumber(int32 id) { m_SerialNumber = id; }
std::map<std::string, Timer>& GetTimers() { return m_timers; }
protected: protected:
////////////////////////// //////////////////////////
// Protected Members // Protected Members
@ -407,7 +407,7 @@ protected:
// Items inside of this item (augs or contents); // Items inside of this item (augs or contents);
std::map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9 std::map<uint8, ItemInst*> m_contents; // Zero-based index: min=0, max=9
std::map<std::string, std::string> m_custom_data; std::map<std::string, std::string> m_custom_data;
eqemu_callback m_on_destroy; std::map<std::string, Timer> m_timers;
}; };
class EvoItemInst: public ItemInst { class EvoItemInst: public ItemInst {

View File

@ -1,17 +0,0 @@
#include <map>
#include "callback_manager.h"
std::map<std::string, eqemu_callback> callback_functions;
void RegisterEQCallback(std::string name, eqemu_callback func) {
callback_functions[name] = func;
}
eqemu_callback GetEQCallback(std::string name) {
auto iter = callback_functions.find(name);
if(iter == callback_functions.end()) {
return nullptr;
}
return iter->second;
}

View File

@ -1,12 +0,0 @@
#ifndef EQEMU_CALLBACK_MANAGER_H
#define EQEMU_CALLBACK_MANAGER_H
#include <string>
#include <functional>
typedef std::function<void(void*)> eqemu_callback;
void RegisterEQCallback(std::string name, eqemu_callback func);
eqemu_callback GetEQCallback(std::string name);
#endif

View File

@ -30,6 +30,14 @@
uint32 current_time = 0; uint32 current_time = 0;
uint32 last_time = 0; uint32 last_time = 0;
Timer::Timer() {
timer_time = 0;
start_time = current_time;
set_at_trigger = timer_time;
pUseAcurateTiming = false;
enabled = false;
}
Timer::Timer(uint32 in_timer_time, bool iUseAcurateTiming) { Timer::Timer(uint32 in_timer_time, bool iUseAcurateTiming) {
timer_time = in_timer_time; timer_time = in_timer_time;
start_time = current_time; start_time = current_time;

View File

@ -29,6 +29,7 @@
class Timer class Timer
{ {
public: public:
Timer();
Timer(uint32 timer_time, bool iUseAcurateTiming = false); Timer(uint32 timer_time, bool iUseAcurateTiming = false);
Timer(uint32 start, uint32 timer, bool iUseAcurateTiming); Timer(uint32 start, uint32 timer, bool iUseAcurateTiming);
~Timer() { } ~Timer() { }
@ -62,9 +63,6 @@ private:
// Instead of Check() setting the start_time = now, // Instead of Check() setting the start_time = now,
// it it sets it to start_time += timer_time // it it sets it to start_time += timer_time
bool pUseAcurateTiming; bool pUseAcurateTiming;
// static uint32 current_time;
// static uint32 last_time;
}; };
#endif #endif

View File

@ -38,12 +38,13 @@ public:
virtual int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) { return 0; } virtual int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) { return 0; }
virtual int EventEncounter(QuestEventID evt, std::string encounter_name, uint32 extra_data) { return 0; } virtual int EventEncounter(QuestEventID evt, std::string encounter_name, uint32 extra_data) { return 0; }
virtual bool HasQuestSub(uint32 npcid, const char *subname) { return false; } virtual bool HasQuestSub(uint32 npcid, QuestEventID evt) { return false; }
virtual bool HasGlobalQuestSub(const char *subname) { return false; } virtual bool HasGlobalQuestSub(QuestEventID evt) { return false; }
virtual bool PlayerHasQuestSub(const char *subname) { return false; } virtual bool PlayerHasQuestSub(QuestEventID evt) { return false; }
virtual bool GlobalPlayerHasQuestSub(const char *subname) { return false; } virtual bool GlobalPlayerHasQuestSub(QuestEventID evt) { return false; }
virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname) { return false; } virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt) { return false; }
virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname) { return false; } virtual bool ItemHasQuestSub(ItemInst *itm, QuestEventID evt) { return false; }
virtual bool EncounterHasQuestSub(std::string encounter_name, QuestEventID evt) { return false; }
virtual void LoadNPCScript(std::string filename, int npc_id) { } virtual void LoadNPCScript(std::string filename, int npc_id) { }
virtual void LoadGlobalNPCScript(std::string filename) { } virtual void LoadGlobalNPCScript(std::string filename) { }

View File

@ -80,18 +80,18 @@ void QuestParserCollection::ReloadQuests(bool reset_timers) {
} }
} }
bool QuestParserCollection::HasQuestSub(uint32 npcid, const char *subname) { bool QuestParserCollection::HasQuestSub(uint32 npcid, QuestEventID evt) {
return HasQuestSubLocal(npcid, subname) || HasQuestSubGlobal(subname); return HasQuestSubLocal(npcid, evt) || HasQuestSubGlobal(evt);
} }
bool QuestParserCollection::HasQuestSubLocal(uint32 npcid, const char *subname) { bool QuestParserCollection::HasQuestSubLocal(uint32 npcid, QuestEventID evt) {
std::map<uint32, uint32>::iterator iter = _npc_quest_status.find(npcid); std::map<uint32, uint32>::iterator iter = _npc_quest_status.find(npcid);
if(iter != _npc_quest_status.end()) { if(iter != _npc_quest_status.end()) {
//loaded or failed to load //loaded or failed to load
if(iter->second != QuestFailedToLoad) { if(iter->second != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(iter->second); std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(iter->second);
if(qiter->second->HasQuestSub(npcid, subname)) { if(qiter->second->HasQuestSub(npcid, evt)) {
return true; return true;
} }
} }
@ -102,7 +102,7 @@ bool QuestParserCollection::HasQuestSubLocal(uint32 npcid, const char *subname)
_npc_quest_status[npcid] = qi->GetIdentifier(); _npc_quest_status[npcid] = qi->GetIdentifier();
qi->LoadNPCScript(filename, npcid); qi->LoadNPCScript(filename, npcid);
if(qi->HasQuestSub(npcid, subname)) { if(qi->HasQuestSub(npcid, evt)) {
return true; return true;
} }
} else { } else {
@ -112,21 +112,21 @@ bool QuestParserCollection::HasQuestSubLocal(uint32 npcid, const char *subname)
return false; return false;
} }
bool QuestParserCollection::HasQuestSubGlobal(const char *subname) { bool QuestParserCollection::HasQuestSubGlobal(QuestEventID evt) {
if(_global_npc_quest_status == QuestUnloaded) { if(_global_npc_quest_status == QuestUnloaded) {
std::string filename; std::string filename;
QuestInterface *qi = GetQIByGlobalNPCQuest(filename); QuestInterface *qi = GetQIByGlobalNPCQuest(filename);
if(qi) { if(qi) {
qi->LoadGlobalNPCScript(filename); qi->LoadGlobalNPCScript(filename);
_global_npc_quest_status = qi->GetIdentifier(); _global_npc_quest_status = qi->GetIdentifier();
if(qi->HasGlobalQuestSub(subname)) { if(qi->HasGlobalQuestSub(evt)) {
return true; return true;
} }
} }
} else { } else {
if(_global_npc_quest_status != QuestFailedToLoad) { if(_global_npc_quest_status != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(_global_npc_quest_status); std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(_global_npc_quest_status);
if(qiter->second->HasGlobalQuestSub(subname)) { if(qiter->second->HasGlobalQuestSub(evt)) {
return true; return true;
} }
} }
@ -134,49 +134,49 @@ bool QuestParserCollection::HasQuestSubGlobal(const char *subname) {
return false; return false;
} }
bool QuestParserCollection::PlayerHasQuestSub(const char *subname) { bool QuestParserCollection::PlayerHasQuestSub(QuestEventID evt) {
return PlayerHasQuestSubLocal(subname) || PlayerHasQuestSubGlobal(subname); return PlayerHasQuestSubLocal(evt) || PlayerHasQuestSubGlobal(evt);
} }
bool QuestParserCollection::PlayerHasQuestSubLocal(const char *subname) { bool QuestParserCollection::PlayerHasQuestSubLocal(QuestEventID evt) {
if(_player_quest_status == QuestUnloaded) { if(_player_quest_status == QuestUnloaded) {
std::string filename; std::string filename;
QuestInterface *qi = GetQIByPlayerQuest(filename); QuestInterface *qi = GetQIByPlayerQuest(filename);
if(qi) { if(qi) {
_player_quest_status = qi->GetIdentifier(); _player_quest_status = qi->GetIdentifier();
qi->LoadPlayerScript(filename); qi->LoadPlayerScript(filename);
return qi->PlayerHasQuestSub(subname); return qi->PlayerHasQuestSub(evt);
} }
} else if(_player_quest_status != QuestFailedToLoad) { } else if(_player_quest_status != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator iter = _interfaces.find(_player_quest_status); std::map<uint32, QuestInterface*>::iterator iter = _interfaces.find(_player_quest_status);
return iter->second->PlayerHasQuestSub(subname); return iter->second->PlayerHasQuestSub(evt);
} }
return false; return false;
} }
bool QuestParserCollection::PlayerHasQuestSubGlobal(const char *subname) { bool QuestParserCollection::PlayerHasQuestSubGlobal(QuestEventID evt) {
if(_global_player_quest_status == QuestUnloaded) { if(_global_player_quest_status == QuestUnloaded) {
std::string filename; std::string filename;
QuestInterface *qi = GetQIByPlayerQuest(filename); QuestInterface *qi = GetQIByPlayerQuest(filename);
if(qi) { if(qi) {
_global_player_quest_status = qi->GetIdentifier(); _global_player_quest_status = qi->GetIdentifier();
qi->LoadPlayerScript(filename); qi->LoadPlayerScript(filename);
return qi->GlobalPlayerHasQuestSub(subname); return qi->GlobalPlayerHasQuestSub(evt);
} }
} else if(_global_player_quest_status != QuestFailedToLoad) { } else if(_global_player_quest_status != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator iter = _interfaces.find(_global_player_quest_status); std::map<uint32, QuestInterface*>::iterator iter = _interfaces.find(_global_player_quest_status);
return iter->second->GlobalPlayerHasQuestSub(subname); return iter->second->GlobalPlayerHasQuestSub(evt);
} }
return false; return false;
} }
bool QuestParserCollection::SpellHasQuestSub(uint32 spell_id, const char *subname) { bool QuestParserCollection::SpellHasQuestSub(uint32 spell_id, QuestEventID evt) {
std::map<uint32, uint32>::iterator iter = _spell_quest_status.find(spell_id); std::map<uint32, uint32>::iterator iter = _spell_quest_status.find(spell_id);
if(iter != _spell_quest_status.end()) { if(iter != _spell_quest_status.end()) {
//loaded or failed to load //loaded or failed to load
if(iter->second != QuestFailedToLoad) { if(iter->second != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(iter->second); std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(iter->second);
return qiter->second->SpellHasQuestSub(spell_id, subname); return qiter->second->SpellHasQuestSub(spell_id, evt);
} }
} else { } else {
std::string filename; std::string filename;
@ -184,7 +184,7 @@ bool QuestParserCollection::SpellHasQuestSub(uint32 spell_id, const char *subnam
if(qi) { if(qi) {
_spell_quest_status[spell_id] = qi->GetIdentifier(); _spell_quest_status[spell_id] = qi->GetIdentifier();
qi->LoadSpellScript(filename, spell_id); qi->LoadSpellScript(filename, spell_id);
return qi->SpellHasQuestSub(spell_id, subname); return qi->SpellHasQuestSub(spell_id, evt);
} else { } else {
_spell_quest_status[spell_id] = QuestFailedToLoad; _spell_quest_status[spell_id] = QuestFailedToLoad;
} }
@ -192,7 +192,7 @@ bool QuestParserCollection::SpellHasQuestSub(uint32 spell_id, const char *subnam
return false; return false;
} }
bool QuestParserCollection::ItemHasQuestSub(ItemInst *itm, const char *subname) { bool QuestParserCollection::ItemHasQuestSub(ItemInst *itm, QuestEventID evt) {
std::string item_script; std::string item_script;
if(itm->GetItem()->ScriptFileID != 0) { if(itm->GetItem()->ScriptFileID != 0) {
item_script = "script_"; item_script = "script_";
@ -209,7 +209,7 @@ bool QuestParserCollection::ItemHasQuestSub(ItemInst *itm, const char *subname)
//loaded or failed to load //loaded or failed to load
if(iter->second != QuestFailedToLoad) { if(iter->second != QuestFailedToLoad) {
std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(iter->second); std::map<uint32, QuestInterface*>::iterator qiter = _interfaces.find(iter->second);
return qiter->second->ItemHasQuestSub(itm, subname); return qiter->second->ItemHasQuestSub(itm, evt);
} }
} else { } else {
std::string filename; std::string filename;
@ -217,7 +217,7 @@ bool QuestParserCollection::ItemHasQuestSub(ItemInst *itm, const char *subname)
if(qi) { if(qi) {
_item_quest_status[item_id] = qi->GetIdentifier(); _item_quest_status[item_id] = qi->GetIdentifier();
qi->LoadItemScript(filename, itm); qi->LoadItemScript(filename, itm);
return qi->ItemHasQuestSub(itm, subname); return qi->ItemHasQuestSub(itm, evt);
} else { } else {
_item_quest_status[item_id] = QuestFailedToLoad; _item_quest_status[item_id] = QuestFailedToLoad;
} }
@ -646,7 +646,7 @@ QuestInterface *QuestParserCollection::GetQIByPlayerQuest(std::string &filename)
} }
QuestInterface *QuestParserCollection::GetQIByGlobalNPCQuest(std::string &filename) { QuestInterface *QuestParserCollection::GetQIByGlobalNPCQuest(std::string &filename) {
// simply look for quests/global/global_npc.pl // simply look for /quests/global/global_npc.ext
filename = "quests/"; filename = "quests/";
filename += QUEST_GLOBAL_DIRECTORY; filename += QUEST_GLOBAL_DIRECTORY;
filename += "/"; filename += "/";

View File

@ -44,10 +44,10 @@ public:
void Init(); void Init();
void ReloadQuests(bool reset_timers = true); void ReloadQuests(bool reset_timers = true);
bool HasQuestSub(uint32 npcid, const char *subname); bool HasQuestSub(uint32 npcid, QuestEventID evt);
bool PlayerHasQuestSub(const char *subname); bool PlayerHasQuestSub(QuestEventID evt);
bool SpellHasQuestSub(uint32 spell_id, const char *subname); bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt);
bool ItemHasQuestSub(ItemInst *itm, const char *subname); bool ItemHasQuestSub(ItemInst *itm, QuestEventID evt);
int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, int EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
std::vector<ItemInst*> *items = nullptr); std::vector<ItemInst*> *items = nullptr);
@ -59,10 +59,10 @@ public:
void GetErrors(std::list<std::string> &err); void GetErrors(std::list<std::string> &err);
private: private:
bool HasQuestSubLocal(uint32 npcid, const char *subname); bool HasQuestSubLocal(uint32 npcid, QuestEventID evt);
bool HasQuestSubGlobal(const char *subname); bool HasQuestSubGlobal(QuestEventID evt);
bool PlayerHasQuestSubLocal(const char *subname); bool PlayerHasQuestSubLocal(QuestEventID evt);
bool PlayerHasQuestSubGlobal(const char *subname); bool PlayerHasQuestSubGlobal(QuestEventID evt);
int EventNPCLocal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, std::vector<ItemInst*> *items); int EventNPCLocal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, std::vector<ItemInst*> *items);
int EventNPCGlobal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, std::vector<ItemInst*> *items); int EventNPCGlobal(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, std::vector<ItemInst*> *items);

View File

@ -918,7 +918,7 @@ int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item, uint32 *hate
dmg = weapon_item->GetItem()->Damage; dmg = weapon_item->GetItem()->Damage;
} }
for(int x = 0; x < 5; x++){ for(int x = 0; x < MAX_AUGMENT_SLOTS; x++){
if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){ if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){
dmg += weapon_item->GetAugment(x)->GetItem()->Damage; dmg += weapon_item->GetAugment(x)->GetItem()->Damage;
if (hate) *hate += weapon_item->GetAugment(x)->GetItem()->Damage + weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt; if (hate) *hate += weapon_item->GetAugment(x)->GetItem()->Damage + weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt;
@ -955,7 +955,7 @@ int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item, uint32 *hate
dmg = weapon_item->GetItem()->Damage; dmg = weapon_item->GetItem()->Damage;
} }
for(int x = 0; x < 5; x++){ for(int x = 0; x < MAX_AUGMENT_SLOTS; x++){
if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){ if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){
dmg += weapon_item->GetAugment(x)->GetItem()->Damage; dmg += weapon_item->GetAugment(x)->GetItem()->Damage;
if (hate) *hate += weapon_item->GetAugment(x)->GetItem()->Damage + weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt; if (hate) *hate += weapon_item->GetAugment(x)->GetItem()->Damage + weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt;
@ -992,7 +992,7 @@ int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item, uint32 *hate
} }
if(weapon_item){ if(weapon_item){
for(int x = 0; x < 5; x++){ for(int x = 0; x < MAX_AUGMENT_SLOTS; x++){
if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){ if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){
if(weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt) if(weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt)
eledmg += (weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt * against->ResistSpell(weapon_item->GetAugment(x)->GetItem()->ElemDmgType, 0, this) / 100); eledmg += (weapon_item->GetAugment(x)->GetItem()->ElemDmgAmt * against->ResistSpell(weapon_item->GetAugment(x)->GetItem()->ElemDmgType, 0, this) / 100);
@ -1021,7 +1021,7 @@ int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item, uint32 *hate
} }
} }
for(int x = 0; x < 5; x++){ for(int x = 0; x < MAX_AUGMENT_SLOTS; x++){
if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){ if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){
if(weapon_item->GetAugment(x)->GetItem()->BaneDmgBody == against->GetBodyType()){ if(weapon_item->GetAugment(x)->GetItem()->BaneDmgBody == against->GetBodyType()){
banedmg += weapon_item->GetAugment(x)->GetItem()->BaneDmgAmt; banedmg += weapon_item->GetAugment(x)->GetItem()->BaneDmgAmt;
@ -1066,7 +1066,7 @@ int Mob::GetWeaponDamage(Mob *against, const ItemInst *weapon_item, uint32 *hate
} }
} }
for(int x = 0; x < 5; x++){ for(int x = 0; x < MAX_AUGMENT_SLOTS; x++){
if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){ if(weapon_item->GetAugment(x) && weapon_item->GetAugment(x)->GetItem()){
if(weapon_item->GetAugment(x)->GetItem()->BaneDmgBody == against->GetBodyType()){ if(weapon_item->GetAugment(x)->GetItem()->BaneDmgBody == against->GetBodyType()){
banedmg += weapon_item->GetAugment(x)->GetItem()->BaneDmgAmt; banedmg += weapon_item->GetAugment(x)->GetItem()->BaneDmgAmt;
@ -2020,7 +2020,7 @@ bool NPC::Death(Mob* killerMob, int32 damage, uint16 spell, SkillType attack_ski
Mob *oos = nullptr; Mob *oos = nullptr;
if(killerMob) { if(killerMob) {
Mob *oos = killerMob->GetOwnerOrSelf(); oos = killerMob->GetOwnerOrSelf();
char buffer[32] = { 0 }; char buffer[32] = { 0 };
snprintf(buffer, 31, "%d %d %d", damage, spell, static_cast<int>(attack_skill)); snprintf(buffer, 31, "%d %d %d", damage, spell, static_cast<int>(attack_skill));

View File

@ -2398,26 +2398,26 @@ void NPC::CalcItemBonuses(StatBonuses *newbon)
} }
} }
void Client::CalcItemScale(bool login) void Client::CalcItemScale()
{ {
bool changed = false; bool changed = false;
if(CalcItemScale(0, 21, login)) if(CalcItemScale(0, 21))
changed = true; changed = true;
if(CalcItemScale(22, 30, login)) if(CalcItemScale(22, 30))
changed = true; changed = true;
if(CalcItemScale(251, 341, login)) if(CalcItemScale(251, 341))
changed = true; changed = true;
if(CalcItemScale(400, 405, login)) if(CalcItemScale(400, 405))
changed = true; changed = true;
//Power Source Slot //Power Source Slot
if (GetClientVersion() >= EQClientSoF) if (GetClientVersion() >= EQClientSoF)
{ {
if(CalcItemScale(9999, 10000, login)) if(CalcItemScale(9999, 10000))
changed = true; changed = true;
} }
@ -2427,7 +2427,7 @@ void Client::CalcItemScale(bool login)
} }
} }
bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y, bool login) bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y)
{ {
bool changed = false; bool changed = false;
int i; int i;
@ -2442,9 +2442,9 @@ bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y, bool login)
EvoItemInst* e_inst = (EvoItemInst*)inst; EvoItemInst* e_inst = (EvoItemInst*)inst;
uint16 oldexp = e_inst->GetExp(); uint16 oldexp = e_inst->GetExp();
if(login) { //if(login) {
parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, e_inst, nullptr, "", 0); // parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, e_inst, nullptr, "", 0);
} //}
parse->EventItem(EVENT_SCALE_CALC, this, e_inst, nullptr, "", 0); parse->EventItem(EVENT_SCALE_CALC, this, e_inst, nullptr, "", 0);
if (e_inst->GetExp() != oldexp) { // if the scaling factor changed, rescale the item and update the client if (e_inst->GetExp() != oldexp) { // if the scaling factor changed, rescale the item and update the client
@ -2466,9 +2466,9 @@ bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y, bool login)
EvoItemInst* e_inst = (EvoItemInst*)a_inst; EvoItemInst* e_inst = (EvoItemInst*)a_inst;
uint16 oldexp = e_inst->GetExp(); uint16 oldexp = e_inst->GetExp();
if(login) { //if(login) {
parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, e_inst, nullptr, "", 0); // parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, e_inst, nullptr, "", 0);
} //}
parse->EventItem(EVENT_SCALE_CALC, this, e_inst, nullptr, "", 0); parse->EventItem(EVENT_SCALE_CALC, this, e_inst, nullptr, "", 0);
if (e_inst->GetExp() != oldexp) if (e_inst->GetExp() != oldexp)
@ -2488,6 +2488,91 @@ bool Client::CalcItemScale(uint32 slot_x, uint32 slot_y, bool login)
return changed; return changed;
} }
void Client::DoItemEnterZone() {
bool changed = false;
if(DoItemEnterZone(0, 21))
changed = true;
if(DoItemEnterZone(22, 30))
changed = true;
if(DoItemEnterZone(251, 341))
changed = true;
if(DoItemEnterZone(400, 405))
changed = true;
//Power Source Slot
if (GetClientVersion() >= EQClientSoF)
{
if(DoItemEnterZone(9999, 10000))
changed = true;
}
if(changed)
{
CalcBonuses();
}
}
bool Client::DoItemEnterZone(uint32 slot_x, uint32 slot_y) {
bool changed = false;
for(int i = slot_x; i < slot_y; i++) {
ItemInst* inst = m_inv.GetItem(i);
if(inst == 0)
continue;
bool update_slot = false;
if(inst->IsScaling())
{
EvoItemInst* e_inst = (EvoItemInst*)inst;
uint16 oldexp = e_inst->GetExp();
parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, e_inst, nullptr, "", 0);
if (e_inst->GetExp() != oldexp) { // if the scaling factor changed, rescale the item and update the client
e_inst->ScaleItem();
changed = true;
update_slot = true;
}
} else {
parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, inst, nullptr, "", 0);
}
//iterate all augments
for(int x = 0; x < MAX_AUGMENT_SLOTS; ++x)
{
ItemInst *a_inst = inst->GetAugment(x);
if(!a_inst)
continue;
if(a_inst->IsScaling())
{
EvoItemInst* e_inst = (EvoItemInst*)a_inst;
uint16 oldexp = e_inst->GetExp();
parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, e_inst, nullptr, "", 0);
if (e_inst->GetExp() != oldexp)
{
e_inst->ScaleItem();
changed = true;
update_slot = true;
}
} else {
parse->EventItem(EVENT_ITEM_ENTER_ZONE, this, a_inst, nullptr, "", 0);
}
}
if(update_slot)
{
SendItemPacket(i, inst, ItemPacketCharmUpdate);
}
}
return changed;
}
uint8 Mob::IsFocusEffect(uint16 spell_id,int effect_index, bool AA,uint32 aa_effect) uint8 Mob::IsFocusEffect(uint16 spell_id,int effect_index, bool AA,uint32 aa_effect)
{ {
uint16 effect = 0; uint16 effect = 0;

View File

@ -1029,14 +1029,14 @@ void Client::ChannelMessageReceived(uint8 chan_num, uint8 language, uint8 lang_s
case 8: { // /say case 8: { // /say
if(message[0] == COMMAND_CHAR) { if(message[0] == COMMAND_CHAR) {
if(command_dispatch(this, message) == -2) { if(command_dispatch(this, message) == -2) {
//if(parse->PlayerHasQuestSub("EVENT_COMMAND")) { if(parse->PlayerHasQuestSub(EVENT_COMMAND)) {
// int i = parse->EventPlayer(EVENT_COMMAND, this, message, 0); int i = parse->EventPlayer(EVENT_COMMAND, this, message, 0);
// if(i != 0) { if(i != 0) {
// Message(13, "Command '%s' not recognized.", message); Message(13, "Command '%s' not recognized.", message);
// } }
//} else { } else {
Message(13, "Command '%s' not recognized.", message); Message(13, "Command '%s' not recognized.", message);
//} }
} }
break; break;
} }
@ -4737,7 +4737,7 @@ void Client::ShowSkillsWindow()
if(GetSkill(it->second) > 0 || MaxSkill(it->second) > 0) { if(GetSkill(it->second) > 0 || MaxSkill(it->second) > 0) {
WindowText += it->first; WindowText += it->first;
// line up the values // line up the values
for (int j = 0; j < 5; j++) for (int j = 0; j < MAX_AUGMENT_SLOTS; j++)
WindowText += "&nbsp;"; WindowText += "&nbsp;";
WindowText += itoa(this->GetSkill(it->second)); WindowText += itoa(this->GetSkill(it->second));
if (MaxSkill(it->second) > 0) { if (MaxSkill(it->second) > 0) {

View File

@ -1013,8 +1013,10 @@ public:
void MarkSingleCompassLoc(float in_x, float in_y, float in_z, uint8 count=1); void MarkSingleCompassLoc(float in_x, float in_y, float in_z, uint8 count=1);
void CalcItemScale(bool login = false); void CalcItemScale();
bool CalcItemScale(uint32 slot_x, uint32 slot_y, bool login = false); bool CalcItemScale(uint32 slot_x, uint32 slot_y);
void DoItemEnterZone();
bool DoItemEnterZone(uint32 slot_x, uint32 slot_y);
void SummonAndRezzAllCorpses(); void SummonAndRezzAllCorpses();
void SummonAllCorpses(float dest_x, float dest_y, float dest_z, float dest_heading); void SummonAllCorpses(float dest_x, float dest_y, float dest_z, float dest_heading);
void DepopAllCorpses(); void DepopAllCorpses();

View File

@ -9642,7 +9642,8 @@ void Client::CompleteConnect()
SendAltCurrencies(); SendAltCurrencies();
database.LoadAltCurrencyValues(CharacterID(), alternate_currency); database.LoadAltCurrencyValues(CharacterID(), alternate_currency);
SendAlternateCurrencyValues(); SendAlternateCurrencyValues();
CalcItemScale(true); CalcItemScale();
DoItemEnterZone();
if(zone->GetZoneID() == RuleI(World, GuildBankZoneID) && GuildBanks) if(zone->GetZoneID() == RuleI(World, GuildBankZoneID) && GuildBanks)
GuildBanks->SendGuildBank(this); GuildBanks->SendGuildBank(this);

View File

@ -786,11 +786,7 @@ void Client::OnDisconnect(bool hard_disconnect) {
if (MyRaid) if (MyRaid)
MyRaid->MemberZoned(this); MyRaid->MemberZoned(this);
if(this->IsClient()){ parse->EventPlayer(EVENT_DISCONNECT, this, "", 0);
if(parse->PlayerHasQuestSub("EVENT_DISCONNECT")) {
parse->EventPlayer(EVENT_DISCONNECT, this, "", 0);
}
}
} }
Mob *Other = trade->With(); Mob *Other = trade->With();

View File

@ -35,7 +35,7 @@ extern Zone* zone;
const char *QuestEventSubroutines[_LargestEventID] = { const char *QuestEventSubroutines[_LargestEventID] = {
"EVENT_SAY", "EVENT_SAY",
"EVENT_TRADE", "EVENT_ITEM",
"EVENT_DEATH", "EVENT_DEATH",
"EVENT_SPAWN", "EVENT_SPAWN",
"EVENT_ATTACK", "EVENT_ATTACK",
@ -50,21 +50,21 @@ const char *QuestEventSubroutines[_LargestEventID] = {
"EVENT_HP", "EVENT_HP",
"EVENT_ENTER", "EVENT_ENTER",
"EVENT_EXIT", "EVENT_EXIT",
"EVENT_ENTER_ZONE", "EVENT_ENTERZONE",
"EVENT_CLICK_DOOR", "EVENT_CLICKDOOR",
"EVENT_LOOT", "EVENT_LOOT",
"EVENT_ZONE", "EVENT_ZONE",
"EVENT_LEVEL_UP", "EVENT_LEVEL_UP",
"EVENT_KILLED_MERIT", "EVENT_KILLED_MERIT",
"EVENT_CAST_ON", "EVENT_CAST_ON",
"EVENT_TASK_ACCEPTED", "EVENT_TASKACCEPTED",
"EVENT_TASK_STAGE_COMPLETE", "EVENT_TASK_STAGE_COMPLETE",
"EVENT_TASK_UPDATE", "EVENT_TASK_UPDATE",
"EVENT_TASK_COMPLETE", "EVENT_TASK_COMPLETE",
"EVENT_TASK_FAIL", "EVENT_TASK_FAIL",
"EVENT_AGGRO_SAY", "EVENT_AGGRO_SAY",
"EVENT_PLAYER_PICKUP", "EVENT_PLAYER_PICKUP",
"EVENT_POPUP_RESPONSE", "EVENT_POPUPRESPONSE",
"EVENT_PROXIMITY_SAY", "EVENT_PROXIMITY_SAY",
"EVENT_CAST", "EVENT_CAST",
"EVENT_CAST_BEGIN", "EVENT_CAST_BEGIN",
@ -72,8 +72,10 @@ const char *QuestEventSubroutines[_LargestEventID] = {
"EVENT_ITEM_ENTER_ZONE", "EVENT_ITEM_ENTER_ZONE",
"EVENT_TARGET_CHANGE", "EVENT_TARGET_CHANGE",
"EVENT_HATE_LIST", "EVENT_HATE_LIST",
"EVENT_SPELL_EFFECT", "EVENT_SPELL_EFFECT_CLIENT",
"EVENT_SPELL_BUFF_TIC", "EVENT_SPELL_EFFECT_NPC",
"EVENT_SPELL_EFFECT_BUFF_TIC_CLIENT",
"EVENT_SPELL_EFFECT_BUFF_TIC_NPC",
"EVENT_SPELL_FADE", "EVENT_SPELL_FADE",
"EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE", "EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE",
"EVENT_COMBINE_SUCCESS", "EVENT_COMBINE_SUCCESS",
@ -95,7 +97,7 @@ const char *QuestEventSubroutines[_LargestEventID] = {
"EVENT_DUEL_LOSE", "EVENT_DUEL_LOSE",
"EVENT_ENCOUNTER_LOAD", "EVENT_ENCOUNTER_LOAD",
"EVENT_ENCOUNTER_UNLOAD", "EVENT_ENCOUNTER_UNLOAD",
"EVENT_COMMAND", "EVENT_SAY",
"EVENT_DROP_ITEM", "EVENT_DROP_ITEM",
"EVENT_DESTROY_ITEM", "EVENT_DESTROY_ITEM",
"EVENT_FEIGN_DEATH" "EVENT_FEIGN_DEATH"
@ -235,13 +237,18 @@ int PerlembParser::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32
return 0; return 0;
} }
bool PerlembParser::HasQuestSub(uint32 npcid, const char *subname) { bool PerlembParser::HasQuestSub(uint32 npcid, QuestEventID evt) {
std::stringstream package_name; std::stringstream package_name;
package_name << "qst_npc_" << npcid; package_name << "qst_npc_" << npcid;
if(!perl) if(!perl)
return false; return false;
if(evt >= _LargestEventID)
return false;
const char *subname = QuestEventSubroutines[evt];
auto iter = npc_quest_status_.find(npcid); auto iter = npc_quest_status_.find(npcid);
if(iter == npc_quest_status_.end() || iter->second == QuestFailedToLoad) { if(iter == npc_quest_status_.end() || iter->second == QuestFailedToLoad) {
return false; return false;
@ -250,7 +257,7 @@ bool PerlembParser::HasQuestSub(uint32 npcid, const char *subname) {
return(perl->SubExists(package_name.str().c_str(), subname)); return(perl->SubExists(package_name.str().c_str(), subname));
} }
bool PerlembParser::HasGlobalQuestSub(const char *subname) { bool PerlembParser::HasGlobalQuestSub(QuestEventID evt) {
if(!perl) if(!perl)
return false; return false;
@ -258,10 +265,15 @@ bool PerlembParser::HasGlobalQuestSub(const char *subname) {
return false; return false;
} }
if(evt >= _LargestEventID)
return false;
const char *subname = QuestEventSubroutines[evt];
return(perl->SubExists("qst_global_npc", subname)); return(perl->SubExists("qst_global_npc", subname));
} }
bool PerlembParser::PlayerHasQuestSub(const char *subname) { bool PerlembParser::PlayerHasQuestSub(QuestEventID evt) {
if(!perl) if(!perl)
return false; return false;
@ -269,10 +281,15 @@ bool PerlembParser::PlayerHasQuestSub(const char *subname) {
return false; return false;
} }
if(evt >= _LargestEventID)
return false;
const char *subname = QuestEventSubroutines[evt];
return(perl->SubExists("qst_player", subname)); return(perl->SubExists("qst_player", subname));
} }
bool PerlembParser::GlobalPlayerHasQuestSub(const char *subname) { bool PerlembParser::GlobalPlayerHasQuestSub(QuestEventID evt) {
if(!perl) if(!perl)
return false; return false;
@ -280,10 +297,15 @@ bool PerlembParser::GlobalPlayerHasQuestSub(const char *subname) {
return false; return false;
} }
if(evt >= _LargestEventID)
return false;
const char *subname = QuestEventSubroutines[evt];
return(perl->SubExists("qst_global_player", subname)); return(perl->SubExists("qst_global_player", subname));
} }
bool PerlembParser::SpellHasQuestSub(uint32 spell_id, const char *subname) { bool PerlembParser::SpellHasQuestSub(uint32 spell_id, QuestEventID evt) {
std::stringstream package_name; std::stringstream package_name;
package_name << "qst_spell_" << spell_id; package_name << "qst_spell_" << spell_id;
@ -295,16 +317,26 @@ bool PerlembParser::SpellHasQuestSub(uint32 spell_id, const char *subname) {
return false; return false;
} }
if(evt >= _LargestEventID)
return false;
const char *subname = QuestEventSubroutines[evt];
return(perl->SubExists(package_name.str().c_str(), subname)); return(perl->SubExists(package_name.str().c_str(), subname));
} }
bool PerlembParser::ItemHasQuestSub(ItemInst *itm, const char *subname) { bool PerlembParser::ItemHasQuestSub(ItemInst *itm, QuestEventID evt) {
std::stringstream package_name; std::stringstream package_name;
package_name << "qst_item_" << itm->GetID(); package_name << "qst_item_" << itm->GetID();
if(!perl) if(!perl)
return false; return false;
if(evt >= _LargestEventID)
return false;
const char *subname = QuestEventSubroutines[evt];
auto iter = item_quest_status_.find(itm->GetID()); auto iter = item_quest_status_.find(itm->GetID());
if(iter == item_quest_status_.end() || iter->second == QuestFailedToLoad) { if(iter == item_quest_status_.end() || iter->second == QuestFailedToLoad) {
return false; return false;
@ -753,8 +785,10 @@ void PerlembParser::AddQueueEvent(QuestEventID event, uint32 objid, const char *
void PerlembParser::GetQuestTypes(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest, void PerlembParser::GetQuestTypes(bool &isPlayerQuest, bool &isGlobalPlayerQuest, bool &isGlobalNPC, bool &isItemQuest,
bool &isSpellQuest, QuestEventID event, NPC* npcmob, ItemInst* iteminst, Mob* mob, bool global) bool &isSpellQuest, QuestEventID event, NPC* npcmob, ItemInst* iteminst, Mob* mob, bool global)
{ {
if(event == EVENT_SPELL_EFFECT || if(event == EVENT_SPELL_EFFECT_CLIENT ||
event == EVENT_SPELL_BUFF_TIC || event == EVENT_SPELL_EFFECT_NPC ||
event == EVENT_SPELL_BUFF_TIC_CLIENT ||
event == EVENT_SPELL_BUFF_TIC_NPC ||
event == EVENT_SPELL_FADE || event == EVENT_SPELL_FADE ||
event == EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE) event == EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE)
{ {
@ -1252,8 +1286,10 @@ void PerlembParser::ExportEventVariables(std::string &package_name, QuestEventID
break; break;
} }
case EVENT_SPELL_EFFECT: case EVENT_SPELL_EFFECT_CLIENT:
case EVENT_SPELL_BUFF_TIC: case EVENT_SPELL_EFFECT_NPC:
case EVENT_SPELL_BUFF_TIC_CLIENT:
case EVENT_SPELL_BUFF_TIC_NPC:
{ {
ExportVar(package_name.c_str(), "caster_id", extradata); ExportVar(package_name.c_str(), "caster_id", extradata);
break; break;
@ -1289,7 +1325,9 @@ void PerlembParser::ExportEventVariables(std::string &package_name, QuestEventID
} }
case EVENT_COMMAND: { case EVENT_COMMAND: {
ExportVar(package_name.c_str(), "message", data); ExportVar(package_name.c_str(), "text", data);
ExportVar(package_name.c_str(), "data", "0");
ExportVar(package_name.c_str(), "langid", "0");
break; break;
} }

View File

@ -65,12 +65,12 @@ public:
virtual int EventItem(QuestEventID evt, Client *client, ItemInst *item, Mob *mob, std::string data, uint32 extra_data); virtual int EventItem(QuestEventID evt, Client *client, ItemInst *item, Mob *mob, std::string data, uint32 extra_data);
virtual int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, 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 HasQuestSub(uint32 npcid, QuestEventID evt);
virtual bool HasGlobalQuestSub(const char *subname); virtual bool HasGlobalQuestSub(QuestEventID evt);
virtual bool PlayerHasQuestSub(const char *subname); virtual bool PlayerHasQuestSub(QuestEventID evt);
virtual bool GlobalPlayerHasQuestSub(const char *subname); virtual bool GlobalPlayerHasQuestSub(QuestEventID evt);
virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname); virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt);
virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname); virtual bool ItemHasQuestSub(ItemInst *itm, QuestEventID evt);
virtual void LoadNPCScript(std::string filename, int npc_id); virtual void LoadNPCScript(std::string filename, int npc_id);
virtual void LoadGlobalNPCScript(std::string filename); virtual void LoadGlobalNPCScript(std::string filename);

View File

@ -40,8 +40,10 @@ typedef enum {
EVENT_ITEM_ENTER_ZONE, EVENT_ITEM_ENTER_ZONE,
EVENT_TARGET_CHANGE, //target selected, target changed, or target removed EVENT_TARGET_CHANGE, //target selected, target changed, or target removed
EVENT_HATE_LIST, EVENT_HATE_LIST,
EVENT_SPELL_EFFECT, EVENT_SPELL_EFFECT_CLIENT,
EVENT_SPELL_BUFF_TIC, EVENT_SPELL_EFFECT_NPC,
EVENT_SPELL_BUFF_TIC_CLIENT,
EVENT_SPELL_BUFF_TIC_NPC,
EVENT_SPELL_FADE, EVENT_SPELL_FADE,
EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE, EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE,
EVENT_COMBINE_SUCCESS, //PC successfully combined a recipe EVENT_COMBINE_SUCCESS, //PC successfully combined a recipe

View File

@ -333,7 +333,6 @@ void Client::DropItem(int16 slot_id)
int i = parse->EventItem(EVENT_DROP_ITEM, this, inst, nullptr, "", 0); int i = parse->EventItem(EVENT_DROP_ITEM, this, inst, nullptr, "", 0);
if(i != 0) { if(i != 0) {
safe_delete(inst); safe_delete(inst);
return;
} }
} else { } else {
// Item doesn't exist in inventory! // Item doesn't exist in inventory!
@ -349,6 +348,9 @@ void Client::DropItem(int16 slot_id)
database.SaveInventory(CharacterID(), nullptr, slot_id); database.SaveInventory(CharacterID(), nullptr, slot_id);
} }
if(!inst)
return;
// Package as zone object // Package as zone object
Object* object = new Object(this, inst); Object* object = new Object(this, inst);
entity_list.AddObject(object, true); entity_list.AddObject(object, true);

View File

@ -1211,7 +1211,7 @@ luabind::scope lua_register_client() {
.def("GetAAExp", (uint32(Lua_Client::*)(void))&Lua_Client::GetAAExp) .def("GetAAExp", (uint32(Lua_Client::*)(void))&Lua_Client::GetAAExp)
.def("GetTotalSecondsPlayed", (uint32(Lua_Client::*)(void))&Lua_Client::GetTotalSecondsPlayed) .def("GetTotalSecondsPlayed", (uint32(Lua_Client::*)(void))&Lua_Client::GetTotalSecondsPlayed)
.def("UpdateLDoNPoints", (void(Lua_Client::*)(int,uint32))&Lua_Client::UpdateLDoNPoints) .def("UpdateLDoNPoints", (void(Lua_Client::*)(int,uint32))&Lua_Client::UpdateLDoNPoints)
.def("SetDeity", (void(Lua_Client::*)(int v))&Lua_Client::SetDeity) .def("SetDeity", (void(Lua_Client::*)(int))&Lua_Client::SetDeity)
.def("AddEXP", (void(Lua_Client::*)(uint32))&Lua_Client::AddEXP) .def("AddEXP", (void(Lua_Client::*)(uint32))&Lua_Client::AddEXP)
.def("AddEXP", (void(Lua_Client::*)(uint32,int))&Lua_Client::AddEXP) .def("AddEXP", (void(Lua_Client::*)(uint32,int))&Lua_Client::AddEXP)
.def("AddEXP", (void(Lua_Client::*)(uint32,int,bool))&Lua_Client::AddEXP) .def("AddEXP", (void(Lua_Client::*)(uint32,int,bool))&Lua_Client::AddEXP)

View File

@ -939,11 +939,8 @@ luabind::scope lua_register_events() {
luabind::value("trade", static_cast<int>(EVENT_TRADE)), luabind::value("trade", static_cast<int>(EVENT_TRADE)),
luabind::value("death", static_cast<int>(EVENT_DEATH)), luabind::value("death", static_cast<int>(EVENT_DEATH)),
luabind::value("spawn", static_cast<int>(EVENT_SPAWN)), luabind::value("spawn", static_cast<int>(EVENT_SPAWN)),
luabind::value("attack", static_cast<int>(EVENT_ATTACK)),
luabind::value("combat", static_cast<int>(EVENT_COMBAT)), luabind::value("combat", static_cast<int>(EVENT_COMBAT)),
luabind::value("aggro", static_cast<int>(EVENT_AGGRO)),
luabind::value("slay", static_cast<int>(EVENT_SLAY)), luabind::value("slay", static_cast<int>(EVENT_SLAY)),
luabind::value("npc_slay", static_cast<int>(EVENT_NPC_SLAY)),
luabind::value("waypoint_arrive", static_cast<int>(EVENT_WAYPOINT_ARRIVE)), luabind::value("waypoint_arrive", static_cast<int>(EVENT_WAYPOINT_ARRIVE)),
luabind::value("waypoint_depart", static_cast<int>(EVENT_WAYPOINT_DEPART)), luabind::value("waypoint_depart", static_cast<int>(EVENT_WAYPOINT_DEPART)),
luabind::value("timer", static_cast<int>(EVENT_TIMER)), luabind::value("timer", static_cast<int>(EVENT_TIMER)),
@ -972,8 +969,8 @@ luabind::scope lua_register_events() {
luabind::value("item_enter_zone", static_cast<int>(EVENT_ITEM_ENTER_ZONE)), luabind::value("item_enter_zone", static_cast<int>(EVENT_ITEM_ENTER_ZONE)),
luabind::value("target_change", static_cast<int>(EVENT_TARGET_CHANGE)), luabind::value("target_change", static_cast<int>(EVENT_TARGET_CHANGE)),
luabind::value("hate_list", static_cast<int>(EVENT_HATE_LIST)), luabind::value("hate_list", static_cast<int>(EVENT_HATE_LIST)),
luabind::value("spell_effect", static_cast<int>(EVENT_SPELL_EFFECT)), luabind::value("spell_effect", static_cast<int>(EVENT_SPELL_EFFECT_CLIENT)),
luabind::value("spell_buff_tic", static_cast<int>(EVENT_SPELL_BUFF_TIC)), luabind::value("spell_buff_tic", static_cast<int>(EVENT_SPELL_BUFF_TIC_CLIENT)),
luabind::value("spell_fade", static_cast<int>(EVENT_SPELL_FADE)), luabind::value("spell_fade", static_cast<int>(EVENT_SPELL_FADE)),
luabind::value("spell_effect_translocate_complete", static_cast<int>(EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE)), luabind::value("spell_effect_translocate_complete", static_cast<int>(EVENT_SPELL_EFFECT_TRANSLOCATE_COMPLETE)),
luabind::value("combine_success ", static_cast<int>(EVENT_COMBINE_SUCCESS )), luabind::value("combine_success ", static_cast<int>(EVENT_COMBINE_SUCCESS )),

View File

@ -178,7 +178,6 @@ public:
Lua_Mob GetPet(); Lua_Mob GetPet();
Lua_Mob GetOwner(); Lua_Mob GetOwner();
Lua_HateList GetHateList(); Lua_HateList GetHateList();
Lua_Mob GetHateTop(); Lua_Mob GetHateTop();
Lua_Mob GetHateDamageTop(Lua_Mob other); Lua_Mob GetHateDamageTop(Lua_Mob other);
Lua_Mob GetHateRandom(); Lua_Mob GetHateRandom();

View File

@ -6,7 +6,7 @@
#include <ctype.h> #include <ctype.h>
#include <stdio.h> #include <stdio.h>
#include <sstream> #include <string>
#include <vector> #include <vector>
#include <algorithm> #include <algorithm>
@ -71,6 +71,8 @@ const char *LuaEvents[_LargestEventID] = {
"event_target_change", "event_target_change",
"event_hate_list", "event_hate_list",
"event_spell_effect", "event_spell_effect",
"event_spell_effect",
"event_spell_buff_tic",
"event_spell_buff_tic", "event_spell_buff_tic",
"event_spell_fade", "event_spell_fade",
"event_spell_effect_translocate_complete", "event_spell_effect_translocate_complete",
@ -122,16 +124,13 @@ LuaParser::LuaParser() {
NPCArgumentDispatch[EVENT_PROXIMITY_SAY] = handle_npc_event_say; NPCArgumentDispatch[EVENT_PROXIMITY_SAY] = handle_npc_event_say;
NPCArgumentDispatch[EVENT_TRADE] = handle_npc_event_trade; NPCArgumentDispatch[EVENT_TRADE] = handle_npc_event_trade;
NPCArgumentDispatch[EVENT_HP] = handle_npc_event_hp; NPCArgumentDispatch[EVENT_HP] = handle_npc_event_hp;
NPCArgumentDispatch[EVENT_ATTACK] = handle_npc_single_mob;
NPCArgumentDispatch[EVENT_AGGRO] = handle_npc_single_mob;
NPCArgumentDispatch[EVENT_TARGET_CHANGE] = handle_npc_single_mob; NPCArgumentDispatch[EVENT_TARGET_CHANGE] = handle_npc_single_mob;
NPCArgumentDispatch[EVENT_CAST_ON] = handle_npc_single_mob; NPCArgumentDispatch[EVENT_CAST_ON] = handle_npc_cast;
NPCArgumentDispatch[EVENT_KILLED_MERIT] = handle_npc_single_client; NPCArgumentDispatch[EVENT_KILLED_MERIT] = handle_npc_single_client;
NPCArgumentDispatch[EVENT_SLAY] = handle_npc_single_client; NPCArgumentDispatch[EVENT_SLAY] = handle_npc_single_mob;
NPCArgumentDispatch[EVENT_ENTER] = handle_npc_single_client; NPCArgumentDispatch[EVENT_ENTER] = handle_npc_single_client;
NPCArgumentDispatch[EVENT_EXIT] = handle_npc_single_client; NPCArgumentDispatch[EVENT_EXIT] = handle_npc_single_client;
NPCArgumentDispatch[EVENT_TASK_ACCEPTED] = handle_npc_single_client; NPCArgumentDispatch[EVENT_TASK_ACCEPTED] = handle_npc_single_client;
NPCArgumentDispatch[EVENT_NPC_SLAY] = handle_npc_single_npc;
NPCArgumentDispatch[EVENT_POPUP_RESPONSE] = handle_npc_popup; NPCArgumentDispatch[EVENT_POPUP_RESPONSE] = handle_npc_popup;
NPCArgumentDispatch[EVENT_WAYPOINT_ARRIVE] = handle_npc_waypoint; NPCArgumentDispatch[EVENT_WAYPOINT_ARRIVE] = handle_npc_waypoint;
NPCArgumentDispatch[EVENT_WAYPOINT_DEPART] = handle_npc_waypoint; NPCArgumentDispatch[EVENT_WAYPOINT_DEPART] = handle_npc_waypoint;
@ -142,6 +141,7 @@ LuaParser::LuaParser() {
NPCArgumentDispatch[EVENT_DEATH] = handle_npc_death; NPCArgumentDispatch[EVENT_DEATH] = handle_npc_death;
NPCArgumentDispatch[EVENT_CAST] = handle_npc_cast; NPCArgumentDispatch[EVENT_CAST] = handle_npc_cast;
NPCArgumentDispatch[EVENT_CAST_BEGIN] = handle_npc_cast; NPCArgumentDispatch[EVENT_CAST_BEGIN] = handle_npc_cast;
NPCArgumentDispatch[EVENT_FEIGN_DEATH] = handle_npc_single_client;
PlayerArgumentDispatch[EVENT_SAY] = handle_player_say; PlayerArgumentDispatch[EVENT_SAY] = handle_player_say;
PlayerArgumentDispatch[EVENT_DEATH] = handle_player_death; PlayerArgumentDispatch[EVENT_DEATH] = handle_player_death;
@ -168,8 +168,8 @@ LuaParser::LuaParser() {
ItemArgumentDispatch[EVENT_ITEM_CLICK] = handle_item_click; ItemArgumentDispatch[EVENT_ITEM_CLICK] = handle_item_click;
ItemArgumentDispatch[EVENT_ITEM_CLICK_CAST] = handle_item_click; ItemArgumentDispatch[EVENT_ITEM_CLICK_CAST] = handle_item_click;
SpellArgumentDispatch[EVENT_SPELL_EFFECT] = handle_spell_effect; SpellArgumentDispatch[EVENT_SPELL_EFFECT_CLIENT] = handle_spell_effect;
SpellArgumentDispatch[EVENT_SPELL_BUFF_TIC] = handle_spell_effect; SpellArgumentDispatch[EVENT_SPELL_BUFF_TIC_CLIENT] = handle_spell_effect;
SpellArgumentDispatch[EVENT_SPELL_FADE] = handle_spell_fade; SpellArgumentDispatch[EVENT_SPELL_FADE] = handle_spell_fade;
L = nullptr; L = nullptr;
@ -183,6 +183,7 @@ LuaParser::~LuaParser() {
int 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,
std::vector<ItemInst*> *items) { std::vector<ItemInst*> *items) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) { if(evt >= _LargestEventID) {
return 0; return 0;
} }
@ -191,18 +192,17 @@ int LuaParser::EventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data,
return 0; return 0;
} }
if(!HasQuestSub(npc->GetNPCTypeID(), LuaEvents[evt])) { if(!HasQuestSub(npc->GetNPCTypeID(), evt)) {
return 0; return 0;
} }
std::stringstream package_name; std::string package_name = "npc_" + std::to_string(npc->GetNPCTypeID());
package_name << "npc_" << npc->GetNPCTypeID(); return _EventNPC(package_name, evt, npc, init, data, extra_data, items);
return _EventNPC(package_name.str(), evt, npc, init, data, extra_data, items);
} }
int LuaParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, int LuaParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
std::vector<ItemInst*> *items) { std::vector<ItemInst*> *items) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) { if(evt >= _LargestEventID) {
return 0; return 0;
} }
@ -211,7 +211,7 @@ int LuaParser::EventGlobalNPC(QuestEventID evt, NPC* npc, Mob *init, std::string
return 0; return 0;
} }
if(!HasGlobalQuestSub(LuaEvents[evt])) { if(!HasGlobalQuestSub(evt)) {
return 0; return 0;
} }
@ -278,6 +278,7 @@ int LuaParser::_EventNPC(std::string package_name, QuestEventID evt, NPC* npc, M
} }
int LuaParser::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { int LuaParser::EventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) { if(evt >= _LargestEventID) {
return 0; return 0;
} }
@ -286,7 +287,7 @@ int LuaParser::EventPlayer(QuestEventID evt, Client *client, std::string data, u
return 0; return 0;
} }
if(!PlayerHasQuestSub(LuaEvents[evt])) { if(!PlayerHasQuestSub(evt)) {
return 0; return 0;
} }
@ -294,6 +295,7 @@ int LuaParser::EventPlayer(QuestEventID evt, Client *client, std::string data, u
} }
int LuaParser::EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { int LuaParser::EventGlobalPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) { if(evt >= _LargestEventID) {
return 0; return 0;
} }
@ -302,7 +304,7 @@ int LuaParser::EventGlobalPlayer(QuestEventID evt, Client *client, std::string d
return 0; return 0;
} }
if(!GlobalPlayerHasQuestSub(LuaEvents[evt])) { if(!GlobalPlayerHasQuestSub(evt)) {
return 0; return 0;
} }
@ -334,7 +336,7 @@ int LuaParser::_EventPlayer(std::string package_name, QuestEventID evt, Client *
auto arg_function = PlayerArgumentDispatch[evt]; auto arg_function = PlayerArgumentDispatch[evt];
arg_function(this, L, client, data, extra_data); arg_function(this, L, client, data, extra_data);
quest_manager.StartQuest(nullptr, client, nullptr); quest_manager.StartQuest(client, client, nullptr);
if(lua_pcall(L, 1, 1, 0)) { if(lua_pcall(L, 1, 1, 0)) {
std::string error = lua_tostring(L, -1); std::string error = lua_tostring(L, -1);
AddError(error); AddError(error);
@ -367,6 +369,7 @@ int LuaParser::_EventPlayer(std::string package_name, QuestEventID evt, Client *
} }
int LuaParser::EventItem(QuestEventID evt, Client *client, ItemInst *item, Mob *mob, std::string data, uint32 extra_data) { int LuaParser::EventItem(QuestEventID evt, Client *client, ItemInst *item, Mob *mob, std::string data, uint32 extra_data) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) { if(evt >= _LargestEventID) {
return 0; return 0;
} }
@ -375,7 +378,7 @@ int LuaParser::EventItem(QuestEventID evt, Client *client, ItemInst *item, Mob *
return 0; return 0;
} }
if(!ItemHasQuestSub(item, LuaEvents[evt])) { if(!ItemHasQuestSub(item, evt)) {
return 0; return 0;
} }
@ -415,7 +418,7 @@ int LuaParser::_EventItem(std::string package_name, QuestEventID evt, Client *cl
auto arg_function = ItemArgumentDispatch[evt]; auto arg_function = ItemArgumentDispatch[evt];
arg_function(this, L, client, item, 0, extra_data); arg_function(this, L, client, item, 0, extra_data);
quest_manager.StartQuest(nullptr, client, item); quest_manager.StartQuest(client, client, item);
if(lua_pcall(L, 1, 1, 0)) { if(lua_pcall(L, 1, 1, 0)) {
std::string error = lua_tostring(L, -1); std::string error = lua_tostring(L, -1);
AddError(error); AddError(error);
@ -448,18 +451,18 @@ int LuaParser::_EventItem(std::string package_name, QuestEventID evt, Client *cl
} }
int LuaParser::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) { int LuaParser::EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) { if(evt >= _LargestEventID) {
return 0; return 0;
} }
std::stringstream package_name; std::string package_name = "spell_" + std::to_string(spell_id);
package_name << "spell_" << spell_id;
if(!SpellHasQuestSub(spell_id, LuaEvents[evt])) { if(!SpellHasQuestSub(spell_id, evt)) {
return 0; return 0;
} }
return _EventSpell(package_name.str(), evt, npc, client, spell_id, extra_data); return _EventSpell(package_name, evt, npc, client, spell_id, extra_data);
} }
int LuaParser::_EventSpell(std::string package_name, QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data, int LuaParser::_EventSpell(std::string package_name, QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data,
@ -528,13 +531,14 @@ int LuaParser::_EventSpell(std::string package_name, QuestEventID evt, NPC* npc,
} }
int LuaParser::EventEncounter(QuestEventID evt, std::string encounter_name, uint32 extra_data) { int LuaParser::EventEncounter(QuestEventID evt, std::string encounter_name, uint32 extra_data) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) { if(evt >= _LargestEventID) {
return 0; return 0;
} }
std::string package_name = "encounter_" + encounter_name; std::string package_name = "encounter_" + encounter_name;
if(!EncounterHasQuestSub(encounter_name, LuaEvents[evt])) { if(!EncounterHasQuestSub(encounter_name, evt)) {
return 0; return 0;
} }
@ -586,50 +590,89 @@ int LuaParser::_EventEncounter(std::string package_name, QuestEventID evt, std::
return 0; return 0;
} }
bool LuaParser::HasQuestSub(uint32 npc_id, const char *subname) { bool LuaParser::HasQuestSub(uint32 npc_id, QuestEventID evt) {
std::stringstream package_name; evt = ConvertLuaEvent(evt);
package_name << "npc_" << npc_id; if(evt >= _LargestEventID) {
return false;
}
return HasFunction(subname, package_name.str()); std::string package_name = "npc_" + std::to_string(npc_id);
}
bool LuaParser::HasGlobalQuestSub(const char *subname) {
return HasFunction(subname, "global_npc");
}
bool LuaParser::PlayerHasQuestSub(const char *subname) {
return HasFunction(subname, "player");
}
bool LuaParser::GlobalPlayerHasQuestSub(const char *subname) {
return HasFunction(subname, "global_player");
}
bool LuaParser::SpellHasQuestSub(uint32 spell_id, const char *subname) {
std::stringstream package_name;
package_name << "spell_" << spell_id;
return HasFunction(subname, package_name.str());
}
bool LuaParser::ItemHasQuestSub(ItemInst *itm, const char *subname) {
std::string package_name = "item_";
package_name += std::to_string(itm->GetID());
const char *subname = LuaEvents[evt];
return HasFunction(subname, package_name); return HasFunction(subname, package_name);
} }
bool LuaParser::EncounterHasQuestSub(std::string encounter_name, const char *subname) { bool LuaParser::HasGlobalQuestSub(QuestEventID evt) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) {
return false;
}
const char *subname = LuaEvents[evt];
return HasFunction(subname, "global_npc");
}
bool LuaParser::PlayerHasQuestSub(QuestEventID evt) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) {
return false;
}
const char *subname = LuaEvents[evt];
return HasFunction(subname, "player");
}
bool LuaParser::GlobalPlayerHasQuestSub(QuestEventID evt) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) {
return false;
}
const char *subname = LuaEvents[evt];
return HasFunction(subname, "global_player");
}
bool LuaParser::SpellHasQuestSub(uint32 spell_id, QuestEventID evt) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) {
return false;
}
std::string package_name = "spell_" + std::to_string(spell_id);
const char *subname = LuaEvents[evt];
return HasFunction(subname, package_name);
}
bool LuaParser::ItemHasQuestSub(ItemInst *itm, QuestEventID evt) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) {
return false;
}
std::string package_name = "item_";
package_name += std::to_string(itm->GetID());
const char *subname = LuaEvents[evt];
return HasFunction(subname, package_name);
}
bool LuaParser::EncounterHasQuestSub(std::string encounter_name, QuestEventID evt) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) {
return false;
}
std::string package_name = "encounter_" + encounter_name; std::string package_name = "encounter_" + encounter_name;
const char *subname = LuaEvents[evt];
return HasFunction(subname, package_name); return HasFunction(subname, package_name);
} }
void LuaParser::LoadNPCScript(std::string filename, int npc_id) { void LuaParser::LoadNPCScript(std::string filename, int npc_id) {
std::stringstream package_name; std::string package_name = "npc_" + std::to_string(npc_id);
package_name << "npc_" << npc_id;
LoadScript(filename, package_name.str()); LoadScript(filename, package_name);
} }
void LuaParser::LoadGlobalNPCScript(std::string filename) { void LuaParser::LoadGlobalNPCScript(std::string filename) {
@ -652,10 +695,9 @@ void LuaParser::LoadItemScript(std::string filename, ItemInst *item) {
} }
void LuaParser::LoadSpellScript(std::string filename, uint32 spell_id) { void LuaParser::LoadSpellScript(std::string filename, uint32 spell_id) {
std::stringstream package_name; std::string package_name = "spell_" + std::to_string(spell_id);
package_name << "spell_" << spell_id;
LoadScript(filename, package_name.str()); LoadScript(filename, package_name);
} }
void LuaParser::LoadEncounterScript(std::string filename, std::string encounter_name) { void LuaParser::LoadEncounterScript(std::string filename, std::string encounter_name) {
@ -843,13 +885,17 @@ void LuaParser::MapFunctions(lua_State *L) {
void LuaParser::DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data, void LuaParser::DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::string data, uint32 extra_data,
std::vector<ItemInst*> *items) { std::vector<ItemInst*> *items) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) {
return;
}
if(!npc) if(!npc)
return; return;
std::stringstream package_name; std::string package_name = "npc_" + std::to_string(npc->GetNPCTypeID());
package_name << "npc_" << npc->GetNPCTypeID();
auto iter = lua_encounter_events_registered.find(package_name.str()); auto iter = lua_encounter_events_registered.find(package_name);
if(iter == lua_encounter_events_registered.end()) { if(iter == lua_encounter_events_registered.end()) {
return; return;
} }
@ -865,6 +911,11 @@ void LuaParser::DispatchEventNPC(QuestEventID evt, NPC* npc, Mob *init, std::str
} }
void LuaParser::DispatchEventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) { void LuaParser::DispatchEventPlayer(QuestEventID evt, Client *client, std::string data, uint32 extra_data) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) {
return;
}
std::string package_name = "player"; std::string package_name = "player";
auto iter = lua_encounter_events_registered.find(package_name); auto iter = lua_encounter_events_registered.find(package_name);
@ -883,6 +934,11 @@ void LuaParser::DispatchEventPlayer(QuestEventID evt, Client *client, std::strin
} }
void LuaParser::DispatchEventItem(QuestEventID evt, Client *client, ItemInst *item, Mob *mob, std::string data, uint32 extra_data) { void LuaParser::DispatchEventItem(QuestEventID evt, Client *client, ItemInst *item, Mob *mob, std::string data, uint32 extra_data) {
evt = ConvertLuaEvent(evt);
if(evt >= _LargestEventID) {
return;
}
if(!item) if(!item)
return; return;
@ -905,10 +961,14 @@ void LuaParser::DispatchEventItem(QuestEventID evt, Client *client, ItemInst *it
} }
void LuaParser::DispatchEventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) { void LuaParser::DispatchEventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data) {
std::stringstream package_name; evt = ConvertLuaEvent(evt);
package_name << "spell_" << spell_id; if(evt >= _LargestEventID) {
return;
}
auto iter = lua_encounter_events_registered.find(package_name.str()); std::string package_name = "spell_" + std::to_string(spell_id);
auto iter = lua_encounter_events_registered.find(package_name);
if(iter == lua_encounter_events_registered.end()) { if(iter == lua_encounter_events_registered.end()) {
return; return;
} }
@ -923,4 +983,27 @@ void LuaParser::DispatchEventSpell(QuestEventID evt, NPC* npc, Client *client, u
} }
} }
QuestEventID LuaParser::ConvertLuaEvent(QuestEventID evt) {
switch(evt) {
case EVENT_SLAY:
case EVENT_NPC_SLAY:
return EVENT_SLAY;
break;
case EVENT_SPELL_EFFECT_CLIENT:
case EVENT_SPELL_EFFECT_NPC:
return EVENT_SPELL_EFFECT_CLIENT;
break;
case EVENT_SPELL_BUFF_TIC_CLIENT:
case EVENT_SPELL_BUFF_TIC_NPC:
return EVENT_SPELL_BUFF_TIC_CLIENT;
break;
case EVENT_AGGRO:
case EVENT_ATTACK:
return _LargestEventID;
break;
default:
return evt;
}
}
#endif #endif

View File

@ -35,13 +35,13 @@ public:
virtual int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data); virtual int EventSpell(QuestEventID evt, NPC* npc, Client *client, uint32 spell_id, uint32 extra_data);
virtual int EventEncounter(QuestEventID evt, std::string encounter_name, uint32 extra_data); virtual int EventEncounter(QuestEventID evt, std::string encounter_name, uint32 extra_data);
virtual bool HasQuestSub(uint32 npc_id, const char *subname); virtual bool HasQuestSub(uint32 npc_id, QuestEventID evt);
virtual bool HasGlobalQuestSub(const char *subname); virtual bool HasGlobalQuestSub(QuestEventID evt);
virtual bool PlayerHasQuestSub(const char *subname); virtual bool PlayerHasQuestSub(QuestEventID evt);
virtual bool GlobalPlayerHasQuestSub(const char *subname); virtual bool GlobalPlayerHasQuestSub(QuestEventID evt);
virtual bool SpellHasQuestSub(uint32 spell_id, const char *subname); virtual bool SpellHasQuestSub(uint32 spell_id, QuestEventID evt);
virtual bool ItemHasQuestSub(ItemInst *itm, const char *subname); virtual bool ItemHasQuestSub(ItemInst *itm, QuestEventID evt);
virtual bool EncounterHasQuestSub(std::string encounter_name, const char *subname); virtual bool EncounterHasQuestSub(std::string encounter_name, QuestEventID evt);
virtual void LoadNPCScript(std::string filename, int npc_id); virtual void LoadNPCScript(std::string filename, int npc_id);
virtual void LoadGlobalNPCScript(std::string filename); virtual void LoadGlobalNPCScript(std::string filename);
@ -78,6 +78,7 @@ private:
bool HasFunction(std::string function, std::string package_name); bool HasFunction(std::string function, std::string package_name);
void ClearStates(); void ClearStates();
void MapFunctions(lua_State *L); void MapFunctions(lua_State *L);
QuestEventID ConvertLuaEvent(QuestEventID evt);
std::map<std::string, std::string> vars_; std::map<std::string, std::string> vars_;
std::map<std::string, bool> loaded_; std::map<std::string, bool> loaded_;

View File

@ -151,7 +151,7 @@ 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) { std::vector<ItemInst*> *items) {
lua_pushinteger(L, std::stoi(data)); lua_pushinteger(L, std::stoi(data));
lua_setfield(L, -2, "signal_id"); lua_setfield(L, -2, "signal");
} }
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,
@ -243,7 +243,7 @@ void handle_player_death(QuestInterface *parse, lua_State* L, Client* client, st
} }
lua_pushinteger(L, std::stoi(sep.arg[3])); lua_pushinteger(L, std::stoi(sep.arg[3]));
lua_setfield(L, -2, "skill_id"); lua_setfield(L, -2, "skill");
} }
void handle_player_timer(QuestInterface *parse, lua_State* L, Client* client, std::string data, uint32 extra_data) { void handle_player_timer(QuestInterface *parse, lua_State* L, Client* client, std::string data, uint32 extra_data) {
@ -379,8 +379,8 @@ void handle_player_command(QuestInterface *parse, lua_State* L, Client* client,
luabind::object args = luabind::newtable(L); luabind::object args = luabind::newtable(L);
int max_args = sep.GetMaxArgNum(); int max_args = sep.GetMaxArgNum();
for(int i = 1; i < max_args; ++i) { for(int i = 1; i < max_args; ++i) {
if(strlen(sep.arg[0]) > 0) { if(strlen(sep.arg[i]) > 0) {
args[i] = sep.arg[i]; args[i] = std::string(sep.arg[i]);
} }
} }

View File

@ -42,7 +42,6 @@
#include "../common/memory_mapped_file.h" #include "../common/memory_mapped_file.h"
#include "../common/eqemu_exception.h" #include "../common/eqemu_exception.h"
#include "../common/spdat.h" #include "../common/spdat.h"
#include "../common/callback_manager.h"
#include "ZoneConfig.h" #include "ZoneConfig.h"
#include "masterentity.h" #include "masterentity.h"
@ -289,10 +288,6 @@ int main(int argc, char** argv) {
parse->RegisterQuestInterface(perl_parser, "pl"); parse->RegisterQuestInterface(perl_parser, "pl");
#endif #endif
RegisterEQCallback("OnItemInstDestroy", [](void* item) {
quest_manager.stop_item_timers(reinterpret_cast<ItemInst*>(item));
});
//now we have our parser, load the quests //now we have our parser, load the quests
_log(ZONE__INIT, "Loading quests"); _log(ZONE__INIT, "Loading quests");
parse->ReloadQuests(); parse->ReloadQuests();

View File

@ -119,13 +119,7 @@ void QuestManager::Process() {
end = QTimerList.end(); end = QTimerList.end();
while (cur != end) { while (cur != end) {
if (cur->Timer_.Enabled() && cur->Timer_.Check()) { if (cur->Timer_.Enabled() && cur->Timer_.Check()) {
if(entity_list.IsMobInZone(cur->mob)) {
if(cur->item) {
parse->EventItem(EVENT_TIMER, cur->mob->CastToClient(), cur->item, nullptr, cur->name, 0);
cur = QTimerList.begin();
end = QTimerList.end();
} else if(entity_list.IsMobInZone(cur->mob)) {
if(cur->mob->IsNPC()) { if(cur->mob->IsNPC()) {
parse->EventNPC(EVENT_TIMER, cur->mob->CastToNPC(), nullptr, cur->name, 0); parse->EventNPC(EVENT_TIMER, cur->mob->CastToNPC(), nullptr, cur->name, 0);
} }
@ -453,12 +447,20 @@ void QuestManager::Zone(const char *zone_name) {
void QuestManager::settimer(const char *timer_name, int seconds) { void QuestManager::settimer(const char *timer_name, int seconds) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if(questitem) {
auto timers = questitem->GetTimers();
Timer t(seconds * 1000);
t.Start(seconds * 1000, false);
timers[timer_name] = t;
return;
}
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end; std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
end = QTimerList.end(); end = QTimerList.end();
while (cur != end) { while (cur != end) {
if (cur->mob == owner && cur->item == questitem && cur->name == timer_name) { if(cur->mob && cur->mob == owner && cur->name == timer_name)
cur->mob = owner; {
cur->Timer_.Enable(); cur->Timer_.Enable();
cur->Timer_.Start(seconds * 1000, false); cur->Timer_.Start(seconds * 1000, false);
return; return;
@ -466,18 +468,26 @@ void QuestManager::settimer(const char *timer_name, int seconds) {
cur++; cur++;
} }
QTimerList.push_back(QuestTimer(seconds * 1000, owner, questitem, timer_name)); QTimerList.push_back(QuestTimer(seconds * 1000, owner, timer_name));
} }
void QuestManager::settimerMS(const char *timer_name, int milliseconds) { void QuestManager::settimerMS(const char *timer_name, int milliseconds) {
QuestManagerCurrentQuestVars(); QuestManagerCurrentQuestVars();
if(questitem) {
auto timers = questitem->GetTimers();
Timer t(milliseconds);
t.Start(milliseconds, false);
timers[timer_name] = t;
return;
}
std::list<QuestTimer>::iterator cur = QTimerList.begin(), end; std::list<QuestTimer>::iterator cur = QTimerList.begin(), end;
end = QTimerList.end(); end = QTimerList.end();
while (cur != end) { while (cur != end) {
if (cur->mob == owner && cur->item == questitem && cur->name == timer_name) { if(cur->mob && cur->mob == owner && cur->name == timer_name)
cur->mob = owner; {
cur->Timer_.Enable(); cur->Timer_.Enable();
cur->Timer_.Start(milliseconds, false); cur->Timer_.Start(milliseconds, false);
return; return;
@ -485,7 +495,7 @@ void QuestManager::settimerMS(const char *timer_name, int milliseconds) {
cur++; cur++;
} }
QTimerList.push_back(QuestTimer(milliseconds, owner, questitem, timer_name)); QTimerList.push_back(QuestTimer(milliseconds, owner, timer_name));
} }
void QuestManager::stoptimer(const char *timer_name) { void QuestManager::stoptimer(const char *timer_name) {
@ -496,7 +506,7 @@ void QuestManager::stoptimer(const char *timer_name) {
end = QTimerList.end(); end = QTimerList.end();
while (cur != end) while (cur != end)
{ {
if(cur->mob == owner && cur->item == questitem && cur->name == timer_name) if(cur->mob && cur->mob == owner && cur->name == timer_name)
{ {
QTimerList.erase(cur); QTimerList.erase(cur);
return; return;
@ -513,7 +523,7 @@ void QuestManager::stopalltimers() {
end = QTimerList.end(); end = QTimerList.end();
while (cur != end) while (cur != end)
{ {
if(cur->mob == owner && cur->item == questitem) if(cur->mob && cur->mob == owner)
{ {
tmp = cur; tmp = cur;
tmp++; tmp++;
@ -2899,19 +2909,3 @@ ItemInst *QuestManager::GetQuestItem() const {
return nullptr; return nullptr;
} }
void QuestManager::stop_item_timers(ItemInst *item) {
if(item_timers == 0)
return;
auto iter = QTimerList.begin();
while(iter != QTimerList.end()) {
if(iter->item == item) {
iter = QTimerList.erase(iter);
--item_timers;
continue;
}
++iter;
}
}

View File

@ -237,7 +237,6 @@ public:
Mob *GetOwner() const; Mob *GetOwner() const;
ItemInst *GetQuestItem() const; ItemInst *GetQuestItem() const;
inline bool ProximitySayInUse() { return HaveProximitySays; } inline bool ProximitySayInUse() { return HaveProximitySays; }
void stop_item_timers(ItemInst *item);
#ifdef BOTS #ifdef BOTS
int createbotcount(); int createbotcount();
@ -258,10 +257,9 @@ private:
class QuestTimer { class QuestTimer {
public: public:
inline QuestTimer(int duration, Mob *_mob, ItemInst *_item, std::string _name) inline QuestTimer(int duration, Mob *_mob, std::string _name)
: mob(_mob), item(_item), name(_name), Timer_(duration) { Timer_.Start(duration, false); } : mob(_mob), name(_name), Timer_(duration) { Timer_.Start(duration, false); }
Mob* mob; Mob* mob;
ItemInst *item;
std::string name; std::string name;
Timer Timer_; Timer Timer_;
}; };

View File

@ -141,7 +141,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
if(IsNPC()) if(IsNPC())
{ {
int i = parse->EventSpell(EVENT_SPELL_EFFECT, CastToNPC(), nullptr, spell_id, caster ? caster->GetID() : 0); int i = parse->EventSpell(EVENT_SPELL_EFFECT_NPC, CastToNPC(), nullptr, spell_id, caster ? caster->GetID() : 0);
if(i != 0){ if(i != 0){
CalcBonuses(); CalcBonuses();
return true; return true;
@ -149,7 +149,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial)
} }
else if(IsClient()) else if(IsClient())
{ {
int i = parse->EventSpell(EVENT_SPELL_EFFECT, nullptr, CastToClient(), spell_id, caster ? caster->GetID() : 0); int i = parse->EventSpell(EVENT_SPELL_EFFECT_CLIENT, nullptr, CastToClient(), spell_id, caster ? caster->GetID() : 0);
if(i != 0){ if(i != 0){
CalcBonuses(); CalcBonuses();
return true; return true;
@ -3066,14 +3066,14 @@ void Mob::DoBuffTic(uint16 spell_id, uint32 ticsremaining, uint8 caster_level, M
if(IsNPC()) if(IsNPC())
{ {
int i = parse->EventSpell(EVENT_SPELL_BUFF_TIC, CastToNPC(), nullptr, spell_id, caster ? caster->GetID() : 0); int i = parse->EventSpell(EVENT_SPELL_BUFF_TIC_NPC, CastToNPC(), nullptr, spell_id, caster ? caster->GetID() : 0);
if(i != 0) { if(i != 0) {
return; return;
} }
} }
else else
{ {
int i = parse->EventSpell(EVENT_SPELL_BUFF_TIC, nullptr, CastToClient(), spell_id, caster ? caster->GetID() : 0); int i = parse->EventSpell(EVENT_SPELL_BUFF_TIC_CLIENT, nullptr, CastToClient(), spell_id, caster ? caster->GetID() : 0);
if(i != 0) { if(i != 0) {
return; return;
} }

View File

@ -4672,362 +4672,6 @@ bool Client::SpellGlobalCheck(uint16 Spell_ID, uint16 Char_ID) {
return false; // Default is false return false; // Default is false
} }
//this is one nasty function... FindType and FindSpell are rather complex operations...
/*void Mob::CheckBuffs() {
if (!IsCasting()) {
//try to summon a pet if we havent yet
CheckPet();
uint8 newtype[15] = { SE_ArmorClass, SE_STR, SE_DEX, SE_AGI, SE_WIS,
SE_INT, SE_CHA, SE_AttackSpeed, SE_MovementSpeed,
SE_DamageShield, SE_ResistFire, SE_ResistCold,
SE_ResistMagic, SE_ResistPoison, SE_ResistDisease };
for (int h=0; h<15; h++) {
if (!this->FindType(newtype[h])) {
uint16 buffid = FindSpell(this->class_, this->level,
newtype[h], SPELLTYPE_SELF, 0,
GetMana());
if (buffid != 0) {
this->CastSpell(buffid, this->GetID());
}
}
}
}
}
void Mob::CheckPet() {
if(HasPet())
return;
uint16 buffid = 0;
if ((GetClass() == NECROMANCER || GetClass() == MAGICIAN)) {
if (this->GetClass() == MAGICIAN) {
buffid = FindSpell(class_, level,
SE_SummonPet, SPELLTYPE_OTHER, 0,
GetMana());
} else if (GetClass() == NECROMANCER) {
buffid = FindSpell(class_, level,
SE_NecPet, SPELLTYPE_OTHER, 0,
GetMana());
}
if (buffid != 0) {
CastSpell(buffid, GetID());
}
}
}
uint16 Mob::FindSpell(uint16 classp, uint16 level, int type,
FindSpellType spelltype, float distance,
int32 mana_avail) {
int i,j;
int bestvalue = -1;
int bestid = 0;
if (classp < 1)
return 0;
if (level < 1)
return 0;
classp = GetEQArrayEQClass(classp);
// purpose: find a suited spell for a class and level and type
// the if's are here to filter out anything which isnt normal.
// its possible that we miss some valid spells, but who cares.
for (i = 0; i < SPDAT_RECORDS; i++) {
if(!IsValidSpell(i))
continue;
// Filter all spells that should never be used
if (spells[i].effectid[0] == SE_NegateIfCombat)
continue;
if (spells[i].targettype == ST_Group)
continue;
if (i == 2632) // fix for obsolete BST pet summon spell
continue;
if (i == 1576) // fix for torpor
continue;
if (spells[i].cast_time < 11)
continue;
if (spells[i].mana == 0)
continue;
// now for closer checks
if (spelltype == SPELLTYPE_SELF) {
if ( i == 357) // fix for dark empathy
continue;
// check buffs 12 would be max, but 90% of all effects are in the first 4 slots
for (j = 0; j < 5; j++) {
// fix for pets
if ( spells[i].effectid[j] == SE_Illusion &&
type != SE_Illusion) // only let illusions thru if explicitly requested
continue;
if (spells[i].effectid[j] == type &&
spells[i].goodEffect != 0 &&
spells[i].classes[classp] <= level &&
spells[i].classes[classp] <= 65 &&
(spells[i].recast_time < 10000 ||
type == SE_SummonPet ||
type == SE_SummonBSTPet) && // fix for druid pets
(type == SE_AbsorbMagicAtt || type == SE_Rune ||
type == SE_NecPet || type == SE_SummonPet ||
spells[i].components[0] == -1 ) &&
spells[i].targettype != ST_Undead && // for necro mend series
spells[i].targettype != ST_Group && // fix for group spells
spells[i].targettype != ST_Pet && // fix for beastlords casting pet heals on self
spells[i].targettype != ST_Summoned && // fix for vs. summoned spells on normal npcs
spells[i].targettype != ST_AETarget && // dont let em cast AEtarget spells
spells[i].mana <= mana_avail &&
spells[i].range >= distance) {
int32 spellvalue;
// lets assume pet is always better if higher, so no formula needed
if (type == SE_NecPet ||
type == SE_SummonPet ||
type == SE_SummonBSTPet) {
spellvalue = spells[i].classes[classp];
} else {
spellvalue = CalcSpellEffectValue_formula(spells[i].formula[j],
spells[i].base[j],
spells[i].max[j],
level, i);
}
if (abs(spellvalue) > bestvalue) {
bestvalue = abs(spellvalue);
bestid = i;
}
}
}
} else if (spelltype == SPELLTYPE_OFFENSIVE) {
// check offensive spells
for (j = 0; j < 5; j++) {
if (spells[i].effectid[j] == SE_Illusion &&
type != SE_Illusion) // only let illusions thru if explicitly requested
continue;
if (spells[i].effectid[j] == type &&
spells[i].goodEffect == 0 &&
spells[i].classes[classp] <= level &&
spells[i].classes[classp] <= 65 &&
spells[i].recast_time < 10000 &&
spells[i].components[0] == -1 &&
spells[i].mana <= mana_avail &&
spells[i].targettype != ST_Undead && // thats for the necro mend series
spells[i].targettype != ST_Group && // fix for group spells
spells[i].targettype != ST_Pet && // fix for beastlords casting pet heals on self
spells[i].targettype != ST_Summoned && // fix for vs. summoned spells on normal npcs
spells[i].targettype != ST_AETarget && // dont let em cast AEtarget spells
spells[i].range >= distance) {
int32 spellvalue = CalcSpellEffectValue_formula(spells[i].formula[j],
spells[i].base[j],
spells[i].max[j],
level, i);
if ( abs(spellvalue) > bestvalue ) {
bestvalue = abs(spellvalue);
bestid = i;
}
}
}
} else if (spelltype == SPELLTYPE_OTHER) {
if ( i == 357) // fix for dark empathy
continue;
// healing and such
for (j = 0; j < 5; j++) {
if (spells[i].effectid[j] == SE_Illusion &&
type != SE_Illusion) // only let illusions thru if explicitly requested
continue;
if (spells[i].effectid[j] == type &&
spells[i].targettype != ST_Self &&
spells[i].goodEffect != 0 &&
spells[i].classes[classp] <= level &&
spells[i].classes[classp] <= 65 &&
spells[i].recast_time < 10000 &&
spells[i].components[0] == -1 &&
spells[i].targettype != ST_Undead && // thats for the necro mend series
spells[i].targettype != ST_Group && // fix for group spells
spells[i].targettype != ST_Pet && // fix for beastlords casting pet heals on self
spells[i].targettype != ST_Summoned && // fix for vs. summoned spells on normal npcs
spells[i].targettype != ST_AETarget && // dont let em cast AEtarget spells
spells[i].mana <= mana_avail &&
spells[i].range >= distance) {
int32 spellvalue = CalcSpellEffectValue_formula(spells[i].formula[j],
spells[i].base[j],
spells[i].max[j],
level, i);
if ( abs(spellvalue) > bestvalue ) {
bestvalue = abs(spellvalue);
bestid = i;
}
}
}
}
} // for i
// g_LogFile.write("for combination [class %02d][level %02d][SE_type %02d][type %02d] i selected the spell: %s",
// classp, level, (uint16)type, uint16(spelltype), spells[bestid].name);
return bestid;
}
#if 0
uint16 Mob::FindSpell(uint16 classp, uint16 level, uint8 type, uint8 spelltype) {
if (this->casting_spell_id != 0)
return 0;
if (spelltype == 2) // for future use
spelltype = 0;
//int count=0;
uint16 bestsofar = 0;
uint16 bestspellid = 0;
for (int i = 0; i < SPDAT_RECORDS; i++) {
if ((IsLifetapSpell(i) && spelltype == 1) || (spells[i].targettype != ST_Group && spells[i].targettype != ST_Undead && spells[i].targettype != ST_Summoned && spells[i].targettype != ST_Pet && strstr(spells[i].name,"Summoning") == nullptr)) {
int Canuse = CanUseSpell(i, classp, level);
if (Canuse != 0) {
for (int z=0; z < 12; z++) {
int spfo = CalcSpellValue(spells[i].formula[z], spells[i].base[z], spells[i].max[z], this->GetLevel());
if (spells[i].effectid[z] == SE_ArmorClass && type == SE_ArmorClass && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_TotalHP && type == SE_TotalHP && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_STR && type == SE_STR && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_DEX && type == SE_DEX && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_AGI && type == SE_AGI && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_WIS && type == SE_WIS && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_INT && type == SE_INT && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_CHA && type == SE_CHA && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_MovementSpeed && type == SE_MovementSpeed && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_AttackSpeed && type == SE_AttackSpeed && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_ResistFire && type == SE_ResistFire && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_ResistCold && type == SE_ResistCold && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_ResistMagic && type == SE_ResistMagic && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_ResistDisease && type == SE_ResistDisease && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_ResistPoison && type == SE_ResistPoison && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_DamageShield && type == SE_DamageShield && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_CurrentHPOnce && type == SE_CurrentHPOnce && !FindBuff(i)) {
if (spfo > 0 && (spfo + spells[i].buffduration) > bestsofar) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_SummonPet && type == SE_SummonPet && !FindBuff(i)) {
if (Canuse > bestsofar) {
bestsofar = Canuse;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_NecPet && type == SE_NecPet && !FindBuff(i)) {
if (Canuse > bestsofar) {
bestsofar = Canuse;
bestspellid = i;
}
}
if (spells[i].effectid[z] == SE_CurrentHP && type == SE_CurrentHP && !FindBuff(i)) {
if (spfo < 0 && (spells[i].buffduration + spfo) < bestsofar && spelltype == 1) {
bestsofar = ((spells[i].buffduration * -1) + spfo);
bestspellid = i;
}
if ((spfo + spells[i].buffduration) > bestsofar && spfo > 0 && spelltype == 0) {
bestsofar = spfo + spells[i].buffduration;
bestspellid = i;
}
}
}
}
}
}
return bestspellid;
}
#endif
*/
// TODO get rid of this // TODO get rid of this
int16 Mob::GetBuffSlotFromType(uint16 type) { int16 Mob::GetBuffSlotFromType(uint16 type) {
uint32 buff_count = GetMaxTotalSlots(); uint32 buff_count = GetMaxTotalSlots();

View File

@ -569,7 +569,7 @@ void Client::FinishTrade(Mob* tradingWith, ServerPacket* qspack, bool finalizer)
} }
bool quest_npc = false; bool quest_npc = false;
if(parse->HasQuestSub(tradingWith->GetNPCTypeID(), "EVENT_TRADE")) { if(parse->HasQuestSub(tradingWith->GetNPCTypeID(), EVENT_TRADE)) {
// This is a quest NPC // This is a quest NPC
quest_npc = true; quest_npc = true;
} }