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 Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #15 on Sun 09 Sep 2001 10:43 PM (UTC)
Message
I'm not sure what you are doing with the // symbol in various places.

In C (C++ really) you use // for a single-line comment. That is, it comments from // to the end of the line.

Thus, something like this won't do much:


{ //
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~
} //


The // on the first line is just a blank comment.

Perhaps what you want is a multi-line comment, like this:


{
/* ----- The next few lines are commented out -----
sprintf(buf1, "$n's %s misses $N badly!", attack );
sprintf(buf2, "Your %s misses $N badly!", attack );
sprintf(buf3, "$n's %s misses you badly!", attack );
*/
}


- Nick Gammon

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

Posted by Rok   (41 posts)  Bio
Date Reply #16 on Mon 10 Sep 2001 08:12 PM (UTC)
Message
Yeah I put the // there so that I can know where it is that I changed stuff because many times I do stuff that doesn't work That is why I put the // so if something messes up I know what how to fix it. But that won't change the miss message from working or not working.... I'm just not sure.

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

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #17 on Tue 11 Sep 2001 12:45 AM (UTC)
Message
Ah yes, I see.

Now to solve the problem, can you specify in what way it isn't working? Can you paste in a log of what you see, and explain what you expected to see?

- Nick Gammon

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

Posted by Rok   (41 posts)  Bio
Date Reply #18 on Wed 12 Sep 2001 02:46 AM (UTC)

Amended on Wed 12 Sep 2001 02:47 AM (UTC) by Rok

Message
Here is what it currently says:


<3441hp 310bp 3088mv>
Your slash _cleaves_ Gas Dragon for 201 damage!
You parry Gas Dragon's attack.
You parry Gas Dragon's attack.
You parry Gas Dragon's attack.
You parry Gas Dragon's attack.
You parry Gas Dragon's attack.
You parry Gas Dragon's attack.

<3441hp 310bp 3087mv>
kick
Your kick misses Gas Dragon for 0 damage.

The last thing is what I want to change to say:

"Your kick misses Gas Dragon."

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

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #19 on Thu 13 Sep 2001 12:21 AM (UTC)
Message
I would have to guess that the condition in your 'if' isn't being met, eg. it is a skill and not a hit.

I would try adding a temporary message to to display the value of relevant variables, eg. dt.

- Nick Gammon

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

Posted by Rok   (41 posts)  Bio
Date Reply #20 on Sat 15 Sep 2001 10:00 PM (UTC)

Amended on Sat 15 Sep 2001 10:05 PM (UTC) by Rok

Message
Hmm... I can't seem to get it to work at all. No matter what I do... It is like it just isn't seeing it. I know that isn't ture but I don't know what I'm doing wrong. How would you go about writing the if??? The only requirements I could think of is a TYPE_HIT and dam = 0 but that just isn't doing it.... Unless I've got a syntax error. The code is still the same as above. Any Suggestions?

Oh, I guess the cod isn't still up there here it is:
if (dt == TYPE_HIT && dam == 0)
{
sprintf(buf1, "$n's %s %s $N badly%c", attack, vp, punct );
sprintf(buf2, "Your %s %s $N badly%c", attack, vp, punct );
sprintf(buf3, "$n's %s %s you badly%c", attack, vp, punct );
}
else if ( dt == TYPE_HIT && dam >=1)
{
sprintf(buf1, "$n's %s %s $N for %i damage%c", attack, vp, dam, punct );
sprintf(buf2, "Your %s %s $N for %i damage%c", attack, vs, dam, punct );
sprintf(buf3, "$n's %s %s you for %i damage%c",attack, vp, dam, punct );

}

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

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #21 on Sun 16 Sep 2001 01:00 AM (UTC)
Message
What I mean is to do something like this. Before the code you just had, put this ...


sprintf (buf1, "dt = %i, dam = %i\n\r", dt, dam);
send_to_char (buf1, ch);


This will let you see whether dt and dam are what you expect.


- Nick Gammon

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

Posted by Rok   (41 posts)  Bio
Date Reply #22 on Thu 20 Sep 2001 07:47 PM (UTC)

Amended on Thu 04 Oct 2001 08:19 PM (UTC) by Rok

Message
Oh you are right, The dt isn't what I was expecting at all. So I got around that and I still can't understand what is wrong. The dt is in fact a number that changes... I don't know what causes it to change but something does. Any clues as to what it is?

YES! FINALLY! I got it thanks for the help guys!

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

Posted by Yourdrunkendad   (35 posts)  Bio
Date Reply #23 on Sat 09 Aug 2003 05:20 AM (UTC)
Message
If there is followup for this or anyone knows how I really appreciate a snippet to make it like Rok was trying to. ie:

"Your <Weapon name> <damage text> <Creature> for <#> damage"

Shampoo is for sissies real men use poo*
[werd]thewerd.com "Smacking Your Mom Then Running Away"
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #24 on Thu 26 Feb 2004 05:34 AM (UTC)
Message
i'm putting this into Smaug Fuss, when i put it in and recompile it in MSC++ it recompiles fine, but when i take out the .o file and make in cygwin it shows a couple warnings with too many arguments.

4 warnings in fight.c

too many arguments in format
too many arguments in format
too many arguments in format
too few arguments in format

any thoughts?

Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #25 on Thu 26 Feb 2004 06:03 AM (UTC)
Message
Yes, your printf is wrong. The gcc compiler is a bit smarter about picking that up. If you use it in MSCV++ it will either crash or give the wrong results.

You need to have the correct number of arguments. Perhaps post the line in error?

- Nick Gammon

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

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #26 on Thu 26 Feb 2004 06:06 AM (UTC)
Message
here:


sprintf( buf1, "$n misses $N badly!", vp, punct );
	sprintf( buf2, "You miss $N badly!", vs, punct );
	sprintf( buf3, "$n misses $N badly!", vp, punct);


and here:

sprintf( buf1, "$n's poisoned %s %s $N%c", attack, vp, punct );

Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #27 on Tue 02 Mar 2004 05:46 AM (UTC)
Message
i'm still getting these warnings.



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);
	}


do you need me to post anymore code? this snippet works fine on a regular smaug window vesrion, but not on smaugfuss cygwin.

Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #28 on Tue 02 Mar 2004 06:34 AM (UTC)
Message
Yeah, I do see a problem. The
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);
	}


There are varaibles there to be printed into the string, vp, vs, and punct, but nothing to indicate what or where to use this information. The original one looks like it should be:
if (dt == TYPE_HIT && dam == 0) 
{ 
sprintf(buf1, "$n's %s %s $N badly%c", attack, vp, punct ); 
sprintf(buf2, "Your %s %s $N badly%c", attack, vp, punct ); 
sprintf(buf3, "$n's %s %s you badly%c", attack, vp, punct ); 
} 
This one has %s and such in them. The $N is only for the act_string function, and is not real C variables. Looks like you may have missed a part of the snippet, double check. That should deal with the too many errors.

Hope that helps.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Ithildin   USA  (262 posts)  Bio
Date Reply #29 on Tue 02 Mar 2004 06:54 PM (UTC)
Message
i added this:

dt  = TYPE_HIT;
	    attack  = attack_table[0];
    
	if (dt == TYPE_HIT && dam == 0) 
		{ 
			sprintf(buf1, "$n's %s %s $N badly%c", attack, vp, punct ); 
			sprintf(buf2, "Your %s %s $N badly%c", attack, vp, punct ); 
			sprintf(buf3, "$n's %s %s you badly%c", attack, vp, punct ); 
		} 
	else 
	if ( dt == TYPE_HIT ) //damage number & text
	{
	sprintf( buf1, "$n %s $N%c",  vp, punct );
	sprintf( buf2, "You %s $N for %i damage%c", vs, dam, punct );
	sprintf( buf3, "$n %s you%c", vp, punct );
	}	


it doesn't have any errors. it works fine. but when i kick, it just says, you jar the guard for 6 damage!

i want it to say this:

Your kick MUTILATES the guard for 110 damage!

on my windows version, it does. but i had to change the code around on this one to get it to compile. i'll go ahead and post both codes on a second post.
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.


100,269 views.

This is page 2, subject is 3 pages long:  [Previous page]  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.