Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let mobRoad = []
- const getRandomInt = (min, max) => {
- min = Math.ceil(min)
- max = Math.floor(max)
- return Math.floor(Math.random() * (max - min)) + min
- }
- const findNearestMob = () => {
- for (let i in g.npc) {
- if(g.npc[i].type == 2 && g.npc[i].lvl > 1 || g.npc[i].type == 3 && g.npc[i].lvl > 1)
- {
- let d = Math.sqrt((Math.pow(2, g.npc[i].x - hero.x)) + (Math.pow(2, g.npc[i].y - hero.y)))
- mobRoad.push(d)
- $.extend(g.npc[i], {
- roadLength: d
- })
- while (mobRoad.length > 1) {
- let a = getRandomInt(0, mobRoad.length)
- let b = getRandomInt(0, mobRoad.length)
- if(a < b) {
- mobRoad.splice(b, 1)
- }
- }
- if(g.npc[i].roadLength == Number(mobRoad)) {
- console.log(`NAZWA:${g.npc[i].nick} na kordach ${g.npc[i].x},${g.npc[i].y}`)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement