Welcome to the Builder Academy

Question Spy skill

More
29 Apr 2013 21:09 #2025 by JTP
Replied by JTP on topic Spy skill
I did the same and get same compile error

Please Log in or Create an account to join the conversation.

More
29 Apr 2013 22:24 #2026 by Kewlb
Replied by Kewlb on topic Spy skill
You need to actually define that ACMD in some header file, which it does not look like you did. I am sure the actual ACMD function went in some act.whatever.c file so in act.h define the ACMD(do_spy);

Please Log in or Create an account to join the conversation.

More
30 Apr 2013 13:13 - 30 Apr 2013 13:39 #2030 by JTP
Replied by JTP on topic Spy skill
after adding it to act.h i got alot of errors when compiling:

gcc -g -O2 -Wall -Wno-char-subscripts -c -o act.other.o act.other.c
act.other.c: In function ‘do_spy’:
act.other.c:1040:4: advarsel: implicit declaration of function ‘number’
act.other.c:1042:4: advarsel: passing argument 2 of ‘search_block’ from incompatible pointer type
interpreter.h:25:5: bemærk: expected ‘const char **’ but argument is of type ‘char **’
act.other.c:1059:23: fejl: ‘buf’ undeclared (first use in this function)
act.other.c:1059:23: bemærk: each undeclared identifier is reported only once for each function it appears in
act.other.c:1060:15: advarsel: passing argument 2 of ‘send_to_char’ from incompatible pointer type
comm.h:22:8: bemærk: expected ‘const char *’ but argument is of type ‘struct char_data *’
<builtin>: recipe for target `act.other.o' failed
make[1]: *** [act.other.o] Error 1
Makefile:30: recipe for target `all' failed
make: *** [all] Error 2


Makefile:30: recipe for target `all' failed
make: *** [all] Error 2
Last edit: 30 Apr 2013 13:39 by JTP.

Please Log in or Create an account to join the conversation.

More
30 Apr 2013 14:35 #2031 by JTP
Replied by JTP on topic Spy skill
interpreter.h:25
int search_block(char *arg, const char **list, int exact);


comm.h:22
size_t send_to_char(struct char_data *ch, const char *messg, ...) __attribute__
((format (printf, 2, 3)));

Please Log in or Create an account to join the conversation.

More
30 Apr 2013 16:14 #2032 by Kewlb
Replied by Kewlb on topic Spy skill
Please learn basic C syntax before you jump into trying to program a MUD. I am not trying to be harsh, but you obviously have no real idea of what you are doing. These little issues you are running into and posting to these forums are all 100% basic syntax related. If you don't know how to swim would you go jump into the water? No, you wouldn't.. the same should be said about this. Else you are just going to frustrate yourself and the forum by constantly posting extremely easy-to-fix problems because you can't be bothered to take the time to actually study and learn about what you are trying to do.

www.cprogramming.com/tutorial.html#ctutorial

Please Log in or Create an account to join the conversation.

More
30 Apr 2013 20:36 #2033 by Papaya Pete
Replied by Papaya Pete on topic Spy skill
I knew I was forgetting something like that! It's been a while since I did anything, so I forgot. :/

Anyways, managed to look through it and get the warnings and errors out of it. Also added the diagonal directions, and it all works well. Note: if you're going to spy northeast, you have to type out "northeast" not "ne". Check it out.
Code:
ACMD(do_spy) { int percent, prob, return_room; char spy_type; const char *spy_dirs[] = { "north", "east", "south", "west", "up", "down", "northwest", /* Diagonals only used if CONFIG_DIAGONAL_DIRS is set */ "northeast", "southeast", "southwest", "\n" }; /* 101% is a complete failure */ percent = rand_number(1, 101); prob = GET_SKILL(ch, SKILL_SPY); spy_type = search_block(argument + 1, spy_dirs, FALSE); if (spy_type < 0 || !EXIT(ch, spy_type) || EXIT(ch, spy_type)->to_room == NOWHERE) { send_to_char(ch, "Spy where?\r\n"); return; } else { if (!(GET_MOVE(ch) >= 5)) { send_to_char(ch, "You don't have enough movement points.\r\n"); } else { if (percent > prob) { send_to_char(ch, "You suck! You need more practice!!\r\n"); GET_MOVE(ch) = MAX(0, MIN(GET_MAX_MOVE(ch), GET_MOVE(ch) - 2)); } else { if (IS_SET(EXIT(ch, spy_type)->exit_info, EX_CLOSED) && EXIT(ch, spy_type)->keyword) { send_to_char(ch, "The %s is closed.\r\n", fname(EXIT(ch, spy_type)->keyword)); GET_MOVE(ch) = MAX(0, MIN(GET_MAX_MOVE(ch), GET_MOVE(ch) - 2)); } else { GET_MOVE(ch) = MAX(0, MIN(GET_MAX_MOVE(ch), GET_MOVE(ch) - 5)); return_room = ch->in_room; char_from_room(ch); char_to_room(ch, world[return_room].dir_option[spy_type]->to_room); send_to_char(ch, "You spy into the next room and see: \r\n\r\n"); look_at_room(ch, 1); char_from_room(ch); char_to_room(ch, return_room); act("$n peeks into the next room.", TRUE, ch, 0, 0, TO_NOTVICT); } } } } }

Please Log in or Create an account to join the conversation.

Time to create page: 0.288 seconds