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

CF: player.c.diff



*** player.c.orig	Sun Aug 17 22:45:14 1997
--- player.c	Thu Oct  2 07:35:27 1997
***************
*** 1196,1207 ****
  void fire(object *op,int dir) {
    object *weap=NULL;
    int spellcost=0;
  
    /* check for loss of invisiblity/hide */
!   if (op->contr->tmp_invis && (!op->hide||op->contr->shoottype==range_magic))  
!     make_visible(op);
  
     /* a check for players, make sure things are groovy. This routine
      * will change the skill of the player as appropriate in order to
      * fire whatever is requested. In the case of spells (range_magic)
      * it handles whether cleric or mage spell is requested to be cast. 
--- 1196,1206 ----
  void fire(object *op,int dir) {
    object *weap=NULL;
    int spellcost=0;
  
    /* check for loss of invisiblity/hide */
!   if (action_makes_visible(op)) make_visible(op);
  
     /* a check for players, make sure things are groovy. This routine
      * will change the skill of the player as appropriate in order to
      * fire whatever is requested. In the case of spells (range_magic)
      * it handles whether cleric or mage spell is requested to be cast. 
***************
*** 1367,1376 ****
--- 1366,1378 ----
  	return;		/* into a wall */
  
      if(tmp->head != NULL)
        tmp = tmp->head;
  
+     /* for 'fragile' forms of invisibiity, eg hidden or invisibility spell, 
+      * any of the following actions, if true,  will make us become seen */
+ 
      /* This blocks deals with opening a normal door.  We look for a key,
       * and if we found one, break the door.  If not, let normal attack
       * code deal with it.
       */
      if (tmp->type==DOOR && tmp->stats.hp>=0) {
***************
*** 1384,1393 ****
--- 1386,1396 ----
  #endif
  	decrease_ob(tmp2); /* Use up one of the keys */
  	hit_player(tmp,9999,op,AT_PHYSICAL); /* Break through the door */
  	if(tmp->inv && tmp->inv->type ==RUNE) spring_trap(tmp->inv,op);	
        }
+       if(action_makes_visible(op)) make_visible(op);
      }
  
      /* This area deals with locked doors.  These are doors that require
       * special keys.
       */
***************
*** 1396,1413 ****
        tmp2=op->inv;
        while(tmp2 && (tmp2->type != SPECIAL_KEY ||
  	    tmp2->slaying != tmp->slaying)) /* Find the key */
  	tmp2=tmp2->below;
  
! 	if(tmp2) {
  	  decrease_ob_nr(tmp2, 1); /* Use the key */
  	  remove_door2(tmp); /* remove door without violence ;-) */
  #ifdef SOUND_EFFECTS
  	  play_sound_map(op->map, op->x, op->y, SOUND_OPEN_DOOR);
  #endif
! 	  } else if (tmp->msg) /* show door's message if present */
  	    new_draw_info(NDI_UNIQUE | NDI_NAVY, 0, op, tmp->msg);
      }
  
      /* The following deals with possibly attacking peaceful
       * or frienddly creatures.  Basically, all players are considered
       * unaggressive.  If the moving player has peaceful set, then the
--- 1399,1417 ----
        tmp2=op->inv;
        while(tmp2 && (tmp2->type != SPECIAL_KEY ||
  	    tmp2->slaying != tmp->slaying)) /* Find the key */
  	tmp2=tmp2->below;
  
!       if(tmp2) {
  	  decrease_ob_nr(tmp2, 1); /* Use the key */
  	  remove_door2(tmp); /* remove door without violence ;-) */
  #ifdef SOUND_EFFECTS
  	  play_sound_map(op->map, op->x, op->y, SOUND_OPEN_DOOR);
  #endif
!       } else if (tmp->msg) /* show door's message if present */
  	    new_draw_info(NDI_UNIQUE | NDI_NAVY, 0, op, tmp->msg);
+       if(action_makes_visible(op)) make_visible(op);
      }
  
      /* The following deals with possibly attacking peaceful
       * or frienddly creatures.  Basically, all players are considered
       * unaggressive.  If the moving player has peaceful set, then the
***************
*** 1422,1438 ****
  	op->contr->peaceful && (!op->contr->braced)) {
  #ifdef SOUND_EFFECTS
  	  play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER);
  #endif
  	  (void) push_ob(tmp,dir,op);
  	}
  
        /* If the object is a boulder or other rollable object, then
         * roll it if not braced.  You can't roll it if you are braced.
         */
!       else if(QUERY_FLAG(tmp,FLAG_CAN_ROLL)&&(!op->contr->braced))
  	  recursive_roll(tmp,dir,op);
  
        /* Any generic living creature.  Including things like doors.
         * Way it works is like this:  First, it must have some hit points
         * and be living.  Then, it must be one of the following:
         * 1) Not a player, 2) A player, but of a different party.  Note
--- 1426,1445 ----
  	op->contr->peaceful && (!op->contr->braced)) {
  #ifdef SOUND_EFFECTS
  	  play_sound_map(op->map, op->x, op->y, SOUND_PUSH_PLAYER);
  #endif
  	  (void) push_ob(tmp,dir,op);
+           if(op->contr->tmp_invis||op->hide) make_visible(op);
  	}
  
        /* If the object is a boulder or other rollable object, then
         * roll it if not braced.  You can't roll it if you are braced.
         */
!       else if(QUERY_FLAG(tmp,FLAG_CAN_ROLL)&&(!op->contr->braced)) {
  	  recursive_roll(tmp,dir,op);
+           if(action_makes_visible(op)) make_visible(op);
+       }
  
        /* Any generic living creature.  Including things like doors.
         * Way it works is like this:  First, it must have some hit points
         * and be living.  Then, it must be one of the following:
         * 1) Not a player, 2) A player, but of a different party.  Note
***************
*** 1466,1476 ****
  #else
  	    (void) attack_ob(op, tmp);
  #endif
  	    tmp->stats.luck = luck;
  	  }
! 	  if(op->contr->tmp_invis||op->hide) make_visible(op);
  	}
      }
  }
  
  int move_player(object *op,int dir) {
--- 1473,1485 ----
  #else
  	    (void) attack_ob(op, tmp);
  #endif
  	    tmp->stats.luck = luck;
  	  }
! 
!           if(action_makes_visible(op)) make_visible(op);
!          
  	}
      }
  }
  
  int move_player(object *op,int dir) {
***************
*** 2829,2833 ****
--- 2838,2904 ----
          return 1;
        else if(tmp->type==PLAYER) return 1;
  
    return 0;
  }
+ 
+ /* check the player los field for viewability of the 
+  * object op. This function works fine for monsters,
+  * but we dont worry if the object isnt the top one in 
+  * a pile (say a coin under a table would return "viewable"
+  * by this routine). Another question, should we be
+  * concerned with the direction the player is looking 
+  * in? Realistically, most of use cant see stuff behind
+  * our backs...on the other hand, does the "facing" direction
+  * imply the way your head, or body is facing? Its possible
+  * for them to differ. Sigh, this fctn could get a bit more complex.
+  * -b.t. */
+ 
+ int player_can_view (object *pl,object *op) {
+ 
+   if(pl->type!=PLAYER) {
+     LOG(llevError,"player_can_view() called for non-player object\n");
+     return -1;
+   }
+ 
+   if(pl&&op&&pl->map==op->map) { 
+     /* starting with the 'head' part, lets loop
+      * through the object and find if it has any
+      * part that is in the los array but isnt on 
+      * a blocked los square. */
+     if(op->head) { op = op->head; }
+     while(op) {
+       if(pl->y + WINUPPER <= op->y && pl->y + WINLOWER >= op->y 
+           && pl->x + WINLEFT <= op->x && pl->x + WINRIGHT >= op->x
+           && !pl->contr->blocked_los[op->x-pl->x+5][op->y-pl->y+5] ) 
+         return 1;
+       op = op->more;
+     }
+   }
+   return 0;
+ }
+ 
+ /* routine for both players and monsters. We call this when
+  * there is a possibility for our action distrubing our hiding
+  * place or invisiblity spell. Artefact invisiblity is not
+  * effected by this. If we arent invisible to begin with, we 
+  * return 0. 
+  */
+ int action_makes_visible (object *op) {
+ 
+   if(op->invisible && QUERY_FLAG(op,FLAG_ALIVE)) 
+     if(!QUERY_FLAG(op,FLAG_MAKE_INVIS)) 
+       return 0; 
+     else if(op->hide || (op->contr&&op->contr->tmp_invis)
+     ) { 
+       new_draw_info_format(NDI_UNIQUE, 0,op,"You become %!",op->hide?"unhidden":"visible");
+       return 1; 
+     } else if(op->contr)  
+         /* improved invis is lost EXCEPT for case of casting of magic */
+         if(!op->contr->shoottype==range_magic) { 
+           new_draw_info(NDI_UNIQUE, 0,op,"Your invisibility spell is broken!");
+           return 1;
+         }
+ 
+   return 0;
+ }
+ 
[to unsubscribe etc., send mail to crossfire-request@ifi.uio.no]