swak / flare-engine

Automatically exported from code.google.com/p/flare-engine
0 stars 0 forks source link

Stackable items #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello,

I would like to help by adding stackable items support for items like potions, 
because it's the first thing that bothered me.
I learn C++ again (and english, by the way ;-)), because I didn't code in C++ 
since school.
I have already begin this functionality to see if I am able to complete it.
I'm in the debugging step and I would like to know if you think this 
functionality is acceptable.

Original issue reported on code.google.com by bonbadil@yahoo.fr on 27 Mar 2011 at 3:51

GoogleCodeExporter commented 9 years ago
bonbadil, yes I'll definitely test it when it's ready.  If it works well I'll 
include it in the engine.  Thanks!

Original comment by clintbel...@gmail.com on 27 Mar 2011 at 4:52

GoogleCodeExporter commented 9 years ago
Cool ! :)
I've managed to almost completely support stacks of items in inventory 
yesterday, but already break it because some problems made me try to generalize 
the concept to the loots, equipments, seller's inventory, etc. Stack of item 
equipped may sound weird, but I think to be able to handle ammunition.
If i move a stack on the inventory, the whole stack follow, with a modifier 
(shift ?) to move only one ?
If i drop a stack of 5 health potions, should I get one potion, 5 potions 
scattered on the ground or a stack of 5 potions ? I would prefer the last.
What about trying to sell a stack of item ?
We could make gold coins a stack of item, too ? It will make the engine more 
flexible, able to handle different kinds of money (silver coin plus bronze 
coin). Maybe later.

Original comment by bonbadil@yahoo.fr on 28 Mar 2011 at 5:10

GoogleCodeExporter commented 9 years ago
It would definitely be good to handle any consumable this way: potions, ammo, 
etc.

Feel free to use shift to manipulate item stacks (ctrl is already used for 
buying/selling).

If the player drops 5 potions, I agree with your choice: I think it's best to 
drop the entire stack and show it on the ground as "5 Health Potions" for 
example.

I think it's ok to allow someone to sell an entire stack of an item.

I don't mind the idea of treating gold like a stacked item, but I'll wait for 
later.

When you're ready please post your new code or a diff.  I'll do some testing 
and tweaking of my own before merging.

Original comment by clintbel...@gmail.com on 28 Mar 2011 at 6:04

GoogleCodeExporter commented 9 years ago
I have repaired the stacking of item in inventory. I attach the patch of my 
mess, if you couldn't sleep this night. I'm here to learn, too, so I don't mind 
to do the things again and again until you're tired to explain how things 
should be done.
If I'm on the right way, I expect to handle stack of items in equipped and 
sellers area, too.
Does I have to maintain compatibility with old savegames?

Original comment by bonbadil@yahoo.fr on 30 Mar 2011 at 7:35

Attachments:

GoogleCodeExporter commented 9 years ago
The patch looks high quality.  Great work!

Here's what I suggest for the save file, so that it's compatible with old save 
games:

carried=  <- this line is just as before, contains 64 item ids
quantity= <- this is a new line, contains 64 ints.  If this line doesn't exist 
(e.g. old save file), assume quantity 1

Original comment by clintbel...@gmail.com on 30 Mar 2011 at 7:54

GoogleCodeExporter commented 9 years ago
Checked in: r312

Original comment by clintbel...@gmail.com on 31 Mar 2011 at 12:59

GoogleCodeExporter commented 9 years ago
With this new patch, you can have up to 100 special magical boots equipped 
(named arrows, id 999). But it change nothing. Maybe we can now make a boots 
launcher...
I've tried to factorize some code (like in areaClicked() and slotClicked()) and 
make things simpler (like in drop() and add()).
The stock and the equipment storage are in an array, if we want to add more 
storage or to generalize and use a same code for vendor storage. I'm not sure 
I've well managed the memory...
I don't know if the tooltip in inventory should show "8 mana potion" or just 
"mane potion" (and if the price should be for one item or the whole stack).
For the r314 ("Restored item sound on MenuInventory::add()"), I had remove this 
line because it make playing the item sound several times for one action. I 
think we should add instead a little short sound to say "I pickup something" in 
GameEngine.cpp, line 86. When we trade with the vendor, we have already the 
gold sound.

As before, this is only an humble draft of a beginner... ^_^

Original comment by bonbadil@yahoo.fr on 1 Apr 2011 at 7:09

Attachments:

GoogleCodeExporter commented 9 years ago
Looking at the patch now.  Mostly seems good.

Note that code in the form:

  ItemStack foo;
  foo = {x,y};

is not working for me, not on MinGW nor XCode.  So I've changed all such 
instances to

  foo.item = x;
  foo.quantity = y;

So it's nice to have the option for stackable equipped items, but I don't have 
a current use for it.  The only such example I can think of is Thrown weapons 
in Diablo 2.  Still, having support for it is good.  Checked in r318

Original comment by clintbel...@gmail.com on 1 Apr 2011 at 7:50

GoogleCodeExporter commented 9 years ago
A new little tiny patch, who just bring stackable item in the vendor and the 
SHIFT key to move only one item of a stack. It should also be easier to add 
other item storage, like a player chest or a craft shed. I think it's in your 
idea of Flare as an easy editable engine.
I've not really played with this. I may have leave some bugs.
If you think it's better with this patch than without, we may think about give 
less random items to vendors, otherwise they will be full too quickly.
I've not put my settings in the patch, this time. I just check again.

Original comment by bonbadil@yahoo.fr on 3 Apr 2011 at 8:55

Attachments:

GoogleCodeExporter commented 9 years ago
I like the refactoring, that clean-up was much needed.

Checked in as r323 with a few changes:
- I gave the existing vendors a bit less inventory
- Stackable items have a random quantity on vendors
- Any changes made to MenuVendor's stock are reflected on that NPC's stock, so 
when you talk to the vendor again (without leaving the map) he has the same 
stuff.

Original comment by clintbel...@gmail.com on 4 Apr 2011 at 5:44

GoogleCodeExporter commented 9 years ago
Completed.

Original comment by clintbel...@gmail.com on 5 Apr 2011 at 3:05