Jump to content
  • 0

Hat Smith npc[not sure how to do setup]


kealzorz

Question


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   0
  • Joined:  02/02/12
  • Last Seen:  

So what I want to do is, after him explaining the items random, it'll tell him what his item is, what I don't know how to do it make it so it'll randomly choose from a list of items. Anyone know how to add this, or what commands/functions to use, also if you click it again it'll continue from the previous quest so you'll still need to collect those same 1-100 etc. items.

thanks for any help :)

prontera,156,145,4 script Hatsmith 480,{
mes "[^aa5500Roger the Hatsmith^000000]";
mes "Hi, I'm the Legendary Hatsmith Roger, how may I help you?";
next;
switch(select("Play A Hat Game","Use A Hat Ticket","Just Wanted To Say Hi")) {
case 1:
mes "In the first game you must collect x of and etc. item.";
mes "Usually between 1-100, the item will be chosen at random.";
next;
mes "Your item is ";
close;

case 2:
mes "This option is not ready yet, sorry!";
close;

case 3:
mes "[" + strcharinfo(0) + "]";
mes "Hi, nice to meet you Mr. Hatsmith.";
next;
mes "[^aa5500Roger the Hatsmith^000000]";
mes "Nice to meet you too " + strcharinfo(0) + ".";
close;
}
}

I was thinking of using this, but not sure what else goes with it.

set .rand, rand(1,100);

bump

Edited by kealzorz
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

kinda fun making this script

been awhile I scripted something like mission board

function	script	rand__	{
.@range = getarg(0);
.@count = getarg(2, 0);
.@count = ( .@count == 0 || .@count > .@range )? .@range : ( .@count > 128 )? 128 : .@count;
while ( .@i < .@count ) {
	.@r = .@save = rand( .@i, .@range -1 ) ;
	if ( getd(".@tmp1_"+ .@i ) == 0 ) {
		.@r = ( getd(".@tmp1_"+ .@r ) )? getd( ".@tmp2_"+ .@r ) : .@r;
		setd ".@tmp2_"+ .@i, .@r;
		setd ".@tmp2_"+ .@save , .@i;
		setd ".@tmp1_"+ .@save , 1;
		set getelementofarray( getarg(1), .@i ), .@r;
		if ( .@save < .@count )
			set getelementofarray( getarg(1), .@save ), .@i;
	}
	.@i++;
}
return .@count;
}

prontera,156,188,5	script	khdfsdkjhf	100,{
//	hatgame$ = "";
if ( hatgame$ != "" ) {
	explode @tmp$, hatgame$, "#";
	callsub L_preview;
	next;
	for ( .@i = 1; .@i <= 3; .@i++ ) {
		if ( countitem( .itemreq[ atoi( @tmp$[ .@i ] ) *2 ] ) < .itemreq[ atoi( @tmp$[ .@i ] ) *2 +1 ] ) {
			mes "you don't have enough "+ getitemname( .itemreq[ atoi( @tmp$[ .@i ] ) *2 ] );
			close;
		}
	}
	for ( .@i = 1; .@i <= 3; .@i++ )
		delitem .itemreq[ atoi( @tmp$[ .@i ] ) *2 ], .itemreq[ atoi( @tmp$[ .@i ] ) *2 +1 ];
	getitem atoi( @tmp$[0] ), 1;
	mes "congrats for "+ getitemname( atoi( @tmp$[0] ) );
	hatgame$ = "";
	close;
}
mes "to play a hat game you need "+ .itemstart[0] +" "+ getitemname(.itemstart[1])+".";
next;
if ( select ( "Yes", "No" ) == 2 ) close;
if ( countitem(.itemstart[1]) < .itemstart[0] ) {
	mes "you don't have enough required items";
	close;
}
delitem .itemstart[1], .itemstart[0];
@tmp$[0] = .rewarditem[ rand( .rewarditemsize ) ] +"";
set .@dummy, callfunc( "rand__", .itemreqsize, $@rand, 3 );
for ( .@i = 0; .@i < 3; .@i++ )
	@tmp$[ .@i +1 ] = $@rand[ .@i ] +"";
hatgame$ = implode( @tmp$, "#" );
callsub L_preview;
close;
L_preview:
mes "headgear : "+ getitemname( atoi( @tmp$[0] ) );
mes "you have to bring";
for ( .@i = 1; .@i <= 3; .@i++ )
	mes .itemreq[ atoi( @tmp$[ .@i ] ) *2 +1 ] +"x "+ getitemname( .itemreq[ atoi( @tmp$[ .@i ] ) *2 ] );
return;
OnInit:
setarray .itemstart,
	10, 909; // 10 jellopy
setarray .itemreq,
	501, 10, // 10 red pot
	502, 9, // 9 orange pot
	503, 8, // 8 yellow pot
	504, 7, // 7 white pot
	505, 6, // 6 blue pot
	512, 1, // 1 apple
	513, 2, // 2 banana
	514, 3, // 3 grape
	515, 4; // 4 carrot
setarray .rewarditem,
	5001, 5002, 5003, 5004;

.itemreqsize = getarraysize(.itemreq) / 2;
.rewarditemsize = getarraysize(.rewarditem);
end;
}

credit to keyworld for the shuffling algorithm

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

play a hat game

- has ticket ( will consume the ticket )

--- pick a quest for random headgear 31000~31050

----- if yes generate 3 set of requirement out of 100 of these ( out of preset 100 requirements, only 3 of them is needed to complete the quest )

i. collect 100 jellopies

ii. collect 20 apples

iii. collect 25 sticky web

iv. collect .....

- if completed the player will get the headgear

so ...

if the player consume 1 ticket, the script generate 1 random quest pick from item ID range 31000~31050 <-- need to save 1 player variable

and pick 3 requirements out of preset 100 <-- need to save another 3 player variables, or use some kind of algoritm to compress into 1 <-- hardest part

I guess the player can give up this quest and let the script generate another by consuming another ticket item

let me tell you

this script is heavily relies on algorithm

especially comparing player saved variable storing the item requirement to the preset script item requirements <-- need comparison on 2 dimensions

I was thinking of using this, but not sure what else goes with it.

set .rand, rand(1,100);

since you stuck on this stage

means you don't even has a slightest clue how to create an array and doing comparison with while-loop ....

you have a long long way to go if you want to make this even look possible ...

PS: pls level up your technique before approaching this level of script ....

you are current level 20 trying to beat a level 80 boss /swt

anyways

step 1.

try to script how to store a player variable with 1 random number

step 2

show me a script that you can store multiple player variables with 3 out of 100 generated numbers

step 3 .... next time ... AFTER you impressed me enough

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   0
  • Joined:  02/02/12
  • Last Seen:  

l'd learn more about the functions, but not really sure where to start, I've looked for guides, nothing. I'm not really sure where to start, but I'm interested in scripting.

Also what I wanted it to be is that the NPC chooses a random item you must collect 'x' amount from a random list of items. then there will be another game after, and more games to get the hat

Edited by kealzorz
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

try do these script,

you can make all these in entirely different npcs / files

1. submit 1 ticket, and the script checks, and delete it

2. the 1st time player click on the npc, npc generate a random number, but from 2nd click on that npc onwards, it will repeat say that generated number forever

if you can pass this stage you should able to make the 1st 20~30 lines of this script ... ( *mes command or dialog isn't count in those lines )

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   0
  • Joined:  02/02/12
  • Last Seen:  

Thanks, I've tried, but I still couldn't' understand arrays, I'm going to use your script to learn.

Edited by kealzorz
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

that's why I said this script is beyond your level

and I don't think at your current level you can learn anything from this script

try study some scripts that is more suitable to your level, like rikimaru's script

well since I already made it, you can make request for more feature etc...

just post a reply and describe in detail what u want me to add

Edited by AnnieRuru
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...