• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# Combining Objects

## Recommended Posts

Ketchaval    186
What are the best ways of making games where the "objects" (ie. items that the player can pick up and manipulate) are combinable to create something with a different / altered or combined effect?

##### Share on other sites
C-Junkie    1099
I would create objects using your own medium-level scripting language. If you embed a gem of light on a staff, for instance, just combine the scripts of the objects and any incompatabilities (like both have the same effect on a single command) can be resolved randomly. (eliminate one of them, make that action cause both effects) I could come up with some examples if you like...

##### Share on other sites
Guest Anonymous Poster
This is a good place for bitflags, eg, one potion could have flags of ITEM_CONSUMABLE | ITEM_MAGICAL (among others), while another could have ITEM_CONSUMABLE | ITEM_FIRERESISTANT. Combine the two potions and simply or the flags together to make one super potion. You could also have certain flags cancel each other out. Check out your bitwise operators

##### Share on other sites
paulkp    122
Or if there is only a small amount of "combined" items, then make separate items for them. For example you have empty waterskin and waterskin which are separate objects. When the player fills the empty waterskin it''s object id is changed to waterskin. This example was taken from my game

##### Share on other sites
Guest Anonymous Poster
Or have a Waterskin object of type OBJ_CONTAINER and a flag of OBJ_FLAG_FULL

An empty Waterskin would, obviously, be flagged OBJ_FLAG_EMPTY

##### Share on other sites
paulkp    122
quote:
Original post by Anonymous Poster
Or have a Waterskin object of type OBJ_CONTAINER and a flag of OBJ_FLAG_FULL
An empty Waterskin would, obviously, be flagged OBJ_FLAG_EMPTY

I have that kind of flag (actually a variable called duration) but I''m using SVGA graphics and the empty waterskin really looks empty (remember Dungeon Master?). Objects could have precalculated ''frame'' in a mask map, but I''m using one frame for item.

##### Share on other sites
Guest Anonymous Poster
quote:
Original post by paulkp
I have that kind of flag (actually a variable called duration) but I''m using SVGA graphics and the empty waterskin really looks empty (remember Dungeon Master?). Objects could have precalculated ''frame'' in a mask map, but I''m using one frame for item.

You could still do it like that, it just depends on how you draw your graphics. Quick eg :

BlitTile(x,y,(Tile^.Flags && OBJ_FLAG_FULL ? TILE_GRAPHIC_WATERSKIN_FULL : TILE_GRAPHIC_WATERSKIN_EMPTY));

Or something ...

##### Share on other sites
Ketchaval    186
quote:
Original post by C-Junkie
If you embed a gem of light on a staff

So in this case the objects are made to be more granular? [ie. gem of light, gem of fire, MOUNT staff , MOUNT ring] and you have certain things that they can be combined with. ie. mountable objects. [a bit like the materia in Final Fantasy 7].

This would be one way, by putting more combinable objects into the game which can be done in different combinations.

So

twig + binding materials + axe blade = axe.

(long) twig + binding materials + spear head = spear

##### Share on other sites
Guest Anonymous Poster
quote:
Original post by Ketchaval

twig + binding materials + axe blade = axe.

(long) twig + binding materials + spear head = spear

How about having something like (very simplified, don''t try this at home) :

  Ingredients[ITEM_SPEAR] = ITEM_BRANCH | ITEM_BINDER | ITEM_SPEARHEAD; ...if Player->Inventory->Contains(Ingredients[ITEM_SPEAR]) { Player->Inventory->Remove(Ingredients[ITEM_SPEAR]; Player->Inventory->Add(ITEM_SPEAR);};

##### Share on other sites
Kylotan    9853
This is pretty trivial, really. A simple way is to just store some sort of Combination Table somewhere. It just maps components to composite items. Whenever the player tries to combine some items, search down the list of composites and try to find a match for all the components. If you find a match for that combination, the other side of the table can give the resulting item. So you then nuke the original items and invoke the new one in their place.

Example, assuming combinations always involve making 2 items into 1:
Original Item 1    Original Item 2     Result----------------------------------------------Hilt               Blade               SwordBranch             Spearhead           Spear

You'd probably use Object type numbers rather than names, obviously.

Maybe you could use 3 components instead of 2, which is simple enough. If you could need a lot more than that, you can use a list of component numbers, which would be easy using the STL in C++ or a collection in Visual Basic.

Edited by - Kylotan on March 20, 2001 1:43:41 PM

##### Share on other sites
C-Junkie    1099
The way i was thinking would be having a blank staff script (scripts imply magical or non-standard effects) and a script on the Gem something cause-effect like:

:spoken "Ächieem Erasnos"
Light self (or ambient) 250
end
:spoken "Semal Erasnos"
Light self 0
end

Which, at the uttereance of command words, would cause an effect. But I just realized that this is not what you wanted because the gem is still a separate object and acts on its own...

For combining potions, i''d ... pregenerate a table of effects of any potion mixed with any other potion based on rules and ramdomness. So, opposites may cancel, similiar both work, weird can cause one to fizzle and another be permanent... BUHAHA...forever polymorphed to a bug. or forever given giant strength... sounds like fun? But then I suppose it would be exploited... maybe just cut the pregenerate so it''s more random.

##### Share on other sites
Guest Anonymous Poster
quote:
Original post by C-Junkie

For combining potions, i''d ... pregenerate a table of effects of any potion mixed with any other potion based on rules and ramdomness. So, opposites may cancel, similiar both work, weird can cause one to fizzle and another be permanent... BUHAHA...forever polymorphed to a bug. or forever given giant strength... sounds like fun? But then I suppose it would be exploited... maybe just cut the pregenerate so it''s more random.

Being temporarily polymorphed into a bug sounds fun, and could have some good gameplay advantages to the player.

What about being able to mix the ingredients, either by choosing proportions. [and having recipies which auto-mix them].

Since potions are supposed to be real, tangible things: you would have to use a predefined table...