Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Death cry range

Death cry range

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Malgor   United Kingdom  (2 posts)  Bio
Date Tue 01 Jan 2002 08:19 PM (UTC)
Message
I am trying to extend the range of the death_cry, so that it can be heard 2 rooms away (rather than just one) - but being a complete C newbie is hindering my progress :)

I have tried everything I can think of with this routine, but I just get a nice crash when something dies.

Any ideas on how to make this work (example code appreciated :)

Thanx
Top

Posted by Kris   USA  (198 posts)  Bio
Date Reply #1 on Mon 07 Jan 2002 07:32 AM (UTC)
Message
I think this could be achieved without much problem. I don't know much about C either, but after modifying the src for almsot a year now, I pretty much have a nack for it (and when I'm stuck, I can always run to good-ol Nick here).

I assume that death_cry (I haven't payed much attention to that) is whatever the mob screams out when it dies. That is done as an echo to the room. If you want it to echo 2 rooms away, you'll have to have it first use the code from do_exits to see what the exits for the room are, and what vnums they correspond to. Then, for each of those exits, you'd have to see what exits are from each of those rooms, and the corresponding vnums. Then, you'd have it echo to each of those rooms. This is just a general concept; I will now look at the source (since I'm bored), and see what exactly would need to be done to accomplish this. Please keep in mind that somebody could probably do this a lot more efficiently, and my method may cause a millisecond or three more lag than someone else's method might, but this should still work ok (you'll have to test it and let me know).

....

Well after reading your post again I realize that death_cry does in fact already echo to the surrounding rooms, and you'd like it to be 2 rooms away instead of one (I noticed this when reviewing the code). That'll make this easier than I initially thought :)....

In fight.c, in function death_cry, you'll notice the lines:

was_in_room = ch->in_room;
for ( pexit = was_in_room->first_exit; pexit; pexit = pexit->next )
{
if ( pexit->to_room
&& pexit->to_room != was_in_room )
{
ch->in_room = pexit->to_room;
act( AT_CARNAGE, msg, ch, NULL, NULL, TO_ROOM );
}
}
ch->in_room = was_in_room;

The first line sets was_in_room to the vnum of the room you're currently in (so it essentially remembers the room you're in). Then, it temporarily puts the mob into each of the surrounding rooms, echoes the msg to each of the rooms, then puts the mob back into its original room, where it can finish dying. So, to have it do this 2 rooms away instead of just one, you'd just copy this code, paste it inside the inner-most ifcheck (where the mob is currently in each surrounding room), and change the variables of course. This will make it so the mob then does the same thing to each of the surrounding rooms for each surrounding room. So, in effect, the death_cry is being displayed 2 rooms away.

Here's what you need to do to the code. First, add these 2 variable definitions to the top of the function where the other variables are defined:

ROOM_INDEX_DATA *was_in_room2;
EXIT_DATA *pexit2;

Then, replace the big block of code I mentioned earlier with this:

was_in_room = ch->in_room;
for ( pexit = was_in_room->first_exit; pexit; pexit = pexit->next )
{
if ( pexit->to_room
&& pexit->to_room != was_in_room )
{
ch->in_room = pexit->to_room;
act( AT_CARNAGE, msg, ch, NULL, NULL, TO_ROOM );

was_in_room2 = ch->in_room;
for ( pexit2 = was_in_room2->first_exit; pexit2; pexit2 = pexit2->next )
{
if ( pexi2t->to_room
&& pexit2->to_room != was_in_room2 )
{
ch->in_room = pexit2->to_room;
act( AT_CARNAGE, msg, ch, NULL, NULL, TO_ROOM );
}
}
}
}
ch->in_room = was_in_room;

I'm sure you can see what I'm doing here. This -should- work, however I haven't tested it on my mud (since my source code is a tangled mess with my almost-finished pskills system). So if you have any problems, please reply to this post. Otherwise, please feel free to visit my website (www.aethia.org) and/or email me at: kris@aethia.org.

I hope this helps :)
Top

Posted by Malgor   United Kingdom  (2 posts)  Bio
Date Reply #2 on Mon 07 Jan 2002 03:23 PM (UTC)
Message
Kris, you are a god :)

I had tried something very similar to this already, but it just killed the mud when something died - I shall study your code closely to see why yours doesn't.

I will have to make one or two tweeks to this code (to avoid a 'death cry nearby' msg being sent to the room the dead mob is in, and to avoid it being sent to some rooms twice), but this code is a damn good start - thanks Kris.

-Malgor
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


14,100 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.