viewing paste Unknown #17531 | Diff

Posted on the
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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
commit 481536dc894bfe2c91793ca8cea85186cbfb13d8
Author: Milk <welcomerooot@gmail.com>
Date:   Mon Nov 24 15:00:43 2014 +0500
 
    Added bg_consume mapflag
 
diff --git a/npc/battleground/bg_supply.txt b/npc/battleground/bg_supply.txt
new file mode 100644
index 0000000..50ee426
--- /dev/null
+++ b/npc/battleground/bg_supply.txt
@@ -0,0 +1,94 @@
+//===== eAthena Script =======================================
+//= BattleGround Supplier
+//===== By: ==================================================
+//= Brian
+//===== Current Version: =====================================
+//= 1.0
+//===== Compatible With: =====================================
+//= eAthena SVN (+ source edits)
+//===== Description: =========================================
+//= Sells consumables that can ONLY be used on 'bg_consume' maps.
+//===== Additional Comments: =================================
+//= http://www.eathena.ws/board/index.php?showtopic=268355
+//= 1. To use, create a char named "Battleground"
+//= 2. edit the #define BG_CHARID in battleground.h
+//= 3. edit the 'set .@BG_CHARID' in this file (line 43)
+//============================================================
+
+bat_room,165,146,3     script  Telma   701,{
+       mes "[Telma]";
+       mes "Welcome, mighty warrior.";
+       mes "Do you need supplies for your battles?";
+       mes "I can exchange supplies for your badges...";
+       next;
+      
+       switch(select("150 Battleground's Condensed White Potion:90 Battleground's Blue Potion:3 Battleground's Poison Bottle:30 Battleground's Fire Bottle:30 Battleground's Acid Bottle:30 Battleground's Plant Bottle:30 Battleground's Marine Sphere Bottle:15 Battleground's Glistening Coat:50 Battleground's Yellow Gemstone:50 Battleground's Red Gemstone:100 Battleground's Blue Gemstone:5 Battleground's Speed Potion:20 Battleground's Cobweb")) {
+               case 1:         callsub S_BuyConsumableBG,547,150;      // Condensed White Potion
+               case 2:         callsub S_BuyConsumableBG,505,90;       // Blue Potion
+               case 3:         callsub S_BuyConsumableBG,678,3;        // Poison Bottle
+               case 4:         callsub S_BuyConsumableBG,7135,30;      // Fire Bottle
+               case 5:         callsub S_BuyConsumableBG,7136,30;      // Acid Bottle
+               case 6:         callsub S_BuyConsumableBG,7137,30;      // Plant Bottle
+               case 7:         callsub S_BuyConsumableBG,7138,30;      // Marine Sphere Bottle
+               case 8:         callsub S_BuyConsumableBG,7139,15;      // Glistening Coat
+               case 9:         callsub S_BuyConsumableBG,715,50;       // Yellow Gemstone
+               case 10:        callsub S_BuyConsumableBG,716,50;       // Red Gemstone
+               case 11:        callsub S_BuyConsumableBG,717,100;      // Blue Gemstone
+               case 12:        callsub S_BuyConsumableBG,12016,5;      // Speed Potion
+               case 13:        callsub S_BuyConsumableBG,1025,20;      // Cobweb
+       }
+       end;
+
+S_BuyConsumableBG:
+       set .@BG_CHARID, 165100; // character named "Battleground"
+S_BuyConsumable:
+       set .@item_id, getarg(0);
+       set .@amt, getarg(1);
+      
+       mes "[Telma]";
+       mes "How many sets of ^0000FF"+ .@amt +" "+ getitemname(.@item_id) +"s^000000 do you want?";
+       mes "1 = "+ .@amt   +" supplies = 1 badge";
+       mes "2 = "+ .@amt*2 +" supplies = 2 badges";
+       mes "3 = "+ .@amt*3 +" supplies = 3 badges";
+       mes "etc..";
+       next;
+       input .@sets;
+       mes "[Telma]";
+       if (.@sets < 1) {
+               mes "Enter a positive amount, greater than zero.";
+               close;
+       }
+       mes "So you want ^0000FF"+ (.@amt*.@sets) +" "+ getitemname(.@item_id) +"s^000000...";
+       if (.@BG_CHARID) mes "Remember these can only be used in Battlegrounds.";
+       mes "It will cost you "+ .@sets +" badge(s)...";
+       next;
+       switch(select("Give her "+ .@sets +" Bravery Badge(s):Give her "+ .@sets +" Valor Badge(s):Give her "+ (3*.@sets) +" Heroism Badges")) {
+               case 1: set .@badge,7828; set .@cost,1; break;
+               case 2: set .@badge,7829; set .@cost,1; break;
+               case 3: set .@badge,7773; set .@cost,3; break;
+       }
+       mes "[Telma]";
+       if (countitem(.@badge) < (.@cost*.@sets)) {
+               mes "You do not have enough ^FF0000"+getitemname(.@badge)+"s^000000 to buy "+(.@amt*.@sets)+" "+getitemname(.@item_id)+"s.";
+       } else if (!checkweight(.@item_id, .@amt*.@sets)) {
+               mes "You are overweight or have too many items in your inventory.";
+       } else {
+               delitem .@badge, .@cost*.@sets;
+               if (.@BG_CHARID) { // Battleground's Consumables
+                       getitem2 .@item_id,(.@amt*.@sets),1,0,0, 254, 0, .@BG_CHARID & 0xFFFF, .@BG_CHARID >> 0x10;
+               } else {
+                       getitem .@item_id,(.@amt*.@sets);
+               }
+               mes "Here are your: ^0000FF"+(.@amt*.@sets)+" "+getitemname(.@item_id)+"s^000000!";
+               if (.@BG_CHARID) mes "Remember, they can only be used in Battlegrounds.";
++      }
+       close;
+}
+
+bat_a01        mapflag bg_consume
+bat_a02        mapflag bg_consume
+bat_b01        mapflag bg_consume
+bat_b02        mapflag bg_consume
+bat_c01        mapflag bg_consume
+bat_c02        mapflag bg_consume
+bat_c03        mapflag bg_consume
\ No newline at end of file
diff --git a/npc/scripts.conf b/npc/scripts.conf
index d81d76e..0dfb53d 100644
--- a/npc/scripts.conf
+++ b/npc/scripts.conf
@@ -33,6 +33,7 @@ npc: npc/battleground/tierra/tierra01.txt
 npc: npc/battleground/tierra/tierra02.txt
 // --------------------------------------------------------------
 npc: npc/battleground/bg_common.txt
+npc: npc/battleground/bg_supply.txt
 
 // --------------------------- Cities ---------------------------
 npc: npc/cities/alberta.txt
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 254da5c..bbb2c7f 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -3711,7 +3711,10 @@ ACMD(mapinfo) {
                clif->message(fd, msg_txt(1044)); // Autotrade Disabled
 
        if (map->list[m_id].flag.battleground)
-               clif->message(fd, msg_txt(1045)); // Battlegrounds ON
+               strcat(atcmd_output, "Battlegrounds ON | ");
+       if (map->list[m_id].flag.bg_consume) // bg_consume mapflag
+               strcat(atcmd_output, "BG items ON | ");
+       clif->message(fd, atcmd_output);
 
        strcpy(atcmd_output,msg_txt(1046)); // PvP Flags:
        if (map->list[m_id].flag.pvp)
diff --git a/src/map/battleground.h b/src/map/battleground.h
index c1d3be0..4881b85 100644
--- a/src/map/battleground.h
+++ b/src/map/battleground.h
@@ -13,6 +13,8 @@
  * Defines
  **/
 #define MAX_BG_MEMBERS 30
+#define BG_CHARID 165100
+#define BG_TRADE 91
 #define BG_DELAY_VAR_LENGTH 30
 
 /**
diff --git a/src/map/clif.c b/src/map/clif.c
index 950898b..b0f00f7 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -1852,7 +1852,10 @@ void clif_selllist(struct map_session_data *sd)
 
                        if( sd->status.inventory[i].expire_time )
                                continue; // Cannot Sell Rental Items
-
+
+                       if( sd->status.inventory[i].card[0]== CARD0_CREATE && MakeDWord(sd->status.inventory[i].card[2],sd->status.inventory[i].card[3])== BG_CHARID && BG_TRADE &8 )
+                               continue; // "Battleground's Items"
+
                        if( sd->status.inventory[i].bound && !pc_can_give_bound_items(sd))
                                continue; // Don't allow sale of bound items
 
diff --git a/src/map/map.h b/src/map/map.h
index bb6e43a..0328d06 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -619,6 +619,7 @@ struct map_data {
                unsigned gvg_dungeon : 1; // Celest
                unsigned gvg_noparty : 1;
                unsigned battleground : 2; // [BattleGround System]
+               unsigned bg_consume : 1; // allows using Battleground's items
                unsigned nozenypenalty : 1;
                unsigned notrade : 1;
                unsigned noskill : 1;
diff --git a/src/map/npc.c b/src/map/npc.c
index ce668bf..590eebf 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -3788,6 +3788,8 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
                        map->zone_change(m,zone,start,buffer,filepath);
                }
        }
+       else if (!strcmpi(w3,"bg_consume"))
+               map->list[m].flag.bg_consume=state;
        else if (!strcmpi(w3,"noexppenalty"))
                map->list[m].flag.noexppenalty=state;
        else if (!strcmpi(w3,"nozenypenalty"))
diff --git a/src/map/pc.c b/src/map/pc.c
index 6ba06c8..ce1cf71 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -368,6 +368,8 @@ unsigned char pc_famerank(int char_id, int job)
                        for(i = 0; i < MAX_FAME_LIST; i++){
                                if(pc->chemist_fame_list[i].id == char_id)
                                        return i + 1;
+                               // else if(BG_CHARID == char_id)
+                                       // return 5;
                        }
                        break;
                case MAPID_TAEKWON: // Taekwon
@@ -4508,6 +4510,13 @@ int pc_useitem(struct map_session_data *sd,int n) {
        if( nameid == ITEMID_BRANCH_OF_DEAD_TREE || nameid == ITEMID_BLOODY_DEAD_BRANCH || nameid == ITEMID_PORING_BOX )
                logs->branch(sd);
       
+       // "Battleground's items" can only be used on maps with 'bg_consume' mapflag
+       if( sd->status.inventory[n].card[0] == CARD0_CREATE &&
+           MakeDWord(sd->status.inventory[n].card[2],sd->status.inventory[n].card[3]) == BG_CHARID &&
+           !map->list[sd->bl.m].flag.bg_consume
+       )
+               return 0;
+
        sd->itemid = sd->status.inventory[n].nameid;
        sd->itemindex = n;
        if(sd->catch_target_class != -1) //Abort pet catching.
@@ -4577,6 +4586,12 @@ int pc_cart_additem(struct map_session_data *sd,struct item *item_data,int amoun
                return 1;/* TODO: there is no official response to this? */
        }
 
+       if( item_data->card[0]== CARD0_CREATE && MakeDWord(item_data->card[2],item_data->card[3]) == BG_CHARID && BG_TRADE&16 )
+       {       // "Battleground's Items"
+               clif->message (sd->fd, msg_txt(264));
+               return 1;
+       }
+
        if( (w = data->weight*amount) + sd->cart_weight > sd->cart_weight_max )
                return 1;
 
@@ -8319,6 +8334,8 @@ int pc_candrop(struct map_session_data *sd, struct item *item)
                return 0;
        if( !pc_can_give_items(sd) ) //check if this GM level can drop items
                return 0;
+       if( item->card[0] == CARD0_CREATE && MakeDWord(item->card[2],item->card[3]) == BG_CHARID && BG_TRADE&1 )
+               return 0;
        return (itemdb_isdropable(item, pc_get_group_level(sd)));
 }
 /**
diff --git a/src/map/skill.c b/src/map/skill.c
index 169f4bc..9bb0f7e 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -13802,7 +13802,11 @@ int skill_check_condition_castend(struct map_session_data* sd, uint16 skill_id,
                if( !require.itemid[i] )
                        continue;
                index[i] = pc->search_inventory(sd,require.itemid[i]);
-               if (index[i] == INDEX_NOT_FOUND || sd->status.inventory[index[i]].amount < require.amount[i]) {
+               if( index[i] < 0 || sd->status.inventory[index[i]].amount < require.amount[i] ||
+                  (sd->status.inventory[index[i]].card[0] == CARD0_CREATE &&
+                   MakeDWord(sd->status.inventory[index[i]].card[2],sd->status.inventory[index[i]].card[3]) == BG_CHARID &&
+                   !map->list[sd->bl.m].flag.bg_consume) // "Battleground's items" can only be used on maps with 'bg_consume' mapflag
+               ) {
                        useskill_fail_cause cause = USESKILL_FAIL_NEED_ITEM;
                        switch( skill_id ){
                                case NC_SILVERSNIPER:
diff --git a/src/map/storage.c b/src/map/storage.c
index 755f50c..441bfa3 100644
--- a/src/map/storage.c
+++ b/src/map/storage.c
@@ -18,12 +18,14 @@
 #include "intif.h"
 #include "itemdb.h"
 #include "log.h"
+#include "battleground.h"
 #include "map.h" // struct map_session_data
 #include "pc.h"
 #include "../common/cbasetypes.h"
 #include "../common/db.h"
 #include "../common/malloc.h"
 #include "../common/nullpo.h"
+#include "../common/utils.h"
 
 struct storage_interface storage_s;
 struct guild_storage_interface gstorage_s;
@@ -147,6 +149,12 @@ int storage_additem(struct map_session_data* sd, struct item* item_data, int amo
                return 1;
        }
 
+       if( item_data->card[0] == CARD0_CREATE && MakeDWord(item_data->card[2],item_data->card[3]) == BG_CHARID && BG_TRADE&32 )
+       {       // "Battleground's Items"
+               clif->message (sd->fd, msg_txt(264));
+               return 1;
+       }
+
        if( itemdb->isstackable2(data) )
        {//Stackable
                for( i = 0; i < MAX_STORAGE; i++ )
@@ -442,6 +450,12 @@ int guild_storage_additem(struct map_session_data* sd, struct guild_storage* sto
                return 1;
        }
 
+       if( item_data->card[0] == CARD0_CREATE && MakeDWord(item_data->card[2],item_data->card[3]) == BG_CHARID && BG_TRADE&64 )
+       {       // "Battleground's Items"
+               clif->message (sd->fd, msg_txt(264));
+               return 1;
+       }
+
        if(itemdb->isstackable2(data)){ //Stackable
                for(i=0;i<MAX_GUILD_STORAGE;i++){
                        if(compare_item(&stor->items[i], item_data)) {
diff --git a/src/map/trade.c b/src/map/trade.c
index 4d69099..aeae7d7 100644
--- a/src/map/trade.c
+++ b/src/map/trade.c
@@ -16,6 +16,7 @@
 #include "intif.h"
 #include "itemdb.h"
 #include "log.h"
+#include "battleground.h"
 #include "map.h"
 #include "npc.h"
 #include "path.h"
@@ -23,6 +24,7 @@
 #include "storage.h"
 #include "../common/nullpo.h"
 #include "../common/socket.h"
+#include "../common/utils.h"
 
 struct trade_interface trade_s;
 
@@ -377,6 +379,14 @@ void trade_tradeadditem(struct map_session_data *sd, short index, short amount)
                return;
        }
 
+       if( item->card[0]== CARD0_CREATE && MakeDWord(item->card[2],item->card[3]) == BG_CHARID && BG_TRADE&2 &&
+               (pc->get_partner(sd) != target_sd || BG_TRADE&4) )
+       {       // "Battleground's Items"
+               clif->message (sd->fd, msg_txt(260));
+               clif->tradeitemok(sd, index+2, 1);
+               return;
+       }
+
        //Locate a trade position
        ARR_FIND( 0, 10, trade_i, sd->deal.item[trade_i].index == index || sd->deal.item[trade_i].amount == 0 );
        if( trade_i == 10 ) //No space left
diff --git a/src/map/vending.c b/src/map/vending.c
index bd61d48..bd0869a 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -262,7 +262,8 @@ void vending_openvending(struct map_session_data* sd, const char* message, const
                 || sd->status.cart[index].attribute == 1 // broken item
                 || sd->status.cart[index].expire_time // It should not be in the cart but just in case
                 || (sd->status.cart[index].bound && !pc_can_give_bound_items(sd)) // can't trade bound items w/o permission
-                || !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) ) // untradeable item
+                || !itemdb_cantrade(&sd->status.cart[index], pc_get_group_level(sd), pc_get_group_level(sd)) // untradeable item
+                || ( sd->status.cart[index].card[0] == CARD0_CREATE && MakeDWord(sd->status.cart[index].card[2],sd->status.cart[index].card[3]) == BG_CHARID && BG_TRADE&2 ) ) // "Battleground's Items"
                        continue;
 
                sd->vending[i].index = index;
 
Viewed 658 times, submitted by milk.