Jump to content

d0ppler

Members
  • Posts

    494
  • Joined

  • Last visited

Community Answers

  1. d0ppler's post in F-5 wants to climb even though I've trimmed it all the way down was marked as the answer   
    NVM, fixed it:

  2. d0ppler's post in Get clock bearing to unit B relative from unit A was marked as the answer   
    Ok, I finally figured it out. The o'clock can't be based on the bearing from player to target alone, it also needs the players bearing, because its' the delta of those two. It is probably possible to refactor this, but here is the code I got it to work with:
     
    Startup (after MIST.lua load) - do script:
    function getHeading(unitpos) local hdg = math.atan2(unitpos.x.z, unitpos.x.x) if hdg < 0 then hdg = hdg + 2 * math.pi end hdg = math.floor(hdg / math.pi * 180) return hdg end function getClockBearing(player_point, target_point, player_heading) local angle = math.deg(mist.utils.getHeadingPoints(player_point, target_point)) if player_heading > angle then angle = 360 + angle - player_heading else angle = math.abs(player_heading - angle ) end local oClock = math.floor(angle / 30 + 0.5) if oClock <= 0 then oClock = 12 end return oClock end player = Unit.getByName("player-1") target = Unit.getByName("lead-1")  
    Then the repetetive task, do script:
    local heading = getHeading(player:getPosition()) local clock_bearing = getClockBearing(player:getPoint(), target:getPoint(), heading)  
×
×
  • Create New...