src/magic.c
/* RT calm spell stops all fighting in the room */
RT calm spell stops all fighting in the room
RT calm spell stops all fighting in the room
void spell_calm( int sn, int level, CHAR_DATA *ch, void *vo,int target)
{
    CHAR_DATA *vch;
    int mlevel = 0;
    int count = 0;
    int high_level = 0;    
    int chance;
    AFFECT_DATA af;
    for (vch = ch->in_room->people; vch != NULL; vch = vch->next_in_room)
    {
	if (vch->position == POS_FIGHTING)
	{
	    count++;
	    if (IS_NPC(vch))
	      mlevel += vch->level;
	    else
	      mlevel += vch->level/2;
	    high_level = UMAX(high_level,vch->level);
	}
    }
    chance = 4 * level - high_level + 2 * count;
    if (IS_IMMORTAL(ch)) 
      mlevel = 0;
    if (number_range(0, chance) >= mlevel)  
    {
	for (vch = ch->in_room->people; vch != NULL; vch = vch->next_in_room)
   	{
	    if (IS_NPC(vch) && (IS_SET(vch->imm_flags,IMM_MAGIC) ||
				IS_SET(vch->act,ACT_UNDEAD)))
	      return;
	    if (IS_AFFECTED(vch,AFF_CALM) || IS_AFFECTED(vch,AFF_BERSERK)
	    ||  is_affected(vch,skill_lookup("frenzy")))
	      return;
	    send_to_char("A wave of calm passes over you.\n\r",vch);
	    if (vch->fighting || vch->position == POS_FIGHTING)
	      stop_fighting(vch,FALSE);
	    af.where = TO_AFFECTS;
	    af.type = sn;
  	    af.level = level;
	    af.duration = level/4;
	    af.location = APPLY_HITROLL;
	    if (!IS_NPC(vch))
	      af.modifier = -5;
	    else
	      af.modifier = -2;
	    af.bitvector = AFF_CALM;
	    affect_to_char(vch,&af);
	    af.location = APPLY_DAMROLL;
	    affect_to_char(vch,&af);
	}
    }
}
void spell_calm ( int sn , int level , CHAR_DATA * ch , void * vo , int target ) { CHAR_DATA * vch ; int mlevel = 0 ; int count = 0 ; int high_level = 0 ; int chance ; AFFECT_DATA af ; for ( vch = ch -> in_room -> people ; vch != NULL ; vch = vch -> next_in_room ) { if ( vch -> position == POS_FIGHTING ) { count ++ ; if ( IS_NPC ( vch ) ) mlevel += vch -> level ; else mlevel += vch -> level / 2 ; high_level = UMAX ( high_level , vch -> level ) ; } } chance = 4 * level - high_level + 2 * count ; if ( IS_IMMORTAL ( ch ) ) mlevel = 0 ; if ( number_range ( 0 , chance ) >= mlevel ) { for ( vch = ch -> in_room -> people ; vch != NULL ; vch = vch -> next_in_room ) { if ( IS_NPC ( vch ) && ( IS_SET ( vch -> imm_flags , IMM_MAGIC ) || IS_SET ( vch -> act , ACT_UNDEAD ) ) ) return ; if ( IS_AFFECTED ( vch , AFF_CALM ) || IS_AFFECTED ( vch , AFF_BERSERK ) || is_affected ( vch , skill_lookup ( " " ) ) ) return ; send_to_char ( " \n \r " , vch ) ; if ( vch -> fighting || vch -> position == POS_FIGHTING ) stop_fighting ( vch , FALSE ) ; af . where = TO_AFFECTS ; af . type = sn ; af . level = level ; af . duration = level / 4 ; af . location = APPLY_HITROLL ; if ( ! IS_NPC ( vch ) ) af . modifier = -5 ; else af . modifier = -2 ; af . bitvector = AFF_CALM ; affect_to_char ( vch , & af ) ; af . location = APPLY_DAMROLL ; affect_to_char ( vch , & af ) ; } } }
RT calm spell stops all fighting in the room
RT calm spell stops all fighting in the room
/* get sum of all mobile levels in the room */ /* compute chance of stopping combat */ /* always works */ /* hard to stop large fights */