Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Release Forum » [SSGM 4.0 Plugin] Building Revival Console Commands v2.0
[SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #482927] Fri, 02 August 2013 10:22 Go to next message
iRANian is currently offline  iRANian
Messages: 4298
Registered: April 2011
Karma: 0
General (4 Stars)
BuildingRevivalConsoleCommands SSGM 4.0 plugin v2.0

This plugin adds console commands for reviving buildings to the FDS. There are console commands for every building and two special console commands to revive a building by preset name and by object ID. Reviving buildings on maps with multiple buildings of the same type (e.g. two Obelisk) is supported too. Note there are two issues with this plugin, an inconvenient one requiring clients to rejoin the server and a potential issue on servers or maps running special scripts/code on buildings (e.g. custom repair scripts). These issues are explained in the following paragraphs.

If during building revival after the building is restored the Ref is alive and harvester is dead a new harvester will be requested. All console commands except ReviveBuildingByID will revive the first dead building found of a type. If there are two Obelisks on the map the first dead one will be revived when these commands are executed. ReviveBuildingByID will revive a building by its ID so you can use it to decide what building to revive if there are multiple structures with the same preset name.

The plugin handles the Obelisk and AGT weapons correctly now (in v1.0 they were bugged). After reviving the building any object create hooks are executed for the building. You need to make sure the code on the server supports this properly. For example code that assumes a building only gets the object create hook called for it only once per level load might act up.

The building revival code does a bit of hackery to make sure the right scripts are attached to the building when it is revived (and hopefully in the right state). This might break special scripts on buildings like the building repair scripts on buildings on C&C_Cairo and custom code attaching scripts to buildings, beware.

ON MAPS WITH SPECIAL REPAIR SCRIPTS ON BUILDINGS REVIVING A BUILDING WILL PROBABLY BREAK THE REPAIR SCRIPT. THIS HAPPENS ON C&C_Cairo FOR EXAMPLE.

After reviving a building I've noticed the following bugs appearing on clients:
1.) If the building is destroyed again no death announcement is played.
2.) If the building is a production facility clients can't build from that facility anymore
3.) If the building is a Communication Centre which controls radar, the radar will stay off-line

These bugs go away after the client restarts his game. They happen because the client doesn't sync the 'is destroyed' setting for a building with the server after building revival (on the server the building is no longer destroyed but on clients it's still destroyed). Hopefully TT will add the following client-side fix I wrote to Scripts 4.0 patch 2:
http://www.renegadeforums.com/index.php?t=msg&th=40362&start=0&rid=2 5967#msg_num_12

All revive console commands except ReviveBuildingByPreset and ReviveBuildingByID might not be able to revive a building type or they might REVIVE THE WRONG BUILDING TYPE on CUSTOM MAPS WITH REALLY NON-STANDARD BUILDING PRESET NAMES OR BUILDING TYPE SET ON BUILDING. If that's the case use ReviveBuildingByPreset or ReviveBuildingByID. I HAVEN'T SEEN THIS HAPPEN YET BUT IT IS A POSSIBILITY.

One way to get the object ID of a building is by opening the map in LevelEdit, checking the ID set on the building controller for that building.

The following console commands are added by this plugin:

REVIVEBUILDINGBYID <OBJECTID> - Revives a building by its object ID.
REVIVEBUILDINGBYPRESET <PRESET NAME> - Revives a building by its preset name.

REVIVEBAR - Revives the GDI Barracks.
REVIVEHON - Revives the Hand of Nod.
REVIVEGDIPP - Revives the GDI Power Plant.
REVIVENODPP - Revives the Nod Power Plant.
REVIVEGDICONYARD - Revives the GDI Construction Yard.
REVIVENODCONYARD - Revives the Nod Construction Yard.
REVIVEGDIREF - Revives the GDI Refinery.
REVIVENODREF - Revives the Nod Refinery.
REVIVEGDIREPBAY - Revives the GDI Repair Bay.
REVIVENODREPBAY - Revives the Nod Repair Bay.
REVIVEWF - Revives the GDI Weapons Factory.
REVIVEAIR - Revives the Nod Airstrip.
REVIVEGDICOMMCENTER - Revives the GDI Communications Center.
REVIVENODCOMMCENTER - Revives the Nod Communications Center.
REVIVEAGT - Revives the GDI Advanced Guard Tower.
REVIVEOB - Revives the Nod Obelisk.
REVIVENODSILO - Revives the Nod Tiberium Silo.
REVIVEGDISILO - Revives the GDI Tiberium Silo.
REVIVENODHELIPAD - Revives the Nod Helipad.
REVIVEGDIHELIPAD - Revives the GDI Helipad.
REVIVESHRINE - Revives the Shrine of Nod.


To install place 'BuildingRevivalConsoleCommands.dll' in the root FDS folder and add an entry for it in SSGM.ini under the [Plugins] section.

You can contact me by PM'ing me on renegadeforums.com under the name "iRANian" or on the usual IRC servers under the nick "Iran".


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: Sun, 04 May 2014 13:06]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #491992 is a reply to message #482927] Sat, 11 February 2017 20:49 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
Amusing dblaney1 has already made a proper update no need to work on this Iran.

Hey dblaney1, Iran said you made additions to this plugin can you post them? I was going to make a da game feature.


http://s18.postimage.org/jc6qbn4k9/bricks3.png

[Updated on: Sat, 11 February 2017 20:52]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #491997 is a reply to message #482927] Sun, 12 February 2017 21:31 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
Yeah I just gotta clean it up a bit. Have a lot of commented out code in it thats from before 4.2 had the proper functions for reviving.
Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #491998 is a reply to message #482927] Sun, 12 February 2017 22:32 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
Ok here it is. This plugin also handles silos correctly as well.

Edit: Updated this post with the one I posted a few posts down.


[Updated on: Mon, 13 February 2017 10:55]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #491999 is a reply to message #482927] Mon, 13 February 2017 01:14 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3555
Registered: February 2003
Karma: 0
General (3 Stars)

Here is a small update to the code.
Calls to Revive_Building are replaced with calls to Restore_Building (which is the correct engine call to use)
CommandREVIVEBAR and CommandREVIVEHON dont need to call Set_Can_Generate_Soldiers as SoldierFactoryGameObj::On_Revived does that for you.
CommandREVIVEGDIPP and CommandREVIVENODPP are fixed to use Find_Power_Plant.
CommandREVIVEGDICY and CommandREVIVENODCY dont need to call Is_Building_Dead as BuildingGameObj::On_Revived handles that all for you.
CommandREVIVENODSILO and CommandREVIVEGDISILO are fixed to not need the revived variable anymore.
CommandREVIVEAGT and CommandREVIVEOB are fixed to use Find_Base_Defense.


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: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492000 is a reply to message #491999] Mon, 13 February 2017 10:01 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
jonwil wrote on Mon, 13 February 2017 01:14

Here is a small update to the code.
Calls to Revive_Building are replaced with calls to Restore_Building (which is the correct engine call to use)
CommandREVIVEBAR and CommandREVIVEHON dont need to call Set_Can_Generate_Soldiers as SoldierFactoryGameObj::On_Revived does that for you.
CommandREVIVEGDIPP and CommandREVIVENODPP are fixed to use Find_Power_Plant.
CommandREVIVEGDICY and CommandREVIVENODCY dont need to call Is_Building_Dead as BuildingGameObj::On_Revived handles that all for you.
CommandREVIVENODSILO and CommandREVIVEGDISILO are fixed to not need the revived variable anymore.
CommandREVIVEAGT and CommandREVIVEOB are fixed to use Find_Base_Defense.



The revived variable was there so that it didn't play the revive sound twice if there were two silos. I actually meant to remove the can generate soldier stuff. Forgot to remove that line. The powerplant was going through all the buildings as there are several maps with multiple powerplants. Thats why it was coded that way. Same for the base defense thing. There are maps out there with multiple Obelisks and AGTs.

Here is a slightly updated version with some of the unnecessary stuff removed using the correct Restore_Building call.

[Updated on: Mon, 13 February 2017 10:17]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492001 is a reply to message #482927] Mon, 13 February 2017 10:46 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4298
Registered: April 2011
Karma: 0
General (4 Stars)
Thanks for the update people.

The functionality is really useful for moderators when a building is destroyed illegally.


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: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492002 is a reply to message #492001] Mon, 13 February 2017 11:28 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
Thanks guys I will post my addition when I get home from work.

iRANian wrote on Mon, 13 February 2017 10:46

Thanks for the update people.

The functionality is really useful for moderators when a building is destroyed illegally.


Yep RC has had a issue lately where people are planting nukes above the gdi base on under. Trying to provide them with the tools they need. Which led to work on all this stuff as of late.


http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492003 is a reply to message #482927] Mon, 13 February 2017 14:33 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
Yeah this should work great for that. It plays a nice building repaired sound for both teams too.

[Updated on: Mon, 13 February 2017 17:11]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492016 is a reply to message #482927] Fri, 17 February 2017 18:49 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
Just add to an existing da project. No reason to make it a game feature.

Added chat command use and you can use your bot to setaccesslevel
Added NavelFactory AirFactory Still need to add sounds and stuff. Does anyone have all building announcements sounds in strings handy?
Created Building Revive functions to stop code duplication

I was experiencing a weird problem where if a refinery gameobejct was passed it would crash on Revive_Building because of some reference to ScriptableGameObj Get_Definition() it would crash on !obj->As_BuildingGameObj(). But it seems to have fixed itself and not sure what was happening.

https://youtu.be/Vn_LQ9fU9g8



http://s18.postimage.org/jc6qbn4k9/bricks3.png

[Updated on: Sun, 19 February 2017 21:13]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492018 is a reply to message #482927] Sat, 18 February 2017 03:31 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4298
Registered: April 2011
Karma: 0
General (4 Stars)
You set the access level to NONE and added commands for reviving and destroying buildings, doesn't that mean everyone can execute those commands?

Good job with the code.


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: Sat, 18 February 2017 03:32]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492019 is a reply to message #482927] Sat, 18 February 2017 04:08 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
Yea, definitely want to set the accesslevel back to admin or something appropriate in an actual server.

Edit
There is a fatal flaw having a global variable name AccessLevel because it is Declared in DAChatCommandClass so it was renamed to ModLevel. lol


http://s18.postimage.org/jc6qbn4k9/bricks3.png

[Updated on: Tue, 21 February 2017 23:28]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492029 is a reply to message #482927] Tue, 21 February 2017 16:42 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
How come the DA version you posted looks like its based on the old version of this plugin? It should only be calling Restore_Building(obj) inside engine_game to bring the buildings back to life. It doesn't need to do anything specific for each type of building.

[Updated on: Tue, 21 February 2017 16:42]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492030 is a reply to message #482927] Tue, 21 February 2017 23:28 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
Its a dup of Restore_Building with extra bits. I only use the function Revive_Building. We still want to set the building health. Turn the base power back on if it is a power plant. We want to apply damage to the building to force it to update. If you don't it will still look damaged until a player damage's the building.

Idk if their is a difference but Im still using 4.3 RC2 or what ever Revision 7103 is


	// Restore building health
	float max = Commands->Get_Max_Health(building);
	Commands->Set_Health(building, max);

	// Still do this to wake everything up.
	// This is needed to update the state of a building from 'dead' to 'alive on the client
	Commands->Apply_Damage(building, 1.0f, "Explosive", 0);

	// If we're a Power Plant turn on base power
	if (building->As_BuildingGameObj()->As_PowerPlantGameObj()) Power_Base(Team, true);


You want to do these 3 things still in addition to the scripts Restore_Building



http://s18.postimage.org/jc6qbn4k9/bricks3.png

[Updated on: Tue, 21 February 2017 23:38]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492031 is a reply to message #482927] Wed, 22 February 2017 03:15 Go to previous messageGo to next message
jonwil is currently offline  jonwil
Messages: 3555
Registered: February 2003
Karma: 0
General (3 Stars)

I can tell you that in 4.3 (all versions) you just need to call Restore_Building or On_Revived or whatever. You don't need to make any of those other calls as On_Revived does it all (PowerPlantGameObj::On_Revived brings the power back online for all buildings btw)




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: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492032 is a reply to message #482927] Wed, 22 February 2017 10:18 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
Make sure your restore building in engine_game reads as the following. It was changed between 4.1 and 4.2.

void SCRIPTS_API Restore_Building(GameObject* obj) 
{
	if (!obj) return;
	BuildingGameObj *Building = obj->As_BuildingGameObj();
	if (Building)
	{
		Building->On_Revived();
	}
}


That should be the only thing you need for any version of 4.2 and newer. I believe that change was missed in the recent versions of DA for some odd reason. I had to update it on my end a while back.

You should also swap out all the Create_2D_WAV_Sound_Team with Create_2D_WAV_Sound_Team_Dialog so that it plays on the dialog volume instead of the sound effects volume setting in the plugin.

[Updated on: Wed, 22 February 2017 10:25]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492034 is a reply to message #482927] Wed, 22 February 2017 12:11 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
Ah yea mine it out of date. Still doing it the old way Instead of calling On_Revived.

void SCRIPTS_API Restore_Building(GameObject* obj) 
{
	if (!obj) return;
	
	BuildingGameObj* building = obj->As_BuildingGameObj();
	if (!building || !building->Is_Destroyed())
		return;

	building->Set_Is_Destroyed(false);

	BaseControllerClass* base = BaseControllerClass::Find_Base(Get_Object_Type(building));
	if (base) 
	{
		if (building->As_SoldierFactoryGameObj())
			base->Set_Can_Generate_Soldiers(true);
		
		if (building->As_VehicleFactoryGameObj())
			base->Set_Can_Generate_Vehicles(true);
		
		base->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE, true);
	}
}


http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492037 is a reply to message #492034] Wed, 22 February 2017 13:40 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
Gen_Blacky wrote on Wed, 22 February 2017 12:11

Ah yea mine it out of date. Still doing it the old way Instead of calling On_Revived.

void SCRIPTS_API Restore_Building(GameObject* obj) 
{
	if (!obj) return;
	
	BuildingGameObj* building = obj->As_BuildingGameObj();
	if (!building || !building->Is_Destroyed())
		return;

	building->Set_Is_Destroyed(false);

	BaseControllerClass* base = BaseControllerClass::Find_Base(Get_Object_Type(building));
	if (base) 
	{
		if (building->As_SoldierFactoryGameObj())
			base->Set_Can_Generate_Soldiers(true);
		
		if (building->As_VehicleFactoryGameObj())
			base->Set_Can_Generate_Vehicles(true);
		
		base->Set_Object_Dirty_Bit(NetworkObjectClass::BIT_RARE, true);
	}
}



Post an updated one when you get a chance please. With the restore building fix and playing the sounds on the dialog channel.
Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492050 is a reply to message #482927] Fri, 24 February 2017 22:28 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
Added Helipad Repair Sounds
Added Repair Facility Repair Sounds
Do On_Revive if Scripts 4.2 RC1 (6983) and up
Play Create_2D_WAV_Sound_Team_Dialog if Scripts 4.3 RC2 (7455) and up
SSGM Log Message for Building Revived

Also these fds commands in DA.dll that already call On_Revive.

revivebuildingbyid <id> - Revives a building by object ID. Host only.
revivebuildingbyname <team> <name> - Revives all buildings whose translated or preset name matches the given wildcard. Host only.
revivebuildingbypreset <team> <preset name> - Revives all buildings with the given preset name. Host only.
revivebuildingbytype <team> <type> - Revives all buildings of the given type. Host only. (See BuildingConstants for types)


http://s18.postimage.org/jc6qbn4k9/bricks3.png

[Updated on: Sat, 25 February 2017 00:24]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492300 is a reply to message #482927] Thu, 27 April 2017 10:27 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4298
Registered: April 2011
Karma: 0
General (4 Stars)
Obelisk after reviving doesn't have his weapon

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: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492301 is a reply to message #482927] Thu, 27 April 2017 10:37 Go to previous messageGo to next message
dblaney1 is currently offline  dblaney1
Messages: 358
Registered: March 2014
Location: United States
Karma: 0
Commander
If you have the fully updated 4.3 code it works properly. Make sure you have it. At least with the version i posted it will work.

http://www.renegadeforums.com/index.php?t=msg&goto=492301&#msg_num_4

[Updated on: Thu, 27 April 2017 10:38]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492306 is a reply to message #482927] Thu, 27 April 2017 23:06 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4298
Registered: April 2011
Karma: 0
General (4 Stars)
Well with Gen_Blacky's version it didn't and I don't see much of a difference with your yours. Adding Attach_Script_Once() ought to fix the issue.

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: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492335 is a reply to message #482927] Sun, 30 April 2017 05:16 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4298
Registered: April 2011
Karma: 0
General (4 Stars)
I can't get it fixed myself either Neutral

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: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492336 is a reply to message #482927] Sun, 30 April 2017 06:44 Go to previous messageGo to next message
Whitedragon is currently offline  Whitedragon
Messages: 829
Registered: February 2003
Location: California
Karma: 0
Colonel
Nod_Obelisk_CnC and GDI_AGT have code that recreate the weapons when the building is revived. Does it work correctly on a stock map using the revive commands built into TT?

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 - )

[Updated on: Sun, 30 April 2017 06:51]

Report message to a moderator

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492338 is a reply to message #482927] Sun, 30 April 2017 13:01 Go to previous messageGo to previous message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)
It works calling On_Revived. Mine is not doing anything differently. Only to check if you are using scripts rev 6983 or higher before calling On_Revived()




http://s18.postimage.org/jc6qbn4k9/bricks3.png
Previous Topic: MapFix Plugin
Next Topic: RenList 1.0.9
Goto Forum:
  


Current Time: Thu Mar 28 08:33:09 MST 2024

Total time taken to generate the page: 0.01228 seconds