Jump to content
  • 0

Random Option NPC not working


DrGruning

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  7
  • Reputation:   0
  • Joined:  12/30/18
  • Last Seen:  

//===== rAthena Script =======================================
//= Random Option NPC dealer
//===== By: ==================================================
//= Keitenai
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= Deals with a player to apply random item option
//= for the price of zeny/cashpoint
//============================================================

vip_lounge,70,147,3	script	Magnus	500,{
	goto NPC;
end;

OnInit:
//==============================
//	CURRENCY SETTING
//	1 = Zeny
//	0 = Cashpoints
//==============================
set .Currency,1;		// Currency to buy random option
//==============================
//	RANDOM OPTION SETTING
//==============================
	set .OverWrite,1;	// Allows overwriting the already existing option enchantment ( 0 to disable )
	set .MaxOpt,64;	// Maximum item option a player can enchant ( reference: https://github.com/rathena/rathena/blob/master/db/const.txt#L1645-L1836 )
	set .MinOpt,1;		// Minimum item option a player can enchant
	set .MinValue,1;	// Minimum option effect value
	set .MaxValue,10;	// Maximum option effect value
	set .MaxIndex,3;	// Maximum option slots ( default is 0 to 4 )

	// Random option that will not be applied
	setarray .ignore[0],
end;

NPC:
disable_items;
	mes "[ Magnus ]";
	mes "Good day sir";
	mes "My name is magnus and i can unlock your Weapon inner abilities";
	mes "abilities are chosen at ^FF0000random^000000";
	next;
	mes "[ Magnus ]";
	mes "I can make your weapon";
	mes "become more powerful";
	if(.Currency){
		mes "For a prize of ^0000FF1x Weapon V Core^000000,";
	} else {
		mes "For a prize of ^0000FF"+.Price+" Cashpoints^000000,";
	}
	mes "I will apply a ^FF0000RANDOM^000000";
	mes "option enchantment on your";
	mes "equipment. (^_^)";
	next;
	if(select("^0000FFEnchant my equip!^000000:Nevermind i changed my mind...")==2) goto OnCancel;
	mes "[ Magnus ]";
	mes "Wonderful!";
	mes "i'll start right away";
	mes "Don't move a muscle while";
	mes "i'm enchanting your equipment!";
	close2;

	setarray .@eq[1], EQI_HAND_R;
	for(set .@i,1; .@i<getarraysize(.@eq); set .@i,.@i+1){
		if(getequipisequiped(.@eq[.@i])){
			set .@menu$,.@menu$+F_getpositionname(.@eq[.@i])+" ~ [ " + getequipname(.@eq[.@i]) + " ]";
			set .@equipped,1;
		} set .@menu$,.@menu$+":";
	} set .@part,.@eq[select(.@menu$)];

	set .@val,rand(.MinValue,.MaxValue);

OnLoop:
    set .@opt,rand(.MinOpt,.MaxOpt);
    for(set .@f,1; .@f<getarraysize(.ignore); set .@f,.@f+1){
        if(.@opt==.ignore[.@f]){
            goto IgnoreCheck;
            end;
        }
    }
    goto OnApplyOpts;
end;

IgnoreCheck:
    set .@opt,rand(.MinOpt,.MaxOpt);
    for(set .@f,1; .@f<getarraysize(.ignore); set .@f,.@f+1)
        if(.@opt==.ignore[.@f]){
            goto OnLoop;
            end;
        }
OnApplyOpts:
	set .@indx,rand(.MaxIndex);
	if(!.OverWrite){
		if(getequiprandomoption(.@part,4,ROA_ID,getcharid(0))) set .@x4,4;
		if(getequiprandomoption(.@part,3,ROA_ID,getcharid(0))) set .@x3,3;
		if(getequiprandomoption(.@part,2,ROA_ID,getcharid(0))) set .@x2,2;
		if(getequiprandomoption(.@part,1,ROA_ID,getcharid(0))) set .@x1,1;
		if(getequiprandomoption(.@part,0,ROA_ID,getcharid(0))) set .@x0,0;

		if(.@indx == 0 && .@x0)
			if(.@indx==.MaxIndex) goto OnMax;
			else set .@indx,1;
		if(.@indx == 1 && .@x1)
			if(.@indx==.MaxIndex) goto OnMax;
			else set .@indx,2;
		if(.@indx == 2 && .@x2)
			if(.@indx==.MaxIndex) goto OnMax;
			else set .@indx,3;
		if(.@indx == 3 && .@x3)
			if(.@indx==.MaxIndex) goto OnMax;
			else set .@indx,4;
		if(.@indx == 4 && .@x4)
			if(.@indx==.MaxIndex) goto OnMax;
	}
	if(.@indx == 4 && (!getequiprandomoption(.@part,3,ROA_ID,getcharid(0)))) set .@indx,3;
	if(.@indx == 3 && (!getequiprandomoption(.@part,2,ROA_ID,getcharid(0)))) set .@indx,2;
	if(.@indx == 2 && (!getequiprandomoption(.@part,1,ROA_ID,getcharid(0)))) set .@indx,1;
	if(.@indx == 1 && (!getequiprandomoption(.@part,0,ROA_ID,getcharid(0)))) set .@indx,0;
	if(.Currency){
		if( countitem(20986) < 1 )
			goto PriceFail;
		else
			delitem 20986,1;
	} else {
		if(#CASHPOINTS < .Price)
			goto PriceFail;
		else
			set #CASHPOINTS,#CASHPOINTS-.Price;
	}
	// Success!!
	setrandomoption(.@part,.@indx,.@opt,.@val,.@indx,getcharid(0));
end;

OnMax:
	mes "[ Magnus ]";
	mes "Wow! your equip already";
	mes "Maxed out its option";
	mes "enchant slots!";
	mes "Sorry but I can't add";
	mes "any more enchantment with";
	mes "your equipment.";
close;

OnFailure:
specialeffect2 EF_PHARMACY_FAIL;
	mes "[ Magnus ]"," ";
	mes "I'm really sorry..."," ";
	mes "^FF0000The process have failed...";
	mes "Your item has been destroyed.^000000";
	delequip .@part;
close;

PriceFail:
	mes "[ Magnus ]";
	mes "What's this?";
	mes "Are you kidding me?";
	mes "Sorry but I don't work";
	mes "for free!";
	mes "You can come back if you";
	mes "Have enough to pay for";
	mes "my service.";
close;

OnCancel:
	mes "[ Magnus ]";
	mes "Suit yourself.";
	mes "Let me know if you";
	mes "ever changed you mind";
close;
}

Although random option is applied and the bonus works, when i relog, the last random option applied dissapear, i tried simpliers script and it worked, this somehow not

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  477
  • Reputation:   269
  • Joined:  06/13/17
  • Last Seen:  

Because that how it works on this script. its working as intended.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  7
  • Reputation:   0
  • Joined:  12/30/18
  • Last Seen:  

Thanks for your input, but i don't think that's how its supposed to work, random option should stay permanently if so, enlight me otherwise.

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