Unsolved AI set to manually drive towards waypoint via Lua?

Discussion in 'Mod Support' started by The Gas Station, Nov 30, 2016.

  1. The Gas Station

    The Gas Station
    Expand Collapse

    Joined:
    Jul 14, 2016
    Messages:
    272
    I want an AI truck to drive towards a waypoint, as achieved in the "bank robbery" scenario. I wrote a Lua file based on the robbery Lua file, and it worked.
    Problem is, in that scenario the robber is set to "flee" mode in the Lua file, so if overtaken by you, it will head the long way, to avoid your car.

    helper.setAiMode('robber', 'flee', 'scenario_player0')

    That is impossible for me, since I want the AI to keep going in the shortest route even if you're in front of them. I want the AI to only care about the waypoint.
    I tried setting the AI to manual as follows:

    helper.setAiMode('truck', 'manual')

    but it doesn't work. The truck doesn't drive at all.

    How can I fix it?


    (I'm confident that this is what causes the truck not to move, since in flee mode
    helper.setAiMode('truck', 'flee', 'scenario_player0') it works just fine.)
     
  2. RyvyLo

    RyvyLo
    Expand Collapse

    Joined:
    May 15, 2014
    Messages:
    438
    Here's a piece of code I got working on my side :

    Code:
    helper.setAiMode('AICar', 'manual')
    helper.setAiTarget('AICar', 'waypoint')
    You could maybe try to take some inspiration from the corridor scenario's lua.
    I could also take a look at your code to see if something's wrong if you want
     
    • Like Like x 1
  3. The Gas Station

    The Gas Station
    Expand Collapse

    Joined:
    Jul 14, 2016
    Messages:
    272
    Thanks, I'll try looking at 'corridor '. I totally forgot it exists...
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice