Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-14-2010, 02:28 AM
blmille2
Sarnak
 
Join Date: Apr 2007
Location: Austin, TX
Posts: 64
Default COMMITTED: Suspend Minion Patch

Hello, guys. I have the Suspend Minion AA working on my server (refreshed SVN yesterday).

Here's the diff:
Code:
Index: zone/AA.h
===================================================================
--- zone/AA.h	(revision 1094)
+++ zone/AA.h	(working copy)
@@ -265,6 +265,7 @@
 	aaParagonofSpirit = 291,			//DB
 	aaAdvancedInnateStrength = 292,		//works
 	aaAdvancedInnateStamina = 302,		//works
+	//aaSuspendMinion = 308,				//WIP -- brandon
 	aaAdvancedInnateAgility = 312,		//works
 	aaAdvancedInnateDexterity = 322,	//works
 	aaAdvancedInnateIntelligence = 332, //works
Index: zone/client.cpp
===================================================================
--- zone/client.cpp	(revision 1094)
+++ zone/client.cpp	(working copy)
@@ -4766,7 +4766,150 @@
 
 	return 0;
 }
+int get_suspendedminion_spell_id(int account_id){
+	char errbuf[MYSQL_ERRMSG_SIZE];
+	char *query = 0;
+	int spell_id = 0;
+	MYSQL_RES *result;
+	MYSQL_ROW row;
 
+	if(account_id <=0)
+		return 0;
+
+	if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT spell_id from suspendedminions WHERE account_id=%0d",account_id), errbuf, &result)){
+		if (mysql_num_rows(result)>0){
+			row = mysql_fetch_row(result);
+			mysql_free_result(result);
+			if (strlen(row[0])>0){
+				spell_id=atoi(row[0]);
+			}
+		}
+	}
+	safe_delete_array(query);
+	return (spell_id > 0 ? spell_id : 0);
+}
+
+void delete_suspendedminions(int account_id){
+	char errbuf[MYSQL_ERRMSG_SIZE];
+	char *query = 0;
+	
+	if(account_id <=0)
+		return;
+
+	database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM suspendedminions WHERE account_id=%0d",account_id), errbuf);//Deletes all suspended minions, just in case they happened to get more than one
+	safe_delete_array(query);
+}
+
+int get_suspendedminion_count(int account_id){
+	char errbuf[MYSQL_ERRMSG_SIZE];
+	char *query = 0;
+	int count = 0;
+	MYSQL_RES *result;
+	MYSQL_ROW row;
+
+	if(account_id <=0)
+		return 0;
+
+	if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT COUNT(*) from suspendedminions WHERE account_id=%0d",account_id), errbuf, &result)){
+		if (mysql_num_rows(result)>0){
+			row = mysql_fetch_row(result);
+			mysql_free_result(result);
+			if (strlen(row[0])>0){
+				count=atoi(row[0]);
+			}
+		}
+	}
+	safe_delete_array(query);
+	return (count > 0 ? count : 0);
+}
+
+int get_spellid_from_npctypeid(int npc_type){
+	char errbuf[MYSQL_ERRMSG_SIZE];
+	char *query = 0;
+	int spell_id = 0;
+	MYSQL_RES *result;
+	MYSQL_ROW row;
+
+	if(npc_type <= 0)
+		return 0;
+
+	if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT s.id FROM spells_new s INNER JOIN npc_types nt ON (s.teleport_zone=nt.name) WHERE nt.id=%0d LIMIT 1",npc_type), errbuf, &result)){
+		if (mysql_num_rows(result)>0){
+			row = mysql_fetch_row(result);
+			mysql_free_result(result);
+			if (strlen(row[0])>0){
+				spell_id=atoi(row[0]);
+			}
+		}
+	}
+	safe_delete_array(query);
+	return (spell_id > 0 ? spell_id : 0);
+}
+
+int add_suspendedminion(int account_id,int spell_id){
+	char errbuf[MYSQL_ERRMSG_SIZE];
+	char *query = 0;
+	
+	if(account_id <=0 || spell_id <=0)
+		return -1;
+
+	database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO suspendedminions (account_id,spell_id) VALUES (%i,%i)", account_id, spell_id));
+	safe_delete_array(query);
+	return 0;
+}
+void Client::SuspendMinion(){
+	Client *c = this;
+	char errbuf[MYSQL_ERRMSG_SIZE];
+	char *query = 0;
+	MYSQL_RES *result;
+	MYSQL_ROW row;
+
+	Mob *pet =  c->GetPet();
+	
+	int cur_level=c->GetAA(aaID::aaSuspendedMinion);//SuspendedMinion ID
+
+	if(cur_level==0){
+		c->Message(0," - You don't have that AA!");
+		return;
+	}
+
+	//TODO: Right now, get the pet to pop and depop--worry about ranks later
+	int spell_id=0;
+	int minion_count = get_suspendedminion_count(c->AccountID());
+	if(pet==0){
+		if(minion_count > 0){
+			spell_id = get_suspendedminion_spell_id(c->AccountID());
+			if(spell_id){
+				c->Message(0,"Your pet falls out of your pocket!");
+				c->MakePet(spell_id,spells[spell_id].teleport_zone);
+				delete_suspendedminions(c->AccountID());
+			}else{
+				c->Message(13,"Error: Couldn't find the spell id for your pet!");
+				return;
+			}
+		}else{
+			c->Message(0,"You check your pocket, but find no minion!");
+			return;
+		}
+	}else{
+		spell_id=get_spellid_from_npctypeid(pet->GetNPCTypeID());
+		if(spell_id){
+			if(minion_count){
+				c->Message(13,"You try to force your pet in your pocket, but your other pet snaps at you.");
+				return;
+			}else{
+				add_suspendedminion(c->AccountID(),spell_id);
+				pet->Kill();
+				c->Message(0,"You open your pocket and your pet hops in.");
+			}
+		}else{
+			c->Message(13,"Error getting the spell_id from the npc_type id.");
+			return;
+		}
+	}
+
+}
+
 void Client::SummonAndRezzAllCorpses()
 {
 	pendingrezzexp = -1;
Index: zone/client.h
===================================================================
--- zone/client.h	(revision 1094)
+++ zone/client.h	(working copy)
@@ -894,6 +894,7 @@
 	void CalcItemScale();
 	bool CalcItemScale(int32 slot_x, int32 slot_y);
 	void SummonAndRezzAllCorpses();
+	void SuspendMinion();
 	void NotifyNewTitlesAvailable();
 	void Signal(int32 data);
 	Mob *GetBindSightTarget() { return bind_sight_target; }
Index: zone/command.cpp
===================================================================
--- zone/command.cpp	(revision 1094)
+++ zone/command.cpp	(working copy)
@@ -341,6 +341,7 @@
 		command_add("guilds",NULL,0,command_guild) ||
 		command_add("zonestatus","- Show connected zoneservers, synonymous with /servers",150,command_zonestatus) ||
 		command_add("manaburn","- Use AA Wizard class skill manaburn on target",10,command_manaburn) ||
+		command_add("suspendminion","- Use pet class AA skill Suspend Minion",10,command_suspendminion) ||
 		command_add("viewmessage","[id] - View messages in your tell queue",100,command_viewmessage) ||
 		command_add("viewmessages",NULL,0,command_viewmessage) ||
 		command_add("doanim","[animnum] [type] - Send an EmoteAnim for you or your target",50,command_doanim) ||
@@ -5158,6 +5159,11 @@
 	}
 }
 
+void command_suspendminion(Client *c, const Seperator *sep)
+{
+	c->SuspendMinion();
+}
+
 void command_viewmessage(Client *c, const Seperator *sep)
 {
 	char errbuf[MYSQL_ERRMSG_SIZE];
Index: zone/command.h
===================================================================
--- zone/command.h	(revision 1094)
+++ zone/command.h	(working copy)
@@ -218,6 +218,7 @@
 bool helper_guild_edit(Client *c, int32 dbid, int32 eqid, int8 rank, const char* what, const char* value);
 void command_zonestatus(Client *c, const Seperator *sep);
 void command_manaburn(Client *c, const Seperator *sep);
+void command_suspendminion(Client *c, const Seperator *sep);
 void command_viewmessage(Client *c, const Seperator *sep);
 void command_doanim(Client *c, const Seperator *sep);
 void command_randomfeatures(Client *c, const Seperator *sep);
Index: zone/pets.cpp
===================================================================
--- zone/pets.cpp	(revision 1094)
+++ zone/pets.cpp	(working copy)
@@ -213,8 +213,6 @@
 	return base_hp;
 }
 */
-
-
 void Mob::MakePet(int16 spell_id, const char* pettype, const char *petname) {
 	//see if we are a special type of pet (for command filtering)
 	PetType type = petOther;
Index: zone/spell_effects.cpp
===================================================================
--- zone/spell_effects.cpp	(revision 1094)
+++ zone/spell_effects.cpp	(working copy)
@@ -2732,6 +2732,10 @@
 					CastToClient()->GoToBind(4);
 				break;
 			}
+			case SE_SuspendMinion:
+			{
+				CastToClient()->SuspendMinion();
+			}
 
 			case SE_ImprovedDamage:
 			case SE_ImprovedHeal:

Last edited by gaeorn; 01-14-2010 at 01:22 PM.. Reason: wrapped diff in /CODE block
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 06:27 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3