Question regarding reviving buildings [message #455191] |
Mon, 19 September 2011 09:24 |
iRANian
Messages: 4308 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
How do you revive buildings? I've tried using
int Team;
for( Team = 0; Team < 2; Team++)
{
Console_Input("msg looping"); // DEBUG CRAP
Restore_Building(Find_Power_Plant(Team));
Restore_Building(Find_Construction_Yard(Team));
Restore_Building(Find_Refinery(Team));
Console_Output("%s\n", Get_Translated_Preset_Name(Find_Refinery(Team)));
Restore_Building(Find_Repair_Bay(Team));
Restore_Building(Find_Soldier_Factory(Team));
Restore_Building(Find_Vehicle_Factory(Team));
Restore_Building(Find_Com_Center(Team));
}
But that doesn't seem to work. I've tried both teams, the output from Get_Translated_Preset_Name() is fine.
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: Question regarding reviving buildings [message #455193 is a reply to message #455191] |
Mon, 19 September 2011 09:33 |
|
Omar007
Messages: 1711 Registered: December 2007 Location: Amsterdam
Karma: 0
|
General (1 Star) |
|
|
IDK what your 'Restore_Building' does but this is what it'd need to rebuild buildings (on 3.4.4 that is).
GameObject *o = As_BuildingGameObj(obj); //obj is your input GameObject
if (!o)
{
return;
}
char *c = (char *)o;
c += 0x778;
bool *x = (bool *)c;
*x = false;
BaseControllerClass *b = BaseControllerClass::Find_Base(Get_Object_Type(o));
if (b && !Is_Building_Dead(o)) //Just to be sure it's revived
{
if (Is_SoldierFactory(o))
{
b->CanGenerateSoldiers = true;
}
else if (Is_WarFactory(o) || Is_Airstrip(o))
{
b->CanGenerateVehicles = true;
}
else if(Is_PowerPlant(o))
{
b->IsPowered = true; //Ofcource you can have some feedback messages around this code (ie "Nod base power restored")
}
Set_Object_Dirty_Bit_All(b, DB_RARE, true);
float max = Commands->Get_Max_Health(o);
Commands->Set_Health(o, max);
}
[Updated on: Mon, 19 September 2011 09:39] Report message to a moderator
|
|
|
Re: Question regarding reviving buildings [message #455195 is a reply to message #455191] |
Mon, 19 September 2011 10:11 |
iRANian
Messages: 4308 Registered: April 2011
Karma: 0
|
General (4 Stars) |
|
|
I had to set the health after reviving the building, works fine now. Thanks! This is what I used as a quick test:
Restore_Building(Find_Refinery(Team));
max = Commands->Get_Max_Health(Find_Refinery(Team));
Commands->Set_Health(Find_Refinery(Team), max);
edit: One thing I've noticed is that your client thinks that the building is dead (e.g. shows the dead building model) until you shoot it with a pistol or anything else.
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: Mon, 19 September 2011 10:22] Report message to a moderator
|
|
|
Re: Question regarding reviving buildings [message #455198 is a reply to message #455195] |
Mon, 19 September 2011 10:27 |
|
Omar007
Messages: 1711 Registered: December 2007 Location: Amsterdam
Karma: 0
|
General (1 Star) |
|
|
iRANian wrote on Mon, 19 September 2011 19:11 | edit: One thing I've noticed is that your client thinks that the building is dead (e.g. shows the dead building model) until you shoot it with a pistol or anything else.
|
Hmm if I recall correctly this part of the above code
Set_Object_Dirty_Bit_All(b, DB_RARE, true);
Should update the clients :S
[Updated on: Mon, 19 September 2011 10:27] Report message to a moderator
|
|
|
|
|
Re: Question regarding reviving buildings [message #466468 is a reply to message #455191] |
Sun, 22 April 2012 10:53 |
|
Given that any fix we came up with would (by necessity) be a hack, given that any such hack would not solve most of the issues with trying to bring a building back to life, given that this would only be being done for the benefit of 1 or 2 people's special case mods and given that any fix we make wouldn't solve the problem for 3.4.4 players, we have decided not to add any code at all to support bringing buildings back to life.
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
|
|
|