Welcome to the Builder Academy

Question New command - Please help

More
14 Jul 2025 21:30 - 14 Jul 2025 21:33 #10803 by thomas
Replied by thomas on topic New command - Please help
Code:
zone_rnum quest_zone(qst_rnum quest) {   zone_rnum i;   if  (quest == NOTHING) {     return NOWHERE;   }   for (i = 0; i  < top_of_zone_table;  i++) {     if (QST_NUM(quest) >= zone_table[i].bot && QST_NUM(quest) <= zone_table[i].top) {       return i;     }   }   return NOWHERE; } ACMD(do_stat_world) {   int loaded_mobs = 0,   unique_mobs = 0,   loaded_objs = 0,   unique_objs = 0,   accessible_rooms = 0,   current_players = 0,   total_players = top_of_p_table + 1,   accessible_zones = 0,   accessible_quests = 0;   int mob_counts[top_of_mobt], obj_counts[top_of_objt];   int i;   room_rnum tmp = NOWHERE;   char_data *vict = NULL;   obj_data *obj = NULL;   struct descriptor_data *desc = NULL;   for (i = 0; i < top_of_mobt; i++) {     mob_counts[i] = 0;   }   for (i = 0; i < top_of_objt; i++) {     obj_counts[i] = 0;   }   for (vict = character_list; vict; vict = vict->next) {     if (IS_NPC(vict)       && GET_MOB_RNUM(vict) != NOTHING       && GET_ROOM_ZONE(IN_ROOM(vict)) != NOWHERE       && !ZONE_FLAGGED(GET_ROOM_ZONE(IN_ROOM(vict)), ZONE_CLOSED)) {       mob_counts[GET_MOB_RNUM(vict)]++;     }   }   for (obj = object_list; obj; obj = obj->next) {     if (GET_OBJ_RNUM(obj) == NOTHING) {       continue;     }     tmp = obj_room(obj);     if (GET_ROOM_ZONE(tmp) != NOWHERE       && !ZONE_FLAGGED(GET_ROOM_ZONE(tmp), ZONE_CLOSED)) {       obj_counts[GET_OBJ_RNUM(obj)]++;     }   }   for (i = 0; i < top_of_mobt; i++) {     if (mob_counts[i] != 0) {       unique_mobs++;       loaded_mobs += mob_counts[i];     }   }   for (i = 0; i < top_of_objt; i++) {     if (obj_counts[i] != 0) {       unique_objs++;       loaded_objs += obj_counts[i];     }   }   for (i = 0; i < top_of_world; i++) {     if (!ZONE_FLAGGED(GET_ROOM_ZONE(i), ZONE_CLOSED)) {       accessible_rooms++;     }   }   for (desc = descriptor_list; desc; desc = desc->next) {     if (desc->character && CAN_SEE(ch, desc->character)) {       current_players++;     }   }   for (i = 0; i < top_of_zone_table; i++) {     if (!ZONE_FLAGGED(i, ZONE_CLOSED)) {       accessible_zones++;     }   }   for (i = 0; i < total_quests; i++) {     tmp = quest_zone(i);     if (tmp != NOWHERE && !ZONE_FLAGGED(tmp, ZONE_CLOSED)) {       accessible_quests++;     }   }   send_to_char(ch,     "Mobiles: %5d (of %5d different types)\r\n"     "Objects: %5d (of %5d different types)\r\n"     "Rooms  : %5d\r\n"     "Zones  : %5d\r\n"     "Quests : %5d\r\n"     "Players: %5d online, %5d registered",     loaded_mobs, unique_mobs,     loaded_objs, unique_objs,     accessible_rooms,     accessible_zones,     accessible_quests,     current_players, total_players   ); }
A prototype then need to be put in the corresponding .h-file and the interpreter.c command list.
Last edit: 14 Jul 2025 21:33 by thomas.

Please Log in or Create an account to join the conversation.

More
23 Jul 2025 19:34 - 23 Jul 2025 19:54 #10820 by JTP
Replied by JTP on topic New command - Please help
Hi Thomas

Did I have to type this in as well:
Code:

zone_rnum quest_zone(qst_rnum quest) {   
zone_rnum i;   
if  (quest == NOTHING) {     
return NOWHERE;   
}   for (i = 0; i  < top_of_zone_table;  i++) {     if (QST_NUM(quest) >= zone_table.bot && QST_NUM(quest) <= zone_table.top) {       
return i;   
  }   
}  
return NOWHERE;
}



I just tried entering the code and I get these errors:

quest.c: In function ‘do_worldinfo’:
quest.c:827: error: ‘char_data’ undeclared (first use in this function)
quest.c:827: error: (Each undeclared identifier is reported only once
quest.c:827: error: for each function it appears in.)
quest.c:827: error: ‘vict’ undeclared (first use in this function)
quest.c:828: error: ‘obj_data’ undeclared (first use in this function)
quest.c:828: error: ‘obj’ undeclared (first use in this function)
quest.c:851: warning: implicit declaration of function ‘obj_room’
Last edit: 23 Jul 2025 19:54 by JTP.

Please Log in or Create an account to join the conversation.

More
23 Jul 2025 21:42 #10822 by wlessard1
Replied by wlessard1 on topic New command - Please help
I just have one question.

Don't need the code just if it can be done.

Would there be a way to have a command that lists the load rooms without going through the Checkload or maybe an addition to checkload

Just list all the rooms and say something like "These rooms have load commands" Yeah should be a better phrasing but just an idea.

I always forget all the rooms I loaded things and I have to go back and check every room.

Please Log in or Create an account to join the conversation.

More
24 Jul 2025 11:16 - 24 Jul 2025 11:20 #10823 by thomas
Replied by thomas on topic New command - Please help

I just tried entering the code and I get these errors:

quest.c: In function ‘do_worldinfo’:
quest.c:827: error: ‘char_data’ undeclared (first use in this function)
quest.c:827: error: (Each undeclared identifier is reported only once
quest.c:827: error: for each function it appears in.)
quest.c:827: error: ‘vict’ undeclared (first use in this function)
quest.c:828: error: ‘obj_data’ undeclared (first use in this function)
quest.c:828: error: ‘obj’ undeclared (first use in this function)
quest.c:851: warning: implicit declaration of function ‘obj_room’

Add 
Code:
#include "dg_scripts.h"
to the top of the file, along with the other imports.
Last edit: 24 Jul 2025 11:20 by thomas.

Please Log in or Create an account to join the conversation.

More
24 Jul 2025 11:18 #10824 by thomas
Replied by thomas on topic New command - Please help

wlessard1 wrote: I just have one question.

Don't need the code just if it can be done.

Would there be a way to have a command that lists the load rooms without going through the Checkload or maybe an addition to checkload

Just list all the rooms and say something like "These rooms have load commands" Yeah should be a better phrasing but just an idea.

I always forget all the rooms I loaded things and I have to go back and check every room.

Sure, the zone_table has the values you're looking for. In practice, you'd loop ovre the zone table, check if you're in the zone you're looking for, loop over the commands and filter out any "load to room" commands. Then, it's just a question of listing them to the user.

Please Log in or Create an account to join the conversation.

More
24 Jul 2025 11:38 #10825 by JTP
Replied by JTP on topic New command - Please help
Did I have to type this in as well ? Or was it just to find somewhere to put in the code ? Because I didn’t have anything like it.
Code:

zone_rnum quest_zone(qst_rnum quest) {   
zone_rnum i;   
if  (quest == NOTHING) {     
return NOWHERE;   
}   for (i = 0; i  < top_of_zone_table;  i++) {     if (QST_NUM(quest) >= zone_table.bot && QST_NUM(quest) <= zone_table.top) {       
return i;   
  }   
}  
return NOWHERE;
}

Please Log in or Create an account to join the conversation.

Time to create page: 0.263 seconds