|
Percentage loads for objs and mobs [by Johan Dustler] |
|
|
|
Posted Wednesday, August 12th @ 11:32:56 PM, by George Greer in the Zones dept.
Added Feb 6, 1997. Click the link below to read it or download it.
From: Johan Dustler <Johan.Dustler@epk.ericsson.se>
Subject: Percentage chance for item loading
This is a patch for percentage loading. Apply the changes and
then add a number between 1 and 100 to the MOEPG lines, for
which you want percentage loading, in the zone files. The number
is the chance that the obj/mob will not load. So with a number
of 100 it is only 1% chance that the load will occur.
New format for the zone commands. (The load chance is not needed
if the obj/mob should always pop.)
M <if-flag> <mob vnum> <max existing> <room vnum> <load chance>
O <if-flag> <obj vnum> <max existing> <room vnum> <load chance>
G <if-flag> <obj vnum> <max existing> <load chance>
E <if-flag> <obj vnum> <max existing> <equipment position> <load chance>
P <if-flag> <obj vnum 1> <max existing> <obj vnum 2> <load chance>
-Johan
----------
diff -c src/db.c src2/db.c
*** src/db.c
Fri Jan 31 14:16:53 1997
--- src2/db.c
Fri Jan 31 14:22:30 1997
***************
*** 1190,1196 ****
void load_zones(FILE * fl, char *zonename)
{
static int zone = 0;
! int cmd_no = 0, num_of_cmds = 0, line_num = 0, tmp, error;
char *ptr, buf[256], zname[256];
strcpy(zname, zonename);
--- 1190,1196 ----
void load_zones(FILE * fl, char *zonename)
{
static int zone = 0;
! int cmd_no = 0, num_of_cmds = 0, line_num = 0, tmp, error, arg_num;
char *ptr, buf[256], zname[256];
strcpy(zname, zonename);
***************
*** 1244,1257 ****
break;
}
error = 0;
! if (strchr("MOEPD", ZCMD.command) == NULL) {
/* a 3-arg command */
! if (sscanf(ptr, " %d %d %d ", &tmp, &ZCMD.arg1, &ZCMD.arg2) != 3)
!
error = 1;
! } else {
if (sscanf(ptr, " %d %d %d %d ", &tmp, &ZCMD.arg1, &ZCMD.arg2,
!
&ZCMD.arg3) != 4)
!
error = 1;
}
ZCMD.if_flag = tmp;
--- 1244,1277 ----
break;
}
error = 0;
! if (strchr("D", ZCMD.command) != NULL) { /* ### */
if (sscanf(ptr, " %d %d %d %d ", &tmp, &ZCMD.arg1, &ZCMD.arg2,
! &ZCMD.arg3) != 4)
! error = 1;
}
+ else if (strchr("R", ZCMD.command) != NULL) { /* ### */
+ if (sscanf(ptr, " %d %d %d ", &tmp, &ZCMD.arg1,
+ &ZCMD.arg2) != 3)
+ error = 1;
+ }
+ else if (strchr("G", ZCMD.command) != NULL) { /* ### */
+ if ((arg_num = sscanf(ptr, " %d %d %d %d ", &tmp, &ZCMD.arg1,
+ &ZCMD.arg2, &ZCMD.arg3)) != 4) {
+ if (arg_num != 3)
+ error = 1;
+ else
+ ZCMD.arg3 = 0;
+ }
+ }
+ else { /* ### */
+ if ((arg_num = sscanf(ptr, " %d %d %d %d %d ", &tmp, &ZCMD.arg1,
+ &ZCMD.arg2, &ZCMD.arg3, &ZCMD.arg4)) != 5) {
+ if (arg_num != 4)
+ error = 1;
+ else
+ ZCMD.arg4 = 0;
+ }
+ }
ZCMD.if_flag = tmp;
***************
*** 1558,1602 ****
void reset_zone(int zone)
{
int cmd_no, last_cmd = 0;
struct char_data *mob = NULL;
struct obj_data *obj, *obj_to;
for (cmd_no = 0; ZCMD.command != 'S'; cmd_no++) {
! if (ZCMD.if_flag && !last_cmd)
continue;
switch (ZCMD.command) {
case '*':
/* ignore command */
last_cmd = 0;
break;
! case 'M':
/* read a mobile */
! if (mob_index[ZCMD.arg1].number < ZCMD.arg2) {
mob = read_mobile(ZCMD.arg1, REAL);
char_to_room(mob, ZCMD.arg3);
last_cmd = 1;
} else
last_cmd = 0;
break;
! case 'O':
/* read an object */
! if (obj_index[ZCMD.arg1].number < ZCMD.arg2) {
if (ZCMD.arg3 >= 0) {
obj = read_object(ZCMD.arg1, REAL);
obj_to_room(obj, ZCMD.arg3);
last_cmd = 1;
} else {
obj = read_object(ZCMD.arg1, REAL);
obj->in_room = NOWHERE;
last_cmd = 1;
}
} else
last_cmd = 0;
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");
--- 1578,1635 ----
void reset_zone(int zone)
{
int cmd_no, last_cmd = 0;
+ int mob_load = FALSE; /* ### */
+ int obj_load = FALSE; /* ### */
struct char_data *mob = NULL;
struct obj_data *obj, *obj_to;
for (cmd_no = 0; ZCMD.command != 'S'; cmd_no++) {
! if (ZCMD.if_flag && !last_cmd && !mob_load && !obj_load)
continue;
+ if (!ZCMD.if_flag) { /* ### */
+ mob_load = FALSE;
+ obj_load = FALSE;
+ }
+
switch (ZCMD.command) {
case '*':
/* ignore command */
last_cmd = 0;
break;
! case 'M':
/* read a mobile ### */
! if ((mob_index[ZCMD.arg1].number < ZCMD.arg2) &&
! (number(1, 100) >= ZCMD.arg4)) {
mob = read_mobile(ZCMD.arg1, REAL);
char_to_room(mob, ZCMD.arg3);
last_cmd = 1;
+ mob_load = TRUE;
} else
last_cmd = 0;
break;
! case 'O':
/* read an object ### */
! if ((obj_index[ZCMD.arg1].number < ZCMD.arg2) &&
! (number(1, 100) >= ZCMD.arg4)) {
if (ZCMD.arg3 >= 0) {
obj = read_object(ZCMD.arg1, REAL);
obj_to_room(obj, ZCMD.arg3);
last_cmd = 1;
+ obj_load = TRUE;
} else {
obj = read_object(ZCMD.arg1, REAL);
obj->in_room = NOWHERE;
last_cmd = 1;
+ obj_load = TRUE;
}
} else
last_cmd = 0;
break;
! case 'P':
/* object to object ### */
! if ((obj_index[ZCMD.arg1].number < ZCMD.arg2) &&
! obj_load && (number(1, 100) >= ZCMD.arg4)) {
obj = read_object(ZCMD.arg1, REAL);
if (!(obj_to = get_obj_num(ZCMD.arg3))) {
ZONE_ERROR("target obj not found");
***************
*** 1608,1619 ****
last_cmd = 0;
break;
! case 'G':
/* obj_to_char */
if (!mob) {
ZONE_ERROR("attempt to give obj to non-existant mob");
break;
}
! if (obj_index[ZCMD.arg1].number < ZCMD.arg2) {
obj = read_object(ZCMD.arg1, REAL);
obj_to_char(obj, mob);
last_cmd = 1;
--- 1641,1653 ----
last_cmd = 0;
break;
! case 'G':
/* obj_to_char ### */
if (!mob) {
ZONE_ERROR("attempt to give obj to non-existant mob");
break;
}
! if ((obj_index[ZCMD.arg1].number < ZCMD.arg2) &&
! mob_load && (number(1, 100) >= ZCMD.arg3)) {
obj = read_object(ZCMD.arg1, REAL);
obj_to_char(obj, mob);
last_cmd = 1;
***************
*** 1621,1632 ****
last_cmd = 0;
break;
! case 'E':
/* object to equipment list */
if (!mob) {
ZONE_ERROR("trying to equip non-existant mob");
break;
}
! if (obj_index[ZCMD.arg1].number < ZCMD.arg2) {
if (ZCMD.arg3 < 0 || ZCMD.arg3 >= NUM_WEARS) {
ZONE_ERROR("invalid equipment pos number");
} else {
--- 1655,1667 ----
last_cmd = 0;
break;
! case 'E':
/* object to equipment list ### */
if (!mob) {
ZONE_ERROR("trying to equip non-existant mob");
break;
}
! if ((obj_index[ZCMD.arg1].number < ZCMD.arg2) &&
! mob_load && (number(1, 100) >= ZCMD.arg4)) {
if (ZCMD.arg3 < 0 || ZCMD.arg3 >= NUM_WEARS) {
ZONE_ERROR("invalid equipment pos number");
} else {
Only in src: db.c.orig
diff -c src/db.h src2/db.h
*** src/db.h
Fri Jan 31 14:17:09 1997
--- src2/db.h
Fri Jan 31 10:03:16 1997
***************
*** 90,95 ****
--- 90,96 ----
bool if_flag;
/* if TRUE: exe only if preceding exe'd */
int
arg1;
/* */
int
arg2;
/* Arguments to the command */
+ int
arg3;
/* */
int arg4;
int line;
/* line number this command appears on */
<< Peace Command [by ?] | Reply | View as text | Flattened | PFile Conversion Utility [by Gekke Eekhoorn] >> |
|
Related Links |
|
|
|
CircleMUD Snippets |
|
|
Note: Not all of these snippets will work perfectly with
your version of code, so be prepared to fix one
or two bugs that may arise, and please let me know
what you needed to do to fix it. Sending a corrected
version is always welcome.
|
Finally, if you wish to use any of the snippets from this
page, you are more than welcome, just mention the
authors in your credits. If you wish to release any
of these snippets to the public on another site,
contact me FIRST.
|
|
|
|
|
|
|