void KB_CarryAll::Created(GameObject *obj)
{
GameObject *driver = Get_Vehicle_Occupant(obj, 0);
int team = Get_Object_Type(driver);
int pID = Get_Player_ID(driver);
Vector3 CurPosition = Commands->Get_Position(obj);
bool test=false;
GenericSLNode *x = BaseGameObjList->HeadNode;
while (x)
{
GameObject *o = (GameObject *)x->NodeData;
if (o && As_ScriptableGameObj(o) && Is_Vehicle(o) && o!=obj)
{
if(Is_VTOLVehicle(o)||Is_Script_Attached(o,"KB_CARRYALL_ATTACHED")|| !Is_Vehicle(o))
{
Remove_Script(obj,"KB_CarryAll");
return;
}
else
{
GameObject *driver2 = Get_Vehicle_Occupant(o, 0);
if(driver2)
{
if(Get_Object_Type(driver2) == team && !Is_Script_Attached(driver2,"KB_Carrytest"))
{
Vector3 CurPositiono = Commands->Get_Position(o);
float DistX = Commands->Get_Distance(CurPosition.X, CurPositiono.X);
float DistY = Commands->Get_Distance(CurPosition.Y, CurPositiono.Y);
float DistZ =Commands->Get_Distance(CurPosition.Z, CurPositiono.Z);
if(DistX <= 10.0f && DistY<=10.0f && DistZ<=7.0f)
{
//do some shit
Commands->Attach_To_Object_Bone(o, obj, "v_fuselage3");
Commands->Disable_Physical_Collisions(o);
Console_Input(StrFormat("CMSGP %d 208,104,0 You have attached a friendly vehicle",pID).c_str());
Attach_Script_Once(o,"KB_CARRYALL_ATTACHED2","!");
return;
}
}
}
else if (!(Is_Script_Attached(o,"KB_CARRYALL_ATTACHED")))
{
Vector3 CurPositiono = Commands->Get_Position(o);
float DistX = Commands->Get_Distance(CurPosition.X, CurPositiono.X);
float DistY = Commands->Get_Distance(CurPosition.Y, CurPositiono.Y);
float DistZ =Commands->Get_Distance(CurPosition.Z, CurPositiono.Z);
if(DistX <= 10.0f && DistY<=10.0f && DistZ<=7.0f)
{
const char *preset = Commands->Get_Preset_Name(o);
if(!isin(preset,"Harvester")&&!isin(preset,"Emplacement")){
if(isin(preset,"Tank")||isin(preset,"Humm")||isin(preset,"APC")||isin(preset,"MRLS")||isin(preset,"Buggy")||isin(preset,"Mobile"))*/{
Commands->Attach_To_Object_Bone(o, obj, "v_fuselage3");
CurPositiono = Commands->Get_Position(o);
Commands->Disable_Physical_Collisions(o);
Attach_Script_Once(o,"KB_CARRYALL_ATTACHED2","!");
Console_Input(StrFormat("CMSGP %d 208,104,0 You have attached a neutral vehicle",pID).c_str());
return;
}
}
}
}
}
}
x = x->NodeNext;
}
if(test == false)
{
Remove_Script(obj,"KB_CarryAll");
}
};