|
Potion Brewing Code [by Franco] |
|
|
|
Posted Wednesday, August 12th @ 11:34:01 PM, by George Greer in the Skills dept.
. Click the link below to read it or download it.
From: Franco <awe@mt.arias.net>
Subject: Potion Brewing Code
Ok, due to overwhelming responses, I'm posting the mix code here. Just
give me credit.
Make sure whatever file you put this in, it contains this:
extern char *spells[];
Now, what you've all been waiting for...
void make_potion(struct char_data *ch, int potion, struct obj_data *container)
{
struct obj_data *final_potion;
int can_make = FALSE, mana, dam;
/* Modify this list to suit which spells you
want to be able to mix. */
switch (potion) {
case SPELL_SHIELD:
case SPELL_CURE_BLIND:
case SPELL_CURE_LIGHT:
case SPELL_CURE_CRITIC:
case SPELL_DETECT_MAGIC:
case SPELL_DETECT_INVIS:
case SPELL_DETECT_POISON:
case SPELL_REMOVE_POISON:
case SPELL_REMOVE_CURSE:
case SPELL_STRENGTH:
case SPELL_WORD_OF_RECALL:
case SPELL_SENSE_LIFE:
case SPELL_WATERWALK:
case SPELL_FLY:
case SPELL_HASTE:
case SPELL_INFRAVISION:
case SPELL_ENLARGE:
case SPELL_REGENERATION:
case SPELL_HEAL:
can_make = TRUE;
break;
default:
break;
}
if (can_make == FALSE) {
send_to_char("You that spell cannot be mixed into a potion.\r\n
", ch);
return;
}
else if (number(1, 3) == 3) {
send_to_char("As you begin mixing the potion, it violently expl
odes!\r\n",ch);
act("$n begins to mix a potion, and it suddenly explodes!", FAL
SE, ch, 0,0, TO_ROOM);
extract_obj(container);
dam = number(5, 50);
GET_HIT(ch) -= dam;
update_pos(ch);
return;
}
/* requires x3 mana to mix a potion than the spell */
mana = mag_manacost(ch, potion) * 3;
if (GET_MANA(ch) - mana > 0) {
GET_MANA(ch) -= mana;
sprintf(buf, "You create a potion labeled '%s'.\r\n", spells[po
tion]);
send_to_char(buf, ch);
act("$n creates a potion!", FALSE, ch, 0, 0, TO_ROOM);
extract_obj(container);
}
else {
send_to_char("You don't have enough mana for mixing that potion
!\r\n", ch);
return;
}
final_potion = create_obj();
final_potion->item_number = NOTHING;
final_potion->in_room = NOWHERE;
final_potion->name = str_dup("potion");
sprintf(buf2, "A potion labeled '%s' lies here.", spells[potion]);
final_potion->description = str_dup(buf2);
sprintf(buf2, "A potion labeled '%s'", spells[potion]);
final_potion->short_description = str_dup(buf2);
GET_OBJ_TYPE(final_potion) = ITEM_POTION;
GET_OBJ_WEAR(final_potion) = ITEM_WEAR_TAKE;
GET_OBJ_EXTRA(final_potion) = ITEM_NORENT;
GET_OBJ_VAL(final_potion, 0) = GET_LEVEL(ch);
GET_OBJ_VAL(final_potion, 1) = potion;
GET_OBJ_VAL(final_potion, 2) = -1;
GET_OBJ_VAL(final_potion, 3) = -1;
GET_OBJ_WEIGHT(final_potion) = 1;
GET_OBJ_RENT(final_potion) = 0;
obj_to_char(final_potion, ch);
}
ACMD(do_brew)
{
struct obj_data *container;
struct obj_data *obj, *next_obj;
char bottle_name[MAX_STRING_LENGTH];
char spell_name[MAX_STRING_LENGTH];
int potion, found = FALSE;
two_arguments(argument, bottle_name, spell_name);
if ((GET_CLASS(ch) == CLASS_WARRIOR || GET_CLASS(ch) == CLASS_THIEF) &&
GET_LEVEL(ch) < LVL_IMMORT) {
send_to_char("You have no idea how to mix potions!\r\n", ch);
return;
}
if (!*bottle_name || !*spell_name) {
send_to_char("What do you wish to mix in where?\r\n", ch);
return;
}
for (obj = ch->carrying; obj; obj = next_obj) {
next_obj = obj->next_content;
if (obj == NULL)
return;
else if (!(container = get_obj_in_list_vis(ch, bottle_name, ch-
>carrying)))
continue;
else
found = TRUE;
}
if (found != FALSE && (GET_OBJ_TYPE(container) != ITEM_CONTAINER &&
GET_OBJ_TYPE(container) != ITEM_DRINKCON)) {
send_to_char("That item is not a container!\r\n", ch);
return;
}
if (found == FALSE) {
sprintf(buf, "You don't have %s in your inventory!\r\n", bottle
_name);
send_to_char(buf, ch);
return;
}
potion = find_skill_num(spell_name);
if ((potion < 1) || (potion > MAX_SPELLS)) {
send_to_char("Mix what spell?!?\r\n", ch);
return;
}
if (GET_LEVEL(ch) < spell_info[potion].min_level[(int) GET_CLASS(ch)])
{
send_to_char("You do not know how to make that potion!\r\n", c
h);
return;
}
if (GET_SKILL(ch, potion) == 0) {
send_to_char("You are unfamiliar with potion brewing.\r\n", ch
);
return;
}
make_potion(ch, potion, container);
}
<< Portals -- With Objects [by Tony Robbins] | Reply | View as text | Threaded | Private Channels [by Darksword] >> |
|
Related Links |
|
|
|
CircleMUD Snippets |
|
|
Note: Not all of these snippets will work perfectly with
your version of code, so be prepared to fix one
or two bugs that may arise, and please let me know
what you needed to do to fix it. Sending a corrected
version is always welcome.
|
Finally, if you wish to use any of the snippets from this
page, you are more than welcome, just mention the
authors in your credits. If you wish to release any
of these snippets to the public on another site,
contact me FIRST.
|
|
|
|
|
|
|