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

Reply
 
Thread Tools Display Modes
  #1  
Old 08-01-2008, 03:23 PM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default NPC Quest Journal

This patch is to enable text sent to the client from quests using quest::say to be recorded
in the NPC Quest Journal (assuming you have it enabled in the client).

I added a rule, RULE_BOOL ( NPC, EnableNPCQuestJournal, false)

By default, this is false and the new code is not enabled. Set it to true and text from
quest::say will be sent to the quest initiator using OP_SpecialMesg instead of OP_SimpleMessage
and will be recorded in the client NPC Quest Log. (Press the EQ button, then select Quests/NPC Journal).

http://www.rama.demon.co.uk/questlog.patch

Reply With Quote
  #2  
Old 08-01-2008, 05:08 PM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

My ISP web hosting is down for maintenance, so here is the patch:

Code:
diff -u --recursive ../EQEmu-0.7.0-1119/common/ruletypes.h ./common/ruletypes.h
--- ../EQEmu-0.7.0-1119/common/ruletypes.h      2008-08-01 19:38:04.000000000 +0100
+++ ./common/ruletypes.h        2008-08-01 19:37:31.000000000 +0100
@@ -141,6 +141,7 @@
 RULE_INT ( NPC, SayPauseTimeInSec, 5)
 RULE_INT ( NPC, OOCRegen, 0)
 RULE_BOOL ( NPC, BuffFriends, false )
+RULE_BOOL ( NPC, EnableNPCQuestJournal, false)
 RULE_CATEGORY_END()

 RULE_CATEGORY ( Aggro )
diff -u --recursive ../EQEmu-0.7.0-1119/zone/client.cpp ./zone/client.cpp
--- ../EQEmu-0.7.0-1119/zone/client.cpp 2008-05-31 05:12:30.000000000 +0100
+++ ./zone/client.cpp   2008-08-01 18:58:22.000000000 +0100
@@ -819,6 +819,47 @@
        safe_delete_array(buffer);
 }

+
+void Client::QuestJournalledMessage(const char *npcname, const char* message) {
+
+       // npcnames longer than 60 characters crash the client when they log back in
+       const int MaxNPCNameLength = 60;
+       // I assume there is an upper safe limit on the message length. Don't know what it is, but 4000 doesn't crash
+       // the client.
+       const int MaxMessageLength = 4000;
+
+       char OutNPCName[MaxNPCNameLength+1];
+       char OutMessage[MaxMessageLength+1];
+
+       // Apparently Visual C++ snprintf is not C99 compliant and doesn't put the null terminator
+       // in if the formatted string >= the maximum length, so we put it in.
+       //
+       snprintf(OutNPCName, MaxNPCNameLength, "%s", npcname); OutNPCName[MaxNPCNameLength]='\0';
+       snprintf(OutMessage, MaxMessageLength, "%s", message); OutMessage[MaxMessageLength]='\0';
+
+       uint32 len_packet = sizeof(SpecialMesg_Struct) + strlen(OutNPCName) + strlen(OutMessage);
+       EQApplicationPacket* app = new EQApplicationPacket(OP_SpecialMesg, len_packet);
+       SpecialMesg_Struct* sm=(SpecialMesg_Struct*)app->pBuffer;
+
+       sm->header[0] = 0;
+       sm->header[1] = 2;
+       sm->header[2] = 0;
+       sm->msg_type = 0x0a;
+       sm->target_spawn_id = GetID();
+
+       char *dest = &sm->sayer[0];
+
+       sprintf(dest, "%s", OutNPCName);
+
+       dest = dest + strlen(OutNPCName) + 13;
+
+       sprintf(dest, "%s", OutMessage);
+
+       QueuePacket(app);
+
+       safe_delete(app);
+}
+
 void Client::SetMaxHP() {
        if(dead)
                return;
diff -u --recursive ../EQEmu-0.7.0-1119/zone/client.h ./zone/client.h
--- ../EQEmu-0.7.0-1119/zone/client.h   2008-06-15 00:07:57.000000000 +0100
+++ ./zone/client.h     2008-07-31 16:29:25.000000000 +0100
@@ -216,6 +216,7 @@
        void    ChannelMessageReceived(int8 chan_num, int8 language, const char* message, const char* targetname=NULL);
        void    ChannelMessageSend(const char* from, const char* to, int8 chan_num, int8 language, const char* message, ...);
        void    Message(int32 type, const char* message, ...);
+       void    QuestJournalledMessage(const char *npcname, const char* message);
        void    SendSound();

        int32   GetAdventureID() const {return 0/*m_pp.adventure_id*/; }
diff -u --recursive ../EQEmu-0.7.0-1119/zone/entity.cpp ./zone/entity.cpp
--- ../EQEmu-0.7.0-1119/zone/entity.cpp 2008-07-21 19:58:29.000000000 +0100
+++ ./zone/entity.cpp   2008-07-31 18:53:45.000000000 +0100
@@ -1151,6 +1151,30 @@
        }
 }

+
+void EntityList::QuestJournalledSayClose(Mob *sender, Client *QuestInitiator, float dist, const char* mobname, const char* message)
+{
+       Client *c;
+       LinkedListIterator<Client*> iterator(client_list);
+       float dist2 = dist * dist;
+
+       // Send the message to the quest initiator such that the client will enter it into the NPC Quest Journal
+       if(QuestInitiator) {
+
+               char *buf = new char[strlen(mobname) + strlen(message) + 10];
+               sprintf(buf, "%s says, '%s'", mobname, message);
+               QuestInitiator->QuestJournalledMessage(mobname, buf);
+               safe_delete_array(buf);
+       }
+       // Use the old method for all other nearby clients
+       for(iterator.Reset(); iterator.MoreElements(); iterator.Advance())
+       {
+               c = iterator.GetData();
+               if(c && (c != QuestInitiator) && c->DistNoRoot(*sender) <= dist2)
+                       c->Message_StringID(10, GENERIC_SAY, mobname, message);
+       }
+}
+
 //sender can be null
 void EntityList::QueueClients(Mob* sender, const EQApplicationPacket* app, bool ignore_sender, bool ackreq) {
        LinkedListIterator<Client*> iterator(client_list);
diff -u --recursive ../EQEmu-0.7.0-1119/zone/entity.h ./zone/entity.h
--- ../EQEmu-0.7.0-1119/zone/entity.h   2008-05-30 23:44:12.000000000 +0100
+++ ./zone/entity.h     2008-07-31 16:44:22.000000000 +0100
@@ -204,6 +204,7 @@
        void    MessageClose(Mob* sender, bool skipsender, float dist, int32 type, const char* message, ...);
        void    Message_StringID(Mob *sender, bool skipsender, int32 type, int32 string_id, const char* message1=0,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0,const char* message9=0);
        void    MessageClose_StringID(Mob *sender, bool skipsender, float dist, int32 type, int32 string_id, const char* message1=0,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0,const char* message9=0);
+       void    QuestJournalledSayClose(Mob *sender, Client *QuestIntiator, float dist, const char* mobname, const char* message);
        void    ChannelMessageFromWorld(const char* from, const char* to, int8 chan_num, int32 guilddbid, int8 language, const char* message);
        void    ChannelMessage(Mob* from, int8 chan_num, int8 language, const char* message, ...);
        void    ChannelMessageSend(Mob* to, int8 chan_num, int8 language, const char* message, ...);
diff -u --recursive ../EQEmu-0.7.0-1119/zone/mob.cpp ./zone/mob.cpp
--- ../EQEmu-0.7.0-1119/zone/mob.cpp    2008-06-15 00:07:57.000000000 +0100
+++ ./zone/mob.cpp      2008-07-31 16:40:05.000000000 +0100
@@ -2019,6 +2019,13 @@
                GENERIC_SAY, GetCleanName(), buf);
 }

+
+void Mob::QuestJournalledSay(Client *QuestInitiator, const char *str)
+{
+
+        entity_list.QuestJournalledSayClose(this, QuestInitiator, 200, GetCleanName(), str);
+}
+
 //
 // solar: this is like the above, but the first parameter is a string id
 //
diff -u --recursive ../EQEmu-0.7.0-1119/zone/mob.h ./zone/mob.h
--- ../EQEmu-0.7.0-1119/zone/mob.h      2008-06-19 15:56:51.000000000 +0100
+++ ./zone/mob.h        2008-07-31 16:40:34.000000000 +0100
@@ -550,6 +550,7 @@
        virtual void    Message_StringID(int32 type, int32 string_id, int32 distance = 0) {}
        virtual void    Message_StringID(int32 type, int32 string_id, const char* message,const char* message2=0,const char* message3=0,const char* message4=0,const char* message5=0,const char* message6=0,const char* message7=0,const char* message8=0, const char* message9=0, int32 distance = 0) {}
        void Say(const char *format, ...);
+       void QuestJournalledSay(Client *QuestInitiator, const char *str);
        void Say_StringID(int32 string_id, const char *message3 = 0, const char *message4 = 0, const char *message5 = 0, const char *message6 = 0, const char *message7 = 0, const char *message8 = 0, const char *message9 = 0);
        void Shout(const char *format, ...);
        void Emote(const char *format, ...);
diff -u --recursive ../EQEmu-0.7.0-1119/zone/questmgr.cpp ./zone/questmgr.cpp
--- ../EQEmu-0.7.0-1119/zone/questmgr.cpp       2008-06-15 00:07:57.000000000 +0100
+++ ./zone/questmgr.cpp 2008-07-31 18:17:01.000000000 +0100
@@ -73,6 +73,7 @@
 #include "parser.h"
 #include "event_codes.h"
 #include "guild_mgr.h"
+#include "../common/rulesys.h"


 extern Zone* zone;
@@ -193,7 +194,11 @@
 }

 void QuestManager::say(const char *str) {
-       owner->Say(str);
+
+       if(RuleB(NPC, EnableNPCQuestJournal) && initiator)
+               owner->QuestJournalledSay(initiator, str);
+       else
+               owner->Say(str);
 }

 void QuestManager::me(const char *str) {
Reply With Quote
  #3  
Old 08-01-2008, 08:27 PM
leslamarch
Discordant
 
Join Date: Sep 2006
Location: Green Bay, WI
Posts: 436
Default

Nice Work Derision,
Works perfect, many many thanks for the fixes very much appreciated here
Reply With Quote
  #4  
Old 08-01-2008, 08:32 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Mmm, would this add entries for all say events? Like perhaps say from npc aggro say?
Reply With Quote
  #5  
Old 08-01-2008, 08:38 PM
leslamarch
Discordant
 
Join Date: Sep 2006
Location: Green Bay, WI
Posts: 436
Default

Quote:
Originally Posted by KLS View Post
Mmm, would this add entries for all say events? Like perhaps say from npc aggro say?
Yes in my limited testing it will add entries for all say events. I'm just glad to have this My parents play and they are up in age and can never remember the quest. LOL
Reply With Quote
  #6  
Old 08-01-2008, 08:55 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Then that's not really gonna work, we should distinguish between quest say and say beyond the rule.
Reply With Quote
  #7  
Old 08-01-2008, 09:05 PM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

Thanks for the patch Derision- as always, your fixes are amazing.

Quote:
Originally Posted by Derision View Post
This patch is to enable text sent to the client from quests using quest::say to be recorded
in the NPC Quest Journal (assuming you have it enabled in the client).

I added a rule, RULE_BOOL ( NPC, EnableNPCQuestJournal, false)

By default, this is false and the new code is not enabled. Set it to true and text from
quest::say will be sent to the quest initiator using OP_SpecialMesg instead of OP_SimpleMessage
and will be recorded in the client NPC Quest Log. (Press the EQ button, then select Quests/NPC Journal).

http://www.rama.demon.co.uk/questlog.patch

Reply With Quote
  #8  
Old 08-02-2008, 12:21 AM
kayen85
Sarnak
 
Join Date: Dec 2007
Posts: 50
Default

Even on live it had npc aggro messages from say logged in.
Reply With Quote
  #9  
Old 08-02-2008, 01:07 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

Attack say is quest say, hehe. Though, maybe a quest command could be added specifically to be logged in this system. Either that, or maybe have an agro check before logs, lol.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!
Reply With Quote
  #10  
Old 08-02-2008, 01:43 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

Good then, sorry for me assuming sony isn't retarded. Sticky for commit.
Reply With Quote
  #11  
Old 08-02-2008, 12:18 PM
cavedude's Avatar
cavedude
The PEQ Dude
 
Join Date: Apr 2003
Location: -
Posts: 1,988
Default

Quote:
Originally Posted by KLS View Post
Good then, sorry for me assuming sony isn't retarded. Sticky for commit.
It makes you wonder just how many things work a bit more logically in EQEmu than on Live.
Reply With Quote
  #12  
Old 08-02-2008, 01:23 PM
Angelox
AX Classic Developer
 
Join Date: May 2006
Location: filler
Posts: 2,049
Default

This is very nice and needed! Sure beats having to go into the eqemu/quests directory and look up the quest pl, or digging through the /everquest/log (sorta takes the roleplay out of the game).
For those that never used it before <alt> and <J> brings it up.
I have it all running, and posted executables/source for anyone who wants it.
Reply With Quote
  #13  
Old 09-23-2008, 06:48 PM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

did this EVEr made it into the source build? I could not get it to work

if didn't - why not?
Reply With Quote
  #14  
Old 09-23-2008, 06:55 PM
renoofturks1
Sarnak
 
Join Date: Jan 2008
Posts: 60
Default

I do believe the rule is set to FALSE by default, so, you would need to turn it on. That is, if it went in.
Reply With Quote
  #15  
Old 09-23-2008, 07:12 PM
ChaosSlayer
Demi-God
 
Join Date: May 2007
Posts: 1,032
Default

ah thats explains it:

"(Derision) Implemented quest journal npc say."

BUt does not say anywhere in change log that it has to be turned ON

excatly whats is the proper syntaxys for the rule?
Reply With Quote
Reply


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 07:26 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