Go to the source code of this file.
Defines |
| #define | ALCHEMY_DEBUG |
| #define | EXTREME_ALCHEMY_DEBUG |
Functions |
| static const char * | cauldron_sound () |
| static int | content_recipe_value (object *op) |
| static int | numb_ob_inside (object *op) |
| static void | adjust_product (object *item, int lvl, int yield) |
| static object * | make_item_from_recipe (object *cauldron, recipe *rp) |
| static void | alchemy_failure_effect (object *op, object *cauldron, recipe *rp, int danger) |
| static void | remove_contents (object *first_ob, object *save_item) |
| static int | calc_alch_danger (object *caster, object *cauldron) |
| static object * | find_transmution_ob (object *first_ingred, recipe *rp) |
| static object * | attempt_recipe (object *caster, object *cauldron, int ability, recipe *rp, int nbatches) |
| static void | attempt_do_alchemy (object *caster, object *cauldron) |
| int | use_alchemy (object *op) |
Variables |
| static char * | cauldron_effect [] |
Detailed Description
Contains all alchemy related code.
Definition in file alchemy.c.
Define Documentation
Define this for some helpful debugging information.
Definition at line 33 of file alchemy.c.
| #define EXTREME_ALCHEMY_DEBUG |
Define this for loads of (marginal) debugging information.
Definition at line 36 of file alchemy.c.
Function Documentation
| static void adjust_product |
( |
object * |
item, |
|
|
int |
lvl, |
|
|
int |
yield |
|
) |
| [static] |
Adjust the nrof, exp and level of the final product, based on the item's default parameters, and the relevant caster skill level.
- Parameters:
-
| item | Item to adjust. |
| lvl | Alchemy skill level. |
| yield | How many products the recipe returns at maximum. |
Definition at line 367 of file alchemy.c.
| static void alchemy_failure_effect |
( |
object * |
op, |
|
|
object * |
cauldron, |
|
|
recipe * |
rp, |
|
|
int |
danger |
|
) |
| [static] |
Ouch. We didn't get the formula we wanted. This function simulates the backfire effects -- worse effects as the level increases. If SPELL_FAILURE_EFFECTS is defined some really evil things can happen to the would be alchemist. This table probably needs some adjustments for playbalance.
- Parameters:
-
| op | Who tried to do alchemy. |
| cauldron | Container that was used. |
| rp | Recipe that failed. |
| danger | Danger value, the higher the more evil the effect. |
Definition at line 506 of file alchemy.c.
| static void attempt_do_alchemy |
( |
object * |
caster, |
|
|
object * |
cauldron |
|
) |
| [static] |
Main part of the alchemy code. From this we call functions that take a look at the contents of the 'cauldron' and, using these ingredients, we construct an integer formula value which is referenced (randomly) against a formula list (the formula list chosen is based on the # contents of the cauldron).
If we get a match between the recipe indicated in cauldron contents and a randomly chosen one, an item is created and experience awarded. Otherwise various failure effects are possible (getting worse and worse with # cauldron ingredients). Note that the 'item' to be made can be *anything* listed on the artifacts list in lib/artifacts which has a recipe listed in lib/formulae.
To those wondering why I am using the funky formula index method: 1) I want to match recipe to ingredients regardless of ordering. 2) I want a fast search for the 'right' recipe.
Note: it is just possible that a totally different combination of ingredients will result in a match with a given recipe. This is not a bug! There is no good reason (in my mind) why alchemical processes have to be unique -- such a 'feature' is one reason why players might want to experiment around. :)
- Parameters:
-
| caster | Who is doing alchemy. |
| cauldron | The cauldron in which alchemy should take place. |
Definition at line 102 of file alchemy.c.
Essentially a wrapper for make_item_from_recipe() and insert_ob_in_ob(). If the caster has some alchemy skill, then they might gain some exp from (successful) fabrication of the product. If nbatches==-1, don't give exp for this creation (random generation/ failed recipe)
- Parameters:
-
| caster | Who is trying to do alchemy. |
| cauldron | Container used for alchemy. |
| rp | Recipe attempted. |
| nbatches | If -1, don't give exp for this creation (random generation/failed recipe) |
- Returns:
- Generated item, can be NULL if contents were destroyed.
Definition at line 310 of file alchemy.c.
| static int calc_alch_danger |
( |
object * |
caster, |
|
|
object * |
cauldron |
|
) |
| [static] |
"Danger" level will determine how bad the backfire could be if the user fails to concoct a recipe properly. Factors include the number of ingredients, the length of the name of each ingredient, the user's effective level, the user's Int and the enchantment on the mixing device (aka "cauldron"). Higher values of 'danger' indicate more danger. Note that we assume that we have had the caster ready the alchemy skill *before *this routine is called (no longer auto-readies that skill).
- Parameters:
-
| caster | Who is trying alchemy. |
| cauldron | Container used. |
- Returns:
- Danger value.
Definition at line 824 of file alchemy.c.
| static const char * cauldron_sound |
( |
| ) |
[static] |
| static int content_recipe_value |
( |
object * |
op | ) |
[static] |
Recipe value of the entire contents of a container.
This appears to just generate a hash value, which I guess for now works ok, but the possibility of duplicate hashes is certainly possible.
- Parameters:
-
| op | Container for which to generate a hash. |
- Returns:
- Hash value.
Definition at line 242 of file alchemy.c.
Looks through the ingredient list, if we find a suitable object in it, we will use that to make the requested artifact. Otherwise the code returns a 'generic' item.
- Parameters:
-
| first_ingred | Pointer to first item to check. |
| rp | Recipe the player is trying. |
- Returns:
- NULL if no suitable item was found, new item otherwise.
Definition at line 459 of file alchemy.c.
Use a list of items and a recipe to make an artifact.
- Parameters:
-
| cauldron | The cauldron (including the ingredients) used to make the item. |
| rp | The recipe to make the artifact from. |
- Returns:
- The newly created object, NULL if something failed.
Definition at line 409 of file alchemy.c.
| static int numb_ob_inside |
( |
object * |
op | ) |
[static] |
Returns the total number of items in op, excluding ones in item's items.
- Parameters:
-
- Returns:
- Total item count.
Definition at line 280 of file alchemy.c.
| static void remove_contents |
( |
object * |
first_ob, |
|
|
object * |
save_item |
|
) |
| [static] |
All but object "save_item" are removed from the container list. Note we have to be careful to remove the inventories of objects in the cauldron inventory (ex icecube has stuff in it).
- Parameters:
-
| first_ob | Container from which to remove. |
| save_item | What item not to remove. Can be NULL. |
Definition at line 782 of file alchemy.c.
| int use_alchemy |
( |
object * |
op | ) |
|
Handle use_skill for alchemy-like items.
Will inform player if attempting to use unpaid cauldron or ingredient.
- Parameters:
-
| op | Player trying to do alchemy. |
- Returns:
- 1 if any recipe was attempted, 0 otherwise.
Definition at line 887 of file alchemy.c.
Variable Documentation
Initial value:
{
"vibrates briefly",
"produces a cloud of steam",
"emits bright flames",
"pours forth heavy black smoke",
"emits sparks",
"shoots out small flames",
"whines painfully",
"hiccups loudly",
"wheezes",
"burps",
"shakes",
"rattles",
"makes chugging sounds",
"smokes heavily for a while"
}
Random cauldron effects.
Definition at line 39 of file alchemy.c.