Hello,
I know tons and tons and tons of people have been trying to make a DBZ mud. the only main problem they have is the whole powerlevel system. Well I received a code to use, where to place it, how to edit it to work. Well everything worked but when I compiled I got errors all over the place. I have a sample of the code if someone could possibly look at it and perhaps give me a hand.(if you need a pl code please feel free to copy paste it and use it for your own well being, I just ask that if you get it to work you explain to me what you fixed to make it work)
[in fight.c find]
if ( dam && ch != victim
in that if level put this:
if (dam > 100)
dam = 100;
if (ch->race == 0) /* Race */
xp_mod = 0.66;
else if (ch->race == 3) /* Race */
xp_mod = 0.665;
else if (ch->race == 2) /* Race */
xp_mod = 0.68;
else
xp_mod = 0.67;
if ( !IS_NPC(victim) )
xp_gain = (float) dam / 100 * powvictim->pl, xp_mod);
if ( IS_NPC(victim) )
xp_gain = (float) dam / 100 * powvictim->exp, xp_mod);
/* Sparing and deadly combat pl gain's */
if ( !IS_NPC(ch) && !IS_NPC(victim)
&& !xIS_SET(ch->act, PLR_SPAR) && !IS_SET(victim->act, PLR_SPAR))
xp_gain = (float) dam / 100 * powvictim->exp, 0.70);
if ( !IS_NPC(ch) && !IS_NPC(victim)
&& !xIS_SET(ch->act, PLR_SPAR) && !IS_SET(victim->act, PLR_SPAR))
{
xp_mod = (float) xp_mod - .01;
xp_gain = (float) dam / 100 pow(victim->exp, xp_mod);
/* PL Gains cut if player is stronger than opontants */
if ( !IS_NPC(victim)) {
if ((ch->pl / victim->pl) < 3)
xp_gain = xp_gain;
else if ((ch->pl / victim->pl) < 4)
xp_gain *= 0.7;
else if ((ch->pl / victim->pl) < 5)
xp_gain *= 0.6;
else if ((ch->pl / victim->pl) < 6)
xp_gain *= 0.5;
else if ((ch->pl / victim->pl) < 7)
xp_gain *= 0.4;
else if ((ch->pl / victim->pl) <
xp_gain *= 0.3;
else if ((ch->pl / victim->exp) < 9)
xp_gain *= 0.2;
else if ((ch->pl / victim->exp) < 10)
xp_gain *= 0.1;
else
xp_gain = 0;
}
/* PL Gains cut if player is weaker than opontants */
if (ch->exp != ch->pl && ch->exp < ch->pl)
{
int pl_exp = 0;
pl_exp = (ch->pl / ch->exp);
xp_gain = xp_gain -( (float) pl_exp * .035 * xp_gain );
}
if (ch->pl < 2500)
xp_gain += 1;
if (ch->pl < 5000)
xp_gain += 1;
if (xp_gain < 0)
xp_gain = 0;
xp_gain_post = xp_gain * ( race_table[ch->race]->exp_multiplier/100.0);
/* if (xp_gain != 1) {
sprintf( buf1, "Your power level ncreases by %s points.", num_punct(xp_gain_post) );
act( AT_HIT, buf1, ch, NULL, victim, TO_CHAR );
}
else {
sprintf( buf1, "Your power level ncreases by %s point.", num_punct(xp_gain_post) );
act( AT_HIT, buf1, ch, NULL, victim, TO_CHAR );
}
*/
gain_exp( ch, xp_gain );
everything worked until i compiled it, then got tons of errors. if supplying the errors will help then tell me and ill do so. If you can help me in anyway I would greatly, appreciate it.
As it tends to be near impossible to debug anything without the error messages, we are going to need those to be of any real help to you in fixing this. We may also need further code samples depending on the error messages.
ewwwwww
so much of that code could be cleaned up too
(race_table->expmod, doing the (ch->pl / victim->pl) once, and not every ifcheck?)
magic numbers tooo
Need some error messages
ah ok then, Ill post my errors that I get. Of the many I get I know of several that I am able to fix, but there various ones that exceed my coding ability. id like to thank you for your responses so far.
error message when compiling (every works til it gets to fight.c [where the powerlevel code is added] and then come the erros out of nowhere)
make[1]: *** Warning: File `fight.c' has modification time in the future (2004-03-01 17:18:48 > 2004-03-01 17:14:46.678293)
SMAUG1.4a R4 now compiling... o/fight.o
fight.c: In function `damage':
fight.c:2190: parse error before "if"
fight.c:2194: `xp_mod' undeclared (first use in this function)
fight.c:2194: (Each undeclared identifier is reported only once
fight.c:2194: for each function it appears in.)
fight.c:2203: `powvictim' undeclared (first use in this function)
fight.c:2203: warning: left-hand operand of comma expression has no effect
fight.c:2203: parse error before ')' token
fight.c:2209: `PLR_SPAR' undeclared (first use in this function)
fight.c:2210: warning: left-hand operand of comma expression has no effect
fight.c:2210: parse error before ')' token
fight.c:2216: parse error before "pow"
fight.c:2221: structure has no member named `pl'
fight.c:2221: structure has no member named `pl'
fight.c:2223: structure has no member named `pl'
fight.c:2223: structure has no member named `pl'
fight.c:2225: structure has no member named `pl'
fight.c:2225: structure has no member named `pl'
fight.c:2227: structure has no member named `pl'
fight.c:2227: structure has no member named `pl'
fight.c:2229: structure has no member named `pl'
fight.c:2229: structure has no member named `pl'
fight.c:2231: structure has no member named `pl'
fight.c:2231: structure has no member named `pl'
fight.c:2233: structure has no member named `pl'
fight.c:2235: structure has no member named `pl'
fight.c:2243: structure has no member named `pl'
fight.c:2243: structure has no member named `pl'
fight.c:2247: structure has no member named `pl'
fight.c:2251: structure has no member named `pl'
fight.c:2253: structure has no member named `pl'
fight.c:2259: `xp_gain_post' undeclared (first use in this function)
fight.c:2272: parse error before '!' token
fight.c:1755: warning: unused variable `buf1'
fight.c:1756: warning: unused variable `filename'
fight.c:1760: warning: unused variable `loot'
fight.c:1766: warning: unused variable `init_gold'
fight.c:1766: warning: unused variable `new_gold'
fight.c:1766: warning: unused variable `gold_diff'
fight.c: At top level:
fight.c:2283: parse error before "if"
fight.c:2306: parse error before '&' token
fight.c:2306: warning: type defaults to `int' in declaration of `affect_join'
fight.c:2306: conflicting types for `affect_join'
mud.h:4935: previous declaration of `affect_join'
fight.c:2306: warning: data definition has no type or storage class
fight.c:2307: parse error before '->' token
fight.c:2323: parse error before numeric constant
fight.c:2323: warning: type defaults to `int' in declaration of `set_char_color'
fight.c:2323: conflicting types for `set_char_color'
mud.h:4642: previous declaration of `set_char_color'
fight.c:2323: warning: data definition has no type or storage class
fight.c:2324: parse error before string constant
fight.c:2324: warning: type defaults to `int' in declaration of `send_to_char'
fight.c:2324: conflicting types for `send_to_char'
mud.h:4638: previous declaration of `send_to_char'
fight.c:2324: warning: data definition has no type or storage class
fight.c:2333: warning: type defaults to `int' in declaration of `update_pos'
fight.c:2333: warning: parameter names (without types) in function declaration
fight.c:2333: conflicting types for `update_pos'
mud.h:4762: previous declaration of `update_pos'
fight.c:2333: warning: data definition has no type or storage class
fight.c:2335: parse error before "switch"
fight.c:2340: parse error before string constant
fight.c:2347: parse error before string constant
fight.c:2356: parse error before string constant
fight.c:2373: parse error before string constant
fight.c:2373: warning: type defaults to `int' in declaration of `act'
fight.c:2373: conflicting types for `act'
mud.h:4648: previous declaration of `act'
fight.c:2373: warning: data definition has no type or storage class
fight.c:2374: parse error before string constant
fight.c:2374: warning: type defaults to `int' in declaration of `act'
fight.c:2374: warning: data definition has no type or storage class
fight.c:2435: parse error before '(' token
fight.c:2436: parse error before '(' token
fight.c:2436: warning: type defaults to `int' in declaration of `to_channel'
fight.c:2436: conflicting types for `to_channel'
mud.h:4544: previous declaration of `to_channel'
fight.c:2444: parse error before string constant
fight.c:2476: warning: type defaults to `int' in declaration of `check_killer'
fight.c:2476: warning: parameter names (without types) in function declaration
fight.c:2476: conflicting types for `check_killer'
mud.h:4767: previous declaration of `check_killer'
fight.c:2476: warning: data definition has no type or storage class
fight.c:2478: parse error before "if"
fight.c:2483: warning: type defaults to `int' in declaration of `set_cur_char'
fight.c:2483: warning: parameter names (without types) in function declaration
fight.c:2483: conflicting types for `set_cur_char'
mud.h:4996: previous declaration of `set_cur_char'
fight.c:2483: warning: data definition has no type or storage class
fight.c:2484: warning: type defaults to `int' in declaration of `raw_kill'
fight.c:2484: warning: parameter names (without types) in function declaration
fight.c:2484: conflicting types for `raw_kill'
mud.h:4783: previous declaration of `raw_kill'
fight.c:2484: warning: data definition has no type or storage class
fight.c:2485: warning: type defaults to `int' in declaration of `victim'
fight.c:2485: warning: initialization makes integer from pointer without a cast
fight.c:2485: warning: data definition has no type or storage class
fight.c:2487: parse error before "if"
fight.c:2493: parse error before string constant
fight.c:2493: warning: type defaults to `int' in declaration of `do_get'
fight.c:2493: conflicting types for `do_get'
mud.h:3854: previous declaration of `do_get'
fight.c:2493: warning: data definition has no type or storage class
fight.c:2494: warning: type defaults to `int' in declaration of `new_gold'
fight.c:2494: `ch' undeclared here (not in a function)
fight.c:2494: warning: data definition has no type or storage class
fight.c:2495: warning: type defaults to `int' in declaration of `gold_diff'
fight.c:2495: `init_gold' undeclared here (not in a function)
fight.c:2495: warning: data definition has no type or storage class
fight.c:2496: parse error before "if"
fight.c:2499: warning: type defaults to `int' in declaration of `do_split'
fight.c:2499: warning: parameter names (without types) in function declaration
fight.c:2499: conflicting types for `do_split'
mud.h:4105: previous declaration of `do_split'
fight.c:2499: warning: data definition has no type or storage class
fight.c:2500: parse error before '}' token
fight.c:2544: warning: type defaults to `int' in declaration of `stop_hunting'
fight.c:2544: warning: parameter names (without types) in function declaration
fight.c:2544: conflicting types for `stop_hunting'
fight.c:121: previous declaration of `stop_hunting'
fight.c:2544: warning: data definition has no type or storage class
fight.c:2545: parse error before string constant
fight.c:2545: warning: type defaults to `int' in declaration of `do_flee'
fight.c:2545: conflicting types for `do_flee'
mud.h:3842: previous declaration of `do_flee'
fight.c:2545: warning: data definition has no type or storage class
fight.c:2558: warning: type defaults to `int' in declaration of `tail_chain'
fight.c:2558: conflicting types for `tail_chain'
mud.h:4717: previous declaration of `tail_chain'
fight.c:2558: warning: data definition has no type or storage class
fight.c:2559: parse error before "return"
fight.c:2708: conflicting types for `check_killer'
fight.c:2476: previous declaration of `check_killer'
fight.c:3035: conflicting types for `update_pos'
fight.c:2333: previous declaration of `update_pos'
fight.c:3399: conflicting types for `raw_kill'
fight.c:2484: previous declaration of `raw_kill'
fight.c:4141: conflicting types for `do_flee'
fight.c:2545: previous declaration of `do_flee'
fight.c:4336:2: warning: no newline at end of file
make[1]: *** [o/fight.o] Error 1
make: *** [all] Error 2
ill post what my fight.c looks like too if that may help
/*
* Get experience based on % of damage done -Thoric
*/
if ( dam && ch != victim
if (dam > 100)
dam = 100;
if (ch->race == 0) /* Saiyan */
xp_mod = 0.66;
else if (ch->race == 3) /* Namek */
xp_mod = 0.665;
else if (ch->race == 2) /* Halfbreed */
xp_mod = 0.68;
else
xp_mod = 0.67;
if ( !IS_NPC(victim) )
xp_gain = (float) dam / 100 * powvictim->pl, xp_mod);
if ( IS_NPC(victim) )
xp_gain = (float) dam / 100 * powvictim->exp, xp_mod);
/* Sparing and deadly combat pl gain's */
if ( !IS_NPC(ch) && !IS_NPC(victim)
&& !xIS_SET(ch->act, PLR_SPAR) && !IS_SET(victim->act, PLR_SPAR))
xp_gain = (float) dam / 100 * powvictim->exp, 0.70);
if ( !IS_NPC(ch) && !IS_NPC(victim)
&& !xIS_SET(ch->act, PLR_SPAR) && !IS_SET(victim->act, PLR_SPAR))
{
xp_mod = (float) xp_mod - .01;
xp_gain = (float) dam / 100 pow(victim->exp, xp_mod);
/* PL Gains cut if player is stronger than opontants */
if ( !IS_NPC(victim)) {
if ((ch->pl / victim->pl) < 3)
xp_gain = xp_gain;
else if ((ch->pl / victim->pl) < 4)
xp_gain *= 0.7;
else if ((ch->pl / victim->pl) < 5)
xp_gain *= 0.6;
else if ((ch->pl / victim->pl) < 6)
xp_gain *= 0.5;
else if ((ch->pl / victim->pl) < 7)
xp_gain *= 0.4;
else if ((ch->pl / victim->pl) < 8)
xp_gain *= 0.3;
else if ((ch->pl / victim->exp) < 9)
xp_gain *= 0.2;
else if ((ch->pl / victim->exp) < 10)
xp_gain *= 0.1;
else
xp_gain = 0;
}
/* PL Gains cut if player is weaker than opontants */
if (ch->exp != ch->pl && ch->exp < ch->pl)
{
int pl_exp = 0;
pl_exp = (ch->pl / ch->exp);
xp_gain = xp_gain -( (float) pl_exp * .035 * xp_gain );
}
if (ch->pl < 2500)
xp_gain += 1;
if (ch->pl < 5000)
xp_gain += 1;
if (xp_gain < 0)
xp_gain = 0;
xp_gain_post = xp_gain * ( race_table[ch->race]->exp_multiplier/100.0);
/* if (xp_gain != 1) {
sprintf( buf1, "Your power level ncreases by %s points.", num_punct(xp_gain_post) );
act( AT_HIT, buf1, ch, NULL, victim, TO_CHAR );
}
else {
sprintf( buf1, "Your power level ncreases by %s point.", num_punct(xp_gain_post) );
act( AT_HIT, buf1, ch, NULL, victim, TO_CHAR );
}
*/
gain_exp( ch, xp_gain );
&& !IS_NPC(ch) && ch->fighting && ch->fighting->xp )
{
if ( ch->fighting->who == victim )
xp_gain = (int) (ch->fighting->xp * dam) / victim->max_hit;
else
xp_gain = (int) (xp_compute( ch, victim ) * 0.85 * dam) / victim->max_hit;
if ( dt == gsn_backstab || dt == gsn_circle )
xp_gain = 0;
gain_exp( ch, xp_gain );
Very first problem I see is this line:
It needs a closing ) that Im just not seeing. Fix that and a great many of the parse errors will disappear. As for the undeclared variables, declare em somewhere and those warnings will go poof as well.
Whould it be possible to send me a copy of your powerlevel code via john_ss413@yahoo.com
I was workin on a powerlevel code and in
mud.h i define it by the #define MAX_EXP_WORTH
i use
#define MAX_POWERLEVEL
#define MIN_POWERLEVEL
can i get some help on createin the powerlevel code
also when i try and use powerlevel instead of exp it says
structure has no define of powerlevel or something like that ill have to check
Jinru, you have to define the new structure in mud.h
Chosen, you need to fix up a lot of that code. Look for brackets that don't have an end bracket, and the such. *nudges Chosen* :P
ah, heh thanks zeno, ive been looking for really hard unobvious mistakes in the code, i over look all of the simple ones, or just everything all together heh.
chould you tell me how to define a new structure?