19 Aug, 2013, Camtire wrote in the 1st comment:
Votes: 0
Greetings everyone. I am a very new coder who started a ROM 2.4 mud with OLC to practice and improve on my coding skills. Using the resources available on this great site I have learned how to do a good number of things I'd never figure out on my own. There is something I would like to do, however, that I have not learned how to do yet. I would greatly appreciate it if people might be willing to help me or at least give me an idea on where to look for information on doing this.

I wish to improve the functionality of the holylight immortal command in these three ways:

A. Autoexit would show all exits to immortals with holylight on, even if closed/locked.
Ex:
[Exits: North East South (Down) (West)] <- Down and west are closed exits.

B. Look would show mob and object vnums in the room with holylight on, similar to the way it does with room names.
Ex:
The Temple Square [Room 3005]
You are standing …

[Exits: North East South West Up]
A small white fountain gushes forth. [3135]
A cityguard stands here. [3060]

C. Lastly, inventory would show vnums to an immortal with holylight on.
Ex:
You are carrying:
a map of the city of Midgaard [3162]

I apologize for such a huge request on my first post, and again if you don't wish to tell me directly how to do it, some clues would be appreciated.

Thank you,
Camtire
19 Aug, 2013, plamzi wrote in the 2nd comment:
Votes: 0
I don't use ROM specifically, so any code I share may throw you off more than help.

What I did back when I was learning this stuff was to look for places in the code where it's already doing something like what I wanted to add. So, for A, find a place like the "open" or "unlock" commands to see how your code determines the state of an exit.

For B and C, I would first check if you don't already have a separate immo flag you can set to see VNUMs. If not, again, find the places where a VNUM is shown (e. g. OLC code) and learn from them.

Over time, you'll get better and better at reading code, to a point where you'll realize that the best (and the only guaranteed) documentation you're likely to get in this pursuit is the code itself.
19 Aug, 2013, Omega wrote in the 3rd comment:
Votes: 0
Camtire said:
Greetings everyone. I am a very new coder who started a ROM 2.4 mud with OLC to practice and improve on my coding skills. Using the resources available on this great site I have learned how to do a good number of things I'd never figure out on my own. There is something I would like to do, however, that I have not learned how to do yet. I would greatly appreciate it if people might be willing to help me or at least give me an idea on where to look for information on doing this.

I wish to improve the functionality of the holylight immortal command in these three ways:

A. Autoexit would show all exits to immortals with holylight on, even if closed/locked.
Ex:
[Exits: North East South (Down) (West)] <- Down and west are closed exits.

B. Look would show mob and object vnums in the room with holylight on, similar to the way it does with room names.
Ex:
The Temple Square [Room 3005]
You are standing …

[Exits: North East South West Up]
A small white fountain gushes forth. [3135]
A cityguard stands here. [3060]

C. Lastly, inventory would show vnums to an immortal with holylight on.
Ex:
You are carrying:
a map of the city of Midgaard [3162]

I apologize for such a huge request on my first post, and again if you don't wish to tell me directly how to do it, some clues would be appreciated.

Thank you,
Camtire


For objects, you need to modify show_list_to_char, for npc's you need to look at show_char_to_char, perhaps show_char_to_char_0 as well.

It ultimately depends.

But editing those functions to put in a modified string to add vnums wouldn't be too difficult. Just read the code, and make an educated guess.


Ex. in show_char_to_char_0, add:


if(IS_NPC(victim) && !IS_NPC(ch) && IS_SET(ch->act, PLR_HOLYLIGHT)) {
char dbuf[1024] = {'\0'};
snprintf(dbuf, 1024, "[%d]", victim->pIndexData->vnum);
strcat(buf, dbuf);
}


right before this:
strcat( buf, "\n\r" );    
buf[0] = UPPER(buf[0]);
send_to_char( buf, ch );


And that will display NPC's vnums beside them when you look around. This same principle can be applied to objects in show_list_to_char.

As for exits, just take a look at 'do_exits' and apply the same principle shown above.

Tada!
20 Aug, 2013, quixadhal wrote in the 4th comment:
Votes: 0
Except, it should be "\r\n", if you're expecting TELNET (and clients which claim to support TELNET) to work properly.
20 Aug, 2013, donky wrote in the 5th comment:
Votes: 0
quixadhal said:
Except, it should be "\r\n", if you're expecting TELNET (and clients which claim to support TELNET) to work properly.
I'm surprised there aren't enough badly implemented muds that the onus these days isn't on the clients to handle the worst case scenarios including bad line endings.
20 Aug, 2013, Camtire wrote in the 6th comment:
Votes: 0
I thank you all so very much for the tips and the example code as well. I will work on it today and let you know how it goes. I appreciate the kindness from the folks in this forum :) This is an excellent learning experience.

Camtire
20 Aug, 2013, Camtire wrote in the 7th comment:
Votes: 0
The code as it was written was giving me errors, but with some minor changes and looking at other functions as suggested, I was able to get it working by placing this in two spots:

if (!IS_NPC(ch) && IS_SET(ch->act, PLR_HOLYLIGHT)) {  
char buf[MAX_STRING_LENGTH];
sprintf( buf, "[%d] ", victim->pIndexData->vnum);
send_to_char( buf, ch );


From what I understand, it handles the long description, and if the mob is out of it's normal position separately. By putting it in twice it shows it both ways.
20 Aug, 2013, Omega wrote in the 8th comment:
Votes: 0
You might want to check to see if the victim is a NPC or else you will crash as PC's do not have pIndexData…
22 Aug, 2013, Camtire wrote in the 9th comment:
Votes: 0
Thank you, Darien. I forgot that part, but I added it and it works now. Today I played with getting objects to show their vnums too. This was my solution:

if (!IS_NPC(ch) && IS_SET(ch->act, PLR_HOLYLIGHT))
{
if (fShort)
{
if(obj->short_descr !=NULL)
sprintf (buf, "[%5d] ", obj->pIndexData->vnum);
}
else
{
if (obj->description != NULL)
sprintf (buf, "[%5d] ", obj->pIndexData->vnum);
}
}

Right before:
if ( IS_OBJ_STAT(obj, ITEM_INVIS)     )   strcat( buf, "(Invis) "     );

under format_obj_to_char
23 Aug, 2013, Camtire wrote in the 10th comment:
Votes: 0
While I am sure a more experienced coder could do this in a matter of minutes, I have finally managed to finish my code and do what I set out to do at the beginning of this topic. My method is probably not the best, but if anybody wants to do the same as I did, I'll post it here. Thank you to everyone who helped me, and if you see any fault or possible improvement in the following, please let me know.

All three of these take place in act_info.c.

In "show_char_to_char_0", right above "if (IS_SET(victim->comm,COMM_AFK))strcat(buf,"[AFK]");" put:
/* S: Holylight: Vnum on Mobs */
if (!IS_NPC(ch) && IS_SET(ch->act, PLR_HOLYLIGHT))
{
char buf[MAX_STRING_LENGTH];
sprintf( buf, "[%5d] ", IS_NPC(victim) ? victim->pIndexData->vnum : 0);
send_to_char( buf, ch );
}
/* E: Holylight: Vnum on Mobs */

In "format_obj_to_char", right above "if(IS_OBJ_STAT(obj,ITEM_INVIS))strcat(buf,"(Invis)");" put:
/* S: Holylight: Vnum on Objects */
if (!IS_NPC(ch) && IS_SET(ch->act, PLR_HOLYLIGHT))
{
if (fShort)
{
if(obj->short_descr !=NULL)
sprintf (buf, "[%5d] ", obj->pIndexData->vnum);
}
else
{
if (obj->description != NULL)
sprintf (buf, "[%5d] ", obj->pIndexData->vnum);
}
}
/* E: Holylight: Vnum on Objects */

Exits was a bit harder for me, I ended up copying and modifying existing exit code. At the end of "for(door=0;door<= 9; door++)" are three closing brackets in a row. This goes before the third one:
/* S: Holylight: Show Closed and Locked Exits */
if ( ( pexit = ch->in_room->exit[door] ) != NULL
&& pexit->u1.to_room != NULL
&& can_see_room(ch,pexit->u1.to_room)
&& IS_SET(pexit->exit_info, EX_CLOSED)
&& !IS_NPC(ch)
&& IS_SET(ch->act, PLR_HOLYLIGHT))
{
found = TRUE;
if ( fAuto )
{
strcat( buf, " (" );
strcat( buf, dir_name[door] );
if IS_SET(pexit->exit_info, EX_LOCKED)
{strcat (buf, "*");}
strcat( buf, ")" );
}
else
{
sprintf( buf + strlen(buf), "(%-5s - %s)",
capitalize( dir_name[door] ),
room_is_dark( pexit->u1.to_room )
? "Too dark to tell"
: pexit->u1.to_room->name
);
if (IS_IMMORTAL(ch))
sprintf(buf + strlen(buf),
" [Room %d]\n\r",pexit->u1.to_room->vnum);
else
sprintf(buf + strlen(buf), "\n\r");
}
}
/* E: Holylight: Show Closed and Locked Exits */
23 Aug, 2013, Camtire wrote in the 11th comment:
Votes: 0
In the end, your rooms will look like this to immortals with holylight on:

—–
The Center of Market Square [Room 9506]
Room text blah blah blah.
Words and words and words.
More text and whanot.

[Exits: north east (south) (west*)]
[ 9601] A large fountain is here gurgling out an endless stream of water.
[ 9537] A small man walks around scribbling in a notebook.
——

South would be a closed door, and west is a closed and locked door. Typing exits will put ( ) around closed exits as well. Eventually I'd like to make typing exits also display the key vnum for a locked door.
0.0/11