Open DarthFutuza opened 6 years ago
Thoughts on how to implement:
When you purchase a new weapon from a shop, add that item to a 2nd "inventory" for that client. This "refundInventory" is just a list of item's/item names that were purchased that also store when (in game time) they were purchased. Every time you buy a weapon from a vendor, it adds the item to this list as well as the current gametime stamp.
Every X seconds (default cvar is 30 seconds), game will loop through the list and check for items older than 30 seconds:
if(refundInventory.size() > 0 && level.time - refundInventory[i].purchasetime > 30 * 1000)
refundInventory.remove(i);
Then it will remove that item from the list. (If the current list size is 0, it doesn't bother removing anything.)
Whenever the player is shopping, if the item is still on the list, the sell cost is the same as the purchase cost instead of being halved.
Unfortunately the current buyback solution needed to be removed as it was causing crashes from spamming too many commands. See the old code here: 14f758409e88cffe8085f899cc0a5d620bce99d7 We want to probably do this a little different, so that we can easily display the full price being returned as well on the UI and not have a mismatch between the server side and client.
Currently if you purchase something from a vendor you can only sell it back for half price. While I agree with this, I think we should allow players to sell things back to vendors for full price after first purchasing for up to 15-30 seconds. That way if you accidentally purchase the wrong item you don't get screwed over. It also gives you a chance to briefly try the weapon out without committing your credits to it. Would only allow this for npc vendors (and definitely not for future player trading). Could also make it a cvar for how long to allow full price sell backs.
-Suggestion comes from two of my brothers who initially wanted an undo button in the shop (similar to LoL).