Pages:<< prev 1 next >>
Fledgling

GroupMembers
Posts12
JoinedDec 14, 2003
I put this on a different forum aswell, but haven't got an answer on that yet, so yea, all help is welcome
I don't know much about timers, but what I just coded in gives me 3(6) bugs, but I don't know why or how. I tried a lot already, like making different do_functions for it, but it still didn't work. It probably is something easy, but yea...I can't figure it out lol.
I'll explain the idea for the code first:
I want to make it so that skills take up some time to use and their opponent can counter it with their skills.
I get the following errors:
magic.c: In function 'spell_water_dragon_blast':
magic.c:7338: error: syntax error before "ch_ret"
magic.c:7340: error: case label not within a switch statement
magic.c:7344: error: syntax error before "ch_ret"
magic.c:7347: error: case label not within a switch statement
magic.c:7351: error: syntax error before "ch_ret"
magic.c:7354: error: case label not within a switch statement
The code of the skill:
I don't know much about timers, but what I just coded in gives me 3(6) bugs, but I don't know why or how. I tried a lot already, like making different do_functions for it, but it still didn't work. It probably is something easy, but yea...I can't figure it out lol.
I'll explain the idea for the code first:
I want to make it so that skills take up some time to use and their opponent can counter it with their skills.
I get the following errors:
magic.c: In function 'spell_water_dragon_blast':
magic.c:7338: error: syntax error before "ch_ret"
magic.c:7340: error: case label not within a switch statement
magic.c:7344: error: syntax error before "ch_ret"
magic.c:7347: error: case label not within a switch statement
magic.c:7351: error: syntax error before "ch_ret"
magic.c:7354: error: case label not within a switch statement
The code of the skill:
ch_ret spell_water_dragon_blast( int sn, int level, CHAR_DATA *ch, void *vo )
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
int dam;
level = UMAX(0, level);
level = UMIN(150, level);
dam = number_range( 1, 7 )*number_range( 50, 75 );
act( AT_MAGIC, "You start performing seals", ch, NULL, NULL, TO_CHAR);
act( AT_MAGIC, "$n starts performing seals", ch, NULL, NULL, TO_CHAR);
add_timer( ch, TIMER_NONE, 1, ch_ret spell_water_dragon_blast, 1 )
ch->alloc_ptr = str_dup( staticbuf );
case 1:
act( AT_MAGIC, "...ox tiger bird monkey rat ox...", ch, NULL, NULL, TO_CHAR);
act( AT_MAGIC, "...ox tiger bird monkey rat ox...", ch, NULL, NULL, TO_ROOM);
DISPOSE( ch->alloc_ptr );
add_timer( ch, TIMER_NONE, 2, ch_ret spell_water_dragon_blast, 2 )
ch->alloc_ptr = str_dup( staticbuf );
case 2:
act( AT_MAGIC, "You yell: '...Bird! Suiton Suiryuudan no Jutsu!'", ch, NULL, NULL, TO_CHAR);
act( AT_MAGIC, "$n yells: '...Bird! Suiton Suiryuudan no Jutsu!'", ch, NULL, NULL, TO_ROOM);
DISPOSE( ch->alloc_ptr );
add_timer( ch, TIMER_NONE, 3, ch_ret spell_water_dragon_blast, 3 )
ch->alloc_ptr = str_dup( staticbuf );
case 3:
act( AT_MAGIC, "A large dragon made completely of water rises up and charges at $N", ch, NULL, NULL, TO_ROOM);
act( AT_MAGIC, "A large dragon made completely of water rises up and charges at $N", ch, NULL, NULL, TO_CHAR);
DISPOSE( ch->alloc_ptr );
if ( IS_AFFECTED( victim, AFF_SHARINGAN ) )
{
if( victim->pcdata->learned[sn] )
{
return damage( ch, victim, dam, sn );
}
if( victim->mana pcdata->learned[sn] = 20;
victim->mana -= 150;
act( AT_FIRE, "Your sharingan starts spinning at a fast rate!\r\n", victim, NULL, NULL, TO_CHAR);
act( AT_YELLOW, "You just copied Water Dragon Blast!\r\n", victim, NULL, NULL, TO_CHAR );
act( AT_FIRE, "$n's sharingan starts spinning!\r\n", victim, NULL, NULL, TO_ROOM );
return damage( ch, victim, dam, sn );
}
if ( saves_spell_staff( level, victim ) )
dam /= 2;
return damage( ch, victim, dam, sn );
}
Apprentice

GroupMembers
Posts95
JoinedNov 19, 2003
I haven't spent much time looking at skills but your problem seems to be that you aren't using case statements properly.
The general syntax of a switch is like this
where if var == 1 it does the stuff after case 1.
The general syntax of a switch is like this
switch (var)
{
case 1:
stuff...
break;
case 2:
stuff...
break:
default:
stuff...
break;
}
where if var == 1 it does the stuff after case 1.
Fledgling

GroupMembers
Posts46
JoinedMar 8, 2005
I'm pretty sure the syntax error is from the way you use add_timer.
add_timer( ch, TIMER_NONE, 1, ch_ret spell_water_dragon_blast, 1 );
Should be:
add_timer( ch, TIMER_NONE, 1, spell_water_dragon_blast, 1 );
The previous post is also correct. A switch as far as I can tell isn't even declared. Follow the form he stated.
add_timer( ch, TIMER_NONE, 1, ch_ret spell_water_dragon_blast, 1 );
Should be:
add_timer( ch, TIMER_NONE, 1, spell_water_dragon_blast, 1 );
The previous post is also correct. A switch as far as I can tell isn't even declared. Follow the form he stated.
Pages:<< prev 1 next >>