Jump to content
  • 0

NPC Shop be walking ?


Tassadar

Question


  • Group:  Members
  • Topic Count:  52
  • Topics Per Day:  0.02
  • Content Count:  107
  • Reputation:   5
  • Joined:  07/21/16
  • Last Seen:  

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:
	.@len = getarraysize(.customs); // Get the number of customs we're adding.
	.@b_len = getarraysize(@bought_nameid); // Get the number of purchased items.

	for( set @i, 0; @i < .@len; set @i, @i+1 ) {
		for( set @d,0; @d < .@b_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 .@i, 0; .customs[.@i]; set .@i, .@i+1 ) // Loop through our custom items.
		npcshopadditem "custom_seller10",.customs[.@i],.Price[.@i]; // 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.

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  436
  • Reputation:   167
  • Joined:  12/12/17
  • Last Seen:  

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:
	.@len = getarraysize(.customs); // Get the number of customs we're adding.
	.@b_len = getarraysize(@bought_nameid); // Get the number of purchased items.

	for( set @i, 0; @i < .@len; set @i, @i+1 ) {
		for( set @d,0; @d < .@b_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:
	.@x = .npc_x + rand( -10,10 );
	.@y = .npc_y + rand( -10,10 );
	npcwalkto .@x,.@y;
	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 .@i, 0; .customs[.@i]; set .@i, .@i+1 ) // Loop through our custom items.
		npcshopadditem "custom_seller10",.customs[.@i],.Price[.@i]; // Add our custom items to the cleared dummy shop.

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

 

  • Like 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  436
  • Reputation:   167
  • Joined:  12/12/17
  • Last Seen:  

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:
	.@len = getarraysize(.customs); // Get the number of customs we're adding.
	.@b_len = getarraysize(@bought_nameid); // Get the number of purchased items.

	for( set @i, 0; @i < .@len; set @i, @i+1 ) {
		for( set @d,0; @d < .@b_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 .@i, 0; .customs[.@i]; set .@i, .@i+1 ) // Loop through our custom items.
		npcshopadditem "custom_seller10",.customs[.@i],.Price[.@i]; // 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..

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  52
  • Topics Per Day:  0.02
  • Content Count:  107
  • Reputation:   5
  • Joined:  07/21/16
  • Last Seen:  

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

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