Adding New Weapon Types

Posted by Intrepid on Wed 21 Mar 2012 08:45 PM — 5 posts, 22,681 views.

#0
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.
#1
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.
Australia Forum Administrator #2
Can you paste the diffs showing what changes you made?
#3
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.
Amended on Wed 21 Mar 2012 09:19 PM by Intrepid
#4
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},