[CF-Devel] stat potions: patch/question

crossfire-devel at archives.real-time.com crossfire-devel at archives.real-time.com
Tue Mar 9 15:52:44 CST 2004


I noticed a bug:
If a natural stat gets below 1, one can no longer
raise it with stat potions.

It is possible to get to 0, if you drink too many
cursed stat potions.
You can even have a negative natural starting stat due to
negative class modificators.
Example: start int 9 -> quez,int 9-8 = 1 -> barbarian, int 1-6 = -5.

With this patch one can now raise these stats with potions.
Furthermore cursed potions no longer drain you below 1.

Now for the question:

In the original code tmp->stats.sp (the potions spellpoints)
is used in the if condition,then set to 0 if a stat is changed.

As i do not understand the intention for /* Fix it up for super potions */
, i can not emulate the desired behavior.

I do know, that this stuff has no relevance to normal stat potions,as
their sp is o anyway.

So if somebody can explain that, i can finish this patch.
-------------- next part --------------
Index: common/living.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/common/living.c,v
retrieving revision 1.60
diff -c -r1.60 living.c
*** common/living.c	27 Feb 2004 23:00:26 -0000	1.60
--- common/living.c	9 Mar 2004 20:50:25 -0000
***************
*** 355,364 ****
   * that gives them that ability.
   */
  int change_abil(object *op, object *tmp) {
!   int flag=QUERY_FLAG(tmp,FLAG_APPLIED)?1:-1,i,j,success=0;
    object refop;
    char message[MAX_BUF];
!   int potion_max=0;
    
    /* remember what object was like before it was changed.  note that
     * refop is a local copy of op only to be used for detecting changes
--- 355,366 ----
   * that gives them that ability.
   */
  int change_abil(object *op, object *tmp) {
!   int flag=QUERY_FLAG(tmp,FLAG_APPLIED)?1:-1;
!   int i,j,potion,newstat,success=0;
    object refop;
    char message[MAX_BUF];
!   int potion_worked=0;
! 
    
    /* remember what object was like before it was changed.  note that
     * refop is a local copy of op only to be used for detecting changes
***************
*** 369,390 ****
      if (tmp->type==POTION) {
        for(j=0;j<NUM_STATS;j++) {
          i = get_attr_value(&(op->contr->orig_stats),j);
! 
! 	/* Check to see if stats are within limits such that this can be
! 	 * applied.
! 	 */
!         if (((i+flag*get_attr_value(&(tmp->stats),j))<=
! 	    (20+tmp->stats.sp + get_attr_value(&(op->arch->clone.stats),j)))
! 	    && i>0)
! 	{
!             change_attr_value(&(op->contr->orig_stats),j,
!                           flag*get_attr_value(&(tmp->stats),j));
! 	    tmp->stats.sp=0;/* Fix it up for super potions */
! 	}
! 	else {
! 	  /* potion is useless - player has already hit the natural maximum */
! 	  potion_max = 1;
! 	}
        }
      /* This section of code ups the characters normal stats also.  I am not
       * sure if this is strictly necessary, being that fix_player probably
--- 371,390 ----
      if (tmp->type==POTION) {
        for(j=0;j<NUM_STATS;j++) {
          i = get_attr_value(&(op->contr->orig_stats),j);
!         potion = flag*get_attr_value(&(tmp->stats),j);
!         printf("sp:%d,pot:%d,stat:%d\n",tmp->stats.sp,potion,i);
!         newstat=i+potion;
!         if (potion<0) { /* stat drain */
!           if (i<1) continue; /* No miracle cure for negative starting stats */
!           else if (newstat<1) newstat=1; /* No drain below 1 */
!         }
!         else if (newstat>20+get_attr_value(&(op->arch->clone.stats),j))
!           newstat=20+get_attr_value(&(op->arch->clone.stats),j);
!         if ( newstat != i ) {
!           set_attr_value(&(op->contr->orig_stats),j,newstat);
!           potion_worked=1;
!           tmp->stats.sp=0;/* Fix it up for super potions (what is this?,b.e.) */
!         }
        }
      /* This section of code ups the characters normal stats also.  I am not
       * sure if this is strictly necessary, being that fix_player probably
***************
*** 614,621 ****
      }
    }
  
!      if(tmp->type!=EXPERIENCE && !potion_max) {
! 	for (j=0; j<NUM_STATS; j++) {
  	    if ((i=get_attr_value(&(tmp->stats),j))!=0) {
  		success=1;
  		if (i * flag > 0)
--- 614,621 ----
      }
    }
  
!     if(tmp->type!=EXPERIENCE && potion_worked) {
! 	  for (j=0; j<NUM_STATS; j++) {
  	    if ((i=get_attr_value(&(tmp->stats),j))!=0) {
  		success=1;
  		if (i * flag > 0)
***************
*** 623,629 ****
  		else
  		    (*draw_info_func)(NDI_UNIQUE, 0, op, lose_msg[j]);
  	    }
! 	}
      }
      return success;
  }
--- 623,629 ----
  		else
  		    (*draw_info_func)(NDI_UNIQUE, 0, op, lose_msg[j]);
  	    }
! 	  }
      }
      return success;
  }
-------------- next part --------------
_______________________________________________
crossfire-devel mailing list
     
     crossfire-devel at lists.real-time.com
     
     
     https://mailman.real-time.com/mailman/listinfo/crossfire-devel
     
     
    


More information about the crossfire mailing list