Greetings,
Here's a snippet for oedit configurable object repop percentages, complete with happyhour bonuses.
add
to struct obj_flag_data in structs.h
define
Code:
#define GET_OBJ_REPOP(obj) ((obj)->obj_flags.rarity)
in utils.h
define
Code:
#define MAX_OBJ_REPOP 100
in oasis.h
add
Code:
#define OEDIT_REPOP <YOUR VALUE>
to the bottom of your Submodes of OEDIT connectedness defines
add
Code:
send_to_char(ch, "Repop Percentage: %d\r\n", GET_OBJ_REPOP(j));
to your do_stat_object() in act.wizard.c
change:
Code:
if ((retval = sscanf(line, "%d %d %d %d %d", t, t + 1, t + 2, t + 3, t + 4)) != 5) {
if (retval == 3) {
t[3] = 0;
t[4] = 0;
} else if (retval == 4)
t[4] = 0;
else {
log("SYSERR: Format error in third numeric line (expecting 5 args, got %d), %s", retval, buf2);
exit(1);
}
}
to
Code:
if ((retval = sscanf(line, "%d %d %d %d %d %d", t, t + 1, t + 2, t + 3, t + 4, t + 5)) != 6)
{
if (retval == 4)
{
t[4] = 0;
t[5] = 100;
}
else if (retval == 5)
t[5] = 100;
else
{
log("SYSERR: Format error in third numeric line (expecting 6 args, got %d), %s", retval, buf2);
exit(1);
}
}
in *parse_object() in db.c
add
Code:
GET_OBJ_REPOP(obj_proto + i) = t[5];
below the change we just made in db.c
the following is the modified cases in my reset_zone function in db.c
Code:
case 'O': /* read an object */
if (obj_index[ZCMD.arg1].number < ZCMD.arg2)
{
obj = read_object(ZCMD.arg1, REAL);
if (ZCMD.arg3 != NOWHERE)
{
rarity = rand_number(0, 99);
if (IS_HAPPYEQ && IS_HAPPYHOUR)
GET_OBJ_REPOP(obj) = MIN(GET_OBJ_REPOP(obj) + HAPPY_EQ, 100);
if (GET_OBJ_REPOP(obj) > rarity)
{
obj_to_room(obj, ZCMD.arg3);
load_otrigger(obj);
last_cmd = 1;
tobj = obj;
}
else
{
extract_obj(obj);
last_cmd = 1;
tobj = obj;
}
}
else
{
obj = read_object(ZCMD.arg1, REAL);
IN_ROOM(obj) = NOWHERE;
last_cmd = 1;
tobj = obj;
}
}
else
last_cmd = 0;
tmob = NULL;
break;
case 'P': /* object to object */
if (obj_index[ZCMD.arg1].number < ZCMD.arg2)
{
obj = read_object(ZCMD.arg1, REAL);
if (!(obj_to = get_obj_num(ZCMD.arg3)))
{
ZONE_ERROR("target obj not found, command disabled");
ZCMD.command = '*';
break;
}
rarity = rand_number(0, 99);
if (IS_HAPPYEQ && IS_HAPPYHOUR)
GET_OBJ_REPOP(obj) = MIN(GET_OBJ_REPOP(obj) + HAPPY_EQ, 100);
if (GET_OBJ_REPOP(obj) > rarity)
{
obj_to_obj(obj, obj_to);
last_cmd = 1;
load_otrigger(obj);
tobj = obj;
}
else
{
extract_obj(obj);
last_cmd = 1;
tobj = obj;
}
}
else
last_cmd = 0;
tmob = NULL;
break;
case 'G': /* obj_to_char */
if (!mob)
{
char error[MAX_INPUT_LENGTH];
snprintf(error, sizeof(error), "attempt to give obj #%d to non-existant mob, command disabled", obj_index[ZCMD.arg1].vnum);
ZONE_ERROR(error);
ZCMD.command = '*';
break;
}
if (obj_index[ZCMD.arg1].number < ZCMD.arg2)
{
obj = read_object(ZCMD.arg1, REAL);
rarity = rand_number(0, 99);
if (IS_HAPPYEQ && IS_HAPPYHOUR)
GET_OBJ_REPOP(obj) = MIN(GET_OBJ_REPOP(obj) + HAPPY_EQ, 100);
if (GET_OBJ_REPOP(obj) > rarity)
{
obj_to_char(obj, mob);
last_cmd = 1;
load_otrigger(obj);
tobj = obj;
}
else
{
extract_obj(obj);
last_cmd = 1;
tobj = obj;
}
}
else
last_cmd = 0;
tmob = NULL;
break;
case 'E': /* object to equipment list */
if (!mob)
{
char error[MAX_INPUT_LENGTH];
snprintf(error, sizeof(error), "trying to equip non-existant mob with obj #%d, command disabled", obj_index[ZCMD.arg1].vnum);
ZONE_ERROR(error);
ZCMD.command = '*';
break;
}
if (obj_index[ZCMD.arg1].number < ZCMD.arg2)
{
obj = read_object(ZCMD.arg1, REAL);
if (ZCMD.arg3 < 0 || ZCMD.arg3 >= NUM_WEARS)
{
char error[MAX_INPUT_LENGTH];
snprintf(error, sizeof(error), "invalid equipment pos number (mob %s, obj %d, pos %d)", GET_NAME(mob), obj_index[ZCMD.arg2].vnum, ZCMD.arg3);
ZONE_ERROR(error);
}
rarity = rand_number(0, 99);
if (IS_HAPPYEQ && IS_HAPPYHOUR)
GET_OBJ_REPOP(obj) = MIN(GET_OBJ_REPOP(obj) + HAPPY_EQ, 100);
if (GET_OBJ_REPOP(obj) > rarity)
{
IN_ROOM(obj) = IN_ROOM(mob);
load_otrigger(obj);
if (wear_otrigger(obj, mob, ZCMD.arg3))
{
IN_ROOM(obj) = NOWHERE;
equip_char(mob, obj, ZCMD.arg3);
}
else
obj_to_char(obj, mob);
tobj = obj;
last_cmd = 1;
}
else
{
extract_obj(obj);
last_cmd = 1;
tobj = obj;
}
}
else
last_cmd = 0;
tmob = NULL;
break;
in genobj.c we need to change another long string:
the original string is:
Code:
fprintf(fp, "%d %s %s %s %s %s %s %s %s %s %s %s %s\n"
"%d %d %d %d\n"
"%d %d %d %d %d\n",
GET_OBJ_TYPE(obj),
ebuf1, ebuf2, ebuf3, ebuf4,
wbuf1, wbuf2, wbuf3, wbuf4,
pbuf1, pbuf2, pbuf3, pbuf4,
GET_OBJ_VAL(obj, 0), GET_OBJ_VAL(obj, 1),
GET_OBJ_VAL(obj, 2), GET_OBJ_VAL(obj, 3),
GET_OBJ_WEIGHT(obj), GET_OBJ_COST(obj),
GET_OBJ_RENT(obj), GET_OBJ_LEVEL(obj), GET_OBJ_TIMER(obj)
);
we change it to:
Code:
fprintf(fp, "%d %s %s %s %s %s %s %s %s %s %s %s %s\n"
"%d %d %d %d\n"
"%d %d %d %d %d %d\n",
GET_OBJ_TYPE(obj),
ebuf1, ebuf2, ebuf3, ebuf4,
wbuf1, wbuf2, wbuf3, wbuf4,
pbuf1, pbuf2, pbuf3, pbuf4,
GET_OBJ_VAL(obj, 0), GET_OBJ_VAL(obj, 1),
GET_OBJ_VAL(obj, 2), GET_OBJ_VAL(obj, 3),
GET_OBJ_WEIGHT(obj), GET_OBJ_COST(obj),
GET_OBJ_RENT(obj), GET_OBJ_LEVEL(obj), GET_OBJ_TIMER(obj), GET_OBJ_REPOP(obj)
);
in objsave.c we change case 'R' of *objsave_parse_objects to be:
Code:
case 'R':
if (!strcmp(tag, "Rare"))
GET_OBJ_REPOP(temp) = num;
else if (!strcmp(tag, "Rent"))
GET_OBJ_RENT(temp) = num;
break;
and add the following to objsave_save_obj_record() near where the if statement for "Rent" is:
Code:
if (TEST_OBJN(rarity))
fprintf(fp, "Rare: %d\n", GET_OBJ_REPOP(obj));
Lastly, we have to add it to Oasis in oedit,c
in oedit_disp_menu() I have the following:
Code:
write_to_output(d,
"%s7%s) Wear flags : %s%s\r\n"
"%s8%s) Weight : %s%d\r\n"
"%s9%s) Cost : %s%d\r\n"
"%sA%s) Cost/Day : %s%d\r\n"
"%sB%s) Timer : %s%d\r\n"
"%sR%s) Repop Pecent: %s%d\r\n"
"%sC%s) Values : %s%d %d %d %d\r\n"
"%sD%s) Applies menu\r\n"
"%sE%s) Extra descriptions menu: %s%s%s\r\n"
"%sM%s) Min Level : %s%d\r\n"
"%sP%s) Perm Affects: %s%s\r\n"
"%sS%s) Script : %s%s\r\n"
"%sW%s) Copy object\r\n"
"%sX%s) Delete object\r\n"
"%sQ%s) Quit\r\n"
"Enter choice : ",
grn, nrm, cyn, buf1,
grn, nrm, cyn, GET_OBJ_WEIGHT(obj),
grn, nrm, cyn, GET_OBJ_COST(obj),
grn, nrm, cyn, GET_OBJ_RENT(obj),
grn, nrm, cyn, GET_OBJ_TIMER(obj),
grn, nrm, cyn, GET_OBJ_REPOP(obj),
grn, nrm, cyn, GET_OBJ_VAL(obj, 0),
GET_OBJ_VAL(obj, 1),
GET_OBJ_VAL(obj, 2),
GET_OBJ_VAL(obj, 3),
grn, nrm, grn, nrm, cyn, obj->ex_description ? "Set." : "Not Set.", grn,
grn, nrm, cyn, GET_OBJ_LEVEL(obj),
grn, nrm, cyn, buf2,
grn, nrm, cyn, OLC_SCRIPT(d) ? "Set." : "Not Set.",
grn, nrm,
grn, nrm,
grn, nrm);
OLC_MODE(d) = OEDIT_MAIN_MENU;
}
in oedit_parse()
Code:
case 'r':
case 'R':
write_to_output(d, "Enter repop percent (0-100): ");
OLC_MODE(d) = OEDIT_REPOP;
break;
and also in oedit_parse() further down:
Code:
case OEDIT_REPOP:
GET_OBJ_REPOP(OLC_OBJ(d)) = LIMIT(atoi(arg), 0, MAX_OBJ_REPOP);
break;
Now, for happyhour integration:
add
to struct happyhour in structs.h
define:
Code:
#define HAPPY_EQ happy_data.eq
in utils.h
IIn act.other.c you need to edit the happyhour integration.
I've removed gold and QP from my game so my show_happyhour looks like this:
Code:
static void show_happyhour(struct char_data *ch)
{
char happyexp[80], happyeq[80];
int secs_left;
if ((IS_HAPPYHOUR) || (GET_LEVEL(ch) >= LVL_GRGOD))
{
if (HAPPY_TIME)
secs_left = ((HAPPY_TIME - 1) * SECS_PER_MUD_HOUR) + next_tick;
else
secs_left = 0;
sprintf(happyexp, "%s+%d%%%s to Experience per kill\r\n", CCYEL(ch, C_NRM), HAPPY_EXP, CCNRM(ch, C_NRM));
sprintf(happyeq, "%s+%d%%%s to equipment repop percentage\r\n", CCYEL(ch, C_NRM), HAPPY_EQ, CCNRM(ch, C_NRM));
send_to_char(ch, "\r\n\r\ntbaMUD Happy Hour!\r\n"
"------------------\r\n"
"%s%sTime Remaining: %s%d%s hours %s%d%s mins %s%d%s secs\r\n",
(IS_HAPPYEXP || (GET_LEVEL(ch) >= LVL_GOD)) ? happyexp : "",
(IS_HAPPYEQ || (GET_LEVEL(ch) >= LVL_GOD)) ? happyeq : "",
CCYEL(ch, C_NRM), (secs_left / 3600), CCNRM(ch, C_NRM),
CCYEL(ch, C_NRM), (secs_left % 3600) / 60, CCNRM(ch, C_NRM),
CCYEL(ch, C_NRM), (secs_left % 60), CCNRM(ch, C_NRM)
);
}
else
{
send_to_char(ch, "Sorry, there is currently no happy hour!\r\n");
}
}
add
Code:
if (is_abbrev(arg, "equipment"))
{
num = MIN(MAX((atoi(val)), 0), 100);
HAPPY_EQ = num;
send_to_char(ch, "Happy Hour equipment drop rate increased by +%d%%\r\n",HAPPY_EQ);
}
to do_happyhour in act.other.c
optionally add HAPPYEQ to "default"
Code:
else if (is_abbrev(arg, "default"))
{
HAPPY_EXP = 100;
HAPPY_TIME = 1000;
HAPPY_EQ = <VALUE>;
game_info("A Happyhour has started!");
}
Feel free to use this snippet. It works flawlessly. All I ask is a credit in your comments. Hope this helps someone.
Thanks.
Note: This will require all you to edit your existing objects for this script to boot: You can write a function adding the extra field (t + 5) to your existing objects on boot before running parse_object(), write a shell script to do it for you, or manually edit your object files.