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 ➜ fMatch

fMatch

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


Posted by GregS   (15 posts)  Bio
Date Wed 31 Aug 2005 12:14 AM (UTC)
Message
I was recently attempting to add an extra field (attack_bonus) to player files. I edited mud.h, comm.c, db.c, and save.c

The code compiles, and even writes to the player file correctly. However, I keep getting these errors when the player logs on:

[*****] BUG: Fread_char: no match: 10
[*****] BUG: Fread_char: no match: lass

It has something to do with there being no fMatch ( !fMatch evaluates as TRUE ). I guess it doesn't match something. Just trying to understand exactly what fMatch is and how I can fix the bugs. Thanks

~greg
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Wed 31 Aug 2005 12:36 AM (UTC)
Message
Could you post an example player file? Not the whole thing, just the line in question and about 3 above and below.

And have you added code that reads the new data? That should be in fread_char, if I remember correctly... It's possible that it's complaining at you because it's not understanding data from the file.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by GregS   (15 posts)  Bio
Date Reply #2 on Wed 31 Aug 2005 12:50 AM (UTC)

Amended on Wed 31 Aug 2005 12:52 AM (UTC) by GregS

Message
Just so you know, what I'm trying to do is convert SMAUG's combat system to pseudo D&D 3rd edition rules. Not a simple task so far ;) Ok here is the player file and other files I edited:
--------

Hitroll 0
Damroll 0
Armor 100
Armor Class 10 <---- Line in question
Mentalstate -31
Password ®„(tµÓ9=@kÍö‡AÚ~
Title the Supreme Entity~
WizInvis 65

-------
from save.c - the void_fread_char function (the value is an integer not a string maybe that's a problem; i used fread_number though and so do other things)

KEY( "Armor", ch->armor,fread_number( fp ) );
KEY( "Armor Class", ch->armor_class, fread_number( fp ));

Exactly what does the KEY macro do?

-------
from db.c the clear_char function

ch->armor_class = 10; /* GREG COMPILES AND RUNS */
ch->attack_bonus = 0;

-------
from comm.c after CON_READ_MOTD

ch->saving_spell_staff = race_table[ch->race]->saving_spell_staff;

ch->height = number_range(race_table[ch->race]->height *.9, race_table[ch->race]->height *1.1);

ch->weight = number_range(race_table[ch->race]->weight *.9, race_table[ch->race]->weight *1.1);

ch->armor_class = 10;
ch->attack_bonus = 0;

--------
from mud.h class_type

sh_int exp_base; /* Class base exp*/
sh_int armor_class;
sh_int attack_bonus;

and under mob_index_data & char_data added these
sh_int attack_bonus; /*GREG*/
sh_int armor_class; /*GREG*/


--- Any help, opinions, or comments are appreciated.

Thanks
Greg








Top

Posted by GregS   (15 posts)  Bio
Date Reply #3 on Wed 31 Aug 2005 12:56 AM (UTC)
Message
What I really want to do is have an array or something for each class that lists the relevant attack bonuses for each level.
I guess I would need a function to check the class of the character then the level of the character and finally compare that to a table with the bonuses.

Example, a barbarian class is like this:
Level Attack Bonus
Level 1 +1
Level 2 +2
Level 3 +3
Level 4 +4
Level 5 +5

While a wizard would look like
Level Attack Bonus
Level 1 +0
Level 2 +1
Level 3 +1
Level 4 +2
Level 5 +2

Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #4 on Wed 31 Aug 2005 01:34 AM (UTC)
Message
You're not allowed to have multiword keys in your pfiles. All keys have to be a single word, i.e. no spaces allowed. That should solve your problem.

KEY is a macro that looks at the word just read and compares it to the first parameter of the macro; if it matches, it does whatever is in the second part of the macro. If you think of the file as a sequence of key-value pairs, where the first word of a line is the key and the rest is the value, it should make sense.

That being said, isn't armor class something that is computed from player's race, class, level, dex, armor, etc.? Why are you storing it like this? Or is this a 'base armor class' of sorts?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by GregS   (15 posts)  Bio
Date Reply #5 on Wed 31 Aug 2005 01:48 AM (UTC)
Message
Yes, the attack bonus should be computed based on the character's class, their strength bonus, and a size modifier.

I'm fairly new to coding C (i've done some java programming) and really just trying some stuff out to get a hold of how everything works.

Another question:

Here is the strength table from the const.c file

const struct str_app_type str_app [26] =
{
{ -5, -4, 0, 0 }, /* 0 */
{ -5, -4, 3, 1 }, /* 1 */
{ -3, -2, 3, 2 },
{ -3, -1, 10, 3 }, /* 3 */
{ -2, -1, 25, 4 },
{ -2, -1, 55, 5 }, /* 5 */
{ -1, 0, 80, 6 },
{ -1, 0, 90, 7 },
{ 0, 0, 100, 8 },
{ 0, 0, 100, 9 },
{ 0, 0, 115, 10 }, /* 10 */
{ 0, 0, 115, 11 },
{ 0, 0, 140, 12 },
{ 0, 0, 140, 13 }, /* 13 */
{ 0, 1, 170, 14 },
{ 1, 1, 170, 15 }, /* 15 */
{ 1, 2, 195, 16 },
{ 2, 3, 220, 22 },
{ 2, 4, 250, 25 }, /* 18 */
{ 3, 5, 400, 30 },
{ 3, 6, 500, 35 }, /* 20 */
{ 4, 7, 600, 40 },
{ 5, 7, 700, 45 },
{ 6, 8, 800, 50 },
{ 8, 10, 900, 55 },
{ 10, 12, 999, 60 } /* 25 */
};

Ok. I assume that this is a table of the different things your strength score modifies: (tohit, carry capacity, etc)
How would I go about adding and extra field to this struct? Does anyone know what each field represents? I believe the third field is the carrying capacity.

Can someone break this line of code down for me:
const struct str_app_type str_app [26] =


Greg
Top

Posted by GregS   (15 posts)  Bio
Date Reply #6 on Wed 31 Aug 2005 03:44 AM (UTC)

Amended on Wed 31 Aug 2005 03:47 AM (UTC) by GregS

Message
Ok after doing a little grepping, it looks like str_app_type is defined in mud.h as a struct containing the variables tohit, todam, carry, and wield.

Can each slot in an array have more than one value?

Or is the object (for lack of a better word) "const struct str_app_type str_app [26] =" in const.c just an array of 26 "struct str_app_type" structs which define (tohit, damroll, etc) in mud.h?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #7 on Wed 31 Aug 2005 05:55 AM (UTC)
Message
Quote:
Or is the object (for lack of a better word) "const struct str_app_type str_app [26] =" in const.c just an array of 26 "struct str_app_type" structs which define (tohit, damroll, etc) in mud.h?
Yes, that is an array of 26 structures, where each structure has all that stuff it says in mud.h. It's a little incorrect to think of it as an object, however, because arrays in C do not behave like arrays in Java. In fact, C really doesn't have much of an 'object' concept. OOP is possible in C, of course, but you have to implement all the facilities yourself.

A structure in C is like a class in Java, where every member is public and methods are impossible. (C++ adds methods to structures, but everything remains public. Basically, C++ structs are all-public classes.)

Quote:
const struct str_app_type str_app [26]

This means:
- const: make the following constant, e.g. you cannot edit the values
- struct str_app_type: whatever we're about to define is of type 'struct str_app_type'. (This is a bit of C syntax that I don't like at all. I don't see why you have to repeat the 'struct'. C++ allows you to drop the 'struct'.)
- str_app: the name of the variable we're defining
- [26]: the variable is in fact an array of size 26

Everything after the =, i.e., the { {1,2,3,4}, ... } is shorthand for initialization. It's kind of confusing, actually, if you're not used to it. Like in Java, you can initialize arrays with { ... }. However, you can also initialize structures like that, where you give the value for each member in the same order as defined in the structure definition, in this case in mud.h.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by GregS   (15 posts)  Bio
Date Reply #8 on Wed 31 Aug 2005 01:39 PM (UTC)
Message
Thanks for the help Ksilyan.

~Greg
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.


24,654 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.