SHARE
TWEET

Untitled

a guest Sep 23rd, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let mobRoad = []
  2.  
  3. const getRandomInt = (min, max) => {
  4.     min = Math.ceil(min)
  5.     max = Math.floor(max)
  6.     return Math.floor(Math.random() * (max - min)) + min
  7.   }
  8.  
  9. const findNearestMob = () => {
  10.     for (let i in g.npc) {
  11.         if(g.npc[i].type == 2 && g.npc[i].lvl > 1 || g.npc[i].type == 3 && g.npc[i].lvl > 1)
  12.         {
  13.             let d = Math.sqrt((Math.pow(2, g.npc[i].x - hero.x)) + (Math.pow(2, g.npc[i].y - hero.y)))
  14.  
  15.             mobRoad.push(d)
  16.  
  17.             $.extend(g.npc[i], {
  18.                 roadLength: d
  19.             })
  20.  
  21.             while (mobRoad.length > 1) {
  22.                 let a = getRandomInt(0, mobRoad.length)
  23.                 let b = getRandomInt(0, mobRoad.length)
  24.  
  25.                 if(a < b) {
  26.                     mobRoad.splice(b, 1)
  27.                 }
  28.             }
  29.  
  30.             if(g.npc[i].roadLength == Number(mobRoad)) {
  31.                 console.log(`NAZWA:${g.npc[i].nick} na kordach ${g.npc[i].x},${g.npc[i].y}`)
  32.             }
  33.         }
  34.     }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top