custom_weapons.zip
snippets · 7.7 KB · 2010-03-30
Custom weapons: customize.c lets players customize weapons (non-commercial MUDs).
Download « Back to the snippets list
install.txt
-------------------------------------------------------------------------------
This snippet is inspired by Final Fantasy VIII's weapon upgrade system. It
allows each player to customize and restring the weapon they start with, as
well as level it up and enhance it to suit their playing style. The major
concern is that nobody will want to use other weapons, but it's quite a fun
system to play with. Hope you enjoy it.
-- Midboss (eclipsing.souls@gmail.com)
-------------------------------------------------------------------------------
merc.h
-------------------------------------------------------------------------------
Add the following fields to obj_data:
/* Customization data for custom weapons. */
long experience; //Total experience points.
int to_level; //Experience to level.
sh_int level; //Current level.
sh_int damage; //Damage improvement levels.
Add a new ITEM_* bit, ITEM_CUSTOMIZE (mine is aa).
-------------------------------------------------------------------------------
fight.c
--------------------------------------------------------------------------------
In the function disarm, change:
if (IS_OBJ_STAT (obj, ITEM_NODROP) || IS_OBJ_STAT (obj, ITEM_INVENTORY))
obj_to_char (obj, victim);
to
if (IS_OBJ_STAT (obj, ITEM_NODROP) || IS_OBJ_STAT (obj, ITEM_INVENTORY)
||IS_OBJ_STAT (obj, ITEM_CUSTOMIZE))
obj_to_char (obj, victim);
In the function make_corpse, right after assigning obj_next, add:
if (IS_SET (obj->extra_flags, ITEM_CUSTOMIZE))
continue;
-------------------------------------------------------------------------------
handler.c
-------------------------------------------------------------------------------
Add this to the top of can_drop_obj:
//Even imms can't drop them.
if (IS_SET (obj->extra_flags, ITEM_CUSTOMIZE))
return FALSE;
-------------------------------------------------------------------------------
update.c
-------------------------------------------------------------------------------
Add the following at the top of the file:
#define "customize.h"
Add the following to gain_exp:
gain_oexp (ch, gain);
-------------------------------------------------------------------------------
save.c:
-------------------------------------------------------------------------------
Somewhere in fwrite_obj(), add this:
if (IS_OBJ_STAT (obj, ITEM_CUSTOMIZE))
{
fprintf (fp, "Exp %d\n", obj->experience);
fprintf (fp, "Tnl %d\n", obj->to_level);
fprintf (fp, "Lvl %d\n", obj->cust_level);
fprintf (fp, "Dmg %d\n", obj->damage);
}
Now, in fread_obj(), add the following (in the appropriate cases):
KEY ("Dmg", obj->damage, fread_number (fp));
KEY ("Exp", obj->experience, fread_number (fp));
KEY ("Lvl", obj->cust_level, fread_number (fp));
KEY ("Tnl", obj->to_level, fread_number (fp));
-------------------------------------------------------------------------------
interp.c/h
-------------------------------------------------------------------------------
Add the DECLARE_DO_FUN() and command entry for do_customize.
-------------------------------------------------------------------------------
Other
-------------------------------------------------------------------------------
Create eight new objects, one weapon of each type. Make sure to flag them all
with ITEM_CUSTOMIZE. Set the defines in customize.h to their vnums.
-------------------------------------------------------------------------------
const.c
--------------------------------------------------------------------------------
Add the following at the top of the file:
#define "customize.h"
Change the OBJ_VNUM_SCHOOL_* in weapon_table to your OBJ_VNUM_CUSTOM_* defines.
--------------------------------------------------------------------------------
act_wiz.c
--------------------------------------------------------------------------------
Add the following at the top of the file:
#define "customize.h"
Replace the first bit of do_outfit (the part that prevents players over level 5
from getting newbie gear) with this, so your existing players may claim a new
customizable weapon:
if (ch->level > 5 || IS_NPC (ch))
{
if ((obj = get_custom (ch)) == NULL && !IS_NPC (ch))
{
sn = 0;
vnum = OBJ_VNUM_SCHOOL_SWORD; /* just in case! */
for (i = 0; weapon_table[i].name != NULL; i++)
{
if (ch->pcdata->learned[sn] <
ch->pcdata->learned[*weapon_table[i].gsn])
{
sn = *weapon_table[i].gsn;
vnum = weapon_table[i].vnum;
}
}
obj = create_object (get_obj_index (vnum), 0);
obj_to_char (obj, ch);
equip_char (ch, obj, WEAR_WIELD);
gain_oexp (ch, 7500);
send_to_char ("You recieved a new customizable weapon.\n\r", ch);
return;
}
send_to_char ("Find it yourself!\n\r", ch);
return;
}
Change this line of do_outfit:
if ((obj = get_eq_char (ch, WEAR_WIELD)) == NULL)
to
if ((obj = get_custom (ch)) == NULL)
Now, also within the weapon statement, add:
gain_oexp (ch, 7500);
--------------------------------------------------------------------------------
Now add customize.c and customize.h to your source directory and recompile.
It's possible I missed some code that prevents destruction or other loss of the
weapons, but outfit will give a new one if they're lost.
--------------------------------------------------------------------------------Archive contents (3 files)
| File | Size |
|---|---|
| customize.c | 17.9 KB |
| customize.h | 1.9 KB |
| install.txt | 5.5 KB |