Jump to content
  • 0

Give 2 random Enchant in 1 roll


LearningRO

Question


  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

how to make enchant armor script give 2 random enchant in 1 roll. and can be repeat to enchant again?

 

thanks

Edited by melv0
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  81
  • Reputation:   14
  • Joined:  11/17/17
  • Last Seen:  

Hi, you can find many sample files in folder npc/re/merchants/enchant_**.txt

This is my script that give 3 random enchants in 1 roll.

prontera,156,186,4	script	stest	857,{
	.@part = EQI_ARMOR;
	.@item_to_test = 2302; // Cotton Shirt [1]

	if (!countitem(.@item_to_test)) {
		specialeffect2 EF_STEAL;
		getitem2 .@item_to_test,1,1,7,0,4003,0,0,0;
		message strcharinfo(0),"You got a Cotton Shirt to test.";
		end;
	}

	if (!getequipisequiped(.@part)) {
		message strcharinfo(0), "Make sure you're wearing the equipment first.";
		end;
	}

	// Enchant stones
	setarray .@enchant_slot1[0],4710,4711,4720,4721; //Inteligence1,Inteligence2,Dexterity1,Dexterity2
	setarray .@enchant_slot2[0],4711,4720,4721,4740; //Inteligence2,Dexterity1,Dexterity2,Vitality1
	setarray .@enchant_slot3[0],4764,4799,4766,4788; //Critical5,HP500,Atk2,Mdef6

	// Random
	.@enchant_1 = .@enchant_slot1[rand(getarraysize(.@enchant_slot1))];
	.@enchant_2 = .@enchant_slot2[rand(getarraysize(.@enchant_slot2))];
	.@enchant_3 = .@enchant_slot3[rand(getarraysize(.@enchant_slot3))];

	// Get current refine to keep refine
	.@equip_refine = getequiprefinerycnt(.@part);

	// Get current card to keep card
	setarray .@equip_card[0], getequipcardid(.@part,0),getequipcardid(.@part,1),getequipcardid(.@part,2),getequipcardid(.@part,3);

	// Delete item
	delitem .@item_to_test,1; // Cotton Shirt [1]

	// Can break armor?
	if (rand(100) < 50) {
		specialeffect2 EF_SUI_EXPLOSION;
		message strcharinfo(0),"Oh Shit!";
		end;
	} else {
		// Effect
		specialeffect2 EF_REPAIRWEAPON;
		emotion ET_BEST;

		// Get a new item
		getitem2 .@item_to_test,1,1,.@equip_refine,0,.@equip_card[0],.@enchant_1,.@enchant_2,.@enchant_3;
		message strcharinfo(0),"Yay!";
	}
	end;
}

It took me about 15 minutes..., hope it helps you ?

Edited by rongmauhong
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  5
  • Reputation:   1
  • Joined:  09/24/16
  • Last Seen:  

On 2/20/2019 at 10:41 AM, rongmauhong said:

Hi, you can find many sample files in folder npc/re/merchants/enchant_**.txt

This is my script that give 3 random enchants in 1 roll.


prontera,156,186,4	script	stest	857,{
	.@part = EQI_ARMOR;
	.@item_to_test = 2302; // Cotton Shirt [1]

	if (!countitem(.@item_to_test)) {
		specialeffect2 EF_STEAL;
		getitem2 .@item_to_test,1,1,7,0,4003,0,0,0;
		message strcharinfo(0),"You got a Cotton Shirt to test.";
		end;
	}

	if (!getequipisequiped(.@part)) {
		message strcharinfo(0), "Make sure you're wearing the equipment first.";
		end;
	}

	// Enchant stones
	setarray .@enchant_slot1[0],4710,4711,4720,4721; //Inteligence1,Inteligence2,Dexterity1,Dexterity2
	setarray .@enchant_slot2[0],4711,4720,4721,4740; //Inteligence2,Dexterity1,Dexterity2,Vitality1
	setarray .@enchant_slot3[0],4764,4799,4766,4788; //Critical5,HP500,Atk2,Mdef6

	// Random
	.@enchant_1 = .@enchant_slot1[rand(getarraysize(.@enchant_slot1))];
	.@enchant_2 = .@enchant_slot2[rand(getarraysize(.@enchant_slot2))];
	.@enchant_3 = .@enchant_slot3[rand(getarraysize(.@enchant_slot3))];

	// Get current refine to keep refine
	.@equip_refine = getequiprefinerycnt(.@part);

	// Get current card to keep card
	setarray .@equip_card[0], getequipcardid(.@part,0),getequipcardid(.@part,1),getequipcardid(.@part,2),getequipcardid(.@part,3);

	// Delete item
	delitem .@item_to_test,1; // Cotton Shirt [1]

	// Can break armor?
	if (rand(100) < 50) {
		specialeffect2 EF_SUI_EXPLOSION;
		message strcharinfo(0),"Oh Shit!";
		end;
	} else {
		// Effect
		specialeffect2 EF_REPAIRWEAPON;
		emotion ET_BEST;

		// Get a new item
		getitem2 .@item_to_test,1,1,.@equip_refine,0,.@equip_card[0],.@enchant_1,.@enchant_2,.@enchant_3;
		message strcharinfo(0),"Yay!";
	}
	end;
}

It took me about 15 minutes..., hope it helps you ?

Thank you. This really helped me.
I would like to ask for a little more help from you.
What can I do to allow the top script to be able to enchant all equiptment?
Including costumes and accessories

But I would like to be able to choose one piece of enchant one piece at a time

Edited by nonmairub
Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

On 10/9/2019 at 2:05 PM, nonmairub said:

Thank you. This really helped me.
I would like to ask for a little more help from you.
What can I do to allow the top script to be able to enchant all equiptment?
Including costumes and accessories

But I would like to be able to choose one piece of enchant one piece at a time

try this

prontera,156,186,4	script	stest	857,{

	setarray .@indices,EQI_ACC_L,EQI_ACC_R,
		EQI_SHOES,EQI_GARMENT,
		EQI_HEAD_LOW,EQI_HEAD_MID,
		EQI_HEAD_TOP,EQI_ARMOR,EQI_HAND_L ,EQI_HAND_R,
		EQI_COSTUME_HEAD_TOP,EQI_COSTUME_HEAD_MID,
		EQI_COSTUME_HEAD_LOW,EQI_COSTUME_GARMENT,
		EQI_SHADOW_ARMOR,EQI_SHADOW_WEAPON,
		EQI_SHADOW_SHIELD,EQI_SHADOW_SHOES,
		EQI_SHADOW_ACC_R,EQI_SHADOW_ACC_L;
	for(.@i = 0;.@i < getarraysize(.@indices);.@i++){
		if (getequipisequiped(.@indices[.@i])) {
			set .@menu$, .@menu$ + F_getpositionname(.@indices[.@i]) + "-[" + getequipname(.@indices[.@i]) + "]";
			set .@equipped,1;
		}
		set .@menu$, .@menu$ + ":";
	}
	if (.@equipped == 0) {
		mes "[Suhnbi]";
		mes "I don't think I can refine any items you have...";
		close;
	}
	set .@part, .@indices[ select(.@menu$) ];

	if (!getequipisequiped(.@part)) {
		message strcharinfo(0), "Make sure you're wearing the equipment first.";
		end;
	}

	// Enchant stones
	setarray .@enchant_slot1[0],4710,4711,4720,4721; //Inteligence1,Inteligence2,Dexterity1,Dexterity2
	setarray .@enchant_slot2[0],4711,4720,4721,4740; //Inteligence2,Dexterity1,Dexterity2,Vitality1
	setarray .@enchant_slot3[0],4764,4799,4766,4788; //Critical5,HP500,Atk2,Mdef6

	// Random
	.@enchant_1 = .@enchant_slot1[rand(getarraysize(.@enchant_slot1))];
	.@enchant_2 = .@enchant_slot2[rand(getarraysize(.@enchant_slot2))];
	.@enchant_3 = .@enchant_slot3[rand(getarraysize(.@enchant_slot3))];

	// Get current refine to keep refine
	.@equip_refine = getequiprefinerycnt(.@part);

	// Get current card to keep card
	setarray .@equip_card[0], getequipcardid(.@part,0),getequipcardid(.@part,1),getequipcardid(.@part,2),getequipcardid(.@part,3);

	// Delete item
	delitem .@item_to_test,1; // Cotton Shirt [1]

	// Can break armor?
	if (rand(100) < 50) {
		specialeffect2 EF_SUI_EXPLOSION;
		message strcharinfo(0),"Oh Shit!";
		end;
	} else {
		// Effect
		specialeffect2 EF_REPAIRWEAPON;
		emotion ET_BEST;

		// Get a new item
		getitem2 .@item_to_test,1,1,.@equip_refine,0,.@equip_card[0],.@enchant_1,.@enchant_2,.@enchant_3;
		message strcharinfo(0),"Yay!";
	}
	end;
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  5
  • Reputation:   1
  • Joined:  09/24/16
  • Last Seen:  

3 hours ago, sader1992 said:

try this


prontera,156,186,4	script	stest	857,{

	setarray .@indices,EQI_ACC_L,EQI_ACC_R,
		EQI_SHOES,EQI_GARMENT,
		EQI_HEAD_LOW,EQI_HEAD_MID,
		EQI_HEAD_TOP,EQI_ARMOR,EQI_HAND_L ,EQI_HAND_R,
		EQI_COSTUME_HEAD_TOP,EQI_COSTUME_HEAD_MID,
		EQI_COSTUME_HEAD_LOW,EQI_COSTUME_GARMENT,
		EQI_SHADOW_ARMOR,EQI_SHADOW_WEAPON,
		EQI_SHADOW_SHIELD,EQI_SHADOW_SHOES,
		EQI_SHADOW_ACC_R,EQI_SHADOW_ACC_L;
	for(.@i = 0;.@i < getarraysize(.@indices);.@i++){
		if (getequipisequiped(.@indices[.@i])) {
			set .@menu$, .@menu$ + F_getpositionname(.@indices[.@i]) + "-[" + getequipname(.@indices[.@i]) + "]";
			set .@equipped,1;
		}
		set .@menu$, .@menu$ + ":";
	}
	if (.@equipped == 0) {
		mes "[Suhnbi]";
		mes "I don't think I can refine any items you have...";
		close;
	}
	set .@part, .@indices[ select(.@menu$) ];

	if (!getequipisequiped(.@part)) {
		message strcharinfo(0), "Make sure you're wearing the equipment first.";
		end;
	}

	// Enchant stones
	setarray .@enchant_slot1[0],4710,4711,4720,4721; //Inteligence1,Inteligence2,Dexterity1,Dexterity2
	setarray .@enchant_slot2[0],4711,4720,4721,4740; //Inteligence2,Dexterity1,Dexterity2,Vitality1
	setarray .@enchant_slot3[0],4764,4799,4766,4788; //Critical5,HP500,Atk2,Mdef6

	// Random
	.@enchant_1 = .@enchant_slot1[rand(getarraysize(.@enchant_slot1))];
	.@enchant_2 = .@enchant_slot2[rand(getarraysize(.@enchant_slot2))];
	.@enchant_3 = .@enchant_slot3[rand(getarraysize(.@enchant_slot3))];

	// Get current refine to keep refine
	.@equip_refine = getequiprefinerycnt(.@part);

	// Get current card to keep card
	setarray .@equip_card[0], getequipcardid(.@part,0),getequipcardid(.@part,1),getequipcardid(.@part,2),getequipcardid(.@part,3);

	// Delete item
	delitem .@item_to_test,1; // Cotton Shirt [1]

	// Can break armor?
	if (rand(100) < 50) {
		specialeffect2 EF_SUI_EXPLOSION;
		message strcharinfo(0),"Oh Shit!";
		end;
	} else {
		// Effect
		specialeffect2 EF_REPAIRWEAPON;
		emotion ET_BEST;

		// Get a new item
		getitem2 .@item_to_test,1,1,.@equip_refine,0,.@equip_card[0],.@enchant_1,.@enchant_2,.@enchant_3;
		message strcharinfo(0),"Yay!";
	}
	end;
}

 

thanks you very much ❤️ 
 

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...