viewing paste topic/4418- vending tax ally | Diff

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
 conf/battle/items.conf |  3 +++
 src/map/battle.c       |  1 +
 src/map/battle.h       |  1 +
 src/map/vending.c      | 28 ++++++++++++++++++++++++----
 4 files changed, 29 insertions(+), 4 deletions(-)
 
diff --git a/conf/battle/items.conf b/conf/battle/items.conf
index 3a4eb80..683438b 100644
--- a/conf/battle/items.conf
+++ b/conf/battle/items.conf
@@ -21,6 +21,9 @@ vending_over_max: yes
 // the vender will not get the whole price paid (they get 100% - this tax).
 vending_tax: 200
 
+// Tax apply to vender.
+vending_tax_ally: 5000
+
 // Show the buyer's name when successfully vended an item
 buyer_name: yes
 
diff --git a/src/map/battle.c b/src/map/battle.c
index 1a04aef..f2771e8 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -6555,6 +6555,7 @@ bool battle_check_range(struct block_list *src, struct block_list *bl, int range
    { "homunculus_show_growth",             &battle_config.homunculus_show_growth,          0,      0,      1,              },
    { "homunculus_friendly_rate",           &battle_config.homunculus_friendly_rate,        100,    0,      INT_MAX,        },
    { "vending_tax",                        &battle_config.vending_tax,                     0,      0,      10000,          },
+   { "vending_tax_ally",                   &battle_config.vending_tax_ally,                0,      0,      10000,          },
    { "day_duration",                       &battle_config.day_duration,                    0,      0,      INT_MAX,        },
    { "night_duration",                     &battle_config.night_duration,                  0,      0,      INT_MAX,        },
    { "mob_remove_delay",                   &battle_config.mob_remove_delay,                60000,  1000,   INT_MAX,        },
diff --git a/src/map/battle.h b/src/map/battle.h
index 0fcef72..bbc7878 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -254,6 +254,7 @@ struct Battle_Config {
    int vending_max_value;
    int vending_over_max;
    int vending_tax;
+   int vending_tax_ally; 
    int show_steal_in_same_party;
    int party_share_type;
    int party_hp_mode;
diff --git a/src/map/vending.c b/src/map/vending.c
index 78bc79a..2ba20f5 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -159,10 +159,30 @@ void vending_purchasereq(struct map_session_data* sd, int aid, unsigned int uid,
        }
    }
 
-   pc->payzeny(sd, (int)z, LOG_TYPE_VENDING, vsd);
-   if( battle_config.vending_tax )
-       z -= z * (battle_config.vending_tax/10000.);
-   pc->getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd);
+   {
+       struct guild * g = guild->search( sd->status.guild_id );
+       if ( !g ) { // this is seriously needed to prevent map-server crash when the buyer doesn't have a guild
+           pc->payzeny(sd, (int)z, LOG_TYPE_VENDING, vsd);
+           if( battle_config.vending_tax )
+               z -= z * (battle_config.vending_tax/10000.);
+           pc->getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd);
+       }
+       else {
+           ARR_FIND( 0, MAX_GUILDALLIANCE, i, vsd->status.guild_id == g->alliance[i].guild_id );
+           if ( vsd->status.guild_id == sd->status.guild_id || i < MAX_GUILDALLIANCE ) {
+               pc->payzeny(sd, (int)z, LOG_TYPE_VENDING, vsd);
+               if( battle_config.vending_tax_ally )
+                   z -= z * (battle_config.vending_tax_ally/10000.);
+               pc->getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd);
+           }
+           else {
+               pc->payzeny(sd, (int)z, LOG_TYPE_VENDING, vsd);
+               if( battle_config.vending_tax )
+                   z -= z * (battle_config.vending_tax/10000.);
+               pc->getzeny(vsd, (int)z, LOG_TYPE_VENDING, sd);
+           }
+       }
+   }
 
    for( i = 0; i < count; i++ ) {
        short amount = *(uint16*)(data + 4*i + 0);
 
Viewed 1314 times, submitted by AnnieRuru.