Renegade Public Forums
C&C: Renegade -- Dead since 2012!™
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: 4258
Registered: April 2011
General (4 Stars)
From: *cm-5-3b.dynamic.ziggo.nl
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".

[Updated on: Sun, 04 May 2014 13:06]


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 #491992] Sat, 11 February 2017 20:49 Go to previous messageGo to next message
Gen_Blacky  is currently offline Gen_Blacky  
Messages: 3213
Registered: September 2006
General (3 Stars)
From: *boid.qwest.net
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.

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


http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #491997] Sun, 12 February 2017 21:31 Go to previous messageGo to next message
dblaney1  is currently offline dblaney1  
Messages: 304
Registered: March 2014
Location: United States
Recruit
From: *nwrknj.fios.verizon.net
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] Sun, 12 February 2017 22:32 Go to previous messageGo to next message
dblaney1  is currently offline dblaney1  
Messages: 304
Registered: March 2014
Location: United States
Recruit
From: *nwrknj.fios.verizon.net
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]

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

From: *tpgi.com.au
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] Mon, 13 February 2017 10:01 Go to previous messageGo to next message
dblaney1  is currently offline dblaney1  
Messages: 304
Registered: March 2014
Location: United States
Recruit
From: *nwrknj.fios.verizon.net
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]

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492001] Mon, 13 February 2017 10:46 Go to previous messageGo to next message
iRANian  is currently offline iRANian  
Messages: 4258
Registered: April 2011
General (4 Stars)
From: *cm-8.dynamic.ziggo.nl
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] Mon, 13 February 2017 11:28 Go to previous messageGo to next message
Gen_Blacky  is currently offline Gen_Blacky  
Messages: 3213
Registered: September 2006
General (3 Stars)
From: *boid.qwest.net
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] Mon, 13 February 2017 14:33 Go to previous messageGo to next message
dblaney1  is currently offline dblaney1  
Messages: 304
Registered: March 2014
Location: United States
Recruit
From: 130.156.84*
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]

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492016] Fri, 17 February 2017 18:49 Go to previous messageGo to next message
Gen_Blacky  is currently offline Gen_Blacky  
Messages: 3213
Registered: September 2006
General (3 Stars)
From: *boid.qwest.net
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

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


http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492018] Sat, 18 February 2017 03:31 Go to previous messageGo to next message
iRANian  is currently offline iRANian  
Messages: 4258
Registered: April 2011
General (4 Stars)
From: *cm-8.dynamic.ziggo.nl
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.

[Updated on: Sat, 18 February 2017 03:32]


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 #492019] Sat, 18 February 2017 04:08 Go to previous messageGo to next message
Gen_Blacky  is currently offline Gen_Blacky  
Messages: 3213
Registered: September 2006
General (3 Stars)
From: *boid.qwest.net
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

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


http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492029] Tue, 21 February 2017 16:42 Go to previous messageGo to next message
dblaney1  is currently offline dblaney1  
Messages: 304
Registered: March 2014
Location: United States
Recruit
From: 130.156.83*
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]

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492030] Tue, 21 February 2017 23:28 Go to previous messageGo to next message
Gen_Blacky  is currently offline Gen_Blacky  
Messages: 3213
Registered: September 2006
General (3 Stars)
From: *boid.qwest.net
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

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


http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492031] Wed, 22 February 2017 03:15 Go to previous messageGo to next message
jonwil  is currently offline jonwil  
Messages: 3472
Registered: February 2003
General (3 Stars)

From: *tpgi.com.au
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] Wed, 22 February 2017 10:18 Go to previous messageGo to next message
dblaney1  is currently offline dblaney1  
Messages: 304
Registered: March 2014
Location: United States
Recruit
From: *nwrknj.fios.verizon.net
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]

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492034] Wed, 22 February 2017 12:11 Go to previous messageGo to next message
Gen_Blacky  is currently offline Gen_Blacky  
Messages: 3213
Registered: September 2006
General (3 Stars)
From: *boid.qwest.net
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] Wed, 22 February 2017 13:40 Go to previous messageGo to next message
dblaney1  is currently offline dblaney1  
Messages: 304
Registered: March 2014
Location: United States
Recruit
From: *nwrknj.fios.verizon.net
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] Fri, 24 February 2017 22:28 Go to previous messageGo to next message
Gen_Blacky  is currently offline Gen_Blacky  
Messages: 3213
Registered: September 2006
General (3 Stars)
From: *boid.qwest.net
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)

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


http://s18.postimage.org/jc6qbn4k9/bricks3.png
Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492300] Thu, 27 April 2017 10:27 Go to previous messageGo to next message
iRANian  is currently offline iRANian  
Messages: 4258
Registered: April 2011
General (4 Stars)
From: *cm-27.dynamic.ziggo.nl
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] Thu, 27 April 2017 10:37 Go to previous messageGo to next message
dblaney1  is currently offline dblaney1  
Messages: 304
Registered: March 2014
Location: United States
Recruit
From: 130.156.92*
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]

Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492306] Thu, 27 April 2017 23:06 Go to previous messageGo to next message
iRANian  is currently offline iRANian  
Messages: 4258
Registered: April 2011
General (4 Stars)
From: *cm-27.dynamic.ziggo.nl
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] Sun, 30 April 2017 05:16 Go to previous messageGo to next message
iRANian  is currently offline iRANian  
Messages: 4258
Registered: April 2011
General (4 Stars)
From: *cm-27.dynamic.ziggo.nl
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] 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
Colonel

From: 47.137.143*
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?

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


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 - )
Re: [SSGM 4.0 Plugin] Building Revival Console Commands v2.0 [message #492338] Sun, 30 April 2017 13:01 Go to previous messageGo to previous message
Gen_Blacky  is currently offline Gen_Blacky  
Messages: 3213
Registered: September 2006
General (3 Stars)
From: *boid.qwest.net
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:Dragonade 1.9
Goto Forum:
  


Current Time: Tue May 23 17:50:47 MST 2017
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7RC2.
Copyright ©2001-2007 FUD Forum Bulletin Board Software