The Loot Posted July 17, 2013 Report Share Posted July 17, 2013 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.) Quote Link to comment Share on other sites More sharing options...
NathanDollinger Posted August 21, 2013 Report Share Posted August 21, 2013 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! ) Quote Link to comment Share on other sites More sharing options...
Hoppah Posted August 21, 2013 Report Share Posted August 21, 2013 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'. Quote Link to comment Share on other sites More sharing options...
The Loot Posted August 21, 2013 Author Report Share Posted August 21, 2013 Ah, that makes sense. I'll take a look at the get equipment and change clothes commands and see if I can get those running using that method. Quote Link to comment Share on other sites More sharing options...
The Loot Posted November 30, 2013 Author Report Share Posted November 30, 2013 OK, a bit of a bump. I've finally got my GetStretcher command to find nearest vehicle, but it won't activate until I click on a valid vehicle. LAStretcher.rar Quote Link to comment Share on other sites More sharing options...