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 ➜ Compiling the server ➜ Fighting System

Fighting System

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


Pages: 1 2  3  

Posted by Rok   (41 posts)  Bio
Date Mon 25 Jun 2001 04:42 PM (UTC)

Amended on Mon 25 Jun 2001 04:44 PM (UTC) by Rok

Message
Hello,I'm new to the lands of compiling my own server. I've been a MUD player for many years now and want something to call my own. I found SMAUG to be an awesome program, but I wanted to change one thing. But that one thing probably isn't going to be so easy. I want to make it so a character doesn't attack on it's own. I want to be able to control it the whole way. Like if I didn't want to attack I could just let a monster beat on me for a while. I've fiddled around with the code(In C++). But I'm having troubles locating the fighting system, and I think once I did I wouldn't know what to do anyway. Any help would be AWESOME! Thanks.

The always thankful
~ROK~
(~Hey you~)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Mon 25 Jun 2001 10:31 PM (UTC)
Message
I would look in fight.c, starting at the function "violence_update".

This is a major change, of course. When you fight in SMAUG it goes into "fight mode" where the fight is regulated by the server.

You would probably take out the bit where it sets the flag:

ch->fighting

Then if the character does (say) a kick, then you would do, once, whatever that normally does in the fight loop.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rok   (41 posts)  Bio
Date Reply #2 on Fri 29 Jun 2001 08:57 PM (UTC)
Message
OK, I've worked out quite a bit of the quirks with the new fighting system, I still have a way to go but I figured while I was at it I would try to work this out, and see if you could offer any advice. I want to be able to see how much damage my character is doing. Instead of saying " ... you mauled the rat..." or whatnot, I want to have it say something along the lines of "You did 14 damage to the rat!" and so fourth... Any Ideas on how to put that into action?

The always thankful
~ROK~
(~Hey you~)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #3 on Sat 30 Jun 2001 05:46 AM (UTC)
Message
In fight.c there is a function "new_dam_message" that converts damage from numbers into words. Just rewrite that to keep the numbers.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rok   (41 posts)  Bio
Date Reply #4 on Sat 30 Jun 2001 07:36 PM (UTC)
Message
Rock on, Thanks for all the help Nick!

The always thankful
~ROK~
(~Hey you~)
Top

Posted by Rok   (41 posts)  Bio
Date Reply #5 on Sun 01 Jul 2001 08:58 PM (UTC)
Message
Hmm.... Ok, now I'm confused. For the New_Dam_message, I changed what I thought I needed to but it didn't work, now I have an error and I'm not real sure what I did.. Any clue?

Here is the Error message I get:
error C2371: 'new_dam_message' : redefinition; different basic types

This is what my code looks like now:
void new_dam_message( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt, OBJ_DATA *obj )
{
char buf1[256], buf2[256], buf3[256];
char bugbuf[MAX_STRING_LENGTH];
const char *vs;
const char *vp;
const char *attack;
char punct;
sh_int dampc;
struct skill_type *skill = NULL;
bool gcflag = FALSE;
bool gvflag = FALSE;
int d_index, w_index;
ROOM_INDEX_DATA *was_in_room;

if ( ! dam )
dampc = 0;
else
dampc = ( (dam * 1000) / victim->max_hit) +
( 50 - ((victim->hit * 50) / victim->max_hit) );

if ( ch->in_room != victim->in_room )
{
was_in_room = ch->in_room;
char_from_room(ch);
char_to_room(ch, victim->in_room);
}
else
was_in_room = NULL;

/* Get the weapon index */
if ( dt > 0 && dt < top_sn )
{
w_index = 0;
}
else
if ( dt >= TYPE_HIT && dt < TYPE_HIT + sizeof(attack_table)/sizeof(attack_table[0]) )
{
w_index = dt - TYPE_HIT;
}
else
{
sprintf(bugbuf, "Dam_message: bad dt %d from %s in %d.",
dt, ch->name, ch->in_room->vnum );
bug( bugbuf, 0);
dt = TYPE_HIT;
w_index = 0;
}

/* get the damage index */
if(dam == 0)
d_index = 0;
else if(dampc < 0)
d_index = 1;
else if(dampc <= 100)
d_index = 1 + dampc/10;
else if(dampc <= 200)
d_index = 11 + (dampc - 100)/20;
else if(dampc <= 900)
d_index = 16 + (dampc - 200)/100;
else
d_index = 23;

/* Lookup the damage message */
vs = s_message_table[w_index][d_index];
vp = p_message_table[w_index][d_index];

punct = (dampc <= 30) ? '.' : '!';

if ( dam == 0 && (!IS_NPC(ch) &&
(IS_SET(ch->pcdata->flags, PCFLAG_GAG)))) gcflag = TRUE;

if ( dam == 0 && (!IS_NPC(victim) &&
(IS_SET(victim->pcdata->flags, PCFLAG_GAG)))) gvflag = TRUE;

if ( dt >=0 && dt < top_sn )
skill = skill_table[dt];
if ( dt == TYPE_HIT )
{
sprintf( buf1, "$n %s $N%c", vp, punct );
sprintf( buf2, "You %s $N%c", vs, punct );
sprintf( buf3, "$n %s you%c", vp, punct );
}
else
if ( dt > TYPE_HIT && is_wielding_poisoned( ch ) )
{
if ( dt < TYPE_HIT + sizeof(attack_table)/sizeof(attack_table[0]) )
attack = attack_table[dt - TYPE_HIT];
else
{
sprintf(bugbuf, "Dam_message: bad dt %d from %s in %d.",
dt, ch->name, ch->in_room->vnum );
bug( bugbuf, 0);
dt = TYPE_HIT;
attack = attack_table[0];
}

sprintf( buf1, "$n's poisoned %s %s $N%c", attack, vp, punct );
sprintf( buf2, "Your poisoned %s %s $N%c", attack, vp, punct );
sprintf( buf3, "$n's poisoned %s %s you%c", attack, vp, punct );
}
else
{
if ( skill )
{
attack = skill->noun_damage;
if ( dam == 0 )
{
bool found = FALSE;

if ( skill->miss_char && skill->miss_char[0] != '\0' )
{
act( AT_HIT, skill->miss_char, ch, NULL, victim, TO_CHAR );
found = TRUE;
}
if ( skill->miss_vict && skill->miss_vict[0] != '\0' )
{
act( AT_HITME, skill->miss_vict, ch, NULL, victim, TO_VICT );
found = TRUE;
}
if ( skill->miss_room && skill->miss_room[0] != '\0' )
{
if (strcmp( skill->miss_room,"supress" ) )
act( AT_ACTION, skill->miss_room, ch, NULL, victim, TO_NOTVICT );
found = TRUE;
}

The always thankful
~ROK~
(~Hey you~)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #6 on Mon 02 Jul 2001 12:22 AM (UTC)
Message
The error message suggests you have defined "new_dam_message" twice. Did you get rid of the earlier one? You don't have two of them in the same source file do you?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rok   (41 posts)  Bio
Date Reply #7 on Tue 24 Jul 2001 07:08 AM (UTC)

Amended on Tue 24 Jul 2001 07:10 AM (UTC) by Rok

Message
Ok, I have not been doing good in either of the things I have been trying to acomplish. I just think I do not have enough knowledge of the C++ language to re-work the fighting system just yet. However I think I can do the damage roll thing. Under new_dam_message what should I do?(To get it so that only numbers come up) I tried a few things... and most everything I could think of short of just deleting the whole thing.... I'm stuck and I don't know what to do. Any help would be much appritiated!



Oh... by the way, you're really smart! how did you learn all of this coding for Smaug??? I find it difficult changing just key things without having to re-write the whole freakin' thing!

The always thankful
~ROK~
(~Hey you~)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #8 on Tue 24 Jul 2001 11:32 AM (UTC)
Message
There are a couple of places I would change in fight.c in function new_dam_message. The original code is commented out, my replacement code precedes it.




sprintf( buf1, "$n inflicts %i damage on $N%c", dam, punct );
sprintf( buf2, "You inflict %i damage on $N%c", dam, punct );
sprintf( buf3, "$n inflicts %i damage on you%c", dam, punct );
// sprintf( buf1, "$n %s $N%c", vp, punct );
// sprintf( buf2, "You %s $N%c", vs, punct );
// sprintf( buf3, "$n %s you%c", vp, punct );

// ..... and later on .......


sprintf( buf1, "$n inflicts %i damage on $N%c", dam, punct );
sprintf( buf2, "You inflict %i damage on $N%c", dam, punct );
sprintf( buf3, "$n inflicts %i damage on you%c", dam, punct );
// sprintf( buf1, "$n's %s %s $N%c", attack, vp, punct );
// sprintf( buf2, "Your %s %s $N%c", attack, vp, punct );
// sprintf( buf3, "$n's %s %s you%c", attack, vp, punct );



- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rok   (41 posts)  Bio
Date Reply #9 on Mon 20 Aug 2001 07:41 AM (UTC)
Message
Thanks for all the help dude! I've been on vacation thus didn't get your messages any earlyer. Thanks for all the help on this mud. I should be getting back into the programming kick here in a few. I'll use that code deffinitly thanks! I was also looking at my other things quest and I was wondering.... well I'll ask in the catagory.

The always thankful
~ROK~
(~Hey you~)
Top

Posted by Rok   (41 posts)  Bio
Date Reply #10 on Thu 23 Aug 2001 05:04 AM (UTC)

Amended on Thu 23 Aug 2001 05:08 AM (UTC) by Rok

Message
Awesome, thanks for all the help. I used the base of your code and just changed it a little. I also added in a little thing because I like it to say I miss when I miss, so any one else who wants to do it here is the code that I came up with , well mostly nick ;)

if ( dt == TYPE_HIT && dam == 0 ) //miss message ~Rok~

sprintf(buf1, "$n misses $N badly!", vp, punct );
sprintf(buf2, "You miss $N badly!", vs, punct );
sprintf(buf3, "$n misses $N badly!", vp, punct);
}
else if ( dt == TYPE_HIT ) //damage number & text
sprintf(buf1, "$n %s $N for %i damage%c", vp, dam, punct );
sprintf(buf2, "You %s $N for %i damage%c", vs, dam, punct );
sprintf(buf3, "$n %s $N for %i damage%c", vp, dam, punct );
}

Then Later on

sprintf( buf1, "$n %s $N for %i damage%c", vp, dam, punct );
sprintf( buf2, "You %s $N for %i damage%c", vp, dam,punct );
sprintf( buf3, "$n %s $N for %i damage%c", vp, dam, punct );

Oh, I had a question on top of that, it doesn't have to do with the fighting system but I don't know where to post it. I was thinking it would be really nice if there was a program that could search through all the player files and find the ones that havn't been modifide for like I don't know like a month and a half or something then automatticly puts a flag on them so you can delete them later, or know that it hasn't been used. Do you know of any programs like that?

The always thankful
~ROK~
(~Hey you~)
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #11 on Thu 23 Aug 2001 08:34 AM (UTC)
Message
Well, you could just use the Windows "find" utility to search for files in the player directory whose date modified was less than a certain date.

Another approach is to use the "grub" command in SMAUG. Here is an example from the help file:


grub 20 level=2 last<=970120 Display 20 L2 players absent since 970120


For grub to work you need to build a grub file, or whatever it is called. There is a program called "grux" that does that. This reads every player file and builds a database that the grub command then searches.

I must admit I can't find the grux program in the current source. If you want it I'll take a lengthier look.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Rok   (41 posts)  Bio
Date Reply #12 on Fri 24 Aug 2001 07:14 AM (UTC)
Message
All right, thanks again nick!

The always thankful
~ROK~
(~Hey you~)
Top

Posted by Rok   (41 posts)  Bio
Date Reply #13 on Mon 27 Aug 2001 07:37 PM (UTC)

Amended on Mon 27 Aug 2001 08:28 PM (UTC) by Rok

Message
Alright, here is what is happening now. I want to be able to see what attack I'm using when it happens... instead of it saying "You **smites** the gas dragon for 15 damage" or whatever it may be, I want it to say "Your <Weapon name> <damage text> <Creature> for <#> damage"

Here is what I put
sprintf(buf2, "Your %s %s $N for %i damage%c", vs, dam, punct );


*************************EDIT*************************

Nevermind I got it working just fine now ~ Thanks anyhow!

The always thankful
~ROK~
(~Hey you~)
Top

Posted by Rok   (41 posts)  Bio
Date Reply #14 on Sun 09 Sep 2001 06:00 PM (UTC)

Amended on Sun 09 Sep 2001 06:05 PM (UTC) by Rok

Message
Ok, Well I thought I was done with this but apparently not. Now the miss damage doesn't work again and I'm not sure why, I have tried several things and I am probably missing some mundane detail because that is just what I do. Here is what I have now:



**********************************************************

if ( dt == TYPE_HIT && dam == 0) // Miss damage message ~Rok~
{ //
sprintf(buf1, "$n's %s misses $N badly!", attack ); // This is in hope of a miss
sprintf(buf2, "Your %s misses $N badly!", attack ); // message not showing the
sprintf(buf3, "$n's %s misses you badly!", attack ); // 0 pts of damage ~Rok~
} //
else if ( dt == TYPE_HIT && dam >=1) //
{

sprintf(buf1, "$n's %s %s $N for %i damage%c", attack, vp, dam, punct ); //We Want the Number Damage Message ~Rok~

sprintf(buf2, "Your %s %s $N for %i damage%c", attack, vs, dam, punct ); //We Want the Number Damage Message ~Rok~

sprintf(buf3, "$n's %s %s you for %i damage%c",attack, vp, dam, punct ); //We Want the Number Damage Message ~Rok~
}



***************************THEN LATER ON***************************

sprintf( buf1, "$n's %s %s $N for %i damage%c", attack, vp, dam, punct ); //We Want the Damage Message ~Rok~

sprintf( buf2, "Your %s %s $N for %i damage%c", attack, vp, dam, punct ); //We Want the Damage Message ~Rok~
sprintf( buf3, "$n's %s %s you for %i damage%c", attack, vp, dam, punct ); //We Want the Damage Message ~Rok~

The always thankful
~ROK~
(~Hey you~)
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.


81,102 views.

This is page 1, subject is 3 pages long: 1 2  3  [Next page]

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.