Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » gameobject lists-> which&when
Re: gameobject lists-> which&when [message #457025 is a reply to message #457023] Thu, 06 October 2011 18:52 Go to previous messageGo to previous message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma:
General (3 Stars)
This should work depending on what exactly you want to do. Just modify it to suit your needs. Like check to see if script is attached to what ever and set how far the player should be or whatever.


GameObject *Get_Nearest_Solider(GameObject *obj) // Get the nearest solider next to a object
{
	float closestdist = FLT_MAX;
	Vector3 obj_pos = Commands->Get_Position(obj);
	GameObject *object = 0;
	SLNode<BaseGameObj> *x = GameObjManager::GameObjList.Head();
	while (x)
	{
		GameObject *o = (GameObject *)x->Data();
		if (o && As_SoldierGameObj(o))
		{
			Vector3 player_pos = Commands->Get_Position(o);
			float dist = Commands->Get_Distance(player_pos,obj_pos);
			if (dist < closestdist)
			{
				closestdist = dist;
				object = o;
			}
		}
		x = x->Next();
	}
	return object;
}


http://s18.postimage.org/jc6qbn4k9/bricks3.png
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: C&C_Mangalia
Next Topic: chatcommand
Goto Forum:
  


Current Time: Mon Dec 02 23:49:36 MST 2024

Total time taken to generate the page: 0.00650 seconds