Jump to content
  • 0

Simplifying this npc.


Tassadar

Question


  • Group:  Members
  • Topic Count:  52
  • Topics Per Day:  0.02
  • Content Count:  107
  • Reputation:   5
  • Joined:  07/21/16
  • Last Seen:  

I'm editing this npc:

function	script	omnirefine	{
	.@name$ = getarg(0);
	/// Custom chances 1 to 20.
	setarray .@refine_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 .@equip_name$[1],"Head","Middle","Lower","Armor","Weapon","Shield","Garment","Shoes","Accessory 1","Accessory 2";
	/// Weapon material
	.@weapon_material = 6438; // Omni-Oridecon
	/// Armor material
	.@armor_material = 6439; // Mega-Elunium

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

	setarray .@equip_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 (.@i = 1; .@i <= getarraysize(.@equip_pos); ++.@i) {
		if (getequipisequiped(.@equip_pos[.@i]))
			.@menu$ += getequipname(.@equip_pos[.@i]);
		else
			.@menu$ += "^777777" + .@equip_name$[.@i] + " - " + "[Unavailable]" + "^000000";
		.@menu$ += ":";
	}
	.@part = .@equip_pos[select(.@menu$)];
	.@equip_id = getequipid(.@part);
	.@refinerycnt = getequiprefinerycnt(.@part);
	if (!getequipisequiped(.@part)) { //custom check
		mes "["+ .@name$ +"]";
		mes "You're not wearing";
		mes "anything there that";
		mes "I can refine.";
		emotion ET_FRET;
		close;
	}
	if (!getequipisenableref(.@part)) {
		mes "["+ .@name$ +"]";
		mes "I don't think I can";
		mes "refine this item at all...";
		close;
	}
	if (.@refinerycnt >= 20) { //custom check
		mes "["+ .@name$ +"]";
		mes "I can't refine this";
		mes "any more. This is as";
		mes "refined as it gets!";
		close;
	}
//		 if (getiteminfo(.@equip_id,2) == 5) .@material = .@weapon_material;
//	else if (getiteminfo(.@equip_id,2) == 4) .@material = .@armor_material;
		 if (getiteminfo(.@equip_id,2) == 5) .@material = "Omni-Oridecon";
	else if (getiteminfo(.@equip_id,2) == 4) .@material = "Mega-Elunium";
	
	
	if ((getequipweaponlv(.@part) >= 1) && (getequipweaponlv(.@part) <= 4)) {
		.@article$ = "a";
		.@type$ = "weapon";
	} else {
		.@article$ = "an";
		.@type$ = "armor";
	}
	
	mes "["+ .@name$ +"]";
	mes "Hmm " + .@article$ + " " + .@type$ + ", is that ok?";
	mes "If you want to refine this " + .@type$ + ",";
	mes "I will need 1 ^FF0000" + getitemname(.@material) + "^000000.";
	mes "Are you sure you want to continue?";
	next;
	if(select("Yes:No") == 2){
		mes "["+ .@npc_name$ +"]";
		mes "Hm... if you mind... never mind...";
		close;
	}
	while (1) {
		.@refinerycnt = getequiprefinerycnt(.@part);
		if (countitem(.@material) < 1) {
			mes "["+ .@name$ +"]";
			mes "Hm. You don't seem to have enough  "+getitemname(.@material)+".";
			mes "Please come back when you have them.";
			close;
		}
		delitem .@material,1;
		// anti-hack
		if (callfunc("F_IsEquipIDHack", .@part, .@equip_id) ||
		    callfunc("F_IsEquipRefineHack", .@part, .@refinerycnt)) {
			mes "["+ .@name$ +"]";
			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 (.@refine_chances[.@refinerycnt+1] > rand(100)) {
			mes "["+ .@name$ +"]";
			mes "Clang! Clang! Clang! Clang!";
			successrefitem .@part;
			next;
			emotion ET_BEST;
			mes "["+ .@name$ +"]";
			mes "Good! Succes!!!";
			mes "I am the best Armsmith.";
			next;
		} else {
			if (rand(100) < 80) {
				mes "["+ .@name$ +"]";
				mes "Clang! Clang! Clang! Clang!";
				downrefitem .@part,0; // Only for the fail refinement animation
				next;
				emotion (!rand(5))?ET_MONEY:ET_HUK;
				mes "["+ .@name$ +"]";
				mes "Ahhh!!!";
				next;
				mes "["+ .@name$ +"]";
				mes "Oh my god!";
				mes "The upgrade level has dropped...";
			} else {
				mes "["+ .@name$ +"]";
				mes "Clang! Clang! Clang!";
				downrefitem .@part,0; // Only for the fail refinement animation
				next;
				emotion (!rand(5))?ET_MONEY:ET_HUK;
				mes "["+ .@name$ +"]";
				mes "Hmmm!";
				next;
				mes "["+ .@name$ +"]";
				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 "["+ .@name$ +"]";
			mes "I will do a better job next time! Don't worry!";
			next;
		}
		mes "["+ .@name$ +"]";
		mes "Do you want to refine again?";
		next;
		if(select("Yes:No") == 2){
			mes "["+ .@npc_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(.@weapon_material) + "^000000 and FF0000" + getitemname(.@armor_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(.@equip_id,2) == 5) .@material = .@weapon_material;
//	else if (getiteminfo(.@equip_id,2) == 4) .@material = .@armor_material;

for

		 if (getiteminfo(.@equip_id,2) == 5) .@material = "Omni-Oridecon";
	else if (getiteminfo(.@equip_id,2) == 4) .@material = "Mega-Elunium";

It loads this variable here:
 

	mes "["+ .@name$ +"]";
	mes "Hmm " + .@article$ + " " + .@type$ + ", is that ok?";
	mes "If you want to refine this " + .@type$ + ",";
	mes "I will need 1 ^FF0000" + getitemname(.@material) + "^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
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  292
  • Reputation:   199
  • Joined:  05/03/13
  • Last Seen:  

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 .@material = „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.

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

function	script	omnirefine	{
	.@name$ = getarg(0);
	/// Custom chances 1 to 20.
	setarray .@refine_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 .@equip_name$[1],"Head","Middle","Lower","Armor","Weapon","Shield","Garment","Shoes","Accessory 1","Accessory 2";
	/// Weapon material
	.@weapon_material = 6438; // Omni-Oridecon
	.@weapon_material_name$ = "Omni-Oridecon";
	/// Armor material
	.@armor_material = 6439; // Mega-Elunium
	.@armor_material_name$ = "Mega-Elunium":
	
	disable_items;
	mes "["+ .@name$ +"]";
	mes "I am the best Armsmith ever!";
	mes "I don't refine with normal, boring materials.";
//	mes "I only refine items using ^FF0000" + getitemname(.@weapon_material) + "^000000 and FF0000" + getitemname(.@armor_material) + "^000000.";
	mes "I only refine items using ^FF0000"+.@weapon_material_name$+"^000000 and ^FF0000"+.@armor_material_name$+"^000000.";	
	next;
	mes "["+ .@name$ +"]";
	mes "Anyway, you may use my services if you have any of that materials.";
	mes "What do you want me to refine?";
	next;

	setarray .@equip_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 (.@i = 1; .@i <= getarraysize(.@equip_pos); ++.@i) {
		if (getequipisequiped(.@equip_pos[.@i]))
			.@menu$ += getequipname(.@equip_pos[.@i]);
		else
			.@menu$ += "^777777" + .@equip_name$[.@i] + " - " + "[Unavailable]" + "^000000";
		.@menu$ += ":";
	}
	.@part = .@equip_pos[select(.@menu$)];
	.@equip_id = getequipid(.@part);
	.@refinerycnt = getequiprefinerycnt(.@part);
	if (!getequipisequiped(.@part)) { //custom check
		mes "["+ .@name$ +"]";
		mes "You're not wearing";
		mes "anything there that";
		mes "I can refine.";
		emotion ET_FRET;
		close;
	}
	if (!getequipisenableref(.@part)) {
		mes "["+ .@name$ +"]";
		mes "I don't think I can";
		mes "refine this item at all...";
		close;
	}
	if (.@refinerycnt >= 20) { //custom check
		mes "["+ .@name$ +"]";
		mes "I can't refine this";
		mes "any more. This is as";
		mes "refined as it gets!";
		close;
	}
	
	if (getiteminfo(.@equip_id,2) == 5) {
		.@material = .@weapon_material;
		.@material_name$ = .@weapon_material_name$;
	}
	else if (getiteminfo(.@equip_id,2) == 4) { 
		.@material = .@armor_material;
		.@material_name$ = .@armor_material_name$;
	}
	
	
	if ((getequipweaponlv(.@part) >= 1) && (getequipweaponlv(.@part) <= 4)) {
		.@article$ = "a";
		.@type$ = "weapon";
	} else {
		.@article$ = "an";
		.@type$ = "armor";
	}
	
	mes "["+ .@name$ +"]";
	mes "Hmm " + .@article$ + " " + .@type$ + ", is that ok?";
	mes "If you want to refine this " + .@type$ + ",";
	mes "I will need 1 ^FF0000" + .@material_name$ + "^000000.";
	mes "Are you sure you want to continue?";
	next;
	if(select("Yes:No") == 2){
		mes "["+ .@npc_name$ +"]";
		mes "Hm... if you mind... never mind...";
		close;
	}
	while (1) {
		.@refinerycnt = getequiprefinerycnt(.@part);
		if (countitem(.@material) < 1) {
			mes "["+ .@name$ +"]";
			mes "Hm. You don't seem to have enough  "+.@material_name$+".";
			mes "Please come back when you have them.";
			close;
		}
		delitem .@material,1;
		// anti-hack
		if (callfunc("F_IsEquipIDHack", .@part, .@equip_id) ||
		    callfunc("F_IsEquipRefineHack", .@part, .@refinerycnt)) {
			mes "["+ .@name$ +"]";
			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 (.@refine_chances[.@refinerycnt+1] > rand(100)) {
			mes "["+ .@name$ +"]";
			mes "Clang! Clang! Clang! Clang!";
			successrefitem .@part;
			next;
			emotion ET_BEST;
			mes "["+ .@name$ +"]";
			mes "Good! Succes!!!";
			mes "I am the best Armsmith.";
			next;
		} else {
			if (rand(100) < 80) {
				mes "["+ .@name$ +"]";
				mes "Clang! Clang! Clang! Clang!";
				downrefitem .@part,0; // Only for the fail refinement animation
				next;
				emotion (!rand(5))?ET_MONEY:ET_HUK;
				mes "["+ .@name$ +"]";
				mes "Ahhh!!!";
				next;
				mes "["+ .@name$ +"]";
				mes "Oh my god!";
				mes "The upgrade level has dropped...";
			} else {
				mes "["+ .@name$ +"]";
				mes "Clang! Clang! Clang!";
				downrefitem .@part,0; // Only for the fail refinement animation
				next;
				emotion (!rand(5))?ET_MONEY:ET_HUK;
				mes "["+ .@name$ +"]";
				mes "Hmmm!";
				next;
				mes "["+ .@name$ +"]";
				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 "["+ .@name$ +"]";
			mes "I will do a better job next time! Don't worry!";
			next;
		}
		mes "["+ .@name$ +"]";
		mes "Do you want to refine again?";
		next;
		if(select("Yes:No") == 2){
			mes "["+ .@npc_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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...