Pārlūkot izejas kodu

Add support for new insurance (#5812)

Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Co-authored-by: Atemo <Atemo@users.noreply.github.com>
Co-authored-by: crazy-arashi <meganekiho@gmail.com>
Balfear 4 gadi atpakaļ
vecāks
revīzija
d33ea18193
4 mainītis faili ar 116 papildinājumiem un 2 dzēšanām
  1. 109 0
      npc/re/merchants/new_insurance.txt
  2. 1 0
      npc/re/scripts_athena.conf
  3. 1 0
      src/map/itemdb.hpp
  4. 5 2
      src/map/pc.cpp

+ 109 - 0
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 <ITEM>["+.@old_item_name$+"]<INFO>" + .@old_item + "</INFO></ITEM> in your storage?";
+		next;
+		mes "[Heart Merchant]";
+		mes "If you bring me a " + .@old_item_name$ + ", I'll exchange it to <ITEM>["+.@new_item_name$+"]<INFO>" + .@new_item + "</INFO></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 <ITEM>["+.@old_item_name$+"]<INFO>" + .@old_item + "</INFO></ITEM> to something better? For example... <ITEM>["+.@new_item_name$+"]<INFO>" + .@new_item + "</INFO></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 "<ITEM>["+.@old_item_name$+"]<INFO>" + .@old_item + "</INFO></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 <ITEM>["+.@new_item_name$+"]<INFO>" + .@new_item + "</INFO></ITEM>.";
+		next;
+		mes "[Heart Merchant]";
+		mes "<ITEM>["+.@new_item_name$+"]<INFO>" + .@new_item + "</INFO></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 <ITEM>["+.@old_item_name$+"]<INFO>" + .@old_item + "</INFO></ITEM> for 1 <ITEM>["+.@new_item_name$+"]<INFO>" + .@new_item + "</INFO></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 <ITEM>["+.@old_item_name$+"]<INFO>" + .@old_item + "</INFO></ITEM> for 1 <ITEM>["+.@new_item_name$+"]<INFO>" + .@new_item + "</INFO></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;
+}

+ 1 - 0
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

+ 1 - 0
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,

+ 5 - 2
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. ) );