RelaX Опубликовано 19 ноября, 2016 Жалоба Поделиться Опубликовано 19 ноября, 2016 Ребята пожалуйста кому не сложно разложите по полочкам как сделать продажу за тцг на Еафине. Заранее спасибо! П.С гуглил и нагуглил только на Ra И Ha на Ea все ссылки мертвы к сожалению... Ссылка на комментарий Поделиться на другие сайты Поделиться
Fizik Опубликовано 19 ноября, 2016 Жалоба Поделиться Опубликовано 19 ноября, 2016 Могу даже написать на еА) магаз за тцг) Ссылка на комментарий Поделиться на другие сайты Поделиться
RelaX Опубликовано 20 ноября, 2016 Автор Жалоба Поделиться Опубликовано 20 ноября, 2016 13 часа назад, Fizik сказал: Могу даже написать на еА) магаз за тцг) Ну будь добр. Ссылка на комментарий Поделиться на другие сайты Поделиться
Ultima Опубликовано 20 ноября, 2016 Жалоба Поделиться Опубликовано 20 ноября, 2016 Не отказался бы увидеть такой же мод на ЕА, который даёт выбор валюты, за что ставить вендинг. Ссылка на комментарий Поделиться на другие сайты Поделиться
Break Опубликовано 20 ноября, 2016 Жалоба Поделиться Опубликовано 20 ноября, 2016 (изменено) ExtendedVendingSystem_1.7_eA.patch Скрытый текст Index: conf/battle/items.conf =================================================================== --- conf/battle/items.conf (revision 15091) +++ conf/battle/items.conf (working copy) @@ -87,3 +87,10 @@ // NOTE: Different cards that grant the same skill will both // always work independently of each other regardless of setting. autospell_stacking: no + +// Enable[1] or disable[0] extended vending system? +extended_vending: 1 +// Item ID for Zeny +item_zeny: 30000 +// Item ID for Cash +item_cash: 30001 \ No newline at end of file Index: conf/msg_athena.conf =================================================================== --- conf/msg_athena.conf (revision 15091) +++ conf/msg_athena.conf (working copy) @@ -535,5 +535,13 @@ //... 650: Unknown Job +700: You do not have enough CashPoint +701: You do not have enough items +702: Seller has not enough space in your inventory +703: Seller can not take all the item +704: You have selected: %s +705: Sale is carried out: %s +706: Current Currency: %s + //Custom translations import: conf/import/msg_conf.txt Index: db/item_db2.txt =================================================================== --- db/item_db2.txt (revision 15091) +++ db/item_db2.txt (working copy) @@ -61,3 +61,7 @@ //================================================================== //2338,Wedding_Dress,Wedding Dress,5,43000,,500,,0,,0,0xFFFFFFFE,7,0,16,,0,1,0,{},{ setoption Option_Wedding,1; },{ setoption Option_Wedding,0; } //7170,Tuxedo,Tuxedo,5,43000,,10,,0,,0,0xFFFFFFFE,7,1,16,,0,1,0,{},{ setoption Option_Wedding,1; },{ setoption Option_Wedding,0; } + +// Vending system +30000,Zeny,Zeny,3,,10,10,,,,,,,,,,,,,{},{},{} +30001,Cash,Cash,3,,10,10,,,,,,,,,,,,,{},{},{} \ No newline at end of file Index: db/item_vending.txt =================================================================== --- db/item_vending.txt (revision 0) +++ db/item_vending.txt (working copy) @@ -0,0 +1,17 @@ +// Specific items for Vending System +// Format: ItemID +// For Zeny use 30000, for Cashpoints use 30001 +// Max items is equal MAX_INVENTORY ( 100 by default ) + +// Zeny +30000 +// CashPoints +30001 +// TCG Card +7227 +// Mithril Coin +674 +// Silver Coin +675 +// Bronze Coin +673 \ No newline at end of file Index: src/map/battle.c =================================================================== --- src/map/battle.c (revision 15091) +++ src/map/battle.c (working copy) @@ -4023,6 +4023,12 @@ { "bg_magic_attack_damage_rate", &battle_config.bg_magic_damage_rate, 60, 0, INT_MAX, }, { "bg_misc_attack_damage_rate", &battle_config.bg_misc_damage_rate, 60, 0, INT_MAX, }, { "bg_flee_penalty", &battle_config.bg_flee_penalty, 20, 0, INT_MAX, }, + /** + * Extended Vending system [Lilith] + **/ + { "extended_vending", &battle_config.extended_vending, 1, 0, 1, }, + { "item_zeny", &battle_config.item_zeny, 30000, 1, MAX_ITEMDB, }, + { "item_cash", &battle_config.item_cash, 30001, 1, MAX_ITEMDB, }, }; Index: src/map/battle.h =================================================================== --- src/map/battle.h (revision 15091) +++ src/map/battle.h (working copy) @@ -497,6 +497,13 @@ int bg_magic_damage_rate; int bg_misc_damage_rate; int bg_flee_penalty; + + /** + * Extended Vending system [Lilith] + **/ + int extended_vending; + int item_zeny; + int item_cash; } battle_config; void do_init_battle(void); Index: src/map/clif.c =================================================================== --- src/map/clif.c (revision 15091) +++ src/map/clif.c (working copy) @@ -8796,6 +8796,38 @@ #undef CHECK_PACKET_VER } +/** + * Extended Vending system [Lilith] + **/ +int clif_vend(struct map_session_data *sd, int skill_lv) { + + struct item_data *item; + int c, i; + int fd; + + nullpo_ret(sd); + + fd = sd->fd; + WFIFOHEAD(fd, 8 * 8 + 8); + WFIFOW(fd,0) = 0x1ad; + for( c = 0, i = 0; i < ARRAYLENGTH(item_vend); i ++ ) { + if((item = itemdb_exists(item_vend.itemid)) != NULL) { + WFIFOW(fd, c * 2 + 4) = item->nameid; + c++; + } + } + if( c > 0 ) { + sd->menuskill_id = MC_VENDING; + sd->menuskill_val = skill_lv; + WFIFOW(fd,2) = c * 2 + 4; + WFIFOSET(fd, WFIFOW(fd, 2)); + } else { + clif_skill_fail(sd, 1, USESKILL_FAIL_LEVEL, 1); + return 0; + } + + return 1; +} // ------------ // clif_parse_* // ------------ @@ -10901,15 +10933,30 @@ /// 01ae <name id>.W void clif_parse_SelectArrow(int fd,struct map_session_data *sd) { - if (sd->menuskill_id != AC_MAKINGARROW) + switch( sd->menuskill_id ) + { + case AC_MAKINGARROW: + case MC_VENDING: // Extended Vending system [Lilith] + break; + default: return; + } + if (pc_istrading(sd)) { //Make it fail to avoid shop exploits where you sell something different than you see. clif_skill_fail(sd,sd->ud.skillid,USESKILL_FAIL_LEVEL,0); sd->menuskill_val = sd->menuskill_id = 0; return; } - skill_arrow_create(sd,RFIFOW(fd,2)); + + switch( sd->menuskill_id ) { + case AC_MAKINGARROW: + skill_arrow_create(sd,RFIFOW(fd,2)); + break; + case MC_VENDING: // Extended Vending system [Lilith] + skill_vending(sd,RFIFOW(fd,2)); + break; + } sd->menuskill_val = sd->menuskill_id = 0; } @@ -11587,10 +11634,17 @@ /// 1 = open void clif_parse_OpenVending(int fd, struct map_session_data* sd) { + struct item_data *item = itemdb_exists(sd->vend_loot); short len = (short)RFIFOW(fd,2) - 85; const char* message = (char*)RFIFOP(fd,4); bool flag = (bool)RFIFOB(fd,84); const uint8* data = (uint8*)RFIFOP(fd,85); + char out_msg[1024]; + + if(battle_config.extended_vending){ + memset(out_msg, '\0', sizeof(out_msg)); + strcat(strcat(strcat(strcat(out_msg,"["),item->jname),"] "),message); + } if( sd->sc.data[SC_NOCHAT] && sd->sc.data[SC_NOCHAT]->val1&MANNER_NOROOM ) return; @@ -11605,7 +11659,10 @@ if( message[0] == '\0' ) // invalid input return; - vending_openvending(sd, message, flag, data, len/8); + if(battle_config.extended_vending) + vending_openvending(sd, out_msg, flag, data, len/8); + else + vending_openvending(sd, message, flag, data, len/8); } Index: src/map/clif.h =================================================================== --- src/map/clif.h (revision 15091) +++ src/map/clif.h (working copy) @@ -714,4 +714,9 @@ void clif_open_search_store_info(struct map_session_data* sd); void clif_search_store_info_click_ack(struct map_session_data* sd, short x, short y); +/** + * Extended Vending system [Lilith] + **/ +int clif_vend(struct map_session_data *sd, int skill_lv); + #endif /* _CLIF_H_ */ Index: src/map/itemdb.c =================================================================== --- src/map/itemdb.c (revision 15091) +++ src/map/itemdb.c (working copy) @@ -15,11 +15,6 @@ #include <stdlib.h> #include <string.h> -// 32k array entries (the rest goes to the db) -#define MAX_ITEMDB 0x8000 - - - static struct item_data* itemdb_array[MAX_ITEMDB]; static DBMap* itemdb_other;// int nameid -> struct item_data* @@ -689,7 +684,33 @@ return true; } +/** + * Extended Vending system [Lilith] + **/ +static bool itemdb_read_vending(char* fields[], int columns, int current) +{ + struct item_data* id; + int nameid; + nameid = atoi(fields[0]); + + if( ( id = itemdb_exists(nameid) ) == NULL ) + { + ShowWarning("itemdb_read_vending: Invalid item id %d.\n", nameid); + return false; + } + + if( id->type == IT_ARMOR || id->type == IT_WEAPON ) + { + ShowWarning("itemdb_read_vending: item id %d cannot be equipment or weapon.\n", nameid); + return false; + } + + item_vend[current].itemid = nameid; + + return true; +} + /*====================================== * Applies gender restrictions according to settings. [Skotlex] *======================================*/ @@ -1007,6 +1028,7 @@ sv_readdb(db_path, "item_trade.txt", ',', 3, 3, -1, &itemdb_read_itemtrade); sv_readdb(db_path, "item_delay.txt", ',', 2, 2, MAX_ITEMDELAYS, &itemdb_read_itemdelay); sv_readdb(db_path, "item_buyingstore.txt", ',', 1, 1, -1, &itemdb_read_buyingstore); + sv_readdb(db_path, "item_vending.txt", ',', 1, 1, ARRAYLENGTH(item_vend), &itemdb_read_vending); // Extended Vending system [Lilith] } /*========================================== @@ -1059,7 +1081,8 @@ itemdb_other->clear(itemdb_other, itemdb_final_sub); memset(itemdb_array, 0, sizeof(itemdb_array)); - + memset(item_vend,0,sizeof(item_vend)); // Extended Vending system [Lilith] + // read new data itemdb_read(); Index: src/map/itemdb.h =================================================================== --- src/map/itemdb.h (revision 15091) +++ src/map/itemdb.h (working copy) @@ -6,6 +6,9 @@ #include "../common/mmo.h" // ITEM_NAME_LENGTH +// 32k array entries (the rest goes to the db) +#define MAX_ITEMDB 0x8000 + #define MAX_RANDITEM 11000 // The maximum number of item delays @@ -91,7 +94,10 @@ int nameid[MAX_RANDITEM]; int qty; //Counts amount of items in the group. }; - +struct s_item_vend{ + int itemid; +}; +struct s_item_vend item_vend[MAX_INVENTORY]; struct item_data* itemdb_searchname(const char *name); int itemdb_searchname_array(struct item_data** data, int size, const char *str); struct item_data* itemdb_load(int nameid); @@ -149,4 +155,10 @@ void do_final_itemdb(void); int do_init_itemdb(void); +/** + * Extended Vending system [Lilith] + **/ +#define ITEMID_ZENY battle_config.item_zeny +#define ITEMID_CASH battle_config.item_cash + #endif /* _ITEMDB_H_ */ Index: src/map/pc.h =================================================================== --- src/map/pc.h (revision 15091) +++ src/map/pc.h (working copy) @@ -423,6 +423,12 @@ // temporary debugging of bug #3504 const char* delunit_prevfile; int delunit_prevline; + + /** + * Extended Vending system [Lilith] + **/ + int vend_loot; + int vend_lvl; }; //Update this max as necessary. 55 is the value needed for Super Baby currently Index: src/map/skill.c =================================================================== --- src/map/skill.c (revision 15091) +++ src/map/skill.c (working copy) @@ -4332,10 +4332,37 @@ { //Prevent vending of GMs with unnecessary Level to trade/drop. [Skotlex] if ( !pc_can_give_items(pc_isGM(sd)) ) clif_skill_fail(sd,skillid,USESKILL_FAIL_LEVEL,0); - else - clif_openvendingreq(sd,2+skilllv); - } - break; + else { // Extended Vending system [Lilith] + if(battle_config.extended_vending){ + struct item_data *item; + char output[1024]; + int c, i; + + sd->vend_lvl = skilllv; + + for( c = 0, i = 0; i < ARRAYLENGTH(item_vend); i ++ ) { + if((item = itemdb_exists(item_vend.itemid)) != NULL) + c++; + } + + if(c > 1) + clif_vend(sd,sd->vend_lvl); + else { + if(c == 1) { + item = itemdb_exists(item_vend[0].itemid); + sd->vend_loot = item->nameid; + } else + sd->vend_loot = ITEMID_ZENY; + + sprintf(output,"Current Currency: %s" ,itemdb_jname(sd->vend_loot)); + clif_displaymessage(sd->fd,output); + clif_openvendingreq(sd,2+sd->vend_lvl); + } + } else + clif_openvendingreq(sd,2+skilllv); + } + } + break; case AL_TELEPORT: if(sd) @@ -6697,6 +6724,38 @@ return map_foreachincell(skill_dance_overlap_sub, unit->bl.m,unit->bl.x,unit->bl.y,BL_SKILL, unit,flag); } +/** + * Extended Vending system [Lilith] + **/ +int skill_vending( struct map_session_data *sd, int nameid) { + + struct item_data *item; + char output[1024]; + + nullpo_ret(sd); + + if( nameid <= 0) { + clif_skill_fail(sd,MC_VENDING,USESKILL_FAIL_LEVEL,0); + return 0; + } + + if( nameid > MAX_ITEMDB ) + return 0; + + sd->vend_loot = nameid; + item = itemdb_exists(nameid); + + sprintf(output,"You have selected: %s",itemdb_jname(sd->vend_loot)); + clif_displaymessage(sd->fd,output); + + if ( !pc_can_give_items(pc_isGM(sd))) + clif_skill_fail(sd,MC_VENDING,USESKILL_FAIL_LEVEL,0); + else + clif_openvendingreq(sd,2+sd->vend_lvl); + + return 0; +} + /*========================================== * Converts this group information so that it is handled as a Dissonance or Ugly Dance cell. * Flag: 0 - Convert, 1 - Revert. Index: src/map/skill.h =================================================================== --- src/map/skill.h (revision 15091) +++ src/map/skill.h (working copy) @@ -1548,4 +1548,9 @@ UNT_MAX = 0x190 }; +/** + * Extended Vending system [Lilith] + **/ +int skill_vending( struct map_session_data *sd, int nameid); + #endif /* _SKILL_H_ */ Index: src/map/vending.c =================================================================== --- src/map/vending.c (revision 15091) +++ src/map/vending.c (working copy) @@ -47,6 +47,7 @@ void vending_vendinglistreq(struct map_session_data* sd, int id) { struct map_session_data* vsd; + char output[1024]; // Extended Vending system [Lilith] nullpo_retv(sd); if( (vsd = map_id2sd(id)) == NULL ) @@ -59,6 +60,12 @@ clif_displaymessage(sd->fd, msg_txt(246)); return; } + + /** + * Extended Vending system [Lilith] + **/ + sprintf(output,msg_txt(705),itemdb_jname(vsd->vend_loot)); + clif_displaymessage(sd->fd,output); sd->vended_id = vsd->vender_id; // register vending uid @@ -121,16 +128,62 @@ vend_list = j; z += ((double)vsd->vending[j].value * (double)amount); - if( z > (double)sd->status.zeny || z < 0. || z > (double)MAX_ZENY ) - { - clif_buyvending(sd, idx, amount, 1); // you don't have enough zeny - return; - } - if( z + (double)vsd->status.zeny > (double)MAX_ZENY && !battle_config.vending_over_max ) - { - clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // too much zeny = overflow - return; + /** + * Extended Vending system [Lilith] + **/ + if(battle_config.extended_vending){ + if(vsd->vend_loot == ITEMID_ZENY) { + if( z > (double)sd->status.zeny || z < 0. || z > (double)MAX_ZENY ) + { + //clif_buyvending(sd, idx, amount, 1); // you don't have enough zeny + return; + } + if( z + (double)vsd->status.zeny > (double)MAX_ZENY && !battle_config.vending_over_max ) + { + clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // too much zeny = overflow + return; + + } + } else if(vsd->vend_loot == ITEMID_CASH){ + if(z > sd->cashPoints || z < 0. || z > (double)MAX_ZENY ) { + clif_displaymessage(sd->fd, msg_txt(700)); + return; + } + } else { + int k, loot_count = 0, vsd_w = 0; + for(k = 0; k < MAX_INVENTORY; k++) + if(sd->status.inventory[k].nameid == vsd->vend_loot) + loot_count += sd->status.inventory[k].amount; + + if( z > loot_count || z < 0) + { + clif_displaymessage(sd->fd,msg_txt(701)); + return; + } + if(pc_inventoryblank(vsd) <= 0) + { + clif_displaymessage(sd->fd,msg_txt(702)); + return; + } + vsd_w += itemdb_weight(vsd->vend_loot) * (int)z; + if(vsd_w + vsd->weight > vsd->max_weight) + { + clif_displaymessage(sd->fd,msg_txt(703)); + return; + } + } + } else { + if( z > (double)sd->status.zeny || z < 0. || z > (double)MAX_ZENY ) + { + clif_buyvending(sd, idx, amount, 1); // you don't have enough zeny + return; + } + if( z + (double)vsd->status.zeny > (double)MAX_ZENY && !battle_config.vending_over_max ) + { + clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // too much zeny = overflow + return; + } } w += itemdb_weight(vsd->status.cart[idx].nameid) * amount; if( w + sd->weight > sd->max_weight ) @@ -166,15 +219,44 @@ return; //too many items } } + + /** + * Extended Vending system [Lilith] + **/ + if(battle_config.extended_vending){ + if(vsd->vend_loot == ITEMID_ZENY) { + + //Logs (V)ending Zeny [Lupus] + log_zeny(vsd, LOG_TYPE_VENDING, sd, (int)z); + + pc_payzeny(sd, (int)z); + if( battle_config.vending_tax ) + z -= z * (battle_config.vending_tax/10000.); + pc_getzeny(vsd, (int)z); + + } else if(vsd->vend_loot == ITEMID_CASH) { + pc_paycash(sd,(int)z,0); + pc_getcash(vsd,(int)z,0); + } else { + for( i = 0; i < MAX_INVENTORY; i++) + if(sd->status.inventory.nameid == vsd->vend_loot) + { + struct item *item; + item = &sd->status.inventory; + pc_additem(vsd,item,(int)z); + } + pc_delitem(sd,pc_search_inventory(sd, vsd->vend_loot),(int)z,0,6); + + } + } else { + //Logs (V)ending Zeny [Lupus] + log_zeny(vsd, LOG_TYPE_VENDING, sd, (int)z); + pc_payzeny(sd, (int)z); + if( battle_config.vending_tax ) + z -= z * (battle_config.vending_tax/10000.); + pc_getzeny(vsd, (int)z); + } - //Logs (V)ending Zeny [Lupus] - log_zeny(vsd, LOG_TYPE_VENDING, sd, (int)z); - - pc_payzeny(sd, (int)z); - if( battle_config.vending_tax ) - z -= z * (battle_config.vending_tax/10000.); - pc_getzeny(vsd, (int)z); - for( i = 0; i < count; i++ ) { short amount = *(uint16*)(data + 4*i + 0); Изменено 20 ноября, 2016 пользователем Sky 1 Ссылка на комментарий Поделиться на другие сайты Поделиться
RelaX Опубликовано 24 ноября, 2016 Автор Жалоба Поделиться Опубликовано 24 ноября, 2016 В 20.11.2016в4:29 PM, Sky сказал: ExtendedVendingSystem_1.7_eA.patch Скрытое содержимое Пожалуйста разложи все по полочкам что куда тыкнуть. Заранее спасибо! 1 Ссылка на комментарий Поделиться на другие сайты Поделиться
RelaX Опубликовано 27 ноября, 2016 Автор Жалоба Поделиться Опубликовано 27 ноября, 2016 В 20.11.2016в4:29 PM, Sky сказал: ExtendedVendingSystem_1.7_eA.patch Ребят чирканите гайд пожалуйста куда вписать строки. Заранее спасибо! 1 Ссылка на комментарий Поделиться на другие сайты Поделиться
Рекомендуемые сообщения