spells_buy.c
src/spells_buy.c · 6.6 KB
From the archive cyhawk_mud.tar.gz
Download the archive « Back to the archive contents
#include <sys/types.h>
#include <stdio.h>
#include <time.h>
#include "merc.h"
#include "magic.h"
#include "interp.h"
#include "rig.h"
#include "rig_tables.h"
#include "balance.h"
#define ptc printf_to_char
/*
* Buying spells:
*
* Ok, So gaining levels only gives you stats.
* So lets make it so you can buy spells.
* Theorticly, this will allow players to purchuse
* spells to use.
*/
void cmd_buy_spell(CHAR_DATA * ch, char *argument)
{
char arg1[MSL];
int cost, spell, sn;
int wizard;
one_argument(argument, arg1);
if (arg1[0] == '\0')
{
ptc(ch, "Buy which spell?\n\r");
return;
}
if (ch->class == CLASS_WIZARD)
wizard = 1;
else if (ch->class == CLASS_PRIEST)
wizard = 2;
else if (ch->class == CLASS_FIGHTER)
wizard = 3;
else if (ch->class == CLASS_THIEF)
wizard = 4;
else
{
ptc(ch, "You cannot buy spells.\n\r");
return;
}
if (wizard == 1)
spell = rig_wizscroll_lookup(arg1);
else if (wizard == 2)
spell = rig_priscroll_lookup(arg1);
else if (wizard == 3)
spell = rig_fighter_tome_lookup(arg1);
else if (wizard == 4)
spell = rig_thief_tome_lookup(arg1);
if (spell == -1)
{
ptc(ch, "There is no spell '%s'.\n\r", arg1);
return;
}
/* Check SN if valid.. */
if (wizard == 1)
sn = skill_lookup(rig_wizscroll_table[spell].name);
else if (wizard == 2)
sn = skill_lookup(rig_priscroll_table[spell].name);
else if (wizard == 3)
sn = skill_lookup(rig_fighter_tome_table[spell].name);
else if (wizard == 4)
sn = skill_lookup(rig_thief_tome_table[spell].name);
if (sn == -1)
{
ptc(ch, "Error: Tell Thri he has an invalid spell in the tables!\n\r");
return;
}
if (wizard == 1)
cost = rig_wizscroll_table[spell].cost;
else if (wizard == 2)
cost = rig_priscroll_table[spell].cost;
else if (wizard == 3)
cost = rig_fighter_tome_table[spell].cost;
else if (wizard == 4)
cost = rig_thief_tome_table[spell].cost;
if (ch->gold < cost)
{
ptc(ch, "You do not have enough gold to purchuse this spell.\n\r");
return;
}
ch->gold -= cost;
ch->pcdata->learned[sn] = 1;
if (wizard == 1)
ptc(ch, "You now have the spell %s at your disposal.\n\r", rig_wizscroll_table[spell].name);
else if (wizard == 2)
ptc(ch, "You now have the spell %s at your disposal.\n\r", rig_priscroll_table[spell].name);
else if (wizard == 3)
ptc(ch, "You now have the skill %s at your disposal.\n\r", rig_fighter_tome_table[spell].name);
else if (wizard == 4)
ptc(ch, "You now have the skill %s at your disposal.\n\r", rig_thief_tome_table[spell].name);
do_save(ch, "");
return;
}
void cmd_list_spell(CHAR_DATA * ch, char *argument)
{
int x, col, sn = 0;
int wizard;
if (!IS_SET(ch->in_room->room_flags, ROOM_SPELL_SHOP))
{
ptc(ch, "You cannot buy any spells here.\n\r");
return;
}
if (ch->class == CLASS_WIZARD)
wizard = 1;
else if (ch->class == CLASS_PRIEST)
wizard = 2;
else if (ch->class == CLASS_FIGHTER)
wizard = 3;
else if (ch->class == CLASS_THIEF)
wizard = 4;
else
{
ptc(ch, "You cannot buy spells.\n\r");
return;
}
if (wizard == 1 || wizard == 2)
{
ptc(ch, "The following spells are availible for sale:\n\r");
ptc(ch, "{B[{wCost {B] {gSpell Name ({rMana{x) {B[{wCost{B ]{g Spell Name ({rMana{x) \n\r");
}
else
{
ptc(ch, "The following skills are availible for sale:\n\r");
ptc(ch, "{B[{wCost {B] {gSpell Name {B[{wCost{B ]{g Spell Name \n\r");
}
if (wizard == 1)
{
for (x = 0; rig_wizscroll_table[x].name != NULL; x++)
{
sn = skill_lookup(rig_wizscroll_table[x].name);
if (sn == -1)
continue;
if (ch->pcdata->learned[sn] != 0)
continue;
ptc(ch, "{B[{w%-5d{B] {g%-20s ({r%-4d{x) ",
rig_wizscroll_table[x].cost,
rig_wizscroll_table[x].name,
calculate_spellcost(ch->level, skill_table[sn].min_mana));
if (++col % 2 == 0)
send_to_char ("{x\n\r", ch);
}
stc("\n\r", ch);
return;
}
else if (wizard == 2)
{
for (x = 0; rig_priscroll_table[x].name != NULL; x++)
{
sn = skill_lookup(rig_priscroll_table[x].name);
if (sn == -1)
continue;
if (ch->pcdata->learned[sn] != 0)
continue;
ptc(ch, "{B[{w%-5d{B] {g%-20s ({r%-4d{x) ",
rig_priscroll_table[x].cost,
rig_priscroll_table[x].name,
calculate_spellcost(ch->level, skill_table[sn].min_mana));
if (++col % 2 == 0)
send_to_char ("{x\n\r", ch);
}
stc("\n\r", ch);
return;
}
else if (wizard == 3)
{
for (x = 0; rig_fighter_tome_table[x].name != NULL; x++)
{
sn = skill_lookup(rig_fighter_tome_table[x].name);
if (sn == -1)
continue;
if (ch->pcdata->learned[sn] != 0)
continue;
ptc(ch, "{B[{w%-5d{B] {g%-20s ",
rig_fighter_tome_table[x].cost,
rig_fighter_tome_table[x].name);
if (++col % 2 == 0)
send_to_char ("{x\n\r", ch);
}
stc("\n\r", ch);
return;
}
else if (wizard == 4)
{
for (x = 0; rig_thief_tome_table[x].name != NULL; x++)
{
sn = skill_lookup(rig_thief_tome_table[x].name);
if (sn == -1)
continue;
if (ch->pcdata->learned[sn] != 0)
continue;
ptc(ch, "{B[{w%-5d{B] {g%-20s ",
rig_thief_tome_table[x].cost,
rig_thief_tome_table[x].name);
if (++col % 2 == 0)
send_to_char ("{x\n\r", ch);
}
stc("\n\r", ch);
return;
}
return;
}