PDA

View Full Version : Quest - fixed unsourced localised emote (quest::echo)


BWStripes
04-23-2009, 09:01 PM
Originally mentioned here: http://www.projecteq.net/phpBB2/viewtopic.php?t=7289

Summary of above:
Neither quest::me or quest::echo works at the moment. I think quest::me is specific to something, but I can't tell what.
The quest::echo code - where does this message go exactly? ~line 193 questmgr.cpp:
void QuestManager::echo(const char *str) {
printf("%s\n", str);
}

So, I rewrote the quest::echo function to be more like the quest::ze and quest::we functions, meaning it will allow a colour ID.
I left the quest::me function as it was in case it was intentional:
void QuestManager::me(const char *str) {
if (!initiator)
return;
entity_list.MessageClose(initiator, false, 200, 10, str);
}

I just made quest::echo work, pretty much identical to the alternative method Trevius posted:
$entity_list->MessageClose($npc, 1, 200, 15, "You hear a whisper in the wind as if something calls to you from the darkness.");

New usage: quest::echo(#colourID, "Message");

Diffs below. Now, I've had this compiled, tested and working, but I am a complete novice at C coding - I tend to stick to script languages. If someone spots something really stupid, please let me know.

questmgr.cpp
--- questmgr.cpp 2009-04-23 11:26:57.000000000 +0100
+++ questmgr.newcpp 2009-04-23 10:43:27.000000000 +0100
@@ -190,8 +190,8 @@ void QuestManager::EndQuest() {


//quest perl functions
-void QuestManager::echo(const char *str) {
- printf("%s\n", str);
+void QuestManager::echo(int colour, const char *str) {
+ entity_list.MessageClose(initiator, false, 200, colour, str);
}

void QuestManager::say(const char *str) {

questmgr.h
--- questmgr.h 2009-04-23 11:26:57.000000000 +0100
+++ questmgr.newh 2009-04-23 10:43:40.000000000 +0100
@@ -42,7 +42,7 @@ public:
void ClearTimers(Mob *who);

//quest perl functions
- void echo(const char *str);
+ void echo(int colour, const char *str);
void say(const char *str);
void me(const char *str);
void summonitem(int32 itemid, uint8 charges = 0);

parser.cpp
--- parser.cpp 2009-04-23 11:26:57.000000000 +0100
+++ parser.newcpp 2009-04-23 11:07:54.000000000 +0100
@@ -799,7 +799,7 @@ void Parser::ExCommands(string o_command
atof(arglist[3]), atof(arglist[4]), atof(arglist[5]), hdng);
}
else if (!strcmp(command,"echo")) {
- quest_manager.echo(parms.c_str());
+ quest_manager.echo(atoi(arglist[0]), parms.c_str());
}
else if (!strcmp(command,"summonitem")) {
quest_manager.summonitem(atoi(arglist[0]));

perlparser.cpp
--- perlparser.cpp 2009-04-23 11:26:57.000000000 +0100
+++ perlparser.newcpp 2009-04-23 11:07:38.000000000 +0100
@@ -210,10 +210,10 @@ XS(XS__echo); // prototype to pass -Wmis
XS(XS__echo) {
dXSARGS;

- if (items != 1)
- Perl_croak(aTHX_ "Usage: say(str)");
+ if (items != 2)
+ Perl_croak(aTHX_ "Usage: echo(id#, str)");

- quest_manager.echo(SvPV_nolen(ST(0)));
+ quest_manager.echo(SvUV(ST(0)), SvPV_nolen(ST(1)));

XSRETURN_EMPTY;
}

Wesell
04-24-2009, 11:56 AM
[...] The quest::echo code - where does this message go exactly? ~line 193 questmgr.cpp:
void QuestManager::echo(const char *str) {
printf("%s\n", str);
}

The message prints to the standard output stream for the process (usually the console), it it's not supposed to appear as an in-game message. You could use it to do some rapid debugging of quest scripts or something like that.

BWStripes
04-24-2009, 02:47 PM
I can accept that. However, the quest documentation alluded to it being a localised emote, rather than something for potential debugging purposes. I'd seen it used as a localised emote in quest files, hence why I tried to fix it. My own method of debugging is to use quest::say so I know something is happening.

Wesell
04-24-2009, 04:24 PM
All the docs I've checked state that the echo method prints its string to the console.

I don't see any obvious bugs in the me method. One thing to consider when using this method is that initiator is going to be the client who started execution of the script - location of the initiator is the center of the area where the emote is visible.

You could change me to center the emote on the NPC involved in the quest which is probably the behavior most would expect:
void QuestManager::me(const char *str) {
entity_list.MessageClose(npc, false, 200, 10, str);
}

cavedude
05-03-2009, 04:17 PM
This has been committed in Revision 454.