|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum) |
08-25-2008, 10:33 PM
|
Discordant
|
|
Join Date: Sep 2006
Location: Subsection 185.D354 C.12
Posts: 346
|
|
#ItemLink <Item ID Number>
It would be cool to somehow get the server to translate a non-item-link into an item link.
Right now, to send an item link it requires two special symbols and a bunch of numbers that don't make any sense to me.
Code:
012FD70000000000000000000000000000000467D6434Distillate of Celestial Healing V
Code:
Input - I want a L:[1001]
You say, 'I want a Cloth Cap'
It's along the lines of the % commands only it has a number in it.
__________________
If at first you don't succeed destroy all evidence that you ever tried.
God doesn't give second chances... Hell, he sets you up the first time.
|
08-26-2008, 12:04 AM
|
|
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
I think it would be nice if the quest command for item linking worked too. It looks like it might have worked at one point, but it definitely doesn't now. It would be kinda cool if you should setup NPCs to link the quest rewards for completing the quest. I also wouldn't mind being able to setup an NPC that could link all of the epics on my server so people wouldn't be asking for the links in OOC all of the time
|
|
|
|
08-30-2008, 12:25 PM
|
Discordant
|
|
Join Date: May 2004
Posts: 290
|
|
Ya, the itemlink function for quests is broken. In fact it will crash the zone if a high itemID is used.
In the new method of linking, the first 6 bytes of that long number are the hex value of the itemID. I assume the last 8ish bytes are a hash or bitmask of something.
Here's a simple fix to link normal, unaugmented items.
Around line 887 in zone/questmgr.cpp change this ..
Code:
// MYRA - added itemlink(ID) command
const Item_Struct* item = 0;
int16 itemid = item_id;
item = database.GetItem(itemid);
initiator->Message(0, "%s tells you, '%c00%i %s%c",owner->GetName(),0x12, item->ID, item->Name, 0x12);
}
.. to this ..
Code:
// MYRA - added itemlink(ID) command
const Item_Struct* item = 0;
uint32 itemid = item_id;
item = database.GetItem(itemid);
initiator->Message(0, "%s tells you, %c%06X000000000000000000000000000000000000000%s%c",owner->GetCleanName(),0x12, item->ID, item->Name, 0x12);
}
Then you can use
Code:
quest::itemlink(1001); // link Cloth Cap
|
|
|
|
08-30-2008, 02:17 PM
|
Developer
|
|
Join Date: Mar 2007
Location: Ohio
Posts: 648
|
|
I assume that, if you use the sequence from above, the client is able to convert it? I ask because, imo, I would rather have a link to an item in the middle of a conversation, rather than just the mob sending a separate message with the link.
|
08-30-2008, 08:10 PM
|
Discordant
|
|
Join Date: May 2004
Posts: 290
|
|
You can do it from a quest like this. Just plug in the item name and ID.
Code:
$item_link = sprintf("%c%06X%s%s%c",0x12,1001,"000000000000000000000000000000000000000","Cloth Cap",0x12);
quest::say("This is a $item_link.");
|
|
|
|
08-31-2008, 05:52 AM
|
Developer
|
|
Join Date: Mar 2007
Location: Ohio
Posts: 648
|
|
I think this would be better, because it would just return the link to the item from the function, rather than outputting it as a generic tell (great for seeing what you're working for in a quest):
Note: I haven't tested this, it's just a specific idea. All changes are in red.
In zone/questmgr.h, change
Code:
char* itemlink(int item_id);
In zone/questmgr.cpp, change
Code:
char* QuestManager::itemlink(int item_id) {
//I dont think this is right anymore, need the hash
/*
uint32_t calc_hash (const char *string)
{
register hash = 0;
while (*string != '\0')
{
register c = toupper(*string);
asm volatile("
imul $31, %1, %1;
movzx %%ax, %%edx;
addl %%edx, %1;
movl %1, %0;
"
:"=r"(hash)
:"D"(hash), "a"(c)
:"%edx"
);
//This is what the inline asm is doing:
//hash *= 0x1f;
//hash += (int)c;
string++;
}
return hash;
}
Now the not so simple part, generating the string to feed into the hash function.
The string for normal (unaugmented) items looks like this:
Code:
sprintf(hashstr, "%d%s%s%d %d %d %d %d %d %d %d", id, name, "-1-1-1-1-1", hp, mana, ac, light, icon, price, size, weight);
The string for bags looks like this:
Code:
sprintf(hashstr, "%d%s%d%d%d%d", id, name, bagslots, bagwr, price, weight);
The string for books looks like this:
Code:
sprintf(hashstr, "%d%s%d%d", id, name, weight, booktype);
*/
// MYRA - added itemlink(ID) command
const Item_Struct* item = 0;
int16 itemid = item_id;
item = database.GetItem(itemid);
return (sprintf("%c%06X%s%s%c",0x12,itemid,"000000000000000000000000000000000000000",item,0x12));
}
And in zone/perlparser.cpp ( really not sure about this part), change
Code:
XS(XS__itemlink);
XS(XS__itemlink)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: itemlink(item_id)");
char* RETVAL;
int item_id = (int)SvIV(ST(0));
RETVAL = quest_manager.itemlink(item_id);
ST(0) = RETVAL;
sv_2mortal(ST(0));
XSRETURN(1);
}
Any thoughts?
|
|
|
|
08-31-2008, 05:54 PM
|
|
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
I moved this to server code submissions. I confirmed that the fix for item linking that Theeper posted here does in fact work. But, it would be nice if the idea that AndMetal was working on worked as well. I haven't tested AndMetal's code yet, but it would be nice if you could use it like:
quest::say ("Here is the link for a quest::itemlink(1001)."); #link for a Cloth Cap
It looks like it could be done the way that Theeper mentioned by defining a variable for it, but it would be best to simplify it if possible. I am really glad that the tell command works now, but it would just be better this way IMO. Either way, this could be added to the code as it fixes a currently broken command.
I will leave this unstickied for now so KLS can decide if she wants to add it as-is or if she wants to wait for the change to be made so it works in the newer (better IMO) way.
Last edited by trevius; 09-01-2008 at 01:57 AM..
|
|
|
|
|
|
|
09-07-2008, 07:14 PM
|
|
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
I tried making the changes that AndMetal posted, but that gives compile errors. I was getting errors about char*, and I am guessing it is because all other quests use void and none use char* like that. I will have to mess with it a little more, but I think that this looks like it could be a simple change to Theeper's code to make it do what AndMetal (and probably most people) want. I will have to mess with it more, but I think that changing the following line:
Code:
initiator->Message(0, "%s tells you, %c%06X000000000000000000000000000000000000000%s%c",owner->GetCleanName(),0x12, item->ID, item->Name, 0x12);
From a message to a print might do it. Maybe I am thinking too simple though. It is no secret that my understanding of how code works is still horrible lol.
Maybe something like this would work:
Code:
printf("%c%06X000000000000000000000000000000000000000%s%c",owner->GetCleanName(),0x12, item->ID, item->Name, 0x12);
I will have to test this out and see if it does anything.
|
|
|
|
|
|
|
09-08-2008, 01:18 AM
|
Developer
|
|
Join Date: Mar 2007
Location: Ohio
Posts: 648
|
|
Quote:
Originally Posted by trevius
I tried making the changes that AndMetal posted, but that gives compile errors. I was getting errors about char*, and I am guessing it is because all other quests use void and none use char* like that. I will have to mess with it a little more, but I think that this looks like it could be a simple change to Theeper's code to make it do what AndMetal (and probably most people) want. I will have to mess with it more, but I think that changing the following line:
Code:
initiator->Message(0, "%s tells you, %c%06X000000000000000000000000000000000000000%s%c",owner->GetCleanName(),0x12, item->ID, item->Name, 0x12);
From a message to a print might do it. Maybe I am thinking too simple though. It is no secret that my understanding of how code works is still horrible lol.
Maybe something like this would work:
Code:
printf("%c%06X000000000000000000000000000000000000000%s%c",owner->GetCleanName(),0x12, item->ID, item->Name, 0x12);
I will have to test this out and see if it does anything.
|
The reason it should be char is because we want it to return a value that contains characters. If it is void, it won't return anything, it just executes whatever is in the function. We want it to return just the string that needs to be added to the text, rather than output it for us (which is what it currently does).
However, my understanding of all the different *, &, and whatnot is somewhat limited. I thought char* meant a variable length (obviously, I need to pick up a C++ book and read like the first 10 pages), but I guess that might be incorrect if it's not compiling properly. Then again, if it failed to compile in zone/perlparser.cpp, that wouldn't surprise me since I honestly have no idea how that XS crap works
However, in the same token, we could go a different way of accomplishing the same thing: a quest plugin. The downside is that it would require knowing both the exact name of the item from the database and the item ID. The bad thing about this is, if the item name changes in the DB, you have to change it in your script. It's not really the end of the world, but could be annoying.
In any case, this should do the trick (which is just what Theeper came up with in a more user friendly form):
new file, itemlink.pl, in the plugins directory
Code:
# plugin::itemlink(itemid, itemname);
# returns the string needed in conversation to link to an item
sub itemlink {
my $itemid = shift;
my $itemname = shift;
my $unknown = "000000000000000000000000000000000000000" # if we ever figure out what we can do with this...
my $string = sprintf("%c%06X%s%s%c",0x12,$itemid,$unknown,$itemname,0x12);
return $string;
}
1; # not really sure if this is needed, but it's in most of the other plugin files...
If I can, I may give this a shot on my server tonight to make sure it actually works. And at the least, this can be an easier workaround unless we can find out how to have it done in the source.
|
|
|
|
|
|
|
09-08-2008, 07:04 AM
|
|
Developer
|
|
Join Date: Aug 2006
Location: USA
Posts: 5,946
|
|
I was messing around with this some more tonight, but I still couldn't get it to work. Haven't tried the plugin yet, but still trying to go for making a command in the source instead. Though, I did find a quest object for it, but it doesn't seem to work right either:
Code:
void Client::SendItemLink(const ItemInst* inst, bool send_to_all)
{
/*
this stuff is old, live dosent do this anymore. they send a much smaller
packet with the item number in it, but I cant seem to find it right now
*/
if (!inst)
return;
const Item_Struct* item = inst->GetItem();
const char* name2 = &item->Name[0];
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ItemLinkText,strlen(name2)+68);
char buffer2[135] = {0};
char itemlink[135] = {0};
sprintf(itemlink,"%c0%06u0%05u-%05u-%05u-%05u-%05u00000000%c",
0x12,
item->ID,
inst->GetAugmentItemID(0),
inst->GetAugmentItemID(1),
inst->GetAugmentItemID(2),
inst->GetAugmentItemID(3),
inst->GetAugmentItemID(4),
0x12);
sprintf(buffer2,"%c%c%c%c%c%c%c%c%c%c%c%c%s",0x00,0x00,0x00,0x00,0xD3,0x01,0x00,0x00,0x1E,0x01,0x00,0x00,itemlink);
memcpy(outapp->pBuffer,buffer2,outapp->size);
QueuePacket(outapp);
safe_delete(outapp);
if (send_to_all==false)
return;
const char* charname = this->GetName();
outapp = new EQApplicationPacket(OP_ItemLinkText,strlen(itemlink)+14+strlen(charname));
char buffer3[150] = {0};
sprintf(buffer3,"%c%c%c%c%c%c%c%c%c%c%c%c%6s%c%s",0x00,0x00,0x00,0x00,0xD2,0x01,0x00,0x00,0x00,0x00,0x00,0x00,charname,0x00,itemlink);
memcpy(outapp->pBuffer,buffer3,outapp->size);
entity_list.QueueCloseClients(this->CastToMob(),outapp,true,200,0,false);
safe_delete(outapp);
}
|
|
|
|
09-24-2008, 02:04 PM
|
|
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
Unstuck this one because I am not sure what the solution (if any) is.
|
|
|
|
11-17-2008, 07:09 AM
|
Developer
|
|
Join Date: Mar 2007
Location: Ohio
Posts: 648
|
|
I had a chance to revisit this a little (no testing yet, just theory), and this is what I came up with this time...
Quote:
Originally Posted by AndMetal
In zone/questmgr.h, change
Code:
char* itemlink(int item_id);
In zone/questmgr.cpp, change
Code:
char* QuestManager::itemlink(int item_id) {
//I dont think this is right anymore, need the hash
/*
uint32_t calc_hash (const char *string)
{
register hash = 0;
while (*string != '\0')
{
register c = toupper(*string);
asm volatile("
imul $31, %1, %1;
movzx %%ax, %%edx;
addl %%edx, %1;
movl %1, %0;
"
:"=r"(hash)
:"D"(hash), "a"(c)
:"%edx"
);
//This is what the inline asm is doing:
//hash *= 0x1f;
//hash += (int)c;
string++;
}
return hash;
}
Now the not so simple part, generating the string to feed into the hash function.
The string for normal (unaugmented) items looks like this:
Code:
sprintf(hashstr, "%d%s%s%d %d %d %d %d %d %d %d", id, name, "-1-1-1-1-1", hp, mana, ac, light, icon, price, size, weight);
The string for bags looks like this:
Code:
sprintf(hashstr, "%d%s%d%d%d%d", id, name, bagslots, bagwr, price, weight);
The string for books looks like this:
Code:
sprintf(hashstr, "%d%s%d%d", id, name, weight, booktype);
*/
// MYRA - added itemlink(ID) command
const Item_Struct* item = 0;
int16 itemid = item_id;
item = database.GetItem(itemid);
return (sprintf("%c%06X%s%s%c",0x12,itemid,"000000000000000000000000000000000000000",item,0x12));
}
And in zone/perlparser.cpp ( really not sure about this part), change
Code:
XS(XS__itemlink);
XS(XS__itemlink)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: itemlink(item_id)");
char* RETVAL;
int item_id = (int)SvIV(ST(0));
RETVAL = quest_manager.itemlink(item_id);
ST(0) = RETVAL;
sv_2mortal(ST(0));
XSRETURN(1);
}
|
zone/questmgr.h:
Code:
void itemlink(char &ret, int item_id);
zone/questmgr.cpp:
Code:
void QuestManager::itemlink(char &ret, int item_id) {
const Item_Struct* item = 0;
uint32 itemid = item_id;
item = database.GetItem(itemid);
ret = sprintf(ret, "%c%06X%s%s%c",0x12,itemid,"000000000000000000000000000000000000000",item,0x12);
}
zone/perlparser.cpp:
Code:
XS(XS__itemlink);
XS(XS__itemlink)
{
dXSARGS;
if (items != 1)
Perl_croak(aTHX_ "Usage: itemlink(item_id)");
char* RETVAL; //may need to set this to a fixed size
int item_id = (int)SvIV(ST(0));
quest_manager.itemlink(RETVAL, item_id);
ST(0) = RETVAL;
sv_2mortal(ST(0));
XSRETURN(1);
}
If that works, then we can easily add in support for Augments.
|
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 05:41 AM.
|
|
|
|
|
|
|
|
|
|
|
|
|