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
➜ new command help
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Frobozz
(75 posts) Bio
|
| Date
| Tue 23 Nov 2004 09:00 PM (UTC) |
| Message
| I am trying to create a command, like glance in a way, that shows just the current state of the victim (target). This is the code that I have so far (again on smaug fuss):
void do_xa( CHAR_DATA *ch, char *argument )
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
char *msg;
int diff;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "&wxa <&Cvictim&w>\n\r", ch );
return;
}
if ( ( victim = get_char_room( ch, arg ) ) == NULL )
{
send_to_char( "They do not seem to be here.\n\r", ch );
return;
}
percent = (( victim->hit) / victim->max_hit));
if ( percent = 100 ) msg = "&w$N(is in &Gperfect health&w)";
else if ( percent >= 90 ) msg = "&w$N(is &gslightly scratched&w)";
else if ( percent >= 80 ) msg = "&w$N(has a &Yfew bruises&w)";
else if ( percent >= 70 ) msg = "&w$N(has &Osome cuts&w)";
else if ( percent >= 60 ) msg = "&w$N(has &Rseveral wounds&w)";
else if ( percent >= 50 ) msg = "&w$N(has &Rnasty wounds&w)";
else if ( percent >= 40 ) msg = "&w$N(is &rbleeding freely&w)";
else if ( percent >= 30 ) msg = "&w$N(is &rcovered in blood&w)";
else if ( percent >= 20 ) msg = "&w$N(is &pleaking guts&w)";
else if ( percent >= 10 ) msg = "&w$N(is &palmost dead!)";
else msg = "&w$N(is &zDYING!)";
act( AT_XA, msg, ch, NULL, victim, TO_CHAR );
return;
}
do_xa has been declared in mud.h and tables.c, but these are the errors that I have sent back to me upon compile:
make -s smaug
Compiling o/act_info.o....
act_info.c: In function `do_xa':
act_info.c:3091: parse error before `one_argument'
act_info.c:3086: parm types given both in parmlist and separately
act_info.c: At top level:
act_info.c:3099: parse error before `if'
cc1: warnings being treated as errors
act_info.c:3105: warning: type defaults to `int' in declaration of `percent'
act_info.c:3105: `victim' undeclared here (not in a function)
act_info.c:3105: `victim' undeclared here (not in a function)
act_info.c:3105: parse error before `)'
act_info.c:3118: parse error before `('
make[1]: *** [o/act_info.o] Error 1
make: *** [all] Error 2
As always your help is greatly appreciated.
-Frobozz | | Top |
|
| Posted by
| Frobozz
(75 posts) Bio
|
| Date
| Reply #1 on Tue 23 Nov 2004 09:06 PM (UTC) |
| Message
| I take that back, the command is:
void do_xa( CHAR_DATA *ch, char *argument )
char arg[MAX_INPUT_LENGTH];
CHAR_DATA *victim;
char *msg;
int diff;
one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "&wxa <&Cvictim&w>\n\r", ch );
return;
}
if ( ( victim = get_char_room( ch, arg ) ) == NULL )
{
send_to_char( "They do not seem to be here.\n\r", ch );
return;
}
percent = (100 * victim->hit) / victim->max_hit;
if ( percent = 100 ) msg = "&w$N(is in &Gperfect health&w)";
else if ( percent >= 90 ) msg = "&w$N(is &gslightly scratched&w)";
else if ( percent >= 80 ) msg = "&w$N(has a &Yfew bruises&w)";
else if ( percent >= 70 ) msg = "&w$N(has &Osome cuts&w)";
else if ( percent >= 60 ) msg = "&w$N(has &Rseveral wounds&w)";
else if ( percent >= 50 ) msg = "&w$N(has &Rnasty wounds&w)";
else if ( percent >= 40 ) msg = "&w$N(is &rbleeding freely&w)";
else if ( percent >= 30 ) msg = "&w$N(is &rcovered in blood&w)";
else if ( percent >= 20 ) msg = "&w$N(is &pleaking guts&w)";
else if ( percent >= 10 ) msg = "&w$N(is &palmost dead!)";
else msg = "&w$N(is &zDYING!)";
act( AT_XA, msg, ch, NULL, victim, TO_CHAR );
return;
}
My math was bad. But errors are still the same. | | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #2 on Tue 23 Nov 2004 09:23 PM (UTC) |
| Message
| void do_xa( CHAR_DATA *ch, char *argument )
char arg[MAX_INPUT_LENGTH];
...
You don't actually open up the first curly bracket. :-) |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Frobozz
(75 posts) Bio
|
| Date
| Reply #3 on Tue 23 Nov 2004 11:29 PM (UTC) |
| Message
| Thanks you have been a huge help so far, Im slowly moving from absolute total newbie to... slightly above total newbie. The new error is:
make -s smaug
Compiling o/act_comm.o....
Compiling o/act_info.o....
act_info.c: In function `do_xa':
act_info.c:3105: `percent' undeclared (first use in this function)
act_info.c:3105: (Each undeclared identifier is reported only once
act_info.c:3105: for each function it appears in.)
act_info.c:3119: `AT_XA' undeclared (first use in this function)
cc1: warnings being treated as errors
act_info.c:3089: warning: unused variable `diff'
make[1]: *** [o/act_info.o] Error 1
make: *** [all] Error 2
[frobozz@bb7 src]$
| | Top |
|
| Posted by
| Frobozz
(75 posts) Bio
|
| Date
| Reply #4 on Tue 23 Nov 2004 11:32 PM (UTC) |
| Message
| Ok, I slipped back to absolute newbie status and found the above errors and got rid of them. I have this now:
make -s smaug
Compiling o/act_info.o....
cc1: warnings being treated as errors
act_info.c: In function `do_xa':
act_info.c:3108: warning: suggest parentheses around assignment used as truth value
make[1]: *** [o/act_info.o] Error 1 | | Top |
|
| Posted by
| Frobozz
(75 posts) Bio
|
| Date
| Reply #5 on Tue 23 Nov 2004 11:35 PM (UTC) |
| Message
| if ( percent >= 100 ) msg = "&w$N(is in &Gperfect health&w)";
I added the > rather than just having this:
if ( percent = 100 ) msg = "&w$N(is in &Gperfect health&w)";
Is there a better way to go?
Again thanks to all for the massive support so far. It's good to be back I guess! | | Top |
|
| Posted by
| David Haley
USA (3,881 posts) Bio
|
| Date
| Reply #6 on Wed 24 Nov 2004 12:15 AM (UTC) |
| Message
|
Quote: act_info.c:3108: warning: suggest parentheses around assignment used as truth value This warning is actually trying to be your friend but is pointing out a different mistake. What it's saying is that in cases like this:
if ( (foo = 1) == 1 ) {
/* do something */
}
The parentheses around foo = 1 make it quite clear that you're doing the assignment of 1 to foo, and then comparing the result of that assignment (which is the value of 'foo') to 1.
Indeed, if you look at your code here:
if ( percent = 100 ) msg = "&w$N(is in &Gperfect health&w)";
- you'll note that you have only a single equal, so you are assigning 100 to percent - and not what you probably meant, which was to see if percent equals 100, in which case you need ==, not =. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | | Top |
|
| Posted by
| Frobozz
(75 posts) Bio
|
| Date
| Reply #7 on Wed 24 Nov 2004 12:43 AM (UTC) |
| Message
| Indeed, thank you very much!
Two more questions from this and Im done with this forum I swear! And I'll post the finish code for anyone that wants to use it.
1- How do I set this command to default to your opponent in combat?
---> I've looked at other skills like do_cast and it really doesnt seem to make a lot of sense to me.
2- How do I set this command to switch between different people of the same race.. the way look does with objects?
---> so xa soldier and xa soldier 2 would return the health of soldier 1 and the health of soldier 2.. so on and so on.
Thanks! | | 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.
21,879 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top