archery

Posted by Ithildin on Sat 06 Dec 2003 07:45 AM — 11 posts, 36,520 views.

USA #0
i took archery.c from samson's snippet page. i put it all in and did every intricate detail i could. then i compiled and came up with:




archery.c(491) : error C2065: 'PROJ_STONE' : undeclared identifier
archery.c(661) : error C2065: 'gsn_archery' : undeclared identifier
archery.c(662) : error C2065: 'gsn_blowguns' : undeclared identifier
archery.c(663) : error C2065: 'gsn_slings' : undeclared identifier
archery.c(1191) : error C2065: 'PROJ_BOLT' : undeclared identifier
archery.c(1191) : error C2051: case expression not constant
archery.c(1192) : error C2065: 'PROJ_ARROW' : undeclared identifier
archery.c(1192) : error C2051: case expression not constant
archery.c(1193) : error C2065: 'PROJ_DART' : undeclared identifier
archery.c(1193) : error C2051: case expression not constant
archery.c(1194) : error C2051: case expression not constant
Error executing cl.exe.


how would i go about declaring those things?

thanks for help
USA #1
Looks like you forgot to add a bunch of constants/variables to mud.h or something.
USA #2
what i did was put int PROJ_STONE and so on at the top of the function. and now all i have is

if( bow->value[5] != arrow->value[4] )
    {
	char *msg = "You have nothing to fire...\n\r";

      switch( bow->value[5] )
      {
        case PROJ_BOLT:	 msg = "You have no bolts...\n\r";	break;
        case PROJ_ARROW: msg = "You have no arrows...\n\r";	break;
        case PROJ_DART:	 msg = "You have no darts...\n\r";	break;
        case PROJ_STONE: msg = "You have no slingstones...\n\r";	break;
      }
	send_to_char( msg, ch );
	return;
    }


here is the error message:

archery.c(1191) : error C2051: case expression not constant
archery.c(1192) : error C2051: case expression not constant
archery.c(1193) : error C2051: case expression not constant
archery.c(1194) : error C2051: case expression not constant


how do i make those constant
Amended on Sat 06 Dec 2003 08:05 AM by Ithildin
USA #3
ok, i'm lookin and i think i need a default but i don't know what to put default or if i even need one. here's the whole function.

[code]

void do_fire( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim = NULL;
OBJ_DATA *arrow;
OBJ_DATA *bow;
sh_int max_dist;
int PROJ_STONE;
int PROJ_BOLT;
int PROJ_ARROW;
int PROJ_DART;


if( ( bow = get_eq_char( ch, WEAR_MISSILE_WIELD ) ) == NULL )
{
send_to_char( "But you are not wielding a missile weapon!!\n\r", ch );
return;
}

one_argument( argument, arg );
if ( arg[0] == '\0' && ch->fighting == NULL )
{
send_to_char( "Fire at whom or what?\n\r", ch );
return;
}

if( !str_cmp( arg, "none" ) || !str_cmp( arg, "self" ) || victim == ch )
{
send_to_char( "How exactly did you plan on firing at yourself?\n\r", ch );
return;
}

if( ( arrow = get_eq_char( ch, WEAR_HOLD ) ) == NULL )
{
send_to_char( "You are not holding a projectile!\n\r", ch );
return;
}

if( arrow->item_type != ITEM_PROJECTILE )
{
send_to_char( "You are not holding a projectile!\n\r", ch );
return;
}

/* modify maximum distance based on bow-type and ch's class/str/etc */
max_dist = URANGE( 1, bow->value[4], 10 );

if( bow->value[5] != arrow->value[4] )
{
char *msg = "You have nothing to fire...\n\r";

switch( bow->value[5] )
{

case PROJ_BOLT: msg = "You have no bolts...\n\r"; break;
case PROJ_ARROW: msg = "You have no arrows...\n\r"; break;
case PROJ_DART: msg = "You have no darts...\n\r"; break;
case PROJ_STONE: msg = "You have no slingstones...\n\r"; break;
}
send_to_char( msg, ch );
return;
}

/* Add wait state to fire for pkill, etc... */
WAIT_STATE( ch, 6 );

/* handle the ranged attack */
ranged_attack( ch, argument, bow, arrow, TYPE_HIT + arrow->value[3], max_dist );

return;
}

[/code]

thanks for any help on this. i'm goin to bed. heh, i've been workin too long on this.
Amended on Sat 06 Dec 2003 08:33 AM by Ithildin
USA #4
No, those shouldn't be ints, those should be constants of the form:
#define PROJ_STONE ???
where the ??? is the right number. I'd be a little surprised if those aren't in the snippet package somewhere... and they'd usually go into mud.h.
USA #5
they weren't in the snippet. i looked like 5-6 times.

so i put #define PROJ_STONE 1 in mud.h

what number would i put at the end?

also, for the gsn_archery errors, i did the same thing

int gsn_archery;
int gsn_blowguns;
int gsn_slings;

so i'm guessin those aren't right either. would i define those as well?
USA #6
I'd try getting in touch with Samson to ask him about the defines... you probably don't want to put in random numbers there.

For the gsns, there should be a whole pile of:
extern int gsn_something_or_other;
in mud.h, and then in db.c those gsns are assigned the skill numbers from skill name lookups. Didn't the snippet ask you to do that too? Hmm... sounds like an incomplete snippet... :P
USA #7
hehe, yea it might be. thanks for all your help. i'll go look at it all and check out what i can find.

thanks so much. be back in a few...i hope
USA #8
As was mentioned on our forums, the archery code requires the weapon profficiency patch to work. If that's not installed, then you'll get errors and the like, much like these.
#9
Hmmm. I put in the weapon proficiency code, compiled, and checked it out. Worked great too.
But when I put in the archery code I get the same errors as above. I have since gone back through and checked both the weapon proficiency instructions and files, and now the archery ones, and I have followed them to a t.
Maybe I am misreading an instruction somehow? The archery system sounds very cool. I'm going back to see if maybe the copy of either archery snippet or weapon prof snippet was updated/changed. Maybe I have an older version of one or the other. Anybody have a clue? How did you make out with it, Ithildin?
Gadush
#10
Forget it, it was me. I somehow put the old files back into src before making clean and compiling. Doh! Apologies all. I went through each file and fixed it up, and it is working now.
Thanks,
Gadush