• 0
insandedid

Have any person Write SHOP script random option on buy item ?

Question

 Have any person Write script SHOP NPC random option on buy item ?

if


OnBuyItem:


function random option add to item aforementioned .

 

58eb8b803ea29_ScreenShot2560-04-10at7_22_04PM.png.a46c51e616e8967a263526f38b5756b1.png

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

How about https://gist.github.com/Atemo/7b741b940ce324c2fa17b8ccdcd84133/revisions

The random options are randomly given when purchasing in the script btw.

 

Mark the shop number as random option shop in

// -----------------------------------------------------------
//  List of Shop ID using random option system.
// -----------------------------------------------------------

	Shop_Random_Option(1,2);	// shop 1 and 2 are using random option system.

Set the option given randomly for each slot in

function get_option_id {
	// opt slot 1
	[email protected][0] = F_Rand(
		RDMOPT_DAMAGE_PROPERTY_NOTHING_TARGET,		RDMOPT_DAMAGE_PROPERTY_POISON_TARGET,
		RDMOPT_DAMAGE_PROPERTY_UNDEAD_TARGET,		RDMOPT_DAMAGE_PROPERTY_DARKNESS_TARGET,
		RDMOPT_DAMAGE_PROPERTY_TELEKINESIS_TARGET,	RDMOPT_DAMAGE_PROPERTY_SAINT_TARGET,
		RDMOPT_DAMAGE_PROPERTY_FIRE_TARGET,			RDMOPT_DAMAGE_PROPERTY_WIND_TARGET,
		RDMOPT_DAMAGE_PROPERTY_WATER_TARGET,		RDMOPT_DAMAGE_PROPERTY_GROUND_TARGET
	);

	// opt slot 2
	[email protected][1] = F_Rand(
		RDMOPT_RACE_DAMAGE_NOTHING,						RDMOPT_RACE_DAMAGE_UNDEAD,
		RDMOPT_RACE_DAMAGE_INSECT,						RDMOPT_RACE_DAMAGE_HUMAN,
		RDMOPT_RACE_DAMAGE_DRAGON,						RDMOPT_RACE_DAMAGE_ANGEL,
		RDMOPT_RACE_DAMAGE_PLANT,						RDMOPT_RACE_DAMAGE_DEVIL,
		RDMOPT_RACE_DAMAGE_ANIMAL,						RDMOPT_RACE_DAMAGE_FISHS
	);

	// opt slot 3
	// [email protected][2] =

	// opt slot 4
	// [email protected][3] =

	setarray getarg(0), [email protected][0], [email protected][1], [email protected][2], [email protected][3];
	return;
}

and set the value for each option ID in

// return a random value depending of the option ID
function get_option_value {
	[email protected]_of_optid = getarraysize( getarg(1) );
	for ( [email protected] = 0; [email protected] < [email protected]_of_optid; [email protected]++ ) {
		[email protected] = getelementofarray( getarg(1), [email protected] );

		switch([email protected]) {
			case RDMOPT_DAMAGE_PROPERTY_NOTHING_TARGET:
			case RDMOPT_DAMAGE_PROPERTY_POISON_TARGET:
			case RDMOPT_DAMAGE_PROPERTY_UNDEAD_TARGET:
			case RDMOPT_DAMAGE_PROPERTY_DARKNESS_TARGET:
			case RDMOPT_DAMAGE_PROPERTY_TELEKINESIS_TARGET:
			case RDMOPT_DAMAGE_PROPERTY_SAINT_TARGET:
			case RDMOPT_DAMAGE_PROPERTY_FIRE_TARGET:
			case RDMOPT_DAMAGE_PROPERTY_WIND_TARGET:
			case RDMOPT_DAMAGE_PROPERTY_WATER_TARGET:
			case RDMOPT_DAMAGE_PROPERTY_GROUND_TARGET:
				[email protected] = rand(1,20);
				break;
			case RDMOPT_RACE_DAMAGE_NOTHING:
			case RDMOPT_RACE_DAMAGE_UNDEAD:
			case RDMOPT_RACE_DAMAGE_INSECT:
			case RDMOPT_RACE_DAMAGE_HUMAN:
			case RDMOPT_RACE_DAMAGE_DRAGON:
			case RDMOPT_RACE_DAMAGE_ANGEL:
			case RDMOPT_RACE_DAMAGE_PLANT:
			case RDMOPT_RACE_DAMAGE_DEVIL:
			case RDMOPT_RACE_DAMAGE_ANIMAL:
			case RDMOPT_RACE_DAMAGE_FISHS:
				[email protected] = rand(1,20);
				break;
		}

		set getelementofarray( getarg(0), [email protected] ), [email protected];
	}
	return;
}

 

  • Upvote 2
  • MVP 1
  • Like 1

Share this post


Link to post
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.

Loading...