finding *any* building [message #467517] |
Sat, 19 May 2012 05:30 ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
robbyke
Messages: 348 Registered: September 2010 Location: Belgium
Karma: 0
|
Recruit |
|
|
I Try to create some base zone by creating a zone around each building of a base.
This works for all normal maps however i want to add new maps to the rotation and ive noticed that on new maps these zones get bugged for some reason.
Zones do get deployed but they arent there where theyre supposed to be (around the structures) it seems like the building controllers are misplaced but ive checked it on some maps and they were in the place where i would estimate them to be
SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
while (x)
{
GameObject *o = (GameObject *)x->Data();
if (o && As_ScriptableGameObj(o))
{
const char *Preset = Commands->Get_Preset_Name(o);
const char *Team = "2";// make base zone neutral just in case
if (strstr(Preset,"_GDI"))
{
Team = "1";
}
if (strstr(Preset,"_Nod"))
{
Team = "0";
}
if(_stricmp("2",Team) != 0)
{
Vector3 Size = Vector3(40.0f,40.0f,80.0f); //Size of the script zone.
Matrix3 Rotation(true);
Rotation.Rotate_Z(DEG_TO_RADF(Commands->Get_Facing(o))); //Set the rotation of the script zone to the same as the building.
Vector3 Pos = Commands->Get_Position(o);
Pos.Z -= 20;
OBBoxClass Box(Pos,Size,Rotation); //Create the bounding box with the position of the beacon, and the size and rotation defined earlier.
GameObject* Zone = Create_Zone("Script_Zone_All",Box);
Attach_Script_Once(Zone,"KB_Base_Zone",Team);
}
}
x = x->Next();
}
i know this doesnt always cover the full base but thats not the main goal
Owner of kambot TT server
kambot.freeforums.org
|
|
|
Re: finding *any* building [message #467582 is a reply to message #467517] |
Sun, 20 May 2012 18:48 ![Go to previous message Go to previous message](/theme/Renegade_Forums/images/up.png) ![Go to next message Go to next message](/theme/Renegade_Forums/images/down.png) |
|
Here is some code that should work:
#include "BuildingGameObj.h"
SLNode<BuildingGameObj> *x = GameObjManager::BuildingGameObjList.Head();
while (x)
{
BuildingGameObj *o = (GameObject *)x->Data();
if (o && (Get_Object_Type(o) == 0 || Get_Object_Type(o) == 1))
{
StringClass str;
str.Format("%d",Get_Object_Type(o));
Vector3 Size = Vector3(40.0f,40.0f,80.0f); //Size of the script zone.
Matrix3 Rotation(true);
Rotation.Rotate_Z(DEG_TO_RADF(Commands->Get_Facing(o))); //Set the rotation of the script zone to the same as the building.
Vector3 Pos = Commands->Get_Position(o);
Pos.Z -= 20;
OBBoxClass Box(Pos,Size,Rotation); //Create the bounding box with the position of the beacon, and the size and rotation defined earlier.
GameObject* Zone = Create_Zone("Script_Zone_All",Box);
Attach_Script_Once(Zone,"KB_Base_Zone",Team);
}
x = x->Next();
}
The key here is Get_Object_Type to identify the type of the object.
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
|
|
|
|