• 0
Sign in to follow this  
Tassadar

NPC Shop be walking ?

Question

Good night..

I need to make a simple modification to a npc I already have, but I do not know if this is possible.

I need an npc shop item to be walking in the middle of prontera.

shop	custom_seller21	-1,673:1000000 // Create our dummy shop.

prontera,150,150,4	script	[Máquina Cartas]	564,{
	
// This code runs when the user clicks our npc.
	mes "[^FF2400Cuidado^000000] Escolha um item!"; // Let the user know about our shop.
	callshop "custom_seller21",1; // Summon our dummy shop filled with custom items.
	
	npcshopattach "custom_seller21"; // Attach the shop to this npc.
	
	end;

// This code runs when a user purchases an item from out shop.
OnBuyItem:
	[email protected] = getarraysize(.customs); // Get the number of customs we're adding.
	[email protected]_len = getarraysize(@bought_nameid); // Get the number of purchased items.

	for( set @i, 0; @i < [email protected]; set @i, @i+1 ) {
		for( set @d,0; @d < [email protected]_len; set @d, @d+1 ) {
			if( @bought_nameid[@d] == .customs[@i] ) { // Check if the purchased item equals our custom item.
				if( countitem(.CoinID) >= .Price[@i] * @bought_quantity[@d] ) { // Check if the user has the correct funds.
					delitem .CoinID,.Price[@i]*@bought_quantity[@d];
					getitem @bought_nameid[@d],@bought_quantity[@d];
				}
			}
		}
	}
	deletearray @bought_quantity, getarraysize(@bought_quantity); // Remove the array.
	deletearray @bought_nameid, getarraysize(@bought_nameid); // Remove the array.
	close;

// This code runs first. When the server is started.
OnInit:
	setarray .customs[0],4035,4060,4063; // An array of out custom items.
	
	set .CoinID,1226; // ID da Moeda em uso.
	
	setarray .Price[0],500,500,500; // The amount of coins needed for our items. (For example: Item 12103 = 20 coins)
	
	npcshopitem "custom_seller21",0,0; // Remove all items from our dummy shop.
	
	for( set [email protected], 0; .customs[[email protected]]; set [email protected], [email protected]+1 ) // Loop through our custom items.
		npcshopadditem "custom_seller10",.customs[[email protected]],.Price[[email protected]]; // Add our custom items to the cleared dummy shop.
	
	end;
}

If it is possible could someone show me how to do it?

If it is possible to do this I can put the sprite of a monster that he will walk?

I thank you for your help.

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
32 minutes ago, Tassadar said:

You can show me how I use? Where in npc I did put all npnwalktos?


shop	custom_seller21	-1,673:1000000 // Create our dummy shop.

prontera,150,150,4	script	[Máquina Cartas]	564,{
	
// This code runs when the user clicks our npc.
	mes "[^FF2400Cuidado^000000] Escolha um item!"; // Let the user know about our shop.
	callshop "custom_seller21",1; // Summon our dummy shop filled with custom items.
	
	npcshopattach "custom_seller21"; // Attach the shop to this npc.
	
	end;

// This code runs when a user purchases an item from out shop.
OnBuyItem:
	[email protected] = getarraysize(.customs); // Get the number of customs we're adding.
	[email protected]_len = getarraysize(@bought_nameid); // Get the number of purchased items.

	for( set @i, 0; @i < [email protected]; set @i, @i+1 ) {
		for( set @d,0; @d < [email protected]_len; set @d, @d+1 ) {
			if( @bought_nameid[@d] == .customs[@i] ) { // Check if the purchased item equals our custom item.
				if( countitem(.CoinID) >= .Price[@i] * @bought_quantity[@d] ) { // Check if the user has the correct funds.
					delitem .CoinID,.Price[@i]*@bought_quantity[@d];
					getitem @bought_nameid[@d],@bought_quantity[@d];
				}
			}
		}
	}
	deletearray @bought_quantity, getarraysize(@bought_quantity); // Remove the array.
	deletearray @bought_nameid, getarraysize(@bought_nameid); // Remove the array.
	close;
	
// Npc walks every 10 sec
OnTimer10000:
	[email protected] = .npc_x + rand( -10,10 );
	[email protected] = .npc_y + rand( -10,10 );
	npcwalkto [email protected],[email protected];
	setnpctimer 0;
	end;

// This code runs first. When the server is started.
OnInit:
	setarray .customs[0],4035,4060,4063; // An array of out custom items.
	
	set .CoinID,1226; // ID da Moeda em uso.
	
	setarray .Price[0],500,500,500; // The amount of coins needed for our items. (For example: Item 12103 = 20 coins)
	
	npcshopitem "custom_seller21",0,0; // Remove all items from our dummy shop.
	
	for( set [email protected], 0; .customs[[email protected]]; set [email protected], [email protected]+1 ) // Loop through our custom items.
		npcshopadditem "custom_seller10",.customs[[email protected]],.Price[[email protected]]; // Add our custom items to the cleared dummy shop.

	npcspeed 200;
    getmapxy( .npc_map$, .npc_x, .npc_y,1 );
    initnpctimer;
    end;
   
	end;
}

 

  • Like 1

Share this post


Link to post
Share on other sites
  • 0
1 hour ago, Tassadar said:

Good night..

I need to make a simple modification to a npc I already have, but I do not know if this is possible.

I need an npc shop item to be walking in the middle of prontera.

shop	custom_seller21	-1,673:1000000 // Create our dummy shop.

prontera,150,150,4	script	[Máquina Cartas]	564,{
	
// This code runs when the user clicks our npc.
	mes "[^FF2400Cuidado^000000] Escolha um item!"; // Let the user know about our shop.
	callshop "custom_seller21",1; // Summon our dummy shop filled with custom items.
	
	npcshopattach "custom_seller21"; // Attach the shop to this npc.
	
	end;

// This code runs when a user purchases an item from out shop.
OnBuyItem:
	[email protected] = getarraysize(.customs); // Get the number of customs we're adding.
	[email protected]_len = getarraysize(@bought_nameid); // Get the number of purchased items.

	for( set @i, 0; @i < [email protected]; set @i, @i+1 ) {
		for( set @d,0; @d < [email protected]_len; set @d, @d+1 ) {
			if( @bought_nameid[@d] == .customs[@i] ) { // Check if the purchased item equals our custom item.
				if( countitem(.CoinID) >= .Price[@i] * @bought_quantity[@d] ) { // Check if the user has the correct funds.
					delitem .CoinID,.Price[@i]*@bought_quantity[@d];
					getitem @bought_nameid[@d],@bought_quantity[@d];
				}
			}
		}
	}
	deletearray @bought_quantity, getarraysize(@bought_quantity); // Remove the array.
	deletearray @bought_nameid, getarraysize(@bought_nameid); // Remove the array.
	close;

// This code runs first. When the server is started.
OnInit:
	setarray .customs[0],4035,4060,4063; // An array of out custom items.
	
	set .CoinID,1226; // ID da Moeda em uso.
	
	setarray .Price[0],500,500,500; // The amount of coins needed for our items. (For example: Item 12103 = 20 coins)
	
	npcshopitem "custom_seller21",0,0; // Remove all items from our dummy shop.
	
	for( set [email protected], 0; .customs[[email protected]]; set [email protected], .[email protected]+1 ) // Loop through our custom items.
		npcshopadditem "custom_seller10",.customs[[email protected]],.Price[[email protected]]; // Add our custom items to the cleared dummy shop.
	
	end;
}

If it is possible could someone show me how to do it?

If it is possible to do this I can put the sprite of a monster that he will walk?

I thank you for your help.

*npcspeed <speed value>;
*npcwalkto <x>,<y>;
*npcstop;

These commands will make the NPC object in question move around the map. As they
currently are, they are a bit buggy and are not useful for much more than making
an NPC move randomly around the map.

'npcspeed' will set the NPCs walking speed to a specified value. As in the
@speed GM command, 200 is the slowest possible speed while 0 is the fastest
possible (instant motion). 100 is the default character walking speed.

'npcwalkto' will start the NPC sprite moving towards the specified coordinates
on the same map it is currently on. The script proceeds immediately after the
NPC begins moving.

'npcstop' will stop the motion.

While in transit, the NPC will be clickable, but invoking it will cause it to
stop moving, which will make its coordinates different from what the client
computed based on the speed and motion coordinates. The effect is rather
unnerving.

Only a few NPC sprites have walking animations, and those that do, do not get
the animation invoked when moving the NPC, due to the problem in the NPC walking
code, which looks a bit silly. You might have better success by defining a job-
sprite based sprite id in 'db/mob_avail.txt' with this.

Then add npctimers..

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

You can show me how I use? Where in npc I did put all npnwalktos?

Edited by Tassadar

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...
Sign in to follow this