Jump to content


Photo

calculate max melee distance


    2 replies to this topic

    #1 sdahlka

    sdahlka

      Advanced Member

    • Members
    • PipPipPip
    • 324 posts

      Posted 30 June 2014 - 09:14 AM

      i know how to calculate the max distance for spells

       

          local range_mult = {
              [2] =  1.70,
              [3] = 1.490909,
              [4] = 1.44,
              [5] = 1.377778,
              [6] = 1.30,
              [7] = 1.20,
              [8] = 1.30,
              [9] = 1.377778,
              [10] = 1.45,
              [11] = 1.490909,
              [12] = 1.70,
              }
          if (spell.target.model_size + spell.range * range_mult[spell.range]) < spell.target.distance then
              if player.target.type == "MONSTER" then
               add_to_chat(123,"Monster out of range of spell")
              elseif player.target.type == "NPC" then
               add_to_chat(123,"NPC out of range of spell")
              else
               add_to_chat(123,"Player out of range of spell")        
              end
              cancel_spell()
              return
          end
       

      but how can we calculate the max melee distance for a given mob



      #2 Arcon

      Arcon

        Advanced Member

      • Windower Staff
      • 1189 posts
      • LocationMunich, Germany

      Posted 30 June 2014 - 01:19 PM

      I'm not sure, but I suspect it's the same formula with a constant offset. It would require some testing.



      #3 sdahlka

      sdahlka

        Advanced Member

      • Members
      • PipPipPip
      • 324 posts

        Posted 01 July 2014 - 08:22 AM

        i think this is it

        player.target.model_size + player.model_size * 1.65

         

        player.target.model_size = 2.7000000476837

        player.model_size = 0.40000000596046

         

        for a distance between 5.1 and 5.2 which is ware it is and i cant get mor accurate then that because i can move my char in smaller incriments






        1 user(s) are reading this topic

        0 members, 1 guests, 0 anonymous users