Dilapidated 26 Posted August 29, 2015 Share Posted August 29, 2015 (edited) I was curious to how someone would get enemy Valkyrie's, Savage's, and Buzzard's to use their respective vehicle weapons. We've tried some of these with no luck VEHICLE_WEAPON_PLANE_ROCKETVEHICLE_WEAPON_PLAYER_BUZZARDVEHICLE_WEAPON_NOSE_TURRET_VALKYRIEVEHICLE_WEAPON_PLAYER_SAVAGE Also what lines would best control the shooting rate of Rhino's (would like to keep it like vanilla but currently they shoot as quickly as the game allows) Edited August 29, 2015 by Dilapidation Link to post Share on other sites
Dilapidated 26 Posted August 29, 2015 Author Share Posted August 29, 2015 I've seen some sources of these vehicles working in C++ but not sure how to make enemies use the vehicle weapons in C# Link to post Share on other sites
GeorgeZhang 25 Posted August 30, 2015 Share Posted August 30, 2015 Have you try converting those source codes to C# using Function.Call? Link to post Share on other sites
Dilapidated 26 Posted August 30, 2015 Author Share Posted August 30, 2015 (edited) Have you try converting those source codes to C# using Function.Call?Thanks for the reply. Yes we have but with no luck. They fly around us but still will not use their vehicle weapons for whatever reason. The Function.Call works well with other vehicle weapons though. Like the Rhino and Lazer just not the heli's. Any other ideas or am I missing something? Edited August 30, 2015 by Dilapidation Link to post Share on other sites
Dilapidated 26 Posted August 31, 2015 Author Share Posted August 31, 2015 Could someone point me to a C# source of these heli's using their vehicle weapons. We've tried so much with no luck. Link to post Share on other sites
whorse 26 Posted September 1, 2015 Share Posted September 1, 2015 (edited) try converting the below natives (C++) to C# Function.Call WEAPON::SET_CURRENT_PED_VEHICLE_WEAPON(pilot,GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_SPACE_ROCKET"));VEHICLE::SET_VEHICLE_SHOOT_AT_TARGET(pilot, target, targPos.x, targPos.y, targPos.z); They worked for me. Of course a vehicle could only shoot a weapon with which it has by default (unarmed planes shooting missiles is done via SHOOT_SINGLE_BULLET_BETWEEN_COORDS()) I saw vehicles like the savage and the buzzard shoot both their missiles and their cannons/miniguns simultaneously, and the Lazer and Hydra would shoot primarily missiles but would shoot cannons if they were strafing right at you. Getting that to work only seemed like a fluke, though; I'd have to tell them to shoot their normal guns with SET_VEHICLE_SHOOT_AT_TARGET alone first, and then a moment later tell them to switch to missiles. But anyway, the most important thing is that you use the c# equivalent of VEHICLE::SET_VEHICLE_SHOOT_AT_TARGET I could not get the valkyrie to do anything with its nose turret weapon, and I spawned hostile peds in the minigun seats and even told them to shoot at and task_combat targets, but they still wouldn't do anything. For some reason, peds were rarely spawning in the co-pilot seat though. Helis seem to shoot "space rockets", planes shoot plane rockets. Edited September 1, 2015 by whorse Link to post Share on other sites
bilago 25 Posted September 2, 2015 Share Posted September 2, 2015 try converting the below natives (C++) to C# Function.Call WEAPON::SET_CURRENT_PED_VEHICLE_WEAPON(pilot,GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_SPACE_ROCKET"));VEHICLE::SET_VEHICLE_SHOOT_AT_TARGET(pilot, target, targPos.x, targPos.y, targPos.z); They worked for me. Of course a vehicle could only shoot a weapon with which it has by default (unarmed planes shooting missiles is done via SHOOT_SINGLE_BULLET_BETWEEN_COORDS()) I saw vehicles like the savage and the buzzard shoot both their missiles and their cannons/miniguns simultaneously, and the Lazer and Hydra would shoot primarily missiles but would shoot cannons if they were strafing right at you. Getting that to work only seemed like a fluke, though; I'd have to tell them to shoot their normal guns with SET_VEHICLE_SHOOT_AT_TARGET alone first, and then a moment later tell them to switch to missiles. But anyway, the most important thing is that you use the c# equivalent of VEHICLE::SET_VEHICLE_SHOOT_AT_TARGET I could not get the valkyrie to do anything with its nose turret weapon, and I spawned hostile peds in the minigun seats and even told them to shoot at and task_combat targets, but they still wouldn't do anything. For some reason, peds were rarely spawning in the co-pilot seat though. Helis seem to shoot "space rockets", planes shoot plane rockets. are you setting these natives once, or every tick? Link to post Share on other sites
whorse 26 Posted September 3, 2015 Share Posted September 3, 2015 (edited) try converting the below natives (C++) to C# Function.Call WEAPON::SET_CURRENT_PED_VEHICLE_WEAPON(pilot,GAMEPLAY::GET_HASH_KEY("VEHICLE_WEAPON_SPACE_ROCKET"));VEHICLE::SET_VEHICLE_SHOOT_AT_TARGET(pilot, target, targPos.x, targPos.y, targPos.z); They worked for me. Of course a vehicle could only shoot a weapon with which it has by default (unarmed planes shooting missiles is done via SHOOT_SINGLE_BULLET_BETWEEN_COORDS()) I saw vehicles like the savage and the buzzard shoot both their missiles and their cannons/miniguns simultaneously, and the Lazer and Hydra would shoot primarily missiles but would shoot cannons if they were strafing right at you. Getting that to work only seemed like a fluke, though; I'd have to tell them to shoot their normal guns with SET_VEHICLE_SHOOT_AT_TARGET alone first, and then a moment later tell them to switch to missiles. But anyway, the most important thing is that you use the c# equivalent of VEHICLE::SET_VEHICLE_SHOOT_AT_TARGET I could not get the valkyrie to do anything with its nose turret weapon, and I spawned hostile peds in the minigun seats and even told them to shoot at and task_combat targets, but they still wouldn't do anything. For some reason, peds were rarely spawning in the co-pilot seat though. Helis seem to shoot "space rockets", planes shoot plane rockets. are you setting these natives once, or every tick? I am setting the natives every 30 ticks, although I'm pretty sure that's unnecessary for the weapon-selection one. Basically, VEHICLE::SET_VEHICLE_SHOOT_AT_TARGET() makes them shoot their default/preferred (or manually selected) vehicle weapon once for each time it is called (but not faster than the weapon's rate of fire). I used to have it do it every single tick, and I had a method to find a random nearby target for each tic too. It made the Buzzard shoot its miniguns literally like a shower, with one bullet going at one ped, the next bullet going at another ped that's 50 feet behind the first one, and so on -- and all of this happened at the speed of a minigun firing (and all while shooting rockets too). Bullets could come out of the helicopter in any direction. To fix that, I had to check to see if the target was in the aircraft's line of sight using these natives: ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY(Entity src, Entity target, 17);ENTITY::HAS_ENTITY_CLEAR_LOS_TO_ENTITY_IN_FRONT(Entity src, Entity target); Getting them to shoot both weapons simultaneously only worked if I had them "vehicle shoot" without always selecting missiles first (by having them only switch to missiles if they passed a 1/15 odds-check for that tick). Later, I made it happen once for every x tics, and that changed it so the heli's miniguns would always fire at the same spot no matter which way the helicopter was pointed and even when there was no one at the target. That got annoying fast, so I just disabled the miniguns and switched them to rockets-only for now. The savage's minigun is ridiculously OP anyway (it's like a gatling-railgun). Planes using their cannons has always been kind of unreliable, but I do hear it/notice it happening sometimes when the plane is flying straight at its semi-close target (rare) I did all this testing while I was creating the Traffic Spawner mod. These are some pretty ghetto techniques (especially the odds-thing), but making the aircraft dogfight wasnt supposed to be that big a part of the mod. You should also check out this thread for more info on aircraft AI and behavior Edited September 3, 2015 by whorse Link to post Share on other sites