NPC Spawn

03/07/2011 03:41 Mr_PoP#1
Code:
union NPC {
			uint16_t val;
			struct {
				uint16_t type, Dir;
			}coords;
		};
		       case 0x7EE:{
			NpcSpawnPacket npc;
			npc.setNPC_ID(1002);
			npc.setNPC_CordX(444);
			npc.setNPC_CordY(444);
			NPC s;
			s.coords.type=0;
			s.coords.Dir=1002;
			npc.setNPC_Type_Direction(s.val);
			npc.setNPC_Interaction(1);
			SendPacket(&npc);
		}
actully idk what is NPC_Type_Direction and NPC_Interaction!!:confused:
03/07/2011 03:56 pro4never#2
Seriously... just learn to log your own packets. This is like the 3rd thread you have made about trying to upgrade your packets.

Simply use my proxy to log some packets and then structure them. You already know it's type 1022 so just fill in the blanks yourself.

There is no actual offset in the packet for direction (it's simply the last digit in the mesh offset) and interaction is most likely the script number.. that being said I don't know how the actual packet is structured cause you only posted yourself USING it.
03/07/2011 04:02 Mr_PoP#3
Quote:
Originally Posted by pro4never View Post
Seriously... just learn to log your own packets. This is like the 3rd thread you have made about trying to upgrade your packets.
am not trying to upgrade am making a server from scratch(C++)

Quote:
Originally Posted by pro4never View Post
Simply use my proxy to log some packets and then structure them. You already know it's type 1022 so just fill in the blanks yourself.
i will

Quote:
Originally Posted by pro4never View Post
There is no actual offset in the packet for direction (it's simply the last digit in the mesh offset) and interaction is most likely the script number.. that being said I don't know how the actual packet is structured cause you only posted yourself USING it.
what am trying to say is:
NPC_ID(means what or what should i pass as it?)= MAPID?
and u already told me about NPC_Type_Direction and NPC_Interaction
03/07/2011 04:24 Arco.#4
@pro, he has the structure already, what he's trying to find out is what exactly do the values mean.
03/07/2011 05:31 pro4never#5
My bad. But without knowing which offset he's writing each value to we have no idea what they mean. For all I know he's writing the NPC ID to the MapX offset. That's what I meant by structuring the packet :P
03/07/2011 05:34 Mr_PoP#6
Quote:
Originally Posted by pro4never View Post
My bad. But without knowing which offset he's writing each value to we have no idea what they mean. For all I know he's writing the NPC ID to the MapX offset. That's what I meant by structuring the packet :P
here is how i DO it:

Code:
	void setNPC_ID(uint32_t value){this->writeInt<uint32_t>(4,value);}
	void setNPC_CordX(uint16_t value){this->writeInt<uint16_t>(8,value);}
	void setNPC_CordY(uint16_t value){this->writeInt<uint16_t>(10,value);}
	void setNPC_Type_Direction(uint16_t value){this->writeInt<uint16_t>(12,value);}
	void setNPC_Interaction(uint16_t value){this->writeInt<uint16_t>(14,value);}
Edit: where should i add the Map_ID?
03/07/2011 05:58 romey007#7
thxxxxxxx
03/07/2011 06:02 pro4never#8
Quote:
Originally Posted by Mr_PoP View Post
here is how i DO it:

Code:
	void setNPC_ID(uint32_t value){this->writeInt<uint32_t>(4,value);}
	void setNPC_CordX(uint16_t value){this->writeInt<uint16_t>(8,value);}
	void setNPC_CordY(uint16_t value){this->writeInt<uint16_t>(10,value);}
	void setNPC_Type_Direction(uint16_t value){this->writeInt<uint16_t>(12,value);}
	void setNPC_Interaction(uint16_t value){this->writeInt<uint16_t>(14,value);}

NpcID should be the ID of the npc (this means the npc script the client will try to use when clicking it)

X should be offset 12
Y should be offset 14

Direction is part of the mesh (offset 16) as the last digit so mesh 1 would be 10-18


Interaction is what many call flag which is simply type of npc which goes at offset 18. 2 is normal npcs which you use. Other interaction types for things like shops and avatar change npcs.
03/07/2011 06:10 Mr_PoP#9
Quote:
Originally Posted by pro4never View Post
NpcID should be the ID of the npc (this means the npc script the client will try to use when clicking it)

X should be offset 12
Y should be offset 14

Direction is part of the mesh (offset 16) as the last digit so mesh 1 would be 10-18


Interaction is what many call flag which is simply type of npc which goes at offset 18. 2 is normal npcs which you use. Other interaction types for things like shops and avatar change npcs.
yeah got it now but u didnt tell me about :
where should i add the Map_ID?
03/07/2011 06:12 pro4never#10
Quote:
Originally Posted by Mr_PoP View Post
yeah got it now but u didnt tell me about :
where should i add the Map_ID?
Not needed. You don't need map id for any of the spawn packets.
03/07/2011 06:21 Mr_PoP#11
Quote:
Originally Posted by pro4never View Post
Not needed. You don't need map id for any of the spawn packets.
then how would the npc knw which map to spawn at ?
03/07/2011 07:42 pro4never#12
The npc doesn't 'know' anything...

You have to control all your maps, x and y from the server. What is sent in the packet simply controls how the entity is displayed in the client. The client removes entities if they go above a distance of 18 from you meaning that you cannot possibly have something visible on a different map.

Obviously you will need a map id in your monster structure to control where and when it is being spawned but it has NOTHING to do with packets.

When you move your character you essentially want to query nearby objects pulling everything within a 18x18 grid and if the entity is not already spawned to the user, you need to spawn it using your spawn packets (spawn sob, npc, player/monster, item)