Commands are dealt with in two different ways. Mob commands are parsed
normally as a normal ACMD() is. They are added in much the same way that
a normal command is added. Object and Room commands, however, have to go
through their own parsing process. This involves not only adding the code
for the command itself, but an entry in their own 'master command list'
which is stored in either dg_wldcmd.c or dg_objcmd.c, depending on which
command type you are referring to. This is simply a matter of adding a
new line entry to either the obj_cmd_info or the wld_cmd_info (found near
the end of their respective files) I won't go into detail on that, as it
is a very simple process, much like adding a new command for players.
Identification of commands is a simple process. ACMD() is for mobs, OCMD() is for objects, and WCMD() is for rooms. Then, it is simply a matter of adding the command, and it's entry into it's respective command list.
The syntax is simple:
wreward <victim> <type> <amount>
mreward <victim> <type> <amount>
oreward <victim> <type> <amount>
Current Types are:
practice
mana
move
Here are the specific commands:
OCMD(do_oreward)
{
char arg[MAX_INPUT_LENGTH];
char_data *victim;
half_chop(argument, arg, buf);
if (!*arg) {
obj_log(obj, "oreward called with no argument");
return;
}
if (!(victim = get_char_by_obj(obj, arg))) {
obj_log(obj, "oreward: victim not found");
return;
}
change_value(victim, buf);
}
WCMD(do_reward)
{
char arg[MAX_INPUT_LENGTH];
char_data *victim;
half_chop(argument, arg, buf);
if (!*arg) {
wld_log(room, "wreward called with no argument");
return;
}
if (!(victim = get_char_by_room(room, arg))) {
wld_log(room, "wreward: victim not in room");
return;
}
change_value(victim, buf);
}
ACMD(do_mreward)
{
char arg[MAX_INPUT_LENGTH];
char_data *victim;
if (!IS_NPC(ch)) {
send_to_char("Huh?!?\r\n", ch);
return;
}
if (AFF_FLAGGED(ch, AFF_CHARM))
return;
half_chop(argument, arg, buf);
if (!*arg) {
mob_log(ch, "mreward called with no argument");
return;
}
if (!(victim = get_char_room_vis(ch, arg))) {
mob_log(ch, "mreward: victim not in room");
return;
}
change_value(victim, buf);
}
void change_value(struct char_data *ch, char *argument)
{
int amount;
two_arguments(argument, buf1, buf2);
/* This is now a two_arguments....it cleans up the extra space */
/* Right down here v there was a * missing */
if (!*buf2 || !isdigit(*buf2)) {
log("SYSERR: Invalid entry in change_value (%s)", argument);
return;
}
amount = atoi(buf2);
if (is_abbrev(buf1, "practice")) {
GET_PRACTICES(ch) += amount;
if (GET_PRACTICES(ch) < 0)
GET_PRACTICES(ch) = 0;
} else if (is_abbrev(buf1, "mana")) {
GET_MANA(ch) += amount;
if (GET_MANA(ch) < 0)
GET_MANA(ch) = 0;
if (GET_MANA(ch) > GET_MAX_MANA(ch))
GET_MANA(ch) = GET_MAX_MANA(ch);
} else if (is_abbrev(buf1, "move")) {
GET_MOVE(ch) += amount;
if (GET_MOVE(ch) < 0)
GET_MOVE(ch) = 0;
if (GET_MOVE(ch) > GET_MAX_MOVE(ch))
GET_MOVE(ch) = GET_MAX_MOVE(ch);
} else {
log("SYSERR: Unknown change_value type (%s)", buf1);
}
}
void reverse_damage(struct char_data *ch, int amount)
{
send_to_char("A warm feeling fills your body as you are healed.\r\n", ch);
GET_HIT(ch) += amount;
if (GET_HIT(ch) > GET_MAX_HIT(ch))
GET_HIT(ch) = GET_MAX_HIT(ch);
update_pos(ch);
}