Crossfire Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CF: monster.c.diff



*** monster.c.orig	Sun Aug 17 22:45:14 1997
--- monster.c	Thu Oct  2 07:42:13 1997
***************
*** 1374,1395 ****
    /* this causes problems, dunno why.. */
    /* are we trying to look through a wall? */ 
    if(path_to_player(op->head?op->head:op,enemy,0)==0) return 0;
  #endif
  
!   /* opponent is unseen? */
    if(!can_see_enemy(op,enemy)) {
      object *part = get_nearest_part(op,enemy);
      int radius = MIN_MON_RADIUS;
      int x_dist = abs(part->x-enemy->x), y_dist = abs(part->y-enemy->y);
      /* This is percentage change of being discovered while standing
       * *adjacent* to the monster */
      int hide_discovery = enemy->hide?op->stats.Int/5:-1;
  
  
!     /* detect non-hidden (eg dark/invis enemy) */
!     if(!enemy->hide)  
        radius = (op->stats.Wis/5)+1>MIN_MON_RADIUS?(op->stats.Wis/5)+1:MIN_MON_RADIUS;
      else { /* a level/INT/Dex adjustment for hiding */
        object *sk_hide;
        int bonus = (op->level/2) + (op->stats.Int/5);
        if(enemy->type==PLAYER)
--- 1374,1406 ----
    /* this causes problems, dunno why.. */
    /* are we trying to look through a wall? */ 
    if(path_to_player(op->head?op->head:op,enemy,0)==0) return 0;
  #endif
  
!   /* opponent is unseen? We still have a chance to find them if
!    * they are 1) standing in dark square, 2) hidden or 3) low-quality
!    * invisible (the basic invisibility spell).
!    */
    if(!can_see_enemy(op,enemy)) {
      object *part = get_nearest_part(op,enemy);
      int radius = MIN_MON_RADIUS;
      int x_dist = abs(part->x-enemy->x), y_dist = abs(part->y-enemy->y);
      /* This is percentage change of being discovered while standing
       * *adjacent* to the monster */
      int hide_discovery = enemy->hide?op->stats.Int/5:-1;
  
+     /* The rest of this is for monsters. Players are on their own for
+      * finding enemies! */
+     if(op->type==PLAYER) return 0;
+ 
+     /* Quality invisible? Bah, we wont see them w/o SEE_INVISIBLE
+      * flag (which was already checked). Lets get out of here */
+     if(enemy->invisible && (!enemy->contr || !enemy->contr->tmp_invis))
+        return 0;
  
!     /* Determine Detection radii */
!     if(!enemy->hide)  /* to detect non-hidden (eg dark/invis enemy) */
        radius = (op->stats.Wis/5)+1>MIN_MON_RADIUS?(op->stats.Wis/5)+1:MIN_MON_RADIUS;
      else { /* a level/INT/Dex adjustment for hiding */
        object *sk_hide;
        int bonus = (op->level/2) + (op->stats.Int/5);
        if(enemy->type==PLAYER)
***************
*** 1400,1488 ****
            make_visible(enemy);
            radius=radius<MIN_MON_RADIUS?MIN_MON_RADIUS:radius;
          }
        else
          bonus -= enemy->level;
        radius += bonus/5;
!       hide_discovery+= bonus/5;
      }
  
!     /* the stealth adjustment. Only if you are stealthy 
       * will you be able to sneak up closer to creatures */ 
      if(QUERY_FLAG(enemy,FLAG_STEALTH)) 
        radius = radius/2, hide_discovery = hide_discovery/3;
  
!     /* sanity check if the enemy is visible */
!     if(!enemy->invisible) {
         /* on dark maps body heat can help indicate location with infravision */
!        if(QUERY_FLAG(op,FLAG_SEE_IN_DARK)&&op->map->darkness>0
!          &&(!enemy->immune&AT_FIRE||QUERY_FLAG(enemy,FLAG_UNDEAD))) 
! 	radius += op->map->darkness/2;
  
         /* op next to a monster (and not in complete darkness) 
! 	* the monster should see you. */
! 	if(radius<MIN_MON_RADIUS&&op->map->darkness<5) 
  	  radius = MIN_MON_RADIUS;
      }
  
      /* Lets not worry about monsters that have incredible detection
!      * radii, we only need to worry here about things the player can 
!      * see. */
!     if(radius>6) radius = 6;
! 
!     /* Now check if the enemy is detected/found. Either the enemy
!      * will get too close OR if *hidden*, there is a small
!      * chance each time we check this function that the monster
!      * can detect the enemy. This means the longer you hide
!      * near something, the greater the chance you have of
!      * being discovered. */
!     if((x_dist<radius&&y_dist<radius)
!       ||(enemy->hide&&(x_dist<=1||y_dist<=1)
!         &&RANDOM()%100<=(hide_discovery>0?hide_discovery:0))
!     ) {
!         /* make hidden/tmp invisible (player) enemies visible */
! 	if(enemy->invisible && (enemy->hide || !QUERY_FLAG(enemy,FLAG_MAKE_INVIS))) 
! 	{ 
  	   make_visible(enemy);
  	   /* inform players of new status */
! 	   if(enemy->type==PLAYER) 
! 	     new_draw_info(NDI_UNIQUE,0, enemy,"You are discovered!");
!         }
!         return 1; /* detected enemy */ 
  
!     } else if(enemy->hide 	/* Nearby Hidden enemies */
! 	&& (x_dist==radius||y_dist==radius)
!     ) { 
!        /* Since the enemy is nearby we excellerate the time of 
!         * becoming unhidden (ie as finding the enemy is easier)
!  	* In order to leave actual discovery (hide==0 state) to
! 	* be handled above (not here) we only decrement so that 
! 	* enemy->invisible>1 is preserved. */
!        if((enemy->invisible-=RANDOM()%(op->stats.Int+2))<1) enemy->invisible=1;
  
!        /* MESSAGING: If we didnt find them, we may warn a hidden 
! 	* player that the monster is getting close to discoverng them. 
    	*
          * We only warn the player if: 
! 	*   1) the player/monster level criteria are met
  	*   2) random value based on player Int value
-    	* This is done primarily to cut down on the messaging 
-  	* and to promote greater care from the player in sneaking 
- 	* up on monsters.
     	*/
         if(enemy->type==PLAYER 
! 	   && ((SK_level(enemy)>op->level? RANDOM()%5 : RANDOM()%3) > 1) 
! 	   && (RANDOM()%(enemy->stats.Int+10)> 15)
         ) { 
           char buf[MAX_BUF];
!          sprintf(buf,"%s looks near your hidden spot.", query_name(op));
  	 new_draw_info(NDI_UNIQUE,0, enemy, buf);
         }
-        return enemy->hide?0:1;
  
-     } else /* Enemy is invisible/hidden far away and NOT found, return 0 */ 
         return 0;
    }
    return 1;
  } 
  
  /* determine if op stands in a lighted square. This is not a very
--- 1411,1502 ----
            make_visible(enemy);
            radius=radius<MIN_MON_RADIUS?MIN_MON_RADIUS:radius;
          }
        else
          bonus -= enemy->level;
+ 
        radius += bonus/5;
!       hide_discovery += bonus*5;
      }
  
!     /* Radii stealth adjustment. Only if you are stealthy 
       * will you be able to sneak up closer to creatures */ 
      if(QUERY_FLAG(enemy,FLAG_STEALTH)) 
        radius = radius/2, hide_discovery = hide_discovery/3;
  
! #ifdef USE_LIGHTING
!     /* Radii adjustment for enemy standing in the dark */ 
!     if(op->map->darkness>0 && !stand_in_light(enemy)) {
         /* on dark maps body heat can help indicate location with infravision */
!        if(QUERY_FLAG(op,FLAG_SEE_IN_DARK)
!          &&(!enemy->immune&AT_FIRE||is_true_undead(enemy))) 
! 	 radius += op->map->darkness/2;
!        else
! 	 radius -= op->map->darkness/2;
  
         /* op next to a monster (and not in complete darkness) 
! 	* the monster should have a chance to see you. */
! 	if(radius<MIN_MON_RADIUS && op->map->darkness<5 && (x_dist<=1||y_dist<=1)) 
  	  radius = MIN_MON_RADIUS;
      }
+ #endif
  
      /* Lets not worry about monsters that have incredible detection
!      * radii, we only need to worry here about things the player can
!      * (potentially) see. */
!     if(radius>5) radius = 5;
! 
!     /* Enemy in range! Now test for detection */
!     if(x_dist<=radius||y_dist<=radius) { 
!        /* ah, we are within range, detected? take cases */
!        if(!enemy->invisible) /* enemy in dark squares... are seen! */
!          return 1;
!        else if(enemy->hide||(enemy->contr&&enemy->contr->tmp_invis)) { 
!          /* hidden or low-quality invisible */  
! 
!          /* THere is a a small chance each time we check this function 
!           * that we can detect hidden enemy. This means the longer you stay 
!           * near something, the greater the chance you have of being 
!           * discovered. */
! 	 if(enemy->hide && (x_dist<=1||y_dist<=1) && (RANDOM()%100<=hide_discovery)
!          ) { 
  	   make_visible(enemy);
  	   /* inform players of new status */
! 	   if(enemy->type==PLAYER && player_can_view(enemy,op)) 
! 	     new_draw_info_format(NDI_UNIQUE,0, enemy,
!                "You are discovered by %s!",op->name);
!            return 1; /* detected enemy */ 
!          }
! 
!          /* If the hidden/tmp_invis enemy is nearby we excellerate the time of 
!           * becoming unhidden/visible (ie as finding the enemy is easier)
!  	  * In order to leave actual discovery (invisible=0 state) to
! 	  * be handled above (not here) we only decrement so that 
! 	  * enemy->invisible>1 is preserved. */
!           if((enemy->invisible-=RANDOM()%(op->stats.Int+2))<1) 
!             enemy->invisible=1;
  
!        }
  
!        /* MESSAGING: SO we didnt find them (wah!), we may warn a 
! 	* player that the monster is getting close to discovering them. 
    	*
          * We only warn the player if: 
!         *   1) player has los to the monster
  	*   2) random value based on player Int value
     	*/
         if(enemy->type==PLAYER 
! 	   && (RANDOM()%(enemy->stats.Int+10)> MAX_STAT/2)
!            && player_can_view(enemy,op)
         ) { 
           char buf[MAX_BUF];
!          sprintf(buf,"You see %s noticing your position.", query_name(op));
  	 new_draw_info(NDI_UNIQUE,0, enemy, buf);
         }
  
         return 0;
+     }
    }
    return 1;
  } 
  
  /* determine if op stands in a lighted square. This is not a very
***************
*** 1532,1559 ****
       * However,if you carry any source of light, then the hidden
       * creature is seeable (and stupid) */
      if(has_carried_lights(enemy)) { 
        if(enemy->hide) { 
  	make_visible(enemy);
! 	new_draw_info(NDI_UNIQUE,0, enemy,
  	  "Your light reveals your hidding spot!");
        }
        return 1;
      } else if (enemy->hide) return 0; 
  
      /* INVISIBLE ENEMY. */
      if(!QUERY_FLAG(looker,FLAG_SEE_INVISIBLE)
        &&(is_true_undead(looker)==QUERY_FLAG(enemy,FLAG_UNDEAD)))
        return 0;
  
!   }
  
  #ifdef USE_LIGHTING
    /* ENEMY IN DARK MAP. Without infravision, the enemy is not seen 
!    * unless they carry a light or stand in light. */
    if(looker->map->darkness>0&&!stand_in_light(enemy) 
!      &&(!QUERY_FLAG(looker,FLAG_SEE_IN_DARK)||!QUERY_FLAG(looker,FLAG_XRAYS)))
      return 0;
  #endif
  
    return 1;
  }
--- 1546,1577 ----
       * However,if you carry any source of light, then the hidden
       * creature is seeable (and stupid) */
      if(has_carried_lights(enemy)) { 
        if(enemy->hide) { 
  	make_visible(enemy);
!         new_draw_info(NDI_UNIQUE,0, enemy,
  	  "Your light reveals your hidding spot!");
        }
        return 1;
      } else if (enemy->hide) return 0; 
  
      /* INVISIBLE ENEMY. */
      if(!QUERY_FLAG(looker,FLAG_SEE_INVISIBLE)
        &&(is_true_undead(looker)==QUERY_FLAG(enemy,FLAG_UNDEAD)))
        return 0;
  
!   } else if(looker->type==PLAYER) /* for players, a (possible) shortcut */
!       if(player_can_view(looker,enemy)) return 1;
  
  #ifdef USE_LIGHTING
    /* ENEMY IN DARK MAP. Without infravision, the enemy is not seen 
!    * unless they carry a light or stand in light. Darkness doesnt
!    * inhibit the undead per se (but we should give their archs
!    * CAN_SEE_IN_DARK, this is just a safety  */
    if(looker->map->darkness>0&&!stand_in_light(enemy) 
!      &&(!QUERY_FLAG(looker,FLAG_SEE_IN_DARK)||
!         !is_true_undead(looker)||!QUERY_FLAG(looker,FLAG_XRAYS)))
      return 0;
  #endif
  
    return 1;
  }
[to unsubscribe etc., send mail to crossfire-request@ifi.uio.no]