From d8628170b5d22bd6baa030c2bec35d37b9ce045d Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 3 Mar 2013 15:26:40 -0800 Subject: [PATCH 1/3] Fixed missing include that blocked compile on linux. --- common/ipc_mutex.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/ipc_mutex.cpp b/common/ipc_mutex.cpp index 2c001cc403..80a583ea81 100644 --- a/common/ipc_mutex.cpp +++ b/common/ipc_mutex.cpp @@ -4,13 +4,13 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY except by those people which sell it, which are required to give you total support for your newly bought product; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -23,6 +23,7 @@ #include #include #include +#include #endif #include "types.h" #include "eqemu_exception.h" @@ -53,8 +54,8 @@ namespace EQEmu { #else std::string final_name = name; final_name += ".lock"; - - imp_->fd_ = open(final_name.c_str(), + + imp_->fd_ = open(final_name.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, S_IRUSR | S_IWUSR); From 950f00fae6c4d5103282551e7b158d32c18219f5 Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 3 Mar 2013 16:17:06 -0800 Subject: [PATCH 2/3] Fixed some warnings, like sprintf %i warnings (converted to %lu), fals vs NULL, etc --- common/EmuTCPServer.h | 16 +- common/misc.cpp | 6 +- common/ptimer.cpp | 92 +++++------ common/rulesys.cpp | 58 +++---- utils/azone2/azone.cpp | 344 ++++++++++++++++++++--------------------- world/EQLConfig.cpp | 96 ++++++------ 6 files changed, 306 insertions(+), 306 deletions(-) diff --git a/common/EmuTCPServer.h b/common/EmuTCPServer.h index fcb49d274a..c84524662e 100644 --- a/common/EmuTCPServer.h +++ b/common/EmuTCPServer.h @@ -11,24 +11,24 @@ class EmuTCPServer : public TCPServer { public: EmuTCPServer(uint16 iPort = 0, bool iOldFormat = false); virtual ~EmuTCPServer(); - + //packet broadcast routines. void SendPacket(ServerPacket* pack); void SendPacket(EmuTCPNetPacket_Struct** tnps); - + //special crap for relay management EmuTCPConnection *FindConnection(uint32 iID); - + //exposed for some crap we pull. Do not call from outside this object. - TCPServer::AddConnection; - + using TCPServer::AddConnection; + protected: virtual void Process(); - + virtual void CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort); - + bool pOldFormat; - + //broadcast packet queue.. void CheckInQueue(); Mutex MInQueue; diff --git a/common/misc.cpp b/common/misc.cpp index 9fe01154aa..4220afcab7 100644 --- a/common/misc.cpp +++ b/common/misc.cpp @@ -118,7 +118,7 @@ static char *temp=NULL; return false; } ptr++; - + for(i=(name_pos-1);i<(max_field-1);i++) { end=ptr-1; while((end=strchr(end+1,'|'))!=NULL) { @@ -463,7 +463,7 @@ bool in_quote=false; } if (in_quote) continue; - if (seps.find(c)!=string::npos) { + if (seps.find(c)!=string::npos) { break; } } @@ -554,7 +554,7 @@ void build_hex_line(const char *buffer, unsigned long length, unsigned long offs char *ptr=out_buffer; int i; char printable[17]; - ptr+=sprintf(ptr,"%0*i:",padding,offset); + ptr+=sprintf(ptr,"%0*lu:",padding,offset); for(i=0;i<16; i++) { if (i==8) { strcpy(ptr," -"); diff --git a/common/ptimer.cpp b/common/ptimer.cpp index 1b2ac45933..9be3594d59 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -48,7 +48,7 @@ to store them in the DB: Load and Store. All durations are in seconds. -Each persistent timer is attached to a character, and given +Each persistent timer is attached to a character, and given a specific type. A given character can only have one timer of each type. While the type is just an arbitrary number, please record what you are using it for in the enum for @@ -59,7 +59,7 @@ client has a facility called p_timers which should handle most of what you need. The idea is that instead of making your own PersistentTimer, you use the methods on p_timers: Start, Check, Clear, GetRemainingTime to access them. You -starting a timer which does not exist will create it. If +starting a timer which does not exist will create it. If you need to do more than that with your timer, you should still use p_timers, just use the Get() method to get direct access to the PersistentTimer. All timers in the p_timers @@ -101,7 +101,7 @@ PersistentTimer *PersistentTimer::LoadTimer(Database *db, uint32 char_id, pTimer PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_timer_time) { _char_id = char_id; _type = type; - + timer_time = in_timer_time; start_time = get_current_time(); if (timer_time == 0) { @@ -117,7 +117,7 @@ PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_time PersistentTimer::PersistentTimer(uint32 char_id, pTimerType type, uint32 in_start_time, uint32 in_timer_time, bool in_enable) { _char_id = char_id; _type = type; - + timer_time = in_timer_time; start_time = in_start_time; enabled = in_enable; @@ -133,14 +133,14 @@ bool PersistentTimer::Load(Database *db) { char *query = 0; uint32 qlen = 0; uint32 qcount = 0; - + qlen = MakeAnyLenString(&query, "SELECT start,duration,enable " " FROM timers WHERE char_id=%lu AND type=%u", (unsigned long)_char_id, _type); - + #ifdef DEBUG_PTIMERS printf("Loading timer: char %lu of type %u\n", (unsigned long)_char_id, _type); #endif - + if (!db->RunQuery(query, qlen, errbuf, &result)) { safe_delete_array(query); #if EQDEBUG > 5 @@ -149,39 +149,39 @@ bool PersistentTimer::Load(Database *db) { return(false); } safe_delete_array(query); - + bool res = false; qcount = mysql_num_rows(result); if(qcount == 1 && (row = mysql_fetch_row(result)) ) { start_time = strtoul(row[0], NULL, 10); timer_time = strtoul(row[1], NULL, 10); enabled = (row[2][0] == '1'); - + res = true; } mysql_free_result(result); - + return(res); } bool PersistentTimer::Store(Database *db) { if(Expired(db, false)) //dont need to store expired timers. return(true); - + char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; uint32 qlen = 0; - + qlen = MakeAnyLenString(&query, "REPLACE INTO timers " " (char_id,type,start,duration,enable) " " VALUES(%lu,%u,%lu,%lu,%d)", (unsigned long)_char_id, _type, (unsigned long)start_time, (unsigned long)timer_time, enabled?1:0); - - + + #ifdef DEBUG_PTIMERS printf("Storing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query); #endif - + if (!db->RunQuery(query, qlen, errbuf)) { safe_delete_array(query); #if EQDEBUG > 5 @@ -190,7 +190,7 @@ bool PersistentTimer::Store(Database *db) { return(false); } safe_delete_array(query); - + return(true); } @@ -198,15 +198,15 @@ bool PersistentTimer::Clear(Database *db) { char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; uint32 qlen = 0; - + qlen = MakeAnyLenString(&query, "DELETE FROM timers " " WHERE char_id=%lu AND type=%u ", (unsigned long)_char_id, _type); - + #ifdef DEBUG_PTIMERS printf("Clearing timer: char %lu of type %u: '%s'\n", (unsigned long)_char_id, _type, query); #endif - + if (!db->RunQuery(query, qlen, errbuf)) { safe_delete_array(query); #if EQDEBUG > 5 @@ -215,15 +215,15 @@ bool PersistentTimer::Clear(Database *db) { return(false); } safe_delete_array(query); - + return(true); } /* This function checks if the timer triggered */ bool PersistentTimer::Expired(Database *db, bool iReset) { - if (this == NULL) { - LogFile->write(EQEMuLog::Error, "Null timer during ->Check()!?\n"); + if (this == NULL) { + LogFile->write(EQEMuLog::Error, "Null timer during ->Check()!?\n"); return(true); } uint32 current_time = get_current_time(); @@ -235,7 +235,7 @@ bool PersistentTimer::Expired(Database *db, bool iReset) { } return(true); } - + return(false); } @@ -287,7 +287,7 @@ uint32 PersistentTimer::get_current_time() { PTimerList::PTimerList(uint32 char_id) { _char_id = char_id; } - + PTimerList::~PTimerList() { map::iterator s; s = _list.begin(); @@ -308,21 +308,21 @@ bool PTimerList::Load(Database *db) { s++; } _list.clear(); - + char errbuf[MYSQL_ERRMSG_SIZE]; MYSQL_RES *result; MYSQL_ROW row; char *query = 0; uint32 qlen = 0; uint32 qcount = 0; - + qlen = MakeAnyLenString(&query, "SELECT type,start,duration,enable " " FROM timers WHERE char_id=%lu", (unsigned long)_char_id); - + #ifdef DEBUG_PTIMERS printf("Loading all timers for char %lu\n", (unsigned long)_char_id); #endif - + if (!db->RunQuery(query, qlen, errbuf, &result)) { safe_delete_array(query); #if EQDEBUG > 5 @@ -331,11 +331,11 @@ bool PTimerList::Load(Database *db) { return(false); } safe_delete_array(query); - + pTimerType type; uint32 start_time, timer_time; bool enabled; - + PersistentTimer *cur; qcount = mysql_num_rows(result); while((row = mysql_fetch_row(result)) ) { @@ -343,17 +343,17 @@ bool PTimerList::Load(Database *db) { start_time = strtoul(row[1], NULL, 10); timer_time = strtoul(row[2], NULL, 10); enabled = (row[3][0] == '1'); - + //if it expired allready, dont bother. - + cur = new PersistentTimer(_char_id, type, start_time, timer_time, enabled); - if(!cur->Expired(false)) + if(!cur->Expired(NULL, false)) _list[type] = cur; else delete cur; } mysql_free_result(result); - + return(true); } @@ -380,18 +380,18 @@ bool PTimerList::Store(Database *db) { bool PTimerList::Clear(Database *db) { _list.clear(); - + char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; uint32 qlen = 0; - + qlen = MakeAnyLenString(&query, "DELETE FROM timers " " WHERE char_id=%lu ", (unsigned long)_char_id); - + #ifdef DEBUG_PTIMERS printf("Storing all timers for char %lu: '%s'\n", (unsigned long)_char_id, query); #endif - + if (!db->RunQuery(query, qlen, errbuf)) { safe_delete_array(query); #if EQDEBUG > 5 @@ -400,10 +400,10 @@ bool PTimerList::Clear(Database *db) { return(false); } safe_delete_array(query); - + return(true); } - + void PTimerList::Start(pTimerType type, uint32 duration) { if(_list.count(type) == 1 && _list[type] != NULL) { _list[type]->Start(duration); @@ -463,9 +463,9 @@ PersistentTimer *PTimerList::Get(pTimerType type) { } void PTimerList::ToVector(vector< pair > &out) { - + pair p; - + map::iterator s; s = _list.begin(); while(s != _list.end()) { @@ -482,13 +482,13 @@ bool PTimerList::ClearOffline(Database *db, uint32 char_id, pTimerType type) { char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; uint32 qlen = 0; - + qlen = MakeAnyLenString(&query, "DELETE FROM timers WHERE char_id=%lu AND type=%u ",(unsigned long)char_id, type); - + #ifdef DEBUG_PTIMERS printf("Clearing timer (offline): char %lu of type %u: '%s'\n", (unsigned long)char_id, type, query); #endif - + if (!db->RunQuery(query, qlen, errbuf)) { safe_delete_array(query); #if EQDEBUG > 5 @@ -497,7 +497,7 @@ bool PTimerList::ClearOffline(Database *db, uint32 char_id, pTimerType type) { return(false); } safe_delete_array(query); - + return(true); diff --git a/common/rulesys.cpp b/common/rulesys.cpp index 32b8fd8ecb..54ef3bf770 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -4,13 +4,13 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY except by those people which sell it, which are required to give you total support for your newly bought product; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -25,7 +25,7 @@ /* - FatherNitwit: Added new rules subsystem to allow game rules to be changed + FatherNitwit: Added new rules subsystem to allow game rules to be changed at runtime. more about this will come as time goes on. FatherNitwit: Added #rules command to manage rules data from in game. FatherNitwit: Renamed old #rules to #serverrules @@ -162,12 +162,12 @@ bool RuleManager::GetRule(const char *rule_name, std::string &ret_val) { bool RuleManager::SetRule(const char *rule_name, const char *rule_value, Database *db, bool db_save) { if(rule_name == NULL || rule_value == NULL) return(false); - + RuleType type; uint16 index; if(!_FindRule(rule_name, type, index)) return(false); - + switch(type) { case IntRule: m_RuleIntValues [index] = atoi(rule_value); @@ -181,11 +181,11 @@ bool RuleManager::SetRule(const char *rule_name, const char *rule_value, Databas uint32 val = 0; if(!strcasecmp(rule_value, "on") || !strcasecmp(rule_value, "true") || !strcasecmp(rule_value, "yes") || !strcasecmp(rule_value, "enabled") || !strcmp(rule_value, "1")) val = 1; - m_RuleBoolValues[index] = val; + m_RuleBoolValues[index] = val; _log(RULES__CHANGE, "Set rule %s to value %s", rule_name, m_RuleBoolValues[index] == 1 ?"true":"false"); break; } - + if(db_save) _SaveRule(db, type, index); @@ -206,7 +206,7 @@ void RuleManager::ResetRules() { bool RuleManager::_FindRule(const char *rule_name, RuleType &type_into, uint16 &index_into) { if(rule_name == NULL) return(false); - + int r; int rcount = CountRules(); for(r = 0; r < rcount; r++) { @@ -253,7 +253,7 @@ void RuleManager::SaveRules(Database *db, const char *ruleset) { } else { _log(RULES__CHANGE, "Saving running rules into running rule set %s", m_activeName.c_str(), m_activeRuleset); } - + int r; for(r = 0; r < _IntRuleCount; r++) { _SaveRule(db, IntRule, r); @@ -284,15 +284,15 @@ bool RuleManager::LoadRules(Database *db, const char *ruleset) { m_activeRuleset = rsid; m_activeName = ruleset; - - if (db->RunQuery(query, MakeAnyLenString(&query, + + if (db->RunQuery(query, MakeAnyLenString(&query, "SELECT rule_name, rule_value" " FROM rule_values" " WHERE ruleset_id=%d", rsid), errbuf, &result)) { safe_delete_array(query); while((row = mysql_fetch_row(result))) { - if(!SetRule(row[0], row[1], false)) + if(!SetRule(row[0], row[1],NULL, false)) _log(RULES__ERROR, "Unable to interpret rule record for %s", row[0]); } mysql_free_result(result); @@ -319,10 +319,10 @@ void RuleManager::_SaveRule(Database *db, RuleType type, uint16 index) { sprintf(vstr, "%s", m_RuleBoolValues[index]?"true":"false"); break; } - + char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; - if (!db->RunQuery(query, MakeAnyLenString(&query, + if (!db->RunQuery(query, MakeAnyLenString(&query, "REPLACE INTO rule_values (ruleset_id, rule_name, rule_value) " " VALUES(%d, '%s', '%s')", m_activeRuleset, _GetRuleName(type, index), vstr),errbuf)) @@ -338,14 +338,14 @@ int RuleManager::GetRulesetID(Database *db, const char *rulesetname) { char *query = 0; MYSQL_RES *result; MYSQL_ROW row; - + uint32 len = strlen(rulesetname); char* rst = new char[2*len+1]; db->DoEscapeString(rst, rulesetname, len); int res = -1; - - if (db->RunQuery(query, MakeAnyLenString(&query, + + if (db->RunQuery(query, MakeAnyLenString(&query, "SELECT ruleset_id" " FROM rule_sets" " WHERE name='%s'", rst), errbuf, &result)) @@ -369,7 +369,7 @@ int RuleManager::_FindOrCreateRuleset(Database *db, const char *ruleset) { res = GetRulesetID(db, ruleset); if(res >= 0) return(res); //found and existing one... - + uint32 len = strlen(ruleset); char* rst = new char[2*len+1]; db->DoEscapeString(rst, ruleset, len); @@ -377,7 +377,7 @@ int RuleManager::_FindOrCreateRuleset(Database *db, const char *ruleset) { uint32 new_id; char errbuf[MYSQL_ERRMSG_SIZE]; char* query = 0; - if (!db->RunQuery(query, MakeAnyLenString(&query, + if (!db->RunQuery(query, MakeAnyLenString(&query, "INSERT INTO rule_sets (ruleset_id, name) " " VALUES(0, '%s')", rst),errbuf,NULL,NULL,&new_id)) @@ -399,8 +399,8 @@ std::string RuleManager::GetRulesetName(Database *db, int id) { MYSQL_ROW row; std::string res; - - if (db->RunQuery(query, MakeAnyLenString(&query, + + if (db->RunQuery(query, MakeAnyLenString(&query, "SELECT name" " FROM rule_sets" " WHERE ruleset_id=%d", id), errbuf, &result)) @@ -425,8 +425,8 @@ bool RuleManager::ListRulesets(Database *db, std::map &into) { //start out with the default set which is always present. into[0] = "default"; - - if (db->RunQuery(query, MakeAnyLenString(&query, + + if (db->RunQuery(query, MakeAnyLenString(&query, "SELECT ruleset_id,name" " FROM rule_sets"), errbuf, &result)) { @@ -444,18 +444,18 @@ bool RuleManager::ListRulesets(Database *db, std::map &into) { } int32 RuleManager::GetIntRule(RuleManager::IntType t) const -{ - return(m_RuleIntValues[t]); +{ + return(m_RuleIntValues[t]); } float RuleManager::GetRealRule(RuleManager::RealType t) const -{ - return(m_RuleRealValues[t]); +{ + return(m_RuleRealValues[t]); } bool RuleManager::GetBoolRule(RuleManager::BoolType t) const -{ - return (m_RuleBoolValues[t] == 1); +{ + return (m_RuleBoolValues[t] == 1); } diff --git a/utils/azone2/azone.cpp b/utils/azone2/azone.cpp index cc9e854680..90a69997f0 100644 --- a/utils/azone2/azone.cpp +++ b/utils/azone2/azone.cpp @@ -2,10 +2,10 @@ Father Nitwit's Zone to map conversion program. Copyright (C) 2004 Father Nitwit (eqemu@8ass.com) - + This thing uses code from freaku, so whatever license that comes under is relavent, if you care. - + the rest of it is GPL, even though I hate the GPL. @@ -19,13 +19,13 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY except by those people which sell it, which are required to give you total support for your newly bought product; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -78,33 +78,33 @@ using namespace std; int main(int argc, char *argv[]) { printf("AZONE2: EQEmu .MAP file generator with placeable object support.\n"); - + if(argc != 2) { printf("Usage: %s (zone short name)\n", argv[0]); return(1); } - + char bufm[250]; - + sprintf(bufm, "%s.map", argv[1]); - + QTBuilder QT; - + if(!QT.build(argv[1])) return(1); - + if(!QT.writeMap(bufm)) return(1); - + return(0); } QTBuilder::QTBuilder() { _root = NULL; - + faceCount = 0; faceBlock = NULL; - + #ifdef COUNT_MACTHES gEasyMatches = 0; gEasyExcludes = 0; @@ -123,8 +123,8 @@ QTBuilder::~QTBuilder() { } bool QTBuilder::build(const char *shortname) { - - + + char bufs[96]; Archive *archive; FileLoader *fileloader; @@ -133,12 +133,12 @@ bool QTBuilder::build(const char *shortname) { EQFileType FileType = UNKNOWN; bool V4Zone = false; - + sprintf(bufs, "%s.s3d", shortname); archive = new PFSLoader(); fff = fopen(bufs, "rb"); - if(fff != NULL) + if(fff != NULL) FileType = S3D; else { sprintf(bufs, "%s.eqg", shortname); @@ -158,7 +158,7 @@ bool QTBuilder::build(const char *shortname) { } switch(FileType) { - case S3D: + case S3D: fileloader = new WLDLoader(); if(fileloader->Open(NULL, (char *) shortname, archive) == 0) { printf("Error reading WLD from %s\n", bufs); @@ -183,7 +183,7 @@ bool QTBuilder::build(const char *shortname) { } zm = fileloader->model_data.zone_model; - + long i; VERTEX v1, v2, v3; for(i = 0; i < zm->poly_count; ++i) { @@ -211,11 +211,11 @@ bool QTBuilder::build(const char *shortname) { v3.y = zm->verts[zm->polys[i]->v3]->y; #endif v3.z = zm->verts[zm->polys[i]->v3]->z; - + AddFace(v1, v2, v3); } - printf("There are %u vertices and %u faces.\n", _FaceList.size()*3, _FaceList.size()); + printf("There are %lu vertices and %lu faces.\n", _FaceList.size()*3, _FaceList.size()); if(fileloader->model_data.plac_count) { @@ -229,30 +229,30 @@ bool QTBuilder::build(const char *shortname) { else AddPlaceable(fileloader, bufs, false); } - else + else printf("No placeable objects (or perhaps %s_obj.s3d not present).\n", shortname); - - printf("After processing placeable objects, there are %u vertices and %u faces.\n", _FaceList.size()*3, _FaceList.size()); + + printf("After processing placeable objects, there are %lu vertices and %lu faces.\n", _FaceList.size()*3, _FaceList.size()); unsigned long r; - + faceCount = _FaceList.size(); - - - + + + faceBlock = new FACE[faceCount]; //im not going to assume I know vectors are stored in contiguous blocks for(r = 0; r < faceCount; r++) { faceBlock[r] = _FaceList[r]; } - + //build quad tree... prolly much slower than it needs to be. float minx, miny, maxx, maxy; minx = 1e12; miny = 1e12; maxx = -1e12; maxy = -1e12; - + //find our limits. for(r = 0; r < faceCount; r++) { //a bit of lazyness going on here... @@ -290,17 +290,17 @@ bool QTBuilder::build(const char *shortname) { miny = v.y; } } - + printf("Bounding box: %.2f < x < %.2f, %.2f < y < %.2f\n", minx, maxx, miny, maxy); printf("Building quadtree.\n"); - + _root = new QTNode(this, minx, maxx, miny, maxy); if(_root == NULL) { printf("Unable to allocate new QTNode.\n"); return(false); } - + //build our initial set of faces... all of them: FACE *faceptr = faceBlock; _root->faces.resize(faceCount); @@ -309,9 +309,9 @@ bool QTBuilder::build(const char *shortname) { _root->faces[r].index = r; faceptr++; } - + _root->divideYourself(0); - + printf("Done building quad tree...\n"); #ifdef COUNT_MACTHES @@ -334,39 +334,39 @@ bool QTBuilder::build(const char *shortname) { bool QTBuilder::writeMap(const char *file) { if(_root == NULL) return(false); - + printf("Writing map file.\n"); - + FILE *out = fopen(file, "wb"); if(out == NULL) { printf("Unable to open output file '%s'.\n", file); return(1); } - + mapHeader head; head.version = MAP_VERSION; head.face_count = faceCount; head.node_count = _root->countNodes(); head.facelist_count = _root->countFacelists(); - + if(fwrite(&head, sizeof(head), 1, out) != 1) { printf("Error writing map file header.\n"); fclose(out); return(1); - + } - + printf("Map header: Version: 0x%08lX. %lu faces, %u nodes, %lu facelists\n", head.version, head.face_count, head.node_count, head.facelist_count); - - + + //write faceBlock if(fwrite(faceBlock, sizeof(FACE), faceCount, out) != faceCount) { printf("Error writing map file faces.\n"); fclose(out); return(1); } - + //make our node blocks to write out... nodeHeader *nodes = new nodeHeader[head.node_count]; unsigned long *facelist = new unsigned long[head.facelist_count]; @@ -375,11 +375,11 @@ bool QTBuilder::writeMap(const char *file) { fclose(out); return(1); //no memory } - + unsigned long hindex = 0; unsigned long findex = 0; _root->fillBlocks(nodes, facelist, hindex, findex); - + if(fwrite(nodes, sizeof(nodeHeader), head.node_count, out) != head.node_count) { printf("Error writing map file nodes.\n"); fclose(out); @@ -390,15 +390,15 @@ bool QTBuilder::writeMap(const char *file) { fclose(out); return(1); } - + long MapFileSize = ftell(out); fclose(out); delete[] nodes; delete[] facelist; - + printf("Done writing map (%3.2fMB).\n", (float)MapFileSize/1048576); - + return(0); } @@ -414,7 +414,7 @@ QTNode::QTNode(QTBuilder *b, float Tminx, float Tmaxx, float Tminy, float Tmaxy) maxy = Tmaxy; final = false; buildVertexes(); - + builder = b; } @@ -441,7 +441,7 @@ void QTNode::clearNodes() { void QTNode::fillBlocks(nodeHeader *heads, unsigned long *flist, unsigned long &hindex, unsigned long &findex) { nodeHeader *head = &heads[hindex]; hindex++; - + head->minx = minx; head->maxx = maxx; head->miny = miny; @@ -462,7 +462,7 @@ void QTNode::fillBlocks(nodeHeader *heads, unsigned long *flist, unsigned long & } else { //branch node. head->flags = 0; - + if(node1 != NULL) { head->nodes[0] = hindex; node1->fillBlocks(heads, flist, hindex, findex); @@ -523,54 +523,54 @@ Map Format: head.face_count x FACE head.node_count x nodeHeader head.facelist_count x unsigned long (indexes into face array) - - + + */ void QTNode::divideYourself(int depth) { -// printf("Dividing in box (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d faces.\n", +// printf("Dividing in box (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d faces.\n", // minx, maxx, miny, maxy, depth, faces.size()); - + unsigned long cc; cc = faces.size(); #ifdef MAX_QUADRENT_FACES if(cc <= MAX_QUADRENT_FACES) { #ifdef SPLIT_DEBUG -printf("Stopping (facecount) on box (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d faces.\n", +printf("Stopping (facecount) on box (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d faces.\n", minx, maxx, miny, maxy, depth, cc); #endif final = true; return; } #endif - + #ifdef MIN_QUADRENT_SIZE if((maxx - minx) < MIN_QUADRENT_SIZE || (maxy - miny) < MIN_QUADRENT_SIZE) { #ifdef SPLIT_DEBUG -printf("Stopping on box (size) (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d faces.\n", +printf("Stopping on box (size) (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d faces.\n", minx, maxx, miny, maxy, depth, cc); #endif final = true; return; } #endif - + doSplit(); - + //get counts on our split float c1, c2, c3, c4; c1 = node1? node1->faces.size() : 0; c2 = node2? node2->faces.size() : 0; c3 = node3? node3->faces.size() : 0; c4 = node4? node4->faces.size() : 0; - + #ifdef MIN_QUADRENT_GAIN int miss = 0; float gain1 = 1.0 - c1 / cc; float gain2 = 1.0 - c2 / cc; float gain3 = 1.0 - c3 / cc; float gain4 = 1.0 - c4 / cc; - + //see how many missed the gain mark if(gain1 < MIN_QUADRENT_GAIN) miss++; @@ -580,33 +580,33 @@ printf("Stopping on box (size) (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d miss++; if(gain4 < MIN_QUADRENT_GAIN) miss++; - + if(miss > MAX_QUADRENT_MISSES) { #ifdef SPLIT_DEBUG -printf("Stopping (gain) on box (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d faces.\n", +printf("Stopping (gain) on box (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d faces.\n", minx, maxx, miny, maxy, depth, cc); #endif final = true; return; } #endif - - + + //if all faces pass through all quadrents, then we are done //partially obsoleted by gain test. if(c1 == c2 && c1 == c3 && c1 == c4) { #ifdef SPLIT_DEBUG -printf("Stopping (empty) on box (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d faces.\n", +printf("Stopping (empty) on box (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d faces.\n", minx, maxx, miny, maxy, depth, cc); #endif final = true; return; } - + //there are prolly some more intelligent stopping criteria... - + depth++; - + if(node1 != NULL) node1->divideYourself(depth); if(node2 != NULL) @@ -615,18 +615,18 @@ printf("Stopping (empty) on box (%.2f -> %.2f, %.2f -> %.2f) at depth %d with %d node3->divideYourself(depth); if(node4 != NULL) node4->divideYourself(depth); - - + + } void QTNode::buildVertexes() { v[0].x = v[1].x = v[2].x = v[3].x = minx; v[4].x = v[5].x = v[6].x = v[7].x = maxx; - + v[0].y = v[1].y = v[4].y = v[5].y = miny; v[2].y = v[3].y = v[6].y = v[7].y = maxy; - + v[0].z = v[3].z = v[4].z = v[7].z = -999999; v[1].z = v[2].z = v[5].z = v[6].z = 9999999; } @@ -677,7 +677,7 @@ bool edges_cross(GPoint *pt1, GPoint *pt2, const VERTEX *pt3, const VERTEX *pt4) (p2->x > p1->x? \ (p1->z + ((inter - p1->x)/(p2->x - p1->x) * (p2->z - p1->z))) \ :(p2->z + ((inter - p2->x)/(p1->x - p2->x) * (p1->z - p2->z)))) - + float denom = IntersectDenom(pt1, pt2, pt3, pt4); if(denom != 0) { @@ -746,25 +746,25 @@ bool QTBuilder::FaceInNode(const QTNode *q, const FACE *f) { const VERTEX *v1 = &f->a; const VERTEX *v2 = &f->b; const VERTEX *v3 = &f->c; - + #ifdef COUNT_MACTHES gEasyMatches++; #endif //Easy matches, points are within the quadrant. - if( ! ( v1->x <= q->minx || v1->x > q->maxx + if( ! ( v1->x <= q->minx || v1->x > q->maxx || v1->y <= q->miny || v1->y > q->maxy ) ) { return(true); } - if( ! ( v2->x <= q->minx || v2->x > q->maxx + if( ! ( v2->x <= q->minx || v2->x > q->maxx || v2->y <= q->miny || v2->y > q->maxy ) ) { return(true); } - if( ! ( v3->x <= q->minx || v3->x > q->maxx + if( ! ( v3->x <= q->minx || v3->x > q->maxx || v3->y <= q->miny || v3->y > q->maxy ) ) { return(true); } - + #ifdef COUNT_MACTHES gEasyMatches--; gEasyExcludes++; @@ -779,41 +779,41 @@ bool QTBuilder::FaceInNode(const QTNode *q, const FACE *f) { return(false); if( v1->y > q->maxy && v2->y > q->maxy && v3->y > q->maxy ) return(false); - - + + #ifdef COUNT_MACTHES gEasyExcludes--; #endif - + #ifdef COUNT_MACTHES gHardMatches++; #endif // return(true); - + //harder: no points are in the cube - + //4 points of this node GPoint pt1(q->minx, q->miny, 0), pt2(q->minx, q->maxy, 0), pt3(q->maxx, q->miny, 0), pt4(q->maxx, q->maxy, 0); - + /* //box lines: pt1, pt2 pt3, pt4 pt1, pt3 pt2, pt4 - + //tri lines v1, v2 v1, v3 v2, v3 */ - + #define CheckIntersect(p1, p2, p3, p4) \ (((p4->y - p3->y)*(p2.x - p1.x) - (p4->x - p3->x)*(p2.y - p1.y)) != 0) - + int finaltest = (edges_cross(&pt1, &pt2, v1, v2) || edges_cross(&pt1, &pt2, v1, v3) @@ -829,7 +829,7 @@ bool QTBuilder::FaceInNode(const QTNode *q, const FACE *f) { || edges_cross(&pt2, &pt4, v2, v3)); if(finaltest) return finaltest; - + VERTEX Triangle[3]; Triangle[0]=*v1; Triangle[1]=*v2; Triangle[2] = *v3; finaltest = PointInTriangle(Triangle, q->minx, q->miny) || @@ -843,12 +843,12 @@ bool QTBuilder::FaceInNode(const QTNode *q, const FACE *f) { void QTNode::doSplit() { - - + + //find midpoints... float midx = minx + (maxx - minx) / 2.0; float midy = miny + (maxy - miny) / 2.0; - + //ordering following definitions in map.h node1 = new QTNode(builder, midx, maxx, midy, maxy); node2 = new QTNode(builder, minx, midx, midy, maxy); @@ -858,7 +858,7 @@ void QTNode::doSplit() { printf("Error: unable to allocate new QTNode, giving up.\n"); return; } - + unsigned long r,l; l = faces.size(); for(r = 0; r < l; r++) { @@ -872,7 +872,7 @@ void QTNode::doSplit() { if(builder->FaceInNode(node4, cur.face)) node4->faces.push_back(cur); } - + //clean up empty sets. if(node1->faces.size() == 0) { delete node1; @@ -890,29 +890,29 @@ void QTNode::doSplit() { delete node4; node4 = NULL; } - + } void QTBuilder::AddFace(VERTEX &v1, VERTEX &v2, VERTEX &v3) { FACE f; - + #ifdef MAX_Z if(v1.z > MAX_Z && v2.z > MAX_Z && v3.z > MAX_Z) return; #endif - - + + //this still might not work f.nx = (v2.y - v1.y)*(v3.z - v1.z) - (v2.z - v1.z)*(v3.y - v1.y); f.ny = (v2.z - v1.z)*(v3.x - v1.x) - (v2.x - v1.x)*(v3.z - v1.z); f.nz = (v2.x - v1.x)*(v3.y - v1.y) - (v2.y - v1.y)*(v3.x - v1.x); NormalizeN(&f); f.nd = - f.nx * v1.x - f.ny * v1.y - f.nz * v1.z; - + f.a = v1; f.b = v2; f.c = v3; - + _FaceList.push_back(f); } @@ -989,75 +989,75 @@ void GVector::normalize() { } //stolen from: http://gamecode.tripod.com/tut/tut04.htm -int QTBuilder::ClipPolygon(POLYGON *poly, GVector *plane) { +int QTBuilder::ClipPolygon(POLYGON *poly, GVector *plane) { /* Plan: cycle through the vertices, considering pairs of them. If both vertices are visible, add them to the new array. If both vertices are invisible, add neither to the new array. If one vertex is visible and the other is not, move the one that's not, and then add both vertices to the new array. */ - float dist1, dist2; // distances of points to plane - float distratio; // fraction of distance between two points - // new vertices might be created. Don't change - // polygon's vertices because we might still need - // them. Instead, use tempvtx array and update vertices + float dist1, dist2; // distances of points to plane + float distratio; // fraction of distance between two points + // new vertices might be created. Don't change + // polygon's vertices because we might still need + // them. Instead, use tempvtx array and update vertices // array at the end. Create tempvtx array once only. - int i, ii, j=0; + int i, ii, j=0; - /* Check if plane is a valid plane */ - if (!(plane->x || plane->y || plane->z)) return -1; - // if not valid plane, don't change polygon and return an error; + /* Check if plane is a valid plane */ + if (!(plane->x || plane->y || plane->z)) return -1; + // if not valid plane, don't change polygon and return an error; - /* The vertices should, as for all functions, be arranged in cyclic - order. That is, if a line was drawn from each vertex to the next - it would form the correct outline of the polygon in 3D space. - This routine might create new vertices because of the clipping, - but the cyclic order will be preserved. - */ + /* The vertices should, as for all functions, be arranged in cyclic + order. That is, if a line was drawn from each vertex to the next + it would form the correct outline of the polygon in 3D space. + This routine might create new vertices because of the clipping, + but the cyclic order will be preserved. + */ - for (i=0; icount; i++) - { + for (i=0; icount; i++) + { ii = (i+1)%poly->count; - dist1 = plane->x * poly->c[i].x + plane->y * poly->c[i].y + - plane->z * poly->c[i].z + plane->W; - dist2 = plane->x * poly->c[ii].x + plane->y * poly->c[ii].y + - plane->z * poly->c[ii].z + plane->W; - if (dist1<0 && dist2<0) // line unclipped and invisible + dist1 = plane->x * poly->c[i].x + plane->y * poly->c[i].y + + plane->z * poly->c[i].z + plane->W; + dist2 = plane->x * poly->c[ii].x + plane->y * poly->c[ii].y + + plane->z * poly->c[ii].z + plane->W; + if (dist1<0 && dist2<0) // line unclipped and invisible continue; if (dist1>0 && dist2>0) // line unclipped and visible tempvtx[j++]=poly->c[i]; - else // line partially visible - if (dist1>0) // first vertex is visible - { - distratio = dist1/(dist1-dist2); + else // line partially visible + if (dist1>0) // first vertex is visible + { + distratio = dist1/(dist1-dist2); tempvtx[j] = poly->c[i]; j++; // Copied 1st vertex - tempvtx[j].x = poly->c[i].x + - (poly->c[ii].x - poly->c[i].x) * distratio; - tempvtx[j].y = poly->c[i].y + - (poly->c[ii].y - poly->c[i].y) * distratio; - tempvtx[j].z = poly->c[i].z + + tempvtx[j].x = poly->c[i].x + + (poly->c[ii].x - poly->c[i].x) * distratio; + tempvtx[j].y = poly->c[i].y + + (poly->c[ii].y - poly->c[i].y) * distratio; + tempvtx[j].z = poly->c[i].z + (poly->c[ii].z - poly->c[i].z) * distratio; j++; // Copied second vertex - } - else // second vertex is visible - { - distratio = dist2/(dist2-dist1); - tempvtx[j].x = poly->c[ii].x + - (poly->c[i].x - poly->c[ii].x) * distratio; - tempvtx[j].y = poly->c[ii].y + - (poly->c[i].y - poly->c[ii].y) * distratio; - tempvtx[j].z = poly->c[ii].z + - (poly->c[i].z - poly->c[ii].z) * distratio; + } + else // second vertex is visible + { + distratio = dist2/(dist2-dist1); + tempvtx[j].x = poly->c[ii].x + + (poly->c[i].x - poly->c[ii].x) * distratio; + tempvtx[j].y = poly->c[ii].y + + (poly->c[i].y - poly->c[ii].y) * distratio; + tempvtx[j].z = poly->c[ii].z + + (poly->c[i].z - poly->c[ii].z) * distratio; j++; // Copy only first vertex. 2nd vertex will be copied // in next iteration of loop } - } + } - for (i=0; ic[i] = tempvtx[i]; // Update the vertices in polygon poly->count = j; // Update the vertex count - return j; + return j; } @@ -1160,7 +1160,7 @@ void QTBuilder::AddPlaceable(FileLoader *fileloader, char *ZoneFileName, bool Li continue; } IniBuffer[StrIndex++] = tolower(ch); - } + } fclose(IniFile); if(INIEntryFound) { @@ -1173,7 +1173,7 @@ void QTBuilder::AddPlaceable(FileLoader *fileloader, char *ZoneFileName, bool Li else { printf("No azone.ini entry found for zone %s\n", ZoneFileName); } - + for(int i = 0; i < fileloader->model_data.plac_count; ++i) { @@ -1186,9 +1186,9 @@ void QTBuilder::AddPlaceable(FileLoader *fileloader, char *ZoneFileName, bool Li fileloader->model_data.placeable[i]->x, fileloader->model_data.placeable[i]->z, fileloader->model_data.placeable[i]->model, - fileloader->model_data.models[fileloader->model_data.placeable[i]->model]->name); + fileloader->model_data.models[fileloader->model_data.placeable[i]->model]->name); + - if(!fileloader->model_data.models[fileloader->model_data.placeable[i]->model]->IncludeInMap) continue; printf("Including Placeable Object %4d using model %4d (%s).\n", i, @@ -1212,11 +1212,11 @@ void QTBuilder::AddPlaceable(FileLoader *fileloader, char *ZoneFileName, bool Li Model *model = fileloader->model_data.models[fileloader->model_data.placeable[i]->model]; - + for(int j = 0; j < model->poly_count; ++j) { poly = model->polys[j]; - + verts[0] = model->verts[poly->v1]; verts[1] = model->verts[poly->v2]; verts[2] = model->verts[poly->v3]; @@ -1234,22 +1234,22 @@ void QTBuilder::AddPlaceable(FileLoader *fileloader, char *ZoneFileName, bool Li ScaleVertex(v2, XScale, YScale, ZScale); ScaleVertex(v3, XScale, YScale, ZScale); - TranslateVertex(v1, XOffset, YOffset, ZOffset); - TranslateVertex(v2, XOffset, YOffset, ZOffset); - TranslateVertex(v3, XOffset, YOffset, ZOffset); + TranslateVertex(v1, XOffset, YOffset, ZOffset); + TranslateVertex(v2, XOffset, YOffset, ZOffset); + TranslateVertex(v3, XOffset, YOffset, ZOffset); // Swap X & Y // - tmpv = v1; v1.x = tmpv.y; v1.y = tmpv.x; + tmpv = v1; v1.x = tmpv.y; v1.y = tmpv.x; tmpv = v2; v2.x = tmpv.y; v2.y = tmpv.x; tmpv = v3; v3.x = tmpv.y; v3.y = tmpv.x; AddFace(v1, v2, v3); } } -} - +} + void QTBuilder::AddPlaceableV4(FileLoader *fileloader, char *ZoneFileName, bool ListPlaceable) { Polygon *poly; @@ -1262,7 +1262,7 @@ void QTBuilder::AddPlaceableV4(FileLoader *fileloader, char *ZoneFileName, bool //return; printf("EQG V4 Placeable Zone Support\n"); - printf("ObjectGroupCount = %i\n", fileloader->model_data.ObjectGroups.size()); + printf("ObjectGroupCount = %lu\n", fileloader->model_data.ObjectGroups.size()); vector::iterator Iterator; @@ -1302,7 +1302,7 @@ void QTBuilder::AddPlaceableV4(FileLoader *fileloader, char *ZoneFileName, bool if((ch=='#')&&(StrIndex==0)) { // Discard comment lines beginning with a hash while((ch!=EOF)&&(ch!='\n')) ch = fgetc(IniFile); - + continue; } if((ch=='\n') && (State==ReadingZoneName)) { @@ -1337,7 +1337,7 @@ void QTBuilder::AddPlaceableV4(FileLoader *fileloader, char *ZoneFileName, bool { if((ModelNumber >= 0) && ((unsigned int)ModelNumber < fileloader->model_data.ObjectGroups.size())) fileloader->model_data.ObjectGroups[ModelNumber].IncludeInMap = Exclude ? false : true; - + } } break; @@ -1383,13 +1383,13 @@ void QTBuilder::AddPlaceableV4(FileLoader *fileloader, char *ZoneFileName, bool { if((ModelNumber >= 0) && ((unsigned int)ModelNumber < fileloader->model_data.ObjectGroups.size())) fileloader->model_data.ObjectGroups[ModelNumber].IncludeInMap = Exclude ? false : true; - + } } continue; } IniBuffer[StrIndex++] = tolower(ch); - } + } fclose(IniFile); if(INIEntryFound) @@ -1397,7 +1397,7 @@ void QTBuilder::AddPlaceableV4(FileLoader *fileloader, char *ZoneFileName, bool else printf("No azone.ini entry found for zone %s\n", ZoneFileName); } - + Iterator = fileloader->model_data.ObjectGroups.begin(); while(Iterator != fileloader->model_data.ObjectGroups.end()) @@ -1429,11 +1429,11 @@ void QTBuilder::AddPlaceableV4(FileLoader *fileloader, char *ZoneFileName, bool list::iterator ModelIterator; ModelIterator = (*Iterator).SubObjects.begin(); - + while(ModelIterator != (*Iterator).SubObjects.end()) { int SubModel = (*ModelIterator); - + #ifdef DEBUG printf(" SubModel: %i\n", (*ModelIterator)); #endif @@ -1519,8 +1519,8 @@ void QTBuilder::AddPlaceableV4(FileLoader *fileloader, char *ZoneFileName, bool RotateVertex(v1, RotX, 0, 0); RotateVertex(v2, RotX, 0, 0); RotateVertex(v3, RotX, 0, 0); - - // Don't know why the Y rotation needs to be negative + + // Don't know why the Y rotation needs to be negative // RotateVertex(v1, 0, -RotY, 0); RotateVertex(v2, 0, -RotY, 0); @@ -1556,12 +1556,12 @@ void QTBuilder::AddPlaceableV4(FileLoader *fileloader, char *ZoneFileName, bool TranslateVertex(v3, (*Iterator).x, (*Iterator).y, (*Iterator).z); // Swap X & Y // - tmpv = v1; v1.x = tmpv.y; v1.y = tmpv.x; + tmpv = v1; v1.x = tmpv.y; v1.y = tmpv.x; tmpv = v2; v2.x = tmpv.y; v2.y = tmpv.x; tmpv = v3; v3.x = tmpv.y; v3.y = tmpv.x; AddFace(v1, v2, v3); - + } ++ModelIterator; } @@ -1619,5 +1619,5 @@ void QTBuilder::TranslateVertex(VERTEX &v, float XOffset, float YOffset, float Z - + diff --git a/world/EQLConfig.cpp b/world/EQLConfig.cpp index 7c94085bf8..7375bd65e7 100644 --- a/world/EQLConfig.cpp +++ b/world/EQLConfig.cpp @@ -4,13 +4,13 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY except by those people which sell it, which are required to give you total support for your newly bought product; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -38,11 +38,11 @@ void EQLConfig::LoadSettings() { MYSQL_RES *result; MYSQL_ROW row; LauncherZone tmp; - + char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; - + if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT dynamics FROM launcher WHERE name='%s'", namebuf) @@ -56,7 +56,7 @@ void EQLConfig::LoadSettings() { LogFile->write(EQEMuLog::Error, "EQLConfig::LoadSettings: %s", errbuf); } safe_delete_array(query); - + if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT zone,port FROM launcher_zones WHERE launcher='%s'", namebuf) @@ -78,20 +78,20 @@ void EQLConfig::LoadSettings() { EQLConfig *EQLConfig::CreateLauncher(const char *name, uint8 dynamic_count) { char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; - + char namebuf[128]; database.DoEscapeString(namebuf, name, strlen(name)&0x3F); //limit len to 64 namebuf[127] = '\0'; - + if (!database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO launcher (name,dynamics) VALUES('%s', %d)", namebuf, dynamic_count), errbuf)) { LogFile->write(EQEMuLog::Error, "Error in CreateLauncher query: %s", errbuf); safe_delete_array(query); - return false; + return NULL; } safe_delete_array(query); - + return(new EQLConfig(name)); } @@ -123,27 +123,27 @@ vector EQLConfig::ListZones() { } void EQLConfig::DeleteLauncher() { - + launcher_list.Remove(m_name.c_str()); - + char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; - + char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; - - if (!database.RunQuery(query, MakeAnyLenString(&query, - "DELETE FROM launcher WHERE name='%s'", + + if (!database.RunQuery(query, MakeAnyLenString(&query, + "DELETE FROM launcher WHERE name='%s'", namebuf), errbuf)) { LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 1 query: %s", errbuf); safe_delete_array(query); return; } safe_delete_array(query); - - if (!database.RunQuery(query, MakeAnyLenString(&query, - "DELETE FROM launcher_zones WHERE launcher='%s'", + + if (!database.RunQuery(query, MakeAnyLenString(&query, + "DELETE FROM launcher_zones WHERE launcher='%s'", namebuf), errbuf)) { LogFile->write(EQEMuLog::Error, "Error in DeleteLauncher 2 query: %s", errbuf); safe_delete_array(query); @@ -182,18 +182,18 @@ bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) { //make sure the short name is valid. if(database.GetZoneID(short_name) == 0) return(false); - + //database update char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; - + char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; char zonebuf[32]; database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16 zonebuf[31] = '\0'; - + if (!database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO launcher_zones (launcher,zone,port) VALUES('%s', '%s', %d)", namebuf, zonebuf, port), errbuf)) { @@ -202,19 +202,19 @@ bool EQLConfig::BootStaticZone(Const_char *short_name, uint16 port) { return false; } safe_delete_array(query); - + //update our internal state. LauncherZone lz; lz.name = short_name; lz.port = port; m_zones[lz.name] = lz; - + //if the launcher is connected, update it. LauncherLink *ll = launcher_list.Get(m_name.c_str()); if(ll != NULL) { ll->BootZone(short_name, port); } - + return(true); } @@ -222,7 +222,7 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) { //make sure the short name is valid. if(database.GetZoneID(short_name) == 0) return(false); - + //check internal state map::iterator res; res = m_zones.find(short_name); @@ -231,19 +231,19 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) { LogFile->write(EQEMuLog::Error, "Update for unknown zone %s", short_name); return(false); } - - + + //database update char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; - + char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; char zonebuf[32]; database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16 zonebuf[31] = '\0'; - + if (!database.RunQuery(query, MakeAnyLenString(&query, "UPDATE launcher_zones SET port=%d WHERE launcher='%s' AND zone='%s'", port, namebuf, zonebuf), errbuf)) { @@ -252,17 +252,17 @@ bool EQLConfig::ChangeStaticZone(Const_char *short_name, uint16 port) { return false; } safe_delete_array(query); - - + + //update internal state res->second.port = port; - + //if the launcher is connected, update it. LauncherLink *ll = launcher_list.Get(m_name.c_str()); if(ll != NULL) { ll->RestartZone(short_name); } - + return(true); } @@ -275,47 +275,47 @@ bool EQLConfig::DeleteStaticZone(Const_char *short_name) { LogFile->write(EQEMuLog::Error, "Update for unknown zone %s", short_name); return(false); } - + //database update char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; - + char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; char zonebuf[32]; database.DoEscapeString(zonebuf, short_name, strlen(short_name)&0xF); //limit len to 16 zonebuf[31] = '\0'; - - if (!database.RunQuery(query, MakeAnyLenString(&query, - "DELETE FROM launcher_zones WHERE launcher='%s' AND zone='%s'", + + if (!database.RunQuery(query, MakeAnyLenString(&query, + "DELETE FROM launcher_zones WHERE launcher='%s' AND zone='%s'", namebuf, zonebuf), errbuf)) { LogFile->write(EQEMuLog::Error, "Error in DeleteStaticZone query: %s", errbuf); safe_delete_array(query); return false; } safe_delete_array(query); - + //internal update. m_zones.erase(res); - + //if the launcher is connected, update it. LauncherLink *ll = launcher_list.Get(m_name.c_str()); if(ll != NULL) { ll->StopZone(short_name); } - + return true; } bool EQLConfig::SetDynamicCount(int count) { char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; - + char namebuf[128]; database.DoEscapeString(namebuf, m_name.c_str(), m_name.length()&0x3F); //limit len to 64 namebuf[127] = '\0'; - + if (!database.RunQuery(query, MakeAnyLenString(&query, "UPDATE launcher SET dynamics=%d WHERE name='%s'", count, namebuf), errbuf)) { @@ -324,16 +324,16 @@ bool EQLConfig::SetDynamicCount(int count) { return false; } safe_delete_array(query); - + //update in-memory version. m_dynamics = count; - + //if the launcher is connected, update it. LauncherLink *ll = launcher_list.Get(m_name.c_str()); if(ll != NULL) { ll->BootDynamics(count); } - + return(false); } @@ -343,7 +343,7 @@ int EQLConfig::GetDynamicCount() const { map EQLConfig::GetZoneDetails(Const_char *zone_ref) { map res; - + LauncherLink *ll = launcher_list.Get(m_name.c_str()); if(ll == NULL) { res["name"] = zone_ref; @@ -353,7 +353,7 @@ map EQLConfig::GetZoneDetails(Const_char *zone_ref) { } else { ll->GetZoneDetails(zone_ref, res); } - + return(res); } From 0c6eee6d81548eed03be42395403d28bd5f9019a Mon Sep 17 00:00:00 2001 From: Arthur Ice Date: Sun, 3 Mar 2013 21:45:46 -0800 Subject: [PATCH 3/3] More warning clean ups (NULL to 0 on int, sprintf flags, typedef on enum) --- zone/bot.cpp | 1336 ++++++++++++++++++++-------------------- zone/bot.h | 20 +- zone/client_packet.cpp | 460 +++++++------- zone/merc.cpp | 8 +- 4 files changed, 912 insertions(+), 912 deletions(-) diff --git a/zone/bot.cpp b/zone/bot.cpp index 17bdc2caef..51b649bce5 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -45,7 +45,7 @@ Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, 0, 0, 0, 0, RestRegenHP = 0; RestRegenMana = 0; RestRegenEndurance = 0; - + SetBotID(0); SetBotSpellID(0); SetSpawnStatus(false); @@ -90,7 +90,7 @@ Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, 0, 0, 0, 0, } for(int i = 0; i < MaxHealRotationTargets; i++) { - _healRotationTargets[i] = 0; + _healRotationTargets[i] = 0; } strcpy(this->name, this->GetCleanName()); @@ -131,7 +131,7 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to _baseGender = npcTypeData.gender; cur_hp = npcTypeData.cur_hp; cur_mana = npcTypeData.Mana; - + RestRegenHP = 0; RestRegenMana = 0; RestRegenEndurance = 0; @@ -183,11 +183,11 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to } for(int i = 0; i < MaxHealRotationTargets; i++) { - _healRotationTargets[i] = 0; + _healRotationTargets[i] = 0; } GenerateBaseStats(); - + LoadTimers(); LoadAAs(); LoadBuffs(); @@ -241,11 +241,11 @@ uint32 Bot::GetBotArcheryRange() { return 0; const Item_Struct* botweapon = rangeItem->GetItem(); - + uint32 archeryMaterial; uint32 archeryColor; uint32 archeryBowID; - uint32 archeryAmmoID; + uint32 archeryAmmoID; if(botweapon && botweapon->ItemType == ItemTypeBow) { uint32 range = 0; @@ -264,7 +264,7 @@ uint32 Bot::GetBotArcheryRange() { } range += botweapon->Range; - + archeryAmmoID = botweapon->ID; result = range; @@ -275,10 +275,10 @@ uint32 Bot::GetBotArcheryRange() { void Bot::ChangeBotArcherWeapons(bool isArcher) { if((GetClass()==WARRIOR) || (GetClass()==PALADIN) || (GetClass()==RANGER) - || (GetClass()==SHADOWKNIGHT) || (GetClass()==ROGUE)) + || (GetClass()==SHADOWKNIGHT) || (GetClass()==ROGUE)) { if(!isArcher) { - BotAddEquipItem(SLOT_PRIMARY, GetBotItemBySlot(SLOT_PRIMARY)); + BotAddEquipItem(SLOT_PRIMARY, GetBotItemBySlot(SLOT_PRIMARY)); BotAddEquipItem(SLOT_SECONDARY, GetBotItemBySlot(SLOT_SECONDARY)); //archerbot->SendWearChange(MATERIAL_PRIMARY); //archerbot->SendWearChange(MATERIAL_SECONDARY); @@ -982,7 +982,7 @@ int16 Bot::acmod() return 27; else if(level <= 39) return 37; - else + else return 44; } else if(agility == 100 && level >= 7) @@ -1364,7 +1364,7 @@ uint16 Bot::GetTotalATK() } else AttackRating = GetATK(); - + AttackRating += spellbonuses.ATK; return AttackRating; @@ -1441,14 +1441,14 @@ void Bot::GenerateAABonuses(StatBonuses* newbon) { if(botLevel >= 51) { //level 51 = 1 AA level - + int i; int totalAAs = database.CountAAs(); uint32 slots = 0; uint32 aa_AA = 0; uint32 aa_value = 0; for (i = 0; i < totalAAs; i++) { //iterate through all of the client's AAs - std::map::iterator aa = botAAs.find(i); + std::map::iterator aa = botAAs.find(i); if(aa != botAAs.end()) { // make sure aa exists or we'll crash zone aa_AA = aa->second.aa_id; //same as aaid from the aa_effects table aa_value = aa->second.total_levels; //how many points in it @@ -1470,7 +1470,7 @@ void Bot::LoadAAs() { char TempErrorMessageBuffer[MYSQL_ERRMSG_SIZE]; MYSQL_RES* DatasetResult; MYSQL_ROW DataRow; - + int maxAAExpansion = RuleI(Bots, BotAAExpansion); //get expansion to get AAs up to botAAs.clear(); //start fresh @@ -1491,7 +1491,7 @@ void Bot::LoadAAs() { if(skill_id > 0 && skill_id < totalAAs) { SendAA_Struct *sendAA = zone->FindAA(skill_id); - + if(sendAA) { for(int i=0; imax_level; i++) { //Get AA info & add to list @@ -1499,34 +1499,34 @@ void Bot::LoadAAs() { uint8 total_levels = 0; uint8 req_level; std::map::iterator RequiredLevel = AARequiredLevelAndCost.find(aaid); - + //Get level required for AA if(RequiredLevel != AARequiredLevelAndCost.end()) req_level = RequiredLevel->second.Level; else req_level = (sendAA->class_type + i * sendAA->level_inc); - if(req_level > GetLevel()) + if(req_level > GetLevel()) break; - + //Bot is high enough level for AA std::map::iterator foundAA = botAAs.find(aaid); - + // AA is not already in list if(foundAA == botAAs.end()) { if(sendAA->id == aaid) { BotAA newAA; - + newAA.total_levels = 0; newAA.aa_id = aaid; newAA.req_level = req_level; newAA.total_levels += 1; - + botAAs[aaid] = newAA; //add to list } else { //update master AA record with number of levels a bot has in AA, based on level. - botAAs[sendAA->id].total_levels+=1; + botAAs[sendAA->id].total_levels+=1; } } } @@ -1549,16 +1549,16 @@ uint32 Bot::GetAA(uint32 aa_id) { std::map::const_iterator find_iter = botAAs.find(aa_id); int aaLevel = 0; - + if(find_iter != botAAs.end()) { aaLevel = find_iter->second.total_levels; } - + return aaLevel; } //current with Client::ApplyAABonuses 9/26/12 -void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) +void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) { if(slots == 0) //sanity check. why bother if no slots to fill? return; @@ -1610,7 +1610,7 @@ void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) case SE_CurrentHP: //regens newbon->HPRegen += base1; break; - case SE_CurrentEndurance: + case SE_CurrentEndurance: newbon->EnduranceRegen += base1; break; case SE_MovementSpeed: @@ -1763,7 +1763,7 @@ void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) newbon->SkillReuseTime[base2] += base1; break; case SE_Fearless: - newbon->Fearless = true; + newbon->Fearless = true; break; case SE_PersistantCasting: newbon->PersistantCasting += base1; @@ -1787,7 +1787,7 @@ void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) newbon->SeeInvis = base1; break; case SE_BaseMovementSpeed: - newbon->BaseMovementSpeed += base1; + newbon->BaseMovementSpeed += base1; break; case SE_IncreaseRunSpeedCap: newbon->IncreaseRunSpeedCap += base1; @@ -1906,7 +1906,7 @@ void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) //base1 = chance, base2 = SpellID to be triggered, base3 = min npc level newbon->SpellOnKill[i] = base2; newbon->SpellOnKill[i+1] = base1; - + if (GetLevel() > 15) newbon->SpellOnKill[i+2] = GetLevel() - 15; //AA specifiy "non-trivial" else @@ -1916,7 +1916,7 @@ void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) } } break; - + case SE_SpellOnDeath: for(int i = 0; i < MAX_SPELL_TRIGGER*2; i+=2) { @@ -1931,7 +1931,7 @@ void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) break; case SE_TriggerOnCast: - + for(int i = 0; i < MAX_SPELL_TRIGGER; i++) { if (newbon->SpellTriggers[i] == aaid) @@ -1945,7 +1945,7 @@ void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) } } break; - + case SE_CriticalHitChance: { if(base2 == -1) @@ -1968,10 +1968,10 @@ void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) case SE_CriticalSpellChance: { newbon->CriticalSpellChance += base1; - + if (base2 > 100) newbon->SpellCritDmgIncrease += (base2 - 100); - + break; } @@ -1979,7 +1979,7 @@ void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) { if(base1 == 100) // If we reach 100% in a single spell/item then we should be immune to negative fear resist effects until our immunity is over newbon->Fearless = true; - + newbon->ResistFearChance += base1; // these should stack break; } @@ -2094,7 +2094,7 @@ void Bot::ApplyAABonuses(uint32 aaid, uint32 slots, StatBonuses* newbon) case SE_FinishingBlow: { - + //base1 = chance, base2 = damage if (newbon->FinishingBlow[1] < base2){ newbon->FinishingBlow[0] = base1; @@ -2474,15 +2474,15 @@ void Bot::SaveBuffs() { if(!database.RunQuery(Query, MakeAnyLenString(&Query, "INSERT INTO botbuffs (BotId, SpellId, CasterLevel, DurationFormula, " "TicsRemaining, PoisonCounters, DiseaseCounters, CurseCounters, CorruptionCounters, HitCount, MeleeRune, MagicRune, " - "DeathSaveSuccessChance, CasterAARank, Persistent) VALUES (%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u);", - GetBotID(), buffs[BuffCount].spellid, buffs[BuffCount].casterlevel, spells[buffs[BuffCount].spellid].buffdurationformula, - buffs[BuffCount].ticsremaining, - CalculatePoisonCounters(buffs[BuffCount].spellid) > 0 ? buffs[BuffCount].counters : 0, - CalculateDiseaseCounters(buffs[BuffCount].spellid) > 0 ? buffs[BuffCount].counters : 0, - CalculateCurseCounters(buffs[BuffCount].spellid) > 0 ? buffs[BuffCount].counters : 0, - CalculateCorruptionCounters(buffs[BuffCount].spellid) > 0 ? buffs[BuffCount].counters : 0, - buffs[BuffCount].numhits, buffs[BuffCount].melee_rune, buffs[BuffCount].magic_rune, - buffs[BuffCount].deathSaveSuccessChance, + "DeathSaveSuccessChance, CasterAARank, Persistent) VALUES (%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u);", + GetBotID(), buffs[BuffCount].spellid, buffs[BuffCount].casterlevel, spells[buffs[BuffCount].spellid].buffdurationformula, + buffs[BuffCount].ticsremaining, + CalculatePoisonCounters(buffs[BuffCount].spellid) > 0 ? buffs[BuffCount].counters : 0, + CalculateDiseaseCounters(buffs[BuffCount].spellid) > 0 ? buffs[BuffCount].counters : 0, + CalculateCurseCounters(buffs[BuffCount].spellid) > 0 ? buffs[BuffCount].counters : 0, + CalculateCorruptionCounters(buffs[BuffCount].spellid) > 0 ? buffs[BuffCount].counters : 0, + buffs[BuffCount].numhits, buffs[BuffCount].melee_rune, buffs[BuffCount].magic_rune, + buffs[BuffCount].deathSaveSuccessChance, buffs[BuffCount].deathsaveCasterAARank, IsPersistent), TempErrorMessageBuffer)) { errorMessage = std::string(TempErrorMessageBuffer); safe_delete(Query); @@ -2535,7 +2535,7 @@ void Bot::LoadBuffs() { buffs[BuffCount].counters = atoi(DataRow[6]); } else if(CalculateCorruptionCounters(buffs[BuffCount].spellid) > 0) { buffs[BuffCount].counters = atoi(DataRow[7]); - } + } buffs[BuffCount].numhits = atoi(DataRow[8]); buffs[BuffCount].melee_rune = atoi(DataRow[9]); buffs[BuffCount].magic_rune = atoi(DataRow[10]); @@ -2777,7 +2777,7 @@ void Bot::SavePet() { uint32 petItems[MAX_WORN_INVENTORY]; pet->GetPetState(petBuffs, petItems, tempPetName); - + uint32 existingBotPetSaveId = GetPetSaveId(); if(existingBotPetSaveId > 0) { @@ -2956,7 +2956,7 @@ void Bot::LoadStance() { if(loaded) SetBotStance((BotStanceType)Result); - else + else SetDefaultBotStance(); } @@ -3048,7 +3048,7 @@ void Bot::SaveTimers() { bool Bot::Process() { _ZP(Bot_Process); - + if(IsStunned() && stunned_timer.Check()) { this->stunned = false; @@ -3084,7 +3084,7 @@ bool Bot::Process() } BuffProcess(); - + CalcRestState(); if(curfp) @@ -3107,7 +3107,7 @@ bool Bot::Process() if(HasPet()) GetPet()->SendHPUpdate(); } - + if(GetAppearance() == eaDead && GetHP() > 0) SetAppearance(eaStanding); @@ -3137,7 +3137,7 @@ void Bot::SpellProcess() NPC::SpellProcess(); if(GetClass() == BARD) { - if (casting_spell_id != 0) + if (casting_spell_id != 0) casting_spell_id = 0; } } @@ -3196,11 +3196,11 @@ void Bot::BotRangedAttack(Mob* other) { if(!RangeWeapon || !Ammo) return; - + mlog(COMBAT__RANGED, "Shooting %s with bow %s (%d) and arrow %s (%d)", other->GetCleanName(), RangeWeapon->Name, RangeWeapon->ID, Ammo->Name, Ammo->ID); - - if(!IsAttackAllowed(other) || - IsCasting() || + + if(!IsAttackAllowed(other) || + IsCasting() || DivineAura() || IsStunned() || IsMezzed() || @@ -3208,10 +3208,10 @@ void Bot::BotRangedAttack(Mob* other) { { return; } - + SendItemAnimation(other, Ammo, ARCHERY); - DoArcheryAttackDmg(GetTarget(), rangedItem, ammoItem); + DoArcheryAttackDmg(GetTarget(), rangedItem, ammoItem); //break invis when you attack if(invisible) { @@ -3253,10 +3253,10 @@ bool Bot::CheckBotDoubleAttack(bool tripleAttack) { // If you don't have the double attack skill, return if(!GetSkill(DOUBLE_ATTACK) && !(GetClass() == BARD || GetClass() == BEASTLORD)) return false; - + // You start with no chance of double attacking float chance = 0.0f; - + uint16 skill = GetSkill(DOUBLE_ATTACK); int16 bonusDA = aabonuses.DoubleAttackChance + spellbonuses.DoubleAttackChance + itembonuses.DoubleAttackChance; @@ -3264,7 +3264,7 @@ bool Bot::CheckBotDoubleAttack(bool tripleAttack) { //Use skill calculations otherwise, if you only have AA applied GiveDoubleAttack chance then use that value as the base. if (skill) chance = (float(skill+GetLevel()) * (float(100.0f+bonusDA+bonusGiveDA) /100.0f)) /500.0f; - else + else chance = (float(bonusGiveDA) * (float(100.0f+bonusDA)/100.0f) ) /100.0f; //Live now uses a static Triple Attack skill (lv 46 = 2% lv 60 = 20%) - We do not have this skill on EMU ATM. @@ -3280,7 +3280,7 @@ bool Bot::CheckBotDoubleAttack(bool tripleAttack) { if((MakeRandomFloat(0, 1) < chance)) return true; - + return false; } @@ -3298,9 +3298,9 @@ void Bot::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillType skil uint32 hate = 0; int Hand = 13; if (hate == 0 && weapon_damage > 1) hate = weapon_damage; - + if(weapon_damage > 0){ - + if(GetClass() == BERSERKER){ int bonus = 3 + GetLevel()/10; weapon_damage = weapon_damage * (100+bonus) / 100; @@ -3350,7 +3350,7 @@ void Bot::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillType skil return; } } - + else damage = -5; @@ -3366,13 +3366,13 @@ void Bot::DoMeleeSkillAttackDmg(Mob* other, uint16 weapon_damage, SkillType skil hate = hate * (100 + GetFuriousBash(botweapon->Focus.Effect)) / 100; } } - + other->AddToHateList(this, hate); bool CanSkillProc = true; if (skillinuse == OFFENSE){ //Hack to allow damage to display. - skillinuse = TIGER_CLAW; //'strike' your opponent - Arbitrary choice for message. - CanSkillProc = false; //Disable skill procs + skillinuse = TIGER_CLAW; //'strike' your opponent - Arbitrary choice for message. + CanSkillProc = false; //Disable skill procs } other->Damage(this, damage, SPELL_UNKNOWN, skillinuse); @@ -3395,7 +3395,7 @@ void Bot::ApplySpecialAttackMod(SkillType skill, int32 &dmg, int32 &mindmg) { int item_slot = -1; //1: Apply bonus from AC (BOOT/SHIELD/HANDS) est. 40AC=6dmg - + switch (skill){ case FLYING_KICK: @@ -3404,7 +3404,7 @@ void Bot::ApplySpecialAttackMod(SkillType skill, int32 &dmg, int32 &mindmg) { item_slot = SLOT_FEET; break; - case BASH: + case BASH: item_slot = SLOT_SECONDARY; break; @@ -3432,13 +3432,13 @@ bool Bot::CanDoSpecialAttack(Mob *other) SetTarget(NULL); return false; } - + if(!GetTarget()) SetTarget(other); - + if ((other == NULL || ((GetAppearance() == eaDead) || (other->IsClient() && other->CastToClient()->IsDead())) || HasDied() || (!IsAttackAllowed(other)))) { - return false; + return false; } if(other->GetInvul() || other->SpecAttacks[IMMUNE_MELEE]) @@ -3458,7 +3458,7 @@ void Bot::SetTarget(Mob* mob) { float Bot::GetMaxMeleeRangeToTarget(Mob* target) { float result = 0; - + if(target) { float size_mod = GetSize(); float other_size_mod = target->GetSize(); @@ -3535,7 +3535,7 @@ void Bot::AI_Process() { SetBotOwner(0); return; } - + if(GetHealRotationActive() && GetHealRotationTarget() && !GetHasHealedThisCycle() && GetHealRotationNextHealTime() < Timer::GetCurrentTime()) { if(AIHealRotation(GetHealRotationTarget(), GetHealRotationUseFastHeals())) { SetHasHealedThisCycle(true); @@ -3545,8 +3545,8 @@ void Bot::AI_Process() { NotifyNextHealRotationMember(true); } } - - if(GetHasBeenSummoned()) { + + if(GetHasBeenSummoned()) { if(IsBotCaster() || IsBotArcher()) { if (AImovement_timer->Check()) { if(!GetTarget() || (IsBotCaster() && !IsBotCasterCombatRange(GetTarget())) || (IsBotArcher() && IsArcheryRange(GetTarget())) || (DistNoRootNoZ(GetPreSummonX(), GetPreSummonY()) < 10)) { @@ -3575,7 +3575,7 @@ void Bot::AI_Process() { FaceTarget(GetTarget()); SetHasBeenSummoned(false); } - + return; } @@ -3584,7 +3584,7 @@ void Bot::AI_Process() { if(BotOwner && BotOwner->CastToClient()->AutoAttackEnabled() && BotOwner->GetTarget() && BotOwner->GetTarget()->IsNPC() && BotOwner->GetTarget()->GetHateAmount(BotOwner)) { AddToHateList(BotOwner->GetTarget(), 1); - + if(HasPet()) GetPet()->AddToHateList(BotOwner->GetTarget(), 1); } @@ -3654,7 +3654,7 @@ void Bot::AI_Process() { } bool atCombatRange = false; - + float meleeDistance = GetMaxMeleeRangeToTarget(GetTarget()); if(botClass == SHADOWKNIGHT || botClass == PALADIN || botClass == WARRIOR) { @@ -3663,7 +3663,7 @@ void Bot::AI_Process() { else { meleeDistance *= (float)MakeRandomFloat(.50, .85); } - + bool atArcheryRange = IsArcheryRange(GetTarget()); if(GetRangerAutoWeaponSelect()) { @@ -3704,11 +3704,11 @@ void Bot::AI_Process() { atCombatRange = true; } - if(atCombatRange) { + if(atCombatRange) { if(IsMoving()) { SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY())); SetRunAnimSpeed(0); - + if(moved) { moved = false; SendPosition(); @@ -3790,7 +3790,7 @@ void Bot::AI_Process() { if (GetTarget() && flurrychance) { - if(MakeRandomInt(0, 100) < flurrychance) + if(MakeRandomInt(0, 100) < flurrychance) { Message_StringID(MT_NPCFlurry, 128); Attack(GetTarget(), SLOT_PRIMARY, false); @@ -3803,7 +3803,7 @@ void Bot::AI_Process() { if (GetTarget() && ExtraAttackChanceBonus) { ItemInst *wpn = GetBotItem(SLOT_PRIMARY); if(wpn){ - if(wpn->GetItem()->ItemType == ItemType2HS || + if(wpn->GetItem()->ItemType == ItemType2HS || wpn->GetItem()->ItemType == ItemType2HB || wpn->GetItem()->ItemType == ItemType2HPierce ) { @@ -3836,7 +3836,7 @@ void Bot::AI_Process() { if(instweapon) weapon = instweapon->GetItem(); - int weapontype = NULL; + int weapontype = 0; // No weapon type. bool bIsFist = true; if(weapon) { @@ -3846,7 +3846,7 @@ void Bot::AI_Process() { if(bIsFist || ((weapontype != ItemType2HS) && (weapontype != ItemType2HPierce) && (weapontype != ItemType2HB))) { float DualWieldProbability = 0.0f; - + int16 Ambidexterity = aabonuses.Ambidexterity + spellbonuses.Ambidexterity + itembonuses.Ambidexterity; DualWieldProbability = (GetSkill(DUAL_WIELD) + GetLevel() + Ambidexterity) / 400.0f; // 78.0 max int16 DWBonus = spellbonuses.DualWieldChance + itembonuses.DualWieldChance; @@ -3860,7 +3860,7 @@ void Bot::AI_Process() { ItemInst *wpn = GetBotItem(SLOT_SECONDARY); TryWeaponProc(wpn, GetTarget(), SLOT_SECONDARY); - + if( CanThisClassDoubleAttack() && CheckBotDoubleAttack()) { if(GetTarget() && GetTarget()->GetHP() > -10) Attack(GetTarget(), SLOT_SECONDARY); // Single attack with offhand @@ -3926,7 +3926,7 @@ void Bot::AI_Process() { float dist = DistNoRoot(*follow); float speed = follow->GetRunspeed(); - if(dist < GetFollowDistance() + 1000) + if(dist < GetFollowDistance() + 1000) speed = follow->GetWalkspeed(); SetRunAnimSpeed(0); @@ -3936,9 +3936,9 @@ void Bot::AI_Process() { if(rest_timer.Enabled()) rest_timer.Disable(); return; - } + } else - { + { if(moved) { moved=false; @@ -3965,7 +3965,7 @@ void Bot::PetAIProcess() { if(!botPet->GetOwner() || !botPet->GetID() || !botPet->GetOwnerID()) { Kill(); return; - } + } if (!botPet->IsAIControlled()) return; @@ -3982,7 +3982,7 @@ void Bot::PetAIProcess() { if (IsEngaged()) { _ZP(Bot_PET_Process_IsEngaged); - + if (botPet->IsRooted()) botPet->SetTarget(hate_list.GetClosest(botPet)); else @@ -3990,7 +3990,7 @@ void Bot::PetAIProcess() { // Let's check if we have a los with our target. // If we don't, our hate_list is wiped. - // It causes some cpu stress but without it, it was causing the bot/pet to aggro behind wall, floor etc... + // It causes some cpu stress but without it, it was causing the bot/pet to aggro behind wall, floor etc... if(!botPet->CheckLosFN(botPet->GetTarget()) || botPet->GetTarget()->IsMezzed() || !botPet->IsAttackAllowed(GetTarget())) { botPet->WipeHateList(); botPet->SetTarget(botPet->GetOwner()); @@ -4023,7 +4023,7 @@ void Bot::PetAIProcess() { // Ok, we 're a melee or any other class lvl<12. Yes, because after it becomes hard to go in melee for casters.. even for bots.. if( is_combat_range ) { botPet->GetAIMovementTimer()->Check(); - + if(botPet->IsMoving()) { botPet->SetRunAnimSpeed(0); botPet->SetHeading(botPet->GetTarget()->GetHeading()); @@ -4075,11 +4075,11 @@ void Bot::PetAIProcess() { } } } - + // we can't fight if we don't have a target, are stun/mezzed or dead.. if(botPet->GetTarget() && !botPet->IsStunned() && !botPet->IsMezzed() && (botPet->GetAppearance() != eaDead)) { // check the delay on the attack - if(botPet->GetAttackTimer().Check()) { + if(botPet->GetAttackTimer().Check()) { // Stop attacking while we are on a front arc and the target is enraged if(!botPet->BehindMob(botPet->GetTarget(), botPet->GetX(), botPet->GetY()) && botPet->GetTarget()->IsEnraged()) return; @@ -4088,10 +4088,10 @@ void Bot::PetAIProcess() { if (botPet->GetTarget()) // Do we still have a target? { // We're a pet so we re able to dual attack - int32 RandRoll = MakeRandomInt(0, 99); - if (botPet->CanThisClassDoubleAttack() && (RandRoll < (botPet->GetLevel() + NPCDualAttackModifier))) + int32 RandRoll = MakeRandomInt(0, 99); + if (botPet->CanThisClassDoubleAttack() && (RandRoll < (botPet->GetLevel() + NPCDualAttackModifier))) { - if(botPet->Attack(botPet->GetTarget(), 13)) + if(botPet->Attack(botPet->GetTarget(), 13)) {} } } @@ -4117,7 +4117,7 @@ void Bot::PetAIProcess() { } if(aa_skill >= 12) { aa_chance += (aa_skill - 11) * 1; - } + } //aa_chance += botPet->GetOwner()->GetAA(aaCompanionsAlacrity) * 3; @@ -4125,8 +4125,8 @@ void Bot::PetAIProcess() { Flurry(); } - // Ok now, let's check pet's offhand. - if (botPet->GetAttackDWTimer().Check() && botPet->GetOwnerID() && botPet->GetOwner() && ((botPet->GetOwner()->GetClass() == MAGICIAN) || (botPet->GetOwner()->GetClass() == NECROMANCER) || (botPet->GetOwner()->GetClass() == SHADOWKNIGHT) || (botPet->GetOwner()->GetClass() == BEASTLORD))) + // Ok now, let's check pet's offhand. + if (botPet->GetAttackDWTimer().Check() && botPet->GetOwnerID() && botPet->GetOwner() && ((botPet->GetOwner()->GetClass() == MAGICIAN) || (botPet->GetOwner()->GetClass() == NECROMANCER) || (botPet->GetOwner()->GetClass() == SHADOWKNIGHT) || (botPet->GetOwner()->GetClass() == BEASTLORD))) { if(botPet->GetOwner()->GetLevel() >= 24) { @@ -4149,19 +4149,19 @@ void Bot::PetAIProcess() { return; // Special attack - botPet->DoClassAttacks(botPet->GetTarget()); + botPet->DoClassAttacks(botPet->GetTarget()); } // See if the pet can cast any spell botPet->AI_EngagedCastCheck(); - } + } }// end of the combat in range else{ // Now, if we cannot reach our target - if (!botPet->HateSummon()) + if (!botPet->HateSummon()) { - if(botPet->GetTarget() && botPet->AI_PursueCastCheck()) + if(botPet->GetTarget() && botPet->AI_PursueCastCheck()) {} - else if (botPet->GetTarget() && botPet->GetAIMovementTimer()->Check()) + else if (botPet->GetTarget() && botPet->GetAIMovementTimer()->Check()) { botPet->SetRunAnimSpeed(0); if(!botPet->IsRooted()) { @@ -4225,20 +4225,20 @@ void Bot::PetAIProcess() { void Bot::Depop() { WipeHateList(); - + entity_list.RemoveFromHateLists(this); - + if(HasGroup()) Bot::RemoveBotFromGroup(this, GetGroup()); if(HasPet()) { GetPet()->Depop(); } - + _botOwner = 0; _botOwnerCharacterID = 0; _previousTarget = 0; - + NPC::Depop(false); } @@ -4263,7 +4263,7 @@ bool Bot::DeleteBot(std::string* errorMessage) { } else TempCounter++; - + if(!database.RunQuery(Query, MakeAnyLenString(&Query, "DELETE FROM botstances WHERE BotID = '%u'", this->GetBotID()), TempErrorMessageBuffer)) { *errorMessage = std::string(TempErrorMessageBuffer); } @@ -4303,7 +4303,7 @@ void Bot::Spawn(Client* botCharacterOwner, std::string* errorMessage) { this->x_pos = botCharacterOwner->GetX(); this->y_pos = botCharacterOwner->GetY(); this->z_pos = botCharacterOwner->GetZ(); - + // Make the bot look at the bot owner FaceTarget(botCharacterOwner); @@ -4431,7 +4431,7 @@ void Bot::GetBotItems(std::string* errorMessage, Inventory &inv) { } mysql_free_result(DatasetResult); } - else + else *errorMessage = std::string(errbuf); safe_delete_array(query); @@ -4654,7 +4654,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { ns->spawn.colors[MATERIAL_FEET].color = GetEquipmentColor(MATERIAL_FEET); } } - + inst = GetBotItem(SLOT_PRIMARY); if(inst) { item = inst->GetItem(); @@ -4764,7 +4764,7 @@ std::list Bot::GetGroupedBotsByGroupId(uint32 groupId, std::string* erro } return Result; -} +} // Load and spawn all zoned bots by bot owner character void Bot::LoadAndSpawnAllZonedBots(Client* botOwner) { @@ -4789,7 +4789,7 @@ void Bot::LoadAndSpawnAllZonedBots(Client* botOwner) { activeBot->Spawn(botOwner, &errorMessage); g->UpdatePlayer(activeBot); - + if(g->GetLeader()) activeBot->SetFollowID(g->GetLeader()->GetID()); } @@ -4902,14 +4902,14 @@ void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* e if(botGroup && !botGroupName.empty()) { char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; - + Mob* tempGroupLeader = botGroup->GetLeader(); if(tempGroupLeader->IsBot()) { uint32 botGroupId = 0; uint32 botGroupLeaderBotId = tempGroupLeader->CastToBot()->GetBotID(); - + if(!database.RunQuery(query, MakeAnyLenString(&query, "INSERT into botgroup (BotGroupLeaderBotId, BotGroupName) values (%u, '%s')", botGroupLeaderBotId, botGroupName.c_str()), errbuf, 0, 0, &botGroupId)) { *errorMessage = std::string(errbuf); } @@ -5041,7 +5041,7 @@ std::list Bot::GetBotGroupListByBotOwnerCharacterId(uint32 botOwne bool Bot::DoesBotGroupNameExist(std::string botGroupName) { bool result = false; - + if(!botGroupName.empty()) { char* Query = 0; MYSQL_RES* DatasetResult; @@ -5117,7 +5117,7 @@ uint32 Bot::CanLoadBotGroup(uint32 botOwnerCharacterId, std::string botGroupName uint32 Bot::GetBotGroupIdByBotGroupName(std::string botGroupName, std::string* errorMessage) { uint32 result = 0; - + if(!botGroupName.empty()) { char ErrBuf[MYSQL_ERRMSG_SIZE]; char* Query = 0; @@ -5152,7 +5152,7 @@ uint32 Bot::GetBotGroupIdByBotGroupName(std::string botGroupName, std::string* e uint32 Bot::GetBotGroupLeaderIdByBotGroupName(std::string botGroupName) { uint32 result = 0; - + if(!botGroupName.empty()) { char* Query = 0; MYSQL_RES* DatasetResult; @@ -5207,7 +5207,7 @@ uint32 Bot::AllowedBotSpawns(uint32 botOwnerCharacterID, std::string* errorMessa return Result; } - + uint32 Bot::SpawnedBotCount(uint32 botOwnerCharacterID, std::string* errorMessage) { uint32 Result = 0; @@ -5441,12 +5441,12 @@ void Bot::BotRemoveEquipItem(int slot) { } void Bot::BotTradeSwapItem(Client* client, int16 lootSlot, const ItemInst* inst, const ItemInst* inst_swap, uint32 equipableSlots, std::string* errorMessage, bool swap) { - + if(!errorMessage->empty()) return; client->PushItemOnCursor(*inst_swap, true); - + // Remove the item from the bot and from the bot's database records RemoveBotItemBySlot(lootSlot, errorMessage); @@ -5699,7 +5699,7 @@ bool Bot::BotGroupCreate(Bot* botGroupLeader) { if(botGroupLeader && !botGroupLeader->HasGroup()) { Group* newGroup = new Group(botGroupLeader); - + if(newGroup) { entity_list.AddGroup(newGroup); database.SetGroupID(botGroupLeader->GetName(), newGroup->GetID(), botGroupLeader->GetBotID()); @@ -5991,7 +5991,7 @@ void Bot::PerformTradeWithClient(int16 beginSlotID, int16 endSlotID, Client* cli uint32 items[MAX_SLOT_ID] = {0}; uint8 charges[MAX_SLOT_ID] = {0}; bool botCanWear[MAX_SLOT_ID] = {0}; - + for(int16 i=beginSlotID; i<=endSlotID; ++i) { bool BotCanWear = false; bool UpdateClient = false; @@ -6341,7 +6341,7 @@ void Bot::Damage(Mob *from, int32 damage, uint16 spell_id, SkillType attack_skil } attacked_timer.Start(CombatEventTimer_expire); - + // TODO: A bot doesnt call this, right? /*if (!IsEngaged()) zone->AddAggroMob();*/ @@ -6355,7 +6355,7 @@ void Bot::Damage(Mob *from, int32 damage, uint16 spell_id, SkillType attack_skil } CommonDamage(from, damage, spell_id, attack_skill, avoidable, buffslot, iBuffTic); - + if(GetHP() < 0) { if(IsCasting()) InterruptSpell(); @@ -6395,12 +6395,12 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b LogFile->write(EQEMuLog::Error, "A null Mob object was passed to Bot::Attack for evaluation!"); return false; } - + if(!GetTarget() || GetTarget() != other) SetTarget(other); - + mlog(COMBAT__ATTACKS, "Attacking %s with hand %d %s", other?other->GetCleanName():"(NULL)", Hand, FromRiposte?"(this is a riposte)":""); - + if ((IsCasting() && (GetClass() != BARD) && !IsFromSpell) || other == NULL || (GetHP() < 0) || @@ -6420,7 +6420,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b mlog(COMBAT__ATTACKS, "Attack canceled, Divine Aura is in effect."); return false; } - + // TODO: Uncomment this block after solved the bug that is assigning a null value to GetTarget() for bots while in combat. Appears to happen at random, but frequently. /*if(HasGroup() && _previousTarget != GetTarget()) { std::ostringstream attackMessage; @@ -6450,13 +6450,13 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b } else { mlog(COMBAT__ATTACKS, "Attacking without a weapon."); } - + // calculate attack_skill and skillinuse depending on hand and weapon // also send Packet to near clients SkillType skillinuse; AttackAnimation(skillinuse, Hand, weapon); mlog(COMBAT__ATTACKS, "Attacking with %s in slot %d using skill %d", weapon?weapon->GetItem()->Name:"Fist", Hand, skillinuse); - + /// Now figure out damage int damage = 0; uint8 mylevel = GetLevel() ? GetLevel() : 1; @@ -6464,11 +6464,11 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b if (weapon) hate = weapon->GetItem()->Damage + weapon->GetItem()->ElemDmgAmt; int weapon_damage = GetWeaponDamage(other, weapon, &hate); if (hate == 0 && weapon_damage > 1) hate = weapon_damage; - + //if weapon damage > 0 then we know we can hit the target with this weapon //otherwise we cannot and we set the damage to -5 later on if(weapon_damage > 0){ - + //Berserker Berserk damage bonus if(berserk && (GetClass() == BERSERKER)){ int bonus = 3 + GetLevel()/10; //unverified @@ -6480,7 +6480,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b if(TryFinishingBlow(other, skillinuse)) { return (true); } - + //damage formula needs some work int min_hit = 1; int max_hit = (2*weapon_damage*GetDamageTable(skillinuse)) / 100; @@ -6519,7 +6519,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b //Live AA - Sinister Strikes *Adds weapon damage bonus to offhand weapon. if (Hand==SLOT_SECONDARY) { if (aabonuses.SecondaryDmgInc || itembonuses.SecondaryDmgInc || spellbonuses.SecondaryDmgInc){ - + ucDamageBonus = GetWeaponDamageBonus( weapon ? weapon->GetItem() : (const Item_Struct*) NULL ); min_hit += (int) ucDamageBonus; @@ -6568,20 +6568,20 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b if (FromRiposte) return false; else { if (Hand == SLOT_SECONDARY) {// Do we even have it & was attack with mainhand? If not, don't bother with other calculations - //Live AA - SlipperyAttacks + //Live AA - SlipperyAttacks //This spell effect most likely directly modifies the actual riposte chance when using offhand attack. int16 OffhandRiposteFail = aabonuses.OffhandRiposteFail + itembonuses.OffhandRiposteFail + spellbonuses.OffhandRiposteFail; OffhandRiposteFail *= -1; //Live uses a negative value for this. - - if (OffhandRiposteFail && + + if (OffhandRiposteFail && (OffhandRiposteFail > 99 || (MakeRandomInt(0, 100) < OffhandRiposteFail))) { damage = 0; // Counts as a miss slippery_attack = true; - } else + } else DoRiposte(other); if (GetHP() < 0) return false; } - else + else DoRiposte(other); if (GetHP() < 0) return false; } @@ -6589,7 +6589,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b if (((damage < 0) || slippery_attack) && !FromRiposte && !IsStrikethrough) { // Hack to still allow Strikethrough chance w/ Slippery Attacks AA int16 bonusStrikeThrough = itembonuses.StrikeThrough + spellbonuses.StrikeThrough + aabonuses.StrikeThrough; - + if(bonusStrikeThrough && (MakeRandomInt(0, 100) < bonusStrikeThrough)) { Message_StringID(MT_StrikeThrough, STRIKETHROUGH_STRING); // You strike through your opponents defenses! Attack(other, Hand, false, true); // Strikethrough only gives another attempted hit @@ -6600,13 +6600,13 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b else{ damage = -5; } - + // Hate Generation is on a per swing basis, regardless of a hit, miss, or block, its always the same. // If we are this far, this means we are atleast making a swing. if (!FromRiposte) {// Ripostes never generate any aggro. other->AddToHateList(this, hate); } - + /////////////////////////////////////////////////////////// ////// Send Attack Damage /////////////////////////////////////////////////////////// @@ -6614,7 +6614,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b if (GetHP() < 0) return false; - if(damage > 0 && (spellbonuses.MeleeLifetap || itembonuses.MeleeLifetap)) + if(damage > 0 && (spellbonuses.MeleeLifetap || itembonuses.MeleeLifetap)) { int lifetap_amt = spellbonuses.MeleeLifetap + itembonuses.MeleeLifetap; if(lifetap_amt > 100) @@ -6625,11 +6625,11 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b mlog(COMBAT__DAMAGE, "Melee lifetap healing for %d damage.", damage); //heal self for damage done.. HealDamage(lifetap_amt); - + if (spellbonuses.MeleeLifetap) CheckHitsRemaining(0, false,false, SE_MeleeLifetap); } - + //break invis when you attack if(invisible) { mlog(COMBAT__ATTACKS, "Removing invisibility due to melee attack."); @@ -6660,7 +6660,7 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b entity_list.QueueClients(this, outapp, true); safe_delete(outapp); } - + if(GetTarget()) TriggerDefensiveProcs(weapon, other, Hand, damage); @@ -6671,10 +6671,10 @@ bool Bot::Attack(Mob* other, int Hand, bool FromRiposte, bool IsStrikethrough, b return false; } -int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) +int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) { const SPDat_Spell_Struct &spell = spells[spell_id]; - + int16 value = 0; int lvlModifier = 100; int spell_level = 0; @@ -6695,17 +6695,17 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) return 0; } - for (map::const_iterator iter = aa_effects[aa_ID].begin(); iter != aa_effects[aa_ID].end(); ++iter) + for (map::const_iterator iter = aa_effects[aa_ID].begin(); iter != aa_effects[aa_ID].end(); ++iter) { effect = iter->second.skill_id; base1 = iter->second.base1; base2 = iter->second.base2; slot = iter->second.slot; - + //AA Foci's can contain multiple focus effects within the same AA. //To handle this we will not automatically return zero if a limit is found. //Instead if limit is found and multiple effects, we will reset the limit check - //when the next valid focus effect is found. + //when the next valid focus effect is found. if (IsFocusEffect(0, 0, true,effect) || (effect == SE_TriggerOnCast)){ FocusCount++; //If limit found on prior check next, else end loop. @@ -6720,13 +6720,13 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) } } } - + switch (effect) { case SE_Blank: break; - + //Handle Focus Limits case SE_LimitResist: if(base1) @@ -6744,14 +6744,14 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) lvldiff = spell_level - base1; //every level over cap reduces the effect by base2 percent unless from a clicky when ItemCastsUseFocus is true if(lvldiff > 0 && (spell_level <= RuleI(Character, MaxLevel) || RuleB(Character, ItemCastsUseFocus) == false)) - { + { if(base2 > 0) { lvlModifier -= base2*lvldiff; if(lvlModifier < 1) LimitFound = true; } - else { + else { LimitFound = true; } } @@ -6766,10 +6766,10 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) break; case SE_LimitSpell: // Exclude spell(any but this) - if(base1 < 0) { + if(base1 < 0) { if (spell_id == (base1*-1)) LimitFound = true; - } + } else { // Include Spell(only this) if (spell_id != base1) @@ -6788,7 +6788,7 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) } else { // Include effect(only this) - if(!IsEffectInSpell(spell_id,base1)) + if(!IsEffectInSpell(spell_id,base1)) LimitFound = true; } break; @@ -6805,16 +6805,16 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) break; } break; - + case SE_LimitManaCost: if(spell.mana < base1) LimitFound = true; break; - + case SE_LimitTarget: // Exclude if(base1 < 0){ - if(-base1 == spell.targettype) + if(-base1 == spell.targettype) LimitFound = true; } // Include @@ -6823,7 +6823,7 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) LimitFound = true; } break; - + case SE_CombatSkills: // 1 is for disciplines only if(base1 == 1 && !IsDiscipline(spell_id)) @@ -6832,15 +6832,15 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) else if(base1 == 0 && IsDiscipline(spell_id)) LimitFound = true; break; - + case SE_LimitSpellGroup: if(base1 > 0 && base1 != spell.spellgroup) LimitFound = true; else if(base1 < 0 && base1 == spell.spellgroup) LimitFound = true; break; - - + + case SE_LimitSpellSkill: LimitSpellSkill = true; if(base1 == spell.skill) @@ -6850,30 +6850,30 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) case SE_LimitExcludeSkill:{ int16 spell_skill = spell.skill * -1; if(base1 == spell_skill) - LimitFound = true; + LimitFound = true; break; } case SE_LimitClass: //Do not use this limit more then once per spell. If multiple class, treat value like items would. if (!PassLimitClass(base1, GetClass())) - LimitFound = true; + LimitFound = true; break; - - + + //Handle Focus Effects case SE_ImprovedDamage: if (type == focusImprovedDamage && base1 > value) value = base1; break; - + case SE_ImprovedHeal: - if (type == focusImprovedHeal && base1 > value) - value = base1; + if (type == focusImprovedHeal && base1 > value) + value = base1; break; - + case SE_ReduceManaCost: - if (type == focusManaCost ) + if (type == focusManaCost ) value = base1; break; @@ -6881,42 +6881,42 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) if (type == focusSpellHaste && base1 > value) value = base1; break; - + case SE_IncreaseSpellDuration: if (type == focusSpellDuration && base1 > value) value = base1; break; - + case SE_SpellDurationIncByTic: if (type == focusSpellDurByTic && base1 > value) value = base1; - break; - + break; + case SE_SwarmPetDuration: if (type == focusSwarmPetDuration && base1 > value) value = base1; - break; - + break; + case SE_IncreaseRange: if (type == focusRange && base1 > value) value = base1; break; - + case SE_ReduceReagentCost: if (type == focusReagentCost && base1 > value) value = base1; break; - + case SE_PetPowerIncrease: if (type == focusPetPower && base1 > value) value = base1; break; - + case SE_SpellResistReduction: if (type == focusResistRate && base1 > value) value = base1; break; - + case SE_SpellHateMod: if (type == focusSpellHateMod) { @@ -6941,12 +6941,12 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) value = base1; } break; - + case SE_ReduceReuseTimer: - { + { if(type == focusReduceRecastTime) value = base1 / 1000; - + break; } @@ -6957,7 +6957,7 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) if(MakeRandomInt(0, 100) <= base1){ value = base2; } - + else{ value = 0; LimitFound = true; @@ -6977,7 +6977,7 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) { if(type == focusBlockNextSpell) { - if(MakeRandomInt(1, 100) <= base1) + if(MakeRandomInt(1, 100) <= base1) value = 1; } break; @@ -6986,7 +6986,7 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) { if(type == focusTwincast) { - value = base1; + value = base1; } break; } @@ -6996,14 +6996,14 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) { if(type == focusSympatheticProc) { - float ProcChance, ProcBonus; + float ProcChance, ProcBonus; int16 ProcRateMod = base1; //Baseline is 100 for most Sympathetic foci int32 cast_time = GetActSpellCasttime(spell_id, spells[spell_id].cast_time); GetSympatheticProcChances(ProcBonus, ProcChance, cast_time, ProcRateMod); if(MakeRandomFloat(0, 1) <= ProcChance) value = focus_id; - + else value = 0; } @@ -7092,7 +7092,7 @@ int16 Bot::CalcBotAAFocus(BotfocusType type, uint32 aa_ID, uint16 spell_id) //Check for spell skill limits. if ((LimitSpellSkill) && (!SpellSkill_Found)) return 0; - + } } @@ -7115,7 +7115,7 @@ int16 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) { //Improved Healing, Damage & Mana Reduction are handled differently in that some are random percentages //In these cases we need to find the most powerful effect, so that each piece of gear wont get its own chance if((bottype == BotfocusManaCost || bottype == BotfocusImprovedHeal || bottype == BotfocusImprovedDamage) - && RuleB(Spells, LiveLikeFocusEffects)) + && RuleB(Spells, LiveLikeFocusEffects)) { rand_effectiveness = true; } @@ -7165,7 +7165,7 @@ int16 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) { } } } - + for(int y = 0; y < MAX_AUGMENT_SLOTS; ++y) { ItemInst *aug = NULL; @@ -7214,7 +7214,7 @@ int16 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) { int16 Total2 = 0; int16 focus_max2 = 0; int16 focus_max_real2 = 0; - + int buff_tracker = -1; int buff_slot = 0; uint16 focusspellid = 0; @@ -7224,7 +7224,7 @@ int16 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) { focusspellid = buffs[buff_slot].spellid; if (focusspellid == 0 || focusspellid >= SPDAT_RECORDS) continue; - + if(rand_effectiveness) { focus_max2 = CalcBotFocusEffect(bottype, focusspellid, spell_id, true); if (focus_max2 > 0 && focus_max_real2 >= 0 && focus_max2 > focus_max_real2) { @@ -7250,10 +7250,10 @@ int16 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) { } } } - + if(focusspell_tracker && rand_effectiveness && focus_max_real2 != 0) realTotal2 = CalcBotFocusEffect(bottype, focusspell_tracker, spell_id); - + // For effects like gift of mana that only fire once, save the spellid into an array that consists of all available buff slots. if(buff_tracker >= 0 && buffs[buff_tracker].numhits > 0) { m_spellHitsLeft[buff_tracker] = focusspell_tracker; @@ -7270,17 +7270,17 @@ int16 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) { uint32 aa_value = 0; for (int i = 0; i < totalAAs; i++) { //iterate through all of the client's AAs - std::map::iterator aa = botAAs.find(i); + std::map::iterator aa = botAAs.find(i); if(aa != botAAs.end()) { // make sure aa exists or we'll crash zone aa_AA = aa->second.aa_id; //same as aaid from the aa_effects table aa_value = aa->second.total_levels; //how many points in it - if (aa_AA < 1 || aa_value < 1) + if (aa_AA < 1 || aa_value < 1) continue; - + Total3 = CalcBotAAFocus(bottype, aa_AA, spell_id); if (Total3 > 0 && realTotal3 >= 0 && Total3 > realTotal3) { realTotal3 = Total3; - } + } else if (Total3 < 0 && Total3 < realTotal3) { realTotal3 = Total3; } @@ -7303,7 +7303,7 @@ int16 Bot::GetBotFocusEffect(BotfocusType bottype, uint16 spell_id) { int16 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spell_id, bool best_focus) { if(!IsValidSpell(focus_id) || !IsValidSpell(spell_id)) return 0; - + const SPDat_Spell_Struct &focus_spell = spells[focus_id]; const SPDat_Spell_Struct &spell = spells[spell_id]; @@ -7426,7 +7426,7 @@ int16 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel if(spell.mana < focus_spell.base[i]) return 0; break; - + case SE_LimitTarget: // Exclude if((focus_spell.base[i] < 0) && -focus_spell.base[i] == spell.targettype) @@ -7436,7 +7436,7 @@ int16 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel return 0; break; - + case SE_CombatSkills: // 1 is for disciplines only if(focus_spell.base[i] == 1 && !IsDiscipline(spell_id)) @@ -7445,7 +7445,7 @@ int16 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel else if(focus_spell.base[i] == 0 && IsDiscipline(spell_id)) return 0; break; - + case SE_LimitSpellGroup: if(focus_spell.base[i] > 0 && focus_spell.base[i] != spell.spellgroup) return 0; @@ -7462,14 +7462,14 @@ int16 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel case SE_LimitExcludeSkill:{ int16 spell_skill = spell.skill * -1; if(focus_spell.base[i] == spell_skill) - return 0; + return 0; break; } case SE_LimitClass: //Do not use this limit more then once per spell. If multiple class, treat value like items would. if (!PassLimitClass(focus_spell.base[i], GetClass())) - return 0; + return 0; break; //handle effects @@ -7550,13 +7550,13 @@ int16 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel { value = focus_spell.base[i]; } - break; + break; case SE_SwarmPetDuration: if (bottype == BotfocusSwarmPetDuration && focus_spell.base[i] > value) { value = focus_spell.base[i]; } - break; + break; case SE_IncreaseRange: if (bottype == BotfocusRange && focus_spell.base[i] > value) { @@ -7605,25 +7605,25 @@ int16 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel value = focus_spell.base[i]; } break; - + case SE_ReduceReuseTimer: - { + { if(bottype == BotfocusReduceRecastTime) value = focus_spell.base[i] / 1000; - + break; } case SE_TriggerOnCast: { if(bottype == BotfocusTriggerOnCast) - + if(MakeRandomInt(0, 100) <= focus_spell.base[i]) value = focus_spell.base2[i]; - + else value = 0; - + break; } case SE_SpellVulnerability: @@ -7638,7 +7638,7 @@ int16 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel { if(bottype == BotfocusBlockNextSpell) { - if(MakeRandomInt(1, 100) <= focus_spell.base[i]) + if(MakeRandomInt(1, 100) <= focus_spell.base[i]) value = 1; } break; @@ -7647,7 +7647,7 @@ int16 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel { if(bottype == BotfocusTwincast) { - value = focus_spell.base[i]; + value = focus_spell.base[i]; } break; } @@ -7655,14 +7655,14 @@ int16 Bot::CalcBotFocusEffect(BotfocusType bottype, uint16 focus_id, uint16 spel { if(bottype == BotfocusSympatheticProc) { - float ProcChance, ProcBonus; + float ProcChance, ProcBonus; int16 ProcRateMod = focus_spell.base[i]; //Baseline is 100 for most Sympathetic foci int32 cast_time = GetActSpellCasttime(spell_id, spells[spell_id].cast_time); GetSympatheticProcChances(ProcBonus, ProcChance, cast_time, ProcRateMod); if(MakeRandomFloat(0, 1) <= ProcChance) value = focus_id; - + else value = 0; } @@ -7783,7 +7783,7 @@ float Bot::GetProcChances(float &ProcBonus, float &ProcChance, uint16 weapon_spe break; } - + //calculate the weapon speed in ms, so we can use the rule to compare against. if(weapon_speed < RuleI(Combat, MinHastedDelay)) // fast as a client can swing, so should be the floor of the proc chance @@ -7811,17 +7811,17 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) { /* solar: called when a mob is attacked, does the checks to see if it's a hit * and does other mitigation checks. 'this' is the mob being attacked. - * + * * special return values: * -1 - block * -2 - parry * -3 - riposte * -4 - dodge - * + * */ if(GetAppearance() == eaDead) return false; - + float skill = 0; float bonus = 0; float RollTable[4] = {0,0,0,0}; @@ -7833,7 +7833,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) bool ghit = false; if((attacker->GetSpellBonuses().MeleeSkillCheck + attacker->GetItemBonuses().MeleeSkillCheck) > 500) ghit = true; - + ////////////////////////////////////////////////////////// // make enrage same as riposte ///////////////////////////////////////////////////////// @@ -7841,7 +7841,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) damage = -3; mlog(COMBAT__DAMAGE, "I am enraged, riposting frontal attack."); } - + ///////////////////////////////////////////////////////// // riposte ///////////////////////////////////////////////////////// @@ -7850,21 +7850,21 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) { riposte_chance = (100.0f + (float)defender->GetAABonuses().RiposteChance + (float)defender->GetSpellBonuses().RiposteChance + (float)defender->GetItemBonuses().RiposteChance) / 100.0f; skill = GetSkill(RIPOSTE); - + if (!ghit) { //if they are not using a garunteed hit discipline bonus = 2.0 + skill/60.0 + (GetDEX()/200); bonus *= riposte_chance; RollTable[0] = bonus + (itembonuses.HeroicDEX / 25); // 25 heroic = 1%, applies to ripo, parry, block } } - - /////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////// // block /////////////////////////////////////////////////////// bool bBlockFromRear = false; bool bShieldBlockFromRear = false; - + if (this->IsBot()) { int aaChance = 0; @@ -7886,7 +7886,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) if (damage > 0 && CanThisClassBlock() && (!other->BehindMob(this, other->GetX(), other->GetY()) || bBlockFromRear)) { block_chance = (100.0f + (float)spellbonuses.IncreaseBlockChance + (float)itembonuses.IncreaseBlockChance) / 100.0f; skill = GetSkill(BLOCKSKILL); - + if (!ghit) { //if they are not using a garunteed hit discipline bonus = 2.0 + skill/35.0 + (GetDEX()/200); RollTable[1] = RollTable[0] + (bonus * block_chance) - riposte_chance; @@ -7897,7 +7897,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) RollTable[1] = RollTable[0]; } - if(damage > 0 && (aabonuses.ShieldBlock || spellbonuses.ShieldBlock || itembonuses.ShieldBlock) + if(damage > 0 && (aabonuses.ShieldBlock || spellbonuses.ShieldBlock || itembonuses.ShieldBlock) && (!other->BehindMob(this, other->GetX(), other->GetY()) || bShieldBlockFromRear)) { bool equiped = GetBotItem(SLOT_SECONDARY); if(equiped) { @@ -7919,14 +7919,14 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) uint8 TwoHandBlunt = GetBotItem(SLOT_PRIMARY)->GetItem()->ItemType; float bonusStaffBlock = 0.0f; if(TwoHandBlunt == ItemType2HB) { - + bonusStaffBlock = aabonuses.TwoHandBluntBlock + spellbonuses.TwoHandBluntBlock + itembonuses.TwoHandBluntBlock; RollTable[1] = RollTable[0] + bonusStaffBlock; } } } - ////////////////////////////////////////////////////// + ////////////////////////////////////////////////////// // parry ////////////////////////////////////////////////////// float parry_chance = 0.0f; @@ -7934,7 +7934,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) { parry_chance = (100.0f + (float)defender->GetSpellBonuses().ParryChance + (float)defender->GetItemBonuses().ParryChance) / 100.0f; skill = GetSkill(PARRY); - + if (!ghit) { //if they are not using a garunteed hit discipline bonus = 2.0 + skill/60.0 + (GetDEX()/200); bonus *= parry_chance; @@ -7944,7 +7944,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) else{ RollTable[2] = RollTable[1] - block_chance; } - + //////////////////////////////////////////////////////// // dodge //////////////////////////////////////////////////////// @@ -7953,7 +7953,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) { dodge_chance = (100.0f + (float)defender->GetSpellBonuses().DodgeChance + (float)defender->GetItemBonuses().DodgeChance) / 100.0f; skill = GetSkill(DODGE); - + if (!ghit) { //if they are not using a garunteed hit discipline bonus = 2.0 + skill/60.0 + (GetAGI()/200); bonus *= dodge_chance; @@ -7982,7 +7982,7 @@ bool Bot::AvoidDamage(Mob* other, int32 &damage, bool CanRiposte) } mlog(COMBAT__DAMAGE, "Final damage after all avoidances: %d", damage); - + if (damage < 0) return true; return false; @@ -8031,9 +8031,9 @@ void Bot::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage) float critChance = 0.0f; - //1: Try Slay Undead + //1: Try Slay Undead if(defender && defender->GetBodyType() == BT_Undead || defender->GetBodyType() == BT_SummonedUndead || defender->GetBodyType() == BT_Vampire){ - + int16 SlayRateBonus = aabonuses.SlayUndead[0] + itembonuses.SlayUndead[0] + spellbonuses.SlayUndead[0]; if (SlayRateBonus) { @@ -8048,7 +8048,7 @@ void Bot::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage) return; } } - } + } //2: Try Melee Critical @@ -8056,11 +8056,11 @@ void Bot::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage) //by item,spell and AA bonuses allowing you a chance to critical hit. If the following rules //are defined you will have an innate chance to hit at Level 1 regardless of bonuses. //Warning: Do not define these rules if you want live like critical hits. - critChance += RuleI(Combat, MeleeBaseCritChance); - + critChance += RuleI(Combat, MeleeBaseCritChance); + critChance += RuleI(Combat, ClientBaseCritChance); - - if(((GetClass() == WARRIOR || GetClass() == BERSERKER) && GetLevel() >= 12)) + + if(((GetClass() == WARRIOR || GetClass() == BERSERKER) && GetLevel() >= 12)) { if((GetHPRatio() < 30) && GetClass() == BERSERKER){ critChance += RuleI(Combat, BerserkBaseCritChance); @@ -8069,13 +8069,13 @@ void Bot::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage) else critChance += RuleI(Combat, WarBerBaseCritChance); } - + if(skill == ARCHERY && GetClass() == RANGER && GetSkill(ARCHERY) >= 65) critChance += 6; if(skill == THROWING && GetClass() == ROGUE && GetSkill(THROWING) >= 65) critChance += 6; - + int CritChanceBonus = GetCriticalChanceBonus(skill); if (CritChanceBonus || critChance) { @@ -8083,12 +8083,12 @@ void Bot::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage) //Get Base CritChance from Dex. (200 = ~1.6%, 255 = ~2.0%, 355 = ~2.20%) Fall off rate > 255 //http://giline.versus.jp/shiden/su.htm , http://giline.versus.jp/shiden/damage_e.htm if (GetDEX() <= 255) - critChance += (float(GetDEX()) / 125.0f); + critChance += (float(GetDEX()) / 125.0f); else if (GetDEX() > 255) critChance += (float(GetDEX()-255)/ 500.0f) + 2.0f; critChance += critChance*(float)CritChanceBonus /100.0f; } - + if(critChance > 0){ critChance /= 100; @@ -8098,7 +8098,7 @@ void Bot::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage) uint16 critMod = 200; bool crip_success = false; int16 CripplingBlowChance = GetCrippBlowChance(); - + //Crippling Blow Chance: The percent value of the effect is applied //to the your Chance to Critical. (ie You have 10% chance to critical and you //have a 200% Chance to Critical Blow effect, therefore you have a 20% Chance to Critical Blow. @@ -8117,11 +8117,11 @@ void Bot::TryCriticalHit(Mob *defender, uint16 skill, int32 &damage) if(berserk || crip_success) { entity_list.MessageClose_StringID(this, false, 200, MT_CritMelee, CRIPPLING_BLOW, GetCleanName(), itoa(damage)); - // Crippling blows also have a chance to stun + // Crippling blows also have a chance to stun //Kayen: Crippling Blow would cause a chance to interrupt for npcs < 55, with a staggers message. if (defender->GetLevel() <= 55 && !defender->SpecAttacks[IMMUNE_STUN]){ defender->Emote("staggers."); - defender->Stun(0); + defender->Stun(0); } } @@ -8137,7 +8137,7 @@ bool Bot::TryFinishingBlow(Mob *defender, SkillType skillinuse) { if (!defender) return false; - + if (aabonuses.FinishingBlow[1] && !defender->IsClient() && defender->GetHPRatio() < 10){ uint32 chance = aabonuses.FinishingBlow[0]/10; //500 = 5% chance. @@ -8168,8 +8168,8 @@ void Bot::DoRiposte(Mob* defender) { defender->Attack(this, SLOT_PRIMARY, true); //double riposte - int16 DoubleRipChance = defender->GetAABonuses().GiveDoubleRiposte[0] + - defender->GetSpellBonuses().GiveDoubleRiposte[0] + + int16 DoubleRipChance = defender->GetAABonuses().GiveDoubleRiposte[0] + + defender->GetSpellBonuses().GiveDoubleRiposte[0] + defender->GetItemBonuses().GiveDoubleRiposte[0]; if(DoubleRipChance && (DoubleRipChance >= MakeRandomInt(0, 100))) { @@ -8180,14 +8180,14 @@ void Bot::DoRiposte(Mob* defender) { //Double Riposte effect, allows for a chance to do RIPOSTE with a skill specfic special attack (ie Return Kick). //Coded narrowly: Limit to one per client. Limit AA only. [1 = Skill Attack Chance, 2 = Skill] - DoubleRipChance = defender->GetAABonuses().GiveDoubleRiposte[1]; + DoubleRipChance = defender->GetAABonuses().GiveDoubleRiposte[1]; if(DoubleRipChance && (DoubleRipChance >= MakeRandomInt(0, 100))) { if (defender->GetClass() == MONK) defender->MonkSpecialAttack(this, defender->GetAABonuses().GiveDoubleRiposte[2]); else if (defender->IsBot()) defender->CastToClient()->DoClassAttacks(this,defender->GetAABonuses().GiveDoubleRiposte[2], true); - } + } } void Bot::MeleeMitigation(Mob *attacker, int32 &damage, int32 minhit) @@ -8234,7 +8234,7 @@ void Bot::MeleeMitigation(Mob *attacker, int32 &damage, int32 minhit) { softcap = RuleI(Combat, PlateACSoftcap); } - + softcap += shield_ac; armor += shield_ac; softcap += (softcap * (aa_mit * RuleR(Combat, AAMitigationACFactor))); @@ -8354,16 +8354,16 @@ void Bot::MeleeMitigation(Mob *attacker, int32 &damage, int32 minhit) acreduction=atof(tmp); if (acreduction>100) acreduction=100; } - + if (database.GetVariable("ACrandom", tmp, 9)) { acrandom = (int) ((atof(tmp)+1) * 100); if (acrandom>10100) acrandom=10100; } - + if (acreduction>0) { damage -= (int) (GetAC() * acreduction/100.0f); - } + } if (acrandom>0) { damage -= (myac * MakeRandomInt(0, acrandom) / 10000); } @@ -8425,9 +8425,9 @@ void Bot::DoSpecialAttackDamage(Mob *who, SkillType skill, int32 max_damage, int who->AvoidDamage(this, max_damage, CanRiposte); who->MeleeMitigation(this, max_damage, min_damage); - + if(max_damage > 0) { - ApplyMeleeDamageBonus(skill, max_damage); + ApplyMeleeDamageBonus(skill, max_damage); max_damage += who->GetAdditionalDamage(this, 0, true, skill); max_damage += (itembonuses.HeroicSTR / 10) + (max_damage * who->GetSkillDmgTaken(skill) / 100) + GetSkillDmgAmt(skill); TryCriticalHit(who, skill, max_damage); @@ -8446,19 +8446,19 @@ void Bot::DoSpecialAttackDamage(Mob *who, SkillType skill, int32 max_damage, int if(aabonuses.SpecialAttackKBProc[0] && aabonuses.SpecialAttackKBProc[1] == skill){ int kb_chance = 25; kb_chance += kb_chance*(100-aabonuses.SpecialAttackKBProc[0])/100; - + if (MakeRandomInt(0, 99) < kb_chance) SpellFinished(904, who, 10, 0, -1, spells[904].ResistDiff); //who->Stun(100); Kayen: This effect does not stun on live, it only moves the NPC. - } + } if (HasSkillProcs()){ float chance = (float)ReuseTime*RuleR(Combat, AvgProcsPerMinute)/60000.0f; TrySkillProc(who, skill, chance); } - + if(max_damage == -3 && !(who->GetHP() <= 0)) - DoRiposte(who); + DoRiposte(who); } void Bot::TryBackstab(Mob *other, int ReuseTime) { @@ -8476,7 +8476,7 @@ void Bot::TryBackstab(Mob *other, int ReuseTime) { Say("I can't backstab with this weapon!"); return; } - + //Live AA - Triple Backstab int tripleChance = itembonuses.TripleBackstab + spellbonuses.TripleBackstab + aabonuses.TripleBackstab; @@ -8484,8 +8484,8 @@ void Bot::TryBackstab(Mob *other, int ReuseTime) { bIsBehind = true; } else { - //Live AA - Seized Opportunity - int FrontalBSChance = itembonuses.FrontalBackstabChance + spellbonuses.FrontalBackstabChance + aabonuses.FrontalBackstabChance; + //Live AA - Seized Opportunity + int FrontalBSChance = itembonuses.FrontalBackstabChance + spellbonuses.FrontalBackstabChance + aabonuses.FrontalBackstabChance; if (FrontalBSChance && (FrontalBSChance > MakeRandomInt(0, 100))) bCanFrontalBS = true; @@ -8511,13 +8511,13 @@ void Bot::TryBackstab(Mob *other, int ReuseTime) { if (level > 54) { float DoubleAttackProbability = (GetSkill(DOUBLE_ATTACK) + GetLevel()) / 500.0f; // 62.4 max // Check for double attack with main hand assuming maxed DA Skill (MS) - + if(MakeRandomFloat(0, 1) < DoubleAttackProbability) // Max 62.4 % chance of DA { if(other->GetHP() > 0) RogueBackstab(other,false,ReuseTime); - if (tripleChance && other->GetHP() > 0 && tripleChance > MakeRandomInt(0, 100)) + if (tripleChance && other->GetHP() > 0 && tripleChance > MakeRandomInt(0, 100)) RogueBackstab(other,false,ReuseTime); } } @@ -8553,7 +8553,7 @@ void Bot::RogueBackstab(Mob* other, bool min_damage, int ReuseTime) int32 hate = 0; int32 primaryweapondamage = 0; int32 backstab_dmg = 0; - + ItemInst* botweaponInst = GetBotItem(SLOT_PRIMARY); if(botweaponInst) { primaryweapondamage = GetWeaponDamage(other, botweaponInst); @@ -8567,7 +8567,7 @@ void Bot::RogueBackstab(Mob* other, bool min_damage, int ReuseTime) } } } - else + else { primaryweapondamage = (GetLevel()/7)+1; // fallback incase it's a npc without a weapon, 2 dmg at 10, 10 dmg at 65 backstab_dmg = primaryweapondamage; @@ -8607,7 +8607,7 @@ void Bot::RogueBackstab(Mob* other, bool min_damage, int ReuseTime) max_hit = min_hit; if(RuleB(Combat, UseIntervalAC)) - ndamage = max_hit; + ndamage = max_hit; else ndamage = MakeRandomInt(min_hit, max_hit); @@ -8643,7 +8643,7 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { if(spellend_timer.Enabled() || IsFeared() || IsStunned() || IsMezzed() || DivineAura() || GetHP() < 0) return; - + if(!IsAttackAllowed(target)) return; @@ -8673,7 +8673,7 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { break; } } - knightattack_timer.Start(knightreuse); + knightattack_timer.Start(knightreuse); } //general stuff, for all classes.... @@ -8681,12 +8681,12 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { //franck-add: EQoffline. Warrior bots must taunt the target. if(taunting && target && target->IsNPC() && taunt_time ) { - //Only taunt if we are not top on target's hate list - //This ensures we have taunt available to regain aggro if needed + //Only taunt if we are not top on target's hate list + //This ensures we have taunt available to regain aggro if needed if(GetTarget() && GetTarget()->GetHateTop() && GetTarget()->GetHateTop() != this) { Say("Taunting %s", target->GetCleanName()); Taunt(target->CastToNPC(), false); - taunt_timer.Start(TauntReuseTime * 1000); + taunt_timer.Start(TauntReuseTime * 1000); } } @@ -8715,9 +8715,9 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { bool canBash = false; if((GetRace() == OGRE || GetRace() == TROLL || GetRace() == BARBARIAN) // Racial Slam || (m_inv.GetItem(SLOT_SECONDARY) && m_inv.GetItem(SLOT_SECONDARY)->GetItem()->ItemType == ItemTypeShield) //Using Shield - || (m_inv.GetItem(SLOT_PRIMARY) && (m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HS - || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HB - || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HPierce) + || (m_inv.GetItem(SLOT_PRIMARY) && (m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HS + || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HB + || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HPierce) && GetAA(aa2HandBash) >= 1)) { //Using 2 hand weapon, but has AA 2 Hand Bash canBash = true; } @@ -8742,9 +8742,9 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { if(level >= RuleI(Combat, NPCBashKickLevel)){ if((GetRace() == OGRE || GetRace() == TROLL || GetRace() == BARBARIAN) // Racial Slam || (m_inv.GetItem(SLOT_SECONDARY) && m_inv.GetItem(SLOT_SECONDARY)->GetItem()->ItemType == ItemTypeShield) //Using Shield - || (m_inv.GetItem(SLOT_PRIMARY) && (m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HS - || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HB - || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HPierce) + || (m_inv.GetItem(SLOT_PRIMARY) && (m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HS + || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HB + || m_inv.GetItem(SLOT_PRIMARY)->GetItem()->ItemType == ItemType2HPierce) && GetAA(aa2HandBash) >= 1)) { //Using 2 hand weapon, but has AA 2 Hand Bash skill_to_use = BASH; } @@ -8780,14 +8780,14 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { skill_to_use = BACKSTAB; break; } - + if(skill_to_use == -1) return; - if(skill_to_use == BASH) + if(skill_to_use == BASH) { - if (target!=this) + if (target!=this) { DoAnim(animTailRake); @@ -8827,7 +8827,7 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { int AtkRounds = 3; int skillmod = 0; - if(MaxSkill(FRENZY) > 0) + if(MaxSkill(FRENZY) > 0) skillmod = 100*GetSkill(FRENZY)/MaxSkill(FRENZY); int32 max_dmg = (26 + ((((GetLevel()-6) * 2)*skillmod)/100)) * ((100+RuleI(Combat, FrenzyBonus))/100); @@ -8846,10 +8846,10 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { //reuse = (reuse * HasteModifier)/100; did_attack = true; - + //Live parses show around 55% Triple 35% Double 10% Single, you will always get first hit. while(AtkRounds > 0) { - + if (GetTarget() && (AtkRounds == 1 || MakeRandomInt(0,100) < 75)){ DoSpecialAttackDamage(GetTarget(), FRENZY, max_dmg, min_dmg, max_dmg , reuse, true); } @@ -8903,7 +8903,7 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { uint16 bDoubleSpecialAttack = itembonuses.DoubleSpecialAttack + spellbonuses.DoubleSpecialAttack + aabonuses.DoubleSpecialAttack; if( bDoubleSpecialAttack && (bDoubleSpecialAttack >= 100 || bDoubleSpecialAttack > MakeRandomInt(0,100))) { - int MonkSPA [5] = { FLYING_KICK, DRAGON_PUNCH, EAGLE_STRIKE, TIGER_CLAW, ROUND_KICK }; + int MonkSPA [5] = { FLYING_KICK, DRAGON_PUNCH, EAGLE_STRIKE, TIGER_CLAW, ROUND_KICK }; MonkSpecialAttack(target, MonkSPA[MakeRandomInt(0,4)]); int TripleChance = 25; @@ -8919,7 +8919,7 @@ void Bot::DoClassAttacks(Mob *target, bool IsRiposte) { reuse *= 1000; did_attack = true; } - + if(skill_to_use == BACKSTAB) { reuse = BackstabReuseTime * 1000; @@ -8977,7 +8977,7 @@ int32 Bot::CheckHealAggroAmount(uint16 spellid, uint32 heal_possible) { int32 AggroAmount = Mob::CheckHealAggroAmount(spellid, heal_possible); int32 focusAggro = GetBotFocusEffect(BotfocusSpellHateMod, spellid); - + AggroAmount = (AggroAmount * (100 + focusAggro) / 100); return AggroAmount; @@ -8995,7 +8995,7 @@ void Bot::AI_Stop() { //this is called with 'this' as the mob being looked at, and //iOther the mob who is doing the looking. It should figure out //what iOther thinks about 'this' -FACTION_VALUE Bot::GetReverseFactionCon(Mob* iOther) { +FACTION_VALUE Bot::GetReverseFactionCon(Mob* iOther) { _ZP(Bot_GetReverseFactionCon); if(iOther->IsBot()) { @@ -9031,7 +9031,7 @@ Mob* Bot::GetOwner() { bool Bot::IsBotAttackAllowed(Mob* attacker, Mob* target, bool& hasRuleDefined) { bool Result = false; - + if(attacker && target) { if(attacker->IsClient() && target->IsBot() && attacker->CastToClient()->GetPVP() && target->CastToBot()->GetBotOwner()->CastToClient()->GetPVP()) @@ -9238,7 +9238,7 @@ void Bot::SetBotGuildMembership(uint32 botId, uint32 guildid, uint8 rank) { std::string errorMessage; char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; - + if(guildid > 0) { if(!database.RunQuery(query, MakeAnyLenString(&query, "REPLACE INTO botguildmembers SET char_id = %u, guild_id = %u, rank = %u;", botId, guildid, rank), errbuf)) { errorMessage = std::string(errbuf); @@ -9291,7 +9291,7 @@ void Bot::LoadGuildMembership(uint32* guildId, uint8* guildRank, std::string* gu int32 Bot::CalcMaxMana() { switch(GetCasterClass()) { - case 'I': + case 'I': case 'W': { max_mana = (GenerateBaseManaPoints() + itembonuses.Mana + spellbonuses.Mana + GroupLeadershipAAManaEnhancement()); @@ -9348,7 +9348,7 @@ void Bot::SetAttackTimer() { else //invalid slot (hands will always hit this) continue; - const Item_Struct* ItemToUse = NULL; + const Item_Struct* ItemToUse = NULL; ItemInst* ci = GetBotItem(i); if(ci) ItemToUse = ci->GetItem(); @@ -9376,8 +9376,8 @@ void Bot::SetAttackTimer() { //see if we have a valid weapon if(ItemToUse != NULL) { //check type and damage/delay - if(ItemToUse->ItemClass != ItemClassCommon - || ItemToUse->Damage == 0 + if(ItemToUse->ItemClass != ItemClassCommon + || ItemToUse->Damage == 0 || ItemToUse->Delay == 0) { //no weapon ItemToUse = NULL; @@ -9424,7 +9424,7 @@ void Bot::SetAttackTimer() { /*if(IsClient()) { float max_quiver = 0; - for(int r = SLOT_PERSONAL_BEGIN; r <= SLOT_PERSONAL_END; r++) + for(int r = SLOT_PERSONAL_BEGIN; r <= SLOT_PERSONAL_END; r++) { const ItemInst *pi = CastToClient()->GetInv().GetItem(r); if(!pi) @@ -9450,14 +9450,14 @@ void Bot::SetAttackTimer() { if(i == SLOT_PRIMARY) PrimaryWeapon = ItemToUse; - } + } } -int32 Bot::Additional_SpellDmg(uint16 spell_id, bool bufftick) +int32 Bot::Additional_SpellDmg(uint16 spell_id, bool bufftick) { int32 spell_dmg = 0; spell_dmg += GetBotFocusEffect(BotfocusFF_Damage_Amount, spell_id); - spell_dmg += GetBotFocusEffect(BotfocusSpellDamage, spell_id); + spell_dmg += GetBotFocusEffect(BotfocusSpellDamage, spell_id); //For DOTs you need to apply the damage over the duration of the dot to each tick (this is how live did it) if (bufftick){ @@ -9499,7 +9499,7 @@ int32 Bot::GetActSpellDamage(uint16 spell_id, int32 value) { // Need to scale HT damage differently after level 40! It no longer scales by the constant value in the spell file. It scales differently, instead of 10 more damage per level, it does 30 more damage per level. So we multiply the level minus 40 times 20 if they are over level 40. if ( spell_id == SPELL_HARM_TOUCH || spell_id == SPELL_HARM_TOUCH2 || spell_id == SPELL_IMP_HARM_TOUCH ) { if (this->GetLevel() > 40) - value -= (this->GetLevel() - 40) * 20; + value -= (this->GetLevel() - 40) * 20; } //This adds the extra damage from the AA Unholy Touch, 450 per level to the AA Improved Harm TOuch. @@ -9522,7 +9522,7 @@ int32 Bot::GetActSpellDamage(uint16 spell_id, int32 value) { if(spell_dmg > -value) spell_dmg = -value; } - + // Spell-based SpellDmg adds directly but it restricted by focuses. spell_dmg += Additional_SpellDmg(spell_id); @@ -9531,7 +9531,7 @@ int32 Bot::GetActSpellDamage(uint16 spell_id, int32 value) { chance += itembonuses.CriticalSpellChance + spellbonuses.CriticalSpellChance + aabonuses.CriticalSpellChance; ratio += itembonuses.SpellCritDmgIncrease + spellbonuses.SpellCritDmgIncrease + aabonuses.SpellCritDmgIncrease; - + if(GetClass() == WIZARD) { if (GetLevel() >= RuleI(Spells, WizCritLevel)) { chance += RuleI(Spells, WizCritChance); @@ -9540,12 +9540,12 @@ int32 Bot::GetActSpellDamage(uint16 spell_id, int32 value) { if(aabonuses.SpellCritDmgIncrease > 0) // wizards get an additional bonus ratio += aabonuses.SpellCritDmgIncrease * 1.5; //108%, 115%, 124%, close to Graffe's 207%, 215%, & 225% } - + //Improved Harm Touch is a guaranteed crit if you have at least one level of SCF. if (spell_id == SPELL_IMP_HARM_TOUCH) { if ( (GetAA(aaSpellCastingFury) > 0) && (GetAA(aaUnholyTouch) > 0) ) chance = 100; - } + } /* //Handled in aa_effects will focus spells from 'spellgroup=99'. (SK life tap from buff procs) @@ -9579,8 +9579,8 @@ int32 Bot::GetActSpellDamage(uint16 spell_id, int32 value) { modifier += modifier*ratio/100; spell_dmg *= 2; mlog(SPELLS__CRITS, "Spell crit successful. Final damage modifier: %d, Final Damage: %d", modifier, (value * modifier / 100) - spell_dmg); - entity_list.MessageClose(this, false, 100, MT_SpellCrits, "%s delivers a critical blast! (%d)", GetName(), (-value * modifier / 100) + spell_dmg); - } else + entity_list.MessageClose(this, false, 100, MT_SpellCrits, "%s delivers a critical blast! (%d)", GetName(), (-value * modifier / 100) + spell_dmg); + } else mlog(SPELLS__CRITS, "Spell crit failed. Final Damage Modifier: %d, Final Damage: %d", modifier, (value * modifier / 100) - spell_dmg); } } @@ -9588,7 +9588,7 @@ int32 Bot::GetActSpellDamage(uint16 spell_id, int32 value) { return ((value * modifier / 100) - spell_dmg); } -int32 Bot::Additional_Heal(uint16 spell_id) +int32 Bot::Additional_Heal(uint16 spell_id) { int32 heal_amt = 0; @@ -9600,7 +9600,7 @@ int32 Bot::Additional_Heal(uint16 spell_id) if (duration > 0) return heal_amt /= duration; } - + return heal_amt; } @@ -9627,22 +9627,22 @@ int32 Bot::GetActSpellHealing(uint16 spell_id, int32 value) { value += value * GetHealRate(spell_id) / 100; chance += GetCriticalHealRate(spell_id); } - + //Live AA - Healing Gift, Theft of Life chance += itembonuses.CriticalHealChance + spellbonuses.CriticalHealChance + aabonuses.CriticalHealChance; if(MakeRandomInt(0,99) < chance) { - entity_list.MessageClose(this, false, 100, MT_SpellCrits, "%s performs an exceptional heal! (%d)", GetName(), ((value * modifier / 50) + heal_amt*2)); + entity_list.MessageClose(this, false, 100, MT_SpellCrits, "%s performs an exceptional heal! (%d)", GetName(), ((value * modifier / 50) + heal_amt*2)); return ((value * modifier / 50) + heal_amt*2); } else{ return ((value * modifier / 100) + heal_amt); - } + } } // Hots else { chance += itembonuses.CriticalHealChance + spellbonuses.CriticalHealChance + aabonuses.CriticalHealChance; - if(MakeRandomInt(0,99) < chance) + if(MakeRandomInt(0,99) < chance) return ((value * modifier / 50) + heal_amt*2); } @@ -9656,8 +9656,8 @@ int32 Bot::GetActSpellCasttime(uint16 spell_id, int32 casttime) { uint8 botlevel = GetLevel(); uint8 botclass = GetClass(); - if (botlevel >= 51 && casttime >= 3000 && !BeneficialSpell(spell_id) - && (botclass == SHADOWKNIGHT || botclass == RANGER + if (botlevel >= 51 && casttime >= 3000 && !BeneficialSpell(spell_id) + && (botclass == SHADOWKNIGHT || botclass == RANGER || botclass == PALADIN || botclass == BEASTLORD )) cast_reducer += (GetLevel()-50)*3; @@ -9730,7 +9730,7 @@ int32 Bot::GetActSpellCasttime(uint16 spell_id, int32 casttime) { } if (cast_reducer > RuleI(Spells, MaxCastTimeReduction)) - cast_reducer = RuleI(Spells, MaxCastTimeReduction); + cast_reducer = RuleI(Spells, MaxCastTimeReduction); casttime = (casttime*(100 - cast_reducer)/100); @@ -9745,10 +9745,10 @@ int32 Bot::GetActSpellCost(uint16 spell_id, int32 cost) { // Doesnt generate mana, so best case is a free spell if(mana_back > cost) mana_back = cost; - + cost -= mana_back; } - + // This formula was derived from the following resource: // http://www.eqsummoners.com/eq1/specialization-library.html // WildcardX @@ -9817,14 +9817,14 @@ int32 Bot::GetActSpellCost(uint16 spell_id, int32 cost) { for (int buffSlot = 0; buffSlot < buff_max; buffSlot++) { if (buffs[buffSlot].spellid == 0 || buffs[buffSlot].spellid >= SPDAT_RECORDS) continue; - + if(IsEffectInSpell(buffs[buffSlot].spellid, SE_ReduceManaCost)) { if(CalcFocusEffect(focusManaCost, buffs[buffSlot].spellid, spell_id) == 100) cost = 1; } } } - + if(cost < 0) cost = 0; @@ -9842,7 +9842,7 @@ int32 Bot::GetActSpellDuration(uint16 spell_id, int32 duration) { increase += GetBotFocusEffect(BotfocusSpellDuration, spell_id); int tic_inc = 0; tic_inc = GetBotFocusEffect(BotfocusSpellDurByTic, spell_id); - + if(IsBeneficialSpell(spell_id)) { switch (GetAA(aaSpellCastingReinforcement)) { @@ -9859,10 +9859,10 @@ int32 Bot::GetActSpellDuration(uint16 spell_id, int32 duration) { break; } - if (GetAA(aaSpellCastingReinforcementMastery)) + if (GetAA(aaSpellCastingReinforcementMastery)) increase += 20; } - + if(IsMezSpell(spell_id)) { tic_inc += GetAA(aaMesmerizationMastery); } @@ -9872,7 +9872,7 @@ int32 Bot::GetActSpellDuration(uint16 spell_id, int32 duration) { float Bot::GetAOERange(uint16 spell_id) { float range; - + range = spells[spell_id].aoerange; if(range == 0) //for TGB spells, they prolly do not have an aoe range range = spells[spell_id].range; @@ -9884,15 +9884,15 @@ float Bot::GetAOERange(uint16 spell_id) { float song_bonus = aabonuses.SongRange + spellbonuses.SongRange + itembonuses.SongRange; range += range*song_bonus /100.0f; } - + range = GetActSpellRange(spell_id, range); - + return range; } bool Bot::SpellEffect(Mob* caster, uint16 spell_id, float partial) { bool Result = false; - + Result = Mob::SpellEffect(caster, spell_id, partial); // Franck-add: If healed/doted, a bot must show its new HP to its leader @@ -10146,14 +10146,14 @@ bool Bot::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce bool Bot::DoCastSpell(uint16 spell_id, uint16 target_id, uint16 slot, int32 cast_time, int32 mana_cost, uint32* oSpellWillFinish, uint32 item_slot) { bool Result = false; - - if(GetClass() == BARD) { + + if(GetClass() == BARD) { // Bard bots casting time is interrupting thier melee cast_time = 0; } Result = Mob::DoCastSpell(spell_id, target_id, slot, cast_time, mana_cost, oSpellWillFinish, item_slot); - + if(oSpellWillFinish) { const SPDat_Spell_Struct &spell = spells[spell_id]; *oSpellWillFinish = Timer::GetCurrentTime() + ((spell.recast_time > 20000) ? 10000 : spell.recast_time); @@ -10186,7 +10186,7 @@ int32 Bot::GenerateBaseManaPoints() else { ConvertedWisInt = WisInt; } - if(GetLevel() < 41) { + if(GetLevel() < 41) { wisint_mana = (GetLevel() * 75 * ConvertedWisInt / 1000); base_mana = (GetLevel() * 15); } @@ -10229,7 +10229,7 @@ int32 Bot::GenerateBaseManaPoints() else { ConvertedWisInt = WisInt; } - if(GetLevel() < 41) { + if(GetLevel() < 41) { wisint_mana = (GetLevel() * 75 * ConvertedWisInt / 1000); base_mana = (GetLevel() * 15); } @@ -10309,7 +10309,7 @@ bool Bot::DoFinishedSpellSingleTarget(uint16 spell_id, Mob* spellTarget, uint16 if(spellequal || slotequal) { if((spelltypeequal || spelltypetargetequal) || spelltypeclassequal || slotequal) { // Don't let the Shaman canni themselves to death - if(((spells[thespell].effectid[0] == 0) && (spells[thespell].base[0] < 0)) && + if(((spells[thespell].effectid[0] == 0) && (spells[thespell].base[0] < 0)) && (spellTarget->GetHP() < ((spells[thespell].base[0] * (-1)) + 100))) { return false; } @@ -10398,7 +10398,7 @@ void Bot::CalcBonuses() { CalcSpellBonuses(&spellbonuses); GenerateAABonuses(&aabonuses); SetAttackTimer(); - + CalcATK(); CalcSTR(); CalcSTA(); @@ -10425,10 +10425,10 @@ void Bot::CalcBonuses() { end_regen = CalcEnduranceRegen(); } -int32 Bot::CalcHPRegenCap(){ +int32 Bot::CalcHPRegenCap(){ int level = GetLevel(); int32 hpregen_cap = 0; - hpregen_cap = RuleI(Character, ItemHealthRegenCap) + itembonuses.HeroicSTA/25; + hpregen_cap = RuleI(Character, ItemHealthRegenCap) + itembonuses.HeroicSTA/25; hpregen_cap += aabonuses.ItemHPRegenCap + spellbonuses.ItemHPRegenCap + itembonuses.ItemHPRegenCap; @@ -10439,10 +10439,10 @@ int32 Bot::CalcManaRegenCap(){ int32 cap = RuleI(Character, ItemManaRegenCap) + aabonuses.ItemManaRegenCap; switch(GetCasterClass()) { - case 'I': + case 'I': cap += (itembonuses.HeroicINT / 25); break; - case 'W': + case 'W': cap += (itembonuses.HeroicWIS / 25); break; } @@ -10454,7 +10454,7 @@ int32 Bot::CalcManaRegenCap(){ int16 Bot::GetMaxStat() { int level = GetLevel(); int16 base = 0; - + if (level < 61) { base = 255; } @@ -10467,7 +10467,7 @@ int16 Bot::GetMaxStat() { else { base = 330; } - + return(base); } @@ -10475,7 +10475,7 @@ int16 Bot::GetMaxResist() { int level = GetLevel(); int16 base = 500; - + if(level > 60) base += ((level - 60) * 5); @@ -10572,30 +10572,30 @@ int16 Bot::CalcSTR() { if(STR < 1) STR = 1; - + int m = GetMaxSTR(); if(STR > m) STR = m; - + return(STR); } int16 Bot::CalcSTA() { int16 val = STA + itembonuses.STA + spellbonuses.STA; - + int16 mod = aabonuses.STA; - + if(val>255 && GetLevel() <= 60) val = 255; STA = val + mod; - + if(STA < 1) STA = 1; int m = GetMaxSTA(); if(STA > m) STA = m; - + return(STA); } @@ -10614,82 +10614,82 @@ int16 Bot::CalcAGI() { int m = GetMaxAGI(); if(AGI > m) AGI = m; - + return(AGI); } int16 Bot::CalcDEX() { int16 val = DEX + itembonuses.DEX + spellbonuses.DEX; - + int16 mod = aabonuses.DEX; - + if(val>255 && GetLevel() <= 60) val = 255; DEX = val + mod; - + if(DEX < 1) DEX = 1; int m = GetMaxDEX(); if(DEX > m) DEX = m; - + return(DEX); } int16 Bot::CalcINT() { int16 val = INT + itembonuses.INT + spellbonuses.INT; - + int16 mod = aabonuses.INT; - + if(val>255 && GetLevel() <= 60) val = 255; INT = val + mod; - + if(INT < 1) INT = 1; int m = GetMaxINT(); if(INT > m) INT = m; - + return(INT); } int16 Bot::CalcWIS() { int16 val = WIS + itembonuses.WIS + spellbonuses.WIS; - + int16 mod = aabonuses.WIS; - + if(val>255 && GetLevel() <= 60) val = 255; WIS = val + mod; - + if(WIS < 1) WIS = 1; int m = GetMaxWIS(); if(WIS > m) WIS = m; - + return(WIS); } int16 Bot::CalcCHA() { int16 val = CHA + itembonuses.CHA + spellbonuses.CHA; - + int16 mod = aabonuses.CHA; - + if(val>255 && GetLevel() <= 60) val = 255; CHA = val + mod; - + if(CHA < 1) CHA = 1; int m = GetMaxCHA(); if(CHA > m) CHA = m; - + return(CHA); } @@ -10699,10 +10699,10 @@ int16 Bot::CalcCHA() { int16 Bot::CalcMR() { MR += itembonuses.MR + spellbonuses.MR + aabonuses.MR; - + if(GetClass() == WARRIOR) MR += GetLevel() / 2; - + if(MR < 1) MR = 1; @@ -10717,21 +10717,21 @@ int16 Bot::CalcFR() int c = GetClass(); if(c == RANGER) { FR += 4; - + int l = GetLevel(); if(l > 49) FR += l - 49; } - + FR += itembonuses.FR + spellbonuses.FR + aabonuses.FR; - + if(FR < 1) FR = 1; - + if(FR > GetMaxFR()) FR = GetMaxFR(); - return(FR); + return(FR); } int16 Bot::CalcDR() @@ -10739,21 +10739,21 @@ int16 Bot::CalcDR() int c = GetClass(); if(c == PALADIN) { DR += 8; - + int l = GetLevel(); if(l > 49) DR += l - 49; } else if(c == SHADOWKNIGHT) { DR += 4; - + int l = GetLevel(); if(l > 49) DR += l - 49; } - + DR += itembonuses.DR + spellbonuses.DR + aabonuses.DR; - + if(DR < 1) DR = 1; @@ -10768,21 +10768,21 @@ int16 Bot::CalcPR() int c = GetClass(); if(c == ROGUE) { PR += 8; - + int l = GetLevel(); if(l > 49) PR += l - 49; } else if(c == SHADOWKNIGHT) { PR += 4; - + int l = GetLevel(); if(l > 49) PR += l - 49; } - + PR += itembonuses.PR + spellbonuses.PR + aabonuses.PR; - + if(PR < 1) PR = 1; @@ -10797,14 +10797,14 @@ int16 Bot::CalcCR() int c = GetClass(); if(c == RANGER) { CR += 4; - + int l = GetLevel(); if(l > 49) CR += l - 49; } - + CR += itembonuses.CR + spellbonuses.CR + aabonuses.CR; - + if(CR < 1) CR = 1; @@ -10817,7 +10817,7 @@ int16 Bot::CalcCR() int16 Bot::CalcCorrup() { Corrup = Corrup + itembonuses.Corrup + spellbonuses.Corrup + aabonuses.Corrup; - + if(Corrup > GetMaxCorrup()) Corrup = GetMaxCorrup(); @@ -10932,13 +10932,13 @@ int32 Bot::CalcHPRegen() { return regen; } -int32 Bot::CalcManaRegen() +int32 Bot::CalcManaRegen() { uint8 level = GetLevel(); uint8 botclass = GetClass(); int32 regen = 0; //this should be changed so we dont med while camping, etc... - if (IsSitting()) + if (IsSitting()) { BuffFadeBySitModifier(); if(botclass != WARRIOR && botclass != MONK && botclass != ROGUE && botclass != BERSERKER) { @@ -10981,7 +10981,7 @@ uint32 Bot::GetClassHPFactor() { // Base HP over level 80 is factor / 10 // HP per STA point per level is factor / 30 for level 80+ // HP per STA under level 40 is the level 80 HP Per STA / 120, and for over 40 it is / 60. - + switch(GetClass()) { case DRUID: @@ -11022,7 +11022,7 @@ uint32 Bot::GetClassHPFactor() { int32 Bot::CalcMaxHP() { int32 bot_hp = 0; uint32 nd = 10000; - + bot_hp += GenerateBaseHitPoints() + itembonuses.HP; nd += aabonuses.MaxHP; //Natural Durability, Physical Enhancement, Planar Durability @@ -11037,7 +11037,7 @@ int32 Bot::CalcMaxHP() { if (cur_hp > max_hp) cur_hp = max_hp; - + int hp_perc_cap = spellbonuses.HPPercCap; if(hp_perc_cap) { int curHP_cap = (max_hp * hp_perc_cap) / 100; @@ -11051,15 +11051,15 @@ int32 Bot::CalcMaxHP() { int32 Bot::CalcMaxEndurance() { max_end = CalcBaseEndurance() + spellbonuses.Endurance + itembonuses.Endurance; - + if (max_end < 0) { max_end = 0; } - + if (cur_end > max_end) { cur_end = max_end; } - + int end_perc_cap = spellbonuses.EndPercCap; if(end_perc_cap) { int curEnd_cap = (max_end * end_perc_cap) / 100; @@ -11094,7 +11094,7 @@ int32 Bot::CalcBaseEndurance() ConvertedStats = Stats; } - if (GetLevel() < 41) { + if (GetLevel() < 41) { sta_end = (GetLevel() * 75 * ConvertedStats / 1000); base_endurance = (GetLevel() * 15); } @@ -11116,24 +11116,24 @@ int32 Bot::CalcBaseEndurance() int at_most_800 = Stats; if(at_most_800 > 800) at_most_800 = 800; - + int Bonus400to800 = 0; int HalfBonus400to800 = 0; int Bonus800plus = 0; int HalfBonus800plus = 0; - + int BonusUpto800 = int( at_most_800 / 4 ) ; if(Stats > 400) { Bonus400to800 = int( (at_most_800 - 400) / 4 ); HalfBonus400to800 = int( max( ( at_most_800 - 400 ), 0 ) / 8 ); - + if(Stats > 800) { Bonus800plus = int( (Stats - 800) / 8 ) * 2; HalfBonus800plus = int( (Stats - 800) / 16 ); } } int bonus_sum = BonusUpto800 + Bonus400to800 + HalfBonus400to800 + Bonus800plus + HalfBonus800plus; - + base_end = LevelBase; //take all of the sums from above, then multiply by level*0.075 @@ -11151,7 +11151,7 @@ int32 Bot::CalcEnduranceRegen() { int32 Bot::CalcEnduranceRegenCap() { int cap = (RuleI(Character, ItemEnduranceRegenCap) + itembonuses.HeroicSTR/25 + itembonuses.HeroicDEX/25 + itembonuses.HeroicAGI/25 + itembonuses.HeroicSTA/25); - + return (cap * RuleI(Character, EnduranceRegenMultiplier) / 100); } @@ -11192,7 +11192,7 @@ void Bot::DoEnduranceUpkeep() { } } } - + if(upkeep_sum != 0) SetEndurance(GetEndurance() - upkeep_sum); } @@ -11232,10 +11232,10 @@ bool Bot::IsArcheryRange(Mob *target) { range *= range; float targetDistance = DistNoRootNoZ(*target); - + float minRuleDistance = RuleI(Combat, MinRangedAttackDist) * RuleI(Combat, MinRangedAttackDist); - if((targetDistance > range) || (targetDistance < minRuleDistance)) + if((targetDistance > range) || (targetDistance < minRuleDistance)) result = false; else result = true; @@ -11257,7 +11257,7 @@ bool Bot::IsBotCasterCombatRange(Mob *target) { float targetDistance = DistNoRootNoZ(*target); - if(targetDistance > range) + if(targetDistance > range) result = false; else result = true; @@ -11269,83 +11269,83 @@ bool Bot::IsBotCasterCombatRange(Mob *target) { bool Bot::IsGroupPrimaryHealer() { bool result = false; uint8 botclass = GetClass(); - + if(HasGroup()) { Group *g = GetGroup(); - + switch(botclass) { - case CLERIC: + case CLERIC: { result = true; break; } - case DRUID: + case DRUID: { result = GroupHasClericClass(g) ? false : true; break; } - case SHAMAN: + case SHAMAN: { result = (GroupHasClericClass(g) || GroupHasDruidClass(g)) ? false : true; break; } - case PALADIN: - case RANGER: - case BEASTLORD: + case PALADIN: + case RANGER: + case BEASTLORD: { result = GroupHasPriestClass(g) ? false : true; break; } - default: + default: { result = false; break; } } } - + return result; } bool Bot::IsGroupPrimarySlower() { bool result = false; uint8 botclass = GetClass(); - + if(HasGroup()) { Group *g = GetGroup(); - + switch(botclass) { - case SHAMAN: + case SHAMAN: { result = true; break; } - case ENCHANTER: + case ENCHANTER: { result = GroupHasShamanClass(g) ? false : true; break; } - case BEASTLORD: + case BEASTLORD: { result = (GroupHasShamanClass(g) || GroupHasEnchanterClass(g)) ? false : true; break; } - default: + default: { result = false; break; } } } - + return result; } bool Bot::CanHeal() { bool result = false; - + if(!AI_HasSpells()) return false; @@ -11363,7 +11363,7 @@ bool Bot::CanHeal() { /*if(GetFirstBotSpellBySpellType(this, SpellType_Heal)){ result = true; }*/ - + return result; } @@ -11377,8 +11377,8 @@ bool Bot::CalculateNewPosition2(float x, float y, float z, float speed, bool che // const int clientAnimationMovementRateTypeMultiple = 8; // WildcardX: These are valid rates and observations based on painstaking testing of the client response to these values - // - // + // + // // 0 * 8 = 0 : No Movement // 1 * 8 = 8 : Death Walk // 2 * 8 = 16 : Slow Walk @@ -11847,13 +11847,13 @@ void Bot::CalcBotStats(bool showtext) { if(showtext) { GetBotOwner()->Message(15, "Bot updating..."); } - + if(!IsValidRaceClassCombo()) { GetBotOwner()->Message(15, "A %s - %s bot was detected. Is this Race/Class combination allowed?.", GetRaceName(GetRace()), GetEQClassName(GetClass(), GetLevel())); GetBotOwner()->Message(15, "Previous Bots Code releases did not check Race/Class combinations during create."); GetBotOwner()->Message(15, "Unless you are experiencing heavy lag, you should delete and remake this bot."); } - + if(GetBotOwner()->GetLevel() != GetLevel()) SetLevel(GetBotOwner()->GetLevel()); @@ -11869,7 +11869,7 @@ void Bot::CalcBotStats(bool showtext) { this->GetBotOwner()->CastToClient()->Message(0, "%s saved.", this->GetCleanName()); else this->GetBotOwner()->CastToClient()->Message(13, "%s save failed!", this->GetCleanName());*/ - + CalcBonuses(); AI_AddNPCSpells(this->GetBotSpellID()); @@ -11888,7 +11888,7 @@ bool Bot::CheckLoreConflict(const Item_Struct* item) { return false; if (item->LoreGroup == -1) // Standard lore items; look everywhere except the shared bank, return the result - return (m_inv.HasItem(item->ID, 0, invWhereWorn) != SLOT_INVALID); + return (m_inv.HasItem(item->ID, 0, invWhereWorn) != SLOT_INVALID); //If the item has a lore group, we check for other items with the same group and return the result return (m_inv.HasItemByLoreGroup(item->LoreGroup, invWhereWorn) != SLOT_INVALID); @@ -11974,7 +11974,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { c->Message(0, "#bot setinspectmessage - Copies your inspect message to a targeted bot that you own"); return; } - + // pull if(!strcasecmp(sep->arg[1], "pull")) { Mob *target = c->GetTarget(); @@ -11983,7 +11983,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { c->Message(15, "You must select a monster"); return; } - + if(c->IsGrouped()) { bool haspuller = false; @@ -12060,7 +12060,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { char* Query = 0; MYSQL_RES* DatasetResult; MYSQL_ROW DataRow; - + c->Message(0, "-----------------#bot armorcolor help-----------------------------"); c->Message(0, "Armor: 17(Chest/Robe), 7(Arms), 9(Bracer), 12(Hands), 18(Legs), 19(Boots), 2(Helm)"); c->Message(0, "------------------------------------------------------------------"); @@ -12121,7 +12121,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { else if(strcasecmp(sep->arg[3],"1") && strcasecmp(sep->arg[3],"2") && strcasecmp(sep->arg[3],"3") && strcasecmp(sep->arg[3],"4") && strcasecmp(sep->arg[3],"5") && strcasecmp(sep->arg[3],"6") && strcasecmp(sep->arg[3],"7") && strcasecmp(sep->arg[3],"8") && strcasecmp(sep->arg[3],"9") && strcasecmp(sep->arg[3],"10") && strcasecmp(sep->arg[3],"11") && strcasecmp(sep->arg[3],"12") && strcasecmp(sep->arg[3],"13") && strcasecmp(sep->arg[3],"14") && strcasecmp(sep->arg[3],"15") && strcasecmp(sep->arg[3],"16")) { c->Message(0, "Usage: #bot create [name] [class(id)] [race(id)] [gender (male/female)]"); return; - } + } else if(strcasecmp(sep->arg[4],"1") && strcasecmp(sep->arg[4],"2") && strcasecmp(sep->arg[4],"3") && strcasecmp(sep->arg[4],"4") && strcasecmp(sep->arg[4],"5") && strcasecmp(sep->arg[4],"6") && strcasecmp(sep->arg[4],"7") && strcasecmp(sep->arg[4],"8") && strcasecmp(sep->arg[4],"9") && strcasecmp(sep->arg[4],"10") && strcasecmp(sep->arg[4],"11") && strcasecmp(sep->arg[4],"12") && strcasecmp(sep->arg[4],"330") && strcasecmp(sep->arg[4],"128") && strcasecmp(sep->arg[4],"130") && strcasecmp(sep->arg[4],"522")) { c->Message(0, "Usage: #bot create [name] [class(1-16)] [race(1-12,128,130,330,522)] [gender (male/female)]"); return; @@ -12239,7 +12239,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(!AvailableBots.empty()) { - for(std::list::iterator TempAvailableBotsList = AvailableBots.begin(); TempAvailableBotsList != AvailableBots.end(); TempAvailableBotsList++) { + for(std::list::iterator TempAvailableBotsList = AvailableBots.begin(); TempAvailableBotsList != AvailableBots.end(); TempAvailableBotsList++) { if(!listAll && TempAvailableBotsList->BotClass != iClass) continue; @@ -12260,9 +12260,9 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { listAll = true; else { string botName = std::string(sep->arg[2]); - + Bot* tempBot = entity_list.GetBotByBotName(botName); - + if(tempBot && tempBot->GetBotOwner() == c) { bot = tempBot; } @@ -12330,7 +12330,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(c->IsGrouped()) { Group *g = entity_list.GetGroupByClient(c); for (int i=0; imembers[i] && !g->members[i]->qglobal && (g->members[i]->GetAppearance() != eaDead) + if(g && g->members[i] && !g->members[i]->qglobal && (g->members[i]->GetAppearance() != eaDead) && (g->members[i]->IsEngaged() || (g->members[i]->IsClient() && g->members[i]->CastToClient()->GetAggroCount()))) { c->Message(0, "You can't summon bots while you are engaged."); return; @@ -12403,7 +12403,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { safe_delete(TempBot); return; } - + TempBot->CastToMob()->Say("I am ready for battle."); } else { @@ -12456,7 +12456,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { else if(c->GetTarget()->IsMob() && !c->GetTarget()->IsPet()) { Mob *b = c->GetTarget(); - if(b) + if(b) { // Is our target "botable" ? if(!b->IsBot()){ @@ -12466,7 +12466,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { { b->Say("You can only summon your own bots."); } - else + else { b->SetTarget(c->CastToMob()); b->Warp(c->GetX(), c->GetY(), c->GetZ()); @@ -12480,7 +12480,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(!strcasecmp(sep->arg[1], "inventory") && !strcasecmp(sep->arg[2], "list")) { if(c->GetTarget() != NULL) { if(c->GetTarget()->IsBot() && c->GetTarget()->CastToBot()->GetBotOwnerCharacterID() == c->CharacterID()) { - Mob* b = c->GetTarget(); + Mob* b = c->GetTarget(); int x = c->GetTarget()->CastToBot()->GetBotItemsCount(&TempErrorMessage); if(!TempErrorMessage.empty()) { @@ -12522,16 +12522,16 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if((i == 0) || (i == 11) || (i == 13) || (i == 14) || (i == 21)) { if (c->GetClientVersion() >= EQClientSoF) { - MakeAnyLenString(&itemLink, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X", + MakeAnyLenString(&itemLink, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X", + 0, + item2->ID, + item1->GetAugmentItemID(0), + item1->GetAugmentItemID(1), + item1->GetAugmentItemID(2), + item1->GetAugmentItemID(3), + item1->GetAugmentItemID(4), + 0, 0, - item2->ID, - item1->GetAugmentItemID(0), - item1->GetAugmentItemID(1), - item1->GetAugmentItemID(2), - item1->GetAugmentItemID(3), - item1->GetAugmentItemID(4), - 0, - 0, 0, 0, 0 @@ -12542,15 +12542,15 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { { MakeAnyLenString(&itemLink, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%08X", 0, - item2->ID, - item1->GetAugmentItemID(0), - item1->GetAugmentItemID(1), - item1->GetAugmentItemID(2), - item1->GetAugmentItemID(3), - item1->GetAugmentItemID(4), - 0, - 0, - 0, + item2->ID, + item1->GetAugmentItemID(0), + item1->GetAugmentItemID(1), + item1->GetAugmentItemID(2), + item1->GetAugmentItemID(3), + item1->GetAugmentItemID(4), + 0, + 0, + 0, 0); c->Message(15, "Using %c%s%s%c in my %s (Item %i)", 0x12, itemLink, item2->Name, 0x12, equipped[i], i); } @@ -12558,16 +12558,16 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { else { if (c->GetClientVersion() >= EQClientSoF) { - MakeAnyLenString(&itemLink, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X", + MakeAnyLenString(&itemLink, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%05X" "%08X", + 0, + item2->ID, + item1->GetAugmentItemID(0), + item1->GetAugmentItemID(1), + item1->GetAugmentItemID(2), + item1->GetAugmentItemID(3), + item1->GetAugmentItemID(4), + 0, 0, - item2->ID, - item1->GetAugmentItemID(0), - item1->GetAugmentItemID(1), - item1->GetAugmentItemID(2), - item1->GetAugmentItemID(3), - item1->GetAugmentItemID(4), - 0, - 0, 0, 0, 0 @@ -12578,15 +12578,15 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { { MakeAnyLenString(&itemLink, "%1X" "%05X" "%05X" "%05X" "%05X" "%05X" "%05X" "%1X" "%04X" "%1X" "%08X", 0, - item2->ID, - item1->GetAugmentItemID(0), - item1->GetAugmentItemID(1), - item1->GetAugmentItemID(2), - item1->GetAugmentItemID(3), - item1->GetAugmentItemID(4), - 0, - 0, - 0, + item2->ID, + item1->GetAugmentItemID(0), + item1->GetAugmentItemID(1), + item1->GetAugmentItemID(2), + item1->GetAugmentItemID(3), + item1->GetAugmentItemID(4), + 0, + 0, + 0, 0); c->Message(15, "Using %c%s%s%c in my %s (Item %i)", 0x12, itemLink, item2->Name, 0x12, equipped[i], i); } @@ -12608,7 +12608,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { { c->Message(15, "Usage: #bot inventory remove [slotid] (You must have a bot targetted) "); return; - } + } else if(c->GetTarget()->IsBot() && c->GetTarget()->CastToBot()->GetBotOwnerCharacterID() == c->CharacterID()) { if(c->GetTradeskillObject() || (c->trade->state == Trading)) @@ -12840,19 +12840,19 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { runeer->Say("Casting Rune II..."); runeer->CastSpell(482, c->GetID(), 1, -1, -1); } - else if ((c->GetLevel() >= 33) && (c->GetLevel() <= 39)) { + else if ((c->GetLevel() >= 33) && (c->GetLevel() <= 39)) { runeer->Say("Casting Rune III..."); runeer->CastSpell(483, c->GetID(), 1, -1, -1); } - else if ((c->GetLevel() >= 40) && (c->GetLevel() <= 51)) { + else if ((c->GetLevel() >= 40) && (c->GetLevel() <= 51)) { runeer->Say("Casting Rune IV..."); runeer->CastSpell(484, c->GetID(), 1, -1, -1); } - else if ((c->GetLevel() >= 52) && (c->GetLevel() <= 60)) { + else if ((c->GetLevel() >= 52) && (c->GetLevel() <= 60)) { runeer->Say("Casting Rune V..."); runeer->CastSpell(1689, c->GetID(), 1, -1, -1); } - else if (c->GetLevel() >= 61){ + else if (c->GetLevel() >= 61){ runeer->Say("Casting Rune of Zebuxoruk..."); runeer->CastSpell(3343, c->GetID(), 1, -1, -1); } @@ -12904,15 +12904,15 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Tracker->Say("Tracking everything", c->GetName()); entity_list.ShowSpawnWindow(c, RangeR, false); } - else if(!strcasecmp(sep->arg[2], "rare")) { + else if(!strcasecmp(sep->arg[2], "rare")) { Tracker->Say("Selective tracking", c->GetName()); entity_list.ShowSpawnWindow(c, RangeR, true); } - else if(!strcasecmp(sep->arg[2], "near")) { + else if(!strcasecmp(sep->arg[2], "near")) { Tracker->Say("Tracking mobs nearby", c->GetName()); entity_list.ShowSpawnWindow(c, RangeD, false); } - else + else Tracker->Say("You want to [track all], [track near], or [track rare]?", c->GetName()); break; @@ -12987,7 +12987,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Curer->CastToBot()->Bot_Command_Cure(4, Curer->GetLevel()); } else if (!strcasecmp(sep->arg[2], "curse") && (c->GetLevel() <= 8) - || !strcasecmp(sep->arg[2], "blindness") && (c->GetLevel() <= 3) + || !strcasecmp(sep->arg[2], "blindness") && (c->GetLevel() <= 3) || !strcasecmp(sep->arg[2], "disease") && (c->GetLevel() <= 4) || !strcasecmp(sep->arg[2], "poison") && (c->GetLevel() <= 1)) { Curer->Say("I don't have the needed level yet", sep->arg[2]); @@ -13013,12 +13013,12 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Curer->Say("Trying to cure us of %s.", sep->arg[2]); Curer->CastToBot()->Bot_Command_Cure(4, Curer->GetLevel()); } - else if (!strcasecmp(sep->arg[2], "blindness") && (c->GetLevel() <= 7) + else if (!strcasecmp(sep->arg[2], "blindness") && (c->GetLevel() <= 7) || !strcasecmp(sep->arg[2], "disease") && (c->GetLevel() <= 1) || !strcasecmp(sep->arg[2], "poison") && (c->GetLevel() <= 2)) { Curer->Say("I don't have the needed level yet", sep->arg[2]); } - else + else Curer->Say("Do you want [cure poison], [cure disease], or [cure blindness]?", c->GetName()); break; @@ -13043,7 +13043,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { || !strcasecmp(sep->arg[2], "poison") && (c->GetLevel() <= 5)) { Curer->Say("I don't have the needed level yet", sep->arg[2]) ; } - else + else Curer->Say("Do you want [cure poison], or [cure disease]?", c->GetName()); break; @@ -13562,7 +13562,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(g) { for(int i=0; imembers[i] && g->members[i]->IsBot() && (g->members[i]->GetClass() == DRUID)) + if((g->members[i] && g->members[i]->IsBot() && (g->members[i]->GetClass() == DRUID)) || (g->members[i] && g->members[i]->IsBot() && (g->members[i]->GetClass() == WIZARD))) { hasevac = true; @@ -13636,14 +13636,14 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { else if ((!strcasecmp(sep->arg[2], "wolf")) && (c->GetLevel() <= 20)) { Sower->Say("I'm not level 20 yet."); } - else if ((!strcasecmp(sep->arg[2], "feral")) && (c->GetLevel() >= 50)) { + else if ((!strcasecmp(sep->arg[2], "feral")) && (c->GetLevel() >= 50)) { Sower->Say("Casting Feral Pack..."); Sower->CastSpell(4058, c->GetID(), 1, -1, -1); } else if ((!strcasecmp(sep->arg[2], "feral")) && (c->GetLevel() <= 50)) { Sower->Say("I'm not level 50 yet."); } - else if ((!strcasecmp(sep->arg[2], "shrew")) && (c->GetLevel() >= 35)) { + else if ((!strcasecmp(sep->arg[2], "shrew")) && (c->GetLevel() >= 35)) { Sower->Say("Casting Pack Shrew..."); Sower->CastSpell(4055, c->GetID(), 1, -1, -1); } @@ -13667,7 +13667,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { case SHAMAN: - if ((zone->CanCastOutdoor()) && (c->GetLevel() >= 9)) { + if ((zone->CanCastOutdoor()) && (c->GetLevel() >= 9)) { Sower->Say("Casting SoW..."); Sower->CastToClient()->CastSpell(278, c->GetID(), 1, -1, -1); } @@ -13747,7 +13747,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { switch(ShrinkerClass) { case SHAMAN: - if (c->GetLevel() >= 15) { + if (c->GetLevel() >= 15) { Shrinker->Say("Casting Shrink..."); Shrinker->CastToBot()->SpellOnTarget(345, target); } @@ -13808,103 +13808,103 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Gater->Say("Casting Circle of Commons..."); Gater->CastSpell(551, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "tox")) && (c->GetLevel() >= 25)) { + else if ((!strcasecmp(sep->arg[2], "tox")) && (c->GetLevel() >= 25)) { Gater->Say("Casting Circle of Toxxulia..."); Gater->CastSpell(552, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "butcher")) && (c->GetLevel() >= 25)) { + else if ((!strcasecmp(sep->arg[2], "butcher")) && (c->GetLevel() >= 25)) { Gater->Say("Casting Circle of Butcherblock..."); Gater->CastSpell(553, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "lava")) && (c->GetLevel() >= 30)) { + else if ((!strcasecmp(sep->arg[2], "lava")) && (c->GetLevel() >= 30)) { Gater->Say("Casting Circle of Lavastorm..."); Gater->CastSpell(554, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "ro")) && (c->GetLevel() >= 32)) { + else if ((!strcasecmp(sep->arg[2], "ro")) && (c->GetLevel() >= 32)) { Gater->Say("Casting Circle of Ro..."); Gater->CastSpell(555, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "feerrott")) && (c->GetLevel() >= 32)) { + else if ((!strcasecmp(sep->arg[2], "feerrott")) && (c->GetLevel() >= 32)) { Gater->Say("Casting Circle of feerrott..."); Gater->CastSpell(556, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "steamfont")) && (c->GetLevel() >= 31)) { + else if ((!strcasecmp(sep->arg[2], "steamfont")) && (c->GetLevel() >= 31)) { Gater->Say("Casting Circle of Steamfont..."); Gater->CastSpell(557, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "misty")) && (c->GetLevel() >= 36)) { + else if ((!strcasecmp(sep->arg[2], "misty")) && (c->GetLevel() >= 36)) { Gater->Say("Casting Circle of Misty..."); Gater->CastSpell(558, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "wakening")) && (c->GetLevel() >= 40)) { + else if ((!strcasecmp(sep->arg[2], "wakening")) && (c->GetLevel() >= 40)) { Gater->Say("Casting Circle of Wakening Lands..."); Gater->CastSpell(1398, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "iceclad")) && (c->GetLevel() >= 32)) { + else if ((!strcasecmp(sep->arg[2], "iceclad")) && (c->GetLevel() >= 32)) { Gater->Say("Casting Circle of Iceclad Ocean..."); Gater->CastSpell(1434, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "divide")) && (c->GetLevel() >= 36)) { + else if ((!strcasecmp(sep->arg[2], "divide")) && (c->GetLevel() >= 36)) { Gater->Say("Casting Circle of The Great Divide..."); Gater->CastSpell(1438, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "cobalt")) && (c->GetLevel() >= 42)) { + else if ((!strcasecmp(sep->arg[2], "cobalt")) && (c->GetLevel() >= 42)) { Gater->Say("Casting Circle of Cobalt Scar..."); Gater->CastSpell(1440, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "combines")) && (c->GetLevel() >= 33)) { + else if ((!strcasecmp(sep->arg[2], "combines")) && (c->GetLevel() >= 33)) { Gater->Say("Casting Circle of The Combines..."); Gater->CastSpell(1517, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "surefall")) && (c->GetLevel() >= 26)) { + else if ((!strcasecmp(sep->arg[2], "surefall")) && (c->GetLevel() >= 26)) { Gater->Say("Casting Circle of Surefall Glade..."); Gater->CastSpell(2020, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "grimling")) && (c->GetLevel() >= 29)) { + else if ((!strcasecmp(sep->arg[2], "grimling")) && (c->GetLevel() >= 29)) { Gater->Say("Casting Circle of Grimling Forest..."); Gater->CastSpell(2419, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "twilight")) && (c->GetLevel() >= 33)) { + else if ((!strcasecmp(sep->arg[2], "twilight")) && (c->GetLevel() >= 33)) { Gater->Say("Casting Circle of Twilight..."); Gater->CastSpell(2424, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "dawnshroud")) && (c->GetLevel() >= 37)) { + else if ((!strcasecmp(sep->arg[2], "dawnshroud")) && (c->GetLevel() >= 37)) { Gater->Say("Casting Circle of Dawnshroud..."); Gater->CastSpell(2429, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "nexus")) && (c->GetLevel() >= 26)) { + else if ((!strcasecmp(sep->arg[2], "nexus")) && (c->GetLevel() >= 26)) { Gater->Say("Casting Circle of The Nexus..."); Gater->CastSpell(2432, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "pok")) && (c->GetLevel() >= 38)) { + else if ((!strcasecmp(sep->arg[2], "pok")) && (c->GetLevel() >= 38)) { Gater->Say("Casting Circle of Knowledge..."); Gater->CastSpell(3184, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "stonebrunt")) && (c->GetLevel() >= 28)) { + else if ((!strcasecmp(sep->arg[2], "stonebrunt")) && (c->GetLevel() >= 28)) { Gater->Say("Casting Circle of Stonebrunt Mountains..."); Gater->CastSpell(3792, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "bloodfields")) && (c->GetLevel() >= 55)) { + else if ((!strcasecmp(sep->arg[2], "bloodfields")) && (c->GetLevel() >= 55)) { Gater->Say("Casting Circle of Bloodfields..."); Gater->CastSpell(6184, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "emerald")) && (c->GetLevel() >= 39)) { + else if ((!strcasecmp(sep->arg[2], "emerald")) && (c->GetLevel() >= 39)) { Gater->Say("Casting Wind of the South..."); Gater->CastSpell(1737, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "skyfire")) && (c->GetLevel() >= 44)) { + else if ((!strcasecmp(sep->arg[2], "skyfire")) && (c->GetLevel() >= 44)) { Gater->Say("Casting Wind of the North..."); Gater->CastSpell(1736, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "slaughter")) && (c->GetLevel() >= 64)) { + else if ((!strcasecmp(sep->arg[2], "slaughter")) && (c->GetLevel() >= 64)) { Gater->Say("Casting Circle of Slaughter..."); Gater->CastSpell(6179, c->GetID(), 1, -1, -1); } - else if ((!strcasecmp(sep->arg[2], "karana") - || !strcasecmp(sep->arg[2], "tox") + else if ((!strcasecmp(sep->arg[2], "karana") + || !strcasecmp(sep->arg[2], "tox") || !strcasecmp(sep->arg[2], "butcher") && (c->GetLevel() <= 25)) || !strcasecmp(sep->arg[2], "commons") && (c->GetLevel() <= 27) - || (!strcasecmp(sep->arg[2], "ro") + || (!strcasecmp(sep->arg[2], "ro") || !strcasecmp(sep->arg[2], "feerrott") && (c->GetLevel() <= 32)) || !strcasecmp(sep->arg[2], "steamfont") && (c->GetLevel() <= 31) || !strcasecmp(sep->arg[2], "misty") && (c->GetLevel() <= 36) @@ -14218,18 +14218,18 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { else if ((c->GetLevel() <= 4) && (!strcasecmp(sep->arg[2], "live"))) { Inviser->Say("I'm not level 4 yet."); } - else if ((!c->IsInvisible(c))&& (!c->invisible_undead) && (c->GetLevel() >= 4) && (!strcasecmp(sep->arg[2], "live"))) { + else if ((!c->IsInvisible(c))&& (!c->invisible_undead) && (c->GetLevel() >= 4) && (!strcasecmp(sep->arg[2], "live"))) { Inviser->Say("Casting invisibilty..."); Inviser->CastSpell(42, c->GetID(), 1, -1, -1); } else if ((c->GetLevel() <= 6) && (!strcasecmp(sep->arg[2], "see"))) { Inviser->Say("I'm not level 6 yet."); } - else if ((c->GetLevel() >= 6) && (!strcasecmp(sep->arg[2], "see"))) { + else if ((c->GetLevel() >= 6) && (!strcasecmp(sep->arg[2], "see"))) { Inviser->Say("Casting see invisible..."); Inviser->CastSpell(80, c->GetID(), 1, -1, -1); } - else if ((c->IsInvisible(c)) || (c->invisible_undead)) { + else if ((c->IsInvisible(c)) || (c->invisible_undead)) { Inviser->Say("I can't cast this if you're already invis-buffed..."); } else { @@ -14243,18 +14243,18 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { else if ((c->GetLevel() <= 8) && (!strcasecmp(sep->arg[2], "live"))) { Inviser->Say("I'm not level 8 yet."); } - else if ((!c->IsInvisible(c))&& (!c->invisible_undead) && (c->GetLevel() >= 8) && (!strcasecmp(sep->arg[2], "live"))) { + else if ((!c->IsInvisible(c))&& (!c->invisible_undead) && (c->GetLevel() >= 8) && (!strcasecmp(sep->arg[2], "live"))) { Inviser->Say("Casting invisibilty..."); Inviser->CastSpell(42, c->GetID(), 1, -1, -1); } else if ((c->GetLevel() <= 16) && (!strcasecmp(sep->arg[2], "see"))) { Inviser->Say("I'm not level 16 yet."); } - else if ((c->GetLevel() >= 16) && (!strcasecmp(sep->arg[2], "see"))) { + else if ((c->GetLevel() >= 16) && (!strcasecmp(sep->arg[2], "see"))) { Inviser->Say("Casting see invisible..."); Inviser->CastSpell(80, c->GetID(), 1, -1, -1); } - else if ((c->IsInvisible(c)) || (c->invisible_undead)) { + else if ((c->IsInvisible(c)) || (c->invisible_undead)) { Inviser->Say("I can't cast this if you're already invis-buffed..."); } else { @@ -14272,18 +14272,18 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { else if ((c->GetLevel() <= 16) && (!strcasecmp(sep->arg[2], "live"))) { Inviser->Say("I'm not level 16 yet."); } - else if ((!c->IsInvisible(c))&& (!c->invisible_undead) && (c->GetLevel() >= 16) && (!strcasecmp(sep->arg[2], "live"))) { + else if ((!c->IsInvisible(c))&& (!c->invisible_undead) && (c->GetLevel() >= 16) && (!strcasecmp(sep->arg[2], "live"))) { Inviser->Say("Casting invisibilty..."); Inviser->CastSpell(42, c->GetID(), 1, -1, -1); } else if ((c->GetLevel() <= 4) && (!strcasecmp(sep->arg[2], "see"))) { Inviser->Say("I'm not level 6 yet."); } - else if ((c->GetLevel() >= 4) && (!strcasecmp(sep->arg[2], "see"))) { + else if ((c->GetLevel() >= 4) && (!strcasecmp(sep->arg[2], "see"))) { Inviser->Say("Casting see invisible..."); Inviser->CastSpell(80, c->GetID(), 1, -1, -1); } - else if ((c->IsInvisible(c)) || (c->invisible_undead)) { + else if ((c->IsInvisible(c)) || (c->invisible_undead)) { Inviser->Say("I can't cast this if you're already invis-buffed..."); } else { @@ -14295,13 +14295,13 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Inviser->Say("Casting invis undead..."); Inviser->CastSpell(235, c->GetID(), 1, -1, -1); } - else if (!strcasecmp(sep->arg[2], "see")) { + else if (!strcasecmp(sep->arg[2], "see")) { Inviser->Say("I don't have that spell..."); } - else if (!strcasecmp(sep->arg[2], "live")) { + else if (!strcasecmp(sep->arg[2], "live")) { Inviser->Say("I don't have that spell..."); } - else if ((c->IsInvisible(c))|| (c->invisible_undead)) { + else if ((c->IsInvisible(c))|| (c->invisible_undead)) { Inviser->Say("I can't cast this if you're already invis-buffed..."); } else { @@ -14315,25 +14315,25 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { else if ((c->GetLevel() <= 4) && (!strcasecmp(sep->arg[2], "live"))) { Inviser->Say("I'm not level 4 yet."); } - else if ((!c->IsInvisible(c))&& (!c->invisible_undead) && (c->GetLevel() >= 18) && (!strcasecmp(sep->arg[2], "live"))) { + else if ((!c->IsInvisible(c))&& (!c->invisible_undead) && (c->GetLevel() >= 18) && (!strcasecmp(sep->arg[2], "live"))) { Inviser->Say("Casting Superior Camouflage..."); Inviser->CastSpell(34, c->GetID(), 1, -1, -1); } - else if ((!c->IsInvisible(c))&& (!c->invisible_undead) && (c->GetLevel() >= 4) && (!strcasecmp(sep->arg[2], "live")) && (zone->CanCastOutdoor())) { + else if ((!c->IsInvisible(c))&& (!c->invisible_undead) && (c->GetLevel() >= 4) && (!strcasecmp(sep->arg[2], "live")) && (zone->CanCastOutdoor())) { Inviser->Say("Casting Camouflage..."); Inviser->CastSpell(247, c->GetID(), 1, -1, -1); } - else if ((c->GetLevel() >= 4) && (!strcasecmp(sep->arg[2], "live")) && (!zone->CanCastOutdoor())) { + else if ((c->GetLevel() >= 4) && (!strcasecmp(sep->arg[2], "live")) && (!zone->CanCastOutdoor())) { Inviser->Say("I can't cast this spell indoors..."); } else if ((c->GetLevel() <= 13) && (!strcasecmp(sep->arg[2], "see"))) { Inviser->Say("I'm not level 13 yet."); } - else if ((c->GetLevel() >= 13) && (!strcasecmp(sep->arg[2], "see"))) { + else if ((c->GetLevel() >= 13) && (!strcasecmp(sep->arg[2], "see"))) { Inviser->Say("Casting see invisible..."); Inviser->CastSpell(80, c->GetID(), 1, -1, -1); } - else if ((c->IsInvisible(c)) || (c->invisible_undead)) { + else if ((c->IsInvisible(c)) || (c->invisible_undead)) { Inviser->Say("I can't cast this if you're already invis-buffed..."); } else { @@ -14400,7 +14400,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { case SHAMAN: - if ((zone->CanCastOutdoor()) && (c->GetLevel() >= 10)) { + if ((zone->CanCastOutdoor()) && (c->GetLevel() >= 10)) { Lever->Say("Casting Levitate..."); Lever->CastToClient()->CastSpell(261, c->GetID(), 1, -1, -1); } @@ -14502,12 +14502,12 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } else if (!strcasecmp(sep->arg[2], "magic") && (c->GetLevel() <= 16) || !strcasecmp(sep->arg[2], "cold") && (c->GetLevel() <= 13) - || !strcasecmp(sep->arg[2], "fire") && (c->GetLevel() <= 8) + || !strcasecmp(sep->arg[2], "fire") && (c->GetLevel() <= 8) || !strcasecmp(sep->arg[2], "disease") && (c->GetLevel() <= 11) || !strcasecmp(sep->arg[2], "poison") && (c->GetLevel() <= 6)) { Resister->Say("I don't have the needed level yet", sep->arg[2]); } - else + else Resister->Say("Do you want [resist poison], [resist disease], [resist fire], [resist cold], or [resist magic]?", c->GetName()); break; @@ -14535,12 +14535,12 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } else if (!strcasecmp(sep->arg[2], "magic") && (c->GetLevel() <= 19) || !strcasecmp(sep->arg[2], "cold") && (c->GetLevel() <= 1) - || !strcasecmp(sep->arg[2], "fire") && (c->GetLevel() <= 5) + || !strcasecmp(sep->arg[2], "fire") && (c->GetLevel() <= 5) || !strcasecmp(sep->arg[2], "disease") && (c->GetLevel() <= 8) || !strcasecmp(sep->arg[2], "poison") && (c->GetLevel() <= 20)) { Resister->Say("I don't have the needed level yet", sep->arg[2]); } - else + else Resister->Say("Do you want [resist poison], [resist disease], [resist fire], [resist cold], or [resist magic]?", c->GetName()); break; @@ -14573,7 +14573,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { || !strcasecmp(sep->arg[2], "poison") && (c->GetLevel() <= 19)) { Resister->Say("I don't have the needed level yet", sep->arg[2]) ; } - else + else Resister->Say("Do you want [resist poison], [resist disease], [resist fire], [resist cold], or [resist magic]?", c->GetName()); break; @@ -14689,7 +14689,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Mob* targetMob = c->GetTarget(); std::string targetName = std::string(sep->arg[3]); Bot* botGroupLeader = 0; - + if(!targetName.empty()) { botGroupLeader = entity_list.GetBotByBotName(targetName); } @@ -14805,7 +14805,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Mob* targetMob = c->GetTarget(); std::string targetName = std::string(sep->arg[3]); Bot* botGroupMember = 0; - + if(!targetName.empty()) { botGroupMember = entity_list.GetBotByBotName(targetName); } @@ -14836,7 +14836,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Mob* targetMob = c->GetTarget(); std::string targetName = std::string(sep->arg[3]); Bot* botGroupLeader = 0; - + if(!targetName.empty()) { botGroupLeader = entity_list.GetBotByBotName(targetName); } @@ -14848,7 +14848,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(botGroupLeader) { if(botGroupLeader->HasGroup()) { Group* g = botGroupLeader->GetGroup(); - + if(g->IsLeader(botGroupLeader)) { if(Bot::RemoveBotFromGroup(botGroupLeader, g)) botGroupLeader->Say("I have disbanded my group, %s.", c->GetName()); @@ -14872,7 +14872,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Mob* targetMob = c->GetTarget(); std::string targetName = std::string(sep->arg[3]); Bot* botGroupLeader = 0; - + if(!targetName.empty()) { botGroupLeader = entity_list.GetBotByBotName(targetName); } @@ -14884,7 +14884,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(botGroupLeader) { if(botGroupLeader->HasGroup()) { Group* g = botGroupLeader->GetGroup(); - + if(g->IsLeader(botGroupLeader)) BotGroupSummon(g, c); } @@ -14899,7 +14899,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Mob* targetMob = c->GetTarget(); std::string targetName = std::string(sep->arg[3]); Bot* botGroupLeader = 0; - + if(!targetName.empty()) { botGroupLeader = entity_list.GetBotByBotName(targetName); } @@ -14911,7 +14911,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(botGroupLeader) { if(botGroupLeader->HasGroup()) { Group* g = botGroupLeader->GetGroup(); - + if(g->IsLeader(botGroupLeader)) BotGroupOrderFollow(g, c); } @@ -14926,7 +14926,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Mob* targetMob = c->GetTarget(); std::string targetName = std::string(sep->arg[3]); Bot* botGroupLeader = 0; - + if(!targetName.empty()) { botGroupLeader = entity_list.GetBotByBotName(targetName); } @@ -14938,7 +14938,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(botGroupLeader) { if(botGroupLeader->HasGroup()) { Group* g = botGroupLeader->GetGroup(); - + if(g->IsLeader(botGroupLeader)) BotGroupOrderGuard(g, c); } @@ -14954,7 +14954,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Bot* botGroupLeader = 0; std::string botGroupLeaderName = std::string(sep->arg[3]); std::string targetName = std::string(sep->arg[4]); - + if(!botGroupLeaderName.empty()) { botGroupLeader = entity_list.GetBotByBotName(botGroupLeaderName); @@ -14962,7 +14962,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(!targetName.empty()) { targetMob = entity_list.GetMob(targetName.c_str()); } - + if(targetMob) { if(c->IsAttackAllowed(targetMob)) { if(botGroupLeader->HasGroup()) { @@ -14998,7 +14998,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(!botGroupList.empty()) { - for(std::list::iterator botGroupListItr = botGroupList.begin(); botGroupListItr != botGroupList.end(); botGroupListItr++) { + for(std::list::iterator botGroupListItr = botGroupList.begin(); botGroupListItr != botGroupList.end(); botGroupListItr++) { c->Message(0, "Bot Group Name: %s -- Bot Group Leader: %s", botGroupListItr->BotGroupName.c_str(), botGroupListItr->BotGroupLeaderName.c_str()); } } @@ -15092,7 +15092,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } // Fail if maximum number of spawned bots allowed for client met or exceeded - // OR will be when bot group is spawned. + // OR will be when bot group is spawned. const int allowedBotsSBC = RuleI(Bots, SpawnBotCount); if(spawnedBots >= allowedBotsSBC || spawnedBots + (int)botGroup.size() > allowedBotsSBC) { @@ -15222,7 +15222,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { else c->Message(0, "You must target a bot that is in the same zone as you."); } - else + else c->Message(0, "The bot group name already exists. Please choose another name to save your bot group as."); } @@ -15244,7 +15244,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { uint8 BeardColor = target->GetBeardColor(); uint8 EyeColor1 = target->GetEyeColor1(); uint8 EyeColor2 = target->GetEyeColor2(); - + uint8 LuclinFace = target->GetLuclinFace(); uint8 Beard = target->GetBeard(); uint32 DrakkinHeritage = target->GetDrakkinHeritage(); @@ -15267,7 +15267,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { return; } } - if (!strcasecmp(sep->arg[1], "face")) + if (!strcasecmp(sep->arg[1], "face")) LuclinFace = atoi(sep->arg[2]); if (!strcasecmp(sep->arg[1], "eyes")) { @@ -15294,7 +15294,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { return; } } - + target->SendIllusionPacket(Race, Gender, Texture, HelmTexture, HairColor, BeardColor, EyeColor1, EyeColor2, HairStyle, LuclinFace, Beard, 0xFF, DrakkinHeritage, DrakkinTattoo, DrakkinDetails, Size); @@ -15316,11 +15316,11 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } return; } - + if(!strcasecmp(sep->arg[1], "taunt")) { - bool taunt = false; + bool taunt = false; bool toggle = false; - + if(sep->arg[2]){ if(!strcasecmp(sep->arg[2], "on")) taunt = true; @@ -15330,11 +15330,11 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { c->Message(0, "Usage #bot taunt [on|off]"); return; } - + Bot* targetedBot; - + if(c->GetTarget() != NULL) { - if (c->GetTarget()->IsBot() && (c->GetTarget()->CastToBot()->GetBotOwner() == c)) + if (c->GetTarget()->IsBot() && (c->GetTarget()->CastToBot()->GetBotOwner() == c)) targetedBot = c->GetTarget()->CastToBot(); else c->Message(13, "You must target a bot that you own."); @@ -15343,7 +15343,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(targetedBot->GetSkill(TAUNT) > 0) { if(toggle) taunt = !targetedBot->taunting; - + if(taunt) { if(!targetedBot->taunting) targetedBot->Say("I am now taunting."); @@ -15352,7 +15352,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(targetedBot->taunting) targetedBot->Say("I am no longer taunting."); } - + targetedBot->SetTaunting(taunt); } else @@ -15366,7 +15366,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { else { c->Message(0, "Usage #bot taunt [on|off]"); } - + return; } @@ -15374,7 +15374,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(sep->argnum == 3){ Bot* tempBot = NULL; std::string botName = std::string(sep->arg[2]); - + if(!botName.empty()) tempBot = entity_list.GetBotByBotName(botName); else @@ -15384,7 +15384,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { std::string stanceName; BotStanceType botStance; - if (tempBot->GetBotOwner() != c) { + if (tempBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -15467,7 +15467,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { c->Message(0, "Usage #bot groupmessages [on|off] [bot name|all]"); return; } - + Bot* tempBot; if(!strcasecmp(sep->arg[3], "all")) { @@ -15498,7 +15498,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(tempBot) { - if (tempBot->GetBotOwner() != c) { + if (tempBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -15532,7 +15532,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { uint8 botlevel = tempBot->GetLevel(); uint32 defensiveSpellID = 0; - if (tempBot->GetBotOwner() != c) { + if (tempBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -15610,7 +15610,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(!strcasecmp(sep->arg[2], "create")) { if(sep->argnum == 5 || sep->argnum == 6) { //allows for target or not Bot* leaderBot; - + std::string botName = std::string(sep->arg[3]); if(!botName.empty()) @@ -15632,12 +15632,12 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { timer = (uint32)(atof(sep->arg[4]) * 1000); - if (leaderBot->GetBotOwner() != c) { + if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } - if (!(leaderBot->IsBotCaster() && leaderBot->CanHeal())) { + if (!(leaderBot->IsBotCaster() && leaderBot->CanHeal())) { c->Message(13, "Heal rotation members must be able to heal."); return; } @@ -15649,7 +15649,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { c->Message(0, "Usage #bot healrotation create [target]."); return; } - + if(!leaderBot->GetInHealRotation()) { //check for target if(sep->argnum == 6) { @@ -15690,7 +15690,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(!strcasecmp(sep->arg[2], "addmember")) { - if(sep->argnum == 4) { + if(sep->argnum == 4) { Bot* leaderBot; std::string botName = std::string(sep->arg[3]); @@ -15705,7 +15705,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { Bot* healer; std::string healerName = std::string(sep->arg[4]); - if (leaderBot->GetBotOwner() != c) { + if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -15716,14 +15716,14 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { c->Message(13, "You must name a valid bot."); return; } - + if(healer) { - if (healer->GetBotOwner() != c) { + if (healer->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } - if (!(healer->IsBotCaster() && healer->CanHeal())) { + if (!(healer->IsBotCaster() && healer->CanHeal())) { c->Message(13, "Heal rotation members must be able to heal."); return; } @@ -15749,7 +15749,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(!strcasecmp(sep->arg[2], "removemember")) { - if(sep->argnum == 4) { + if(sep->argnum == 4) { Bot* leaderBot; std::string botName = std::string(sep->arg[3]); @@ -15761,7 +15761,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(leaderBot) { - if (leaderBot->GetBotOwner() != c) { + if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -15775,9 +15775,9 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { c->Message(13, "You must name a valid bot."); return; } - + if(healer) { - if (healer->GetBotOwner() != c) { + if (healer->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -15819,7 +15819,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(leaderBot) { - if (leaderBot->GetBotOwner() != c) { + if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -15830,11 +15830,11 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(!targetName.empty()) target = entity_list.GetMob(targetName.c_str()); else { - if(c->GetTarget() != NULL) { + if(c->GetTarget() != NULL) { target = c->GetTarget(); } } - + if(target) { //add target if(leaderBot->AddHealRotationTarget(target)) { @@ -15873,7 +15873,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { } if(leaderBot) { - if (leaderBot->GetBotOwner() != c) { + if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -15887,7 +15887,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { c->Message(13, "You must name a valid target."); return; } - + if(target) { //add to rotation if(leaderBot->RemoveHealRotationTarget(target)) { @@ -15953,7 +15953,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(leaderBot) { list botList; int index = 0; - if (leaderBot->GetBotOwner() != c) { + if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -16025,7 +16025,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(leaderBot) { list botList; - if (leaderBot->GetBotOwner() != c) { + if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -16084,7 +16084,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(leaderBot) { list botList; - if (leaderBot->GetBotOwner() != c) { + if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -16131,7 +16131,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { return; } } - + if(!strcasecmp(sep->arg[2], "cleartargets")) { if(sep->argnum == 3) { Bot* leaderBot; @@ -16146,7 +16146,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(leaderBot) { list botList; - if (leaderBot->GetBotOwner() != c) { + if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } @@ -16170,7 +16170,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { return; } } - + if(!strcasecmp(sep->arg[2], "fastheals")) { if(sep->argnum == 3) { Bot* leaderBot; @@ -16186,11 +16186,11 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) { if(leaderBot) { bool fastHeals = false; list botList; - if (leaderBot->GetBotOwner() != c) { + if (leaderBot->GetBotOwner() != c) { c->Message(13, "You must target a bot that you own."); return; } - + //get percentage heals & target if(!strcasecmp(sep->arg[4], "on")) fastHeals = true; @@ -16278,7 +16278,7 @@ bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, fl _log(AI__ERROR, "Error: detrimental spells requested from AICheckCloseBeneficialSpells!!"); return(false); } - + if(!caster) return false; @@ -16297,11 +16297,11 @@ bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, fl // Changed so heal based on health percentage is different for hybrids if( botCasterClass == CLERIC || botCasterClass == DRUID || botCasterClass == SHAMAN) { //If AI_EngagedCastCheck() said to the healer that he had to heal - + // check in group if(caster->HasGroup()) { Group *g = caster->GetGroup(); - + if(g) { for(int i = 0; i < MAX_GROUP_MEMBERS; i++) { if(g->members[i] && !g->members[i]->qglobal) { @@ -16344,9 +16344,9 @@ bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, fl // check in group if(caster->HasGroup()) { Group *g = caster->GetGroup(); - + float hpRatioToHeal = 25.0f; - + switch(caster->GetBotStance()) { case BotStanceAggressive: @@ -16365,7 +16365,7 @@ bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, fl hpRatioToHeal = 25.0f; break; } - + if(g) { for(int i = 0; i < MAX_GROUP_MEMBERS; i++) { if(g->members[i] && !g->members[i]->qglobal) { @@ -16401,7 +16401,7 @@ bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, fl // TODO: raid heals } } - + //Ok for the buffs.. if( iSpellTypes == SpellType_Buff) { uint8 chanceToCast = caster->IsEngaged()?caster->GetChanceToCastBySpellType(SpellType_Buff):100; @@ -16412,10 +16412,10 @@ bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, fl else return false; } - + if(caster->HasGroup()) { Group *g = caster->GetGroup(); - + if(g) { for( int i = 0; i < MAX_GROUP_MEMBERS; i++) { if(g->members[i]) { @@ -16435,14 +16435,14 @@ bool EntityList::Bot_AICheckCloseBeneficialSpells(Bot* caster, uint8 iChance, fl if( iSpellTypes == SpellType_Cure) { if(caster->HasGroup()) { Group *g = caster->GetGroup(); - + if(g) { for( int i = 0; i < MAX_GROUP_MEMBERS; i++) { if(g->members[i] && caster->GetNeedsCured(g->members[i])) { if(caster->AICastSpell(g->members[i], caster->GetChanceToCastBySpellType(SpellType_Cure), SpellType_Cure)) return true; else if(botCasterClass == BARD) - return false; + return false; } if(g->members[i] && g->members[i]->GetPet() && caster->GetNeedsCured(g->members[i]->GetPet())) { @@ -16465,7 +16465,7 @@ Mob* EntityList::GetMobByBotID(uint32 botID) { if(botID > 0) { LinkedListIterator iterator(mob_list); - + iterator.Reset(); while(iterator.MoreElements()) { @@ -16635,9 +16635,9 @@ void EntityList::ShowSpawnWindow(Client* client, int Distance, bool NamedOnly) { string WindowText; int LastCon = -1; int CurrentCon = 0; - + uint32 array_counter = 0; - + LinkedListIterator iterator(mob_list); iterator.Reset(); @@ -16752,21 +16752,21 @@ void EntityList::ShowSpawnWindow(Client* client, int Distance, bool NamedOnly) { client->SendPopupToClient(WindowTitle, WindowText.c_str()); - return; + return; } uint8 Bot::GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets) { uint8 needHealed = 0; Group *g; - + if(this->HasGroup()) { g = this->GetGroup(); - + if(g) { for( int i = 0; imembers[i] && !g->members[i]->qglobal) { - if(g->members[i]->GetHPRatio() <= hpr) + if(g->members[i]->GetHPRatio() <= hpr) needHealed++; if(includePets) { @@ -16775,7 +16775,7 @@ uint8 Bot::GetNumberNeedingHealedInGroup(uint8 hpr, bool includePets) { } } } - } + } } } @@ -16788,7 +16788,7 @@ uint32 Bot::GetEquipmentColor(uint8 material_slot) const uint32 slotid = 0; uint32 returncolor = 0; uint32 botid = this->GetBotID(); - + //Translate code slot # to DB slot # slotid = Inventory::CalcSlotFromMaterial(material_slot); @@ -16796,7 +16796,7 @@ uint32 Bot::GetEquipmentColor(uint8 material_slot) const char* Query = 0; MYSQL_RES* DatasetResult; MYSQL_ROW DataRow; - + if(database.RunQuery(Query, MakeAnyLenString(&Query, "SELECT color FROM botinventory WHERE BotID = %u AND SlotID = %u", botid, slotid), 0, &DatasetResult)) { if(mysql_num_rows(DatasetResult) == 1) { DataRow = mysql_fetch_row(DatasetResult); @@ -16838,7 +16838,7 @@ uint32 Bot::CalcCurrentWeight() { const Item_Struct* TempItem = 0; ItemInst* inst; uint32 Total = 0; - + for(int i=0; i<=21; ++i) { inst = GetBotItem(i); if(inst) { @@ -16956,13 +16956,13 @@ bool Bot::GetNeedsCured(Mob *tar) { uint32 buff_count = GetMaxTotalSlots(); int buffsWithCounters = 0; needCured = true; - + for (unsigned int j = 0; j < buff_count; j++) { if(tar->GetBuffs()[j].spellid != SPELL_UNKNOWN) { if(CalculateCounters(tar->GetBuffs()[j].spellid) > 0) { buffsWithCounters++; - - if(buffsWithCounters == 1 && (tar->GetBuffs()[j].ticsremaining < 2 || (int32)((tar->GetBuffs()[j].ticsremaining * 6) / tar->GetBuffs()[j].counters) < 2)) { + + if(buffsWithCounters == 1 && (tar->GetBuffs()[j].ticsremaining < 2 || (int32)((tar->GetBuffs()[j].ticsremaining * 6) / tar->GetBuffs()[j].counters) < 2)) { // Spell has ticks remaining but may have too many counters to cure in the time remaining; // We should try to just wait it out. Could spend entire time trying to cure spell instead of healing, buffing, etc. // Since this is the first buff with counters, don't try to cure. Cure spell will be wasted, as cure will try to @@ -16984,13 +16984,13 @@ bool Bot::HasOrMayGetAggro() { if(GetTarget() && GetTarget()->GetHateTop()) { Mob *topHate = GetTarget()->GetHateTop(); - + if(topHate == this) mayGetAggro = true; //I currently have aggro else { uint32 myHateAmt = GetTarget()->GetHateAmount(this); uint32 topHateAmt = GetTarget()->GetHateAmount(topHate); - + if(myHateAmt > 0 && topHateAmt > 0 && (uint8)((myHateAmt/topHateAmt)*100) > 90) //I have 90% as much hate as top, next action may give me aggro mayGetAggro = true; } @@ -17043,10 +17043,10 @@ void Bot::SetDefaultBotStance() { void Bot::BotGroupSay(Mob *speaker, const char *msg, ...) { - + char buf[1000]; va_list ap; - + va_start(ap, msg); vsnprintf(buf, 1000, msg, ap); va_end(ap); @@ -17077,20 +17077,20 @@ bool Bot::UseDiscipline(uint32 spell_id, uint32 target) { Message(0, "You can use this discipline in %d minutes %d seconds.", ((remain)/60), (remain%60)); return(false); }*/ - + //make sure we can use it.. if(!IsValidSpell(spell_id)) { Say("Not a valid spell"); return(false); } - + //can we use the spell? const SPDat_Spell_Struct &spell = spells[spell_id]; uint8 level_to_use = spell.classes[GetClass() - 1]; if(level_to_use == 255) { return(false); } - + if(level_to_use > GetLevel()) { return(false); } @@ -17100,7 +17100,7 @@ bool Bot::UseDiscipline(uint32 spell_id, uint32 target) { } else { return(false); } - + if(spell.recast_time > 0) { if(CheckDisciplineRecastTimers(this, spells[spell_id].EndurTimerIndex)) { @@ -17108,7 +17108,7 @@ bool Bot::UseDiscipline(uint32 spell_id, uint32 target) { //CastSpell(spell_id, target, DISCIPLINE_SPELL_SLOT); if(spells[spell_id].EndurTimerIndex > 0 && spells[spell_id].EndurTimerIndex < MAX_DISCIPLINE_TIMERS) { SetDisciplineRecastTimer(spells[spell_id].EndurTimerIndex, spell.recast_time); - } + } } else { uint32 remain = GetDisciplineRemainingTime(this, spells[spell_id].EndurTimerIndex) / 1000; @@ -17121,7 +17121,7 @@ bool Bot::UseDiscipline(uint32 spell_id, uint32 target) { InterruptSpell(); CastSpell(spell_id, target, DISCIPLINE_SPELL_SLOT); - + return(true); } @@ -17141,9 +17141,9 @@ void Bot::CreateHealRotation( Mob* target, uint32 timer ) { bool Bot::AddHealRotationMember( Bot* healer ) { if(healer) { - if(GetNumHealRotationMembers() > 0 && GetNumHealRotationMembers() < MaxHealRotationMembers) { + if(GetNumHealRotationMembers() > 0 && GetNumHealRotationMembers() < MaxHealRotationMembers) { Bot* tempBot = GetPrevHealRotationMember(); - + if(tempBot) { //add new healer to rotation at end of list for(int i=0; i<3; i++){ @@ -17158,13 +17158,13 @@ bool Bot::AddHealRotationMember( Bot* healer ) { healer->SetInHealRotation(true); healer->SetHasHealedThisCycle(false); healer->SetHealRotationUseFastHeals(tempBot->GetHealRotationUseFastHeals()); - + //set previous rotation member's next member to new member - tempBot->SetNextHealRotationMember(healer); - + tempBot->SetNextHealRotationMember(healer); + //update leader's previous member (end of list) to new member and update rotation data SetPrevHealRotationMember(healer); - + list botList = GetBotsInHealRotation(this); for(list::iterator botListItr = botList.begin(); botListItr != botList.end(); botListItr++) { @@ -17178,12 +17178,12 @@ bool Bot::AddHealRotationMember( Bot* healer ) { } } } - + return false; } bool Bot::RemoveHealRotationMember( Bot* healer ) { - if(healer && GetNumHealRotationMembers() > 0) { + if(healer && GetNumHealRotationMembers() > 0) { Bot* leader = healer->GetHealRotationLeader(); Bot* prevBot = healer->GetPrevHealRotationMember(); Bot* nextBot = healer->GetNextHealRotationMember(); @@ -17206,10 +17206,10 @@ bool Bot::RemoveHealRotationMember( Bot* healer ) { if(prevBot && nextBot && GetNumHealRotationMembers() > 1) { //set previous rotation member's next member to new member - prevBot->SetNextHealRotationMember(nextBot); - + prevBot->SetNextHealRotationMember(nextBot); + //set previous rotation member's next member to new member - nextBot->SetPrevHealRotationMember(prevBot); + nextBot->SetPrevHealRotationMember(prevBot); } //update rotation data @@ -17270,7 +17270,7 @@ bool Bot::AddHealRotationTarget( Mob* target ) { for (int i = 0; i < MaxHealRotationTargets; ++i) { if(_healRotationTargets[i] > 0) { Mob* tempTarget = entity_list.GetMob(_healRotationTargets[i]); - + if(!tempTarget) { _healRotationTargets[i] = 0; } @@ -17283,7 +17283,7 @@ bool Bot::AddHealRotationTarget( Mob* target ) { return false; } } - + if (_healRotationTargets[i] == 0) { list botList = GetBotsInHealRotation(this); @@ -17359,8 +17359,8 @@ bool Bot::RemoveHealRotationTarget( int index ) { } void Bot::ClearHealRotationMembers() { - _healRotationMemberPrev = NULL; - _healRotationMemberNext = NULL; + _healRotationMemberPrev = 0; // No previous member + _healRotationMemberNext = 0; // No next member } void Bot::ClearHealRotationTargets() { @@ -17377,7 +17377,7 @@ Mob* Bot::GetHealRotationTarget( ) { int count = 0; for(int i=0; i 0) { //get first target in list @@ -17385,7 +17385,7 @@ Mob* Bot::GetHealRotationTarget( ) { if(target) { //check if valid target - if(target->GetZoneID() == GetZoneID() + if(target->GetZoneID() == GetZoneID() && !(target->GetAppearance() == eaDead && !(target->IsClient() && target->CastToClient()->GetFeigned()))) { @@ -17396,8 +17396,8 @@ Mob* Bot::GetHealRotationTarget( ) { first = target; } - //check to see if target is group main tank - //(target first, in case top target has died and was rez'd - + //check to see if target is group main tank + //(target first, in case top target has died and was rez'd - //we don't want to heal them then) if(!tank) { Group* g = target->GetGroup(); @@ -17421,7 +17421,7 @@ Mob* Bot::GetHealRotationTarget( ) { if(tank) return tank; - + return first; } @@ -17432,7 +17432,7 @@ Mob* Bot::GetHealRotationTarget( uint8 index ) { //get target at specified index target = entity_list.GetMob(_healRotationTargets[index]); } - + return target; } diff --git a/zone/bot.h b/zone/bot.h index 661f3cc813..d5bd5d1135 100644 --- a/zone/bot.h +++ b/zone/bot.h @@ -32,7 +32,7 @@ const int MaxSpellTypes = 16; const int MaxHealRotationMembers = 6; const int MaxHealRotationTargets = 3; -typedef enum BotStanceType { +enum BotStanceType { BotStancePassive, BotStanceBalanced, BotStanceEfficient, @@ -42,7 +42,7 @@ typedef enum BotStanceType { BotStanceBurnAE }; -typedef enum SpellTypeIndex { +enum SpellTypeIndex { SpellType_NukeIndex, SpellType_HealIndex, SpellType_RootIndex, @@ -64,7 +64,7 @@ typedef enum SpellTypeIndex { class Bot : public NPC { public: // Class enums - typedef enum BotfocusType { //focus types + enum BotfocusType { //focus types BotfocusSpellHaste = 1, BotfocusSpellDuration, BotfocusRange, @@ -97,18 +97,18 @@ class Bot : public NPC { BotfocusAdditionalHeal, }; - typedef enum BotTradeType { // types of trades a bot can do + enum BotTradeType { // types of trades a bot can do BotTradeClientNormal, BotTradeClientNoDropNoTrade }; - typedef enum BotRoleType { + enum BotRoleType { BotRoleMainAssist, BotRoleGroupHealer, BotRoleRaidHealer }; - typedef enum EqExpansions { + enum EqExpansions { ExpansionNone, ExpansionEQ, ExpansionRoK, @@ -143,7 +143,7 @@ class Bot : public NPC { virtual bool HasGroup() { return (GetGroup() ? true : false); } virtual Raid* GetRaid() { return entity_list.GetRaidByMob(this); } virtual Group* GetGroup() { return entity_list.GetGroupByMob(this); } - + // Common, but informal "interfaces" with Client object uint32 CharacterID() { return GetBotID(); } // Just returns the Bot Id inline bool IsInAGuild() const { return (_guildId != GUILD_NONE && _guildId != 0); } @@ -237,7 +237,7 @@ class Bot : public NPC { bool RemoveHealRotationTarget( Mob* target ); bool RemoveHealRotationTarget( int index); void NotifyNextHealRotationMember( bool notifyNow = false ); - void ClearHealRotationLeader() { _healRotationLeader = NULL; } + void ClearHealRotationLeader() { _healRotationLeader = 0; } void ClearHealRotationMembers(); void ClearHealRotationTargets(); inline virtual int16 GetMaxStat(); @@ -285,7 +285,7 @@ class Bot : public NPC { int32 CalcEnduranceRegen(); //Calculates endurance regen used in DoEnduranceRegen() int32 GetEndurance() const {return cur_end;} //This gets our current endurance int32 GetMaxEndurance() const {return max_end;} //This gets our endurance from the last CalcMaxEndurance() call - int32 CalcEnduranceRegenCap(); + int32 CalcEnduranceRegenCap(); inline uint8 GetEndurancePercent() { return (uint8)((float)cur_end / (float)max_end * 100.0f); } void SetEndurance(int32 newEnd); //This sets the current endurance to the new value void DoEnduranceRegen(); //This Regenerates endurance @@ -516,7 +516,7 @@ class Bot : public NPC { inline virtual int16 GetPercMod() const { return itembonuses.percussionMod; } inline virtual int16 GetStringMod() const { return itembonuses.stringedMod; } inline virtual int16 GetWindMod() const { return itembonuses.windMod; } - + inline virtual int16 GetDelayDeath() const { return aabonuses.DelayDeath + spellbonuses.DelayDeath + itembonuses.DelayDeath; } inline InspectMessage_Struct& GetInspectMessage() { return _botInspectMessage; } diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 49e12374de..6685bfa990 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -351,7 +351,7 @@ void MapOpcodes() { ConnectedOpcodes[OP_RespawnWindow] = &Client::Handle_OP_RespawnWindow; ConnectedOpcodes[OP_AdventureMerchantSell] = &Client::Handle_OP_AdventureMerchantSell; ConnectedOpcodes[OP_AdventureStatsRequest] = &Client::Handle_OP_AdventureStatsRequest; - ConnectedOpcodes[OP_AdventureLeaderboardRequest] = &Client::Handle_OP_AdventureLeaderboardRequest; + ConnectedOpcodes[OP_AdventureLeaderboardRequest] = &Client::Handle_OP_AdventureLeaderboardRequest; ConnectedOpcodes[OP_GroupUpdate] = &Client::Handle_OP_GroupUpdate; ConnectedOpcodes[OP_SetStartCity] = &Client::Handle_OP_SetStartCity; ConnectedOpcodes[OP_ItemViewUnknown] = &Client::Handle_OP_Ignore; @@ -624,7 +624,7 @@ void Client::Handle_Connect_OP_ReqClientSpawn(const EQApplicationPacket *app) EQApplicationPacket* outapp = new EQApplicationPacket; // Send Zone Doors - if(entity_list.MakeDoorSpawnPacket(outapp, this)) + if(entity_list.MakeDoorSpawnPacket(outapp, this)) { QueuePacket(outapp); } @@ -862,7 +862,7 @@ void Client::Handle_Connect_OP_ClientUpdate(const EQApplicationPacket *app) void Client::Handle_Connect_OP_ClientReady(const EQApplicationPacket *app) { conn_state = ClientReadyReceived; - + CompleteConnect(); SendHPUpdate(); } @@ -918,8 +918,8 @@ void Client::CheatDetected(CheatTypes CheatType, float x, float y, float z) switch (CheatType) { case MQWarp: //Some zones may still have issues. Database updates will eliminate most if not all problems. - if(RuleB(Zone, EnableMQWarpDetector) - && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) + if(RuleB(Zone, EnableMQWarpDetector) + && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) || (RuleI(Zone, MQWarpExemptStatus)) == -1))) { Message(13, "Large warp detected."); @@ -929,8 +929,8 @@ void Client::CheatDetected(CheatTypes CheatType, float x, float y, float z) } break; case MQWarpShadowStep: - if(RuleB(Zone, EnableMQWarpDetector) - && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) + if(RuleB(Zone, EnableMQWarpDetector) + && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) || (RuleI(Zone, MQWarpExemptStatus)) == -1))) { char *hString = NULL; @@ -940,8 +940,8 @@ void Client::CheatDetected(CheatTypes CheatType, float x, float y, float z) } break; case MQWarpKnockBack: - if(RuleB(Zone, EnableMQWarpDetector) - && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) + if(RuleB(Zone, EnableMQWarpDetector) + && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) || (RuleI(Zone, MQWarpExemptStatus)) == -1))) { char *hString = NULL; @@ -952,8 +952,8 @@ void Client::CheatDetected(CheatTypes CheatType, float x, float y, float z) break; case MQWarpLight: - if(RuleB(Zone, EnableMQWarpDetector) - && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) + if(RuleB(Zone, EnableMQWarpDetector) + && ((this->Admin() < RuleI(Zone, MQWarpExemptStatus) || (RuleI(Zone, MQWarpExemptStatus)) == -1))) { if(RuleB(Zone, MarkMQWarpLT)) @@ -1061,7 +1061,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) dist = sqrt(dist); //the purpose of this first block may not be readily apparent - //basically it's so people don't do a moderate warp every 2.5 seconds + //basically it's so people don't do a moderate warp every 2.5 seconds //letting it even out and basically getting the job done without triggering if(dist == 0) { @@ -1085,7 +1085,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) } else if(IsKnockBackExempted()) { - //still potential to trigger this if you're knocked back off a + //still potential to trigger this if you're knocked back off a //HUGE fall that takes > 2.5 seconds if(speed > 30.0f) { @@ -1157,7 +1157,7 @@ void Client::Handle_OP_ClientUpdate(const EQApplicationPacket *app) } else if(IsKnockBackExempted()) { - //still potential to trigger this if you're knocked back off a + //still potential to trigger this if you're knocked back off a //HUGE fall that takes > 2.5 seconds if(speed > 30.0f) { @@ -1301,7 +1301,7 @@ void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app) return; } - if (app->pBuffer[0] == 0) + if (app->pBuffer[0] == 0) { auto_attack = false; if (IsAIControlled()) @@ -1318,7 +1318,7 @@ void Client::Handle_OP_AutoAttack(const EQApplicationPacket *app) aa_los_them.z = 0; aa_los_them_mob = NULL; } - else if (app->pBuffer[0] == 1) + else if (app->pBuffer[0] == 1) { auto_attack = true; auto_fire = false; @@ -1462,12 +1462,12 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) } // HoTT - if (GetTarget() && GetTarget()->GetTarget()) + if (GetTarget() && GetTarget()->GetTarget()) { SetHoTT(GetTarget()->GetTarget()->GetID()); UpdateXTargetType(TargetsTarget, GetTarget()->GetTarget()); } - else + else { SetHoTT(0); UpdateXTargetType(TargetsTarget, NULL); @@ -1487,7 +1487,7 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) // For /target, send reject or success packet if (app->GetOpcode() == OP_TargetCommand) { if (GetTarget() && !GetTarget()->CastToMob()->IsInvisible(this) && (DistNoRoot(*GetTarget()) <= TARGETING_RANGE*TARGETING_RANGE || GetGM())) { - if(GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special + if(GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special || GetTarget()->GetBodyType() == BT_NoTarget) { //Targeting something we shouldn't with /target @@ -1504,14 +1504,14 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) safe_delete(outapp); return; } - + QueuePacket(app); EQApplicationPacket hp_app; GetTarget()->IsTargeted(1); GetTarget()->CreateHPPacket(&hp_app); QueuePacket(&hp_app, false); - } - else + } + else { EQApplicationPacket* outapp = new EQApplicationPacket(OP_TargetReject, sizeof(TargetReject_Struct)); outapp->pBuffer[0] = 0x2f; @@ -1540,7 +1540,7 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app) GetTarget()->IsTargeted(1); return; } - else if(GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special + else if(GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special || GetTarget()->GetBodyType() == BT_NoTarget) { char *hacker_str = NULL; @@ -1766,7 +1766,7 @@ void Client::Handle_OP_AdventureRequest(const EQApplicationPacket *app) { return; } - + Mob* m = entity_list.GetMob(ars->entity_id); uint32 template_id = 0; if(m && m->IsNPC()) @@ -1785,7 +1785,7 @@ void Client::Handle_OP_AdventureRequest(const EQApplicationPacket *app) sar->type = ars->type; sar->template_id = template_id; strcpy(sar->leader, GetName()); - + if(IsRaidGrouped()) { int i = 0; @@ -1849,7 +1849,7 @@ void Client::Handle_OP_LDoNButton(const EQApplicationPacket *app) } bool* p = (bool*)app->pBuffer; - if(*p == true) + if(*p == true) { ServerPacket *pack = new ServerPacket(ServerOP_AdventureRequestCreate, sizeof(ServerAdventureRequestCreate_Struct) + (64 * adv_requested_member_count)); ServerAdventureRequestCreate_Struct *sac = (ServerAdventureRequestCreate_Struct*)pack->pBuffer; @@ -2255,7 +2255,7 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app) if(fac != 0 && GetModCharacterFactionLevel(fac) < ml.faction_required) { continue; } - + item = database.GetItem(ml.item); if(item) { @@ -2267,7 +2267,7 @@ void Client::Handle_OP_AdventureMerchantRequest(const EQApplicationPacket *app) else if(item->LDoNTheme & 16) { theme = 5; - } + } else if(item->LDoNTheme & 8) { theme = 4; @@ -2350,8 +2350,8 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app) int32 fac = tmp->GetPrimaryFaction(); if(fac != 0 && GetModCharacterFactionLevel(fac) < ml.faction_required) { continue; - } - + } + item = database.GetItem(ml.item); if(!item) continue; @@ -2364,7 +2364,7 @@ void Client::Handle_OP_AdventureMerchantPurchase(const EQApplicationPacket *app) Message(13, "Error: The item you purchased does not exist!"); return; } - + if(aps->Type == LDoNMerchant) { if(m_pp.ldon_points_available < int32(item->LDoNPrice)) { @@ -2522,11 +2522,11 @@ void Client::Handle_OP_ConsiderCorpse(const EQApplicationPacket *app) Message(0, "This corpse will decay in %i hours, %i minutes and %i seconds.", hour, min, sec); else Message(0, "This corpse will decay in %i minutes and %i seconds.", min, sec); - + Message(0, "This corpse %s be resurrected.", tcorpse->Rezzed()?"cannot":"can"); /* hour = 0; - + if((ttime = tcorpse->GetResTime()) != 0) { sec = (ttime/1000)%60; // Total seconds min = (ttime/60000)%60; // Total seconds @@ -2612,7 +2612,7 @@ void Client::Handle_OP_Consider(const EQApplicationPacket *app) void Client::Handle_OP_Begging(const EQApplicationPacket *app) { - if(!p_timers.Expired(&database, pTimerBeggingPickPocket, false)) + if(!p_timers.Expired(&database, pTimerBeggingPickPocket, false)) { Message(13,"Ability recovery time not yet met."); @@ -3075,7 +3075,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app) // don't do anything with this, we tell the client when it's // levitating, not the other way around } - else if (sa->type == AT_ShowHelm) + else if (sa->type == AT_ShowHelm) { m_pp.showhelm = (sa->parameter == 1); entity_list.QueueClients(this, app, true); @@ -3172,13 +3172,13 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app) silentsaylink = true; } - if (sayid && sayid > 0) + if (sayid && sayid > 0) { char errbuf[MYSQL_ERRMSG_SIZE]; char *query = 0; MYSQL_RES *result; MYSQL_ROW row; - + if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT `phrase` FROM saylink WHERE `id` = '%i'", sayid),errbuf,&result)) { @@ -3187,9 +3187,9 @@ void Client::Handle_OP_ItemLinkClick(const EQApplicationPacket *app) row = mysql_fetch_row(result); response = row[0]; } - mysql_free_result(result); + mysql_free_result(result); } - else + else { Message(13, "Error: The saylink (%s) was not found in the database.",response.c_str()); safe_delete_array(query); @@ -3283,11 +3283,11 @@ void Client::Handle_OP_MoveItem(const EQApplicationPacket *app) char *detect = NULL; const ItemInst *itm_from = GetInv().GetItem(mi->from_slot); const ItemInst *itm_to = GetInv().GetItem(mi->to_slot); - MakeAnyLenString(&detect, "Player issued a move item from %u(item id %u) to %u(item id %u) while casting %u.", - mi->from_slot, - itm_from ? itm_from->GetID() : 0, - mi->to_slot, - itm_to ? itm_to->GetID() : 0, + MakeAnyLenString(&detect, "Player issued a move item from %u(item id %u) to %u(item id %u) while casting %u.", + mi->from_slot, + itm_from ? itm_from->GetID() : 0, + mi->to_slot, + itm_to ? itm_to->GetID() : 0, casting_spell_id); database.SetMQDetectionFlag(AccountName(), GetName(), detect, zone->GetShortName()); safe_delete_array(detect); @@ -3301,17 +3301,17 @@ void Client::Handle_OP_MoveItem(const EQApplicationPacket *app) if(mi->from_slot >= 251 && mi->from_slot <= 340) { if(mi->from_slot > 330) { mi_hack = true; } - else { + else { int16 from_parent = m_inv.CalcSlotId(mi->from_slot); if(!m_inv[from_parent]) { mi_hack = true; } else if(!m_inv[from_parent]->IsType(ItemClassContainer)) { mi_hack = true; } else if(m_inv.CalcBagIdx(mi->from_slot) >= m_inv[from_parent]->GetItem()->BagSlots) { mi_hack = true; } } } - + if(mi->to_slot >= 251 && mi->to_slot <= 340) { if(mi->to_slot > 330) { mi_hack = true; } - else { + else { int16 to_parent = m_inv.CalcSlotId(mi->to_slot); if(!m_inv[to_parent]) { mi_hack = true; } else if(!m_inv[to_parent]->IsType(ItemClassContainer)) { mi_hack = true; } @@ -3335,7 +3335,7 @@ void Client::Handle_OP_Camp(const EQApplicationPacket *app) { if(IsLFP()) worldserver.StopLFP(CharacterID()); - if (GetGM()) + if (GetGM()) { OnDisconnect(true); return; @@ -3464,7 +3464,7 @@ void Client::Handle_OP_Sneak(const EQApplicationPacket *app) void Client::Handle_OP_Hide(const EQApplicationPacket *app) { - if(!HasSkill(HIDE) && GetSkill(HIDE) == 0) + if(!HasSkill(HIDE) && GetSkill(HIDE) == 0) { //Can not be able to train hide but still have it from racial though return; //You cannot hide if you do not have hide @@ -3730,7 +3730,7 @@ void Client::Handle_OP_LootRequest(const EQApplicationPacket *app) Corpse::SendLootReqErrorPacket(this); return; } - if (ent->IsCorpse()) + if (ent->IsCorpse()) { Corpse *ent_corpse = ent->CastToCorpse(); if(DistNoRootNoZ(ent_corpse->GetX(), ent_corpse->GetY()) > 625) @@ -3850,7 +3850,7 @@ void Client::Handle_OP_LDoNInspect(const EQApplicationPacket *app) void Client::Handle_OP_Dye(const EQApplicationPacket *app) { if(app->size!=sizeof(DyeStruct)) - printf("Wrong size of DyeStruct, Got: %i, Expected: %i\n",app->size,sizeof(DyeStruct)); + printf("Wrong size of DyeStruct, Got: %i, Expected: %lu\n",app->size,sizeof(DyeStruct)); else{ DyeStruct* dye = (DyeStruct*)app->pBuffer; DyeArmor(dye); @@ -3921,7 +3921,7 @@ void Client::Handle_OP_GuildPublicNote(const EQApplicationPacket *app) if (app->size < sizeof(GuildUpdate_PublicNote)) { // client calls for a motd on login even if they arent in a guild - printf("Error: app size of %i < size of OP_GuildPublicNote of %i\n",app->size,sizeof(GuildUpdate_PublicNote)); + printf("Error: app size of %i < size of OP_GuildPublicNote of %lu\n",app->size,sizeof(GuildUpdate_PublicNote)); return; } GuildUpdate_PublicNote* gpn=(GuildUpdate_PublicNote*)app->pBuffer; @@ -3979,7 +3979,7 @@ void Client::Handle_OP_SetGuildMOTD(const EQApplicationPacket *app) if (app->size != sizeof(GuildMOTD_Struct)) { // client calls for a motd on login even if they arent in a guild - printf("Error: app size of %i != size of GuildMOTD_Struct of %i\n",app->size,sizeof(GuildMOTD_Struct)); + printf("Error: app size of %i != size of GuildMOTD_Struct of %lu\n",app->size,sizeof(GuildMOTD_Struct)); return; } if(!IsInAGuild()) { @@ -4343,7 +4343,7 @@ void Client::Handle_OP_GuildRemove(const EQApplicationPacket *app) #endif uint32 char_id; Client* client = entity_list.GetClientByName(gc->othername); - + if(client) { if(!client->IsInGuild(GuildID())) { Message(0, "You aren't in the same guild, what do you think you are doing?"); @@ -4553,7 +4553,7 @@ LogFile->write(EQEMuLog::Debug, "OP CastSpell: slot=%d, spell=%d, target=%d, inv InterruptSpell(castspell->spell_id); //CHEATER!! return; } - + if ((item->Click.Type == ET_ClickEffect) || (item->Click.Type == ET_Expendable) || (item->Click.Type == ET_EquipClick) || (item->Click.Type == ET_ClickEffect2)) { if(item->Click.Level2 > 0) @@ -4577,7 +4577,7 @@ LogFile->write(EQEMuLog::Debug, "OP CastSpell: slot=%d, spell=%d, target=%d, inv database.SetMQDetectionFlag(account_name, name, "OP_CastSpell with item, did not meet req level.", zone->GetShortName()); Message(0, "Error: level not high enough.", castspell->inventoryslot); InterruptSpell(castspell->spell_id); - } + } } else { @@ -4774,7 +4774,7 @@ void Client::Handle_OP_RezzAnswer(const EQApplicationPacket *app) } const Resurrect_Struct* ra = (const Resurrect_Struct*) app->pBuffer; - _log(SPELLS__REZ, "Received OP_RezzAnswer from client. Pendingrezzexp is %i, action is %s", + _log(SPELLS__REZ, "Received OP_RezzAnswer from client. Pendingrezzexp is %i, action is %s", PendingRezzXP, ra->action ? "ACCEPT" : "DECLINE"); _pkt(SPELLS__REZ, app); @@ -4810,13 +4810,13 @@ void Client::Handle_OP_TradeRequest(const EQApplicationPacket *app) } // Client requesting a trade session from an npc/client // Trade session not started until OP_TradeRequestAck is sent - + BreakInvis(); // Pass trade request on to recipient TradeRequest_Struct* msg = (TradeRequest_Struct*) app->pBuffer; Mob* tradee = entity_list.GetMob(msg->to_mob_id); - + if (tradee && tradee->IsClient()) { tradee->CastToClient()->QueuePacket(app); } @@ -4827,7 +4827,7 @@ void Client::Handle_OP_TradeRequest(const EQApplicationPacket *app) #endif //npcs always accept trade->Start(msg->to_mob_id); - + EQApplicationPacket* outapp = new EQApplicationPacket(OP_TradeRequestAck, sizeof(TradeRequest_Struct)); TradeRequest_Struct* acc = (TradeRequest_Struct*) outapp->pBuffer; acc->from_mob_id = msg->to_mob_id; @@ -4849,7 +4849,7 @@ void Client::Handle_OP_TradeRequestAck(const EQApplicationPacket *app) // Send ack on to trade initiator if client TradeRequest_Struct* msg = (TradeRequest_Struct*) app->pBuffer; Mob* tradee = entity_list.GetMob(msg->to_mob_id); - + if (tradee && tradee->IsClient()) { trade->Start(msg->to_mob_id); tradee->CastToClient()->QueuePacket(app); @@ -4928,7 +4928,7 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) if(other->GetInv().GetItem(slot_id)) { trade_count += other->GetInv().GetItem(slot_id)->GetTotalItemCount(); } if(m_inv[slot_id]) { trade_count += m_inv[slot_id]->GetTotalItemCount(); } } - + ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogTrades, sizeof(QSPlayerLogTrade_Struct) + (sizeof(QSTradeItems_Struct) * trade_count)); // Perform actual trade @@ -4969,14 +4969,14 @@ void Client::Handle_OP_TradeAcceptClick(const EQApplicationPacket *app) } ServerPacket* qspack = new ServerPacket(ServerOP_QSPlayerLogHandins, sizeof(QSPlayerLogHandin_Struct) + (sizeof(QSHandinItems_Struct) * handin_count)); - + FinishTrade(with->CastToNPC(), qspack); qspack->Deflate(); if(worldserver.Connected()) { worldserver.SendPacket(qspack); } safe_delete(qspack); } - else { + else { FinishTrade(with->CastToNPC()); } #ifdef BOTS @@ -5001,7 +5001,7 @@ void Client::Handle_OP_TradeBusy(const EQApplicationPacket *app) // Send busy message on to trade initiator if client TradeBusy_Struct* msg = (TradeBusy_Struct*) app->pBuffer; Mob* tradee = entity_list.GetMob(msg->to_mob_id); - + if (tradee && tradee->IsClient()) { tradee->CastToClient()->QueuePacket(app); } @@ -5018,7 +5018,7 @@ void Client::Handle_OP_BoardBoat(const EQApplicationPacket *app) boatname = new char[app->size-3]; memset(boatname, 0, app->size-3); memcpy(boatname, app->pBuffer, app->size-4); - + Mob* boat = entity_list.GetMob(boatname); if (boat) this->BoatID = boat->GetID(); // set the client's BoatID to show that it's on this boat @@ -5274,7 +5274,7 @@ void Client::Handle_OP_LFGCommand(const EQApplicationPacket *app) LFGComments[0] = '\0'; } break; - case 1: + case 1: if(!LFG) { LFG = true; database.SetLFG(CharacterID(), true); @@ -5392,7 +5392,7 @@ void Client::Handle_OP_ShopRequest(const EQApplicationPacket *app) } Merchant_Click_Struct* mc=(Merchant_Click_Struct*)app->pBuffer; - + // Send back opcode OP_ShopRequest - tells client to open merchant window. //EQApplicationPacket* outapp = new EQApplicationPacket(OP_ShopRequest, sizeof(Merchant_Click_Struct)); //Merchant_Click_Struct* mco=(Merchant_Click_Struct*)outapp->pBuffer; @@ -5490,7 +5490,7 @@ void Client::Handle_OP_BazaarSearch(const EQApplicationPacket *app) BazaarSearch_Struct* bss= (BazaarSearch_Struct*)app->pBuffer; - this->SendBazaarResults(bss->TraderID, bss->Class_, bss->Race, bss->ItemStat, bss->Slot, bss->Type, + this->SendBazaarResults(bss->TraderID, bss->Class_, bss->Race, bss->ItemStat, bss->Slot, bss->Type, bss->Name, bss->MinPrice*1000, bss->MaxPrice*1000); } else if (app->size==sizeof(BazaarWelcome_Struct)) { @@ -5507,7 +5507,7 @@ void Client::Handle_OP_BazaarSearch(const EQApplicationPacket *app) Client *c = entity_list.GetClientByName(nbis->Name); if(c) { ItemInst* inst = c->FindTraderItemBySerialNumber(nbis->SerialNumber); - if(inst) + if(inst) SendItemPacket(0, inst, ItemPacketViewLink); } return; @@ -5563,7 +5563,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) if(fac != 0 && GetModCharacterFactionLevel(fac) < ml.faction_required) { continue; } - + if(mp->itemslot == ml.slot){ item_id = ml.item; break; @@ -5627,7 +5627,7 @@ void Client::Handle_OP_ShopPlayerBuy(const EQApplicationPacket *app) int SinglePrice = 0; if (RuleB(Merchant, UsePriceMod)) - SinglePrice = (item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate * Client::CalcPriceMod(tmp, false)); + SinglePrice = (item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate * Client::CalcPriceMod(tmp, false)); else SinglePrice = (item->Price * (RuleR(Merchant, SellCostMod)) * item->SellRate); @@ -5967,7 +5967,7 @@ void Client::Handle_OP_ClickObjectAction(const EQApplicationPacket *app) sizeof(ClickObjectAction_Struct), app->size); return; } - + ClickObjectAction_Struct* oos = (ClickObjectAction_Struct*)app->pBuffer; Entity* entity = entity_list.GetEntityObject(oos->drop_id); if (entity && entity->IsObject()) { @@ -5981,9 +5981,9 @@ void Client::Handle_OP_ClickObjectAction(const EQApplicationPacket *app) LogFile->write(EQEMuLog::Error, "Invalid object %d in OP_ClickObjectAction", oos->drop_id); } } - + SetTradeskillObject(NULL); - + EQApplicationPacket end_trade1(OP_FinishWindow, 0); QueuePacket(&end_trade1); @@ -6012,7 +6012,7 @@ void Client::Handle_OP_ClickObject(const EQApplicationPacket *app) buf[9] = '\0'; parse->EventPlayer(EVENT_CLICK_OBJECT, this, buf, 0); } - + // Observed in RoF after OP_ClickObjectAction: //EQApplicationPacket end_trade2(OP_FinishWindow2, 0); //QueuePacket(&end_trade2); @@ -6052,7 +6052,7 @@ void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app) char *pos = buf; //Assumes item IDs are <10 characters long - for(r = 0; r < 500; r++) { + for(r = 0; r < 500; r++) { if(tsf->favorite_recipes[r] == 0) continue; @@ -6073,7 +6073,7 @@ void Client::Handle_OP_RecipesFavorite(const EQApplicationPacket *app) qlen = MakeAnyLenString(&query, "SELECT tr.id,tr.name,tr.trivial,SUM(tre.componentcount),crl.madecount,tr.tradeskill " " FROM tradeskill_recipe AS tr " " LEFT JOIN tradeskill_recipe_entries AS tre ON tr.id=tre.recipe_id " - " LEFT JOIN (SELECT recipe_id, madecount FROM char_recipe_list WHERE char_id = %u) AS crl ON tr.id=crl.recipe_id " + " LEFT JOIN (SELECT recipe_id, madecount FROM char_recipe_list WHERE char_id = %u) AS crl ON tr.id=crl.recipe_id " " WHERE tr.id IN (%s) " " AND tr.must_learn & 0x20 <> 0x20 AND ((tr.must_learn & 0x3 <> 0 AND crl.madecount IS NOT NULL) OR (tr.must_learn & 0x3 = 0)) " " GROUP BY tr.id " @@ -6299,7 +6299,7 @@ void Client::Handle_OP_GroupInvite2(const EQApplicationPacket *app) sizeof(GroupInvite_Struct), app->size); return; } - + GroupInvite_Struct* gis = (GroupInvite_Struct*) app->pBuffer; Mob *Invitee = entity_list.GetMob(gis->invitee_name); @@ -6312,7 +6312,7 @@ void Client::Handle_OP_GroupInvite2(const EQApplicationPacket *app) if(Invitee) { if(Invitee->IsClient()) { - if((!Invitee->IsGrouped() && !Invitee->IsRaidGrouped()) || + if((!Invitee->IsGrouped() && !Invitee->IsRaidGrouped()) || (Invitee->GetGroup() && Invitee->CastToClient()->GetMerc() && Invitee->GetGroup()->GroupCount() == 2)) { if(app->GetOpcode() == OP_GroupInvite2) @@ -6515,13 +6515,13 @@ void Client::Handle_OP_GroupFollow2(const EQApplicationPacket *app) { // SoD and later // - inviter->CastToClient()->SendGroupCreatePacket(); - + inviter->CastToClient()->SendGroupCreatePacket(); + inviter->CastToClient()->SendGroupLeaderChangePacket(inviter->GetName()); - inviter->CastToClient()->SendGroupJoinAcknowledge(); + inviter->CastToClient()->SendGroupJoinAcknowledge(); } - + } if(!group) return; @@ -6543,7 +6543,7 @@ void Client::Handle_OP_GroupFollow2(const EQApplicationPacket *app) } if(GetClientVersion() >= EQClientSoD) - SendGroupJoinAcknowledge(); + SendGroupJoinAcknowledge(); database.RefreshGroupFromDB(this); group->SendHPPacketsTo(this); @@ -6638,7 +6638,7 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app) return; #ifdef BOTS - // this block is necessary to allow more control over controlling how bots are zoned or camped. + // this block is necessary to allow more control over controlling how bots are zoned or camped. if(Bot::GroupHasBot(group)) { if(group->IsLeader(this)) { if((GetTarget() == 0 || GetTarget() == this) || (group->GroupCount() < 3)) { @@ -6694,7 +6694,7 @@ void Client::Handle_OP_GroupDisband(const EQApplicationPacket *app) memberToDisband->CastToMerc()->Suspend(); } } - else + else { // ...but other members can only remove themselves group->DelMember(this,false); @@ -6732,7 +6732,7 @@ void Client::Handle_OP_GroupDelete(const EQApplicationPacket *app) if (group) group->DisbandGroup(); - if(LFP) + if(LFP) UpdateLFP(); return; @@ -6799,7 +6799,7 @@ void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app) { for (int16 L = 0; L <= 20; L++) { const ItemInst* inst = GetInv().GetItem(L); item = inst ? inst->GetItem() : NULL; - + if(item) { strcpy(insr->itemnames[L], item->Name); insr->itemicons[L] = item->Icon; @@ -6809,7 +6809,7 @@ void Client::Handle_OP_InspectAnswer(const EQApplicationPacket *app) { const ItemInst* inst = GetInv().GetItem(21); item = inst ? inst->GetItem() : NULL; - + if(item) { strcpy(insr->itemnames[22], item->Name); insr->itemicons[22] = item->Icon; @@ -6876,7 +6876,7 @@ void Client::Handle_OP_DeleteSpell(const EQApplicationPacket *app) void Client::Handle_OP_LoadSpellSet(const EQApplicationPacket *app) { if(app->size!=sizeof(LoadSpellSet_Struct)) { - printf("Wrong size of LoadSpellSet_Struct! Expected: %i, Got: %i\n",sizeof(LoadSpellSet_Struct),app->size); + printf("Wrong size of LoadSpellSet_Struct! Expected: %lu, Got: %i\n",sizeof(LoadSpellSet_Struct),app->size); return; } int i; @@ -6891,7 +6891,7 @@ void Client::Handle_OP_LoadSpellSet(const EQApplicationPacket *app) void Client::Handle_OP_PetitionBug(const EQApplicationPacket *app) { if(app->size!=sizeof(PetitionBug_Struct)) - printf("Wrong size of BugStruct! Expected: %i, Got: %i\n",sizeof(PetitionBug_Struct),app->size); + printf("Wrong size of BugStruct! Expected: %lu, Got: %i\n",sizeof(PetitionBug_Struct),app->size); else{ Message(0, "Petition Bugs are not supported, please use /bug."); } @@ -6901,7 +6901,7 @@ void Client::Handle_OP_PetitionBug(const EQApplicationPacket *app) void Client::Handle_OP_Bug(const EQApplicationPacket *app) { if(app->size!=sizeof(BugStruct)) - printf("Wrong size of BugStruct got %d expected %d!\n", app->size, sizeof(BugStruct)); + printf("Wrong size of BugStruct got %d expected %lu!\n", app->size, sizeof(BugStruct)); else{ BugStruct* bug=(BugStruct*)app->pBuffer; database.UpdateBug(bug); @@ -6939,7 +6939,7 @@ void Client::Handle_OP_Petition(const EQApplicationPacket *app) pet->SetZone(zone->GetZoneID()); pet->SetUrgency(0); petition_list.AddPetition(pet); - database.InsertPetitionToDB(pet); + database.InsertPetitionToDB(pet); petition_list.UpdateGMQueue(); petition_list.UpdateZoneListQueue(); worldserver.SendEmoteMessage(0, 0, 80, 15, "%s has made a petition. #%i", GetName(), pet->GetID()); @@ -7583,7 +7583,7 @@ void Client::Handle_OP_Fishing(const EQApplicationPacket *app) Message(13,"Ability recovery time not yet met."); return; } - + if (CanFish()) { parse->EventPlayer(EVENT_FISH_START, this, "", 0); @@ -7820,9 +7820,9 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) //Show Items if(app->size==sizeof(Trader_ShowItems_Struct)) - { + { Trader_ShowItems_Struct* sis = (Trader_ShowItems_Struct*)app->pBuffer; - + switch(sis->Code) { case BazaarTrader_EndTraderMode: { @@ -8000,7 +8000,7 @@ void Client::Handle_OP_PickPocket(const EQApplicationPacket *app) return; } - if(!p_timers.Expired(&database, pTimerBeggingPickPocket, false)) + if(!p_timers.Expired(&database, pTimerBeggingPickPocket, false)) { Message(13,"Ability recovery time not yet met."); database.SetMQDetectionFlag(this->AccountName(), this->GetName(), "OP_PickPocket was sent again too quickly.", zone->GetShortName()); @@ -8171,7 +8171,7 @@ void Client::Handle_OP_Split(const EQApplicationPacket *app) if(!TakeMoneyFromPP(static_cast(split->copper) + 10 * static_cast(split->silver) + - 100 * static_cast(split->gold) + + 100 * static_cast(split->gold) + 1000 * static_cast(split->platinum))) { Message(13, "You do not have enough money to do that split."); return; @@ -8306,7 +8306,7 @@ void Client::Handle_OP_OpenTributeMaster(const EQApplicationPacket *app) _pkt(TRIBUTE__IN, app); if(app->size != sizeof(StartTribute_Struct)) - printf("Error in OP_OpenTributeMaster. Expected size of: %i, but got: %i\n",sizeof(StartTribute_Struct),app->size); + printf("Error in OP_OpenTributeMaster. Expected size of: %lu, but got: %i\n",sizeof(StartTribute_Struct),app->size); else { //Opens the tribute master window StartTribute_Struct* st = (StartTribute_Struct*)app->pBuffer; @@ -8331,7 +8331,7 @@ void Client::Handle_OP_OpenGuildTributeMaster(const EQApplicationPacket *app) _pkt(TRIBUTE__IN, app); if(app->size != sizeof(StartTribute_Struct)) - printf("Error in OP_OpenGuildTributeMaster. Expected size of: %i, but got: %i\n",sizeof(StartTribute_Struct),app->size); + printf("Error in OP_OpenGuildTributeMaster. Expected size of: %lu, but got: %i\n",sizeof(StartTribute_Struct),app->size); else { //Opens the guild tribute master window StartTribute_Struct* st = (StartTribute_Struct*)app->pBuffer; @@ -8357,7 +8357,7 @@ void Client::Handle_OP_TributeItem(const EQApplicationPacket *app) //player donates an item... if(app->size != sizeof(TributeItem_Struct)) - printf("Error in OP_TributeItem. Expected size of: %i, but got: %i\n",sizeof(StartTribute_Struct),app->size); + printf("Error in OP_TributeItem. Expected size of: %lu, but got: %i\n",sizeof(StartTribute_Struct),app->size); else { TributeItem_Struct* t = (TributeItem_Struct*)app->pBuffer; @@ -8386,7 +8386,7 @@ void Client::Handle_OP_TributeMoney(const EQApplicationPacket *app) //player donates money if(app->size != sizeof(TributeMoney_Struct)) - printf("Error in OP_TributeMoney. Expected size of: %i, but got: %i\n",sizeof(StartTribute_Struct),app->size); + printf("Error in OP_TributeMoney. Expected size of: %lu, but got: %i\n",sizeof(StartTribute_Struct),app->size); else { TributeMoney_Struct* t = (TributeMoney_Struct*)app->pBuffer; @@ -8473,9 +8473,9 @@ void Client::Handle_OP_ControlBoat(const EQApplicationPacket *app) } ControlBoat_Struct* cbs = (ControlBoat_Struct*)app->pBuffer; Mob* boat = entity_list.GetMob(cbs->boatId); - if (boat == 0) + if (boat == 0) return; // do nothing if the boat isn't valid - + if(!boat->IsNPC() || (boat->GetRace() != CONTROLLED_BOAT && boat->GetRace() != 502)) { char *hacked_string = NULL; @@ -8495,9 +8495,9 @@ void Client::Handle_OP_ControlBoat(const EQApplicationPacket *app) return; } } - else + else boat->SetTarget(0); - + EQApplicationPacket* outapp=new EQApplicationPacket(OP_ControlBoat,0); FastQueuePacket(&outapp); safe_delete(outapp); @@ -8534,7 +8534,7 @@ void Client::Handle_OP_Ignore(const EQApplicationPacket *app) void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app) { if(app->size != sizeof(FindPersonRequest_Struct)) - printf("Error in FindPersonRequest_Struct. Expected size of: %i, but got: %i\n",sizeof(FindPersonRequest_Struct),app->size); + printf("Error in FindPersonRequest_Struct. Expected size of: %lu, but got: %i\n",sizeof(FindPersonRequest_Struct),app->size); else { FindPersonRequest_Struct* t = (FindPersonRequest_Struct*)app->pBuffer; @@ -8575,7 +8575,7 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app) VERTEX Start(GetX(), GetY(), GetZ() + (GetSize() < 6.0 ? 6 : GetSize()) * HEAD_POSITION); VERTEX End(target->GetX(), target->GetY(), target->GetZ() + (target->GetSize() < 6.0 ? 6 : target->GetSize()) * HEAD_POSITION); - if(!zone->zonemap->LineIntersectsZone(Start, End, 1.0f, NULL, NULL) && zone->pathing->NoHazards(Start, End)) + if(!zone->zonemap->LineIntersectsZone(Start, End, 1.0f, NULL, NULL) && zone->pathing->NoHazards(Start, End)) { points.resize(2); points[0].x = Start.x; @@ -8585,12 +8585,12 @@ void Client::Handle_OP_FindPersonRequest(const EQApplicationPacket *app) points[1].x = End.x; points[1].y = End.y; points[1].z = End.z; - + } else { list pathlist = zone->pathing->FindRoute(Start, End); - + if(pathlist.size() == 0) { EQApplicationPacket outapp(OP_FindPersonReply, 0); @@ -9257,7 +9257,7 @@ bool Client::FinishConnState2(DBAsyncWork* dbaw) { //////////////////////////////////////////////////////////// // Task Packets LoadClientTaskState(); - + if (GetClientVersion() >= EQClientRoF) { outapp = new EQApplicationPacket(OP_ReqNewZone, 0); @@ -9565,7 +9565,7 @@ void Client::CompleteConnect() zone->weatherSend(); TotalKarma = database.GetKarma(AccountID()); - + SendDisciplineTimers(); parse->EventPlayer(EVENT_ENTERZONE, this, "", 0); @@ -9638,7 +9638,7 @@ void Client::CompleteConnect() entity_list.RefreshClientXTargets(this); } -void Client::Handle_OP_KeyRing(const EQApplicationPacket *app) +void Client::Handle_OP_KeyRing(const EQApplicationPacket *app) { KeyRingList(); } @@ -9716,7 +9716,7 @@ void Client::Handle_OP_PurchaseLeadershipAA(const EQApplicationPacket *app) { u->new_rank = m_pp.leader_abilities.ranks[aaid]; u->pointsleft = m_pp.group_leadership_points; // FIXME: Take into account raid abilities FastQueuePacket(&outapp); - + Group *g = GetGroup(); // Update all group members with the new AA the leader has purchased. @@ -9724,7 +9724,7 @@ void Client::Handle_OP_PurchaseLeadershipAA(const EQApplicationPacket *app) { g->UpdateGroupAAs(); g->SendLeadershipAAUpdate(); } - + } void Client::Handle_OP_SetTitle(const EQApplicationPacket *app) @@ -9775,7 +9775,7 @@ void Client::Handle_OP_BankerChange(const EQApplicationPacket *app) if(!banker || distance > USE_NPC_RANGE2) { char *hacked_string = NULL; - MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(money) but %s is non-existant or too far away (%u units).", + MakeAnyLenString(&hacked_string, "Player tried to make use of a banker(money) but %s is non-existant or too far away (%u units).", banker ? banker->GetName() : "UNKNOWN NPC", distance); database.SetMQDetectionFlag(AccountName(), GetName(), hacked_string, zone->GetShortName()); safe_delete_array(hacked_string); @@ -9785,26 +9785,26 @@ void Client::Handle_OP_BankerChange(const EQApplicationPacket *app) EQApplicationPacket *outapp=new EQApplicationPacket(OP_BankerChange,NULL,sizeof(BankerChange_Struct)); BankerChange_Struct *bc=(BankerChange_Struct *)outapp->pBuffer; - if(m_pp.platinum < 0) + if(m_pp.platinum < 0) m_pp.platinum = 0; - if(m_pp.gold < 0) + if(m_pp.gold < 0) m_pp.gold = 0; - if(m_pp.silver < 0) + if(m_pp.silver < 0) m_pp.silver = 0; - if(m_pp.copper < 0) + if(m_pp.copper < 0) m_pp.copper = 0; - if(m_pp.platinum_bank < 0) + if(m_pp.platinum_bank < 0) m_pp.platinum_bank = 0; - if(m_pp.gold_bank < 0) + if(m_pp.gold_bank < 0) m_pp.gold_bank = 0; - if(m_pp.silver_bank < 0) + if(m_pp.silver_bank < 0) m_pp.silver_bank = 0; - if(m_pp.copper_bank < 0) + if(m_pp.copper_bank < 0) m_pp.copper_bank = 0; - uint64 cp = static_cast(m_pp.copper) + - (static_cast(m_pp.silver) * 10) + + uint64 cp = static_cast(m_pp.copper) + + (static_cast(m_pp.silver) * 10) + (static_cast(m_pp.gold) * 100) + (static_cast(m_pp.platinum) * 1000); @@ -9816,7 +9816,7 @@ void Client::Handle_OP_BankerChange(const EQApplicationPacket *app) cp/=10; m_pp.platinum=cp; - cp = static_cast(m_pp.copper_bank) + + cp = static_cast(m_pp.copper_bank) + (static_cast(m_pp.silver_bank) * 10) + (static_cast(m_pp.gold_bank) * 100) + (static_cast(m_pp.platinum_bank) * 1000); @@ -10478,8 +10478,8 @@ void Client::Handle_OP_Translocate(const EQApplicationPacket *app) { EQApplicationPacket* outapp = new EQApplicationPacket(OP_Translocate, sizeof(Translocate_Struct)); Translocate_Struct *ots = (Translocate_Struct*)outapp->pBuffer; memcpy(ots, &PendingTranslocateData, sizeof(Translocate_Struct)); - - //Was sending the packet back to initiate client zone... + + //Was sending the packet back to initiate client zone... //but that could be abusable, so lets go through proper channels MovePC(ots->ZoneID, 0, ots->x, ots->y, ots->z, GetHeading(), 0, ZoneSolicited); } @@ -10673,7 +10673,7 @@ void Client::Handle_OP_LFGGetMatchesRequest(const EQApplicationPacket *app) { void Client::Handle_OP_LFPCommand(const EQApplicationPacket *app) { - + if (app->size != sizeof(LFP_Struct)) { LogFile->write(EQEMuLog::Error, "Wrong size: OP_LFPCommand, size=%i, expected %i", app->size, sizeof(LFP_Struct)); DumpPacket(app); @@ -10709,14 +10709,14 @@ void Client::Handle_OP_LFPCommand(const EQApplicationPacket *app) { LFPMembers[0].GuildID = GuildID(); if(g) { - // This should not happen. The client checks if you are in a group and will not let you put LFP on if + // This should not happen. The client checks if you are in a group and will not let you put LFP on if // you are not the leader. if(!g->IsLeader(this)) { LogFile->write(EQEMuLog::Error,"Client sent LFP on for character %s who is grouped but not leader.", GetName()); return; } // Fill the LFPMembers array with the rest of the group members, excluding ourself - // We don't fill in the class, level or zone, because we may not be able to determine + // We don't fill in the class, level or zone, because we may not be able to determine // them if the other group members are not in this zone. World will fill in this information // for us, if it can. int NextFreeSlot = 1; @@ -10727,7 +10727,7 @@ void Client::Handle_OP_LFPCommand(const EQApplicationPacket *app) { } - worldserver.UpdateLFP(CharacterID(), lfp->Action, lfp->MatchFilter, lfp->FromLevel, lfp->ToLevel, lfp->Classes, + worldserver.UpdateLFP(CharacterID(), lfp->Action, lfp->MatchFilter, lfp->FromLevel, lfp->ToLevel, lfp->Classes, lfp->Comments, LFPMembers); @@ -10857,8 +10857,8 @@ void Client::Handle_OP_Barter(const EQApplicationPacket *app) BarterItemSearchLinkRequest_Struct* bislr = (BarterItemSearchLinkRequest_Struct*)app->pBuffer; const Item_Struct* item = database.GetItem(bislr->ItemID); - - if (!item) + + if (!item) Message(13, "Error: This item does not exist!"); else { @@ -10891,7 +10891,7 @@ void Client::Handle_OP_Barter(const EQApplicationPacket *app) const Item_Struct* item = database.GetItem(bislr->ItemID); - if (!item) + if (!item) Message(13, "Error: This item does not exist!"); else { @@ -11073,14 +11073,14 @@ void Client::Handle_OP_ApplyPoison(const EQApplicationPacket *app) { } else if(GetClass() == ROGUE) { - if((PrimaryWeapon && PrimaryWeapon->GetItem()->ItemType == ItemTypePierce) || + if((PrimaryWeapon && PrimaryWeapon->GetItem()->ItemType == ItemTypePierce) || (SecondaryWeapon && SecondaryWeapon->GetItem()->ItemType == ItemTypePierce)) { float SuccessChance = (GetSkill(APPLY_POISON) + GetLevel()) / 400.0f; double ChanceRoll = MakeRandomFloat(0, 1); - + CheckIncreaseSkill(APPLY_POISON, NULL, 10); - + if(ChanceRoll < SuccessChance) { ApplyPoisonSuccessResult = 1; // NOTE: Someone may want to tweak the chance to proc the poison effect that is added to the weapon here. @@ -11098,7 +11098,7 @@ void Client::Handle_OP_ApplyPoison(const EQApplicationPacket *app) { ApplyPoison_Struct* ApplyPoisonResult = (ApplyPoison_Struct*)outapp->pBuffer; ApplyPoisonResult->success = ApplyPoisonSuccessResult; ApplyPoisonResult->inventorySlot = ApplyPoisonData->inventorySlot; - + FastQueuePacket(&outapp); } @@ -11110,7 +11110,7 @@ void Client::Handle_OP_AugmentInfo(const EQApplicationPacket *app) { // The OP_Augment packet includes a window parameter to determine which Item window in the UI the // text is to be displayed in. out->type = 2 indicates the BookText_Struct contains item information. // - + if(app->size != sizeof(AugmentInfo_Struct)) { LogFile->write(EQEMuLog::Debug, "Size mismatch in OP_AugmentInfo expected %i got %i", @@ -11129,7 +11129,7 @@ void Client::Handle_OP_AugmentInfo(const EQApplicationPacket *app) { if (item) { MakeAnyLenString(&outstring, "You must use the solvent %s to remove this augment safely.", item->Name); - + EQApplicationPacket* outapp = new EQApplicationPacket(OP_ReadBook, strlen(outstring) + sizeof(BookText_Struct)); BookText_Struct *out = (BookText_Struct *) outapp->pBuffer; @@ -11151,7 +11151,7 @@ void Client::Handle_OP_AugmentInfo(const EQApplicationPacket *app) { void Client::Handle_OP_PVPLeaderBoardRequest(const EQApplicationPacket *app) { // This Opcode is sent by the client when the Leaderboard button on the PVP Stats window is pressed. - // + // // It has a single uint32 payload which is the sort method: // // PVPSortByKills = 0, PVPSortByPoints = 1, PVPSortByInfamy = 2 @@ -11169,9 +11169,9 @@ void Client::Handle_OP_PVPLeaderBoardRequest(const EQApplicationPacket *app) EQApplicationPacket *outapp = new EQApplicationPacket(OP_PVPLeaderBoardReply, sizeof(PVPLeaderBoard_Struct)); /*PVPLeaderBoard_Struct *pvplb = (PVPLeaderBoard_Struct *)outapp->pBuffer;*/ //unused - + // TODO: Record and send this data. - + QueuePacket(outapp); safe_delete(outapp); } @@ -11195,7 +11195,7 @@ void Client::Handle_OP_PVPLeaderBoardDetailsRequest(const EQApplicationPacket *a PVPLeaderBoardDetailsReply_Struct *pvplbdrs = (PVPLeaderBoardDetailsReply_Struct *)outapp->pBuffer; // TODO: Record and send this data. - + QueuePacket(outapp); safe_delete(outapp); } @@ -11204,7 +11204,7 @@ void Client::Handle_OP_AdventureMerchantSell(const EQApplicationPacket *app) { if(app->size != sizeof(Adventure_Sell_Struct)) { - LogFile->write(EQEMuLog::Debug, "Size mismatch on OP_AdventureMerchantSell: got %u expected %u", + LogFile->write(EQEMuLog::Debug, "Size mismatch on OP_AdventureMerchantSell: got %u expected %u", app->size, sizeof(Adventure_Sell_Struct)); DumpPacket(app); return; @@ -11248,9 +11248,9 @@ void Client::Handle_OP_AdventureMerchantSell(const EQApplicationPacket *app) // The Merchant seems to have some other way of knowing whether he will accept the item, other than the ldonsold field, // e.g. if you summon items 76036 and 76053 (good and evil versions of Spell: Ward Of Vengeance), if you are interacting // with a Norrath's Keeper merchant and click on 76036 in your inventory, he says he will give you radiant crystals for - // it, but he will refuse for item 76053. - // - // Similarly, just giving a cloth cap an ldonsold value of 4 will not make the Merchant buy it. + // it, but he will refuse for item 76053. + // + // Similarly, just giving a cloth cap an ldonsold value of 4 will not make the Merchant buy it. // // Note that the the Client will not allow you to sell anything back to a Discord merchant, so there is no need to handle // that case here. @@ -11399,32 +11399,32 @@ void Client::Handle_OP_RespawnWindow(const EQApplicationPacket *app) return; } char *Buffer = (char *)app->pBuffer; - + uint32 Option = VARSTRUCT_DECODE_TYPE(uint32, Buffer); HandleRespawnFromHover(Option); } -void Client::Handle_OP_GroupUpdate(const EQApplicationPacket *app) +void Client::Handle_OP_GroupUpdate(const EQApplicationPacket *app) { if(app->size != sizeof(GroupUpdate_Struct)) { - LogFile->write(EQEMuLog::Debug, "Size mismatch on OP_GroupUpdate: got %u expected %u", + LogFile->write(EQEMuLog::Debug, "Size mismatch on OP_GroupUpdate: got %u expected %u", app->size, sizeof(GroupUpdate_Struct)); DumpPacket(app); return; } - + GroupUpdate_Struct* gu = (GroupUpdate_Struct*)app->pBuffer; switch(gu->action) { - case groupActMakeLeader: + case groupActMakeLeader: { Mob* newleader = entity_list.GetClientByName(gu->membername[0]); Group* group = this->GetGroup(); - + if (newleader && group) { // the client only sends this if it's the group leader, but check anyway - if(group->IsLeader(this)) + if(group->IsLeader(this)) group->ChangeLeader(newleader); else { LogFile->write(EQEMuLog::Debug, "Group /makeleader request originated from non-leader member: %s",GetName()); @@ -11434,16 +11434,16 @@ void Client::Handle_OP_GroupUpdate(const EQApplicationPacket *app) break; } - default: + default: { LogFile->write(EQEMuLog::Debug, "Received unhandled OP_GroupUpdate requesting action %u", gu->action); DumpPacket(app); return; - } + } } } -void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) +void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) { // if the character has a start city, don't let them use the command if(m_pp.binds[4].zoneId != 0) { @@ -11462,7 +11462,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) MYSQL_ROW row = 0; float x(0),y(0),z(0); uint32 zoneid = 0; - + uint32 StartCity = (uint32)strtol((const char*)app->pBuffer, NULL, 10); bool ValidCity = false; database.RunQuery @@ -11473,14 +11473,14 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) &query, "SELECT zone_id, bind_id, x, y, z FROM start_zones " "WHERE player_class=%i AND player_deity=%i AND player_race=%i", - m_pp.class_, + m_pp.class_, m_pp.deity, m_pp.race ), errbuf, &result ); - safe_delete_array(query); + safe_delete_array(query); if(!result) { LogFile->write(EQEMuLog::Error, "No valid start zones found for /setstartcity"); @@ -11492,7 +11492,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) zoneid = atoi(row[1]); else zoneid = atoi(row[0]); - + if(zoneid == StartCity) { ValidCity = true; x = atof(row[2]); @@ -11514,14 +11514,14 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) &query, "SELECT zone_id, bind_id FROM start_zones " "WHERE player_class=%i AND player_deity=%i AND player_race=%i", - m_pp.class_, + m_pp.class_, m_pp.deity, m_pp.race ), errbuf, &result ); - safe_delete_array(query); + safe_delete_array(query); Message(15,"Use \"/startcity #\" to choose a home city from the following list:"); char* name; while(row = mysql_fetch_row(result)) { @@ -11535,7 +11535,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) } } - mysql_free_result(result); + mysql_free_result(result); } void Client::Handle_OP_Report(const EQApplicationPacket *app) @@ -11601,7 +11601,7 @@ void Client::Handle_OP_VetClaimRequest(const EQApplicationPacket *app) { if(app->size < sizeof(VeteranClaimRequest)) { - LogFile->write(EQEMuLog::Debug, "OP_VetClaimRequest size lower than expected: got %u expected at least %u", + LogFile->write(EQEMuLog::Debug, "OP_VetClaimRequest size lower than expected: got %u expected at least %u", app->size, sizeof(VeteranClaimRequest)); DumpPacket(app); return; @@ -11646,7 +11646,7 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app) if(app->size < sizeof(GMSearchCorpse_Struct)) { - LogFile->write(EQEMuLog::Debug, "OP_GMSearchCorpse size lower than expected: got %u expected at least %u", + LogFile->write(EQEMuLog::Debug, "OP_GMSearchCorpse size lower than expected: got %u expected at least %u", app->size, sizeof(GMSearchCorpse_Struct)); DumpPacket(app); return; @@ -11673,7 +11673,7 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app) if(NumberOfRows == MaxResults) Message(clientMessageError, "Your search found too many results; some are not displayed."); else { - Message(clientMessageYellow, "There are %i corpse(s) that match the search string '%s'.", + Message(clientMessageYellow, "There are %i corpse(s) that match the search string '%s'.", NumberOfRows, gmscs->Name); } @@ -11831,7 +11831,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) break; } - + case GuildBankDeposit: // Deposit Item { if(GuildBanks->IsAreaFull(GuildID(), GuildBankDepositArea)) @@ -11933,14 +11933,14 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) GuildBankWithdrawItem_Struct *gbwis = (GuildBankWithdrawItem_Struct*)app->pBuffer; ItemInst* inst = GuildBanks->GetItem(GuildID(), gbwis->Area, gbwis->SlotID, gbwis->Quantity); - + if(!inst) { GuildBankAck(); break; } - + if(!IsGuildBanker() && !GuildBanks->AllowedToWithdraw(GuildID(), gbwis->Area, gbwis->SlotID, GetName())) { _log(GUILDS__BANK_ERROR, "Suspected attempted hack on the guild bank from %s", GetName()); @@ -11982,7 +11982,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) break; } - + case GuildBankSplitStacks: { if(GuildBanks->IsAreaFull(GuildID(), GuildBankMainArea)) @@ -11990,7 +11990,7 @@ void Client::Handle_OP_GuildBank(const EQApplicationPacket *app) else { GuildBankWithdrawItem_Struct *gbwis = (GuildBankWithdrawItem_Struct*)app->pBuffer; - + GuildBanks->SplitStack(GuildID(), gbwis->SlotID, gbwis->Quantity); } @@ -12032,7 +12032,7 @@ void Client::Handle_OP_GroupRoles(const EQApplicationPacket *app) if(!g) return; - + switch(grs->RoleNumber) { case 1: //Main Tank @@ -12262,7 +12262,7 @@ void Client::Handle_OP_BlockedBuffs(const EQApplicationPacket *app) obbs->Count = BlockedBuffs->size(); Iterator = BlockedBuffs->begin(); - + unsigned int Element = 0; while(Iterator != BlockedBuffs->end()) @@ -12324,7 +12324,7 @@ void Client::Handle_OP_RemoveBlockedBuffs(const EQApplicationPacket *app) obbs->Count = RemovedBuffs.size(); Iterator = RemovedBuffs.begin(); - + unsigned int Element = 0; while(Iterator != RemovedBuffs.end()) @@ -12399,7 +12399,7 @@ void Client::Handle_OP_CorpseDrag(const EQApplicationPacket *app) VERIFY_PACKET_LENGTH(OP_CorpseDrag, app, CorpseDrag_Struct); CorpseDrag_Struct *cds = (CorpseDrag_Struct*)app->pBuffer; - + Mob* corpse = entity_list.GetMob(cds->CorpseName); if(!corpse || !corpse->IsPlayerCorpse() || corpse->CastToCorpse()->IsBeingLooted()) @@ -12454,10 +12454,10 @@ void Client::Handle_OP_GroupMakeLeader(const EQApplicationPacket *app) Mob* NewLeader = entity_list.GetClientByName(gmls->NewLeader); Group* g = GetGroup(); - + if (NewLeader && g) { - if(g->IsLeader(this)) + if(g->IsLeader(this)) g->ChangeLeader(NewLeader); else { LogFile->write(EQEMuLog::Debug, "Group /makeleader request originated from non-leader member: %s", GetName()); @@ -12491,7 +12491,7 @@ void Client::Handle_OP_GuildCreate(const EQApplicationPacket *app) // The Underfoot client Guild Creation window will only allow a guild name of <= around 30 characters, but the packet is 64 bytes. Sanity check the // name anway. // - + char *GuildName = (char *)app->pBuffer; #ifdef FREEBSD if(strlen(GuildName) > 60) @@ -12527,10 +12527,10 @@ void Client::Handle_OP_GuildCreate(const EQApplicationPacket *app) } uint32 NewGuildID = guild_mgr.CreateGuild(GuildName, CharacterID()); - + _log(GUILDS__ACTIONS, "%s: Creating guild %s with leader %d via UF+ GUI. It was given id %lu.", GetName(), GuildName, CharacterID(), (unsigned long)NewGuildID); - + if (NewGuildID == GUILD_NONE) Message(clientMessageError, "Guild creation failed."); else @@ -12563,8 +12563,8 @@ void Client::Handle_OP_AltCurrencyMerchantRequest(const EQApplicationPacket *app if(alt_cur_id == 0) { return; } - - list::iterator altc_iter = zone->AlternateCurrencies.begin(); + + list::iterator altc_iter = zone->AlternateCurrencies.begin(); bool found = false; while(altc_iter != zone->AlternateCurrencies.end()) { if((*altc_iter).id == alt_cur_id) { @@ -12944,7 +12944,7 @@ void Client::Handle_OP_LFGuild(const EQApplicationPacket *app) { VERIFY_PACKET_LENGTH(OP_LFGuild, app, LFGuild_PlayerToggle_Struct); LFGuild_PlayerToggle_Struct *pts = (LFGuild_PlayerToggle_Struct *)app->pBuffer; - + if(strnlen(pts->Comment, 256) > 256) return; @@ -12960,11 +12960,11 @@ void Client::Handle_OP_LFGuild(const EQApplicationPacket *app) pack->WriteUInt32(GetAAPointsSpent()); pack->WriteString(pts->Comment); pack->WriteUInt32(pts->Toggle); - pack->WriteUInt32(pts->TimeZone); - + pack->WriteUInt32(pts->TimeZone); + worldserver.SendPacket(pack); safe_delete(pack); - + break; } case 1: @@ -12990,7 +12990,7 @@ void Client::Handle_OP_LFGuild(const EQApplicationPacket *app) pack->WriteUInt32(gts->AACount); pack->WriteUInt32(gts->Toggle); pack->WriteUInt32(gts->TimeZone); - + worldserver.SendPacket(pack); safe_delete(pack); @@ -13001,20 +13001,20 @@ void Client::Handle_OP_LFGuild(const EQApplicationPacket *app) VERIFY_PACKET_LENGTH(OP_LFGuild, app, LFGuild_SearchPlayer_Struct); ServerPacket* pack = new ServerPacket(ServerOP_QueryServGeneric, strlen(GetName()) + 37); - + pack->WriteUInt32(zone->GetZoneID()); pack->WriteUInt32(zone->GetInstanceID()); pack->WriteString(GetName()); pack->WriteUInt32(QSG_LFGuild); pack->WriteUInt32(QSG_LFGuild_PlayerMatches); - + LFGuild_SearchPlayer_Struct *sps = (LFGuild_SearchPlayer_Struct *)app->pBuffer; pack->WriteUInt32(sps->FromLevel); pack->WriteUInt32(sps->ToLevel); pack->WriteUInt32(sps->MinAA); pack->WriteUInt32(sps->TimeZone); pack->WriteUInt32(sps->Classes); - + worldserver.SendPacket(pack); safe_delete(pack); @@ -13025,20 +13025,20 @@ void Client::Handle_OP_LFGuild(const EQApplicationPacket *app) VERIFY_PACKET_LENGTH(OP_LFGuild, app, LFGuild_SearchGuild_Struct); ServerPacket* pack = new ServerPacket(ServerOP_QueryServGeneric, strlen(GetName()) + 33); - + pack->WriteUInt32(zone->GetZoneID()); pack->WriteUInt32(zone->GetInstanceID()); pack->WriteString(GetName()); pack->WriteUInt32(QSG_LFGuild); pack->WriteUInt32(QSG_LFGuild_GuildMatches); - + LFGuild_SearchGuild_Struct *sgs = (LFGuild_SearchGuild_Struct *)app->pBuffer; pack->WriteUInt32(sgs->Level); pack->WriteUInt32(sgs->AAPoints); pack->WriteUInt32(sgs->TimeZone); pack->WriteUInt32(sgs->Class); - + worldserver.SendPacket(pack); safe_delete(pack); @@ -13053,7 +13053,7 @@ void Client::Handle_OP_XTargetRequest(const EQApplicationPacket *app) { if(app->size < 12) { - LogFile->write(EQEMuLog::Debug, "Size mismatch in OP_XTargetRequest, expected at least 12, got %i", app->size); + LogFile->write(EQEMuLog::Debug, "Size mismatch in OP_XTargetRequest, expected at least 12, got %i", app->size); DumpPacket(app); return; } @@ -13098,7 +13098,7 @@ void Client::Handle_OP_XTargetRequest(const EQApplicationPacket *app) strncpy(XTargets[Slot].Name, Name, 64); } SendXTargetPacket(Slot, c); - + break; } @@ -13262,7 +13262,7 @@ void Client::Handle_OP_XTargetRequest(const EQApplicationPacket *app) case MyPetTarget: { Mob *m = GetPet(); - + if(m) m = m->GetTarget(); @@ -13286,7 +13286,7 @@ void Client::Handle_OP_XTargetAutoAddHaters(const EQApplicationPacket *app) { if(app->size != 1) { - LogFile->write(EQEMuLog::Debug, "Size mismatch in OP_XTargetAutoAddHaters, expected 1, got %i", app->size); + LogFile->write(EQEMuLog::Debug, "Size mismatch in OP_XTargetAutoAddHaters, expected 1, got %i", app->size); DumpPacket(app); return; } @@ -13295,7 +13295,7 @@ void Client::Handle_OP_XTargetAutoAddHaters(const EQApplicationPacket *app) } void Client::Handle_OP_ItemPreview(const EQApplicationPacket *app) -{ +{ VERIFY_PACKET_LENGTH(OP_ItemPreview, app, ItemPreview_Struct); ItemPreview_Struct *ips = (ItemPreview_Struct *)app->pBuffer; @@ -13355,7 +13355,7 @@ void Client::Handle_OP_ItemPreview(const EQApplicationPacket *app) outapp->WriteUInt8(item->DR); outapp->WriteUInt8(item->PR); outapp->WriteUInt8(item->MR); - outapp->WriteUInt8(item->FR); + outapp->WriteUInt8(item->FR); outapp->WriteUInt8(item->AStr); outapp->WriteUInt8(item->ASta); outapp->WriteUInt8(item->AAgi); @@ -13544,22 +13544,22 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) i = 0; for(std::list::iterator mercListItr = mercDataList.begin(); mercListItr != mercDataList.end(); mercListItr++) { - mml->Mercs[i].MercID = mercListItr->MercTemplateID; - mml->Mercs[i].MercType = mercListItr->MercType; - mml->Mercs[i].MercSubType = mercListItr->MercSubType; - mml->Mercs[i].PurchaseCost = RuleB(Mercs, ChargeMercPurchaseCost) ? Merc::CalcPurchaseCost(mercListItr->MercTemplateID, GetLevel(), 0): 0; - mml->Mercs[i].UpkeepCost = RuleB(Mercs, ChargeMercUpkeepCost) ? Merc::CalcUpkeepCost(mercListItr->MercTemplateID, GetLevel(), 0): 0; - mml->Mercs[i].Status = 0; - mml->Mercs[i].AltCurrencyCost = RuleB(Mercs, ChargeMercPurchaseCost) ? Merc::CalcPurchaseCost(mercListItr->MercTemplateID, GetLevel(), altCurrentType): 0; - mml->Mercs[i].AltCurrencyUpkeep = RuleB(Mercs, ChargeMercUpkeepCost) ? Merc::CalcUpkeepCost(mercListItr->MercTemplateID, GetLevel(), altCurrentType): 0; + mml->Mercs[i].MercID = mercListItr->MercTemplateID; + mml->Mercs[i].MercType = mercListItr->MercType; + mml->Mercs[i].MercSubType = mercListItr->MercSubType; + mml->Mercs[i].PurchaseCost = RuleB(Mercs, ChargeMercPurchaseCost) ? Merc::CalcPurchaseCost(mercListItr->MercTemplateID, GetLevel(), 0): 0; + mml->Mercs[i].UpkeepCost = RuleB(Mercs, ChargeMercUpkeepCost) ? Merc::CalcUpkeepCost(mercListItr->MercTemplateID, GetLevel(), 0): 0; + mml->Mercs[i].Status = 0; + mml->Mercs[i].AltCurrencyCost = RuleB(Mercs, ChargeMercPurchaseCost) ? Merc::CalcPurchaseCost(mercListItr->MercTemplateID, GetLevel(), altCurrentType): 0; + mml->Mercs[i].AltCurrencyUpkeep = RuleB(Mercs, ChargeMercUpkeepCost) ? Merc::CalcUpkeepCost(mercListItr->MercTemplateID, GetLevel(), altCurrentType): 0; mml->Mercs[i].AltCurrencyType = altCurrentType; - mml->Mercs[i].MercUnk01 = 0; - mml->Mercs[i].TimeLeft = -1; + mml->Mercs[i].MercUnk01 = 0; + mml->Mercs[i].TimeLeft = -1; mml->Mercs[i].MerchantSlot = i + 1; - mml->Mercs[i].MercUnk02 = 1; - mml->Mercs[i].StanceCount = zone->merc_stance_list[mercListItr->MercTemplateID].size(); - mml->Mercs[i].MercUnk03 = 519044964; - mml->Mercs[i].MercUnk04 = 1; + mml->Mercs[i].MercUnk02 = 1; + mml->Mercs[i].StanceCount = zone->merc_stance_list[mercListItr->MercTemplateID].size(); + mml->Mercs[i].MercUnk03 = 519044964; + mml->Mercs[i].MercUnk04 = 1; //mml->Mercs[i].MercName; int stanceindex = 0; if(mml->Mercs[i].StanceCount != 0) @@ -13582,7 +13582,7 @@ void Client::Handle_OP_MercenaryDataRequest(const EQApplicationPacket *app) EQApplicationPacket *outapp = new EQApplicationPacket(OP_MercenaryDataResponse, 1); //Packet sizes are handled by the encoder. outapp->pBuffer = (unsigned char*)mml; // DumpPacket(outapp); - FastQueuePacket(&outapp); + FastQueuePacket(&outapp); } } @@ -13598,7 +13598,7 @@ void Client::Handle_OP_MercenaryHire(const EQApplicationPacket *app) return; } - + MercenaryMerchantRequest_Struct* mmrq = (MercenaryMerchantRequest_Struct*) app->pBuffer; uint32 merc_template_id = mmrq->MercID; uint32 merchant_id = mmrq->MercMerchantID; @@ -13613,7 +13613,7 @@ void Client::Handle_OP_MercenaryHire(const EQApplicationPacket *app) //HirePending = true; SetHoTT(0); SendTargetCommand(0); - + if(!RuleB(Mercs, AllowMercs)) return; @@ -13625,7 +13625,7 @@ void Client::Handle_OP_MercenaryHire(const EQApplicationPacket *app) if(!CheckCanHireMerc(merchant, merc_template_id)) { return; } - + if(RuleB(Mercs, ChargeMercPurchaseCost)) { uint32 cost = Merc::CalcPurchaseCost(merc_template->MercTemplateID, GetLevel()) * 100; // Cost is in gold TakeMoneyFromPP(cost, true); @@ -13636,7 +13636,7 @@ void Client::Handle_OP_MercenaryHire(const EQApplicationPacket *app) // Get merc, assign it to client & spawn Merc* merc = Merc::LoadMerc(this, merc_template, merchant_id, false); - + if(merc) { SpawnMerc(merc, true); merc->Save(); @@ -13672,10 +13672,10 @@ void Client::Handle_OP_MercenarySuspendRequest(const EQApplicationPacket *app) if(MERC_DEBUG > 0) Message(7, "Mercenary Debug: Suspend ( %i ) received.", merc_suspend); - + if(!RuleB(Mercs, AllowMercs)) return; - + // Check if the merc is suspended and if so, unsuspend, otherwise suspend it SuspendMercCommand(); } @@ -13703,10 +13703,10 @@ void Client::Handle_OP_MercenaryCommand(const EQApplicationPacket *app) if(MERC_DEBUG > 0) Message(7, "Mercenary Debug: Command %i, Option %i received.", merc_command, option); - + if(!RuleB(Mercs, AllowMercs)) return; - + // Handle the Command here... // Will need a list of what every type of command is supposed to do // Unsure if there is a server response to this packet @@ -13764,9 +13764,9 @@ void Client::Handle_OP_MercenaryDismiss(const EQApplicationPacket *app) if(merc) merc->Dismiss(); } - + // Unsure if there is a server response to this packet - + } void Client::Handle_OP_MercenaryTimerRequest(const EQApplicationPacket *app) @@ -13779,7 +13779,7 @@ void Client::Handle_OP_MercenaryTimerRequest(const EQApplicationPacket *app) DumpPacket(app); return; } - + DumpPacket(app); if(MERC_DEBUG > 0) diff --git a/zone/merc.cpp b/zone/merc.cpp index 01a4ff1b42..db1860fabf 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -1812,7 +1812,7 @@ void Merc::AI_Process() { //now off hand if(GetTarget() && attack_dw_timer.Check() && CanThisClassDualWield()) { - int weapontype = NULL; + int weapontype = 0; // No weapon type bool bIsFist = true; if(bIsFist || ((weapontype != ItemType2HS) && (weapontype != ItemType2HPierce) && (weapontype != ItemType2HB))) { @@ -2362,8 +2362,8 @@ bool Merc::AICastSpell(int8 iChance, int32 iSpellTypes) { if(!castedSpell && tar->GetPet()) { //don't cast group spells on pets - if(IsGroupSpell(selectedMercSpell.spellid) - || spells[selectedMercSpell.spellid].targettype == ST_Group + if(IsGroupSpell(selectedMercSpell.spellid) + || spells[selectedMercSpell.spellid].targettype == ST_Group || spells[selectedMercSpell.spellid].targettype == ST_GroupTeleport ) { continue; } @@ -5103,7 +5103,7 @@ bool Merc::Unsuspend(bool setMaxStats) { uint32 suspendedTime = 0; SetSuspended(false); - + mercOwner->GetMercInfo().mercid = GetMercID(); mercOwner->GetMercInfo().IsSuspended = false; mercOwner->GetMercInfo().SuspendedTime = 0;