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

Reply
 
Thread Tools Display Modes
  #16  
Old 08-29-2014, 03:03 PM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

Quote:
Originally Posted by demonstar55 View Post
I'll see if I can figure it out either through IDA or packet capture

Edit: also, Say_StringID handles the merchants name, should of clarified that, so you can remove the GetCleanName() (I was just trying to explain why it was a 3)

Doing Say_StringID(messageid, "12"); says Gnomes for me.

Using one of the messageids with %B3 or %B2 in it?
Reply With Quote
  #17  
Old 08-29-2014, 03:12 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,165
Default

%B3, specifically I just had tmp->Say_StringID(1154, "12"); (well, I had more, but that's the one that worked)
Reply With Quote
  #18  
Old 08-29-2014, 03:31 PM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

I'm narrowing in on the solution.

I'm going to include some hard coded strings as well. You guys can delete them if you want.

I want to be able to reject based on deity as well, and I like having the deity name show up. It'll be easy to drop that out of my solution and go with the standard stuff, its a separate if clause.

Testing..

Thanks - It was my misunderstanding of the Say_Message that I got from some other examples. If I had stuck with your message instead I'd be done by now.
Reply With Quote
  #19  
Old 08-29-2014, 05:12 PM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

It is all working now. Posting the code later tonight or tomorrow.

I had to go custom for my messages based on diety, as I wanted more variety than the text that was available with no arguments. As I said, that's easily removed if you don't want it.

- noudess
Reply With Quote
  #20  
Old 08-29-2014, 07:00 PM
noudess
Discordant
 
Join Date: Sep 2012
Location: Upstate NY
Posts: 274
Default

Latest diff. Working as far as I've tested.

This is a straight diff against MY repo, which is old, so some of it will need to be manually interpreted. I believe you guys have moved files around in the directories, and functions around within the files.

Still I don't think it would be too bad. This stuff was spread out between two files and functions (the main functionality of it). I put it all in one function in client_packet.cpp and deleted the no longer used Function.

Code:
=== modified file 'zone/StringIDs.h'
--- zone/StringIDs.h	2013-05-02 18:37:13 +0000
+++ zone/StringIDs.h	2014-08-29 21:30:44 +0000
@@ -273,6 +273,29 @@
 #define SPELL_REFLECT				9082	//%1's spell has been reflected by %2.
 #define NEW_SPELLS_AVAIL			9149	//You have new spells available to you.  Check the merchants near your guild master.
 #define AE_RAMPAGE					11015	//%1 goes on a WILD RAMPAGE!
+
+#define WONT_SELL_CLASS1			1155 	//It's %B3(13) like you that are ruining the continent...get OUT!
+#define WONT_SELL_CLASS2			1156 	//Isn't there some kind of ordinance against %B3(13) crawling out from under their rocks?
+#define WONT_SELL_CLASS3			1157 	//%B3(13) like you don't have any place in my shop..now make way for welcome customers.
+#define WONT_SELL_CLASS4			1158 	//I thought scumbag %B3(13) like you just stole whatever they need.  Now GET OUT!
+#define WONT_SELL_CLASS5			1159 	//I don't have anything to do with %B3(13)..move along.
+
+#define WONT_SELL_RACE1				1154 	//I don't like to speak to %B3(12) much less sell to them!
+#define WONT_SELL_RACE2				1161 	//It's not enough that you %B3(12) have ruined your own land. Now get lost!
+#define WONT_SELL_RACE3				1162 	//I have something here that %B3(12) use..let me see...it's the EXIT, now get LOST!
+#define WONT_SELL_RACE4				1163 	//Don't you %B3(12) have your own merchants?  Whatever, I'm not selling anything to you!
+
+#define WONT_SELL_NONSTDRACE1		1160 	//I don't have anything to do with your little gang..move along.
+#define WONT_SELL_NONSTDRACE2		1164 	//Members of your little "club" have ruined things around here..get lost!
+#define WONT_SELL_NONSTDRACE3		1165 	//I don't have anything to do with your damned club..move along.
+
+#define WONT_SELL_DEEDS_1			1166 	//Creatures like you make me sick..the things you do..get out of here Pagan!
+#define WONT_SELL_DEEDS_2			1167 	//After all the things you've done..the things you believe in..leave my shop!
+#define WONT_SELL_DEEDS_3			1168 	//Actions speak louder than beliefs, and I despise both your actions and all you believe in.
+#define WONT_SELL_DEEDS_4			1169 	//Get out of here now!
+#define WONT_SELL_DEEDS_5			1170 	//I am tolerant by nature..but infidels like you push me past my limit..get out!
+#define WONT_SELL_DEEDS_6			1171 	//I cannot abide you or your actions against all that is right..BE GONE!
+
 #define FACE_ACCEPTED				12028	//Facial features accepted.
 #define SPELL_LEVEL_TO_LOW			12048	//You will have to achieve level %1 before you can scribe the %2.
 #define ATTACKFAILED				12158	//%1 try to %2 %3, but %4!

=== modified file 'zone/client.h'
--- zone/client.h	2014-07-25 14:55:13 +0000
+++ zone/client.h	2014-08-29 21:26:55 +0000
@@ -577,7 +577,6 @@
     FACTION_VALUE   GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 p_race, uint32 p_class, uint32 p_deity, int32 pFaction, Mob* tnpc);
 	int32	GetCharacterFactionLevel(int32 faction_id);
 	int32  GetModCharacterFactionLevel(int32 faction_id);
-	bool	HatedByClass(uint32 p_race, uint32 p_class, uint32 p_deity, int32 pFaction);
 
 	void	SetFactionLevel(uint32 char_id, uint32 npc_id, uint8 char_class, uint8 char_race, uint8 char_deity);
 	void    SetFactionLevel2(uint32 char_id, int32 faction_id, uint8 char_class, uint8 char_race, uint8 char_deity, int32 value, uint8 temp);

=== modified file 'zone/client_packet.cpp'
--- zone/client_packet.cpp	2014-08-15 18:12:09 +0000
+++ zone/client_packet.cpp	2014-08-29 21:42:18 +0000
@@ -90,7 +90,19 @@
 extern DBAsync *dbasync;
 
 typedef void (Client::*ClientPacketProc)(const EQApplicationPacket *app);
-
+
+static const char *wontsellhardcoded[]={
+"%s says 'It's %s like you that are ruining the continent...get OUT!'",
+"%s says 'Isn't there some kind of ordinance against %s crawling out from under their rocks?'",
+"%s says '%s like you don't have any place in my shop..now make way for welcome customers.'",
+"%s says 'I thought scumbag %s like you just stole whatever they need.  Now GET OUT!'",
+"%s says 'I don't have anything to do with %s..move along.'",
+"%s says 'I don't like to speak to %s much less sell to them!'",
+"%s says 'It's not enough that you %s have ruined your own land. Now get lost!'",
+"%s says 'I have something here that %s use..let me see...it's the EXIT, now get LOST!'",
+"%s says 'Don't you %s have your own merchants?  Whatever, I'm not selling anything to you!"
+};
+
 //Use a map for connecting opcodes since it dosent get used a lot and is sparse
 map<uint32, ClientPacketProc> ConnectingOpcodes;
 //Use a static array for connected, for speed
@@ -5431,6 +5443,7 @@
 	//Merchant_Click_Struct* mco=(Merchant_Click_Struct*)outapp->pBuffer;
 	int merchantid=0;
 	Mob* tmp = entity_list.GetMob(mc->npcid);
+	int primaryfaction;
 
 	if (tmp == 0 || !tmp->IsNPC() || tmp->GetClass() != MERCHANT)
 		return;
@@ -5462,30 +5475,11 @@
 		Message(0,"You cannot use a merchant right now.");
 		action = 0;
 	}
-	int factionlvl = GetFactionLevel(CharacterID(), tmp->CastToNPC()->GetNPCTypeID(), GetRace(), GetClass(), GetDeity(), tmp->CastToNPC()->GetPrimaryFaction(), tmp);
+	primaryfaction=tmp->CastToNPC()->GetPrimaryFaction();
+	int factionlvl = GetFactionLevel(CharacterID(), tmp->CastToNPC()->GetNPCTypeID(), GetRace(), GetClass(), GetDeity(), primaryfaction, tmp);
 	if(factionlvl >= 7)
 	{
-		char playerp[16] = "players";
-		if(HatedByClass(GetRace(), GetClass(), GetDeity(), tmp->CastToNPC()->GetPrimaryFaction()))
-			strcpy(playerp,GetClassPlural(this));
-		else
-			strcpy(playerp,GetRacePlural(this));
-
-		uint8 rand_ = rand() % 4;
-		switch(rand_){
-			case 1:
-				Message(0,"%s says 'It's not enough that you %s have ruined your own lands. Now get lost!'", tmp->GetCleanName(), playerp);
-				break;
-			case 2:
-				Message(0,"%s says 'I have something here that %s use... let me see... it's the EXIT, now get LOST!'", tmp->GetCleanName(), playerp);
-				break;
-			case 3:
-				Message(0,"%s says 'Don't you %s have your own merchants? Whatever, I'm not selling anything to you!'", tmp->GetCleanName(), playerp);
-				break;
-			default:
-				Message(0,"%s says 'I don't like to speak to %s much less sell to them!'", tmp->GetCleanName(), playerp);
-				break;
-		}
+		MerchantRejectMessage(tmp, primaryfaction);
 		action = 0;
 	}
 	if (tmp->Charmed())
@@ -13820,3 +13814,103 @@
 	// SideNote: Watching the slot translations, Unknown1 is showing '141' as well on certain item swaps.
 	// Manually looting a corpse results in a from '34' to '68' value for equipment items, '0' to '0' for inventory.
 }
+
+void Client::MerchantRejectMessage(Mob *merchant, int primaryfaction) 
+{
+uint16 race;
+uint16 pclass;
+uint16 deity;
+uint32 messageid;
+uint32 whichhardcoded;
+char   constructed_message[256];
+uint16 numhardcoded=sizeof(wontsellhardcoded)/sizeof(char *);
+int32  tmpFactionValue;
+FactionMods fmods;
+int32  lowestvalue;
+string tempstr;
+
+	// Pick which type of string to display from (4) types
+	//
+	// NONSTDRACE: Something like wolf form std messages
+	// DEEDS: Personal Faction issues std messages
+	// RCD: Race/Class std messages
+	// DEITY: Non standard to eqstr Deity messages
+	race=GetRace();
+	pclass=GetClass();
+	deity=GetDeity();
+
+	if (race > PLAYER_RACE_COUNT) // wolf form, etc.
+		{
+		messageid=MakeRandomInt(1,3);
+		switch (messageid)
+			{
+			case 1:
+				messageid=WONT_SELL_NONSTDRACE1;
+				break;
+			case 2:
+				messageid=WONT_SELL_NONSTDRACE2;
+				break;
+			case 3:
+				messageid=WONT_SELL_NONSTDRACE3;
+				break;
+			}
+		merchant->Say_StringID(messageid);
+		}
+	else
+		{
+		// If a faction is involved, get the data.
+		if(primaryfaction > 0)
+			{
+			if (database.GetFactionData(&fmods, pclass, race, deity,
+															primaryfaction))
+				{
+				tmpFactionValue = GetCharacterFactionLevel(primaryfaction);
+				lowestvalue=min(tmpFactionValue, min(fmods.class_mod, 
+									min(fmods.race_mod, fmods.deity_mod)));
+				}
+			}
+		// If no faction, or deeds score the worst, use deeds message
+		if (primaryfaction <= 0 || lowestvalue == tmpFactionValue)
+			{
+			messageid=MakeRandomInt(WONT_SELL_DEEDS_1, WONT_SELL_DEEDS_6);
+			merchant->Say_StringID(messageid);
+			}
+		// If Diety is the biggest motivator, use some custom messages
+		else if (lowestvalue == fmods.deity_mod)
+			{
+			// These messages use a %B3 format in eq_str.txt and I can't
+			// figure out how to send race/class,  So, hard coded those
+			// formats in am array at top, and using sprintf and GENERIC_SAY.
+			whichhardcoded=MakeRandomInt(0, numhardcoded-1);
+			tempstr = "worshippers of " + GetDeityName(deity);
+			Message(0,  (char *)wontsellhardcoded[whichhardcoded], 
+				merchant->GetCleanName(), tempstr.c_str());
+			}
+		else if (lowestvalue == fmods.race_mod)
+			{
+			messageid=MakeRandomInt(1,4);
+			switch (messageid)
+				{
+				case 1:
+					messageid=WONT_SELL_RACE1;
+					break;
+				case 2:
+					messageid=WONT_SELL_RACE2;
+					break;
+				case 3:
+					messageid=WONT_SELL_RACE3;
+					break;
+				case 4:
+					messageid=WONT_SELL_RACE4;
+					break;
+				}
+			merchant->Say_StringID(messageid, itoa(race));
+			}
+		else if (lowestvalue == fmods.class_mod)
+			{
+			messageid=MakeRandomInt(WONT_SELL_CLASS1,WONT_SELL_CLASS5);
+			merchant->Say_StringID(messageid, itoa(pclass));
+			}
+		}
+}
+

=== modified file 'zone/client_packet.h'
--- zone/client_packet.h	2013-05-02 18:37:13 +0000
+++ zone/client_packet.h	2014-08-29 17:40:36 +0000
@@ -288,3 +288,4 @@
 	void Handle_OP_MercenaryTimerRequest(const EQApplicationPacket *app);
 	void Handle_OP_OpenInventory(const EQApplicationPacket *app);
 	void Handle_OP_OpenContainer(const EQApplicationPacket *app);
+	void MerchantRejectMessage(Mob *merchant, int primaryfaction);

=== modified file 'zone/faction.cpp'
--- zone/faction.cpp	2013-07-09 15:28:09 +0000
+++ zone/faction.cpp	2014-08-29 20:53:09 +0000
@@ -1036,29 +1038,3 @@
 	}
 	return true;
 }
-
-bool Client::HatedByClass(uint32 p_race, uint32 p_class, uint32 p_deity, int32 pFaction)
-{
-	
-	bool Result = false;
-	_ZP(Client_GetFactionLevel);
-
-	int32 tmpFactionValue;
-	FactionMods fmods;
-
-    //First get the NPC's Primary faction
-	if(pFaction > 0)
-	{
-		//Get the faction data from the database
-		if(database.GetFactionData(&fmods, p_class, p_race, p_deity, pFaction))
-		{
-			tmpFactionValue = GetCharacterFactionLevel(pFaction);
-			tmpFactionValue += GetFactionBonus(pFaction);
-			tmpFactionValue += GetItemFactionBonus(pFaction);
-			CalculateFaction(&fmods, tmpFactionValue);
-			if(fmods.class_mod < fmods.race_mod)
-				Result = true;
-		}
-	}
-	return Result;
-}

=== modified file 'zone/mob.cpp'
--- zone/mob.cpp	2014-07-22 19:15:11 +0000
+++ zone/mob.cpp	2014-08-27 20:13:08 +0000
@@ -30,6 +30,7 @@
 #include "../common/rulesys.h"
 #include "../common/emu_opcodes.h"
 #include "../common/eq_packet_structs.h"
+#include "../common/deity.h"
 #include "zonedb.h"
 #include "../common/packet_dump.h"
 #include "../common/packet_functions.h"
@@ -4598,3 +4599,31 @@
 }
 
 
+string Mob::GetDeityName(uint8 deity)
+
+{
+	string name;
+
+	switch (deity)
+		{
+		case DEITY_AGNOSTIC:	name="AGNOSTIC"; break;
+		case DEITY_BRELL:		name="BRELL"; break;
+		case DEITY_CAZIC:		name="CAZIC"; break;
+		case DEITY_EROLLSI:		name="EROLLSI"; break;
+		case DEITY_BRISTLE:		name="BRISTLE"; break;
+		case DEITY_INNY:		name="INNY"; break;
+		case DEITY_KARANA:		name="KARANA"; break;
+		case DEITY_MITH:		name="MITH"; break;
+		case DEITY_PREXUS:		name="PREXUS"; break;
+		case DEITY_QUELLIOUS:	name="QUELLIOUS"; break;
+		case DEITY_RALLOS:		name="RALLOS"; break;
+		case DEITY_SOLUSEK:		name="SOLUSEK"; break;
+		case DEITY_TRIBUNAL:	name="TRIBUNAL"; break;
+		case DEITY_TUNARE:		name="TUNARE"; break;
+		case DEITY_BERTOX:		name="BERTOX"; break;
+		case DEITY_RODCET:		name="RODCET"; break;
+		case DEITY_VEESHAN:		name="VEESHAN"; break;
+		} 
+	
+	return name;
+}

=== modified file 'zone/mob.h'
--- zone/mob.h	2014-07-22 19:15:11 +0000
+++ zone/mob.h	2014-08-27 19:53:40 +0000
@@ -732,6 +732,7 @@
 	virtual void SetTarget(Mob* mob);
 	virtual inline float		GetHPRatio() const { return max_hp == 0 ? 0 : ((float)cur_hp/max_hp*100); }
 
+	string GetDeityName(uint8 deity);
 	bool IsLoggingEnabled() const { return(logging_enabled); }
 	void EnableLogging() { logging_enabled = true; }
 	void DisableLogging() { logging_enabled = false; }
Reply With Quote
  #21  
Old 08-29-2014, 10:48 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,165
Default

Your codebase is super old :| I'll see if I can get it working if someone else doesn't

EDIT: I also want to test on live it's not just a random message :P


EDIT: Okay, I pushed it, I changed it around just a bit.

Last edited by demonstar55; 08-30-2014 at 01:29 AM..
Reply With Quote
Reply

Thread Tools
Display Modes

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 12:03 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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3