Is it possible the character doesn't walk by clicking outside the area of the way borders?

  • #1, z juansirlinkWednesday, 22. February 2017, 19:13 hodinky 8 years ago
    Hi there!

    Guys, I wonder if Is it possible the character doesn't walk by clicking outside the area of the way borders... Is there any way to do this?

    Thanks a lot!!

    Bažant

    46 Posts


  • #2, z sebastianWednesday, 22. February 2017, 19:58 hodinky 8 years ago
    With no waypoints in the waysystem the character has no points he/she could go to to reach the closest destination. But you also have problems then when your wayborder shape is not convex

    Kapitán

    2346 Posts

  • #3, z juansirlinkWednesday, 22. February 2017, 20:22 hodinky 8 years ago
    Jur... But I really need waypoints... Isn't there any another way?

    Bažant

    46 Posts

  • #4, z sebastianWednesday, 22. February 2017, 21:24 hodinky 8 years ago
    you could try to use lua script and check if when left clicked outside of the wayborder-polygon of the current scene. Then setting the characters speed of the current outfit to 0.
    And the other way around when clicking inside the waypoint polygon.

    Im not sure if this really works and also not how to script it out of my mind. But i think that all relevant data structure fields for this exist...

    Kapitán

    2346 Posts

  • #5, z juansirlinkWednesday, 22. February 2017, 21:50 hodinky 8 years ago
    Really thanks, sebastian, that's a good idea. I'm not sure how to script that but I will try to think how to do that...

    Thanks, guy!

    Bažant

    46 Posts

  • #6, z ke4Wednesday, 22. February 2017, 22:17 hodinky 8 years ago
    Maybe you could just stop the character instead of changing the speed.

    Stuff you would need for the solution Sebastian suggested.
    You should be able to get the current way borders with this line

    game.CurrentScene.SceneCurrentWaySystem.WaySystemBorder

    And you can get the current cursor position with the getCursorPos() function

    getCursorPos().x
    
    getCursorPos().y

    Then there's this built in function for checking point inside polygon

    isPointInsidePolygon()

    So the whole script might look something like this

    polygon = game.CurrentScene.SceneCurrentWaySystem.WaySystemBorder
    if not isPointInsidePolygon({ x = getCursorPos().x, y = getCursorPos().y}, polygon) then
    --your actions
    end

    I didn't test it, don't know if that works.

    Zabiják klíčů

    810 Posts