Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » vtach/detach command
vtach/detach command [message #436900] Thu, 23 September 2010 12:59 Go to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
well i started searching and found the command JFW_CarryAll
now my problem is that i need to attach to a bone but how do i find the bone that i have to attach

its the orca that doing vtach and it should only be up close any help is appreciated


Owner of kambot TT server

kambot.freeforums.org
Re: vtach/detach command [message #436911 is a reply to message #436900] Thu, 23 September 2010 22:04 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
robbyke wrote on Thu, 23 September 2010 15:59

well i started searching and found the command JFW_CarryAll
now my problem is that i need to attach to a bone but how do i find the bone that i have to attach

its the orca that doing vtach and it should only be up close any help is appreciated



I once started work some time ago on a carry-all plugin. It never got finished and this doesn't work, but with some time it might...

#include "scripts.h"
#include <stdarg.h>
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include "engine.h"
#include "gmmain.h"
#include "CarryAll.h"

bool Activated[128];
bool HasAgreed[128];

ExampleSettingsStruct *ExampleSettings = 0;

void ExampleSettingsStruct::Load() 
{
	SettingsLoader::Load();
}


int ObjectHookID = 0;
ObjectCreateHookStruct *ObjectHookStruct = 0;


void ObjectHookCall(void *data,GameObject *obj) 
{
	if(Is_Vehicle(obj))
	{
		if (strstr(Commands->Get_Preset_Name(obj),"CnC_Nod_Transport") || strstr(Commands->Get_Preset_Name(obj),"CnC_GDI_Transport"))
		{
			Attach_Script_Once(obj,"CarryAll","");
		}
	}
	else if(Commands->Is_A_Star(obj))
	{
		Attach_Script_Once(obj,"carryvarsetter","");
	}
}


void Plugin_Load() 
{
	ExampleSettings = new ExampleSettingsStruct("Example.ini");

	ObjectHookStruct = new ObjectCreateHookStruct;
	ObjectHookStruct->hook = ObjectHookCall;
	ObjectHookStruct->data = 0;
	ObjectHookID = AddObjectCreateHook(ObjectHookStruct);
}


void CarryAll::Custom(GameObject *obj, int message, int param, GameObject *sender)
{
	if (message == CUSTOM_EVENT_VEHICLE_ENTER)
	{
		if (Get_Vehicle_Owner(obj))
		{
			Console_Input(StrFormat("ppage %d This vehicle has been modified to be a \"Carry-All\", when you get close to a team-mate's vehicle you'll be able to transport them if they type \"!carryme\" in team chat.", Get_Player_ID(sender)).c_str());
			Console_Input(StrFormat("ppage %d To activate the Carry-All and grant permission to carry passengers, you must type \"!activate\" in team chat.", Get_Player_ID(sender)).c_str());
			Commands->Start_Timer(obj, this, 1.0f, 1);
		}
	}
}


void CarryAll::Timer_Expired(GameObject *obj, int number)
{
	if(number == 1)
	{
		GameObject *driver = Get_Vehicle_Owner(obj);
		if(driver && Activated[Get_Player_ID(driver)] == true)
		{
			int team = Get_Object_Type(obj);
			Vector3 CurPosition = Commands->Get_Position(obj);

			GenericSLNode *x = BaseGameObjList->HeadNode;
			while (x)
			{
				GameObject *o = (GameObject *)x->NodeData;
				if (o && As_ScriptableGameObj(o) && Is_Vehicle(o))
				{
					if (Get_Object_Type(o) == team)
					{
						printf("Found someone.\n");
						Vector3 CurPositiono = Commands->Get_Position(o);
						float Dist = Commands->Get_Distance(CurPosition, CurPositiono);
						if(Dist <= 10.0f)
						{
							printf("Found someone in distance.\n");
							GameObject *driver2 = Get_Vehicle_Occupant(o, 0);
							if(driver2)
							{
								printf("Found someone in distance and a driver.\n");
								if(HasAgreed[Get_Player_ID(driver2)] == true)
								{
									printf("Found someone in distance and a driver and has agreed.\n");
									//do some shit
									GameObject *Harness = Commands->Create_Object_At_Bone(obj, "Invisible_Object", "v_fuselage3");
									Commands->Set_Model(Harness,"XG_HD_Harness");	
									Commands->Attach_To_Object_Bone(Harness, obj, "v_fuselage3");
									Console_Input(StrFormat("ppage %d You have just picked up aa vehicle, to release the vehicle type \"!release\".", Get_Player_ID(driver2)).c_str());
									Destroy_Script();
								}
							}
						}
					}
				}
				x = x->NodeNext;
			}
		}
	Commands->Start_Timer(obj, this, 1.0f, 1);
	}
}

ScriptRegistrant<CarryAll> CarryAll_Registrant("CarryAll","");


void carryvarsetter::Killed(GameObject *obj, GameObject *shooter)
{
	Activated[Get_Player_ID(obj)] = false;
	HasAgreed[Get_Player_ID(obj)] = false;
}

ScriptRegistrant<carryvarsetter> carryvarsetter_Registrant("carryvarsetter","");


void Plugin_Unload() 
{
	delete ExampleSettings;
	RemoveObjectCreateHook(ObjectHookID);
	delete ObjectHookStruct;
}


class AChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType)
	{
		Activated[ID] = true;
		Console_Input(StrFormat("ppage %d You have just activated the Carry-All feature of this transport helicopter, any team mates in vehicles who have agreed to be transported can now be carried and wil attach when you approach them.",ID).c_str());
		Console_Input(StrFormat("ppage %d To de-activate the Caary-All feature, type \"!deactivate\" in team chat.",ID).c_str());
	}
};
ChatCommandRegistrant<AChatCommand> AChatCommandReg("!ACTIVATE;!Activate;!activate",CHATTYPE_ALL,0,GAMEMODE_ALL);


class DChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType)
	{
		Activated[ID] = false;
		Console_Input(StrFormat("ppage %d You have just removed permission for passengers to be carried.",ID).c_str());
	}
};
ChatCommandRegistrant<DChatCommand> DChatCommandReg("!DEACTIVATE;!Deactivate;!deactivate",CHATTYPE_ALL,0,GAMEMODE_ALL);


class CMChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType)
	{
		HasAgreed[ID] = true;
		Console_Input(StrFormat("ppage %d You have agreed to be carried by a team mate using a transport helicopter, to remove permission type \"!cancelcarry\".",ID).c_str());
	}
};
ChatCommandRegistrant<CMChatCommand> CMChatCommandReg("!carryme;!CARRYME;!Carryme;!CarryMe",CHATTYPE_ALL,0,GAMEMODE_ALL);



class CCChatCommand : public ChatCommandClass {
	void Triggered(int ID,const TokenClass &Text,int ChatType)
	{
		HasAgreed[ID] = false;
		Console_Input(StrFormat("ppage %d You have removed permission for you to be carried.",ID).c_str());
	}
};
ChatCommandRegistrant<CCChatCommand> CCChatCommandReg("!CANCELCARRY;!cancelcarry;!Cancelcarry;!CancelCarry",CHATTYPE_ALL,0,GAMEMODE_ALL);



extern "C" 
{
	DLLEXPORT void SSGM_Level_Loaded_Hook()
	{
		ExampleSettings->Load();
		for(int i = 0; i < 128; i++)
		{
			Activated[i] = false;
			HasAgreed[i] = false;
		}
	}
	DLLEXPORT void SSGM_Player_Leave_Hook(int ID)
	{
		Activated[ID] = false;
		HasAgreed[ID] = false;
	}
}



Re: vtach/detach command [message #436937 is a reply to message #436900] Fri, 24 September 2010 09:30 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
thanks this really helps this gives me an idea of how to do it

if you still check perhaps
i found a way to attach the vehicle but with the bools you made i cant get it detached or even without i think but do you know a way perhaps
i didnt try to continue on your project mainly because im just a starter and cant start own projects yet and didnt have header file wich might have contained neccesary data Surprised


Owner of kambot TT server

kambot.freeforums.org

[Updated on: Tue, 28 September 2010 13:39]

Report message to a moderator

Re: vtach/detach command [message #437238 is a reply to message #436900] Thu, 30 September 2010 12:09 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
isnt there some command to remove an object from bone?

Owner of kambot TT server

kambot.freeforums.org
Re: vtach/detach command [message #437239 is a reply to message #437238] Thu, 30 September 2010 12:13 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3805
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Attaching it to itself does the trick.
Commands->Attach_To_Bone(AttachedVehicle,AttachedVehicle,"origin");

Also make sure to disable the vehicle's collisions once its attached or else it will collide with the attacher's bounding box.


Re: vtach/detach command [message #437293 is a reply to message #436900] Fri, 01 October 2010 10:19 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
well it works to detach only thing is how do i get the attached veh back on the ground without stucking it in my veh because i "detach" and then set collisions back results in 2 veh stuck into eachother

Owner of kambot TT server

kambot.freeforums.org
Re: vtach/detach command [message #437330 is a reply to message #436900] Sat, 02 October 2010 04:20 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
Set the position of the 2 vehicle objects apart from eachother before you re-enable collisions.


Re: vtach/detach command [message #437353 is a reply to message #436900] Sat, 02 October 2010 11:42 Go to previous messageGo to next message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
yea reborn thats obvious but i have no idea how otherwise i wouldnt ask Sad everything is fine exept the stupid detaching Sad

Owner of kambot TT server

kambot.freeforums.org
Re: vtach/detach command [message #437360 is a reply to message #436900] Sat, 02 October 2010 14:30 Go to previous messageGo to next message
reborn is currently offline  reborn
Messages: 3231
Registered: September 2004
Location: uk - london
Karma: 0
General (3 Stars)
Commands->Set_Position


Re: vtach/detach command [message #437364 is a reply to message #436900] Sat, 02 October 2010 16:08 Go to previous message
robbyke is currently offline  robbyke
Messages: 348
Registered: September 2010
Location: Belgium
Karma: 0
Recruit
I had found a way thnx anyway =D

Owner of kambot TT server

kambot.freeforums.org
Previous Topic: Change map
Next Topic: I wonder if its possible to add movies to maps?
Goto Forum:
  


Current Time: Wed May 29 01:18:20 MST 2024

Total time taken to generate the page: 0.00959 seconds