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

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

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

      1. Recruitment
    2. Events

    1. GTA Online

      1. Diamond Casino & Resort
      2. DLC
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

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

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

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

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

    2. Forum Support

    3. Site Suggestions

Graphicscore

[Q][.NET]AI Drive to Coords, Fly Helicopter to location and land on gr

Recommended Posts

Cyron43

Yes of course. I thought this is self-explanatory. The following method gets called by an event that's being fired after the target has been reached.

      private void ReleaseDriver()      {         if(!CommonFunctions.PedExists(Driver))            return;         MakeDriverInvincible(false);         Driver.AlwaysKeepTask = false;         Driver.BlockPermanentEvents = false;         // note: missing members         //Driver.ChangeRelationship(RelationshipGroup.Player, Relationship.Neutral);         Driver.Task.ClearAll();                  Driver.SetRequiredForMission(false); //note: was .IsRequiredForMission = false;         //Driver.LeaveGroup();         Driver.Task.LeaveVehicle();         Driver.Task.WanderAround();         Driver.MarkAsNoLongerNeeded();         //note: missing member         //if(Driver.PedType == PedType.Cop)         //{         //   Wait(3000);         //   Driver.Delete();         //}         CommonFunctions.LoadAllPathNodes(false);         _drivingData.TargetType = TypeOfTarget.None;         DeactivateAutodriveFlags();         if(Game.Player.Character.IsSittingInVehicle(CurrentVehicle))            _seatHandling.WarpPlayerBackToDriverSeatOnceFree();         UI.Notify("Driving task has been released.");         CurrentVehicle.FreezePosition = false;         _speedState = SpeedState.Low;         SwitchTickEventToHelmetObserver();      }

Here is the link to my git repository.
Note: This mod is migrated from GTA IV and still has some bugs and deactivated code.

https://bitbucket.org/CyronsTeam/vautodrive/src

And here is the link to my VCommonFunctions framework. It is referenced by this mod and contains several extensions and common functionality across my mods.

https://bitbucket.org/CyronsTeam/vcommonfunctions/downloads

Edited by Cyron43

Share this post


Link to post
Share on other sites
Graphicscore

Thanks in advace, I'll give it a shot if I am back home.

 

Just for the guys which may be interested in what I am doing, I recently saw a mod where you could "rob" the banks again. I think the idea is pretty cool but the way it's made is "meh", I am currently working on some kind of custom mission(s) where you have to gather equipment and rob the bank, yep its almost some kind of mission. I'll let you know if I got something working.

Share this post


Link to post
Share on other sites
Cyron43

It would be cool if we could bring the mission editor for online to Singleplayer mode.

Share this post


Link to post
Share on other sites
Graphicscore

It would indeed but I don't think that this will be possible though :) Only time will tell.

Share this post


Link to post
Share on other sites
DataHead

Awesome to see someone else with a similar idea yet different implementation! Nice!

 

I was doing something rather similar but i was doing it for a custom personal tasks for pededstrian missions that I assign them.

 

For example, in mine, an a.i. ped whom is "unemployed" and looking to do some dirtywork, i can pick another a.i. to put a hit on, and that ped a.i. will try and kill them appropriately

Share this post


Link to post
Share on other sites
Cyron43

Hello there,

 

I want that a Ped drives/flys to given COORDS and lands on the ground.

 

I am currently using the following funciton to make the Ped flying to given coords.

void TASK_VEHICLE_DRIVE_TO_COORD(Ped pedHandle, Vehicle vehicleHandle, float x, float y, float z, float speed, Any p6, Hash vehicleModel, int drivingMode, float p9, float p10) // E2A2AA2F659D77A7 E4AC0387
The ped is actually flying to the given x y z , but the ped does not land on the the ground, is will hover mid air and wander around the point.

 

Do I have to call a fuction for landing the vehicle or do I just have to make sure that the landing area is not occupied ?

 

Regards

 

Hi,

Could you please share what parameters you used? Because when I try it the whole game crashes. Also, have you wrapped those into an InputParameters instance? I'm still confused about in which cases to use that class.

Share this post


Link to post
Share on other sites
Graphicscore

 

Hello there,

 

I want that a Ped drives/flys to given COORDS and lands on the ground.

 

I am currently using the following funciton to make the Ped flying to given coords.

void TASK_VEHICLE_DRIVE_TO_COORD(Ped pedHandle, Vehicle vehicleHandle, float x, float y, float z, float speed, Any p6, Hash vehicleModel, int drivingMode, float p9, float p10) // E2A2AA2F659D77A7 E4AC0387
The ped is actually flying to the given x y z , but the ped does not land on the the ground, is will hover mid air and wander around the point.

 

Do I have to call a fuction for landing the vehicle or do I just have to make sure that the landing area is not occupied ?

 

Regards

 

Hi,

Could you please share what parameters you used? Because when I try it the whole game crashes. Also, have you wrapped those into an InputParameters instance? I'm still confused about in which cases to use that class.

 

 

Yeah I will post the code as soon as I am back home again. Regarding to the InputParameters I think it's used if the param is a pointer (*) instead of a n actual real instance of an object, but that's just a guess.

Share this post


Link to post
Share on other sites
Graphicscore

@Cyron43, here we go , as promised :)

Ped companion_3 = World.CreatePed(companionModel, new GTA.Math.Vector3(2370.871F, 6624.624F, 3.100F), 270F);Vehicle valkyrie = World.CreateVehicle(valkyrieModel, new GTA.Math.Vector3(2378.245F, 6618.386F, 2.459F));Function.Call<bool>(Hash.TASK_VEHICLE_DRIVE_TO_COORD, new InputArgument[] { companion_3, valkyrie, 3464.990F, 3682.537F, 33.200F, 80F, 1, (uint) VehicleHash.Valkyrie, 1, (uint) DrivingStyle.SometimesOvertakeTraffic, -1 });I actually wrapped the arguments inside of the InputArguments class but I don't know if you actually have to. 64.990F, 3682.537F, 33.200F are the COORDS( X, Y, Z) and 80F is the speed 

Share this post


Link to post
Share on other sites
Cyron43

@Cyron43, here we go , as promised :)

Ped companion_3 = World.CreatePed(companionModel, new GTA.Math.Vector3(2370.871F, 6624.624F, 3.100F), 270F);Vehicle valkyrie = World.CreateVehicle(valkyrieModel, new GTA.Math.Vector3(2378.245F, 6618.386F, 2.459F));Function.Call<bool>(Hash.TASK_VEHICLE_DRIVE_TO_COORD, new InputArgument[] { companion_3, valkyrie, 3464.990F, 3682.537F, 33.200F, 80F, 1, (uint) VehicleHash.Valkyrie, 1, (uint) DrivingStyle.SometimesOvertakeTraffic, -1 });I actually wrapped the arguments inside of the InputArguments class but I don't know if you actually have to. 64.990F, 3682.537F, 33.200F are the COORDS( X, Y, Z) and 80F is the speed 

Thanks a bunch. That's much appreciated. :+1:

I will try that tomorrow. Finally I can implement the helicopter autopilot in my Autodrive mod. I guess I can mention your name as help contributor in the guide?

Share this post


Link to post
Share on other sites
Graphicscore

 

@Cyron43, here we go , as promised :)

Ped companion_3 = World.CreatePed(companionModel, new GTA.Math.Vector3(2370.871F, 6624.624F, 3.100F), 270F);Vehicle valkyrie = World.CreateVehicle(valkyrieModel, new GTA.Math.Vector3(2378.245F, 6618.386F, 2.459F));Function.Call<bool>(Hash.TASK_VEHICLE_DRIVE_TO_COORD, new InputArgument[] { companion_3, valkyrie, 3464.990F, 3682.537F, 33.200F, 80F, 1, (uint) VehicleHash.Valkyrie, 1, (uint) DrivingStyle.SometimesOvertakeTraffic, -1 });I actually wrapped the arguments inside of the InputArguments class but I don't know if you actually have to. 64.990F, 3682.537F, 33.200F are the COORDS( X, Y, Z) and 80F is the speed 

Thanks a bunch. That's much appreciated. :+1:

I will try that tomorrow. Finally I can implement the helicopter autopilot in my Autodrive mod. I guess I can mention your name as help contributor in the guide?

 

Would be an honor :), I'll include yours as well in my because you lead me into the right direction of landing that freaking chopper :)

Edited by Graphicscore

Share this post


Link to post
Share on other sites
Cyron43

I don't get it! I tried your code but the chopper just don't move. *sigh*

I give up for today. First that freakin GoTo and now that. I can only bear so much frustration. Time for some gaming fun.

Okay the last thing I try today is TASK_HELI_MISSION because THAT was the function I needed in GTA IV to make that damn thing fly. Keep your fingers crossed I find the right parameters.

Edited by Cyron43

Share this post


Link to post
Share on other sites
Graphicscore

I haven't used the Heli Mission Task, do you use the player as driver or another ped ? I use another ped and maybe you need to set an relationship between the player and the ped. I'll look up my source maybe I find something interesting :)

Share this post


Link to post
Share on other sites
Graphicscore

Alright , I looked up my source again so basically the only thing I do before calling the DRIVE_TO native is setting the relationship between the driver and the player

//Declaring stuffPed companion_3 = World.CreatePed(...);Ped player = Game.Player.Character;//Getting player relation ship groupint i = Function.Call<int>(Hash.GET_PED_GROUP_INDEX, new InputArgument[] { player });//Set relationship groupFunction.Call(Hash.SET_PED_AS_GROUP_MEMBER, new InputArgument[] { companion_3, i });//Set relationship between groupsWorld.SetRelationshipBetweenGroups(Relationship.Like, companion_3.RelationshipGroup, player.RelationshipGroup);
Edited by Graphicscore

Share this post


Link to post
Share on other sites
Cyron43

Thanks I will try that. The relationship handling is still lacking in the .net script hook and I didn't know how to do it. :^:

Edited by Cyron43

Share this post


Link to post
Share on other sites
Graphicscore

Keep me updated :):^:

Edited by Graphicscore

Share this post


Link to post
Share on other sites
Cyron43

Still don't work. I guess I wait for the RAGE plugin. Maybe that provides a working method. This is what I got (I even commented out some code because you didn't use it also):

 

      private void PrepareDriver()      {         if(!CommonFunctions.PedExists(Driver))            return;         //Driver.BlockPermanentEvents = true;         Driver.ChangeRelationshipTo(Game.Player.Character, Relationship.Like);         //Driver.SetRequiredForMission(true);         if(CommonFunctions.VehicleExists(CurrentVehicle))            CurrentVehicle.IsInvincible = true; //note: missing member, was .MakeProofTo(true, true, true, true, true);         MakeDriverInvincible(true);         //Driver.AlwaysKeepTask = true;      }
      public void DriveWith(DrivingData drivingData)      {         if(drivingData.DesiredAltitude < drivingData.StaticTarget.Z)            drivingData.DesiredAltitude = (short)(drivingData.StaticTarget.Z + CommonFunctions.MIN_ALT_FIX);         drivingData.DrivingIsActive = true;         drivingData.Driver.Task.ClearAll();         var args = new InputArgument[]                    {                       drivingData.Driver,                       drivingData.Vehicle,                       drivingData.StaticTarget.X,                       drivingData.StaticTarget.Y,                       drivingData.DesiredAltitude,                       1,                       (uint)drivingData.Vehicle.Model.GetHashCode(),                       (uint)DrivingStyle.SometimesOvertakeTraffic,                       -1                    };         Function.Call(Hash.TASK_VEHICLE_DRIVE_TO_COORD, args);      }
I wrapped your relationship code in an extension method.

 

      public static void ChangeRelationshipTo(this Ped ped, Ped otherPed, Relationship relationship)      {         //Getting player relation ship group         int i = Function.Call<int>(Hash.GET_PED_GROUP_INDEX, ped);         //Set relationship group         Function.Call(Hash.SET_PED_AS_GROUP_MEMBER, otherPed, i);         //Set relationship between groups         World.SetRelationshipBetweenGroups(relationship, ped.RelationshipGroup, otherPed.RelationshipGroup);      }
In case you need more information here is my Autodrive repo

https://bitbucket.org/CyronsTeam/vautodrive/src

 

and this is the repo of GTAVCommonFunctions (which holds the exensions)

https://bitbucket.org/CyronsTeam/vcommonfunctions/src

Edited by Cyron43

Share this post


Link to post
Share on other sites
Graphicscore

I'll take a look at that !

Share this post


Link to post
Share on other sites
Connor_l_ane96

Can someone help me get mod menu please

Share this post


Link to post
Share on other sites
Graphicscore

@Connor_I_ane96, could you please open another thread for your question, because this question is regarding the issue of calling tasks on peds to make them drive to a given location. I think you'll get an answer faster as well if you open a correct thread for that :).

 

@Cyron43, I actually excluded all the code for flying out of my main script and copied it together. This script should spawn a chopper(Valkyrie) at the observatorium and then it should spawn a Ped at the players location , player gets warped into the chopper and the ped gets in aswell and flies to the given location.

 

Can you verify for me that this script is working for you?

 

And by the way , what exactly does happen if the Ped should drive there, or do you call the drive to method on the player ?

 

Regards,

 

G.

public class Testing: Script{    Model valkyrieModel = new Model(VehicleHash.Valkyrie);    Model companionModel = new Model(PedHash.CiaSec01SMM);    Vehicle testVehicle;    Ped testPed;    public Testing()    {        Tick += OnTick;        KeyDown += OnKeyDown;        Interval = 10;    }    void OnKeyDown(object sender, KeyEventArgs e)    {        Ped player = Game.Player.Character;        if (e.KeyCode == Keys.O)        {            testVehicle = World.CreateVehicle(valkyrieModel, new Vector3(-407.480F, 1064.360F, 323.841F));            testPed = World.CreatePed(companionModel, player.Position);            player.Task.WarpIntoVehicle(testVehicle, VehicleSeat.Passenger);            Wait(1000);            Function.Call<bool>(Hash.TASK_VEHICLE_DRIVE_TO_COORD, new InputArgument[] { testPed, testVehicle, 3464.990F, 3682.537F, 33.200F, 80F, 1, (uint)VehicleHash.Valkyrie, 1, (uint)DrivingStyle.SometimesOvertakeTraffic, -1 });        }        if (e.KeyCode == Keys.I)        {            removePed(testPed);            removeVehicle(testVehicle);        }    }    void removeVehicle(Vehicle vehicle)    {        if (vehicle != null)        {            vehicle.Delete();        }    }    void removePed(Ped ped)    {        if (ped != null)        {            ped.Delete();        }    }}
Edited by Graphicscore

Share this post


Link to post
Share on other sites
Cyron43

@Graphicscore: Thanks mate. I don't know what to say about your big effort. If we ever meet in real life we have to get a drink together. :)

I will test your code - I dunno maybe today but I'm not sure if I get the time - but tomorrow no matter what.

What happens? Well if the chopper is still on the ground, the driver spawns but nothing else happens. In case the chopper is airborne already the driver hovers right there and even adjusts to any drifts (why are choppers so unstable in GTA V anyway, but that's more of a rhetorical question). So he's really good at keeping a position in mid-air but that's all that happens. The call hierarchy in my mod is pretty long as it needs to care for all circumstances.

This is the actual code map from the trigger key to the drive strategy.

x2rmet.png

Share this post


Link to post
Share on other sites
Graphicscore

@Graphicscore: Thanks mate. I don't know what to say about your big effort. If we ever meet in real life we have to get a drink together. :)

I will test your code - I dunno maybe today but I'm not sure if I get the time - but tomorrow no matter what.

What happens? Well if the chopper is still on the ground, the driver spawns but nothing else happens. In case the chopper is airborne already the driver hovers right there and even adjusts to any drifts (why are choppers so unstable in GTA V anyway, but that's more of a rhetorical question). So he's really good at keeping a position in mid-air but that's all that happens. The call hierarchy in my mod is pretty long as it needs to care for all circumstances.

This is the actual code map from the trigger key to the drive strategy.

x2rmet.png

Woah thats a big code map dude, I have to admit that I never plan or organize anything in my scripts or applications(I know it's bad but I am lazy as f*ck :panic: ).

Initially I had the idea to fork your code and tweak around abit too see if I would get it working but your code is rather complex and divided into multiple instances and I didn't had the time to read through all of it(btw it's really well written, you don't want to see my script though, hah). The code should work, maybe you could just hard code it and test it in your script(with the correct vehicle and ped ofcourse). Let me know how it's going :lol:.

 

PS: I would check if you call any other tasks on the ped after DRIVE_TO, because I didn't call anything after it( and if I remember right it breaks if you call something else , but I am not quite sure ) :).

 

 

Keep me updated :^:

Edited by Graphicscore

Share this post


Link to post
Share on other sites
Cyron43

Great job, your code works! :^:

Now I have to find out why mine doesn't - step by step. *sigh*

Share this post


Link to post
Share on other sites
Graphicscore

Glad I could help :)

Share this post


Link to post
Share on other sites
Cyron43

Got it! It was just some mistakes in the parameters. Now all there's left to do is to care for some stupid bugs like the pilot leaving the chopper in mid-air when we arrived over the target. Ugly blood puddle on the ground. Poor pilot. RIP

Thanks for your great help. :^:

Share this post


Link to post
Share on other sites
leftas

Graphicscore, you can generate this one by Visual studio ;)

 

Best wishes,

Paul.

Share this post


Link to post
Share on other sites
Graphicscore

Got it! It was just some mistakes in the parameters. Now all there's left to do is to care for some stupid bugs like the pilot leaving the chopper in mid-air when we arrived over the target. Ugly blood puddle on the ground. Poor pilot. RIP

Thanks for your great help. :^:

 

Nice ! I'm glad I could help you :)

 

Graphicscore, you can generate this one by Visual studio ;)

 

Best wishes,

Paul.

 

 

Oo, Really ? Where ?

Share this post


Link to post
Share on other sites
leftas

 

Got it! It was just some mistakes in the parameters. Now all there's left to do is to care for some stupid bugs like the pilot leaving the chopper in mid-air when we arrived over the target. Ugly blood puddle on the ground. Poor pilot. RIP

Thanks for your great help. :^:

 

Nice ! I'm glad I could help you :)

 

Graphicscore, you can generate this one by Visual studio ;)

 

Best wishes,

Paul.

 

 

Oo, Really ? Where ?

 

It's called "Code map". MSDN explains https://msdn.microsoft.com/en-us/library/jj739835.aspx

 

All the best,

Paul.

Share this post


Link to post
Share on other sites
Cyron43

 

 

Got it! It was just some mistakes in the parameters. Now all there's left to do is to care for some stupid bugs like the pilot leaving the chopper in mid-air when we arrived over the target. Ugly blood puddle on the ground. Poor pilot. RIP

Thanks for your great help. :^:

 

Nice ! I'm glad I could help you :)

 

Graphicscore, you can generate this one by Visual studio ;)

 

Best wishes,

Paul.

 

 

Oo, Really ? Where ?

 

It's called "Code map". MSDN explains https://msdn.microsoft.com/en-us/library/jj739835.aspx

 

All the best,

Paul.

 

I wonder if that feature is available in the free editions.

Share this post


Link to post
Share on other sites
Graphicscore

 

 

 

Got it! It was just some mistakes in the parameters. Now all there's left to do is to care for some stupid bugs like the pilot leaving the chopper in mid-air when we arrived over the target. Ugly blood puddle on the ground. Poor pilot. RIP

Thanks for your great help. :^:

 

Nice ! I'm glad I could help you :)

 

Graphicscore, you can generate this one by Visual studio ;)

 

Best wishes,

Paul.

 

 

Oo, Really ? Where ?

 

It's called "Code map". MSDN explains https://msdn.microsoft.com/en-us/library/jj739835.aspx

 

All the best,

Paul.

 

I wonder if that feature is available in the free editions.

 

 

I actually have the paid students edition(#ThanksSchool)

 

But you can't tell me that this is organized, it looks kinda messed up XD (Auto generated by VS)

 

Ah what am I talking, take a look for yourself XD

 

PBeTd.png

Edited by Graphicscore

Share this post


Link to post
Share on other sites
Cyron43

 

 

 

 

Got it! It was just some mistakes in the parameters. Now all there's left to do is to care for some stupid bugs like the pilot leaving the chopper in mid-air when we arrived over the target. Ugly blood puddle on the ground. Poor pilot. RIP

Thanks for your great help. :^:

Nice ! I'm glad I could help you :)

 

Graphicscore, you can generate this one by Visual studio ;)

 

Best wishes,

Paul.

Oo, Really ? Where ?

 

It's called "Code map". MSDN explains https://msdn.microsoft.com/en-us/library/jj739835.aspx

 

All the best,

Paul.

 

I wonder if that feature is available in the free editions.

 

I actually have the paid students edition(#ThanksSchool)

 

But you can't tell me that this is organized, it looks kinda messed up XD (Auto generated by VS)

 

Ah what am I talking, take a look for yourself XD

 

PBeTd.png

 

It's hard to tell from that graph (as with mine). I think you get a better visualization of the architecture by creating a "dependency graph". You can find that in the menu bar above (I mean in VS). Architecture -> Create dependency graph.

ngaxy0.png

 

I don't know your knowledge about software architecture. Have you heard of "separation of concerns" or the SOLID principle or design patterns? I use a strategy pattern in my Autodrive mod.

Edited by Cyron43

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.
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.


  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

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