[Suggestion] Add *getequipuniqueid script cmd

Angelmelody

(\ /) ( . .)
Messages
772
Points
0
Age
32
Location
new_1-1,53,111
Github
Angelmelody
Emulator
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
default_smile.png


src - getequipuniqueid

doc - getequipuniqueid

 
Last edited by a moderator:
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

 
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
  •  

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

 
Last edited by a moderator:
@@AnnieRuru

 Calculating the unique ID isn't real-time updating into mysql ,it requires waiting  server to save , so I think
 obtaining the unique ID via memory is better than  mysql query

 
check Haru's post

Code:
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));
 
check Haru's post

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

Code:
snprintf(buf, sizeof(buf)-1, "%llu", (unsigned long long)item->unique_id);
 
check Haru's post

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

 
Back
Top