quinta-feira, 6 de setembro de 2012

[code] Monster = {name = 'Monster', health = 100, image = 'gfx/weiwen/circle.png', scalex = 1, scaley = 1, atk = 1, def = 1, spd = 5, x = 0, y = 0, ang = 0, imgang = 0, exp = 5, money = 50, type = 'monster', loot = {}} MONSTERS = {} local t = 0 CONFIG.MONSTERS = { { name = 'Bulbasaur', health = 100, image = 'gfx/weiwen/pokemon/9.bmp', scalex = 2, scaley = 2, r = 136, g = 224, b = 32, atk = 1.9, def = 2.1, spd = 6, atkspd = 8, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 5, runat = 10, exp = 15, money = 100, loot = {{chance = 5000, id = 102}, {chance = 50, id = 221}}, spawn1 = {0, 100}, spawn2 = {150, 150}, spc = {1500, function(self) radiusmsg("Bulbasaur casts heal!", self.x, self.y) parse("effect \"colorsmoke\" " .. self.x .. " " .. self.y .. " 5 5 255 255 255") end}, }, { name = 'Charmander', health = 100, image = 'gfx/weiwen/pokemon/200.bmp', scalex = 2, scaley = 2, atk = 2.2, def = 1.8, spd = 6, atkspd = 8, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 5, runat = 10, exp = 15, money = 100, loot = {{chance = 5000, id = 100}, {chance = 50, id = 222}}, spawn1 = {0, 100}, spawn2 = {150, 150}, spc = {1000, function(self, target) radiusmsg("Charmander uses ember!", self.x, self.y) parse('explosion ' .. self.x .. ' ' .. self.y .. ' 96 40') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 100 64 255 128 0') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 100 96 255 255 0') end}, }, { name = 'Squirtle', health = 100, image = 'gfx/weiwen/pokemon/azul.bmp', scalex = 2, scaley = 2, atk = 1.7, def = 2.3, spd = 6, atkspd = 8, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 5, runat = 10, exp = 15, money = 100, loot = {{chance = 5000, id = 101}, {chance = 50, id = 223}}, spawn1 = {0, 100}, spawn2 = {150, 150}, spc = {1000, function(self) radiusmsg("Squirtle uses watergun!", self.x, self.y) parse('explosion ' .. self.x .. ' ' .. self.y .. ' 96 40') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 100 96 255 255 255') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 75 96 128 128 255') end}, }, { name = 'Caterpie', health = 100, image = 'gfx/weiwen/pokemon/16.bmp', scalex = 1.5, scaley = 1.5, r = 104, g = 152, b = 40, atk = 1.1, def = 1.2, spd = 7, atkspd = 10, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 100, runat = 20, spawn1 = {0, 0}, spawn2 = {150, 150}, exp = 10, money = 30, loot = {{chance = 8000, id = 1}}, }, { name = 'Weedle', health = 100, image = 'gfx/weiwen/pokemon/17.bmp', scalex = 1.5, scaley = 1.5, r = 104, g = 152, b = 40, atk = 1.2, def = 1.1, spd = 7, atkspd = 10, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 100, runat = 20, spawn1 = {0, 0}, spawn2 = {150, 150}, exp = 10, money = 30, loot = {{chance = 8000, id = 1}}, }, { name = 'Pidgey', health = 100, image = 'gfx/weiwen/pokemon/18.bmp', scalex = 2, scaley = 2, atk = 1.2, def = 1.2, spd = 10, atkspd = 7, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 50, runat = 20, spawn1 = {0, 0}, spawn2 = {150, 150}, exp = 20, money = 60, loot = {}, spc = {500, function(self) radiusmsg("Pidgey uses sand attack!", self.x, self.y) parse('flashposition ' .. self.x .. ' ' .. self.y .. ' 100') end}, }, { name = 'esquelet', health = 100, image = 'gfx/weiwen/pokemon/7.bmp', scalex = 1.5, scaley = 1.5, atk = 1.0, def = 1.0, spd = 9, atkspd = 5, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 100, runat = 20, spawn1 = {0, 0}, spawn2 = {150, 150}, exp = 10, money = 50, loot = {{chance = 8000, id = 4}}, }, { name = 'Bronze Vortex', health = 165, image = 'gfx/weiwen/pokemon/tierra.bmp', scalex = 2, scaley = 2, atk = 2.0, def = 7.0, spd = 10, atkspd = 9, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 100, runat = 20, spawn1 = {0, 0}, spawn2 = {180, 77}, exp = 410, money = 1000, loot = {{chance = 8000, id = 320}, {chance = 8000, id = 321}}, }, { name = 'Ice Monster', health = 200, image = 'gfx/weiwen/pokemon/13.bmp', scalex = 2, scaley = 2, atk = 4.3, def = 11.2, spd = 10, atkspd = 11, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 100, runat = 20, spawn1 = {0, 0}, spawn2 = {177, 143}, exp = 2020, money = 2200, loot = {{chance = 8000, id = 340}, {chance = 8000, id = 341}}, }, { name = 'Fire Dragon', health = 190, image = 'gfx/weiwen/pokemon/firedragon.bmp', scalex = 2, scaley = 2, atk = 6.3, def = 19.2, spd = 20, atkspd = 11, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 100, runat = 20, spawn1 = {0, 0}, spawn2 = {177, 143}, exp = 4020, money = 5000, loot = {{chance = 8000, id = 356}, {chance = 8000, id = 350}}, }, { name = 'Dragon', health = 200, image = 'gfx/weiwen/pokemon/3.bmp', scalex = 2, scaley = 2, atk = 3.0, def = 9.0, spd = 12, atkspd = 9, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 100, runat = 20, spawn1 = {0, 0}, spawn2 = {171, 119}, exp = 1020, money = 1200, loot = {{chance = 8000, id = 327}, {chance = 8000, id = 328}}, }, { name = 'Aqua', health = 200, image = 'gfx/weiwen/pokemon/3.bmp', scalex = 2, scaley = 2, atk = 3.0, def = 9.0, spd = 12, atkspd = 9, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 100, runat = 20, spawn1 = {0, 0}, spawn2 = {171, 119}, exp = 1020, money = 1200, loot = {{chance = 8000, id = 327}, {chance = 8000, id = 328}}, }, { name = 'Spearow', health = 100, image = 'gfx/weiwen/pokemon/6.bmp', scalex = 2, scaley = 2, atk = 1.4, def = 1.0, spd = 10, atkspd = 7, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 50, runat = 20, spawn1 = {0, 0}, spawn2 = {150, 150}, exp = 20, money =60, loot = {}, spc = {2500, function(self, id, dist) if not self.agility then radiusmsg("Spearow uses agility!", self.x, self.y) parse("effect \"colorsmoke\" " .. self.x .. " " .. self.y .. " 5 5 155 255 155") radiussound("weapons/g_flash.wav", self.x, self.y) self.spd = 10 self.agility = true imagecolor(self.image, 155, 255, 155) timer(5000, "CONFIG.MONSTERSKILLS.endAgility", self.id) elseif dist <= 32 then self:hit(id, 10) end end}, }, { name = 'Ekans', health = 100, image = 'gfx/weiwen/pokemon/10.bmp', scalex = 2, scaley = 2, atk = 1.8, def = 1.2, spd = 7, atkspd = 8, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 20, runat = 10, spawn1 = {0, 0}, spawn2 = {150, 150}, exp = 10, money = 80, loot = {}, spc = {500, function(self, id, dist) if dist <= 96 then radiusmsg("Ekans uses poison sting!", self.x, self.y) self:hit(id, 20) end end}, }, { name = 'Bear', health = 100, image = 'gfx/weiwen/pokemon/15.bmp', scalex = 2, scaley = 2, atk = 2.1, def = 2.1, spd = 7, atkspd = 7, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 5, runat = 10, spawn1 = {0, 100}, spawn2 = {150, 150}, exp = 25, money = 120, loot = {{chance = 5000, id = 103}, {chance = 50, id = 220}}, spc = {500, function(self) radiusmsg("Pikachu uses thundershock!", self.x, self.y) parse('explosion ' .. self.x .. ' ' .. self.y .. ' 96 40') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 100 96 255 255 0') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 75 64 255 255 255') end}, }, { name = 'Sandshrew', health = 100, image = 'gfx/weiwen/pokemon/12.bmp', scalex = 2, scaley = 2, atk = 1.7, def = 2.1, spd = 7, atkspd = 7, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 10, runat = 10, spawn1 = {165, 30}, spawn2 = {184, 48}, exp = 18, money = 120, loot = {}, spc = {1000, function(self) radiusmsg("Sandshrew uses sand attack!", self.x, self.y) parse('flashposition ' .. self.x .. ' ' .. self.y .. ' 100') end}, }, { name = 'NidoranF', health = 100, image = 'gfx/weiwen/pokemon/100.bmp', scalex = 2, scaley = 2, atk = 1.8, def = 1.2, spd = 7, atkspd = 8, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 20, runat = 10, spawn1 = {0, 0}, spawn2 = {150, 150}, exp = 10, money = 80, loot = {}, spc = {750, function(self, id, dist) if dist <= 96 then radiusmsg("NidoranF uses poison sting!", self.x, self.y) self:hit(id, 20) end end}, }, { name = 'mumia', health = 100, image = 'gfx/weiwen/pokemon/10006.bmp', scalex = 2, scaley = 2, atk = 1.8, def = 1.2, spd = 7, atkspd = 8, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 20, runat = 10, spawn1 = {0, 0}, spawn2 = {150, 150}, exp = 10, money = 80, loot = {}, spc = {750, function(self, id, dist) if dist <= 96 then radiusmsg("NidoranM uses horn attack!", self.x, self.y) self:hit(id, 20) end end}, }, { name = 'Vulpix', health = 100, image = 'gfx/weiwen/pokemon/10005.bmp', scalex = 2, scaley = 2, atk = 2.2, def = 1.8, spd = 7, atkspd = 8, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 10, runat = 0, spawn1 = {0, 100}, spawn2 = {150, 150}, exp = 10, money = 100, loot = {{chance = 5000, id = 104}}, spc = {500, function(self, id, dist) radiusmsg("Vulpix uses flamethrower!", self.x, self.y) local x1, y1 = self.x, self.y local rot = math.atan2(player(id, 'y')-y1, player(id, 'x')-x1) + math.pi/2 local x2, y2 = math.sin(rot), -math.cos(rot) local fire = image("gfx/sprites/spot.bmp", 0, 0, 1) imagepos(fire, x1+x2*64, y1+y2*64, math.deg(rot)+180) imagescale(fire, 1.5, 2) imagecolor(fire, 255, 64, 0) imageblend(fire, 1) timer(500, "freeimage", fire) parse('explosion ' .. x1+x2*100 .. ' ' .. y1+y2*100 .. ' 48 40') parse('explosion ' .. x1+x2*50 .. ' ' .. y1+y2*50 .. ' 32 40') end}, }, { name = 'Dog', health = 100000, image = 'gfx/weiwen/pokemon/14.bmp', scalex = 2, scaley = 2, atk = 0, def = 999999, spd = 1, atkspd = 6, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 10, runat = 0, spawn1 = {0, 0}, spawn2 = {150, 150}, exp = 25, money = 100, loot = {{chance = 1000, id = 230}}, }, { name = 'Exp', health = 500, image = 'gfx/weiwen/pokemon/exp.png', scalex = 2, scaley = 2, atk = 0.0, def = 5.2, spd = 0.1, atkspd = 1, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 10, runat = 0, spawn1 = {0, 0}, spawn2 = {150, 150}, exp = 5000000, money = 100, loot = {}, }, { name = 'Mankey', health = 100, image = 'gfx/weiwen/pokemon/2000.bmp', scalex = 2, scaley = 2, atk = 2.5, def = 1.8, spd = 10, atkspd = 6, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 10, runat = 0, range = 48, spawn1 = {0, 100}, spawn2 = {150, 150}, exp = 25, money = 120, loot = {{chance = 1000, id = 300},{chance = 1000, id = 301},{chance = 1000, id = 302},{chance = 1000, id = 303},{chance = 1000, id = 304},{chance = 1000, id = 305},{chance = 1000, id = 306}}, spc = {1000, function(self, id, dist) if not self.rage then radiusmsg("Mankey uses rage!", self.x, self.y) parse("effect \"colorsmoke\" " .. self.x .. " " .. self.y .. " 5 5 255 155 155") radiussound("weapons/g_flash.wav", self.x, self.y) self.def = 3.3 self.rage = true imagecolor(self.image, 255, 155, 155) timer(5000, "CONFIG.MONSTERSKILLS.endRage", self.id) elseif dist <= 96 then radiusmsg("Mankey uses karate chop!", self.x, self.y) self:hit(id, 20) end end}, }, { name = 'Abra', health = 100, image = 'gfx/weiwen/pokemon/250.bmp', scalex = 2, scaley = 2, atk = 0.6, def = 1.0, spd = 5, atkspd = 10, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 10, runat = 100, spawn1 = {0, 0}, spawn2 = {150, 150}, exp = 8, money = 50, loot = {{chance = 5000, id = 105}}, spc = {2500, function(self) radiusmsg("Abra uses teleport!", self.x, self.y) parse("effect \"colorsmoke\" " .. self.x .. " " .. self.y .. " 5 5 255 255 255") local dir = math.random(math.pi*2) if self:move(dir, 40) or self:move(dir, -40) then parse("effect \"colorsmoke\" " .. self.x .. " " .. self.y .. " 5 5 255 255 255") end end}, }, { name = 'Gastly', health = 100, image = 'gfx/weiwen/pokemon/8.bmp', scalex = 2, scaley = 2, r = 64, g = 0, b = 64, atk = 1.2, def = 1.5, spd = 8, atkspd = 10, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 10, runat = 50, spawn1 = {0, 100}, spawn2 = {150, 150}, exp = 8, money = 100, loot = {}, spc = {1000, function(self, id, dist) if dist <= 64 and not PLAYERS[id].tmp.paralyse then radiusmsg("Gastly uses lick!", self.x, self.y) PLAYERS[id].tmp.paralyse = true msg2(id, "You are paralysed.") parse("effect \"colorsmoke\" " .. player(id, 'x') .. " " .. player(id, 'y') .. " 5 5 64 0 64") timer(3000, "rem.paralyse", id) elseif dist <= 32 then self:hit(id, 10) end end}, }, { name = 'Onix', health = 125, image = 'gfx/weiwen/pokemon/1.bmp', scalex = 3, scaley = 3, r = 144, g = 144, b = 144, atk = 1.8, def = 5.0, spd = 3, atkspd = 10, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 5, runat = 0, range = 64, spawn1 = {165, 30}, spawn2 = {184, 48}, exp = 100, money = 300, loot = {{chance = 1000, id = 310},{chance = 1000, id = 311},{chance = 1000, id = 312},{chance = 1000, id = 313},{chance = 1000, id = 314},{chance = 1000, id = 315},{chance = 1000, id = 316}}, spc = {1000, function(self) if not self.harden then radiusmsg("Onix uses harden!", self.x, self.y) parse("effect \"colorsmoke\" " .. self.x .. " " .. self.y .. " 5 5 192 192 192") radiussound("weapons/g_flash.wav", self.x, self.y) self.def = 7.5 self.harden = true imagecolor(self.image, 155, 155, 255) timer(5000, "CONFIG.MONSTERSKILLS.endHarden", self.id) end end}, }, { name = 'Voltorb', health = 100, image = 'gfx/weiwen/pokemon/5.bmp', scalex = 2, scaley = 2, r = 144, g = 144, b = 144, atk = 2.3, def = 2.3, spd = 5, atkspd = 8, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 10, runat = 20, range = 48, spawn1 = {0, 100}, spawn2 = {150, 150}, exp = 30, money = 130, loot = {{chance = 5000, id = 103}}, spc = {1000, function(self) if self.health < 20 then radiusmsg("Voltorb uses selfdestruct!", self.x, self.y) parse('explosion ' .. self.x .. ' ' .. self.y .. ' 128 80') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 100 128 255 128 0') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 100 128 255 255 0') self:destroy() else radiusmsg("Voltorb uses thundershock!", self.x, self.y) parse('explosion ' .. self.x .. ' ' .. self.y .. ' 96 40') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 100 96 255 255 0') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 75 64 255 255 255') end end}, }, { name = 'Koffing', health = 100, image = 'gfx/weiwen/pokemon/251.bmp', scalex = 2, scaley = 2, r = 128, g = 128, b = 0, atk = 2.0, def = 1.7, spd = 4, atkspd = 10, x = 0, y = 0, ang = 0, imgang = 0, spawnchance = 10, runat = 20, range = 48, spawn1 = {0, 100}, spawn2 = {150, 150}, exp = 30, money = 150, loot = {{chance = 5000, id = 106}}, spc = {1000, function(self) if self.health < 20 then radiusmsg("Koffing uses explosion!", self.x, self.y) parse('explosion ' .. self.x .. ' ' .. self.y .. ' 128 40') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 100 128 255 128 0') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 100 128 255 255 0') self:destroy() else radiusmsg("Koffing uses poison fog!", self.x, self.y) parse('explosion ' .. self.x .. ' ' .. self.y .. ' 96 40') parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 100 96 128 128 0') end end}, }, } CONFIG.MONSTERSKILLS = { endAgility = function(id) self = MONSTERS[tonumber(id)] self.spd = self._spd self._spd = nil imagecolor(self.image, 255, 255, 255) self.agility = nil end, endRage = function(id) self = MONSTERS[tonumber(id)] self.atk = self._atk self._atk = nil imagecolor(self.image, 255, 255, 255) self.rage = nil end, endHarden = function(id) self = MONSTERS[tonumber(id)] self.def = self._def self._def = nil imagecolor(self.image, 255, 255, 255) self.harden = nil end, } addhook("attack", "MONSTERattack") function MONSTERattack(id) if gettile(PLAYERS[id].x, PLAYERS[id].y).SAFE or gettile(PLAYERS[id].x, PLAYERS[id].y).NOMONSTERS then return end if inarray({400, 401, 402, 403, 404}, PLAYERS[id].Equipment[7]) then message(id, "You may not attack on a horse.") return end local weapon, closest = player(id, 'weapontype') for _, m in ipairs(MONSTERS) do local x, y = player(id, 'x'), player(id, 'y') local dist = math.sqrt((m.x-x)^2+(m.y-y)^2) if dist <= (closest and closest[2] or (CONFIG.WEAPONRANGE[weapon] or CONFIG.WEAPONRANGE[50])) then local rot = player(id, 'rot') if math.abs(math.rad(rot) - math.atan2(y-m.y, x-m.x) + math.pi/2)%(2*math.pi) <= (CONFIG.WEAPONWIDTH[weapon] or CONFIG.WEAPONRANGE[50]) then closest = {m, dist} end end end if closest then closest[1]:damage(id, math.ceil(20*((PLAYERS[id].Level+50)*PLAYERS[id].tmp.atk/closest[1].def)/math.random(60, 140)), weapon) end end addhook("ms100", "MONSTERms100") function MONSTERms100() t = t + 1 if t % 100 == 0 then while #MONSTERS < CONFIG.MAXMONSTERS do local rand, spawnNo, mapName while true do rand = math.random(#CONFIG.MONSTERS) mapName = CONFIG.MONSTERS[rand].spawn[map'name'] and map'name' or CONFIG.DEFAULTMAP spawnNo = math.random(#CONFIG.MONSTERS[rand].spawn[mapName]) if math.random(0, 100) < CONFIG.MONSTERS[rand].spawnchance[mapName][spawnNo] then break end end local m = deepcopy(CONFIG.MONSTERS[rand]) local x, y, tilex, tiley local spawn = m.spawn[mapName][spawnNo] repeat tilex, tiley = math.random(spawn[1][1], spawn[2][1]), math.random(spawn[1][2], spawn[2][2]) until not gettile(tilex, tiley).SAFE and not gettile(tilex, tiley).NOMONSTERS and tile(tilex, tiley, "walkable") and tile(tilex, tiley, "frame") ~= 34 m.x, m.y = math.floor(tilex*32+16), math.floor(tiley*32+16) Monster:new(m) end end for _, m in ipairs(MONSTERS) do if t % m.atkspd == 0 then m.target = nil local closest for _, p in ipairs(table.shuffle(player(0, 'table'))) do if player(p, 'health') > 0 and not gettile(PLAYERS[p].x, PLAYERS[p].y).SAFE and not gettile(PLAYERS[p].x, PLAYERS[p].y).NOMONSTERS then local dist = math.sqrt((player(p, 'x')-m.x)^2 + (player(p, 'y')-m.y)^2) if dist < 400 then if not closest or dist < closest[2] then closest = {p, dist} end end end end if closest then local dist = closest[2] if dist < 400 then m.target = closest[1] if m.spc and math.random(10000) <= m.spc[1] then m.spc[2](m, m.target, dist) elseif dist <= (m.range or 32) then m:hit(m.target, 10) end end end end m.imgang = math.sin(t/2.5*math.pi) * 15 if m.target and player(m.target, 'exists') and player(m.target, 'health') > 0 and not gettile(PLAYERS[m.target].x, PLAYERS[m.target].y).SAFE and not gettile(PLAYERS[m.target].x, PLAYERS[m.target].y).NOMONSTERS then xdist, ydist = player(m.target, 'x') - m.x, player(m.target, 'y') - m.y local dist = math.sqrt(xdist^2 + ydist^2) if dist < 400 then m.ang = math.atan2(ydist, xdist)-math.pi/2+math.random(-1, 1)/2 else m.target = nil end end if not m.target then m:rot(math.random(-1, 1)/2) end if not m:move(m:rot(), m.health > m.runat and 1 or -1) then repeat until m:move(math.rad(math.random(360)), 1) end end end function Monster:new(m) if not (m.x or m.y) then return false end m.image = image(m.image, m.x, m.y, 0) imagescale(m.image, m.scalex, m.scaley) setmetatable(m, self) self.__index = self local n = #MONSTERS+1 MONSTERS[#MONSTERS+1] = m m.id = n return m end function Monster:pos(x, y) if not x and not y then return self.x, self.y else self.x, self.y = x or self.x, y or self.y imagepos(self.image, self.x, self.y, self.imgang) end return true end function Monster:move(dir, amt) local x, y = -math.sin(dir)*amt*self.spd, math.cos(dir)*amt*self.spd local x, y = self.x+x, self.y+y local tilex, tiley = math.floor(x/32), math.floor(y/32) if tile(tilex, tiley, 'walkable') and tile(tilex, tiley, 'frame') ~= 34 and not gettile(tilex, tiley).SAFE and not gettile(tilex, tiley).NOMONSTERS then self:pos(x, y) return true else self:rot(math.random(-1, 1)*math.pi/2) return false end end function Monster:damage(id, dmg, wpntype) if not PLAYERS[id].Tutorial.damagem then message(id, "You have attacked a monster! Good job! Keep on attacking it until it dies.", "255128000") PLAYERS[id].Tutorial.damagem = true end local wpnName if weapon == 251 then wpnName = 'rune' elseif weapon == 46 then wpnName = 'firewave' dmg = dmg/5 else wpnName = PLAYERS[id].Equipment[3] and ITEMS[PLAYERS[id].Equipment[3]].name or 'dagger' end self.health = self.health - dmg --print(player(id, 'name') .. ' deals ' .. dmg .. ' damage to ' .. self.name .. ' usng a ' .. wpnName .. '.') if self.health <= 0 then if not PLAYERS[id].Tutorial.killm then message(id, "Congratulation! You have killed your first monster. You can proceed to pick up the loot by using the drop weapon button (default G)", "255128000") PLAYERS[id].Tutorial.killm = true end addexp(id, math.floor(self.exp*CONFIG.EXPRATE)) self:die() else parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' 0 ' .. self.scaley .. ' ' .. (self.r and (self.r .. ' ' .. self.g .. ' ' .. self.b) or '192 0 0')) end radiussound("weapons/machete_hit.wav", self.x, self.y) return true end function Monster:hit(id, dmg) if not PLAYERS[id].Tutorial.hitm then message(id, "A monster is attacking you! You can fight back by swinging your weapon at it.", "255128000") PLAYERS[id].Tutorial.hitm = true end if player(id, 'weapontype') == 41 and (math.abs(math.rad(player(id, 'rot')) - math.atan2(player(id, 'y')-self.y, player(id, 'x')-self.x) + math.pi/2)%(2*math.pi) <= math.pi*2/3) then EXPhit(id, self, -1, dmg/4) radiussound("weapons/ricmetal" .. math.random(1,2) .. ".wav", self.x, self.y) else EXPhit(id, self, -1, dmg) radiussound("weapons/knife_hit.wav", self.x, self.y) end return true end function Monster:die(id) local size = self.scalex+self.scaley parse('effect "colorsmoke" ' .. self.x .. ' ' .. self.y .. ' ' .. size .. ' 64 ' .. (self.r and (self.r .. ' ' .. self.g .. ' ' .. self.b) or '192 0 0')) local tilex, tiley = math.floor(self.x/32), math.floor(self.y/32) spawnitem(1337, tilex, tiley, math.floor(self.money*math.random(50, 150)/100)*CONFIG.MONEYRATE) for _, loot in ipairs(self.loot) do local chance = math.random(10000) if chance <= loot.chance then spawnitem(loot.id, tilex, tiley) end end radiussound("weapons/c4_explode.wav", self.x, self.y) self:destroy() end function Monster:destroy() freeimage(self.image) local found table.remove(MONSTERS, self.id) for i, m in ipairs(MONSTERS) do m.id = i end return true end function Monster:rot(rot) if not rot then return self.ang else self.ang = (self.ang+rot)%(math.pi*2) end return true end~ [code]

Nenhum comentário:

Postar um comentário