The basis for 'oset'
This commit is contained in:
@@ -1137,6 +1137,22 @@ else
|
|||||||
%send% %actor% The switch says, 'Fine... fine.'
|
%send% %actor% The switch says, 'Fine... fine.'
|
||||||
end
|
end
|
||||||
~
|
~
|
||||||
|
#1279
|
||||||
|
OSET test trigger~
|
||||||
|
0 j 100
|
||||||
|
~
|
||||||
|
wait 2 sec
|
||||||
|
say Yeah, I can sharpen this.
|
||||||
|
wait 2 sec
|
||||||
|
emote chips away at %object.shortdesc%.
|
||||||
|
set short %object.shortdesc% sharpened by '%self.name%'
|
||||||
|
nop %object.oset(apply damroll 1)%
|
||||||
|
nop %object.oset(shortdesc %short%)%
|
||||||
|
wait 2 sec
|
||||||
|
give %object.name.car% %actor.name%
|
||||||
|
wait 1 sec
|
||||||
|
say There ya go!
|
||||||
|
~
|
||||||
#1280
|
#1280
|
||||||
Mob Raid~
|
Mob Raid~
|
||||||
2 b 100
|
2 b 100
|
||||||
|
|||||||
@@ -322,6 +322,7 @@ ACMD(do_goto);
|
|||||||
ACMD(do_invis);
|
ACMD(do_invis);
|
||||||
ACMD(do_links);
|
ACMD(do_links);
|
||||||
ACMD(do_load);
|
ACMD(do_load);
|
||||||
|
ACMD(do_oset);
|
||||||
ACMD(do_peace);
|
ACMD(do_peace);
|
||||||
ACMD(do_plist);
|
ACMD(do_plist);
|
||||||
ACMD(do_purge);
|
ACMD(do_purge);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "genzon.h" /* for real_zone_by_thing */
|
#include "genzon.h" /* for real_zone_by_thing */
|
||||||
#include "class.h"
|
#include "class.h"
|
||||||
#include "genolc.h"
|
#include "genolc.h"
|
||||||
|
#include "genobj.h"
|
||||||
#include "fight.h"
|
#include "fight.h"
|
||||||
#include "house.h"
|
#include "house.h"
|
||||||
#include "modify.h"
|
#include "modify.h"
|
||||||
@@ -5030,3 +5031,43 @@ ACMD(do_recent)
|
|||||||
*(tmstr + strlen(tmstr) - 1) = '\0';
|
*(tmstr + strlen(tmstr) - 1) = '\0';
|
||||||
send_to_char(ch, "Current Server Time: %-19.19s\r\nShowing %d players since last copyover/reboot\r\n", tmstr, hits);
|
send_to_char(ch, "Current Server Time: %-19.19s\r\nShowing %d players since last copyover/reboot\r\n", tmstr, hits);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ACMD(do_oset)
|
||||||
|
{
|
||||||
|
char arg[MAX_INPUT_LENGTH];
|
||||||
|
char arg2[MAX_INPUT_LENGTH];
|
||||||
|
struct obj_data *obj;
|
||||||
|
bool success = TRUE;
|
||||||
|
|
||||||
|
argument = one_argument(argument, arg);
|
||||||
|
|
||||||
|
if (!*arg)
|
||||||
|
send_to_char(ch, "oset what?\r\n");
|
||||||
|
else if (!(obj = get_obj_in_list_vis(ch, arg, NULL, ch->carrying)) &&
|
||||||
|
!(obj = get_obj_in_list_vis(ch, arg, NULL, world[IN_ROOM(ch)].contents)))
|
||||||
|
send_to_char(ch, "You don't seem to have %s %s.\r\n", AN(arg), arg);
|
||||||
|
else {
|
||||||
|
argument = one_argument(argument, arg2);
|
||||||
|
|
||||||
|
if (!*arg2)
|
||||||
|
send_to_char(ch, "What?\r\n");
|
||||||
|
else {
|
||||||
|
if (is_abbrev(arg2, "alias") && (success = oset_alias(obj, argument)))
|
||||||
|
send_to_char(ch, "Object alias set to %s.\r\n", argument);
|
||||||
|
else if (is_abbrev(arg2, "longdesc") && (success = oset_long_description(obj, argument)))
|
||||||
|
send_to_char(ch, "Object long description set to %s.\r\n", argument);
|
||||||
|
else if (is_abbrev(arg2, "shortdesc") && (success = oset_short_description(obj, argument)))
|
||||||
|
send_to_char(ch, "Object short description set to %s.\r\n", argument);
|
||||||
|
else if (is_abbrev(arg2, "apply") && (success = oset_apply(obj, argument)))
|
||||||
|
send_to_char(ch, "Object apply set to %s.\r\n", argument);
|
||||||
|
else {
|
||||||
|
if (!success)
|
||||||
|
send_to_char(ch, "%s was unsuccessful.\r\n", arg2);
|
||||||
|
else
|
||||||
|
send_to_char(ch, "Unknown argument: %s.\r\n", arg2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "class.h"
|
#include "class.h"
|
||||||
#include "quest.h"
|
#include "quest.h"
|
||||||
#include "act.h"
|
#include "act.h"
|
||||||
|
#include "genobj.h"
|
||||||
|
|
||||||
/* Utility functions */
|
/* Utility functions */
|
||||||
|
|
||||||
@@ -132,6 +133,43 @@ int char_has_item(char *item, struct char_data *ch)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int handle_oset(struct obj_data * obj, char * argument)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
bool found = FALSE;
|
||||||
|
char value[MAX_INPUT_LENGTH];
|
||||||
|
|
||||||
|
struct oset_handler {
|
||||||
|
const char * type;
|
||||||
|
bool (* name)(struct obj_data *, char *);
|
||||||
|
} handler[] = {
|
||||||
|
{ "alias", oset_alias },
|
||||||
|
{ "apply", oset_apply },
|
||||||
|
{ "longdesc", oset_long_description },
|
||||||
|
{ "shortdesc", oset_short_description},
|
||||||
|
{ "\n", NULL }
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!obj || !*argument)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
argument = one_argument(argument, value);
|
||||||
|
|
||||||
|
while (*handler[i].type != '\n') {
|
||||||
|
if (is_abbrev(value, handler[i].type)) {
|
||||||
|
found = TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
handler[i].name(obj, argument);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int text_processed(char *field, char *subfield, struct trig_var_data *vd,
|
int text_processed(char *field, char *subfield, struct trig_var_data *vd,
|
||||||
char *str, size_t slen)
|
char *str, size_t slen)
|
||||||
{
|
{
|
||||||
@@ -1200,6 +1238,16 @@ o->contains) ? "1" : "0"));
|
|||||||
*str = '\0';
|
*str = '\0';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
if (!str_cmp(field, "oset")) {
|
||||||
|
if (subfield && *subfield) {
|
||||||
|
if (handle_oset(o, subfield))
|
||||||
|
strcpy(str, "1");
|
||||||
|
else
|
||||||
|
strcpy(str, "0");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'r':
|
case 'r':
|
||||||
if (!str_cmp(field, "room")) {
|
if (!str_cmp(field, "room")) {
|
||||||
if (obj_room(o) != NOWHERE)
|
if (obj_room(o) != NOWHERE)
|
||||||
|
|||||||
110
src/genobj.c
110
src/genobj.c
@@ -11,11 +11,13 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
#include "shop.h"
|
#include "shop.h"
|
||||||
|
#include "constants.h"
|
||||||
#include "genolc.h"
|
#include "genolc.h"
|
||||||
#include "genobj.h"
|
#include "genobj.h"
|
||||||
#include "genzon.h"
|
#include "genzon.h"
|
||||||
#include "dg_olc.h"
|
#include "dg_olc.h"
|
||||||
#include "handler.h"
|
#include "handler.h"
|
||||||
|
#include "interpreter.h"
|
||||||
#include "boards.h" /* for board_info */
|
#include "boards.h" /* for board_info */
|
||||||
|
|
||||||
|
|
||||||
@@ -474,3 +476,111 @@ int delete_object(obj_rnum rnum)
|
|||||||
|
|
||||||
return rnum;
|
return rnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* oset handling, this location should be temporary */
|
||||||
|
bool oset_alias(struct obj_data *obj, char * argument)
|
||||||
|
{
|
||||||
|
static int max_len = 64;
|
||||||
|
int i = GET_OBJ_RNUM(obj);
|
||||||
|
|
||||||
|
skip_spaces(&argument);
|
||||||
|
|
||||||
|
if (strlen(argument) > max_len)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (obj->name && obj->name != obj_proto[i].name)
|
||||||
|
free(obj->name);
|
||||||
|
|
||||||
|
obj->name = strdup(argument);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool oset_apply(struct obj_data *obj, char * argument)
|
||||||
|
{
|
||||||
|
int i = 0, apply = -1, location = -1, mod = 0, empty = -1, value;
|
||||||
|
char arg[MAX_INPUT_LENGTH];
|
||||||
|
|
||||||
|
argument = one_argument(argument, arg);
|
||||||
|
|
||||||
|
skip_spaces(&argument);
|
||||||
|
|
||||||
|
if ((value = atoi(argument)) == 0)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
while (*apply_types[i] != '\n') {
|
||||||
|
if (is_abbrev(apply_types[i], arg)) {
|
||||||
|
apply = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (apply == -1)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_OBJ_AFFECT; i++) {
|
||||||
|
if (obj->affected[i].location == apply) {
|
||||||
|
location = i;
|
||||||
|
mod = obj->affected[i].modifier;
|
||||||
|
break;
|
||||||
|
} else if (obj->affected[i].location == APPLY_NONE && empty == -1) {
|
||||||
|
empty = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No slot already using APPLY_XXX, so use an empty one... if available */
|
||||||
|
if (location == -1)
|
||||||
|
location = empty;
|
||||||
|
|
||||||
|
/* There is no slot already using our APPLY_XXX type, and no empty slots either */
|
||||||
|
if (location == -1)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
obj->affected[location].modifier = mod + value;
|
||||||
|
|
||||||
|
/* Our modifier is set at 0, so lets just clear the apply location so that it may
|
||||||
|
* be reused at a later point */
|
||||||
|
if (obj->affected[location].modifier != 0)
|
||||||
|
obj->affected[location].location = apply;
|
||||||
|
else
|
||||||
|
obj->affected[location].location = APPLY_NONE;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool oset_short_description(struct obj_data *obj, char * argument)
|
||||||
|
{
|
||||||
|
static int max_len = 64;
|
||||||
|
int i = GET_OBJ_RNUM(obj);
|
||||||
|
|
||||||
|
skip_spaces(&argument);
|
||||||
|
|
||||||
|
if (strlen(argument) > max_len)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (obj->short_description && obj->short_description != obj_proto[i].short_description)
|
||||||
|
free(obj->short_description);
|
||||||
|
|
||||||
|
obj->short_description = strdup(argument);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool oset_long_description(struct obj_data *obj, char * argument)
|
||||||
|
{
|
||||||
|
static int max_len = 128;
|
||||||
|
int i = GET_OBJ_RNUM(obj);
|
||||||
|
|
||||||
|
skip_spaces(&argument);
|
||||||
|
|
||||||
|
if (strlen(argument) > max_len)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (obj->description && obj->description != obj_proto[i].description)
|
||||||
|
free(obj->description);
|
||||||
|
|
||||||
|
obj->description = strdup(argument);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,5 +23,9 @@ obj_rnum index_object(struct obj_data *obj, obj_vnum ovnum, obj_rnum ornum);
|
|||||||
obj_rnum add_object(struct obj_data *, obj_vnum ovnum);
|
obj_rnum add_object(struct obj_data *, obj_vnum ovnum);
|
||||||
int copy_object_main(struct obj_data *to, struct obj_data *from, int free_object);
|
int copy_object_main(struct obj_data *to, struct obj_data *from, int free_object);
|
||||||
int delete_object(obj_rnum);
|
int delete_object(obj_rnum);
|
||||||
|
bool oset_alias(struct obj_data *obj, char * argument);
|
||||||
|
bool oset_apply(struct obj_data *obj, char * argument);
|
||||||
|
bool oset_short_description(struct obj_data *obj, char * argument);
|
||||||
|
bool oset_long_description(struct obj_data *obj, char * argument);
|
||||||
|
|
||||||
#endif /* _GENOBJ_H_ */
|
#endif /* _GENOBJ_H_ */
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ cpp_extern const struct command_info cmd_info[] = {
|
|||||||
{ "olc" , "olc" , POS_DEAD , do_show_save_list, LVL_BUILDER, 0 },
|
{ "olc" , "olc" , POS_DEAD , do_show_save_list, LVL_BUILDER, 0 },
|
||||||
{ "olist" , "olist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_OLIST },
|
{ "olist" , "olist" , POS_DEAD , do_oasis_list, LVL_BUILDER, SCMD_OASIS_OLIST },
|
||||||
{ "oedit" , "oedit" , POS_DEAD , do_oasis_oedit, LVL_BUILDER, 0 },
|
{ "oedit" , "oedit" , POS_DEAD , do_oasis_oedit, LVL_BUILDER, 0 },
|
||||||
|
{ "oset" , "oset" , POS_DEAD , do_oset, LVL_BUILDER, 0 },
|
||||||
{ "ocopy" , "ocopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_OEDIT },
|
{ "ocopy" , "ocopy" , POS_DEAD , do_oasis_copy, LVL_GOD, CON_OEDIT },
|
||||||
|
|
||||||
{ "put" , "p" , POS_RESTING , do_put , 0, 0 },
|
{ "put" , "p" , POS_RESTING , do_put , 0, 0 },
|
||||||
|
|||||||
Reference in New Issue
Block a user