|
|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
| Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum) |

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.
|
 |
|
 |
 |
|
 |

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.
|
 |
|
 |
| Thread Tools |
|
|
| Display Modes |
Hybrid Mode
|
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 12:24 AM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |