ArcEmu: [lua] Packet Help - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[lua] Packet Help Some questions regarding packets

#1 User is offline   Wolferine 

  • Member
  • Pip
  • Group: Members
  • Posts: 19
  • Joined: 27-November 09

Posted 29 July 2011 - 06:06 AM

Lately me and Marijn have been fascinated by the availability from Packets trough Lua. We are able to produce a packet that sends a world state & world state update to the world so we know how Packets somehow work. Just some things aren't clear to me:

For example we foun information about this packet:
packet: SMSG_RESURRECT_REQUEST 
  byte: 0x15B
  size: 13
  args: data << m_caster->GetGUID();
	data << uint32(0) << uint8(0);


and you want to use it, is the correct way:

local p = LuaPacket:CreatePacket(0x15B, 13)
p:WriteGUID(xxx) -- GUID of the npc sending it I guess?
p:WriteULong(0)
p:WriteUByte(0)
x:SendPacketToPlayer(p)


Then another question; Some packets return a CMSG_RESPONSE, but you cannot use that right? So how do you check for example if you have the Spirit Healers and you get the menu for the Ress Sickness and you press yes, how does the client know that?

Thanks in advance.
0

#2 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 29 July 2011 - 06:40 AM

Hi there, like I've told you on that other forum, you shouldn't worry about packets. I don't even know why they are available thru Lua, since it's not something a scripting language should handle.
You should tell us what functionality you need and then we can expose that to the Lua engine(s).
For example this packet you speak of is sent when handling the resurrect spells.
This packet is what presents you that menu "xyz wants to resurrect you".
Then when you click yes the client sends a CMSG_RESURRECT_RESPONSE message to the server, which then resurrects the player.
All this is already handled by the server!
So as I said you don't have to worry about it!
"The demand for free goods is infinite."
0

#3 User is offline   Wolferine 

  • Member
  • Pip
  • Group: Members
  • Posts: 19
  • Joined: 27-November 09

Posted 29 July 2011 - 06:48 AM

Thank you for your answer as it is clearer this time, haha. I just wanted to know if it was possible to for example make a gossip npc send that window. Or in a glorified resurrection chat hook, e.g: #resurrect -> pop up window -> if yes -> player:ResurrectPlayer()
0

#4 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 29 July 2011 - 06:51 AM

View PostWolferine, on 29 July 2011 - 06:48 AM, said:

Thank you for your answer as it is clearer this time, haha. I just wanted to know if it was possible to for example make a gossip npc send that window.

Yes, it's more than likely possible, but don't mess with packets, because if you mess up 1 byte, your client blows up.
Just let us handle the inner workings, if you need functionality to send that window then tell us and we will add it with a nice Lua function :(

View PostWolferine, on 29 July 2011 - 06:48 AM, said:

Or in a glorified resurrection chat hook, e.g: #resurrect -> pop up window -> if yes -> player:ResurrectPlayer()

You can't handle the packets the client send in Lua so that wouldn't work :)
"The demand for free goods is infinite."
0

#5 User is offline   marijnz 

  • Newbie
  • Group: Members
  • Posts: 5
  • Joined: 24-April 10
  • Gender:Male

Posted 29 July 2011 - 06:54 AM

View Postdfighter, on 29 July 2011 - 06:51 AM, said:

Yes, it's more than likely possible, but don't mess with packets, because if you mess up 1 byte, your client blows up.
Just let us handle the inner workings, if you need functionality to send that window then tell us and we will add it with a nice Lua function :(


You can't handle the packets the client send in Lua so that wouldn't work :)


Oke then, well we're mostly interested in this because of the huge amount of possibilities with packets. Well, I was planning to move on to C++ soon anyways, as I'm more interested in the whole idea behind it, than actually using it.
0

#6 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 29 July 2011 - 06:57 AM

View Postmarijnz, on 29 July 2011 - 06:54 AM, said:

Oke then, well we're mostly interested in this because of the huge amount of possibilities with packets. Well, I was planning to move on to C++ soon anyways, as I'm more interested in the whole idea behind it, than actually using it.

All those possibilities are available thru simple Lua scripting too if they are implemented in Arcemu... That's the exact point.
Basically what you are doing when mangling these packets is like, sending 0s and 1s thru a wire to browse some site, instead of just typing in the URL to the browser, is it really worth it?
"The demand for free goods is infinite."
0

#7 User is offline   Wolferine 

  • Member
  • Pip
  • Group: Members
  • Posts: 19
  • Joined: 27-November 09

Posted 29 July 2011 - 06:58 AM

I'd really like it if you guys added this packet then: packet: SMSG_AREA_SPIRIT_HEALER_TIME, haha.
0

#8 User is offline   marijnz 

  • Newbie
  • Group: Members
  • Posts: 5
  • Joined: 24-April 10
  • Gender:Male

Posted 29 July 2011 - 07:03 AM

View Postdfighter, on 29 July 2011 - 06:57 AM, said:

All those possibilities are available thru simple Lua scripting too if they are implemented in Arcemu... That's the exact point.
Basically what you are doing when mangling these packets is like, sending 0s and 1s thru a wire to browse some site, instead of just typing in the URL to the browser, is it really worth it?


I get what you mean. But what my point was, that I'm rather interested in implementing such things in Arcemu, then actually using them, because using them, doesn't require a lot of knowledge. I'm going to study Game Development in a while, and getting a little more familiar with C++ wouldn't hurt then, packets are just an example.
0

#9 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 29 July 2011 - 07:05 AM

View PostWolferine, on 29 July 2011 - 06:58 AM, said:

I'd really like it if you guys added this packet then: packet: SMSG_AREA_SPIRIT_HEALER_TIME, haha.

It is already in Arcemu....

Quote

Find all "SMSG_AREA_SPIRIT_HEALER_TIME", Subfolders, Find Results 1, "Entire Solution", "*.cpp;*.h;*.hpp"
Z:\stuff\arcemu\trunk\src\arcemu-world\Opcodes.h(769): SMSG_AREA_SPIRIT_HEALER_TIME = 0x2E4, // implemented
Z:\stuff\arcemu\trunk\src\arcemu-world\BattlegroundHandler.cpp(151): WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12);
Z:\stuff\arcemu\trunk\src\arcemu-world\Opcodes.cpp(765): {SMSG_AREA_SPIRIT_HEALER_TIME, "SMSG_AREA_SPIRIT_HEALER_TIME"},
Matching lines: 3 Matching files: 3 Total files searched: 622


View Postmarijnz, on 29 July 2011 - 07:03 AM, said:

I get what you mean. But what my point was, that I'm rather interested in implementing such things in Arcemu, then actually using them, because using them, doesn't require a lot of knowledge. I'm going to study Game Development in a while, and getting a little more familiar with C++ wouldn't hurt then, packets are just an example.

It has nothing to do with C++, it only has to do with wow, as these are the messages that the client and server communicate with. It's really boring, and doesn't anyhow help you, trust me.
If you want to learn the C++ programming language then get a good book, and read it, and write programs :(
"The demand for free goods is infinite."
0

#10 User is offline   Wolferine 

  • Member
  • Pip
  • Group: Members
  • Posts: 19
  • Joined: 27-November 09

Posted 29 July 2011 - 07:12 AM

I mean in the Lua Engine as in SendResurrectionWindow(player, time)?
0

#11 User is offline   marijnz 

  • Newbie
  • Group: Members
  • Posts: 5
  • Joined: 24-April 10
  • Gender:Male

Posted 29 July 2011 - 07:17 AM

View Postdfighter, on 29 July 2011 - 07:05 AM, said:


It has nothing to do with C++, it only has to do with wow, as these are the messages that the client and server communicate with. It's really boring, and doesn't anyhow help you, trust me.
If you want to learn the C++ programming language then get a good book, and read it, and write programs :(


I was planning to do that, hehe. Could you recommend something to me from the internet, where to start, for now? I can perhaps borrow somebody else his book, with some luck.
0

#12 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 29 July 2011 - 07:20 AM

View PostWolferine, on 29 July 2011 - 07:12 AM, said:

I mean in the Lua Engine as in SendResurrectionWindow(player, time)?

The packet you named is some BG related auto-resurrect time update, it is sent as a response to a client message, so I am not sure if it will work, but I will definitely try later ^^

View Postmarijnz, on 29 July 2011 - 07:17 AM, said:

I was planning to do that, hehe. Could you recommend something to me from the internet, where to start, for now? I can perhaps borrow somebody else his book, with some luck.

Book stores and libraries are full of them.
I learned it from my college notes so I can't recommend any specific one, I can only tell you which ones are horrible and shouldn't be used:
  • Anything written by Herbert Schildt
  • Anything that has "for dummies" in the title
  • Anything that has "in x hours" or "in x days" in the title
You can find some nice advices in the C++ FAQ lite even about books tho http://www.parashift.com/c++-faq-lite/
"The demand for free goods is infinite."
0

#13 User is offline   Wolferine 

  • Member
  • Pip
  • Group: Members
  • Posts: 19
  • Joined: 27-November 09

Posted 29 July 2011 - 07:26 AM

Cool, thanks for all the answers Dfighter, it really helped :(.

-On a side note, if I'd like to request more of these packets transformed into Lua where do I post that =P?
0

#14 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 29 July 2011 - 07:32 AM

View PostWolferine, on 29 July 2011 - 07:26 AM, said:

Cool, thanks for all the answers Dfighter, it really helped :(.

-On a side note, if I'd like to request more of these packets transformed into Lua where do I post that =P?

You are welcome :)
Most packets should be already usable one way or another ( whatever you do in wow that ends up being sent as a packet between the server and the client ), but you can always post your suggestions regarding scripting here in the script forums or put in a feature request ticket on trac ( http://arcemu.org/fo...p?showforum=169 ) ( you need to be signed up and logged in on Sourceforge for that )
"The demand for free goods is infinite."
0

#15 User is offline   marijnz 

  • Newbie
  • Group: Members
  • Posts: 5
  • Joined: 24-April 10
  • Gender:Male

Posted 29 July 2011 - 07:42 AM

View Postdfighter, on 29 July 2011 - 07:20 AM, said:

The packet you named is some BG related auto-resurrect time update, it is sent as a response to a client message, so I am not sure if it will work, but I will definitely try later ^^


Book stores and libraries are full of them.
I learned it from my college notes so I can't recommend any specific one, I can only tell you which ones are horrible and shouldn't be used:
  • Anything written by Herbert Schildt
  • Anything that has "for dummies" in the title
  • Anything that has "in x hours" or "in x days" in the title
You can find some nice advices in the C++ FAQ lite even about books tho http://www.parashift.com/c++-faq-lite/


Well thank you then. : )
I'm not sure what book he had, but it was an expensive one, lol. Otherwise I will just get to the library and get something there.
I appreciate the time you take to answer me and Jeffrey, as the answers are actually useful. : )
0

#16 User is offline   dfighter 

  • Titles are overrated
  • PipPipPipPipPipPipPipPipPipPip
  • Group: Administrator
  • Posts: 5,189
  • Joined: 14-June 08
  • IRC:dfighter
  • Gender:Male
  • Server OS:Linux

Posted 29 July 2011 - 09:06 PM

View PostWolferine, on 29 July 2011 - 06:58 AM, said:

I'd really like it if you guys added this packet then: packet: SMSG_AREA_SPIRIT_HEALER_TIME, haha.

So I've just checked this one, and it seems to be the one that sends the "Resurrected in x seconds" window.

Posted Image

However it has nothing to do with resurrection itself, but anyhow I will try to expose it.

EDIT:
So I added it locally for myself to see if it works

Index: src/arcemu-world/BattlegroundHandler.cpp
===================================================================
--- src/arcemu-world/BattlegroundHandler.cpp	(revision 4408)
+++ src/arcemu-world/BattlegroundHandler.cpp	(working copy)
@@ -148,9 +148,8 @@
 	else
 		restime = (restime - (uint32)UNIXTIME) * 1000;
 
-	WorldPacket data(SMSG_AREA_SPIRIT_HEALER_TIME, 12);
-	data << guid << restime;
-	SendPacket(&data);
+	_player->SendResurrectTime( guid, restime );
+
 }
 
 void WorldSession::HandleAreaSpiritHealerQueueOpcode(WorldPacket &recv_data)
Index: src/arcemu-world/Player.h
===================================================================
--- src/arcemu-world/Player.h	(revision 4408)
+++ src/arcemu-world/Player.h	(working copy)
@@ -1016,6 +1016,7 @@
 	void SendEquipmentSetList();
 	void SendEquipmentSetSaved( uint32 setID, uint32 setGUID );
 	void SendEquipmentSetUseResult( uint8 result );
+	void SendResurrectTime( uint64 GUID, uint32 resurrect_time );
 
 	void OutPacket( uint16 opcode, uint16 len, const void *data );
 	void SendPacket( WorldPacket *packet );
Index: src/arcemu-world/PlayerPacketWrapper.cpp
===================================================================
--- src/arcemu-world/PlayerPacketWrapper.cpp	(revision 4408)
+++ src/arcemu-world/PlayerPacketWrapper.cpp	(working copy)
@@ -818,4 +818,11 @@
 	m_session->SendPacket( &data );
 
 	LOG_DEBUG("SMSG_EQUIPMENT_SET_USE_RESULT sent.");
+}
+
+void Player::SendResurrectTime( uint64 GUID, uint32 resurrect_time ){
+	WorldPacket data( SMSG_AREA_SPIRIT_HEALER_TIME, 12 );
+	data << uint64( GUID ); // GUID of the Unit that will resurrect us
+	data << uint32( resurrect_time ); // The time remaining until resurrection in milliseconds
+	m_session->SendPacket( &data );
 }
\ No newline at end of file
Index: src/scripts/src/LuaEngine/FunctionTables.h
===================================================================
--- src/scripts/src/LuaEngine/FunctionTables.h	(revision 4408)
+++ src/scripts/src/LuaEngine/FunctionTables.h	(working copy)
@@ -531,6 +531,7 @@
 	{ "CastSpellAoE", &luaUnit::CastSpellAoF },
 	{ "SetFlag", &luaUnit::SetFlag },
 	{ "SetSelectedGO", &luaUnit::SetSelectedGO },
+	{ "SendResurrectTime", &luaUnit::SendResurrectTime },
 	{ NULL, NULL },
 };
 
Index: src/scripts/src/LuaEngine/UnitFunctions.h
===================================================================
--- src/scripts/src/LuaEngine/UnitFunctions.h	(revision 4408)
+++ src/scripts/src/LuaEngine/UnitFunctions.h	(working copy)
@@ -5890,5 +5890,20 @@
 			lua_pushnil(L);
 		return 1;
 	}
+
+	int SendResurrectTime( lua_State *L, Unit *ptr ){
+		TEST_PLAYER();
+
+		int count = lua_gettop( L );
+		if( count < 2 )
+			return 0;
+
+		uint64 GUID = CHECK_GUID( L, 1 );
+		uint32 time = CHECK_ULONG( L, 2 );
+
+		TO< Player* >( ptr )->SendResurrectTime( GUID, time );
+
+		return 0;
+	}
 }
 #endif 


Also modified my example guard gossip script to send this message
function SWGuard_OnTalk( unit, event, player )
		unit:GossipCreateMenu( 1, player, 0 );
		unit:GossipMenuAddItem( 0, "text1", 1, 0 );
		unit:GossipMenuAddItem( 0, "text2", 2, 0 );
		unit:GossipSendMenu( player );

end


function SWGuard_OnSelect( unit, event, player, id, selection, code )
		if( selection == 1 )
		then
				unit:SendChatMessage( 12, 0, "whoe!" );
				local guid = unit:GetGUID();

				player:SendResurrectTime( guid, 10000 );
		elseif( selection == 2 )
		then
				unit:SendChatMessage( 12, 0, "yay!" );
		end

		player:GossipComplete();
end

RegisterUnitGossipEvent( 68, 1, "SWGuard_OnTalk" );
RegisterUnitGossipEvent( 68, 2, "SWGuard_OnSelect" );



The client doesn't seem to at all care about it. The messagebox with the countdown doesn't at all pop up.
So as I said before the client probably ignores it because it didn't ask for it.
"The demand for free goods is infinite."
1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users