@ -30,18 +30,19 @@ static boolean makemon_rnd_goodpos(struct monst *, mmflags_nht, coord *);
boolean
boolean
is_home_elemental ( struct permonst * ptr )
is_home_elemental ( struct permonst * ptr )
{
{
if ( ptr - > mlet = = S_ELEMENTAL )
if ( ptr - > mlet = = S_ELEMENTAL ) // Check if the monster is an elemental creature
switch ( monsndx ( ptr ) ) {
switch ( monsndx ( ptr ) ) { // Determine the specific type of the elemental creature
case PM_AIR_ELEMENTAL :
case PM_AIR_ELEMENTAL :
case PM_AIR_ELEMENTAL :
return Is_airlevel ( & u . uz ) ;
return Is_airlevel ( & u . uz ) ; // Check if the player is on an air elemental level
case PM_FIRE_ELEMENTAL :
case PM_FIRE_ELEMENTAL :
return Is_firelevel ( & u . uz ) ;
return Is_firelevel ( & u . uz ) ; // Check if the player is on a fire elemental level
case PM_EARTH_ELEMENTAL :
case PM_EARTH_ELEMENTAL :
return Is_earthlevel ( & u . uz ) ;
return Is_earthlevel ( & u . uz ) ; // Check if the player is on an earth elemental level
case PM_WATER_ELEMENTAL :
case PM_WATER_ELEMENTAL :
return Is_waterlevel ( & u . uz ) ;
return Is_waterlevel ( & u . uz ) ; // Check if the player is on a water elemental level
}
}
return FALSE ;
return FALSE ; // The monster is not an elemental or the player is not on a matching elemental level
}
}
/*
/*
@ -50,23 +51,24 @@ is_home_elemental(struct permonst *ptr)
static boolean
static boolean
wrong_elem_type ( struct permonst * ptr )
wrong_elem_type ( struct permonst * ptr )
{
{
if ( ptr - > mlet = = S_ELEMENTAL ) {
if ( ptr - > mlet = = S_ELEMENTAL ) { // Check if the monster is an elemental creature
return ( boolean ) ! is_home_elemental ( ptr ) ;
return ( boolean ) ! is_home_elemental ( ptr ) ; // Return the opposite of is_home_elemental
} else if ( Is_earthlevel ( & u . uz ) ) {
} else if ( Is_earthlevel ( & u . uz ) ) {
/* no restrictions? */
/* no restrictions? */
} else if ( Is_waterlevel ( & u . uz ) ) {
} else if ( Is_waterlevel ( & u . uz ) ) {
/* just monsters that can swim */
/* just monsters that can swim */
if ( ! is_swimmer ( ptr ) )
if ( ! is_swimmer ( ptr ) )
return TRUE ;
return TRUE ; // Return true if the monster cannot swim
} else if ( Is_firelevel ( & u . uz ) ) {
} else if ( Is_firelevel ( & u . uz ) ) {
if ( ! pm_resistance ( ptr , MR_FIRE ) )
if ( ! pm_resistance ( ptr , MR_FIRE ) )
return TRUE ;
return TRUE ; // Return true if the monster is not resistant to fire
} else if ( Is_airlevel ( & u . uz ) ) {
} else if ( Is_airlevel ( & u . uz ) ) {
if ( ! ( is_flyer ( ptr ) & & ptr - > mlet ! = S_TRAPPER ) & & ! is_floater ( ptr )
if ( ! ( is_flyer ( ptr ) & & ptr - > mlet ! = S_TRAPPER ) & & ! is_floater ( ptr )
& & ! amorphous ( ptr ) & & ! noncorporeal ( ptr ) & & ! is_whirly ( ptr ) )
& & ! amorphous ( ptr ) & & ! noncorporeal ( ptr ) & & ! is_whirly ( ptr ) )
return TRUE ;
return TRUE ; // Return true if the monster is not suited for an air level
}
}
return FALSE ;
return FALSE ; // The monster is suitable for the current level or is not an elemental
}
}
/* make a group just like mtmp */
/* make a group just like mtmp */
@ -142,12 +144,12 @@ m_initthrow(struct monst *mtmp, int otyp, int oquan)
{
{
register struct obj * otmp ;
register struct obj * otmp ;
otmp = mksobj ( otyp , TRUE , FALSE ) ;
otmp = mksobj ( otyp , TRUE , FALSE ) ; // Create a new object of the given type
otmp - > quan = ( long ) rn1 ( oquan , 3 ) ;
otmp - > quan = ( long ) rn1 ( oquan , 3 ) ; // Set the quantity of the object
otmp - > owt = weight ( otmp ) ;
otmp - > owt = weight ( otmp ) ; // Set the weight of the object
if ( otyp = = ORCISH_ARROW )
if ( otyp = = ORCISH_ARROW )
otmp - > opoisoned = TRUE ;
otmp - > opoisoned = TRUE ; // Set the poisoned flag if the object type is ORCISH_ARROW
( void ) mpickobj ( mtmp , otmp ) ;
( void ) mpickobj ( mtmp , otmp ) ; // Add the object to the monster's inventory
}
}
static void
static void