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 ➜ ROM ➜ Running the server ➜ Adding New Weapon Types

Adding New Weapon Types

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


Posted by Intrepid   (5 posts)  Bio
Date Wed 21 Mar 2012 08:45 PM (UTC)
Message
I'm running QuickMUD (ROM 2.4b6+OLC+Color, basically) and I'm having trouble adding a new type of weapon. If you don't define a weapon (in the area file) with one of the standard types (sword, dagger, etc) it is classed exotic.

So, I did a "grep -n polearm *" and added a new entry to every case and struct I could find. When i was done, "grep -n firearm *" returned identical entries except the line numbers were understandably a few different. I also incremented the MAXSKILL to 151 from 150 in merc.h.

I thought this would work, but I get:

gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/act_comm.o act_comm.c
gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/act_enter.o act_enter.c
gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/act_info.o act_info.c
gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/act_move.o act_move.c
gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/act_obj.o act_obj.c
gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/act_wiz.o act_wiz.c
act_wiz.c: In function âdo_ostatâ:
act_wiz.c:1377: error: âWEAPON_FIREARMâ undeclared (first use in this function)
act_wiz.c:1377: error: (Each undeclared identifier is reported only once
act_wiz.c:1377: error: for each function it appears in.)
make: *** [obj/act_wiz.o] Error 1


I don't know where I've messed the declaration. If I comment it out (which would make ostat call it unknown instead of firearms) I get:


gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/act_wiz.o act_wiz.c
gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/alias.o alias.c
gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/ban.o ban.c
gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/bit.o bit.c
gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/board.o board.c
gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/comm.o comm.c
gcc -O -g3 -Wall -DIMC -DIMCROM -c -o obj/const.o const.c
const.c:85: error: âWEAPON_FIREARMâ undeclared here (not in a function)
const.c:1588: warning: implicit declaration of function âslotâ
const.c:1588: error: initializer element is not constant
const.c:1588: error: (near initialization for âskill_table[103].slotâ)
const.c:1589: error: expected expression before â:â token
const.c:1589: warning: missing braces around initializer
const.c:1589: warning: (near initialization for âskill_table[104]â)
const.c:1589: error: initializer element is not constant
const.c:1589: error: (near initialization for âskill_table[104].nameâ)
make: *** [obj/const.o] Error 1


Feedback or a guide would be really appreciated.
Top

Posted by Intrepid   (5 posts)  Bio
Date Reply #1 on Wed 21 Mar 2012 09:15 PM (UTC)
Message
I found a few things I was missing due to the case sensitivity of grep, namely defining the weapon class in merc.h.

I'll continue to comment as I either figure it out, go bald from madness, or receive comments. Next one up indicates an issue with excess elements in tables.c.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #2 on Wed 21 Mar 2012 09:16 PM (UTC)
Message
Can you paste the diffs showing what changes you made?

- Nick Gammon

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

Posted by Intrepid   (5 posts)  Bio
Date Reply #3 on Wed 21 Mar 2012 09:18 PM (UTC)

Amended on Wed 21 Mar 2012 09:19 PM (UTC) by Intrepid

Message
Used a ) instead of a }. It now compiles. I need to test it out.

Sure Nick. Let me make sure it works and then I'll be glad to post them.
Top

Posted by Intrepid   (5 posts)  Bio
Date Reply #4 on Wed 21 Mar 2012 09:42 PM (UTC)
Message
My line number is next to the .h or .c file. This will change a little from the standard if there are multiple edits, but its close enough to follow along. Including previous portion of code for searching/matching purposes.


act_wiz.c:1374
                case (WEAPON_POLEARM):
                    send_to_char ("polearm\n\r", ch);
                    break;
                case (WEAPON_FIREARM):
                    send_to_char ("firearm\n\r", ch);
                    break;



const.c:84
    {"polearm", OBJ_VNUM_SCHOOL_POLEARM, WEAPON_POLEARM, &gsn_polearm},
    {"firearm", OBJ_VNUM_SCHOOL_FIREARM, WEAPON_FIREARM, &gsn_firearm},


You'll have to assign it to something in your const.c file or no one can actually use the skill. I put mine in warrior (which I now call soldier) basics.

const.c:1579
    {
     "polearm", {1, 1, 1, 1}, {6, 6, 3, 1},
     spell_null, TAR_IGNORE, POS_FIGHTING,
     &gsn_polearm, SLOT (0), 0, 0,
     "", "!Polearm!", ""},

    {
     "firearm", {20, 20, 1, 1}, {6, 6, 2, 1},
     spell_null, TAR_IGNORE, POS_FIGHTING,
     &gsn_firearm, SLOT (0), 0, 0,
     "shot", "!Firearm!", ""},



db.c:135
sh_int gsn_whip;
sh_int gsn_firearm;



handler.c:430
                 || sn == gsn_polearm
                 || sn == gsn_firearm)

handler.c:487
            case (WEAPON_POLEARM):
                sn = gsn_polearm;
                break;
            case (WEAPON_FIREARM):
                sn = gsn_firearm;



magic.c:3453
                case (WEAPON_POLEARM):
                    send_to_char ("polearm.\n\r", ch);
                    break;
                case (WEAPON_FIREARM):
                    send_to_char ("firearm.\n\r", ch);
                    break;


The definition on 1176 was what I was missing. It doesn't know to look for that element in the table if you don't define it here.

merc.h:139
#define MAX_SKILL          151 /* Unsure if needed. It should be. */

merc.h:1053
#define OBJ_VNUM_SCHOOL_POLEARM    3722
#define OBJ_VNUM_SCHOOL_FIREARM    2500

merc.h:1176
#define WEAPON_POLEARM  8
#define WEAPON_FIREARM  9

merc.h:2047
extern sh_int  gsn_whip;
extern sh_int  gsn_firearm;



tables.c:619
    {"polearm", WEAPON_POLEARM, TRUE},
    {"firearm", WEAPON_FIREARM, TRUE},
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.


17,686 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.