mirror of
https://github.com/tbamud/tbamud.git
synced 2025-12-20 17:20:12 +01:00
Object Events and some formatting corrections.
This commit is contained in:
parent
36f35cdf55
commit
f0d34e6cd6
5 changed files with 55 additions and 35 deletions
|
|
@ -1521,49 +1521,49 @@ ACMD(do_sac)
|
||||||
one_argument(argument, arg);
|
one_argument(argument, arg);
|
||||||
|
|
||||||
if (!*arg) {
|
if (!*arg) {
|
||||||
send_to_char(ch, "Sacrifice what?\n\r");
|
send_to_char(ch, "Sacrifice what?\n\r");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(j = get_obj_in_list_vis(ch, arg, NULL, world[IN_ROOM(ch)].contents)) && (!(j = get_obj_in_list_vis(ch, arg, NULL, ch->carrying)))) {
|
if (!(j = get_obj_in_list_vis(ch, arg, NULL, world[IN_ROOM(ch)].contents)) && (!(j = get_obj_in_list_vis(ch, arg, NULL, ch->carrying)))) {
|
||||||
send_to_char(ch, "It doesn't seem to be here.\n\r");
|
send_to_char(ch, "It doesn't seem to be here.\n\r");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CAN_WEAR(j, ITEM_WEAR_TAKE)) {
|
if (!CAN_WEAR(j, ITEM_WEAR_TAKE)) {
|
||||||
send_to_char(ch, "You can't sacrifice that!\n\r");
|
send_to_char(ch, "You can't sacrifice that!\n\r");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
act("$n sacrifices $p.", FALSE, ch, j, 0, TO_ROOM);
|
act("$n sacrifices $p.", FALSE, ch, j, 0, TO_ROOM);
|
||||||
|
|
||||||
switch (rand_number(0, 5)) {
|
switch (rand_number(0, 5)) {
|
||||||
case 0:
|
case 0:
|
||||||
send_to_char(ch, "You sacrifice %s to the Gods.\r\nYou receive one gold coin for your humility.\r\n", GET_OBJ_SHORT(j));
|
send_to_char(ch, "You sacrifice %s to the Gods.\r\nYou receive one gold coin for your humility.\r\n", GET_OBJ_SHORT(j));
|
||||||
increase_gold(ch, 1);
|
increase_gold(ch, 1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
send_to_char(ch, "You sacrifice %s to the Gods.\r\nThe Gods ignore your sacrifice.\r\n", GET_OBJ_SHORT(j));
|
send_to_char(ch, "You sacrifice %s to the Gods.\r\nThe Gods ignore your sacrifice.\r\n", GET_OBJ_SHORT(j));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
send_to_char(ch, "You sacrifice %s to the Gods.\r\nThe gods give you %d experience points.\r\n", GET_OBJ_SHORT(j), (2*GET_OBJ_COST(j)));
|
send_to_char(ch, "You sacrifice %s to the Gods.\r\nThe gods give you %d experience points.\r\n", GET_OBJ_SHORT(j), (2*GET_OBJ_COST(j)));
|
||||||
GET_EXP(ch) += (2*GET_OBJ_COST(j));
|
GET_EXP(ch) += (2*GET_OBJ_COST(j));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
send_to_char(ch, "You sacrifice %s to the Gods.\r\nYou receive %d experience points.\r\n", GET_OBJ_SHORT(j), GET_OBJ_COST(j));
|
send_to_char(ch, "You sacrifice %s to the Gods.\r\nYou receive %d experience points.\r\n", GET_OBJ_SHORT(j), GET_OBJ_COST(j));
|
||||||
GET_EXP(ch) += GET_OBJ_COST(j);
|
GET_EXP(ch) += GET_OBJ_COST(j);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
send_to_char(ch, "Your sacrifice to the Gods is rewarded with %d gold coins.\r\n", GET_OBJ_COST(j));
|
send_to_char(ch, "Your sacrifice to the Gods is rewarded with %d gold coins.\r\n", GET_OBJ_COST(j));
|
||||||
increase_gold(ch, GET_OBJ_COST(j));
|
increase_gold(ch, GET_OBJ_COST(j));
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
send_to_char(ch, "Your sacrifice to the Gods is rewarded with %d gold coins\r\n", (2*GET_OBJ_COST(j)));
|
send_to_char(ch, "Your sacrifice to the Gods is rewarded with %d gold coins\r\n", (2*GET_OBJ_COST(j)));
|
||||||
increase_gold(ch, (2*GET_OBJ_COST(j)));
|
increase_gold(ch, (2*GET_OBJ_COST(j)));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
send_to_char(ch, "You sacrifice %s to the Gods.\r\nYou receive one gold coin for your humility.\r\n", GET_OBJ_SHORT(j));
|
send_to_char(ch, "You sacrifice %s to the Gods.\r\nYou receive one gold coin for your humility.\r\n",GET_OBJ_SHORT(j));
|
||||||
increase_gold(ch, 1);
|
increase_gold(ch, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for (jj = j->contains; jj; jj = next_thing2) {
|
for (jj = j->contains; jj; jj = next_thing2) {
|
||||||
|
|
|
||||||
6
src/db.c
6
src/db.c
|
|
@ -519,6 +519,7 @@ void destroy_db(void)
|
||||||
event_cancel(pEvent);
|
event_cancel(pEvent);
|
||||||
}
|
}
|
||||||
free_list(world[cnt].events);
|
free_list(world[cnt].events);
|
||||||
|
world[cnt].events = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free any assigned scripts */
|
/* free any assigned scripts */
|
||||||
|
|
@ -2421,6 +2422,8 @@ struct obj_data *create_obj(void)
|
||||||
obj->next = object_list;
|
obj->next = object_list;
|
||||||
object_list = obj;
|
object_list = obj;
|
||||||
|
|
||||||
|
obj->events = NULL;
|
||||||
|
|
||||||
GET_ID(obj) = max_obj_id++;
|
GET_ID(obj) = max_obj_id++;
|
||||||
/* find_obj helper */
|
/* find_obj helper */
|
||||||
add_to_lookup_table(GET_ID(obj), (void *)obj);
|
add_to_lookup_table(GET_ID(obj), (void *)obj);
|
||||||
|
|
@ -2445,6 +2448,8 @@ struct obj_data *read_object(obj_vnum nr, int type) /* and obj_rnum */
|
||||||
obj->next = object_list;
|
obj->next = object_list;
|
||||||
object_list = obj;
|
object_list = obj;
|
||||||
|
|
||||||
|
obj->events = NULL;
|
||||||
|
|
||||||
obj_index[i].number++;
|
obj_index[i].number++;
|
||||||
|
|
||||||
GET_ID(obj) = max_obj_id++;
|
GET_ID(obj) = max_obj_id++;
|
||||||
|
|
@ -3233,6 +3238,7 @@ void free_char(struct char_data *ch)
|
||||||
event_cancel(pEvent);
|
event_cancel(pEvent);
|
||||||
}
|
}
|
||||||
free_list(ch->events);
|
free_list(ch->events);
|
||||||
|
ch->events = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* new version of free_followers take the followers pointer as arg */
|
/* new version of free_followers take the followers pointer as arg */
|
||||||
|
|
|
||||||
|
|
@ -176,6 +176,7 @@ int delete_room(room_rnum rnum)
|
||||||
event_cancel(pEvent);
|
event_cancel(pEvent);
|
||||||
}
|
}
|
||||||
free_list(room->events);
|
free_list(room->events);
|
||||||
|
room->events = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Change any exit going to this room to go the void. Also fix all the exits
|
/* Change any exit going to this room to go the void. Also fix all the exits
|
||||||
|
|
|
||||||
|
|
@ -816,6 +816,17 @@ void extract_obj(struct obj_data *obj)
|
||||||
if (SCRIPT(obj))
|
if (SCRIPT(obj))
|
||||||
extract_script(obj, OBJ_TRIGGER);
|
extract_script(obj, OBJ_TRIGGER);
|
||||||
|
|
||||||
|
if (obj->events != NULL) {
|
||||||
|
if (obj->events->iSize > 0) {
|
||||||
|
struct event * pEvent;
|
||||||
|
|
||||||
|
while ((pEvent = simple_list(obj->events)) != NULL)
|
||||||
|
event_cancel(pEvent);
|
||||||
|
}
|
||||||
|
free_list(obj->events);
|
||||||
|
obj->events = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (GET_OBJ_RNUM(obj) == NOTHING || obj->proto_script != obj_proto[GET_OBJ_RNUM(obj)].proto_script)
|
if (GET_OBJ_RNUM(obj) == NOTHING || obj->proto_script != obj_proto[GET_OBJ_RNUM(obj)].proto_script)
|
||||||
free_proto_script(obj, OBJ_TRIGGER);
|
free_proto_script(obj, OBJ_TRIGGER);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -732,6 +732,8 @@ struct obj_data
|
||||||
struct obj_data *next_content; /**< For 'contains' lists */
|
struct obj_data *next_content; /**< For 'contains' lists */
|
||||||
struct obj_data *next; /**< For the object list */
|
struct obj_data *next; /**< For the object list */
|
||||||
struct char_data *sitting_here; /**< For furniture, who is sitting in it */
|
struct char_data *sitting_here; /**< For furniture, who is sitting in it */
|
||||||
|
|
||||||
|
struct list_data *events; /**< Used for object events */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Instance info for an object that gets saved to disk.
|
/** Instance info for an object that gets saved to disk.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue