Ejemplo n.º 1
0
int
cast_spell (struct char_data *ch, struct char_data *tch,
			struct obj_data *tobj, int spellnum)
{
	if (spellnum < 0 || spellnum > TOP_SPELL_DEFINE)
	{
		log ("SYSERR: cast_spell trying to call spellnum %d/%d.\n", spellnum,
			 TOP_SPELL_DEFINE);
		return (0);
	}

	if (GET_POS (ch) < SINFO.min_position)
	{
		switch (GET_POS (ch))
		{
		case POS_SLEEPING:
			send_to_char ("You dream about great magical powers.\r\n", ch);
			break;
		case POS_RESTING:
			send_to_char ("You cannot concentrate while resting.\r\n", ch);
			break;
		case POS_SITTING:
			send_to_char ("You can't do this sitting!\r\n", ch);
			break;
		case POS_FIGHTING:
			send_to_char ("Impossible!  You can't concentrate enough!\r\n",
						  ch);
			break;
		default:
			send_to_char ("You can't do much of anything like this!\r\n", ch);
			break;
		}
		return (0);
	}
	if (AFF_FLAGGED (ch, AFF_CHARM) && (ch->master == tch))
	{
		send_to_char ("You are afraid you might hurt your master!\r\n", ch);
		return (0);
	}
	if ((tch != ch) && IS_SET (SINFO.targets, TAR_SELF_ONLY))
	{
		send_to_char ("You can only cast this spell upon yourself!\r\n", ch);
		return (0);
	}
	if ((tch == ch) && IS_SET (SINFO.targets, TAR_NOT_SELF))
	{
		send_to_char ("You cannot cast this spell upon yourself!\r\n", ch);
		return (0);
	}
	if (IS_SET (SINFO.routines, MAG_GROUPS) && !AFF_FLAGGED (ch, AFF_GROUP))
	{
		send_to_char
			("You can't cast this spell if you're not in a group!\r\n", ch);
		return (0);
	}
	send_to_char (OK, ch);
	say_spell (ch, spellnum, tch, tobj);

	return (call_magic (ch, tch, tobj, spellnum, GET_LEVEL (ch), CAST_SPELL));
}
Ejemplo n.º 2
0
void advance_turn(CHAR_DATA * ch)
{
CHAR_DATA *rch;
int q=0;

for (rch = ch->in_room->people; rch != NULL; rch = rch->next_in_room)
    {
if(rch->infight)
q++;    
}
if(q<1);
return;

    check_winner(ch->in_room);

q = 0;
    for (rch = ch->in_room->people; rch != NULL; rch = rch->next_in_room)
    {  
    if(rch == NULL || !rch->infight)
    continue;
    do_map(rch,"forced");
    }

ch->in_room->next = NULL;
while(ch->in_room->next == NULL)
{
    for (rch = ch->in_room->people; rch != NULL; rch = rch->next_in_room)
    {
    if(rch == NULL || !rch->infight)
    continue;
    
    if(rch->ATToCast < rch->AT)
    {
    say_spell (rch, rch->SnToCast);
    tile_spell(rch, rch->SnToCast);
    rch->ATToCast = 0;
    rch->SnToCast = 0;
    rch->casting = FALSE;
    rch->CastTargY = 0;
    rch->CastTargX = 0;   
    }

    rch->AT += rch->speed;
    if(rch->AT >= 100)
    {
    rch->AT = 100;
    ch->in_room->turn = rch;
    break;
    }
    }
}

    ch->in_room->turn->MoveLeft = ch->in_room->turn->base_move;
    ch->in_room->turn->AttackLeft = 1;

    printf_to_char(rch,"%s's turn.\n",fcn(ch->in_room->turn));

}
Ejemplo n.º 3
0
void tile_spell(CHAR_DATA *ch, int sn)
{
void * vo;
CHAR_DATA *rch;
bool hit;
    for (rch = ch->in_room->people; rch != NULL; rch = rch->next_in_room)
    {
    say_spell(ch,sn);
    if((rch->mposx == ch->CastTargX && rch->mposy == ch->CastTargY))
    {
    vo = (CHAR_DATA *) rch;
    if (IS_NPC (ch) )
    (*skill_table[sn].spell_fun) (ch->SnToCast, ch->level, ch, vo, 0);
    else
    (*skill_table[sn].spell_fun) (ch->SnToCast, 3 * ch->level / 4, ch, vo, 0);
    hit = TRUE;
    }
 
    if((rch->mposx == ch->CastTargX && rch->mposy == ch->CastTargY-1))
    {
    vo = (CHAR_DATA *) rch;
    if (IS_NPC (ch) )
    (*skill_table[sn].spell_fun) (ch->SnToCast, ch->level, ch, vo, 0);
    else
    (*skill_table[sn].spell_fun) (ch->SnToCast, 3 * ch->level / 4, ch, vo, 0);
    hit = TRUE;
    }

    if((rch->mposx == ch->CastTargX-1 && rch->mposy == ch->CastTargY))
    {
    vo = (CHAR_DATA *) rch;
    if (IS_NPC (ch) )
    (*skill_table[sn].spell_fun) (ch->SnToCast, ch->level, ch, vo, 0);
    else
    (*skill_table[sn].spell_fun) (ch->SnToCast, 3 * ch->level / 4, ch, vo, 0);
    hit = TRUE;
    }

    if((rch->mposx == ch->CastTargX+1 && rch->mposy == ch->CastTargY))
    {
    vo = (CHAR_DATA *) rch;
    if (IS_NPC (ch) )
    (*skill_table[sn].spell_fun) (ch->SnToCast, ch->level, ch, vo, 0);
    else
    (*skill_table[sn].spell_fun) (ch->SnToCast, 3 * ch->level / 4, ch, vo, 0);
    hit = TRUE;
    }

    if((rch->mposx == ch->CastTargX && rch->mposy == ch->CastTargY+1))
    {
    vo = (CHAR_DATA *) rch;
    if (IS_NPC (ch) )
    (*skill_table[sn].spell_fun) (ch->SnToCast, ch->level, ch, vo, 0);
    else
    (*skill_table[sn].spell_fun) (ch->SnToCast, 3 * ch->level / 4, ch, vo, 0);
    hit = TRUE;
    }

}    

}
Ejemplo n.º 4
0
int	cast_spell(struct char_data *ch, struct char_data *tch,
               struct obj_data *tobj, struct spell_info_type *sptr,
               char *tar_str)
{

    if (!magic_enabled)
        return (0);

    if (!sptr) {
        extended_mudlog(NRM, SYSL_BUGS, TRUE, "cast_spell() called without a valid sptr: ch: %s, tch: %s",
                        GET_NAME(ch), GET_NAME(tch));
        return (0);
    }

    if (GET_POS(ch) < sptr->min_position) {
        switch (GET_POS(ch)) {
        case POS_SLEEPING:
            send_to_char("You dream about great magical powers.\r\n", ch);
            break;
        case POS_RESTING:
            send_to_char("You cannot concentrate while resting.\r\n", ch);
            break;
        case POS_SITTING:
            send_to_char("You can't do this sitting!\r\n", ch);
            break;
        case POS_FIGHTING:
            send_to_char("Impossible!  You can't concentrate enough!\r\n", ch);
            break;
        default:
            send_to_char("You can't do much of anything like this!\r\n", ch);
            break;
        }
        return (0);
    }
    if (AFF_FLAGGED(ch, AFF_CHARM) && (ch->master == tch)) {
        send_to_char("You are afraid you might hurt your master!\r\n", ch);
        return (0);
    }
    if ((tch != ch) && IS_SET(sptr->targets, TAR_SELF_ONLY)) {
        send_to_char("You can only cast this spell upon yourself!\r\n", ch);
        return (0);
    }
    if ((tch == ch) && IS_SET(sptr->targets, TAR_NOT_SELF)) {
        send_to_char("You cannot cast this spell upon yourself!\r\n", ch);
        return (0);
    }
    if (IS_SET(sptr->routines, MAG_GROUPS) && !AFF_FLAGGED(ch, AFF_GROUP)) {
        send_to_char("You can't cast this spell if you're not in a group!\r\n",ch);
        return (0);
    }

    if (cast_mtrigger(tch, ch, tar_str, sptr) == 0)
        return (0);
    if (cast_otrigger(tobj, ch, tar_str, sptr) == 0)
        return (0);
    if (cast_wtrigger(ch, tch, tobj, tar_str, sptr) == 0)
        return (0);

    send_to_char(OK, ch);
    say_spell(ch, sptr, tch, tobj);

    return (call_magic(ch, tch, tobj, sptr, (GET_SKILL(ch, sptr->skill)/100), CAST_SPELL,
                       tar_str));
}