New item member: gottenby

Archive of the older Feature Request Forum Posts
Locked
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

New item member: gottenby

Post by ncrsn »

When an item is picked up by player, core marks it for the character. While holding, dragged item can be retrieved using character method GetGottenItem(). Nice and useful.

But, if scripter only wants to check if the item is gotten by someone, without knowing whom to check, one has to use a script like this:

Code: Select all

function IsGotten( item )
    foreach char in EnumerateOnlineCharacters()
        if (char.GetGottenItem() == item)
            return char;
        endif
    endforeach
endfunction
Which, while a working solution, isn't really a neat one. So I'm suggesting that whenever an item is picked up by player, not only the item is marked to be gotten by character, but also the character is marked to be carrying the item.

That would item.gottenby, which would return character reference of carrier, if there is one.

Either so or the information could be saved in container member, like done when item is equipped, and the new item member could be just item.gotten, returning true or false, to tell apart equipped and gotten item.

Ideas, solutions?
Luth
Former Developer
Posts: 200
Joined: Mon Jan 30, 2006 8:10 am

Post by Luth »

I think a feasible work-around can be implemented using a Packet Hook for Packet 0x07 (Lift) and 0x08 (Drop). On Lift, you can set a CProp on the item, "GottenBy", to the char's serial, and erase it On Drop. During the interim, any script can check "GottenBy" by accessing its CProp and getting the character directly from the serial.

What do you think?
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

Not a very clean way, but that would do it.

I mean, if the item is not draggable, server replies with 0x27 (dragging rejected, 2 bytes, no serial included). If the dragging succeeds, server replies only with 0x1D (delete object), which is sent to every player around and also in other instances, too. So there's no way I know to react only when supposed to.

To make things perfect, not only would one have to hook packets 0x07 and 0x08 you mentioned, but also 0x27, and in its script, find out what item the player was about to drag (save serial into the character in 0x07 packet, that is), then remove the just set "GottenBy" cprop from the item. That's to make sure an item is not marked gotten when it's not.

Another way to handle that is to do it when checking if item is gotten. First to find out whom should be dragging the item, then comparing the item to the one he/she really is dragging (character.GetGottenItem()). Removing outdated information if values differ.

Might be just a minor issue, but I think it's worth a thought anyway.

--

So while doable, should I have stated things correctly and mentioned the easiest ways to overcome the problem, I still hope this feature will be implemented in the course of time.

Unless there's a reason to not do so at all?
Locked