From d33ea1819384e1d5f6b6c987d722d40996db38ed Mon Sep 17 00:00:00 2001 From: Balfear Date: Thu, 8 Apr 2021 18:15:39 +0300 Subject: [PATCH] Add support for new insurance (#5812) Co-authored-by: Lemongrass3110 Co-authored-by: Aleos Co-authored-by: Atemo Co-authored-by: crazy-arashi --- npc/re/merchants/new_insurance.txt | 109 +++++++++++++++++++++++++++++ npc/re/scripts_athena.conf | 1 + src/map/itemdb.hpp | 1 + src/map/pc.cpp | 7 +- 4 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 npc/re/merchants/new_insurance.txt diff --git a/npc/re/merchants/new_insurance.txt b/npc/re/merchants/new_insurance.txt new file mode 100644 index 0000000000..d55d229e91 --- /dev/null +++ b/npc/re/merchants/new_insurance.txt @@ -0,0 +1,109 @@ +//===== rAthena Script ======================================= +//= Insurance Exchanger +//===== Description: ========================================= +//= Exchange items for New_Insurance item. +//===== Changelogs: ========================================== +//= 1.0 Initial release. [Balfear] +//============================================================ + +prontera,82,108,5 script Heart Merchant#life01 4_M_NFDEADMAN2,5,5,{ + .@old_item = 12209; + .@new_item = 6413; + .@old_item_name$ = getitemname(.@old_item); + .@new_item_name$ = getitemname(.@new_item); + + if (!checkweight(1201,1) || (MaxWeight - Weight) < 500) { + mes "You can't proceed with the conversation because you have a large quantity of items."; + mes "Please organize your items and try again."; + close; + } + mes "[Heart Merchant]"; + mes "Hello! I see you are an adventurer who gives your heart to traveling, uses a boat to sail across the continent, and enjoys the thrill of danger!"; + next; + if(!countitem(.@old_item)){ + mes "[Heart Merchant]"; + mes "Do you have any ["+.@old_item_name$+"]" + .@old_item + " in your storage?"; + next; + mes "[Heart Merchant]"; + mes "If you bring me a " + .@old_item_name$ + ", I'll exchange it to ["+.@new_item_name$+"]" + .@new_item + ". What do you think? Do you have any idea what this item is?"; + } else { + mes "[Heart Merchant]"; + mes "Have you ever thought about replacing your ["+.@old_item_name$+"]" + .@old_item + " to something better? For example... ["+.@new_item_name$+"]" + .@new_item + ". What do you think?"; + } + next; + switch(select("What is it?",(countitem(.@old_item)?"Exchange it please!":""),"I'm not interested")) { + case 1: + mes "[Heart Merchant]"; + mes "["+.@old_item_name$+"]" + .@old_item + " is an item that prevents you from losing experience on death once within the 30 minutes duration after use."; + next; + mes "[Heart Merchant]"; + mes "But a lot of people are sad about the time limit, right? So I looked into it and prepared the ["+.@new_item_name$+"]" + .@new_item + "."; + next; + mes "[Heart Merchant]"; + mes "["+.@new_item_name$+"]" + .@new_item + " is an item that will prevent the loss of experience on death once by just having it ^EE0000regardless of the duration^000000. Of course, after death, the "+.@new_item_name$+" is consumed."; + next; + select("Why are you exchanging it?"); + mes "[Heart Merchant]"; + mes "Are you curious about that? I'm a merchant. Buying and selling things is my fate, whether it's related to one's life or death. Do you think I'm going to miss this opportunity to make money? I make money, and the living get a leeway from the pain of death. Isn't that a good deal?"; + next; + mes "[Heart Merchant]"; + mes "The exchange rate is 5 ["+.@old_item_name$+"]" + .@old_item + " for 1 ["+.@new_item_name$+"]" + .@new_item + ". Do you have any questions?"; + next; + mes "[Heart Merchant]"; + mes "Hm~ What do you think? Isn't it a fair trade? Do you want to always worry about time? It's a must-have for adventurers who enjoy breathtaking adventures."; + close; + + case 2: + mes "[Heart Merchant]"; + mes "Yeah, yeah. Good decision. It's better to exchange it for a better one, isn't it?"; + next; + mes "[Heart Merchant]"; + mes "I can exchange your ^0000cd5 "+.@old_item_name$+" to 1 "+.@new_item_name$+"."; + next; + mes "[Heart Merchant]"; + mes "However, ^EE0000[Not for sale] " + .@old_item_name$ + " is not eligible for exchange^000000, so it is useless to bring it here and ask for it to be exchanged."; + next; + mes "[Heart Merchant]"; + mes "Shall we exchange it now?"; + next; + if (select("Exchange it please!:I don't want to exchange it.") == 2) + break; + mes "[Heart Merchant]"; + mes "How many do you want to exchange? ^0000cdYou can exchange up to 10 "+.@new_item_name$+" at a time^000000."; + next; + input .@amount; + if (.@amount == 0) { + mes "[Heart Merchant]"; + mes "Hm? Are you not interested? This is a great product, and it's really good for someone like you. But if you don't want to protect your live, I won't force you either."; + close; + } + if (.@amount > 10) { + mes "[Heart Merchant]"; + mes "Like I said, ^0000cdyou can only exchange up to 10^000000 at a time. Check the quantity again."; + close; + } + if (countitem(.@old_item) < (.@amount*5)) { + mes "[Heart Merchant]"; + mes "Um, excuse me but... you don't have enough " +.@old_item_name$+ ", no? It's 5 ["+.@old_item_name$+"]" + .@old_item + " for 1 ["+.@new_item_name$+"]" + .@new_item + ". Please check the quantity."; + close; + } + mes "[Heart Merchant]"; + mes "Now, with this, I've exchanged your ^0000cd" + .@old_item_name$ + "^000000 for the ^EE0000" + .@new_item_name$ + "^000000!! That was a good deal, wasn't it? The next time you get your hands on a "+.@old_item_name$+", come see me again!"; + delitem .@old_item,.@amount*5; + getitem .@new_item,.@amount; + close; + case 3: + break; + } + mes "[Heart Merchant]"; + mes "This is a great deal! Adventurer, it's a must-have item for people like you who ventures in dangerous places!"; + next; + mes "[Heart Merchant]"; + mes "If you become interested in it, be sure to come back for the exchange. Okay?"; + close; + +OnTouch: + if(countitem(12209)) + npctalk "You have something good. Would you like to replace your " + getitemname(12209) + " with a better one?", "", bc_self; + end; +} diff --git a/npc/re/scripts_athena.conf b/npc/re/scripts_athena.conf index e507d2b5a4..fea666fb93 100644 --- a/npc/re/scripts_athena.conf +++ b/npc/re/scripts_athena.conf @@ -124,6 +124,7 @@ npc: npc/re/merchants/HorrorToyFactory_merchants.txt npc: npc/re/merchants/inn.txt npc: npc/re/merchants/malangdo_costume.txt npc: npc/re/merchants/moro_cav_exchange.txt +npc: npc/re/merchants/new_insurance.txt npc: npc/re/merchants/nightmare_biolab.txt npc: npc/re/merchants/novice_vending_machine.txt npc: npc/re/merchants/OldGlastHeim_merchants.txt diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp index ee0c77dcc8..f1026b8974 100644 --- a/src/map/itemdb.hpp +++ b/src/map/itemdb.hpp @@ -87,6 +87,7 @@ enum item_itemid : t_itemid ITEMID_ANGRA_MANYU = 1599, ITEMID_PAINT_BRUSH = 6122, ITEMID_MAGIC_GEAR_FUEL = 6146, + ITEMID_NEW_INSURANCE = 6413, ITEMID_STRANGE_EMBRYO = 6415, ITEMID_STONE = 7049, ITEMID_FIRE_BOTTLE = 7135, diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 35ba99cfa5..b8dcc65b52 100755 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -8623,8 +8623,11 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) else job_penalty = 0; - if (base_penalty || job_penalty) - pc_lostexp(sd, base_penalty, job_penalty); + if (base_penalty || job_penalty) { + short insurance_idx = pc_search_inventory(sd, ITEMID_NEW_INSURANCE); + if (insurance_idx < 0 || pc_delitem(sd, insurance_idx, 1, 0, 1, LOG_TYPE_CONSUME) != 0) + pc_lostexp(sd, base_penalty, job_penalty); + } if( zeny_penalty > 0 && !mapdata->flag[MF_NOZENYPENALTY]) { zeny_penalty = (uint32)( sd->status.zeny * ( zeny_penalty / 10000. ) );