Jump to content
The Loot

LA Get Equipment Behavior

Recommended Posts

Is it possible to have the LAChangeClothes, LAStretcher, LAGetEMTBag, and such commands automatically find the nearest valid vehicle like the default equipment commands do?

 

There has to be just a line or two of code to make that possible, right?

 

(OT: If someone could possibly answer my question here, that'd be great.)

 

 

Based off the below code!

		GameObject obj(Target);		if (Caller->GetObjectType()==TYPE_PERSON && Caller->GetEquipment()!=EQUIP_FIRE_EXTINGUISHER &&			obj.IsValid() && obj.IsFlagSet(OF_HAS_FIRE_EXTINGUISHER))		{			Person p(Caller);			if(p.IsValid() && (p.IsCarryingPerson()|| p.HasCommand("HolsterWeapon") || p.IsLinkedWithPerson()|| p.GetFirehoseID()!=0 || p.IsPulling() || p.GetEnteredCarID() != -1))				return false;						return true;		}		return false;	}	void PushActions(GameObject *Caller, Actor *Target, int childID)	{		Vector TargetPos = Target->GetTargetPoint(Caller, TARGET_EQUIPMENTDOOR);		if (!Caller->IsCommandEnabled("Extinguish"))		{			Person p(Caller);			p.EnableCommand("Extinguish", true);			p.EnableCommand("Cool", true);			p.EnableAutoTarget(true);		}				Caller->PushActionMove(ACTION_NEWLIST, TargetPos);		Caller->PushActionTurnTo(ACTION_APPEND, Target);		Caller->PushActionGetEquipment(ACTION_APPEND, Target, EQUIP_FIRE_EXTINGUISHER);		Caller->PushActionExecuteCommand(ACTION_APPEND, DUMMY_EQUIPMENT, Target, 8, false);	

Your looking to do the PushAction parts! of course you will half to define where the person is going to go which i belive would be this part 

		Vector TargetPos = Target->GetTargetPoint(Caller, TARGET_EQUIPMENTDOOR);		if (!Caller->IsCommandEnabled("Extinguish"))		{			Person p(Caller);			p.EnableCommand("Extinguish", true);			p.EnableCommand("Cool", true);			p.EnableAutoTarget(true);		}

So in theory editing and put this in proper line of the scripts related to the items you mentioned would allow you to do what you wish!

( Im sure it would take some tinkering though! )

Link to comment
Share on other sites

Yes that's possible and there are at least two ways. I personally prefer a code in the PushActions section of the commandscript.

 

In the US Army Mod I used the following code to get the medic case from the closest ambulance:

	Vector CmdPos = Caller->GetPosition();	Vehicle *t = NULL;	float bestCar = 0.;	VehicleList list(VT_AMBULANCE_ITW, VT_THW_FGRT_BH);	for (int i = 0; i < list.GetNumVehicles(); i++) 	{		Vehicle *aCar = list.GetVehicle(i);		if (!aCar->IsCurrentAction("EActionFindPath") && !aCar->IsDestroyed() && aCar->IsValid() && (aCar->GetVehicleType() == VT_AMBULANCE_ITW || aCar->GetVehicleType() == VT_AMBULANCE_NEF || (aCar->GetVehicleType() == VT_AMBULANCE_RHC && aCar->IsOnGround()) || aCar->GetVehicleType() == VT_AMBULANCE_RTW || (aCar->GetVehicleType() == VT_THW_FGRT_BH && aCar->IsOnGround())))		{			float distCurrCar = Math::dist(CmdPos.x, CmdPos.y, aCar->GetPosition().x, aCar->GetPosition().y);			if (distCurrCar < bestCar || bestCar == 0.) 			{				t = aCar;				bestCar = distCurrCar;			}		}	}	if (t)	{		Vector TargetPos = t->GetTargetPoint(Caller, TARGET_EQUIPMENTDOOR);		Caller->PushActionMove(ACTION_NEWLIST, TargetPos);		Caller->PushActionTurnTo(ACTION_APPEND, t);		Caller->PushActionExecuteCommand(ACTION_APPEND, "PcmdGetEMTCase", t, 1, false);	}

What it does is that it first gets all vehicles that are a certain vehicletype in a list, it checks each found vehicle for certain traits (such as 'not destroyed', 'vehicletype itw or rtw' etc..). Then it checks the absolute distance to the caller and compares that with all other found vehicles with the same traits. The closest vehicle is defined as target 't'.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...