[CF-Devel] patch:Bargaining experience

crossfire-devel at archives.real-time.com crossfire-devel at archives.real-time.com
Thu Nov 13 06:44:26 CST 2003


On Mon, 10 Nov 2003, Mark Wedel wrote:

>
     
      No longer is there code which straight out says
     
     >
     
      'if you have an 18 int, you get 10% more exp'.
     
     >
     
     
     >
     
        For bargaining, it is a bit odd, because there is no failure/success chance.
     
     >
     
      However, one could certainly be added in - the level of the shop could be used
     
     >
     
      as the basis of how hard it is to bargain against (better shop = harder bargaining).
     
     >
     
     
     >
     
        With that, the query_cost could then do something like always return the value
     
     >
     
      of the item without any bargaining going into effect.  Then when you buy/sell
     
     >
     
      something, it could see if you were successful (and how successfull - higher
     
     >
     
      success = more savings = more exp), and print out a message like 'you saved X
     
     >
     
      gold through your clever bargaining'.  And in that model, that characters
     
     >
     
      charisma adjustment would aid in the chance of success.
     
     >
     
     
     Thus you say :

 5% constant cha bargain -> more exp  NOT ok.

 10% chance of 50% bargain -> more exp  IS ok.

althogh the experience gained due to charisma is the same in both cases?

Anyway, this new patch does not grant exp from charisma.
And it does no longer meddle with the player's stats.
One get's 1 exp per silver saved buying,
and 1 exp per gold gained selling.

The expmul issue seems to be solved of cvs.
Although i'd rather change the gained exp, than the level requirements.
If someone wanted to use expmul, he now has to make sure, not to step
over maxint64 for maxlevel.
OTOH, this way,a different expmul is more transparent to the players.

-------------- next part --------------
*** include/define.h~	Thu Nov 13 11:35:18 2003
--- include/define.h	Wed Nov 12 17:53:43 2003
***************
*** 603,608 ****
--- 603,609 ----
  #define F_BUY 0
  #define F_SELL 1
  #define F_TRUE 2	/* True value of item, unadjusted */
+ #define F_BARGAIN 4/* combine with F_BUY or F_SELL to disable bargaining calc */
  
  #define DIRX(xyz)	freearr_x[(xyz)->direction]
  #define DIRY(xyz)	freearr_y[(xyz)->direction]
-------------- next part --------------
*** server/shop.c~	Thu Nov 13 12:13:51 2003
--- server/shop.c	Wed Nov 12 19:45:13 2003
***************
*** 59,65 ****
  int query_cost(object *tmp, object *who, int flag) {
    int val;
    int number;	/* used to better calculate value */
!   int charisma;
  
    if (tmp->type==MONEY) return (tmp->nrof * tmp->value);
    if (tmp->type==GEM) {
--- 59,70 ----
  int query_cost(object *tmp, object *who, int flag) {
    int val;
    int number;	/* used to better calculate value */
!   int no_bargain;
!   float diff;
!   float ratio;
! 
!   no_bargain = flag & F_BARGAIN;
!   if (no_bargain) flag = flag - F_BARGAIN;
  
    if (tmp->type==MONEY) return (tmp->nrof * tmp->value);
    if (tmp->type==GEM) {
***************
*** 146,174 ****
      }
    }
  
! /* this  modification is for merchant skill
!  * now players with readied merchant skill get
!  * more Cha up to the limit of modified Cha = 30.
!  * -b.t. 
     
     thomas at nomad.astro.psu.edu
     
     
   */
  
    if (who!=NULL && who->type==PLAYER) {
!       float diff;
! 
!       charisma = who->stats.Cha;  /* used for SK_BARGAINING modification */
  
        if (find_skill_by_number(who,SK_BARGAINING)) {
! 	charisma += (who->level+2)/3;
! 	if(charisma>30) charisma = 30;
!       }
!       if (cha_bonus[charisma]<=1.0) {
! 	LOG(llevError,"Illegal charisma bonus, %d <=1.0", cha_bonus[charisma]);
! 	diff=0.9;	/*pretty bad case */
        }
        else
! 	/* Diff is now a float between 0 and 1 */
! 	diff=(cha_bonus[charisma]-1)/(1+cha_bonus[charisma]);
! 
        /* we need to multiply these by 4.0 to keep buy costs roughly the same
         * (otherwise, you could buy a potion of charisma for around 400 pp.
         * Arguable, the costs in the archetypes should be updated to better
--- 151,182 ----
      }
    }
  
! /* This modification is for bargaining skill.
!  * Now only players with max level in bargaining
!  * AND Cha = 30 will get optimal price.
!  * Thus charisma will never get useless.
!  * -b.e. 
     
     edler at heydernet.de
     
     
   */
  
    if (who!=NULL && who->type==PLAYER) {
!       ratio = 0.5;
!       /* ratio determines how much of the price modification
!        * will come from the basic stat charisma
!        * the rest will come from the level in bargaining skill
!        */
!       int lev_bargain = 0;
  
        if (find_skill_by_number(who,SK_BARGAINING)) {
!         lev_bargain = find_skill_by_number(who,SK_BARGAINING)->level;
        }
+       if ( (no_bargain==0)  && (lev_bargain>0) )
+         diff = (0.8 - 0.6*((lev_bargain+settings.max_level*0.05)
+                          /(settings.max_level*1.05)));
        else
!         diff = 0.8;
!       diff *= 1-ratio;
! 	/* Diff is now a float between 0.2 and 0.8 */
! 	diff+=(cha_bonus[who->stats.Cha]-1)/(1+cha_bonus[who->stats.Cha])*ratio;
        /* we need to multiply these by 4.0 to keep buy costs roughly the same
         * (otherwise, you could buy a potion of charisma for around 400 pp.
         * Arguable, the costs in the archetypes should be updated to better
***************
*** 325,334 ****
--- 334,353 ----
  int pay_for_item(object *op,object *pl) {
      int to_pay = query_cost(op,pl,F_BUY);
      object *pouch;
+     int saved_money;
  
      if (to_pay==0) return 1;
      if(to_pay>query_money(pl)) return 0;
  
+     /* We compare the paid price with the one for a player
+      * without bargaining skill.
+      * This determins the amount of exp (if any) gained for bargaining.
+      */
+     saved_money = query_cost(op,pl,F_BUY | F_BARGAIN) - to_pay;
+ 
+     if (saved_money > 0)
+       change_exp(pl,saved_money,"bargaining",SK_EXP_NONE);
+ 
      to_pay = pay_from_container(op, pl, to_pay);
  
      for (pouch=pl->inv; (pouch!=NULL) && (to_pay>0); pouch=pouch->below) {
***************
*** 517,522 ****
--- 536,542 ----
    object *tmp;
    object *pouch;
    archetype *at;
+   int extra_gain;
  
    if(pl==NULL||pl->type!=PLAYER) {
      LOG(llevDebug,"Object other than player tried to sell something.\n");
***************
*** 537,542 ****
--- 557,572 ----
      identify(op);
      return;
    }
+   /* We compare the price with the one for a player
+    * without bargaining skill.
+    * This determins the amount of exp (if any) gained for bargaining.
+    * exp/10 -> 1 for each gold coin
+    */
+   extra_gain = i - query_cost(op,pl,F_SELL | F_BARGAIN);
+ 
+   if (extra_gain > 0)
+     change_exp(pl,extra_gain/10,"bargaining",SK_EXP_NONE);
+   
    for (count=0; coins[count]!=NULL; count++) {
        at = find_archetype(coins[count]);
        if (at==NULL) LOG(llevError, "Could not find %s archetype", coins[count]);
-------------- 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