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

Re: Crossfire comments



This should help the problem of balancing.
I working on creating a fairly powerful race, and wanted to balence
them by making it take a lot of experience to advance in level.
Hence the following patch.  As part of the patch, I've also kept notes
on what I had to change to help people who follow.  We might want to
collect all of these notes in some sort of document.
Notes and context diff follow.  This difference allows you to set the
variable expmul, and have the experience neccesary to advance a level
be expmul*old_way();
-----------
To add a new variable expmul:
Edit structs.h to add it to the appropriate structure(living)
Edit loader.h to add it to the enum of variables(varnrs)
Edit loader.c, add it to get_ob_diff so it will be saved,
(I added save_double to loader.c)
Edit set_variable to set the expmul variable
Edit object.c:clear_object to set the default value for the variable
--
Edit the files neccesary to make your change. For me this was:
living.c:level_exp(),add_exp()
libproto.h:level_exp();
map.c:calculate_difficulty();
*** common/living.c-old	Thu Mar  3 17:15:47 1994
--- common/living.c	Thu Mar  3 17:32:39 1994
***************
*** 838,854 ****
   * the given level.
   */
  
! int level_exp(int level) {
    int   count,required_exp;
  
  /*  static int bleep=250000; */
  /* Eneq(@csd.uu.se):  New level-algorithm; level 2 at 1000 then  
     times 2 for all following. */
  
!   if(level<=10) return levels[level];
  
!   for (count=10, required_exp=levels[count];count<level;count++)
!     required_exp*=1.5;
    return required_exp;
  /*    return levels[10]+bleep*(level-10); */
  }
--- 838,861 ----
   * the given level.
   */
  
! int level_exp(int level,double expmul) {
    int   count,required_exp;
  
  /*  static int bleep=250000; */
  /* Eneq(@csd.uu.se):  New level-algorithm; level 2 at 1000 then  
     times 2 for all following. */
  
!   if(level<=10) required_exp = levels[level];
!   else {
!     count=10;
!     required_exp=levels[count];
!     for (;count<level;count++)
!       required_exp*=1.5;
!   }
  
!   if (expmul>0) {
!     return (int)((double)required_exp * expmul);
!   }
    return required_exp;
  /*    return levels[10]+bleep*(level-10); */
  }
***************
*** 874,880 ****
    if(op->stats.exp>99999999)
      op->stats.exp=99999999;
    if(op->type==PLAYER) {
!     if(op->level < 100 && op->stats.exp >= level_exp(op->level+1)) {
        op->level++;
        if(op->level < 11)
        {
--- 881,887 ----
    if(op->stats.exp>99999999)
      op->stats.exp=99999999;
    if(op->type==PLAYER) {
!     if(op->level < 100 && op->stats.exp >= level_exp(op->level+1,op->stats.expmul)) {
        op->level++;
        if(op->level < 11)
        {
***************
*** 887,893 ****
          (*draw_info_func)(op,buf);
        }
        add_exp(op,0); /* To increase more levels */
!     } else if(op->level>1&&op->stats.exp<level_exp(op->level)) {
        op->level--;
        fix_player(op);
        sprintf(buf,"You are now level %d.",op->level);
--- 894,900 ----
          (*draw_info_func)(op,buf);
        }
        add_exp(op,0); /* To increase more levels */
!     } else if(op->level>1&&op->stats.exp<level_exp(op->level,op->stats.expmul)) {
        op->level--;
        fix_player(op);
        sprintf(buf,"You are now level %d.",op->level);
*** common/loader.c-old	Thu Mar  3 16:53:36 1994
--- common/loader.c	Thu Mar  3 17:08:37 1994
***************
*** 36,42 ****
  /* variable_const doesn't appear to be used anyplace except in this
   * file.  Perhaps it should be declared as a static char? 
   */
! char *variable_const[NR_OF_VARIABLES] = {
    "Object","name","race","slaying","msg","endmsg",
    "Inventory","arch","other_arch","More",
    "anim","mina","end","last_heal","last_sp","last_eat",
--- 36,42 ----
  /* variable_const doesn't appear to be used anyplace except in this
   * file.  Perhaps it should be declared as a static char? 
   */
! static char *variable_const[NR_OF_VARIABLES] = {
    "Object","name","race","slaying","msg","endmsg",
    "Inventory","arch","other_arch","More",
    "anim","mina","end","last_heal","last_sp","last_eat",
***************
*** 62,68 ****
    "attack_movement","move_state","confused","stealth","connected",
    "cursed","damned","see_anywhere","known_magical","known_cursed",
    "can_steal","been_applied","title","has_ready_rod","can_use_rod",
!   "has_ready_horn","can_use_horn",
  #ifdef NPC_PROG
    "npc_status","npc_program",
  #endif
--- 62,68 ----
    "attack_movement","move_state","confused","stealth","connected",
    "cursed","damned","see_anywhere","known_magical","known_cursed",
    "can_steal","been_applied","title","has_ready_rod","can_use_rod",
!   "has_ready_horn","can_use_horn","expmul",
  #ifdef NPC_PROG
    "npc_status","npc_program",
  #endif
***************
*** 75,80 ****
--- 75,88 ----
    "green","light_green","grey","brown","yellow","khaki"
  };
  
+ void save_double(char *buf,char *name,double v)
+ {
+   char tbuf[200];
+ 
+   sprintf(tbuf,"%s %lf\n",name,v);
+   strcat(buf,tbuf);
+ }
+ 
  /*
   * Initialises the array of variable-names.  Needed before any
   * objects can be loaded.  Called by init_library().
***************
*** 175,180 ****
--- 183,190 ----
      save_long(buf,variable_const[V_MAXSP],op->stats.maxsp);
    if(op->stats.exp!=op2->stats.exp)
      save_long(buf,variable_const[V_EXP],op->stats.exp);
+   if(op->stats.expmul!=op2->stats.expmul) 
+     save_double(buf,variable_const[V_EXPMUL],op->stats.expmul);
    if(op->stats.food!=op2->stats.food)
      save_long(buf,variable_const[V_FOOD],op->stats.food);
    if(op->stats.dam!=op2->stats.dam)
***************
*** 699,704 ****
--- 709,717 ----
      break;
    case V_EXP:
      op->stats.exp=(signed long) value;
+     break;
+   case V_EXPMUL:
+     sscanf(vbp,"%lf",&op->stats.expmul);
      break;
    case V_FOOD:
      op->stats.food=(signed short) value;
*** common/map.c-old	Thu Mar  3 17:19:02 1994
--- common/map.c	Thu Mar  3 17:19:20 1994
***************
*** 1286,1292 ****
  #ifdef NEWCALC
    (int)exp_pr_sq=((double)1000*total_exp)/(m->mapx*m->mapy+1);
    for(i=20;i>0;i--)
!     if(exp_pr_sq>level_exp(i)) {
        diff=i;
        break;
      }
--- 1286,1292 ----
  #ifdef NEWCALC
    (int)exp_pr_sq=((double)1000*total_exp)/(m->mapx*m->mapy+1);
    for(i=20;i>0;i--)
!     if(exp_pr_sq>level_exp(i,1.0)) {
        diff=i;
        break;
      }
***************
*** 1294,1300 ****
    exp_pr_sq=((double)1000*total_exp)/(m->mapx*m->mapy+1);
    diff=20;
    for(i=1;i<20;i++)
!     if(exp_pr_sq<=level_exp(i)) {
        diff=i;
        break;
      }
--- 1294,1300 ----
    exp_pr_sq=((double)1000*total_exp)/(m->mapx*m->mapy+1);
    diff=20;
    for(i=1;i<20;i++)
!     if(exp_pr_sq<=level_exp(i,1.0)) {
        diff=i;
        break;
      }
*** common/object.c-old	Thu Mar  3 17:11:21 1994
--- common/object.c	Thu Mar  3 17:11:03 1994
***************
*** 315,320 ****
--- 315,321 ----
    op->stats.luck=0;
    op->stats.food=0;
    op->stats.sp=op->stats.maxsp=op->stats.hp=op->stats.maxhp=0;
+   op->stats.expmul=1.0;
    op->direction=0;
  #ifdef NPC_PROG
    op->npc_status=0;
*** include/libproto.h-old	Thu Mar  3 17:16:35 1994
--- include/libproto.h	Thu Mar  3 17:16:50 1994
***************
*** 167,173 ****
  extern int is_magical ( object *op );
  extern object *is_player_inv ( object *op );
  extern int legal_artifact_combination ( object *op, int table, int index );
! extern int level_exp ( int level );
  extern object *LoadObject ( FILE *fp );
  extern void load_archetypes ( void );
  extern int load_object ( FILE *fp, object *op );
--- 167,173 ----
  extern int is_magical ( object *op );
  extern object *is_player_inv ( object *op );
  extern int legal_artifact_combination ( object *op, int table, int index );
! extern int level_exp ( int level,double expmul);
  extern object *LoadObject ( FILE *fp );
  extern void load_archetypes ( void );
  extern int load_object ( FILE *fp, object *op );
*** include/loader.h-old	Thu Mar  3 16:59:58 1994
--- include/loader.h	Thu Mar  3 17:02:33 1994
***************
*** 53,59 ****
    V_ATT_MOVE,V_MOVE_STATUS,V_CONFUSED,V_STEALTH,V_CONNECTED,
    V_CURSED,V_DAMNED,V_SEE_ANYWHERE,V_KNOWN_MAGICAL,V_KNOWN_CURSED,
    V_CAN_STEAL,V_BEEN_APPLIED,V_TITLE,V_HAS_READY_ROD,V_CAN_USE_ROD,
!   V_HAS_READY_HORN,V_CAN_USE_HORN,
  #ifdef NPCPROG
    V_NPC_STATUS,V_NPC_PROGRAM,
  #endif
--- 53,59 ----
    V_ATT_MOVE,V_MOVE_STATUS,V_CONFUSED,V_STEALTH,V_CONNECTED,
    V_CURSED,V_DAMNED,V_SEE_ANYWHERE,V_KNOWN_MAGICAL,V_KNOWN_CURSED,
    V_CAN_STEAL,V_BEEN_APPLIED,V_TITLE,V_HAS_READY_ROD,V_CAN_USE_ROD,
!   V_HAS_READY_HORN,V_CAN_USE_HORN,V_EXPMUL,
  #ifdef NPCPROG
    V_NPC_STATUS,V_NPC_PROGRAM,
  #endif
*** include/structs.h-old	Thu Mar  3 16:39:54 1994
--- include/structs.h	Thu Mar  3 16:50:30 1994
***************
*** 52,57 ****
--- 52,60 ----
    signed short sp;      /* Spell points.  Used to cast spells. */
    signed short maxsp;	/* Max spell points. */
    signed long exp;      /* Experience.  Killers gain 1/10. */
+ /* These two modifications will allow classes which have different
+    experience requirements for advancement */
+   double expmul;        /* needed experience = (calc_exp*expmul) */
    signed short food;    /* How much food in stomach.  0 = starved. */
    signed char dam;	/* How much damage this object does when hitting */
    signed char luck;	/* Affects thaco and ac from time to time */