• 0
Sign in to follow this  
Tassadar

Simplifying this npc.

Question

I'm editing this npc:

function	script	omnirefine	{
	[email protected]$ = getarg(0);
	/// Custom chances 1 to 20.
	setarray [email protected]_chances[1], 100, 100, 100, 100, 95, 80, 80, 50, 50, 35, 20, 20, 16, 16, 15, 15, 14, 14, 10, 10;
	/// Equipment position names (Don't edit that order).
	setarray [email protected]_name$[1],"Head","Middle","Lower","Armor","Weapon","Shield","Garment","Shoes","Accessory 1","Accessory 2";
	/// Weapon material
	[email protected]_material = 6438; // Omni-Oridecon
	/// Armor material
	[email protected]_material = 6439; // Mega-Elunium

	disable_items;
	mes "["+ [email protected]$ +"]";
	mes "I am the best Armsmith ever!";
	mes "I don't refine with normal, boring materials.";
//	mes "I only refine items using ^FF0000" + getitemname([email protected]_material) + "^000000 and FF0000" + getitemname([email protected]_material) + "^000000.";
	mes "I only refine items using ^FF0000Omni-Oridecon^000000 and ^FF0000Mega-Elunium^000000.";	
	next;
	mes "["+ [email protected]$ +"]";
	mes "Anyway, you may use my services if you have any of that materials.";
	mes "What do you want me to refine?";
	next;

	setarray [email protected]_pos[1],EQI_HEAD_TOP,EQI_HEAD_MID,EQI_HEAD_LOW,EQI_ARMOR,EQI_HAND_R,EQI_HAND_L,EQI_GARMENT,EQI_SHOES,EQI_ACC_R,EQI_ACC_L;
	for ([email protected] = 1; [email protected] <= getarraysize([email protected]_pos); [email protected]) {
		if (getequipisequiped([email protected]_pos[[email protected]]))
			[email protected]$ += getequipname([email protected]_pos[[email protected]]);
		else
			[email protected]$ += "^777777" + [email protected]_name$[[email protected]] + " - " + "[Unavailable]" + "^000000";
		[email protected]$ += ":";
	}
	[email protected] = [email protected]_pos[select([email protected]$)];
	[email protected]_id = getequipid([email protected]);
	[email protected] = getequiprefinerycnt([email protected]);
	if (!getequipisequiped([email protected])) { //custom check
		mes "["+ [email protected]$ +"]";
		mes "You're not wearing";
		mes "anything there that";
		mes "I can refine.";
		emotion ET_FRET;
		close;
	}
	if (!getequipisenableref([email protected])) {
		mes "["+ [email protected]$ +"]";
		mes "I don't think I can";
		mes "refine this item at all...";
		close;
	}
	if ([email protected] >= 20) { //custom check
		mes "["+ [email protected]$ +"]";
		mes "I can't refine this";
		mes "any more. This is as";
		mes "refined as it gets!";
		close;
	}
//		 if (getiteminfo([email protected]_id,2) == 5) [email protected] = [email protected]_material;
//	else if (getiteminfo([email protected]_id,2) == 4) [email protected] = [email protected]_material;
		 if (getiteminfo([email protected]_id,2) == 5) [email protected] = "Omni-Oridecon";
	else if (getiteminfo([email protected]_id,2) == 4) [email protected] = "Mega-Elunium";
	
	
	if ((getequipweaponlv([email protected]) >= 1) && (getequipweaponlv([email protected]) <= 4)) {
		[email protected]$ = "a";
		[email protected]$ = "weapon";
	} else {
		[email protected]$ = "an";
		[email protected]$ = "armor";
	}
	
	mes "["+ [email protected]$ +"]";
	mes "Hmm " + [email protected]$ + " " + [email protected]$ + ", is that ok?";
	mes "If you want to refine this " + [email protected]$ + ",";
	mes "I will need 1 ^FF0000" + getitemname([email protected]) + "^000000.";
	mes "Are you sure you want to continue?";
	next;
	if(select("Yes:No") == 2){
		mes "["+ [email protected]_name$ +"]";
		mes "Hm... if you mind... never mind...";
		close;
	}
	while (1) {
		[email protected] = getequiprefinerycnt([email protected]);
		if (countitem([email protected]) < 1) {
			mes "["+ [email protected]$ +"]";
			mes "Hm. You don't seem to have enough  "+getitemname([email protected])+".";
			mes "Please come back when you have them.";
			close;
		}
		delitem [email protected],1;
		// anti-hack
		if (callfunc("F_IsEquipIDHack", [email protected], [email protected]_id) ||
		    callfunc("F_IsEquipRefineHack", [email protected], [email protected])) {
			mes "["+ [email protected]$ +"]";
			emotion ET_FRET;
			mes "Wait a second...";
			mes "Do you think I'm stupid?!";
			mes "You switched the item while I wasn't looking! Get out of here!";
			close;
		}
		if ([email protected]_chances[[email protected]+1] > rand(100)) {
			mes "["+ [email protected]$ +"]";
			mes "Clang! Clang! Clang! Clang!";
			successrefitem [email protected];
			next;
			emotion ET_BEST;
			mes "["+ [email protected]$ +"]";
			mes "Good! Succes!!!";
			mes "I am the best Armsmith.";
			next;
		} else {
			if (rand(100) < 80) {
				mes "["+ [email protected]$ +"]";
				mes "Clang! Clang! Clang! Clang!";
				downrefitem [email protected],0; // Only for the fail refinement animation
				next;
				emotion (!rand(5))?ET_MONEY:ET_HUK;
				mes "["+ [email protected]$ +"]";
				mes "Ahhh!!!";
				next;
				mes "["+ [email protected]$ +"]";
				mes "Oh my god!";
				mes "The upgrade level has dropped...";
			} else {
				mes "["+ [email protected]$ +"]";
				mes "Clang! Clang! Clang!";
				downrefitem [email protected],0; // Only for the fail refinement animation
				next;
				emotion (!rand(5))?ET_MONEY:ET_HUK;
				mes "["+ [email protected]$ +"]";
				mes "Hmmm!";
				next;
				mes "["+ [email protected]$ +"]";
				mes "Oh my! I've failed to refine stuff...";
				mes "I didn't mean it!";
			}
			mes "I could have made a mistake even though I am the best Armsmith ever.";
			mes "It just wasn't meant to be.";
			next;
			mes "["+ [email protected]$ +"]";
			mes "I will do a better job next time! Don't worry!";
			next;
		}
		mes "["+ [email protected]me$ +"]";
		mes "Do you want to refine again?";
		next;
		if(select("Yes:No") == 2){
			mes "["+ [email protected]_name$ +"]";
			mes "Hm... if you mind... never mind...";
			close;
		}
	}

	return;
}

prt_in,54,58,3	script	Refiner#1	813,{
	callfunc "omnirefine","^0000FFBlessed Refiner^000000";
	end;
}

I changed here, I do not know how to change that other part:
 

//	mes "I only refine items using ^FF0000" + getitemname([email protected]_material) + "^000000 and FF0000" + getitemname([email protected]_material) + "^000000.";
	mes "I only refine items using ^FF0000Omni-Oridecon^000000 and ^FF0000Mega-Elunium^000000.";	

 

In this part I would like to change the variable to a text, because the name it carries I do not like.

//		 if (getiteminfo([email protected]_id,2) == 5) [email protected] = [email protected]_material;
//	else if (getiteminfo([email protected]_id,2) == 4) [email protected] = [email protected]_material;

for

		 if (getiteminfo([email protected]_id,2) == 5) [email protected] = "Omni-Oridecon";
	else if (getiteminfo([email protected]_id,2) == 4) [email protected] = "Mega-Elunium";

It loads this variable here:
 

	mes "["+ [email protected]$ +"]";
	mes "Hmm " + [email protected]$ + " " + [email protected]$ + ", is that ok?";
	mes "If you want to refine this " + [email protected]$ + ",";
	mes "I will need 1 ^FF0000" + getitemname([email protected]) + "^000000.";
	mes "Are you sure you want to continue?";

I want it to either show the text without loading the actual name of the Item, only with the text that I chose.

Can you do that?

I know I can only change the item name in itemdb. but I want to learn this.

Thank you for your help.

Edited by Tassadar
misspelled word

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

The script requires an item id not a string with a Name.

Also does this not simplify the scripts, it makes it unclean.

So instead of [email protected] = „Mega-Elunium“ (and the other possibility) you should keep the orignal part and just save the choice and use it later to display the text you want.

But again, this isnt making the script simpler.

Share this post


Link to post
Share on other sites
  • 0
function	script	omnirefine	{
	[email protected]$ = getarg(0);
	/// Custom chances 1 to 20.
	setarray [email protected]_chances[1], 100, 100, 100, 100, 95, 80, 80, 50, 50, 35, 20, 20, 16, 16, 15, 15, 14, 14, 10, 10;
	/// Equipment position names (Don't edit that order).
	setarray [email protected]_name$[1],"Head","Middle","Lower","Armor","Weapon","Shield","Garment","Shoes","Accessory 1","Accessory 2";
	/// Weapon material
	[email protected]_material = 6438; // Omni-Oridecon
	[email protected]_material_name$ = "Omni-Oridecon";
	/// Armor material
	[email protected]_material = 6439; // Mega-Elunium
	[email protected]_material_name$ = "Mega-Elunium":
	
	disable_items;
	mes "["+ [email protected]$ +"]";
	mes "I am the best Armsmith ever!";
	mes "I don't refine with normal, boring materials.";
//	mes "I only refine items using ^FF0000" + getitemname([email protected]_material) + "^000000 and FF0000" + getitemname([email protected]_material) + "^000000.";
	mes "I only refine items using ^FF0000"[email protected]_material_name$+"^000000 and ^FF0000"[email protected]_material_name$+"^000000.";	
	next;
	mes "["+ [email protected]$ +"]";
	mes "Anyway, you may use my services if you have any of that materials.";
	mes "What do you want me to refine?";
	next;

	setarray [email protected]_pos[1],EQI_HEAD_TOP,EQI_HEAD_MID,EQI_HEAD_LOW,EQI_ARMOR,EQI_HAND_R,EQI_HAND_L,EQI_GARMENT,EQI_SHOES,EQI_ACC_R,EQI_ACC_L;
	for ([email protected] = 1; [email protected] <= getarraysize([email protected]_pos); [email protected]) {
		if (getequipisequiped([email protected]_pos[[email protected]]))
			[email protected]$ += getequipname([email protected]_pos[[email protected]]);
		else
			[email protected]$ += "^777777" + [email protected]_name$[[email protected]] + " - " + "[Unavailable]" + "^000000";
		[email protected]$ += ":";
	}
	[email protected] = [email protected]_pos[select([email protected]$)];
	[email protected]_id = getequipid([email protected]);
	[email protected] = getequiprefinerycnt([email protected]);
	if (!getequipisequiped([email protected])) { //custom check
		mes "["+ [email protected]$ +"]";
		mes "You're not wearing";
		mes "anything there that";
		mes "I can refine.";
		emotion ET_FRET;
		close;
	}
	if (!getequipisenableref([email protected])) {
		mes "["+ [email protected]$ +"]";
		mes "I don't think I can";
		mes "refine this item at all...";
		close;
	}
	if ([email protected] >= 20) { //custom check
		mes "["+ [email protected]$ +"]";
		mes "I can't refine this";
		mes "any more. This is as";
		mes "refined as it gets!";
		close;
	}
	
	if (getiteminfo([email protected]_id,2) == 5) {
		[email protected] = [email protected]_material;
		[email protected]_name$ = [email protected]_material_name$;
	}
	else if (getiteminfo([email protected]_id,2) == 4) { 
		[email protected] = [email protected]_material;
		[email protected]_name$ = [email protected]_material_name$;
	}
	
	
	if ((getequipweaponlv([email protected]) >= 1) && (getequipweaponlv([email protected]) <= 4)) {
		[email protected]$ = "a";
		[email protected]$ = "weapon";
	} else {
		[email protected]$ = "an";
		[email protected]$ = "armor";
	}
	
	mes "["+ [email protected]$ +"]";
	mes "Hmm " + [email protected]$ + " " + [email protected]$ + ", is that ok?";
	mes "If you want to refine this " + [email protected]$ + ",";
	mes "I will need 1 ^FF0000" + [email protected]_name$ + "^000000.";
	mes "Are you sure you want to continue?";
	next;
	if(select("Yes:No") == 2){
		mes "["+ [email protected]_name$ +"]";
		mes "Hm... if you mind... never mind...";
		close;
	}
	while (1) {
		[email protected] = getequiprefinerycnt([email protected]);
		if (countitem([email protected]) < 1) {
			mes "["+ [email protected]$ +"]";
			mes "Hm. You don't seem to have enough  "[email protected]_name$+".";
			mes "Please come back when you have them.";
			close;
		}
		delitem [email protected],1;
		// anti-hack
		if (callfunc("F_IsEquipIDHack", [email protected], [email protected]_id) ||
		    callfunc("F_IsEquipRefineHack", [email protected], [email protected])) {
			mes "["+ [email protected]$ +"]";
			emotion ET_FRET;
			mes "Wait a second...";
			mes "Do you think I'm stupid?!";
			mes "You switched the item while I wasn't looking! Get out of here!";
			close;
		}
		if ([email protected]_chances[[email protected]+1] > rand(100)) {
			mes "["+ [email protected]$ +"]";
			mes "Clang! Clang! Clang! Clang!";
			successrefitem [email protected];
			next;
			emotion ET_BEST;
			mes "["+ [email protected]$ +"]";
			mes "Good! Succes!!!";
			mes "I am the best Armsmith.";
			next;
		} else {
			if (rand(100) < 80) {
				mes "["+ [email protected]$ +"]";
				mes "Clang! Clang! Clang! Clang!";
				downrefitem [email protected],0; // Only for the fail refinement animation
				next;
				emotion (!rand(5))?ET_MONEY:ET_HUK;
				mes "["+ [email protected]$ +"]";
				mes "Ahhh!!!";
				next;
				mes "["+ [email protected]$ +"]";
				mes "Oh my god!";
				mes "The upgrade level has dropped...";
			} else {
				mes "["+ [email protected]$ +"]";
				mes "Clang! Clang! Clang!";
				downrefitem [email protected],0; // Only for the fail refinement animation
				next;
				emotion (!rand(5))?ET_MONEY:ET_HUK;
				mes "["+ [email protected]$ +"]";
				mes "Hmmm!";
				next;
				mes "["+ [email protected]$ +"]";
				mes "Oh my! I've failed to refine stuff...";
				mes "I didn't mean it!";
			}
			mes "I could have made a mistake even though I am the best Armsmith ever.";
			mes "It just wasn't meant to be.";
			next;
			mes "["+ [email protected]$ +"]";
			mes "I will do a better job next time! Don't worry!";
			next;
		}
		mes "["+ [email protected]$ +"]";
		mes "Do you want to refine again?";
		next;
		if(select("Yes:No") == 2){
			mes "["+ [email protected]_name$ +"]";
			mes "Hm... if you mind... never mind...";
			close;
		}
	}

	return;
}

prt_in,54,58,3	script	Refiner#1	813,{
	callfunc "omnirefine","^0000FFBlessed Refiner^000000";
	end;
}

try this, you just have to find all and rename it... or save the name to a variable, and use that variable to display the name

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this