[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Death cry range

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Death cry range
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Malgor   United Kingdom  (2 posts)  [Biography] bio
Date Mon 07 Jan 2002 03:23 PM (UTC)  quote  ]
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
[Go to top] top

Posted by Kris   USA  (198 posts)  [Biography] bio
Date Mon 07 Jan 2002 07:32 AM (UTC)  quote  ]
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 :)

--Kris
[Go to top] top

Posted by Malgor   United Kingdom  (2 posts)  [Biography] bio
Date Tue 01 Jan 2002 08:19 PM (UTC)  quote  ]
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
[Go to top] 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.


2,616 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]