Iran Posted October 21, 2020 Posted October 21, 2020 When a vehicle is bought it will automatically follow three possible waypoints outside of the WF or after being dropped by cargo plane for Air. This code will find those waypaths and use them to determine where to drop off the !vehicle vehicle with the chinook after wf/air is dead. [spoiler][code] bool Inside_OBBox(OBBoxClass &ob, Vector3 &pos) { int val; _asm { push pos push ob mov ecx, 0x00616430 call ecx add esp, 8 mov val, eax } return val == 2; // 2 = inside } bool Find_Vehicle_Drop_Off_Position(int Team, Vector3 &pos) { GameObject *building = Find_Vehicle_Factory(Team); if (!building || !building->As_BuildingGameObj() || !building->As_BuildingGameObj()->As_VehicleFactoryGameObj()) return false; OBBoxClass gr = ((VehicleFactoryGameObjDummy *)building->As_BuildingGameObj()->As_VehicleFactoryGameObj())->GeneratingRegion; DynamicVectorClass<int> Waypaths; Retrieve_Waypaths(Waypaths); int WaypathID = -1; int WaypointID = -1; int count = 0; for (int i = 0; i < Waypaths.Count(); i++) { DynamicVectorClass<int> Waypoints; Retrieve_Waypoints(Waypaths[i], Waypoints); for (int j = 0; j < Waypoints.Count(); j++) { Vector3 waypos = Vector3(); Get_Waypoint_Position(Waypaths[i], Waypoints[j], waypos); if (Inside_OBBox(gr, waypos)) { count++; // Console_Output("Team %d found waypath inside obbox\n", Team); WaypointID = Waypoints[j]; WaypathID = Waypaths[i]; } if (count == 2) break; } if (count == 2) break; // Get the waypath in the middle } if (WaypathID == -1 || WaypointID == -1) return false; DynamicVectorClass<int> Waypoints; Retrieve_Waypoints(WaypathID, Waypoints); // Last added way point should be fartest away int finalwaypointID = Waypoints[Waypoints.Count() - 1]; Get_Waypoint_Position(WaypathID, finalwaypointID, pos); return true; } bool Main_Hooks::Try_Vehicles_Command(cPlayer *Player, TextMessageEnum Type, const StringClass &Command, const DATokenClass &Text, int ReceiverID) { int Team = Player->Get_Player_Type(); if (Team != 0 && Team != 1) return true; for (int i = 0; i < Vehicles.Count(); i++) { if (Vehicles[i].Triggers.ID(Command) != -1) { if (!Has_Vehicle_Factory_And_Is_Destroyed(Team)) { DA::Private_Color_Message(Player, COLORGRAY, "ERROR: The %s has not been destroyed. Purchase characters via the Purchase Terminal.", Get_Vehicle_Factory_String(Team)); return false; } if (VehicleBuyWaitTimer[Team] > 0) { DA::Private_Color_Message(Player, COLORGRAY, "ERROR: You need to wait %d seconds before you can buy a vehicle.", VehicleBuyWaitTimer[Team]); return false; } if ((Team != 0 && Team != 1) || !Vehicles[i].Vehicle[Team]) { DA::Private_Color_Message(Player, COLORGRAY, "ERROR: Your team cannot purchase that vehicle."); return false; } else if (Get_Distance_To_Closest_PCT(Player->Get_GameObj()->Get_Position(), Team) > 5.0f) { DA::Private_Color_Message(Player, COLORGRAY, "ERROR: You must be at a Purchase Terminal to use this command."); return false; } else { VehicleGameObjDef *VehDef = Vehicles[i].Vehicle[Team]; if (!VehDef) { DA::Private_Color_Message(Player, COLORGRAY, "ERROR: Vehicle definition not found."); return false; } if (VehDef->Get_Type() == VEHICLE_TYPE_FLYING && !Is_Map_Flying()) { DA::Private_Color_Message(Player, COLORGRAY, "ERROR: You can not buy a flying vehicle on a non-flying map."); return false; } else { int Cost = (int)Round((float)Vehicles[i].Cost*Player->Get_DA_Player()->Get_PowerUp_Discount()); if (!BaseControllerClass::Find_Base(Team)->Is_Base_Powered()) { Cost *= 2; } if (Player->Get_Money() < Cost) { DA::Private_Color_Message(Player, COLORGRAY, "ERROR: Insufficient funds. %s currently costs %d credits.", A_Or_An_Prepend(DATranslationManager::Translate(VehDef)), Cost); if (Team == 0) { Create_2D_WAV_Sound_Player_By_ID(Player->Get_Id(), "M00EVAN_DSGN0024I1EVAN_snd.wav"); } else { Create_2D_WAV_Sound_Player_By_ID(Player->Get_Id(), "M00EVAG_DSGN0028I1EVAG_snd.wav"); } return false; } else { Vector3 pos = Vector3(); if (Find_Vehicle_Drop_Off_Position(Team, pos)) { DAVehicleManager::Air_Drop_Vehicle(Team, VehDef, pos, 0.0f); VehicleBuyWaitTimer[Team] = VEHICLE_BUY_WAIT_TIME; Start_Timer(1499, 0.1f, false, Team); Player->Purchase_Item(Cost); Create_2D_WAV_Sound_Player_By_ID(Player->Get_Id(), "M00GBMG_SECX0002I1GBMG_snd.wav"); DALogManager::Write_Log("_PURCHASE", "%ls - %s", Player->Get_Name(), DATranslationManager::Translate(VehDef)); DA::Private_Color_Message(Player, COLORGRAY, "You have purchased %s for %d credits. It will be air dropped at the %s.", a_or_an_Prepend(DATranslationManager::Translate(VehDef)), Cost, Get_Vehicle_Factory_String(Team)); } else { DA::Private_Color_Message(Player, COLORGRAY, "ERROR: No drop off position found."); } } } } } } return true; } [/code] Add a code file VehicleFactoryGameObjDummy.h it's used by the code to get the vehicle creation waypoints list. [code] #ifndef VEHICLE_FACTORY_GAME_OBJ_DUMMY_H #define VEHICLE_FACTORY_GAME_OBJ_DUMMY_H #include "general.h" #include "engine.h" #include "BuildingGameObj.h" #include "ReferencerClass.h" #include "Matrix3D.h" class VehicleFactoryGameObjDummy : public BuildingGameObj { public: virtual void Init(void) {} ReferencerClass Vehicle; Matrix3D CreationTM; OBBoxClass GeneratingRegion; float GenerationTime; int GeneratingVehicleID; bool IsBusy; bool IsDisabled; ReferencerClass Purchaser; int LastDeliveryPath; int LastFlyingDeliveryPath; float EndTimer; static int MaxVehiclesPerTeam; }; // 08CC #endif // !VEHICLE_FACTORY_GAME_OBJ_DUMMY_H[/code] [/spoiler] 1
Blacky Posted October 24, 2020 Posted October 24, 2020 I added this to the !tank command. if the drop off position is not defined in the ini to get the vehicle way points position.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now