Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Cayo Perico Heist
      2. The Diamond Casino Heist
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Frontier Pursuits
      2. Find Lobbies & Outlaws
      3. Help & Support
    3. Crews

    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. Grand Theft Auto Series

    2. GTA VI

      1. St. Andrews Cathedral
    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
    6. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
    7. GTA III

      1. Guides & Strategies
      2. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    3. Gangs

    1. Announcements

    2. Support

    3. Suggestions

Sign in to follow this  
Dilapidated

C# Questions

Recommended Posts

Dilapidated

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 by Dilapidation

Share this post


Link to post
Share on other sites
Dilapidated

I've seen some sources of these vehicles working in C++ but not sure how to make enemies use the vehicle weapons in C#

Share this post


Link to post
Share on other sites
GeorgeZhang

Have you try converting those source codes to C# using Function.Call?

Share this post


Link to post
Share on other sites
Dilapidated

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 by Dilapidation

Share this post


Link to post
Share on other sites
Dilapidated

Could someone point me to a C# source of these heli's using their vehicle weapons. We've tried so much with no luck.

Share this post


Link to post
Share on other sites
whorse

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 by whorse

Share this post


Link to post
Share on other sites
bilago

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?

Share this post


Link to post
Share on other sites
whorse

 

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 by whorse

Share this post


Link to post
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.

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.

Sign in to follow this  

  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.