Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Release Forum » [CODE] SCAnnouncement class definition
[CODE] SCAnnouncement class definition [message #465569] Thu, 05 April 2012 08:52 Go to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
This is what the engine uses to send out radio commands to players after a player sends a radio command to the server. If an invalid player ID (e.g. ID = -1) is used, the radio command will be shown as if it were an announcement, which basically means that 'AnnouncementID' (an ID from strings.tdb) will be shown in a white colour and if it has a sound ID it will be played, the same as with normal radio commands, but with a white colour and with no player name prepended to it.

IconID needs to be between 0 or 1 and 30 or 31 or the radio command won't be sent.

PlayerType is the team of the player, this appears to be ignored.

AnnouncementType seems to be ignored too, no idea what it's for.

AnnouncementID is an ID from strings.tdb, it's the string ID to be displayed and if the strings.tdb ID has a sound ID attached it'll also play a sound (not for all strings, probably because the sound file is missing).

ID is the player ID of the player sending the message.

.h

class SCAnnouncement : public NetworkObjectClass
{
public:	

	int PlayerType;
	int ID;
	int AnnouncementID;
	int IconId;
	uint8 AnnouncementType;

	SCAnnouncement* Constructor();

	void Init(int PlayerType, int ID, int AnnouncementID, uint8 AnnouncementType, int IconId );
	void Act();	
};


.cpp (without the header #includes)

void* HookupAT3x(void* a, void* b, void* c, void* patch_start, void* patch_end, int (*version_selector)())
{
	return HookupAT3(a,b,c,patch_start,patch_end,version_selector);
}

RENEGADE_FUNCTION
uint Send_Object_Update(NetworkObjectClass* object, int remoteHostId)
AT2(0x00461820,0x004612F0);

RENEGADE_FUNCTION
SCAnnouncement* __thiscall  SCAnnouncement::Constructor() 
AT2(0x004B38B0, 0x004B38B0);

RENEGADE_FUNCTION
void SCAnnouncement::Init(int PlayerType, int ID, int AnnouncementID, uint8 AnnouncementType, int IconId )
AT2(0x004B3930, 0x004B3930);

RENEGADE_FUNCTION
void SCAnnouncement::Act()
AT2(0x004B3D10, 0x004B3D10);


Example usage:

Code emulating PlayerID sending the ALT+3 (move out) radio command:
			SCAnnouncement* RadioObj = (SCAnnouncement*)operator new(sizeof(SCAnnouncement));
			RadioObj = RadioObj->Constructor();
			RadioObj->Init(Get_Team(PlayerID), PlayerID, 8547, 1, 12);


Show a white coloured message "You have been banned from Westwood Online." for one player:
			SCAnnouncement* RadioObj = (SCAnnouncement*)operator new(sizeof(SCAnnouncement));
			RadioObj = RadioObj->Constructor();

			RadioObj->PlayerType = 0; // Doesn't seem to be checked
			RadioObj->ID = -1; // Invalid player ID, which will cause the radio command to be shown in white without a sender
			RadioObj->IconId = 12; // IconId is the same as for the ALT+3 ("Move out.") radio command.
			RadioObj->AnnouncementType = 1; // Doesn't seem to be used
			RadioObj->AnnouncementID = 9757; // strings.tdb ID for "You have been banned from Westwood Online."

			// Sends the radio command only to PlayerID.
			RadioObj->Set_Object_Dirty_Bits(PlayerID, NetworkObjectClass::BIT_CREATION); // Netcode stuff
			Send_Object_Update(RadioObj, PlayerID); // Send an object update for only this player

			RadioObj->Set_Delete_Pending();
			delete RadioObj;


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Fri, 06 April 2012 05:37]

Report message to a moderator

Re: [CODE] SCAnnouncement class definition [message #465573 is a reply to message #465569] Thu, 05 April 2012 09:26 Go to previous messageGo to next message
sla.ro(master) is currently offline  sla.ro(master)
Messages: 610
Registered: September 2010
Location: Romania
Karma: 0
Colonel
nice code. i was finding a code who can display models only for a player Smile

Creator of Mutant Co-Op
Developer of LuaTT
Re: [CODE] SCAnnouncement class definition [message #465605 is a reply to message #465573] Thu, 05 April 2012 17:00 Go to previous messageGo to next message
halo2pac is currently offline  halo2pac
Messages: 659
Registered: December 2006
Location: Near Cleveland, Ohio
Karma: 0
Colonel
I wonder what else you can do with Send_Object_Update and NetworkObjectClass ....

http://img339.imageshack.us/img339/1991/nefobbygenyunoreleasere.jpg
Rene-Buddy | Renegade X
Join the fight against Obsessive-Compulsive Posting Disorder. Cancel is ur friend.
*Renegade X Dev Team Member*
Re: [CODE] SCAnnouncement class definition [message #465606 is a reply to message #465605] Thu, 05 April 2012 17:23 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
halo2pac wrote on Thu, 05 April 2012 17:00

I wonder what else you can do with Send_Object_Update and NetworkObjectClass ....

A lot of stuff, like sending cScTextObj to only one player, and creating powerups that can only be picked up by one player, delete crate objects only for people who have an SBH, sending radio commands to both teams.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Thu, 05 April 2012 17:26]

Report message to a moderator

Re: [CODE] SCAnnouncement class definition [message #465634 is a reply to message #465606] Fri, 06 April 2012 11:58 Go to previous messageGo to next message
halo2pac is currently offline  halo2pac
Messages: 659
Registered: December 2006
Location: Near Cleveland, Ohio
Karma: 0
Colonel
Wait... how many years has this stuff been around?

http://img339.imageshack.us/img339/1991/nefobbygenyunoreleasere.jpg
Rene-Buddy | Renegade X
Join the fight against Obsessive-Compulsive Posting Disorder. Cancel is ur friend.
*Renegade X Dev Team Member*
Re: [CODE] SCAnnouncement class definition [message #465640 is a reply to message #465569] Fri, 06 April 2012 13:14 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Those functions/classes are part of the engine.

Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: [CODE] SCAnnouncement class definition [message #465778 is a reply to message #465640] Sun, 08 April 2012 21:20 Go to previous messageGo to next message
halo2pac is currently offline  halo2pac
Messages: 659
Registered: December 2006
Location: Near Cleveland, Ohio
Karma: 0
Colonel
I'm confused, if they are part of the engine... why are you showing them here? Just so you can make people aware of them or is it because your doing something special with the code that is beyond the default?

http://img339.imageshack.us/img339/1991/nefobbygenyunoreleasere.jpg
Rene-Buddy | Renegade X
Join the fight against Obsessive-Compulsive Posting Disorder. Cancel is ur friend.
*Renegade X Dev Team Member*
Re: [CODE] SCAnnouncement class definition [message #465780 is a reply to message #465569] Sun, 08 April 2012 21:39 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

He is showing them so that people have the information required to call them and make use of them.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: [CODE] SCAnnouncement class definition [message #465801 is a reply to message #465569] Mon, 09 April 2012 10:13 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3557
Registered: February 2003
Karma: 0
General (3 Stars)

I have added a new engine call to 4.0 beta 5 as follows:
SCAnnouncement *Send_Client_Announcement(int _receiptientId, int _senderId, int _translationId, AnnouncementEnum _type, int _emoticonId, bool dodirtybit, bool doact)

dodirtybit determines whether SCAnnouncement::Init should make its normal calls to the various Set_Object_Dirty_Bit functions or not
doact determines whether SCAnnouncement::Init should make its normal calls to SCAnnouncement::Act

The function will create a new SCAnnouncement, call its constructor, call SCAnnouncement::Init and return the new object.
Note that you should not call Set_Delete_Pending, nor should you delete the returned object as Set_Delete_Pending is already handled by SCAnnouncement::Init and the object will be automatically deleted by the netcode.

You are free to call any of the Set_Object_Dirty_Bit functions and to call Send_Object_Update. Note however that you can only call Send_Object_Update ONCE for each SCAnnouncement object as SCAnnouncement was not designed to be sent multiple times.

The purpose of the engine call is to make this stuff easier to use and to make sure it wont break in the future if SCAnnouncement has to change for some reason.


Jonathan Wilson aka Jonwil
Creator and Lead Coder of the Custom scripts.dll
Renegade Engine Guru
Creator and Lead Coder of TT.DLL
Official member of Tiberian Technologies
Re: [CODE] SCAnnouncement class definition [message #465830 is a reply to message #465778] Mon, 09 April 2012 16:05 Go to previous message
Whitedragon is currently offline  Whitedragon
Messages: 832
Registered: February 2003
Location: California
Karma: 1
Colonel
halo2pac wrote on Sun, 08 April 2012 21:20

I'm confused, if they are part of the engine... why are you showing them here? Just so you can make people aware of them or is it because your doing something special with the code that is beyond the default?


This displays a string from strings.tdb and plays the associated sound. It's a good way to send certain messages to players who aren't running tt.dll. Of course the string needs to be in the strings database but there's quite a bit of stuff in there.

void Send_Announcement_Player(int ID,int StringID) {
	SCAnnouncement *RadioEvent = (SCAnnouncement*)operator new(sizeof(SCAnnouncement));
	RadioEvent->Constructor();
	RadioEvent->AnnouncementID = StringID;
	RadioEvent->ID = -1;
	RadioEvent->IconID = 0;
	RadioEvent->AnnouncementType = 0;
	RadioEvent->PlayerType = 0;
	RadioEvent->Set_Object_Dirty_Bits(ID,NetworkObjectClass::BIT_CREATION);
	Send_Object_Update(RadioEvent,ID);
	RadioEvent->Set_Delete_Pending();
	delete RadioEvent;
}

Send_Announcement_Player(ID,1496);


index.php?t=getfile&id=14109&private=0


Black-Cell.net
Network Administrator (2003 - )

DragonServ, Renegade's first IRC interface bot
Creator and lead coder (2002 - )

Dragonade, Renegade's first server side modification
Lead coder (2005 - )
Previous Topic: [CODE] cScTextObj class definition
Next Topic: [Map]C&C_aLittleMapv2.1
Goto Forum:
  


Current Time: Wed Dec 11 16:12:26 MST 2024

Total time taken to generate the page: 0.00968 seconds