Jump to content
Angelmelody

[Suggestion] Add *getequipuniqueid script cmd

Recommended Posts

Hello, I would like to suggest adding this command getequipuniqueid into Herc emulator.

Since we had implemented Unique ID system ,but don't have script cmd to get the Unique ID

of equipped equipment,so here's hoping that devs can implement this cmd ,thx :)

 

 

src - getequipuniqueid

 

doc - getequipuniqueid

Edited by Angelmelody

Share this post


Link to post
Share on other sites

I already knew about this

and they missing @inventorylist_uniqueid ... this is more important though

need this to search in their inventory, cart, storage and so on

Share this post


Link to post
Share on other sites

maybe they haven't found any useful implementation for uniqueid ?? this caused it placed in low priority maybe ? haha

 

there are several place we could have it implemented tho

  • getitem / geitem2 - return new unique id if any
  • deleteuniqueid( <unique id> ); - delete item based  on unique id
  • hasuniqueid( <unique id> ); - check if item with the said unique id exist
  •  

Share this post


Link to post
Share on other sites

https://github.com/HerculesWS/Hercules/pull/1046

 

the way it calculate the unique ID is

https://github.com/HerculesWS/Hercules/blob/09a2201e0d8563608a421378970f9d9ae6bc38bc/src/map/itemdb.c#L1922

return ((uint64)sd->status.char_id << 32) | sd->status.uniqueitem_counter++;
which is, there is an upper value and lower value

 

the upper value is the char ID, move 32 bits left

and the left over, lower value is unique item counter

 

you can try this in your test server

SELECT char_id, unique_id, unique_id >>32, unique_id & ((1<<32)-1) FROM inventory where unique_id <> 0;SELECT char_id, unique_id, unique_id >> 32 & 0xffffffff, unique_id & 0xffffffff FROM inventory where unique_id <> 0;
the reason why its implement this way has explained by Haru and hemagx, its for multiple map-server support

since there can be only 1 char can connect to a map-server at a time

 

 

in other words, I think this unique ID should be split into 2 value

@inventorylist_uid_char = return the upper value of unique ID

@inventorylist_uid_counter = return the lower value of unique ID

 

the way rathena return the value in 64bits is just ... hilarious to me

 


 

*getitem return a value

since the upper value is always its char ID, I guess can make it return the sd->status.uniqueitem_counter instead

EDIT: just tested, the counter start from 0, so it has to return -1 for error

 

*hasuniqueid, deleteuniqueid

this is tough, it has to search through `inventory`, `cart_inventory`, `storage`, `guild_storage`, `mail` and `auction` table

its better to do this via SQL

Edited by AnnieRuru

Share this post


Link to post
Share on other sites

check Haru's post

pc->setreg(sd, script->add_str("@expire_uniqueid_lo"), (int)(sd->status.inventory[i].unique_id&0xffffffff));pc->setreg(sd, script->add_str("@expire_uniqueid_hi"), (int)((sd->status.inventory[i].unique_id>>32)&0xffffffff));

Share this post


Link to post
Share on other sites

 

check Haru's post

pc->setreg(sd, script->add_str("@expire_uniqueid_lo"), (int)(sd->status.inventory[i].unique_id&0xffffffff));pc->setreg(sd, script->add_str("@expire_uniqueid_hi"), (int)((sd->status.inventory[i].unique_id>>32)&0xffffffff));

I prefer ra's method, convert the long long type var  into string var

snprintf(buf, sizeof(buf)-1, "%llu", (unsigned long long)item->unique_id);

Share this post


Link to post
Share on other sites

 

check Haru's post

 

pc->setreg(sd, script->add_str("@expire_uniqueid_lo"), (int)(sd->status.inventory[i].unique_id&0xffffffff));pc->setreg(sd, script->add_str("@expire_uniqueid_hi"), (int)((sd->status.inventory[i].unique_id>>32)&0xffffffff));
I prefer ra's method, convert the long long type var  into string var

snprintf(buf, sizeof(buf)-1, "%llu", (unsigned long long)item->unique_id);
But then, we cannot perform actions on string, if its integer, we can perform many things...

Share this post


Link to post
Share on other sites

Hello guys, i liked Angelmelody suggestion to make "getequipuniqueid".

 

It has an awesome implementation idea for dynamic items tree (i was using it before in reathena):

- You can make the item (specific unique id) to win points or experience to possibility it to evolve to another item later.

- Also, you can buy, sell, trade and store this specific item with other players, keeping it's points/experience.

- If you do not use unique id feature, the points/experience can not be attached to the item.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.