mine.rtf
docs · 8.9 KB · 2010-03-30
Download « Back to the docs list
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Courier New;}{\f1\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.15.1507;}\viewkind4\uc1\pard\f0\fs20 I wrote this up one night in about 45 minutes or so. It's not the greatest way of doing this I know, but a friend of mine asked me if I could create a small mining code that wouldn't be difficult to add, and this is just what I came up with. In the do_mining code you will have to build the pick axe object, and remove the ch->in_room checks. You don't have to contact me or anything if you use this, maybe if you could just add something into the helpfile for it or whatever you wanna do, that would be cool. I'm also putting in the junk command I added later on to get rid of the materials since I only allow for 30 materials total to be held. Also, this could easily be converted to make you actually mine the objects for the materials, I just use a point system cause it was fast and easy to do.\par
\par
Josh Erickson -AKA- Azmodian - Coder for Malacious Bliss\par
\par
\par
----Merc.h-----\par
I did this in my char_data, you can add it into either char_data or pc_data\par
\par
int gld;\par
int silv;\par
int ore;\par
int adamantium;\par
int thorium;\par
\par
----Save.c-----\par
in fwrite_char I added this under fprintf ( fp, "Exp %ld\\n", ch->exp );\par
\par
fprintf ( fp, "Gld %d\\n", ch->gld );\par
fprintf ( fp, "Slv %d\\n", ch->silv );\par
fprintf ( fp, "Adama %d\\n", ch->adamantium );\par
fprintf ( fp, "Thorium %d\\n", ch->thorium );\par
fprintf ( fp, "Ore %d\\n", ch->ore );\par
\par
further down in fread_char \par
\par
in case 'A' under KEY ( "Act2", ch->act2, fread_flag ( fp ) );\par
\par
add--> KEY ( "Adama", ch->adamantium, fread_number ( fp ) );\par
\par
in case 'G' under KEY ( "Gold", ch->gold, fread_number ( fp ) );\par
\par
add--> KEY ( "Gld", ch->gld, fread_number ( fp ) );\par
\par
in case 'S' under KEY ( "Silv", ch->silver, fread_number ( fp ) );\par
\par
add--> KEY ( "Slv", ch->silv, fread_number ( fp ) );\par
\par
in case 'T' above KEY ( "Tier", ch->pcdata->tier, fread_number ( fp ) );\par
\par
add--> KEY ( "Thorium", ch->thorium, fread_number ( fp ) );\par
\par
Ok, now if you are running a stock version of rot/rom, or if you haven't yet added anything needed for a case 'O' yet, look for case 'N', now since I don't know what your fread_char has in it. right above case 'P':--\par
\par
add--> case 'O':\par
KEY ( "Ore", ch->ore, fread_number ( fp ) );\par
break;\par
\par
----that should take care of save.c----\par
\par
----act_info.c----\par
\par
Or wherever you wanna add the mining command.\par
\par
void do_mine(CHAR_DATA *ch, char *argument)\par
\{\par
char arg[MAX_INPUT_LENGTH];\par
OBJ_DATA *pick;\par
int mnum;\par
\par
mnum = ch->gld + ch->silv + ch->ore + ch->adamantium + ch->thorium;\par
\par
one_argument ( argument, arg );\par
\par
pick = get_eq_char ( ch, WEAR_HOLD );\par
\par
if ( arg[0] == '\\0')\par
\{\par
send_to_char ( "You can mine the Following materials: Ore Silver Gold Thorium Adamantium", ch );\par
return;\par
\}\par
\par
if ( pick == NULL )\par
\{\par
send_to_char ( "You are not holding anything!\\n\\r", ch );\par
return;\par
\}\par
\par
if ( pick->pIndexData->vnum != 99 )\par
\{\par
send_to_char ( "You must be holding a pick axe to mine!\\n\\r", ch);\par
return;\par
\}\par
\par
if ( mnum >= 30 )\par
\{\par
send_to_char ( "You are already carrying your limit in materials, you may not carry more than 30 pieces at a time\\n\\r", ch );\par
return;\par
\}\par
\par
if ( !str_cmp (arg, "ore" ) && ch->in_room->vnum >= 9500 && ch->in_room->vnum <= 9519 )\par
\{\par
if (number_percent () > 90 )\par
\{\par
send_to_char ( "You begin to mine.....", ch);\par
WAIT_STATE ( ch, 60 );\par
send_to_char ("You have found a piece of Ore\\n\\r", ch);\par
send_to_char ("\\n\\r", ch );\par
send_to_char ("You are exhausted, you must wait a little bit", ch );\par
ch->ore += 1;\par
\}\par
else\par
\{\par
send_to_char ("You begin to mine.....You found nothing", ch );\par
WAIT_STATE ( ch, 10 );\par
return;\par
\}\par
\}\par
\par
if ( !str_cmp (arg, "silver" ) && ch->in_room->vnum >= 9540 && ch->in_room->vnum <= 9559 )\par
\{\par
if (number_percent () > 90 )\par
\{\par
send_to_char ( "You begin to mine.....", ch);\par
WAIT_STATE ( ch, 60 );\par
send_to_char ("You have found a piece of silver\\n\\r", ch);\par
send_to_char ("\\n\\r", ch );\par
send_to_char ("You are exhausted, you must wait a little bit", ch );\par
ch->silv += 1;\par
\}\par
else\par
\{\par
send_to_char ("You begin to mine.....You found nothing", ch );\par
WAIT_STATE ( ch, 10 );\par
return;\par
\}\par
\}\par
\par
if ( !str_cmp (arg, "gold" ) && ch->in_room->vnum >= 9520 && ch->in_room->vnum <= 9539 )\par
\{\par
if (number_percent () > 90 )\par
\{\par
send_to_char ( "You begin to mine.....", ch);\par
WAIT_STATE ( ch, 60 );\par
send_to_char ("You have found a piece of gold\\n\\r", ch);\par
send_to_char ("\\n\\r", ch );\par
send_to_char ("You are exhausted, you must wait a little bit", ch );\par
ch->gld += 1;\par
\}\par
else\par
\{\par
send_to_char ("You begin to mine.....You found nothing", ch );\par
WAIT_STATE ( ch, 10 );\par
return;\par
\}\par
\}\par
\par
if ( !str_cmp (arg, "thorium" ) && ch->in_room->vnum >= 9560 && ch->in_room->vnum <= 9579 )\par
\{\par
if (number_percent () > 90 )\par
\{\par
send_to_char ( "You begin to mine.....", ch);\par
WAIT_STATE ( ch, 60 );\par
send_to_char ("You have found a piece of Thorium\\n\\r", ch);\par
send_to_char ("\\n\\r", ch );\par
send_to_char ("You are exhausted, you must wait a little bit", ch );\par
ch->thorium += 1;\par
\}\par
else\par
\{\par
send_to_char ("You begin to mine.....You found nothing", ch );\par
WAIT_STATE ( ch, 10 );\par
return;\par
\}\par
\}\par
\par
if ( !str_cmp (arg, "adamantium" ) )\par
\{\par
if (number_percent () > 90 && ch->in_room->vnum >= 9580 && ch->in_room->vnum <= 9599 )\par
\{\par
send_to_char ( "You begin to mine.....", ch);\par
WAIT_STATE ( ch, 60 );\par
send_to_char ("You have found a piece of Adamantium\\n\\r", ch);\par
send_to_char ("\\n\\r", ch );\par
send_to_char ("You are exhausted, you must wait a little bit", ch );\par
ch->adamantium += 1;\par
\}\par
else\par
\{\par
send_to_char ("You begin to mine.....You found nothing", ch );\par
WAIT_STATE ( ch, 10 );\par
return;\par
\}\par
\}\par
\}\par
\f1\par
\par
\f0 void do_junk(CHAR_DATA *ch, char *argument)\par
\{\par
char arg1[MAX_INPUT_LENGTH];\par
char arg2[MAX_INPUT_LENGTH];\par
long value;\par
\par
\par
smash_tilde ( argument );\par
argument = one_argument ( argument, arg1 );\par
strcpy ( arg2, argument );\par
\par
if ( arg1[0] == '\\0' || arg2[0] == '\\0')\par
\{\par
send_to_char ("Syntax: junk <material> <amount>\\n\\r", ch );\par
return;\par
\}\par
\par
value = is_number ( arg2 ) ? atol ( arg2 ) : 1;\par
\par
if ( !str_cmp ( arg1, "ore" ) && ch->ore >= value )\par
\{\par
printf_to_char ( ch, "You toss out %ld ore\\n\\r", value );\par
ch->ore -= value;\par
\}\par
else if ( !str_cmp ( arg1, "silver" ) && ch->silv >= value)\par
\{\par
printf_to_char ( ch, "You toss out %ld silver\\n\\r", value);\par
ch->silv -= value;\par
\}\par
else if ( !str_cmp ( arg1, "gold" ) && ch->gld >= value)\par
\{\par
printf_to_char (ch, "You toss out %ld gold\\n\\r", value);\par
ch->gld -= value;\par
\}\par
else if ( !str_cmp ( arg1, "adamantium" ) && ch->adamantium >= value )\par
\{\par
printf_to_char (ch, "You toss out %ld adamantium\\n\\r", value );\par
ch->adamantium -= value;\par
\}\par
else if ( !str_cmp ( arg1, "thorium" ) && ch->thorium >= value )\par
\{\par
printf_to_char (ch, "You toss out %ld thorium\\n\\r", value );\par
ch->thorium -= value;\par
\}\par
else\par
\{\par
send_to_char ("You can't do that\\n\\r", ch );\par
\}\par
return;\par
\par
\}\par
\f1\par
\par
Now, that you got everything in, go into interp.c and interp.h and declare the commands, compile, and go. It should go in with no problems. Enjoy!\par
}