Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local term = require "term"
- local event = require "event"
- local image = require "image"
- local thread = require "thread"
- local fs = require "filesystem"
- local unicode = require "unicode"
- local computer = require "computer"
- local keyboard = require "keyboard"
- local term = require "term"
- local event = require "event"
- local image = require "image"
- local thread = require "thread"
- local fs = require "filesystem"
- local unicode = require "unicode"
- local computer = require "computer"
- local keyboard = require "keyboard"
- local component = require "component"
- local buffer = require "doubleBuffering"
- local gpu = component.gpu
- local mxw, mxh = gpu.maxResolution()
- local TextVersion = "Версия 1.2(b) v14"
- local pScreenText = "(C) 2016 Wirthe16"
- local cScreenStat = "Загрузка..."
- local preduprejdenie = ""
- local vseNormalno = true
- local ESC = "pause"
- local LANGUAGE = "russian"
- gpu.setResolution(mxw,mxh)
- local startBckgColour = 0x222222
- local limg = image.load("/games/testgame/image/slg.pic")
- limg = image.brightness(limg,-10)
- for f = 1, 6 do
- buffer.square(1,1,160,50,startBckgColour,0x000000," ")
- buffer.text(2,2,0xA7A7A7,cScreenStat)
- limg = image.brightness(limg,2*f)
- buffer.image(80-limg.width/2,25-limg.height/2,limg)
- buffer.draw()
- os.sleep()
- end
- limg = nil
- if mxw < 160 or mxh < 50 then
- vseNormalno = false
- preduprejdenie = 'Предупреждение: экран не поддерживает текущее разрешение'
- end
- local dopInfo = {
- "Разрешение экрана только 160х50",
- "DoubleBuffering lib by IgorTimofeev",
- "Image lib by IgorTimofeev",
- "Thread lib by Zer0Galaxy",
- }
- local function dmLoading()
- buffer.square(1,1,160,50,startBckgColour,0x000000," ")
- buffer.text(2,2,0xA7A7A7,cScreenStat)
- buffer.text(158-unicode.len(TextVersion),48,0xA1A1A1,TextVersion)
- buffer.text(158-unicode.len(pScreenText),49,0xB1B1B1,pScreenText)
- for f = 1, #dopInfo do
- buffer.text(2,48-#dopInfo+f,0xA7A7A7,dopInfo[f])
- end
- if not vseNormalno then
- buffer.text(2,math.floor(mxh/2),0xD80000,preduprejdenie)
- buffer.text(2,math.floor(mxh/2)+1,0xD80000,"Продолжить загрузку? Y/N")
- buffer.draw()
- while true do
- local ev = table.pack(event.pull())
- if ev[1] == "key_up" then
- if ev[4] == 21 then
- break
- elseif ev[4] == 49 or ev[4] == 28 then
- error("interrupted")
- end
- end
- end
- end
- buffer.draw()
- end
- local gamefps, cfps = 0, 0
- thread.init()
- local function readFromFile(path)
- local file = io.open(path, 'r')
- local array = {}
- for line in file:lines() do
- if line:sub(-1) == "\r" then
- line = line:sub(1, -2)
- end
- table.insert(array, line)
- end
- file:close()
- return array
- end
- local function loadLanguage(wPath)
- if not fs.exists(wPath) then error("File not exists") end
- local ptable = {}
- local key, value, dmt1
- local len = 0
- local f = io.open(wPath, "r")
- for line in f:lines() do
- if not f then return nil end
- len = len + 1
- dmt1 = string.find(line, "@")
- value1 = string.sub(line, 1, dmt1 - 2)
- value2 = string.sub(line, dmt1 + 2, #line-1)
- table.insert(ptable,{value1, value2})
- end
- f:close()
- if len == 0 then return nil end
- return ptable
- end
- local function convLang(ptable,value)
- local cLang = 2
- local newTable = {}
- if value == "russian" then cLang = 1 end
- for f = 1, #ptable do
- newTable[ptable[f][1]] = ptable[f][cLang]
- end
- return newTable
- end
- local rawlang = loadLanguage("/games/testgame/translate.lang")
- local nlang = convLang(rawlang, LANGUAGE)
- local function lang(string)
- if type(nlang[string]) == "string" then return nlang[string] end
- return string
- end
- local aItemIconsSpr
- aItemIconsSpr = readFromFile("/games/testgame/itempic.data")
- local dialogs = {
- [1]={["text"] = "",
- {["text"] = lang("До встречи"),["action"] = "close", ["do"] = nil},
- },
- [2]={["text"] = "",
- {["text"] = lang("До встречи"),["action"] = "close", ["do"] = nil},
- },
- [3]={["text"] = "",
- {["text"] = lang("Товары и услуги"),["action"] = "trade", ["do"] = 1},
- {["text"] = lang("До встречи"),["action"] = "close", ["do"] = nil},
- },
- [4]={["text"] = "",
- {["text"] = lang("Покинуть это место"), ["action"] = "dialog", ["do"] = {
- ["text"] = "",
- {["text"] = lang("Да, я хочу выйти"),["action"] = "setWorld", ["do"] = 2, ["reqlvl"] = 1},
- {["text"] = lang("До встречи"),["action"] = "close", ["do"] = nil},
- }},
- {["text"] = lang("До встречи"),["action"] = "close", ["do"] = nil},
- },
- [5]={["text"] = "",
- {["text"] = lang("Пещера (тест)"), ["action"] = "dialog", ["do"] = {
- ["text"] = "",
- {["text"] = lang("В пещеру"),["action"] = "setWorld", ["do"] = 3, ["reqlvl"] = 5},
- {["text"] = lang("До встречи"),["action"] = "close", ["do"] = nil},
- }},
- {["text"] = lang("Вернуться"), ["action"] = "dialog", ["do"] = {
- ["text"] = "",
- {["text"] = lang("Мне нужно поскорее вернуться"),["action"] = "setWorld", ["do"] = 1, ["reqlvl"] = 1},
- {["text"] = lang("До встречи"),["action"] = "close", ["do"] = nil},
- }},
- {["text"] = lang("До встречи"),["action"] = "close", ["do"] = nil},
- },
- [6]={["text"] = "",
- {["text"] = lang("Вернуться"), ["action"] = "dialog", ["do"] = {
- ["text"] = "Вернуться в локацию 'Зеленые луга'?",
- {["text"] = lang("Да"),["action"] = "setWorld", ["do"] = 2, ["reqlvl"] = 1},
- {["text"] = lang("Нет"),["action"] = "close", ["do"] = nil},
- }},
- {["text"] = lang("Не сейчас"),["action"] = "close", ["do"] = nil},
- },
- [7]={["text"] = "",
- {["text"] = lang("Войти в поселение"), ["action"] = "dialog", ["do"] = {
- ["text"] = "Войти в поселение?",
- {["text"] = lang("Да"),["action"] = "setWorld", ["do"] = 4, ["reqlvl"] = 1},
- {["text"] = lang("Нет"),["action"] = "close", ["do"] = nil},
- }},
- {["text"] = lang("Не сейчас"),["action"] = "close", ["do"] = nil},
- },
- [8]={["text"] = "Я еще не видел ничего подобного!",
- {["text"] = lang("До встречи"),["action"] = "close", ["do"] = nil},
- },
- }
- local mSprites = {}
- local vAttackDistance
- local standartItemLoot1_4 = {
- {17,2.7},{18,2.7},{19,2.7},{20,2.7},{3,1.8},{4,1.8},{5,1.8},{6,1.8},{8,1.7},{28,1.2},{29,1.2},{30,1.1},{9,7.4},{10,7.4}
- }
- local standartItemLoot5_9 = {
- {17,2.7},{18,2.7},{19,2.7},{20,2.7},{31,1.8},{32,1.8},{33,1.8},{34,1.8},{35,1.7},{28,1.2},{29,1.2},{30,1.1},{11,7.4},{12,7.4}
- }
- local gameUnitData = {
- {["id"] = 1, ["name"] = "Игрок", ["wtype"] = "Управляемый персонаж", ["level"] = 6, ["atds"] = 10,
- ["loot"] = {["exp"] = 0, ["coins"] = 0, ["items"] = {}}, ["vresp"] = 0, ["rtype"] = "p", ["image"] = "player"},
- {["id"] = 2, ["name"] = "Зомби", ["wtype"] = "Ходячий труп",["level"] = 1, ["atds"] = 10, ["agr"] = true,
- ["loot"] = {["exp"] = 2, ["coins"] = 3, ["items"] = standartItemLoot1_4},
- ["vresp"] = 45, ["rtype"] = "e", ["image"] = "zombie1"},
- {["id"] = 3, ["name"] = "Привидение", ["wtype"] = "Призрак",["level"] = 2, ["atds"] = 10,
- ["loot"] = {["exp"] = 3, ["coins"] = 5, ["items"] = standartItemLoot1_4},
- ["vresp"] = 45, ["rtype"] = "e", ["image"] = "ghost"},
- {["id"] = 4, ["name"] = "Зеленый слизень", ["wtype"] = "Слизень", ["level"] = 2, ["atds"] = 10,
- ["loot"] = {["exp"] = 3, ["coins"] = 4, ["items"] = standartItemLoot1_4},
- ["vresp"] = 45, ["rtype"] = "e", ["image"] = "greenslug"},
- {["id"] = 5, ["name"] = "Василий", ["wtype"] = "", ["level"] = 0, ["quests"] = {1,2,3},
- ["vresp"] = 0, ["image"] = "vil1", ["rtype"] = "f",["dialog"] = 1},
- {["id"] = 6, ["name"] = "Зеленый куст", ["wtype"] = "Дерево", ["level"] = 3, ["atds"] = 10,
- ["loot"] = {["exp"] = 4, ["coins"] = 6, ["items"] = {
- {30,1.1},{9,7.4},{10,7.4}
- }}, ["vresp"] = 45, ["rtype"] = "e", ["image"] = "bush"},
- {["id"] = 7, ["name"] = "Дух места", ["wtype"] = "Призрак", ["level"] = 3, ["atds"] = 10,
- ["loot"] = {["exp"] = 4, ["coins"] = 6, ["items"] = {
- {29,1.2},{30,1.1},{9,7.4},{10,7.4}
- }}, ["vresp"] = 45, ["rtype"] = "e", ["image"] = "spiritofplace"},
- {["id"] = 8, ["name"] = "Каменная черепаха", ["wtype"] = "Черепаха", ["level"] = 4, ["atds"] = 9,
- ["loot"] = {["exp"] = 5, ["coins"] = 7, ["items"] = standartItemLoot1_4},
- ["vresp"] = 45, ["rtype"] = "e", ["image"] = "stoneturtle"},
- {["id"] = 9, ["name"] = "Гниющее дерево", ["wtype"] = "Дерево", ["level"] = 4, ["atds"] = 10,
- ["loot"] = {["exp"] = 5, ["coins"] = 7, ["items"] = standartItemLoot1_4},
- ["vresp"] = 45, ["rtype"] = "e", ["image"] = "swamptree"},
- {["id"] = 10, ["name"] = "Анатолий", ["wtype"] = "Торговец снадобьями", ["level"] = 0, ["quests"] = {4},
- ["vresp"] = 0, ["image"] = "vil2", ["rtype"] = "f",["dialog"] = 2},
- {["id"] = 11, ["name"] = "Кинехет", ["wtype"] = "Кузнец", ["level"] = 0, ["quests"] = nil,
- ["vresp"] = 0, ["image"] = "vil3", ["rtype"] = "f",["dialog"] = 3},
- {["id"] = 12, ["name"] = "Стражник", ["wtype"] = "", ["level"] = 0, ["quests"] = nil,
- ["vresp"] = 0, ["image"] = "guardian1", ["rtype"] = "f",["dialog"] = 4},
- {["id"] = 13, ["name"] = "Стражник", ["wtype"] = "", ["level"] = 0, ["quests"] = nil,
- ["vresp"] = 0, ["image"] = "guardian1", ["rtype"] = "f",["dialog"] = 5},
- {["id"] = 14, ["name"] = "Болотный вурдалак", ["wtype"] = "Ходячий труп", ["level"] = 5, ["atds"] = 10, ["agr"] = true,
- ["loot"] = {["exp"] = 6, ["coins"] = 9, ["items"] = standartItemLoot5_9}, ["vresp"] = 55, ["rtype"] = "e", ["image"] = "venomous_ghoul"},
- {["id"] = 15, ["name"] = "Скелет", ["wtype"] = "Ходячий труп", ["level"] = 5, ["atds"] = 10, ["agr"] = true,
- ["loot"] = {["exp"] = 6, ["coins"] = 9, ["items"] = standartItemLoot5_9}, ["vresp"] = 55, ["rtype"] = "e", ["image"] = "skelet1"},
- {["id"] = 16, ["name"] = "Подземный вурдалак", ["wtype"] = "Ходячий труп", ["level"] = 5, ["atds"] = 10, ["agr"] = true,
- ["loot"] = {["exp"] = 4, ["coins"] = 8, ["items"] = standartItemLoot5_9}, ["vresp"] = 85, ["rtype"] = "e", ["image"] = "venomous_ghoul"},
- {["id"] = 17, ["name"] = "Привидение", ["wtype"] = "Призрак", ["level"] = 6, ["atds"] = 10, ["agr"] = true,
- ["loot"] = {["exp"] = 7, ["coins"] = 11, ["items"] = standartItemLoot5_9}, ["vresp"] = 55, ["rtype"] = "e", ["image"] = "nv_ghost"},
- {["id"] = 18, ["name"] = "Выход", ["wtype"] = "", ["level"] = 0, ["quests"] = nil,
- ["vresp"] = 0, ["image"] = "tlp1", ["rtype"] = "f",["dialog"] = 6},
- {["id"] = 19, ["name"] = "Каменная стена", ["wtype"] = "", ["level"] = 0, ["quests"] = nil,
- ["vresp"] = 0, ["image"] = "stne_wall", ["rtype"] = "f",["dialog"] = 7},
- {["id"] = 20, ["name"] = "Ученый из Лусофаега", ["wtype"] = "", ["level"] = 0, ["quests"] = nil,
- ["vresp"] = 0, ["image"] = "vil4", ["rtype"] = "f",["dialog"] = 8},
- {["id"] = 21, ["name"] = "Гравий", ["level"] = 0, ["reqlvl"] = 1, ["rtype"] = "r", ["image"] = "gravel", ["mnprs"] = 9, ["mxprs"] = 21, ["vresp"] = 750,
- ["items"] = {{27,100},{27,1}}, ["coins"] = 0, ["exp"] = 0},
- {["id"] = 22, ["name"] = "Залежи железа", ["level"] = 0, ["reqlvl"] = 1, ["rtype"] = "r", ["image"] = "iron_ore", ["mnprs"] = 9, ["mxprs"] = 21, ["vresp"] = 750,
- ["items"] = {{25,100},{25,1}}, ["coins"] = 0, ["exp"] = 0},
- {["id"] = 23, ["name"] = "Залежи меди", ["level"] = 0, ["reqlvl"] = 1, ["rtype"] = "r", ["image"] = "copper_ore", ["mnprs"] = 9, ["mxprs"] = 21, ["vresp"] = 750,
- ["items"] = {{24,100},{24,1}}, ["coins"] = 0, ["exp"] = 0},
- {["id"] = 24, ["name"] = "Старый пень", ["level"] = 0, ["reqlvl"] = 1, ["rtype"] = "r", ["image"] = "wooden", ["mnprs"] = 9, ["mxprs"] = 21, ["vresp"] = 750,
- ["items"] = {{21,100},{21,1}}, ["coins"] = 0, ["exp"] = 0},
- {["id"] = 25, ["name"] = "Залежи древесного угля", ["level"] = 0, ["reqlvl"] = 1, ["rtype"] = "r", ["image"] = "wcoal", ["mnprs"] = 9, ["mxprs"] = 21, ["vresp"] = 750,
- ["items"] = {{26,100},{26,1}}, ["coins"] = 0, ["exp"] = 0}
- }
- standartItemLoot1_4 = nil
- standartItemLoot5_9 = nil
- for f = 1, #gameUnitData do
- gameUnitData[f]["name"] = lang(gameUnitData[f]["name"])
- gameUnitData[f]["wtype"] = lang(gameUnitData[f]["wtype"])
- end
- local gameItemData = {
- {["name"] = "Медный слиток", ["type"] = "item", ["subtype"] = "res", ["description"] = "Может быть использован для крафта",
- ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 5, ["icon"] = 1, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Железный слиток", ["type"] = "item", ["subtype"] = "res", ["description"] = "Может быть использован для крафта",
- ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 5, ["icon"] = 2, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Шлем новобранца", ["level"] = 1, ["type"] = "armor", ["subtype"] = "helmet", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {}, ["stackable"] = false, ["cost"] = 5, ["icon"] = 5, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Доспех новобранца", ["level"] = 1, ["type"] = "armor", ["subtype"] = "bodywear", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {}, ["stackable"] = false, ["cost"] = 5, ["icon"] = 3, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Брюки новобранца", ["level"] = 1, ["type"] = "armor", ["subtype"] = "pants", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {}, ["stackable"] = false, ["cost"] = 5, ["icon"] = 4, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Сапоги новобранца", ["level"] = 1, ["type"] = "armor", ["subtype"] = "footwear", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {}, ["stackable"] = false, ["cost"] = 5, ["icon"] = 6, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Деревянный меч", ["level"] = 1, ["type"] = "weapon", ["subtype"] = "sword", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {["atds"] = 10, ["phisat"] = 2, ["magat"] = 0}, ["stackable"] = false, ["cost"] = 1, ["icon"] = 7, ["ncolor"] = 0xFFFF00},
- {["name"] = "Ожерелье из кости", ["level"] = 1, ["type"] = "armor", ["subtype"] = "pendant", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {}, ["stackable"] = false, ["cost"] = 6, ["icon"] = 8, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Малое исцеляющее зелье", ["type"] = "potion", ["subtype"] = "health", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 1, ["icon"] = 9, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Малое бодрящее зелье", ["type"] = "potion", ["subtype"] = "mana", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 1, ["icon"] = 10, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Среднее исцеляющее зелье", ["type"] = "potion", ["subtype"] = "health", ["reqlvl"] = 5, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["level"] = 2, ["cost"] = 2, ["icon"] = 11, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Среднее бодрящее зелье", ["type"] = "potion", ["subtype"] = "mana", ["reqlvl"] = 5, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["level"] = 2, ["cost"] = 2, ["icon"] = 12, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Большое исцеляющее зелье", ["type"] = "potion", ["subtype"] = "health", ["reqlvl"] = 10, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["level"] = 3, ["cost"] = 3, ["icon"] = 13, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Большое бодрящее зелье", ["type"] = "potion", ["subtype"] = "mana", ["reqlvl"] = 10, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["level"] = 3, ["cost"] = 3, ["icon"] = 14, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Концентрированное исцеляющее зелье", ["type"] = "potion", ["subtype"] = "health", ["reqlvl"] = 15, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["level"] = 4, ["cost"] = 4, ["icon"] = 15, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Концентрированное бодрящее зелье", ["type"] = "potion", ["subtype"] = "mana", ["reqlvl"] = 15, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["level"] = 4, ["cost"] = 4, ["icon"] = 16, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Грубая шкура животного", ["type"] = "item", ["subtype"] = "res", ["description"] = "Может быть использован для крафта",
- ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 3, ["icon"] = 17, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Мягкий мех", ["type"] = "item", ["subtype"] = "res", ["description"] = "Может быть использован для крафта",
- ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 5, ["icon"] = 18, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Грубая нить", ["type"] = "item", ["subtype"] = "res", ["description"] = "Может быть использован для крафта",
- ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 5, ["icon"] = 19, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Необработанная кожа", ["type"] = "item", ["subtype"] = "res", ["description"] = "Может быть использован для крафта",
- ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 6, ["icon"] = 20, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Необработанная древесина", ["type"] = "item", ["subtype"] = "res", ["description"] = "Может быть использован для крафта",
- ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 4, ["icon"] = 21, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Коробка", ["type"] = "chest", ["subtype"] = "none", ["cost"] = 1, ["description"] = "Награда за задание",
- ["props"] = {{9,5,14.2},{10,5,14.2},{3,1,14.2},{4,1,14.2},{5,1,14.2},{6,1,14.2},{8,1,14.2},{9,1,100}},
- ["stackable"] = false, ["maxstack"] = 99, ["icon"] = 22, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Телепортирующая частица", ["type"] = "tlp", ["subtype"] = "none", ["description"] = "Телепортирует к началу",
- ["stackable"] = true, ["maxstack"] = 99, ["cost"] = 1, ["icon"] = 23, ["ncolor"] = 0x00C232},
- {["name"] = "Медная руда", ["type"] = "item", ["subtype"] = "res", ["description"] = "Перерабатываемое сырье",
- ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 2, ["icon"] = 24, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Железная руда", ["type"] = "item", ["subtype"] = "res", ["description"] = "Перерабатываемое сырье",
- ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 2, ["icon"] = 25, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Древесный уголь", ["type"] = "item", ["subtype"] = "res", ["description"] = "Базовое топливо",
- ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 3, ["icon"] = 26, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Гравий", ["type"] = "item", ["subtype"] = "res", ["description"] = "Сырье для работы с камнем",
- ["stackable"] = true, ["maxstack"] = 99, ["level"] = 1, ["cost"] = 3, ["icon"] = 27, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Длинный меч", ["level"] = 1, ["type"] = "weapon", ["subtype"] = "sword", ["reqlvl"] = 2, ["description"] = "",
- ["props"] = {["atds"] = 10, ["phisat"] = 5, ["magat"] = 0}, ["stackable"] = false, ["cost"] = 14, ["icon"] = 29, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Легкое копье", ["level"] = 1, ["type"] = "weapon", ["subtype"] = "spear", ["reqlvl"] = 2, ["description"] = "",
- ["props"] = {["atds"] = 14, ["phisat"] = 4, ["magat"] = 0}, ["stackable"] = false, ["cost"] = 14, ["icon"] = 28, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Короткий каменный топор", ["level"] = 1, ["type"] = "weapon", ["subtype"] = "axe", ["reqlvl"] = 2, ["description"] = "",
- ["props"] = {["atds"] = 10, ["phisat"] = 6, ["magat"] = 0}, ["stackable"] = false, ["cost"] = 14, ["icon"] = 30, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Легкий боевой шлем", ["level"] = 2, ["type"] = "armor", ["subtype"] = "helmet", ["reqlvl"] = 5, ["description"] = "",
- ["props"] = {}, ["stackable"] = false, ["cost"] = 23, ["icon"] = 31, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Доспех из кожи", ["level"] = 2, ["type"] = "armor", ["subtype"] = "bodywear", ["reqlvl"] = 5, ["description"] = "",
- ["props"] = {}, ["stackable"] = false, ["cost"] = 27, ["icon"] = 32, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Брюки из кожи", ["level"] = 2, ["type"] = "armor", ["subtype"] = "pants", ["reqlvl"] = 5, ["description"] = "",
- ["props"] = {}, ["stackable"] = false, ["cost"] = 25, ["icon"] = 33, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Кожаные сапоги", ["level"] = 2, ["type"] = "armor", ["subtype"] = "footwear", ["reqlvl"] = 5, ["description"] = "",
- ["props"] = {}, ["stackable"] = false, ["cost"] = 25, ["icon"] = 34, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Волшебный кулон", ["level"] = 2, ["type"] = "armor", ["subtype"] = "pendant", ["reqlvl"] = 6, ["description"] = "",
- ["props"] = {}, ["stackable"] = false, ["cost"] = 36, ["icon"] = 35, ["ncolor"] = 0xFFFFFF},
- -- Читерское
- {["name"] = "Дохрена мощный топор", ["level"] = 16, ["type"] = "weapon", ["subtype"] = "axe", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {["atds"] = 10, ["phisat"] = 6, ["magat"] = 0}, ["stackable"] = false, ["cost"] = 1, ["icon"] = 30, ["ncolor"] = 0x00C221},
- }
- local itemPhysDefMlt = {["helmet"]=13.2,["bodywear"]=14.4,["pants"]=13.7,["footwear"]=12.2,["pendant"]=9.5}
- local itemMagDefMlt = {["helmet"]=1.5,["bodywear"]=5.3,["pants"]=4.8,["footwear"]=4.5,["pendant"]=11.7}
- for f = 1, #gameItemData do
- gameItemData[f]["name"] = lang(gameItemData[f]["name"])
- gameItemData[f]["description"] = lang(gameItemData[f]["description"])
- if gameItemData[f]["type"] == "armor" then
- if gameItemData[f]["props"]["pdef"] == nil then
- gameItemData[f]["props"]["pdef"] = math.ceil(21+gameItemData[f]["level"]*itemPhysDefMlt[gameItemData[f]["subtype"]])
- end
- if gameItemData[f]["props"]["magdef"] == nil then
- gameItemData[f]["props"]["magdef"] = math.ceil(9+gameItemData[f]["level"]*itemMagDefMlt[gameItemData[f]["subtype"]])
- end
- end
- end
- local gameQuestsData = {
- {["name"] = "Зомби", ["type"] = "k", ["qstrec"] = 5, ["targ"] = 2, ["num"] = 1, ["minlvl"] = 1,
- ["descr"] = "Избавьте людей от этой угрозы!",
- ["comp"] = 0, ["qreward"] = {["coins"] = 10, ["xp"] = 10, ["item"] = {{9,5},{23,5}}}},
- {["name"] = "Призраки", ["type"] = "k", ["qstrec"] = 5, ["targ"] = 3, ["num"] = 3, ["minlvl"] = 1,
- ["descr"] = "Даже привидения могут представлять угрозу человеку.",
- ["comp"] = 0, ["qreward"] = {["coins"] = 12, ["xp"] = 9, ["item"] = {{10,5}}}},
- {["name"] = "Луговые слизни", ["type"] = "k", ["qstrec"] = 5, ["targ"] = 4, ["num"] = 7, ["minlvl"] = 2,
- ["descr"] = "Никогда не было так много слизней в наших лугах! Зеленые луговые слизни очень быстро уничтожат все растения и, скорее всего, скоро будут здесь.",
- ["comp"] = 0, ["qreward"] = {["coins"] = 20, ["xp"] = 15, ["item"] = {{22,1}}}},
- {["name"] = "Необычные черепахи", ["type"] = "k", ["qstrec"] = 10, ["targ"] = 8, ["num"] = 3, ["minlvl"] = 3,
- ["descr"] = " Анатолия очень заинтересовали каменные черепахи. Принесите ему 3 панциря каменных черепах.",
- ["comp"] = 0, ["qreward"] = {["coins"] = 18, ["xp"] = 16, ["item"] = nil}},
- }
- local gameSkillsData = {
- {["name"] = "Физическая атака", ["distance"] = 0, ["type"] = "attack", ["typedm"] = "p", ["level"] = 1, ["reloading"] = 1,
- ["mindamage"] = {0,0,0,0,0,0,0}, ["maxdamage"] = {1,1,1,1,1,1,1}, ["manacost"] = {0,0,0,0,0,0,0}, ["eff"] = nil},
- {["name"] = "Глубокий порез", ["distance"] = 1, ["type"] = "attack", ["typedm"] = "p", ["level"] = 1, ["reloading"] = 3,
- ["mindamage"] = {2,3,4,6,9,14,19}, ["maxdamage"] = {4,7,10,13,16,20,28}, ["manacost"] = {5,6,7,9,11,13,15}, ["eff"] = nil},
- {["name"] = "Кровопускание", ["distance"] = 1, ["type"] = "attack", ["typedm"] = "p", ["level"] = 1, ["reloading"] = 7,
- ["mindamage"] = {2,3,4,6,8,12,16}, ["maxdamage"] = {4,6,8,10,12,17,23}, ["manacost"] = {6,7,9,11,13,16,20}, ["eff"] = 3},
- {["name"] = "Аура железа", ["type"] = "buff", ["level"] = 1, ["reloading"] = 25,
- ["manacost"] = {8,11,14,18,25,34,47}, ["eff"] = 4},
- }
- local gameEffectsData = {
- {["name"]="Исцеляющее зелье",["type"]="hpi", ["descr"]="Восстановление здоровья",
- ["dur"]={10,10,10,10,10,10},["val"]={12,22,35,47,60,85},["i"]={0xcc4940,"h",0xff9200,"p"}},
- {["name"]="Бодрящее зелье",["type"]="mpi", ["descr"]="Восстановление маны",
- ["dur"]={10,10,10,10,10,10},["val"]={12,22,35,47,60,85},["i"]={0x3349bf,"m",0xff9200,"p"}},
- {["name"]="Кровоточащая рана",["type"]="hpd", ["descr"]="",
- ["dur"]={8,8,8,8,8,8},["val"]={8,14,21,29,38,53},["i"]={0x434941,"b",0xe32114,"w"}},
- {["name"]="Аура железа",["type"]="pdfi%", ["descr"]="Физическая защита увеличена",
- ["dur"]={60,90,120,180,240,300},["val"]={5,10,15,20,25,30,35},["i"]={0x81c181,"w",0x3872ae,"a"}},
- }
- local gameTradew = {
- [1]={
- { ["section_name"] = "Тест",
- {["item"]=3,["chance"]=100,["cost"]=182},
- {["item"]=4,["chance"]=100,["cost"]=181},
- {["item"]=5,["chance"]=100,["cost"]=185},
- {["item"]=6,["chance"]=100,["cost"]=183},
- {["item"]=7,["chance"]=100,["cost"]=111},
- {["item"]=8,["chance"]=100,["cost"]=666},
- {["item"]=9,["chance"]=100,["cost"]=16},
- {["item"]=10,["chance"]=100,["cost"]=31},
- {["item"]=11,["chance"]=100,["cost"]=53},
- {["item"]=12,["chance"]=100,["cost"]=321},
- {["item"]=13,["chance"]=100,["cost"]=12},
- {["item"]=14,["chance"]=100,["cost"]=10},
- {["item"]=15,["chance"]=100,["cost"]=62},
- {["item"]=16,["chance"]=100,["cost"]=27},
- {["item"]=17,["chance"]=100,["cost"]=82},
- {["item"]=18,["chance"]=100,["cost"]=63},
- },
- { ["section_name"] = "Тест2",
- {["item"]=21,["chance"]=100,["cost"]=22},
- }
- },
- }
- for f = 1, #gameQuestsData do
- gameQuestsData[f]["name"] = lang(gameQuestsData[f]["name"])
- gameQuestsData[f]["comp"] = 0
- end
- local cGUData = {} -- массив со всеми персонажами
- local cPlayerSkills = {{2,0,1}}
- local cUskills = {{1,0,1},{2,0,1},{3,0,1},{0,0,1},{4,0,1},{0,0,1}}
- local cUquests = {} -- структура -- [1] (и т.д.) = {1(id),0(прогресс),false(не выполнено/выполнено)}
- local inventory = {
- ["weared"] = {
- ["helmet"] = 0,
- ["bodywear"] = 0,
- ["pants"] = 0,
- ["weapon"] = 7,
- ["footwear"] = 0,
- ["pendant"] = 0},
- ["bag"] = {}
- }
- for f = 1, 20 do
- inventory["bag"][f] = {}
- inventory["bag"][f][1] = 0
- inventory["bag"][f][2] = 0
- end
- local cpath = "/games/testgame/"
- local cGlobalx, cBackgroundPos = 1, 1
- local playerSprPicPos = 75
- local cTarget = 0
- local paused = false
- local cWindowTrd = nil
- local showTargetInfo = false
- local pckTarget = 0
- local pickingUp = false
- local maxPckTime = 0
- local pckTime = 0
- local stopDrawing = false
- local ingame = true
- local playerCanMove = true
- local cmp, mmp, cxp, mxp, cCoins = 0, 0, 0, 0, 0
- local cDialog
- local charPoints = gameUnitData[1]["level"]-1
- local survivability = 1
- local strength = 1
- local intelligence = 1
- local world = {
- current = 1,
- [1]={
- name = "Деревня Зеленый Камень",
- limitL = -160,
- limitR = 105,
- spawnList = {
- {11,-68,1},
- {10,-47,1},
- {5,-25,1},
- {12,45,1}
- },
- draw = function()
- buffer.square(1, 1, 160, 50, 0x00AAFF, 0xFFFFFF, " ")
- buffer.square(1, 48, 160, 1, 0x755340, 0xFFFFFF, " ")
- buffer.square(1, 49, 160, 2, 0x339240, 0xFFFFFF, " ")
- end,
- },
- [2]={
- name = "Зеленые луга",
- limitL = -60,
- limitR = 2115,
- spawnList = {
- {13,-27,1},
- {2,95,1,5,42},
- {3,361,2,5,95},
- {4,328,1,6,95},
- {6,856,1,5,95},
- {7,823,1,4,95},
- {8,1361,1,4,95},
- {9,1328,1,3,95},
- {14,1758,1,4,95},
- {15,1737,1,4,95},
- {19,2125,-2},
- {21,math.random(100,1450),1,math.random(1,3),math.random(120,290)},
- {22,math.random(100,1450),1,math.random(1,3),math.random(120,290)},
- {23,math.random(100,1450),1,math.random(1,3),math.random(120,290)},
- {24,math.random(100,1450),1,math.random(1,3),math.random(120,290)}
- --{17,2125,1,4,55},
- },
- draw = function()
- buffer.square(1, 1, 160, 50, 0x00AAFF, 0xFFFFFF, " ")
- buffer.square(1, 48, 160, 1, 0x755340, 0xFFFFFF, " ")
- buffer.square(1, 49, 160, 2, 0x339240, 0xFFFFFF, " ")
- end,
- },
- [3]={
- name = "Пещера",
- limitL = -60,
- limitR = 500,
- spawnList = {
- {18,-25,1},
- {16,68,1,4,44},
- },
- draw = function()
- buffer.square(1, 1, 160, 50, 0x656565, 0xFFFFFF, " ")
- buffer.square(1, 1, 160, 3, 0x616161, 0xFFFFFF, " ")
- buffer.square(1, 48, 160, 1, 0x585858, 0xFFFFFF, " ")
- buffer.square(1, 49, 160, 2, 0x434343, 0xFFFFFF, " ")
- end,
- },
- [4]={
- name = "Поселение",
- limitL = -160,
- limitR = 105,
- spawnList = {
- {10,-68,1},
- {11,-47,1},
- {20,-25,1},
- },
- draw = function()
- buffer.square(1, 1, 160, 50, 0x00AAFF, 0xFFFFFF, " ")
- buffer.square(1, 48, 160, 1, 0x755340, 0xFFFFFF, " ")
- buffer.square(1, 49, 160, 2, 0x339240, 0xFFFFFF, " ")
- end,
- },
- }
- local function clicked(x,y,x1,y1,x2,y2)
- if x >= x1 and x <= x2 and y >= y1 and y <= y2 then
- return true
- end
- return false
- end
- local function toboolean(v)
- if v == "true" then return true
- else return false
- end
- end
- local function getDistance(from,x)
- local dist = 0
- local x1, x2 = cGUData[from]["x"], x
- if x1 < x2 then dist = x2-x1
- elseif x1 > x2 then dist = x1-x2
- end
- return dist
- end
- local function getDistanceToId(from,to)
- local dist = 0
- local x1, x2 = cGUData[from]["x"], cGUData[to]["x"]
- if x1 < x2 then dist = x2-x1-cGUData[from]["width"]
- elseif x1 > x2+cGUData[to]["width"] then dist = x1-x2-cGUData[to]["width"]
- end
- return dist
- end
- local sScreenTimerw = false
- local sScreenTimer1 = 0
- local sScreenXValue = 1
- local old_cgx, old_cbpos = cGlobalx, cBackgroundPos
- local function setScreenXValue(x, time)
- cWindowTrd = "screen_save"
- old_cgx, old_cbpos = cGlobalx, cBackgroundPos
- sScreenTimerw = true
- sScreenTimer1 = time
- sScreenXValue = x
- end
- local function setScreenPosition(x)
- local ncGlobalx, ncBackgroundPos = cGlobalx, cBackgroundPos
- cGlobalx = x
- cBackgroundPos = x
- playerSprPicPos = 75-getDistance(1,x)
- end
- local function setScreenNormalPosition(ncGlobalx, ncBackgroundPos)
- playerSprPicPos = 75
- cGlobalx, cBackgroundPos = ncGlobalx, ncBackgroundPos
- sScreenTimerw = false
- cWindowTrd = nil
- end
- local function setScreenNewPosition()
- if sScreenTimerw and sScreenXValue ~= nil then
- if sScreenTimer1 - 1 > 0 then
- setScreenPosition(sScreenXValue)
- else
- sScreenTimer1 = 0
- setScreenNormalPosition(old_cgx, old_cbpos)
- end
- end
- end
- local function movetoward(id, x, distanceLimit, step)
- if getDistance(id,x) < distanceLimit and x < cGUData[id]["x"] then
- cGUData[id]["x"] = cGUData[id]["x"] - step
- cGUData[id]["spos"] = "l"
- elseif getDistance(id,x) < distanceLimit and x > cGUData[id]["x"] then
- cGUData[id]["x"] = cGUData[id]["x"] + step
- cGUData[id]["spos"] = "r"
- end
- end
- local function playerAutoMove(x, distanceLimit, step)
- if getDistance(1,x) >= step and getDistance(1,x) < distanceLimit and x < cGUData[1]["x"] then
- x = math.ceil((cGUData[1]["x"] - x)/3)*3
- cGUData[1]["spos"] = "l"
- cGUData[1]["x"] = cGUData[1]["x"] - step
- cGlobalx = cGlobalx - step
- cBackgroundPos = cBackgroundPos - step
- elseif getDistance(1,x) >= step and getDistance(1,x) < distanceLimit and x > cGUData[1]["x"] then
- x = math.ceil((cGUData[1]["x"] + x)/3)*3
- cGUData[1]["spos"] = "r"
- cGUData[1]["x"] = cGUData[1]["x"] + step
- cGlobalx = cGlobalx + step
- cBackgroundPos = cBackgroundPos + step
- else
- cGUData[1]["mx"] = cGUData[1]["x"]
- end
- end
- local function insertQuests(id,dialog)
- local newDialog = dialog
- local tvar
- local cQue = gameUnitData[cGUData[id]["id"]]["quests"]
- local insQuestDialog = true
- if type(cQue) == "table" then
- for n = 1, #dialog do
- if dialog[n]["action"] == "dialog" and dialog[n]["text"] then
- insQuestDialog = false
- break
- end
- end
- if insQuestDialog then
- table.insert(newDialog,1,{["text"]=lang("Задания"),["action"]="dialog",["do"] ={["text"]="Выберите любые доступные задания"}})
- end
- for v = 0, #cQue-1 do
- tvar = true
- for sq = 1, #cUquests do
- if cUquests[sq][1] == #cQue-v and cUquests[sq][3] then
- tvar = false
- break
- end
- end
- if not tvar then break end
- if cQue[#cQue-v] > 0 and cQue[#cQue-v] <= #gameQuestsData and cGUData[1]["level"] >= gameQuestsData[#cQue-v]["minlvl"] then
- newDialog[1]["do"][v] = {["q"]=#cQue-v,["text"]=gameQuestsData[#cQue-v]["name"],["action"]="qdialog",
- ["do"] = {
- ["text"]="Выбрать задание '"..gameQuestsData[cQue[#cQue-v]]["name"].."'",
- {["text"]="Я готов выполнить задание",["action"]="getquest",["do"]=cQue[#cQue-v]},
- {["text"]="Не сейчас",["action"]="close",["do"]=nil}
- }}
- end
- end
- for v = 1, #cUquests do
- if cUquests[v][3] and gameUnitData[cTarget]["id"] == gameQuestsData[cUquests[v][1]]["qstrec"] and not gameQuestsData[cUquests[v][1]]["comp"] then
- table.insert(newDialog[1]["do"],{["text"]=gameQuestsData[cUquests[v][1]]["name"],["action"]="cmpquest",["do"]=cUquests[v][1]})
- end
- end
- newDialog[1]["do"][#cQue] = {["text"]=lang("До встречи"),["action"]="close",["do"]=nil}
- end
- return newDialog
- end
- local sMSG1, smsg1time = {"",""}, 0
- local function addsmsg1(msg)
- table.insert(sMSG1,msg)
- smsg1time = 8
- end
- local sMSG2, smsg2time = {""}, 0
- local function addsmsg2(msg)
- table.insert(sMSG2,msg)
- smsg2time = 5
- end
- sMSG3 = ""
- local function addsmsg3(msg)
- sMSG3 = msg
- end
- local consDataR = {}
- local function booleanToString(b)
- if b then
- return "true"
- else
- return "false"
- end
- end
- local console={}
- function console.debug(...)
- local args = table.pack(...)
- local msg, adt = "", ""
- if #args > 0 then
- for f = 1, #args do
- if type(args[f]) == "string" then
- adt = args[f]
- elseif type(args[f]) == "number" then
- adt = tostring(args[f])
- elseif type(args[f]) == "boolean" then
- adt = booleanToString(args[f])
- else
- adt = type(args[f])
- end
- msg = msg..adt.." "
- end
- end
- table.insert(consDataR,msg)
- end
- function console.wError(e)
- if type(e) == "string" then table.insert(consDataR,"!/"..e) end
- end
- local cnsCommands = {
- ["clear"] = function() consDataR = {} end
- }
- function console.execCommand(com)
- if type(com) ~= "string" then
- console.wError("Значение команды невозможно")
- else
- if type(cnsCommands[com]) == "string" then
- cnsCommands[com]()
- end
- end
- end
- local function addUnit(id,x,y)
- local cUSprite
- cGUData[#cGUData+1] = {}
- cGUData[#cGUData]["sx"] = x
- cGUData[#cGUData]["mx"] = x
- cGUData[#cGUData]["x"] = x
- cGUData[#cGUData]["y"] = y
- cGUData[#cGUData]["id"] = gameUnitData[id]["id"]
- cGUData[#cGUData]["level"] = gameUnitData[id]["level"]
- cGUData[#cGUData]["spos"] = "r"
- cGUData[#cGUData]["image"] = gameUnitData[id]["image"]
- if cGUData[#cGUData]["image"] ~= nil then
- cUSprite = image.load(cpath.."sprpic/"..gameUnitData[id]["image"]..".pic")
- cGUData[#cGUData]["width"] = cUSprite.width
- cGUData[#cGUData]["height"] = cUSprite.height
- end
- if gameUnitData[id]["mhp"] == nil then
- cGUData[#cGUData]["mhp"] = math.ceil(12+(gameUnitData[id]["level"]-1)*gameUnitData[id]["level"]*2.25)
- else
- cGUData[#cGUData]["mhp"] = gameUnitData[id]["mhp"]
- end
- cGUData[#cGUData]["chp"] = cGUData[#cGUData]["mhp"]
- cGUData[#cGUData]["phisatck"] = math.ceil(0.15+cGUData[#cGUData]["level"]*0.44)
- cGUData[#cGUData]["magatck"] = math.ceil(0.75+cGUData[#cGUData]["level"]*0.3)
- cGUData[#cGUData]["pdef"] = math.ceil(11.5+cGUData[#cGUData]["level"]*5.84)
- cGUData[#cGUData]["magdef"] = math.ceil(9+gameUnitData[id]["level"]*4.31)
- cGUData[#cGUData]["resptime"] = 0
- cGUData[#cGUData]["living"] = true
- cGUData[#cGUData]["rtype"] = gameUnitData[id]["rtype"]
- cGUData[#cGUData]["attackdistance"] = gameUnitData[id]["atds"]
- cGUData[#cGUData]["attPlayer"] = false
- if gameUnitData[id]["rtype"] == "f" then
- cGUData[#cGUData]["dialog"] = gameUnitData[id]["dialog"]
- end
- cGUData[#cGUData]["effects"] = {}
- if gameUnitData[id]["rtype"] == "m" then
- cGUData[#cGUData]["mhp"] = gameUnitData[id]["mhp"]
- cGUData[#cGUData]["chp"] = cGUData[#cGUData]["mhp"]
- end
- console.debug("Spawn new unit","id:"..tostring(gameUnitData[id]["id"]),"name:"..gameUnitData[id]["name"],"x:"..tostring(x),"y:"..tostring(y),"Gid:"..#cGUData)
- end
- console.wError(preduprejdenie)
- console.debug("Загрузка ("..unicode.sub(os.date(), 1, -4)..")")
- local function addItem(itemid,num)
- local vparInvEx = 0
- for f = 1, #inventory["bag"] do
- if inventory["bag"][f][1] == 0 and inventory["bag"][f][1] ~= itemid and not gameItemData[itemid]["stackable"] then
- inventory["bag"][f][1] = itemid
- inventory["bag"][f][2] = num
- break
- end
- end
- if gameItemData[itemid]["stackable"] and vparInvEx == 0 then
- for i = 1, #inventory["bag"] do
- if inventory["bag"][i][1] == itemid then
- inventory["bag"][i][2] = inventory["bag"][i][2] + num
- vparInvEx = 1
- break
- end
- end
- if vparInvEx == 0 then
- for i = 1, #inventory["bag"] do
- if inventory["bag"][i][1] == 0 then
- inventory["bag"][i][1] = itemid
- inventory["bag"][i][2] = num
- break
- end
- end
- end
- end
- for f = 1, #inventory["bag"] do
- if inventory["bag"][f][1] ~= 0 and not gameItemData[inventory["bag"][f][1]]["stackable"] and inventory["bag"][f][2] > 1 then
- inventory["bag"][f][2] = 1
- end
- end
- end
- -- создание новых предметов и заполнение ими массива gameItemData
- local function createNewItem(itemID)
- local adds = {}
- local newItemID = #gameItemData + 1
- if gameItemData[itemID]["type"] == "armor" or gameItemData[itemID]["type"] == "weapon" then
- gameItemData[newItemID] = {}
- local list = {
- "name",
- "level",
- "type",
- "subtype",
- "reqlvl",
- "description",
- "stackable",
- "cost",
- "icon",
- "ncolor"
- }
- for e = 1, # list do
- gameItemData[newItemID][list[e]] = gameItemData[itemID][list[e]]
- end
- gameItemData[newItemID]["props"] = {}
- for k, v in pairs(gameItemData[itemID]["props"]) do
- gameItemData[newItemID]["props"][k] = gameItemData[itemID]["props"][k]
- end
- local function A() gameItemData[newItemID]["name"] = "♦"..gameItemData[newItemID]["name"] end
- for f = 1, math.min(math.random(1,math.ceil(gameItemData[itemID]["level"]/2)),5) do adds[f] = math.random(1,6) end
- for f = 1, #adds do
- if adds[f] == 1 then
- gameItemData[newItemID]["props"]["hp+"] = math.random(5+(gameItemData[itemID]["level"]-1)*2,5+(gameItemData[itemID]["level"]-1)*6)
- A()
- elseif adds[f] == 2 then
- gameItemData[newItemID]["props"]["sur+"] = math.floor(math.random(gameItemData[itemID]["level"],gameItemData[itemID]["level"]*2))
- A()
- elseif adds[f] == 3 then
- gameItemData[newItemID]["props"]["str+"] = math.floor(math.random(gameItemData[itemID]["level"],gameItemData[itemID]["level"]*2))
- A()
- elseif adds[f] == 4 then
- gameItemData[newItemID]["props"]["int+"] = math.floor(math.random(gameItemData[itemID]["level"],gameItemData[itemID]["level"]*1.5))
- A()
- elseif adds[f] == 5 then
- gameItemData[newItemID]["props"]["pdm+"] = math.floor(math.random((gameItemData[itemID]["level"]-1)*15.7,(gameItemData[itemID]["level"]-1)*28.3)/10)
- A()
- elseif adds[f] == 6 then
- gameItemData[newItemID]["props"]["mdm+"] = math.floor(math.random((gameItemData[itemID]["level"]-1)*12.5,(gameItemData[itemID]["level"]-1)*22.5)/10)
- A()
- end
- end
- if #adds > 0 then gameItemData[newItemID]["ncolor"] = 0x0044FF end
- else
- return itemID
- end
- return newItemID
- end
- --[[
- addItem(1,1)
- ]]
- addItem(createNewItem(#gameItemData),1)
- addItem(createNewItem(30),1)
- addItem(createNewItem(35),1)
- addItem(35,1)
- local function addPlayerEffect(id,level)
- local addne = true
- if type(id) == 'number' and type(level) == 'number' and id >= 1 and id <= #gameEffectsData then
- for eff = 1, #cGUData[1]["effects"] do
- if cGUData[1]["effects"][eff][1] == id then
- cGUData[1]["effects"][eff][2] = cGUData[1]["effects"][eff][2] + gameEffectsData[id]["dur"][level]
- addne = false
- break
- end
- end
- if addne then table.insert(cGUData[1]["effects"],{id,gameEffectsData[id]["dur"][level],level}) end
- else
- console.wError('addPlayerEffect: неверное значение id или level')
- end
- end
- local function addUnitEffect(uID,eID,level)
- local addne = true
- if type(uID) == 'number' and type(eID) == 'number' and type(level) == 'number' and eID >= 1 and eID <= #gameEffectsData then
- for eff = 1, #cGUData[uID]["effects"] do
- if cGUData[uID]["effects"][eff][1] == eID then
- cGUData[uID]["effects"][eff][2] = cGUData[uID]["effects"][eff][2] + gameEffectsData[eID]["dur"][level]
- addne = false
- break
- end
- end
- if addne then table.insert(cGUData[uID]["effects"],{eID,gameEffectsData[eID]["dur"][level],level}) end
- else
- console.wError('addUnitEffect: неверное значение uID, eID или level')
- end
- end
- local function saveGame(savePath,filename)
- if not fs.exists(savePath) then
- fs.makeDirectory(savePath)
- end
- local saveNum = #fs.list(savePath)()-4 or 0
- fs.copy(savePath.."/gsave",savePath.."/"..filename)
- local save = io.open(savePath.."/"..filename,"w")
- local function rudt(id,value,ctype) return value.." = "..tostring(cGUData[id][value]).." @ "..ctype end
- save:write("save","\n")
- save:write(os.date(),"\n")
- save:write("save_md_s","\n")
- save:write("gameunitdata_s","\n")
- for f = 1, #cGUData do
- save:write("{","\n")
- save:write(rudt(f,"sx","n"),"\n")
- save:write(rudt(f,"x","n"),"\n")
- save:write(rudt(f,"y","n"),"\n")
- save:write(rudt(f,"id","n"),"\n")
- save:write(rudt(f,"spos","n"),"\n")
- save:write(rudt(f,"mhp","n"),"\n")
- save:write(rudt(f,"chp","n"),"\n")
- save:write(rudt(f,"living","b"),"\n")
- save:write(rudt(f,"resptime","n"),"\n")
- save:write("}","\n")
- end
- save:write("save_md_e","\n")
- save:close()
- end
- local function strGetValue(string)
- local del1 = string.find(string,"=")
- local del2 = string.find(string,"@")
- if del1 ~= nil and del2 ~= nil then
- local key = string.sub(string,1,del1-2)
- local value = string.sub(string,del1+2,del2-2)
- local ctype = string.sub(string,del2+2,#string)
- else key = nil
- end
- return key, value, ctype
- end
- local function loadGame(savePath,filename)
- local gkv, ndKey, ndValue, ndType = 1, "", "", ""
- local rdata = {}
- local aInfo = {}
- local gUnitData = {}
- local cReadMode = "S"
- if fs.exists(savePath.."/"..filename) then rdata = readFromFile(savePath.."/"..filename) end
- for f = 1, #rdata do
- if cReadMode == "Gv" and rdata == "}" then
- cReadMode = "G"
- gkv = gkv + 1
- end
- if rdata[f] == "save_md_e" then
- break
- end
- if cReadMode == "S" then
- table.insert(aInfo,rdata[f])
- elseif cReadMode == "M" then
- elseif cReadMode == "Gv" then
- ndKey, ndValue, ndType = strGetValue(rdata[f])
- if ndKey ~= nil then
- if ndType == "n" then ndValue = tonumber(ndValue)
- elseif ndType == "b" then ndValue = toboolean(ndValue)
- end
- gUnitData[gkv][ndKey] = ndValue
- end
- end
- if rdata[f] == "save_md_s" then
- cReadMode = "M"
- end
- if rdata[f] == "gameunitdata_s" then
- cReadMode = "G"
- end
- if cReadMode == "G" and rdata[f] == "{" then
- cReadMode = "Gv"
- table.insert(gUnitData,gkv,{})
- end
- end
- return aInfo, gUnitData
- end
- -- local dd, cGUData = loadGame("/games/testgame/saves","save_1.save")
- -- saveGame("/games/testgame/saves","save_1.save")
- local vaddsPnts = {vSur=0,vStr=0,vInt=0,vPdm=0,vMdm=0}
- local function playerRefreshVar()
- local vAtds = 8
- local vSur,vStr,vInt,vHpi,vPdm,vMdm,vPdf,vMdf = 0, 0, 0, 0, 0, 0, 0, 0
- local vaPdm, vaMdm = 0, 0
- cGUData[1]["mhp"], mmp, mxp, cGUData[1]["phisatck"], cGUData[1]["magatck"], cGUData[1]["pdef"], cGUData[1]["magdef"] = 0, 0, 0, 0, 0, 0, 0
- local wItemTypes = {
- "helmet",
- "bodywear",
- "pants",
- "footwear",
- "pendant",
- }
- --
- for f = 1, 5 do
- if inventory["weared"][wItemTypes[f]] ~= 0 then
- if gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["sur+"] ~= nil then
- vSur = vSur + gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["sur+"]
- end
- if gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["str+"] ~= nil then
- vStr = vStr + gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["str+"]
- end
- if gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["int+"] ~= nil then
- vInt = vInt + gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["int+"]
- end
- if gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["hp+"] ~= nil then
- vHpi = vHpi + gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["hp+"]
- end
- if gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["pdm+"] ~= nil then
- vPdm, vaPdm = vPdm + gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["pdm+"], vaPdm + gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["pdm+"]
- end
- if gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["mdm+"] ~= nil then
- vMdm, vaMdm = vMdm + gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["mdm+"], vaMdm + gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["mdm+"]
- end
- vPdf = vPdf + gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["pdef"]
- vMdf = vMdf + gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["magdef"]
- end
- end
- --
- if inventory["weared"]["weapon"] ~= 0 then
- if gameItemData[inventory["weared"]["weapon"]]["props"]["sur+"] ~= nil then
- vSur = vSur + gameItemData[inventory["weared"]["weapon"]]["props"]["sur+"]
- end
- if gameItemData[inventory["weared"]["weapon"]]["props"]["str+"] ~= nil then
- vStr = vStr + gameItemData[inventory["weared"]["weapon"]]["props"]["str+"]
- end
- if gameItemData[inventory["weared"]["weapon"]]["props"]["int+"] ~= nil then
- vInt = vInt + gameItemData[inventory["weared"]["weapon"]]["props"]["int+"]
- end
- if gameItemData[inventory["weared"]["weapon"]]["props"]["hp+"] ~= nil then
- vHpi = vHpi + gameItemData[inventory["weared"]["weapon"]]["props"]["hp+"]
- end
- if gameItemData[inventory["weared"]["weapon"]]["props"]["pdm+"] ~= nil then
- vPdm = vPdm + gameItemData[inventory["weared"]["weapon"]]["props"]["pdm+"]
- end
- if gameItemData[inventory["weared"]["weapon"]]["props"]["mdm+"] ~= nil then
- vMdm = vMdm + gameItemData[inventory["weared"]["weapon"]]["props"]["mdm+"]
- end
- if gameItemData[inventory["weared"]["weapon"]]["props"]["pdm+"] ~= nil then
- vPdm, vaPdm = vPdm + gameItemData[inventory["weared"]["weapon"]]["props"]["pdm+"], vaPdm + gameItemData[inventory["weared"]["weapon"]]["props"]["pdm+"]
- end
- if gameItemData[inventory["weared"]["weapon"]]["props"]["mdm+"] ~= nil then
- vMdm, vaMdm = vMdm + gameItemData[inventory["weared"]["weapon"]]["props"]["mdm+"], vaMdm + gameItemData[inventory["weared"]["weapon"]]["props"]["mdm+"]
- end
- vPdm = cGUData[1]["phisatck"] + gameItemData[inventory["weared"]["weapon"]]["props"]["phisat"]
- vMdm = cGUData[1]["magatck"] + gameItemData[inventory["weared"]["weapon"]]["props"]["magat"]
- vAtds = gameItemData[inventory["weared"]["weapon"]]["props"]["atds"]
- end
- vaddsPnts.vSur, vaddsPnts.vStr, vaddsPnts.vInt, vaddsPnts.vPdm, vaddsPnts.vMdm = vSur, vStr, vInt, vaPdm, vaMdm
- cGUData[1]["mhp"] = math.ceil(4+(survivability+vSur)*11+(cGUData[1]["level"]-1)*7)+vHpi
- mmp = math.ceil(4+(intelligence+vInt)*6+(cGUData[1]["level"]-1)*4)
- mxp = math.ceil(28+(cGUData[1]["level"]-1)*34.7)
- cGUData[1]["phisatck"] = math.floor(1+(strength+vStr-1)*0.9+(cGUData[1]["level"]-1)*0.1525)+vPdm
- cGUData[1]["magatck"] = math.floor(1+(intelligence+vInt-1)*0.25+(cGUData[1]["level"]-1)*0.0125)+vMdm
- cGUData[1]["pdef"] = math.ceil(5+(strength+vStr-1)*29.4+(cGUData[1]["level"]-1)*4.85)+vPdf
- cGUData[1]["magdef"] = math.ceil(5+(intelligence+vInt-1)*22.8+(cGUData[1]["level"]-1)*1.5)+vMdf
- vAttackDistance = vAtds
- end
- local function addXP(value)
- if mxp-cxp >= value then
- cxp = cxp + value
- else
- value = value - (mxp - cxp)
- charPoints = charPoints + 1
- cGUData[1]["level"] = cGUData[1]["level"] + 1
- playerRefreshVar()
- cxp = value
- cGUData[1]["chp"] = cGUData[1]["mhp"]
- cmp = mmp
- end
- end
- local function getQuest(quest)
- table.insert(cUquests,{quest,0,false})
- end
- addUnit(1,1,1)
- local function loadWorld(id)
- stopDrawing = true
- cWindowTrd = nil
- cTarget = 0
- cDialog = nil
- paused = false
- dmLoading()
- cGUData[1]["x"], cGlobalx, cBackgroundPos = 1, 1, 1
- local n = cGUData[1]
- cGUData = {}
- cGUData[1] = n
- local cspawnl = world[id].spawnList
- for f = 1, #cspawnl do
- if cspawnl[f][4] == nil then
- addUnit(cspawnl[f][1],cspawnl[f][2],cspawnl[f][3])
- else
- for i = 1, cspawnl[f][4] do
- addUnit(cspawnl[f][1],cspawnl[f][2]+i*cspawnl[f][5]-cspawnl[f][5],cspawnl[f][3])
- os.sleep()
- end
- end
- os.sleep()
- end
- -- nenujnayaVar = 0
- stopDrawing = false
- addsmsg2(world[id].name)
- end
- local function pbar(x,y,size,percent,color1,color2, text, textcolor)
- percent = 100 - percent
- local fill = {}
- for f = 1, size do
- table.insert(fill,1)
- end
- for f = 1, size do
- if 100/size*f <= percent then
- fill[size-f+1] = 0
- end
- end
- local color0 = 0x000000
- for f = 1, size do
- if fill[f] == 1 then color0 = color1
- else color0 = color2
- end
- buffer.set(x+f-1,y,color0, 0xFFFFFF, " ")
- buffer.text(x, y, textcolor, text)
- end
- end
- local function drawCDataUnit()
- for f = 2, #cGUData do
- if getDistanceToId(1,f) <= 170 and cGUData[f]["living"] then
- if cGUData[f]["image"] ~= nil and cGUData[f]["spos"] == "r" then
- buffer.image(cGUData[f]["x"]+75-cGlobalx,49-cGUData[f]["y"]-cGUData[f]["height"], image.load(cpath.."sprpic/"..cGUData[f]["image"]..".pic"))
- elseif cGUData[f]["spos"] == "l" then
- buffer.image(cGUData[f]["x"]+75-cGlobalx,49-cGUData[f]["y"]-cGUData[f]["height"], image.flipHorizontal(image.load(cpath.."sprpic/"..cGUData[f]["image"]..".pic")))
- end
- if ( cGUData[f]["rtype"] == "e" or cGUData[f]["rtype"] == "p" or cGUData[f]["rtype"] == "m" ) and cTarget == f then
- pbar(cGUData[f]["x"]+75-cGlobalx, 49-cGUData[f]["y"]-2-cGUData[f]["height"],8,math.ceil(cGUData[f]["chp"])*100/cGUData[f]["mhp"],0xFF0000,0x444444," ",0xFFFFFF)
- buffer.text(cGUData[f]["x"]+75-cGlobalx+math.max(math.floor((8 / 2) - (unicode.len(tostring(math.ceil(cGUData[f]["chp"]))) / 2)), 0),49-cGUData[f]["y"]-2-cGUData[f]["height"],0xFFFFFF,tostring(math.ceil(cGUData[f]["chp"])))
- elseif pickingUp and cTarget ~= 0 and pckTarget == f and cGUData[f]["rtype"] == "r" then
- local vpercentr = math.ceil((maxPckTime-pckTime)*100/maxPckTime)
- pbar(cGUData[f]["x"]+75-cGlobalx,49-cGUData[f]["y"]-cGUData[f]["height"]-2,8,vpercentr,0x009945,0x444444,vpercentr.."% ",0xFFFFFF)
- end
- end
- end
- end
- local function target(x,y)
- if cTarget ~= 1 and not showTargetInfo then
- cTarget = 0
- end
- for f = 2, #cGUData do
- if clicked(x, y, cGUData[f]["x"]+75-cGlobalx, 49-cGUData[f]["y"]-2-cGUData[f]["height"], cGUData[f]["x"]+75-cGlobalx+cGUData[f]["width"], 49-cGUData[f]["y"]) then
- if cGUData[f]["living"] then
- cTarget = f
- console.debug("Выбрать цель","id:",tostring(cTarget),gameUnitData[cGUData[cTarget]["id"]]["name"])
- end
- end
- end
- end
- local fPauselist = {
- "Продолжить игру",
- "Инвентарь",
- "Умения персонажа",
- "Характеристика",
- "Текущие задания",
- "Выйти из игры"
- }
- local function fPause()
- buffer.square(1, 1, 30, 50, 0x9D9D9D, 0xFFFFFF, " ")
- buffer.text(13,2,0xFFFFFF,"Пауза")
- for f = 1, #fPauselist do
- buffer.square(1, 2+f*2, 30, 1, 0x838383, 0xFFFFFF, " ")
- buffer.text(math.max(math.floor((30/2)-(unicode.len(fPauselist[f])/2)),0),2+f*2,0xFFFFFF,fPauselist[f])
- end
- end
- local svxpbar = false
- local vshowEffDescr, sEffdx, sEffdy = 0, 1, 1
- local function playerCInfoBar(x,y)
- local isTrue = false
- buffer.square(x, y, 25, 5, 0x8C8C8C, 0xFFFFFF, " ")
- local fxpdt = tostring(cxp).."/"..tostring(mxp)
- local percent1 = math.floor(cGUData[1]["chp"]*100/cGUData[1]["mhp"])
- local percent2 = math.floor(cmp*100/mmp)
- local percent3 = math.floor(cxp*100/mxp*10)/10
- buffer.text(x+1, y, 0xFFFFFF, "Уровень "..cGUData[1]["level"])
- local tpbar1 = math.floor(cGUData[1]["chp"]).."/"..math.floor(cGUData[1]["mhp"])
- local tpbar2 = math.floor(cmp).."/"..math.floor(mmp)
- local tpbar3 = percent3.."% "
- if percent3 == 0 then tpbar3 = percent3..".0% " end
- pbar(x,y+1,25,percent1,0xFF0000,0x5B5B5B," ", 0xFFFFFF)
- buffer.text(math.max(math.floor((25/2)-(#tpbar1/2)),0),y+1,0xFFFFFF,tpbar1)
- pbar(x,y+2,25,percent2,0x0000FF,0x5B5B5B," ", 0xFFFFFF)
- buffer.text(math.max(math.floor((25/2)-(#tpbar2/2)),0),y+2,0xFFFFFF,tpbar2)
- pbar(x,y+3,25,percent3,0xFFFF00,0x5B5B5B," ", 0x333333)
- buffer.text(math.max(math.floor((25/2)-(#tpbar3/2)),0),y+3,0x333333,tpbar3)
- if svxpbar then buffer.text(x+25-#fxpdt, y+3, 0x4F4F4F, fxpdt) end
- for f = 1, math.min(#cGUData[1]["effects"],5) do
- buffer.square(x+f*3-3+1,y+5,1,1,gameEffectsData[cGUData[1]["effects"][f][1]]["i"][1],0xFFFFFF,gameEffectsData[cGUData[1]["effects"][f][1]]["i"][2])
- buffer.square(x+f*3-3+2,y+5,1,1,gameEffectsData[cGUData[1]["effects"][f][1]]["i"][3],0xFFFFFF,gameEffectsData[cGUData[1]["effects"][f][1]]["i"][4])
- end
- if vshowEffDescr ~= 0 then
- for g = 1, #cGUData[1]["effects"] do
- if cGUData[1]["effects"][g][1] == vshowEffDescr then
- isTrue = true
- break
- else
- isTrue = false
- vshowEffDescr = 0
- end
- end
- if isTrue then
- buffer.square(sEffdx,sEffdy,math.max(unicode.len(gameEffectsData[cGUData[1]["effects"][vshowEffDescr][1]]["name"]),unicode.len(gameEffectsData[cGUData[1]["effects"][vshowEffDescr][1]]["descr"])),2,0xA1A1A1,0xFFFFFF," ")
- buffer.text(sEffdx,sEffdy,0xEDEDED,gameEffectsData[cGUData[1]["effects"][vshowEffDescr][1]]["name"])
- buffer.text(sEffdx,sEffdy+1,0xCECECE,gameEffectsData[cGUData[1]["effects"][vshowEffDescr][1]]["descr"])
- end
- end
- end
- local function sTargetInfo(x,y)
- local sTInfoArray1 = {
- gameUnitData[cGUData[cTarget]["id"]]["name"],
- "Тип: "..unicode.sub(gameUnitData[cGUData[cTarget]["id"]]["wtype"],1,22),
- "Respawn: "..tostring(gameUnitData[cGUData[cTarget]["id"]]["vresp"]).." секунд",
- "ID: "..tostring(cGUData[cTarget]["id"]),
- }
- local sTInfoArray2 = {
- "Физ.атака: "..tostring(cGUData[cTarget]["phisatck"]),
- "Маг.атака: "..tostring(cGUData[cTarget]["magatck"]),
- "Физ.защита: "..tostring(cGUData[cTarget]["pdef"]),
- "Маг.защита: "..tostring(cGUData[cTarget]["magdef"]),
- }
- buffer.square(x, y, 25, 9, 0xABABAB, 0xFFFFFF, " ")
- for f = 1, #sTInfoArray1 do
- buffer.text(x+1,y+f-1,0xFFFFFF,tostring(sTInfoArray1[f]))
- end
- if cGUData[cTarget]["rtype"] ~= "f" then
- for f = 1, #sTInfoArray2 do
- buffer.text(x+1,y+f-1+#sTInfoArray1,0xFFFFFF,tostring(sTInfoArray2[f]))
- end
- end
- end
- local function targetCInfoBar(x,y)
- local bl = false
- buffer.square(x, y, 35, 5, 0x9B9B9B, 0xFFFFFF, " ")
- if cGUData[cTarget]["rtype"] == "e" or cGUData[cTarget]["rtype"] == "p" or cGUData[cTarget]["rtype"] == "m" then
- local chp, mhp = cGUData[cTarget]["chp"], cGUData[cTarget]["mhp"]
- local pbtext, lbtext = tostring(math.ceil(chp)).."/"..tostring(math.ceil(mhp)), "["..tostring(cGUData[cTarget]["level"]).."] "..gameUnitData[cGUData[cTarget]["id"]]["name"]
- local percent = math.ceil(chp*100/mhp)
- pbar(x,y+1,35,percent,0xFF0000,0x5B5B5B," ", 0xFFFFFF)
- pbar(x,y+2,35,percent,0xFF0000,0x5B5B5B," ", 0xFFFFFF)
- buffer.text(x + (math.max(math.floor((35 / 2) - (unicode.len(pbtext) / 2)), 0)),y+1,0xFFFFFF,pbtext)
- buffer.text(x + (math.max(math.floor((35 / 2) - (unicode.len(lbtext) / 2)), 0)), y+2, 0xFFFFFF, lbtext)
- bl = true
- elseif cGUData[cTarget]["rtype"] == "f" then
- local pntext, lbtext = gameUnitData[cGUData[cTarget]["id"]]["wtype"], gameUnitData[cGUData[cTarget]["id"]]["name"]
- buffer.text(x,y,0x727272,"НИП")
- buffer.text(x + (math.max(math.floor((35 / 2) - (unicode.len(lbtext) / 2)), 0)), y+1, 0xFFFFFF, lbtext)
- buffer.text(x + (math.max(math.floor((35 / 2) - (unicode.len(pntext) / 2)), 0)), y+2, 0x727272, pntext)
- bl = true
- elseif cGUData[cTarget]["rtype"] == "r" then
- buffer.text(x,y,0x727272,"Ресурс")
- local pntext = "Нажмите 'E' чтобы собрать"
- buffer.text(x + (math.max(math.floor((35 / 2) - (unicode.len(gameUnitData[cGUData[cTarget]["id"]]["name"]) / 2)), 0)), y+1, 0xFFFFFF, gameUnitData[cGUData[cTarget]["id"]]["name"])
- buffer.text(x + (math.max(math.floor((35 / 2) - (unicode.len(pntext) / 2)), 0)), y+2, 0x727272, pntext)
- bl = false
- end
- if bl then buffer.text(x+1,y+4,0xFFFFFF,"О персонаже") end
- for f = 1, math.min(#cGUData[cTarget]["effects"],10) do
- buffer.square(x+f*3-3+1,y+5,1,1,gameEffectsData[cGUData[cTarget]["effects"][f][1]]["i"][1],0xFFFFFF,gameEffectsData[cGUData[cTarget]["effects"][f][1]]["i"][2])
- buffer.square(x+f*3-3+2,y+5,1,1,gameEffectsData[cGUData[cTarget]["effects"][f][1]]["i"][3],0xFFFFFF,gameEffectsData[cGUData[cTarget]["effects"][f][1]]["i"][4])
- end
- if showTargetInfo then
- sTargetInfo(x+1,y+5)
- end
- end
- local vtskillUsingMsg, skillUsingMsg = 0, {}
- local function fSkillBar(x,y)
- buffer.square(x, y, 30, 5, 0x9B9B9B, 0xFFFFFF, " ")
- local sarray = {
- {c = 0x614251, t = "/2"},
- {c = 0x0000FF, t = "*3"},
- {c = 0x008500, t = "@4"},
- {c = 0x8600A0, t = "&5"},
- {c = 0xEE0000, t = "!6"},
- }
- for f = 1, #sarray do
- buffer.square(x+4+(f*5-5), y+1, 2, 1, sarray[f].c, 0xFFFFFF, " ")
- buffer.text(x+4+(f*5-5), y+1, 0xFFFFFF, sarray[f].t)
- buffer.text(x+4+(f*5-5), y+2, 0xFFFFFF, tostring(cUskills[f+1][2]))
- end
- if vtskillUsingMsg > 0 then buffer.text(x+1,y+4,0xC1C1C1,skillUsingMsg[#skillUsingMsg]) end
- end
- local function drawDialog(x,y)
- local sColor
- local isQnComp, isQcomp = false, false
- for f = 1, #cDialog do
- isQnComp = false
- if cDialog[#cDialog-f+1] ~= nil then
- if cDialog[#cDialog-f+1]["action"] == "qdialog" then
- for l = 1, #cUquests do
- if cUquests[l][1] == cDialog[#cDialog-f+1]["q"] and cUquests[l][3] == false then
- isQnComp = true
- break
- end
- end
- end
- if cDialog[#cDialog-f+1] ~= nil and cDialog[#cDialog-f+1]["action"] == "qdialog" then
- if isQnComp or gameQuestsData[cDialog[#cDialog-f+1]["q"]]["minlvl"] > cGUData[1]["level"] then
- table.remove(cDialog,#cDialog-f+1)
- end
- elseif cDialog[#cDialog-f+1]["action"] == "setWorld" and cGUData[1]["level"] < cDialog[#cDialog-f+1]["reqlvl"] then
- cDialog[#cDialog-f+1]["text"] = unicode.sub(cDialog[#cDialog-f+1]["text"],1,unicode.len(cDialog[#cDialog-f+1]["text"])-#tostring(cDialog[#cDialog-f+1]["reqlvl"])-2)
- cDialog[#cDialog-f+1]["text"] = cDialog[#cDialog-f+1]["text"].." "..cDialog[#cDialog-f+1]["reqlvl"].."+"
- end
- end
- end
- buffer.square(x, y, 50, 24, 0x9B9B9B, 0xFFFFFF, " ")
- buffer.square(x, y, 50, 1, 0x606060, 0xFFFFFF, " ")
- buffer.square(x+1, y+1, 48, 12, 0x7A7A7A, 0xFFFFFF, " ")
- buffer.square(x+1, y+14, 48, 9, 0x7A7A7A, 0xFFFFFF, " ")
- buffer.text(x+49,y,0xFFFFFF,"X")
- local text1 = gameUnitData[cGUData[cTarget]["id"]]["name"]
- buffer.text(x+(math.max(math.floor((50 / 2) - (unicode.len(text1) / 2)), 0)), y, 0xFFFFFF, text1)
- for f = 1, math.ceil(#cDialog["text"]/46) do
- buffer.text(x+2,y+1+f,0xFFFFFF,unicode.sub(cDialog["text"],1+f*46-46,f*46))
- end
- for f = 1, #cDialog do
- sColor = 0xFFFFFF
- isQnComp, isQcomp = false, false
- for l = 1, #cUquests do
- if cDialog[f]["action"] == "qdialog" then
- if cUquests[l][1] == cDialog[f]["q"] and not cUquests[l][3] then isQnComp = true end
- elseif cDialog[f]["action"] == "cmpquest" then isQcomp = true
- end
- end
- if isQnComp then
- sColor = 0x555555
- elseif isQcomp then
- sColor = 0x1AB235
- end
- buffer.text(x+2,y+14+f,sColor,cDialog[f]["text"])
- end
- end
- local function itemSubtypeToRus(subtype)
- local massiv = {
- ["helmet"] = "Шлем",
- ["bodywear"] = "Броня",
- ["pants"] = "Штаны",
- ["footwear"] = "Сапоги",
- ["pendant"] = "Кулон",
- ["sword"] = "Меч",
- ["spear"] = "Копье",
- ["axe"] = "Короткая секира",
- }
- return massiv[subtype]
- end
- local invTItem = 0
- local invcTItem, invcTargetItem, showItemData = 0, 0, false
- local invIdx, invIdy = 1, 1
- local function getItemInfoWColor(id)
- local info = {}
- local function giiwcAdd(t,c) table.insert(info,{tostring(t),c}) end
- local itemtype, itemsubtype = gameItemData[id]["type"], gameItemData[id]["subtype"]
- giiwcAdd(gameItemData[id]["name"], gameItemData[id]["ncolor"])
- if itemtype == "armor" or itemtype == "weapon" then
- giiwcAdd(lang(itemSubtypeToRus(itemsubtype)), 0xBCBCBC)
- giiwcAdd(lang("Уровень").." "..tostring(gameItemData[id]["level"]), 0xFFFFFF)
- end
- if itemtype == "weapon" then
- giiwcAdd(lang("Дальность атаки:").." "..gameItemData[id]["props"]["atds"], 0xEFEFEF)
- end
- if itemtype == "item" and itemsubtype == "res" then
- giiwcAdd(lang("Уровень материала").." "..tostring(gameItemData[id]["level"]), 0xFFFFFF)
- end
- if itemtype == "armor" then
- if gameItemData[id]["props"]["pdef"] ~= 0 then giiwcAdd("Защита +"..tostring(gameItemData[id]["props"]["pdef"]), 0xFFFFFF) end
- if gameItemData[id]["props"]["magdef"] ~= 0 then giiwcAdd("Магическая защита +"..tostring(gameItemData[id]["props"]["magdef"]), 0xFFFFFF) end
- elseif itemtype == "weapon" then
- if gameItemData[id]["props"]["phisat"] ~= 0 then giiwcAdd("Физическая атака "..tostring(gameItemData[id]["props"]["phisat"]), 0xFFFFFF) end
- if gameItemData[id]["props"]["magat"] ~= 0 then giiwcAdd("Магическая атака "..tostring(gameItemData[id]["props"]["magat"]), 0xFFFFFF) end
- end
- if itemtype == "armor" or itemtype == "weapon" or itemtype == "potion" then
- if gameItemData[id]["subtype"] == "health" then
- giiwcAdd("Восстановить "..tostring(gameEffectsData[1]["val"][gameItemData[id]["level"]]).." ед. здоровья за 10 секунд", 0xFFFFFF)
- elseif gameItemData[id]["subtype"] == "mana" then
- giiwcAdd("Восстановить "..tostring(gameEffectsData[2]["val"][gameItemData[id]["level"]]).." ед. маны за 10 секунд", 0xFFFFFF)
- end
- if gameItemData[id]["reqlvl"] > cGUData[1]["level"] then
- giiwcAdd(lang("Требуемый уровень:").." "..gameItemData[id]["reqlvl"], 0xFF0000)
- else
- giiwcAdd(lang("Требуемый уровень:").." "..gameItemData[id]["reqlvl"], 0xFFFFFF)
- end
- if itemtype == "armor" or itemtype == "weapon" then
- local spisok1 = {
- {"hp+","Здоровье"},
- {"sur+","Выживаемость"},
- {"str+","Сила"},
- {"int+","Интеллект"},
- {"pdm+","Атака"},
- {"mdm+","Магическая атака"},
- }
- for e = 1, #spisok1 do
- if gameItemData[id]["props"][spisok1[e][1]] ~= nil and gameItemData[id]["props"][spisok1[e][1]] ~= 0 then
- giiwcAdd(lang(spisok1[e][2]).." + "..gameItemData[id]["props"][spisok1[e][1]], 0x0044ee)
- end
- end
- end
- end
- if gameItemData[id]["description"] ~= "" then
- for f = 1, math.ceil(unicode.len(gameItemData[id]["description"])/35) do
- giiwcAdd(unicode.sub(gameItemData[id]["description"],1+f*35-35,f*35), 0xBCBCBC)
- end
- end
- local v = ""
- if invTItem > 1 then v = " ("..tostring(gameItemData[id]["cost"]*invTItem)..")" end
- giiwcAdd(lang("Цена").." "..tostring(gameItemData[id]["cost"])..v, 0xFFFFFF)
- return info
- end
- local function drawInventory(x,y)
- buffer.square(x, y, 160, 50, 0x9B9B9B, 0xFFFFFF, " ")
- buffer.square(x, y, 160, 1, 0x525252, 0xFFFFFF, " ")
- buffer.square(x, y+49, 160, 1, 0x525252, 0xFFFFFF, " ")
- buffer.square(x, y+1, 105, 45, 0x767676, 0xFFFFFF, " ")
- for f = 1, 5 do
- buffer.square(x, y+1+(f*11-11), 105, 1, 0x4A4A4A, 0xFFFFFF, " ")
- end
- for f = 1, 6 do
- buffer.square(x+(f*21-21), y+1, 1, 45, 0x4A4A4A, 0xFFFFFF, " ")
- end
- buffer.image(x+105, y+1, image.load(cpath.."image/gGrid.pic"))
- buffer.text(x+1,y,0xC4C4C4,"Монеты:".." "..tostring(cCoins))
- buffer.text(x+75,y,0xFFFFFF,"Инвентарь")
- buffer.text(x+152,y,0xFFFFFF,"Закрыть")
- local xps, yps
- for f = 1, 4 do
- for i = 1, 5 do
- xps, yps = x+1+i*21-21, y+2+f*11-11
- local formula = (f-1)*5+i
- if inventory["bag"][formula][1] ~= 0 and inventory["bag"][formula][2] ~= 0 then
- buffer.image(xps, yps, image.load(cpath.."itempic/"..aItemIconsSpr[gameItemData[inventory["bag"][formula][1]]["icon"]]..".pic"))
- if inventory["bag"][formula][2] > 1 then
- buffer.square(xps, yps+9, #tostring(inventory["bag"][formula][2]), 1, 0x4A4A4A, 0xFFFFFF, " ")
- buffer.text(xps,yps+9,0xFFFFFF,tostring(inventory["bag"][formula][2]))
- end
- end
- end
- end
- local wItemTypes = {
- "helmet",
- "bodywear",
- "pants",
- "weapon",
- "footwear",
- "pendant",
- }
- for f = 1, 3 do
- for i = 1, 2 do
- xps, yps = 107+i*21-21, 3+f*11-11
- if inventory["weared"][wItemTypes[(f-1)*2+i]] ~= 0 then
- buffer.image(xps, yps, image.load(cpath.."itempic/"..aItemIconsSpr[gameItemData[inventory["weared"][wItemTypes[(f-1)*2+i]]]["icon"]]..".pic"))
- end
- end
- end
- buffer.text(2,48,0x444444,sMSG3)
- local textRemoveItem = "Выбросить предмет(ы)"
- if showItemData and invcTItem ~= 0 then
- local itemInfo = getItemInfoWColor(invcTItem)
- local hn, w, h = 0, 0, #itemInfo
- for f = 1, #itemInfo do
- if unicode.len(itemInfo[f][1]) > w then w = unicode.len(itemInfo[f][1]) end
- end
- buffer.square(math.min(invIdx,160-w), math.min(invIdy,50-h), w, h, 0x7E7E7E, 0xFFFFFF, " ")
- for f = 1, #itemInfo do
- buffer.text(math.min(invIdx,160-w),math.min(invIdy+f-1,50-h+f),itemInfo[f][2],itemInfo[f][1])
- end
- buffer.square(x+1,y+46,unicode.len(textRemoveItem),1,0x3c539e, 0xFFFFFF," ")
- buffer.text(x+1,y+46,0xFEFEFE,textRemoveItem)
- end
- end
- local function unicodeframe(x,y,w,h,c)
- buffer.text(x,y,c,"┌"..string.rep("─",w-2).."┐")
- for f = 1, h-2 do
- buffer.text(x,y+f,c,"│")
- buffer.text(x+w-1,y+f,c,"│")
- end
- buffer.text(x,y+h-1,c,"└"..string.rep("─",w-2).."┘")
- end
- local tradew = {
- twindow = 0,
- titem = 0,
- titemcount = 1,
- sect = 1,
- tScrl = 1
- }
- local smw, smh = 50, 15
- local function tradeWindow(x,y)
- buffer.square(x, y, 160, 50, 0x9B9B9B, 0xFFFFFF, " ")
- buffer.square(x, y, 160, 1, 0x525252, 0xFFFFFF, " ")
- buffer.square(x, y+1, 160, 3, 0x747474, 0xFFFFFF, " ")
- local hclr
- local t = "Торговля"
- buffer.text(math.max(80-(unicode.len(t)/2), 0), y, 0xFFFFFF, t)
- buffer.text(x+1,y+3,0xC2C2C2,"Наименование")
- buffer.text(x+65,y+3,0xC2C2C2,"Цена за единицу")
- buffer.text(x+152,y,0xFFFFFF,"Закрыть")
- buffer.text(x+1,y+2,0xFFFFFF,"Монеты "..cCoins)
- local massiv = gameTradew[tradew.twindow][tradew.sect]
- local t1
- for f = 1, #gameTradew[tradew.twindow] do
- t1 = unicode.sub(gameTradew[tradew.twindow][f]["section_name"],1,25)
- if tradew.sect == f then hclr = 0x525252 else hclr = 0x606060 end
- buffer.square(x+1+f*26-26, y+1, 25, 1, hclr, 0xFFFFFF, " ")
- buffer.text(x+1+f*26-26, y+1, 0xCCCCCC, t1)
- end
- for f = 1, math.min(#massiv, 24) do
- if f+4*tradew.tScrl-4 == tradew.titem then buffer.square(x+1,y+4+f*2-2, 160, 3, 0x818181, 0xFFFFFF, " ") end
- end
- for f = 1, math.min(#massiv+1, 24) do
- buffer.text(x+1,y+4+f*2-2,0xFFFFFF,string.rep("─",158))
- end
- for f = 1, math.min(#massiv, 24) do
- buffer.text(x+1,y+4+f*2-1,0xFFFFFF,gameItemData[massiv[f+4*tradew.tScrl-4]["item"]]["name"])
- buffer.text(x+65,y+4+f*2-1,0xFFFFFF,tostring(massiv[f+4*tradew.tScrl-4]["cost"]))
- end
- local clr, smx, smy, tn = 0xCCCCCC
- tn = "Купить"
- if tradew.titem ~= 0 then
- smx, smy = math.floor(80-smw/2), math.floor(25-smh/2)
- buffer.square(smx, smy, smw, smh, 0x828282, 0xFFFFFF, " ")
- unicodeframe(smx, smy, smw, smh, 0x4c4c4c)
- buffer.square(smx-23, smy, 22, 12, 0x828282, 0xFFFFFF, " ")
- buffer.image(smx-22, smy+1, image.load(cpath.."itempic/"..aItemIconsSpr[gameItemData[massiv[tradew.titem]["item"]]["icon"]]..".pic"))
- buffer.text(smx+smw-2, smy, 0x4c4c4c, "X")
- buffer.text(smx+(smw/2-unicode.len(gameItemData[massiv[tradew.titem]["item"]]["name"])/2), smy+1, clr, gameItemData[massiv[tradew.titem]["item"]]["name"])
- buffer.text(smx+1,smy+2, clr, "Покупка предмета")
- buffer.text(smx+1,smy+3, clr, "Количество:")
- buffer.square(smx+13, smy+3, #tostring(tradew.titemcount)+4, 1, 0x616161, 0xFFFFFF, " ")
- buffer.text(smx+13,smy+3, clr, "+ "..tradew.titemcount.." -")
- buffer.text(smx+1,smy+4, clr, "Цена: "..massiv[tradew.titem]["cost"])
- local td
- if tradew.titemcount*massiv[tradew.titem]["cost"] <= cCoins then td = clr else td = 0xb71202 end
- buffer.text(smx+1,smy+5, td, "Сумма: "..tostring(tradew.titemcount*massiv[tradew.titem]["cost"]))
- buffer.square(smx, smy+smh, smw, 3, 0x0054cb5, 0xFFFFFF, " ")
- buffer.text(smx+(smw/2-unicode.len(tn)/2), smy+smh+1, clr, tn)
- end
- end
- local cCnsScroll = 1
- local function gameConsole(x,y)
- buffer.square(x, y, 60, 35, 0xABABAB, 0xFFFFFF, " ")
- buffer.square(x, y, 60, 1, 0x525252, 0xFFFFFF, " ")
- buffer.square(x+1, y+1, 58, 31, 0x1A1A1A, 0xFFFFFF, " ")
- buffer.square(x+1, y+33, 58, 1, 0x1A1A1A, 0xFFFFFF, " ")
- local bColor, bSub
- local text1 = "debug"
- buffer.text(x+(math.max(math.floor((60 / 2) - (unicode.len(text1) / 2)), 0)), y, 0xFFFFFF, text1)
- buffer.text(x+59,y,0xFFFFFF,"X")
- for f = 1, math.min(#consDataR,28) do
- if consDataR[f+(cCnsScroll*4-4)] then
- if unicode.sub(consDataR[f+(cCnsScroll*4-4)],1,2) == "!/" then
- bColor = 0xFF0000
- bSub = 3
- else
- bColor = 0xFFFFFF
- bSub = 1
- end
- buffer.text(x+2,y+2+f,bColor,unicode.sub(consDataR[f+(cCnsScroll*4-4)],bSub,56))
- end
- end
- end
- local function remFirstSmfromString(str,cs)
- local s = unicode.sub(str,1,1)
- if s == cs then
- return unicode.sub(str,2,#str)
- end
- return str
- end
- local targetQuest = 0
- local function questsList(x,y)
- buffer.square(x, y, 100, 25, 0xABABAB, 0xFFFFFF, " ")
- buffer.square(x, y, 100, 1, 0x525252, 0xFFFFFF, " ")
- buffer.text(x+45,y,0xFFFFFF,"Задания")
- buffer.text(x+92,y,0xFFFFFF,"Закрыть")
- buffer.square(x+2, y+2, 29, 22, 0x7A7A7A, 0xFFFFFF, " ")
- buffer.square(x+32, y+2, 66, 22, 0x7A7A7A, 0xFFFFFF, " ")
- for f = 1, math.min(#cUquests,20) do
- if cUquests[f][3] then buffer.text(x+3,y+3+f,0x00C222,"→") end
- buffer.text(x+4,y+3+f,0xDDDDDD,unicode.sub(gameQuestsData[cUquests[f][1]]["name"],1,28))
- end
- if targetQuest > 0 and cUquests[targetQuest] ~= nil then
- local qDeskList = {}
- local dstr
- for i = 1, math.floor(#gameQuestsData[cUquests[targetQuest][1]]["descr"]/60) do
- dstr = remFirstSmfromString(remFirstSmfromString(unicode.sub(gameQuestsData[cUquests[targetQuest][1]]["descr"],1+(60*i-60),60*i),",")," ")
- table.insert(qDeskList, dstr)
- end
- local qInfoList = {
- "Награда:",
- "Монеты "..tostring(gameQuestsData[cUquests[targetQuest][1]]["qreward"]["coins"]),
- "Опыт "..tostring(gameQuestsData[cUquests[targetQuest][1]]["qreward"]["xp"]),
- }
- table.insert(qInfoList,1,"Описание:")
- for i = 1, #qDeskList do
- table.insert(qInfoList,i+1,qDeskList[i])
- end
- if gameQuestsData[cUquests[targetQuest][1]]["type"] == "k" then
- table.insert(qInfoList,1,"Уничтожить: "..gameUnitData[gameQuestsData[cUquests[targetQuest][1]]["targ"]]["name"].." ("..cUquests[targetQuest][2].."/"..gameQuestsData[cUquests[targetQuest][1]]["num"]..")")
- end
- if gameQuestsData[cUquests[targetQuest][1]]["qreward"]["item"] ~= nil then
- table.insert(qInfoList,"Предмет:")
- for o = 1, #gameQuestsData[cUquests[targetQuest][1]]["qreward"]["item"] do
- table.insert(qInfoList,unicode.sub(gameItemData[gameQuestsData[cUquests[targetQuest][1]]["qreward"]["item"][o][1]]["name"].." ("..tostring(gameQuestsData[cUquests[targetQuest][1]]["qreward"]["item"][o][2])..")",1,45))
- end
- end
- buffer.text(x+33,y+3,0xFFFFFF,unicode.sub(gameQuestsData[cUquests[targetQuest][1]]["name"],1,60))
- for f = 1, #qInfoList do
- buffer.text(x+33,y+3+f,0xFFFFFF,qInfoList[f])
- end
- end
- end
- local pstatspntrs={x=0,y=0}
- local chPointsAss = {0,0,0,0} -- не надо менять этот массив, читеры!
- local function playerStats(x,y)
- buffer.square(x, y, 100, 35, 0xABABAB, 0xFFFFFF, " ")
- buffer.square(x, y, 100, 1, 0x525252, 0xFFFFFF, " ")
- local someText = "Персонаж"
- buffer.text(x+(math.max(50-(unicode.len(someText)/2),0)),y,0xFFFFFF,someText)
- buffer.text(x+92,y,0xFFFFFF,"Закрыть")
- local info1 = {
- "Имя персонажа: "..gameUnitData[cGUData[1]["id"]]["name"],
- "Уровень: "..cGUData[1]["level"],
- "Здоровье: "..tostring(math.floor(cGUData[1]["chp"]*10)/10).."/"..math.floor(cGUData[1]["mhp"]),
- "Мана: "..tostring(math.floor(cmp*10)/10).."/"..math.floor(mmp),
- "Опыт: "..cxp.."/"..mxp.." ("..tostring(math.floor(cxp*100/mxp*10)/10).."%)",
- "Физическая атака: "..cGUData[1]["phisatck"]+vaddsPnts.vPdm,
- "Магическая атака: "..cGUData[1]["magatck"]+vaddsPnts.vMdm,
- "Физическая защита: "..cGUData[1]["pdef"],
- "Магическая защита: "..cGUData[1]["magdef"],
- }
- for f = 1, #info1 do
- buffer.text(x+3,y+1+f,0xFFFFFF,info1[f])
- end
- pstatspntrs.x, pstatspntrs.y = x+3, y+14
- buffer.square(x+3, y+14, 37, 4, 0x898989, 0xFFFFFF, " ")
- buffer.text(x+4,y+14,0xFFFFFF,"Очков для распределния "..charPoints)
- buffer.text(x+4,y+15,0xEEEEEE,"Интеллект")
- buffer.text(x+17,y+15,0xCECECE,tostring(intelligence+chPointsAss[1]+vaddsPnts.vInt))
- buffer.text(x+4,y+16,0xEEEEEE,"Сила")
- buffer.text(x+17,y+16,0xCECECE,tostring(strength+chPointsAss[2]+vaddsPnts.vStr))
- buffer.text(x+4,y+17,0xEEEEEE,"Выносливость")
- buffer.text(x+17,y+17,0xCECECE,tostring(survivability+chPointsAss[3]+vaddsPnts.vSur))
- for f = 1, 3 do
- buffer.square(x+20, y+14+f, 3, 1, 0x727272, 0xFFFFFF, " ")
- buffer.text(x+21,y+14+f,0xEEEEEE,"+")
- buffer.square(x+24, y+14+f, 3, 1, 0x727272, 0xFFFFFF, " ")
- buffer.text(x+25,y+14+f,0xEEEEEE,"-")
- end
- buffer.square(x+28, y+15, 9, 1, 0x737373, 0xFFFFFF, " ")
- buffer.text(x+28,y+15,0xEEEEEE,"→Принять")
- buffer.square(x+28, y+17, 9, 1, 0x737373, 0xFFFFFF, " ")
- buffer.text(x+28,y+17,0xEEEEEE,"×отменить")
- end
- local function killUnitWithoutAnyLoot(id)
- cGUData[id]["living"] = false
- cGUData[id]["resptime"] = gameUnitData[cGUData[id]["id"]]["vresp"]
- end
- local function getRandSeq(massiv)
- -- эта функция перемешивает значения переменной (костыль)
- local new = {}
- for e = 1, #massiv do
- new[e] = "_n"
- end
- local nrandom
- for f = 1, #massiv do
- nrandom = math.random(1,#massiv)
- table.insert(new,nrandom,massiv[f])
- end
- for e = 1, #new do if new[#new-e+1] == "_n" then table.remove(new,#new-e+1) end end
- return new
- end
- local function makeDamage(id, damage)
- if cGUData[id]["chp"] > damage then
- cGUData[id]["attPlayer"] = true
- cGUData[id]["chp"] = cGUData[id]["chp"] - damage
- console.debug("Урон нанесен персонажу",gameUnitData[cGUData[id]["id"]]["name"],tostring(damage):sub(1,5))
- elseif cGUData[id]["chp"] <= damage then
- cGUData[id]["effects"] = {}
- cGUData[id]["attPlayer"] = false
- console.debug("Урон нанесен персонажу",gameUnitData[cGUData[id]["id"]]["name"],tostring(damage):sub(1,5))
- cGUData[id]["chp"] = 0
- cGUData[id]["living"] = false
- cGUData[id]["resptime"] = gameUnitData[cGUData[id]["id"]]["vresp"]
- local expr = math.ceil(gameUnitData[cGUData[id]["id"]]["loot"]["exp"]+math.random(-gameUnitData[cGUData[id]["id"]]["loot"]["exp"]*0.1,gameUnitData[cGUData[id]["id"]]["loot"]["exp"]*0.1))
- addXP(expr)
- for f = 1, #cUquests do
- if cGUData[id]["id"] == gameQuestsData[cUquests[f][1]]["targ"] and cUquests[f][3] == false then
- if cUquests[f][2] + 1 < gameQuestsData[cUquests[f][1]]["num"] then
- cUquests[f][2] = cUquests[f][2] + 1
- else
- gameQuestsData[cUquests[f][1]]["comp"] = true
- cUquests[f][2] = gameQuestsData[cUquests[f][1]]["num"]
- cUquests[f][3] = true
- addsmsg1("Задание "..gameQuestsData[cUquests[f][1]]["name"].." выполнено!")
- end
- end
- end
- local coinsLoot = gameUnitData[cGUData[id]["id"]]["loot"]["coins"]
- local giveCoins = math.ceil(math.random(coinsLoot-coinsLoot*0.5,coinsLoot+coinsLoot*0.1))
- cCoins = cCoins + giveCoins
- local itemLoot = getRandSeq(gameUnitData[cGUData[id]["id"]]["loot"]["items"])
- local nitemid
- for f = 1, #itemLoot do
- if itemLoot[f][1] ~= nil and 1000-itemLoot[f][2]*10 <= math.random(1,1000) then
- if math.random(1,15) == 5 then itemLoot[f][1] = createNewItem(itemLoot[f][1]) end
- addItem(itemLoot[f][1],1)
- console.debug("Получен предмет "..gameItemData[itemLoot[f][1]]["name"])
- addsmsg1("Получен предмет "..gameItemData[itemLoot[f][1]]["name"])
- break
- end
- end
- cGUData[id]["resptime"] = gameUnitData[cGUData[id]["id"]]["vresp"]
- console.debug("опыт +",expr,"монеты +",giveCoins)
- if id == cTarget then cTarget = 0 end
- showTargetInfo = false
- end
- end
- local function playerGetDamage(fromID)
- if cGUData[fromID]["x"] > cGUData[1]["x"] then
- cGUData[fromID]["spos"] = "l"
- else
- cGUData[fromID]["spos"] = "r"
- end
- local patck = cGUData[fromID]["phisatck"]
- local dmgRed = cGUData[1]["pdef"]/(cGUData[1]["pdef"]+cGUData[fromID]["level"]*85)
- local damage = math.max(math.random(patck-patck*0.5,patck+patck*0.5)*(1-dmgRed),0.01)
- if cTarget == 0 then cTarget = fromID end
- if damage < cGUData[1]["chp"] then
- cGUData[1]["chp"] = cGUData[1]["chp"] - damage
- else
- cGUData[1]["living"] = false
- end
- return damage
- end
- local function useSkill(skill)
- local cskill = cUskills[skill][1]
- local damage = 0
- if gameSkillsData[cskill]["type"] == "attack" and cGUData[cTarget]["rtype"] ~= "p" and cGUData[cTarget]["rtype"] ~= "f" and cGUData[cTarget]["rtype"] ~= "r" then
- if cGUData[cTarget]["x"] > cGUData[1]["x"] then
- cGUData[1]["spos"] = "r"
- else
- cGUData[1]["spos"] = "l"
- end
- local physDefRedu = cGUData[cTarget]["pdef"]/(cGUData[cTarget]["pdef"]+cGUData[1]["level"]*85)
- local magDefRedu = cGUData[cTarget]["magdef"]/(cGUData[cTarget]["magdef"]+cGUData[1]["level"]*85)
- if gameSkillsData[cskill]["typedm"] == "p" then
- damage = math.max((cGUData[1]["phisatck"]+math.random(gameSkillsData[cskill]["mindamage"][cUskills[skill][3]],gameSkillsData[cskill]["maxdamage"][cUskills[skill][3]]))*(1-physDefRedu),0.1)
- elseif gameSkillsData[cskill]["typedm"] == "m" then
- damage = math.max((cGUData[1]["magatck"]+math.random(gameSkillsData[cskill]["mindamage"][cUskills[skill][3]],gameSkillsData[cskill]["maxdamage"][cUskills[skill][3]]))*(1-magDefRedu),0.1)
- end
- if cmp >= gameSkillsData[cskill]["manacost"][cUskills[skill][3]] and cUskills[skill][2] == 0 and getDistanceToId(1,cTarget) <= vAttackDistance+gameSkillsData[cskill]["distance"] then
- cmp = cmp - gameSkillsData[cskill]["manacost"][cUskills[skill][3]]
- makeDamage(cTarget, damage)
- if gameSkillsData[cskill]["eff"] ~= nil then addUnitEffect(cTarget,gameSkillsData[cskill]["eff"],cUskills[skill][3]) end
- cUskills[skill][2] = gameSkillsData[cskill]["reloading"]
- vtskillUsingMsg = 3
- table.insert(skillUsingMsg,gameSkillsData[cskill]["name"])
- end
- elseif gameSkillsData[cskill]["type"] == "buff" and cmp >= gameSkillsData[cskill]["manacost"][cUskills[skill][3]] and cUskills[skill][2] == 0 then
- cmp = cmp - gameSkillsData[cskill]["manacost"][cUskills[skill][3]]
- if gameSkillsData[cskill]["eff"] ~= nil then addUnitEffect(1,gameSkillsData[cskill]["eff"],cUskills[skill][3]) end
- end
- end
- local sram
- local function dmain()
- if cWindowTrd ~= "inventory" and cWindowTrd ~= "tradeWindow" then
- world[world.current].draw()
- if cGUData[1]["spos"] == "r" then buffer.image(playerSprPicPos, 34, image.load(cpath.."sprpic/"..cGUData[1]["image"]..".pic"))
- else buffer.image(playerSprPicPos, 34, image.flipHorizontal(image.load(cpath.."sprpic/"..cGUData[1]["image"]..".pic")))
- end
- drawCDataUnit()
- if cWindowTrd ~= "screen_save" then
- playerCInfoBar(1,1)
- if cTarget ~= 0 then targetCInfoBar(60,1) end
- fSkillBar(110,1)
- buffer.text(156,2,0xFFFFFF,"█ █")
- buffer.text(156,3,0xFFFFFF,"█ █")
- if smsg1time > 0 then
- buffer.text(9,49,0x929292,">"..sMSG1[#sMSG1-1])
- buffer.text(9,50,0xC7C7C7,">"..sMSG1[#sMSG1])
- end
- if smsg2time > 0 then
- buffer.text(80-unicode.len(sMSG2[#sMSG2])/2,12,0xD3D3D3,sMSG2[#sMSG2])
- end
- end
- end
- if cWindowTrd == "pause" then
- fPause()
- elseif cWindowTrd == "inventory" then
- drawInventory(1,1)
- elseif cWindowTrd == "dialog" then
- drawDialog(12,11)
- elseif cWindowTrd == "quests" then
- questsList(30,15)
- elseif cWindowTrd == "console" then
- gameConsole(50,10)
- elseif cWindowTrd == "pstats" then
- playerStats(30,8)
- elseif cWindowTrd == "tradeWindow" then
- tradeWindow(1,1)
- end
- if #cUquests > 0 and cUquests[1][3] == true then buffer.text(50,50,0xFFFFFF,"#### quest 1 true") end
- buffer.text(1,50,0xFFFFFF,"fps: "..tostring(cfps))
- sram = tostring(math.floor((computer.totalMemory()-computer.freeMemory())/1024)).." KB/"..tostring(math.ceil(computer.totalMemory()/1048576*10)/10).." MB"
- buffer.text(160-#sram,50,0xC7C7C7,sram)
- buffer.draw()
- end
- local fPauseMenuAction = {
- [1]=function()
- cWindowTrd = nil
- paused = false
- end,
- [2]=function()
- cWindowTrd = "inventory"
- end,
- [3]=function()
- end,
- [4]=function()
- cWindowTrd = "pstats"
- end,
- [5]=function()
- cWindowTrd = "quests"
- end,
- [6]=function()
- ingame = false
- end,
- }
- loadWorld(world.current)
- playerRefreshVar()
- cGUData[1]["chp"] = cGUData[1]["mhp"]
- cmp = mmp
- dmain()
- local uMoveRef = 1
- local healthReg, manaReg
- local function functionPS()
- local value, duration, efftype
- local itemLootarray
- while ingame do
- cfps = gamefps
- gamefps = 0
- if not paused then
- if cTarget ~= 0 and getDistanceToId(1,cTarget) > 99 then cTarget = 0 end
- playerRefreshVar()
- uMoveRef = uMoveRef - 1
- if vtskillUsingMsg > 0 then vtskillUsingMsg = vtskillUsingMsg - 1 end
- manaReg = math.min(0.26+(cGUData[1]["level"]-1)*0.015,2)
- healthReg = math.min(0.08+(cGUData[1]["level"]-1)*0.008,1)
- for f = 1, #cUskills do
- if cUskills[f][1] > 0 and cUskills[f][2] > 0 then
- cUskills[f][2] = cUskills[f][2] - 1
- end
- end
- if cGUData[1]["living"] then
- -- восстановление маны персонажа
- if cmp < mmp - manaReg then
- cmp = cmp + manaReg
- else
- cmp = mmp
- end
- -- восстановление здоровья персонажа
- if cGUData[1]["chp"] < cGUData[1]["mhp"] - healthReg then
- cGUData[1]["chp"] = cGUData[1]["chp"] + healthReg
- else
- cGUData[1]["chp"] = cGUData[1]["mhp"]
- end
- end
- for f = 2, #cGUData do
- -- респавн юнитов
- if not cGUData[f]["living"] and cGUData[f]["resptime"] > 0 then
- cGUData[f]["resptime"] = cGUData[f]["resptime"] - 1
- end
- if not cGUData[f]["living"] and cGUData[f]["resptime"] == 0 then
- cGUData[f]["chp"] = cGUData[f]["mhp"]
- cGUData[f]["x"] = cGUData[f]["sx"]
- cGUData[f]["living"] = true
- end
- -- рандомное движение мобов
- if getDistanceToId(1,f) <= 320 and cGUData[f]["rtype"] == "e" and cGUData[f]["living"] and math.random(1,3) == 3 and uMoveRef == 0 then
- cGUData[f]["mx"] = cGUData[f]["sx"] + math.random(-16, 16)
- end
- if getDistanceToId(1,f) <= 140 and cGUData[f]["x"] ~= cGUData[f]["mx"] then
- movetoward(f, cGUData[f]["mx"], 100, 1)
- end
- -- теперь мобы могут бить вашего персонажа >:D
- if cGUData[f]["living"] and getDistanceToId(1,f) <= 60 and cGUData[f]["attPlayer"] == true then
- if getDistanceToId(1,f) > gameUnitData[cGUData[f]["id"]]["atds"] then
- if cGUData[f]["x"] > cGUData[1]["x"] then
- cGUData[f]["spos"] = "l"
- cGUData[f]["mx"] = cGUData[1]["x"]+cGUData[1]["width"]+gameUnitData[cGUData[f]["id"]]["atds"]
- else
- cGUData[f]["spos"] = "r"
- cGUData[f]["mx"] = cGUData[1]["x"]-gameUnitData[cGUData[f]["id"]]["atds"]
- end
- else
- cGUData[f]["mx"] = cGUData[f]["x"]
- playerGetDamage(f)
- end
- end
- if cGUData[f]["living"] and cGUData[f]["attPlayer"] == true and getDistanceToId(1,f) > 60 then
- cGUData[f]["attPlayer"] = false
- cGUData[f]["mx"] = cGUData[f]["sx"]
- end
- if not cGUData[f]["living"] and cGUData[f]["attPlayer"] and cGUData[f]["agr"] == true and getDistanceToId(1,f) <= cGUData[f]["atds"]*2 then
- cGUData[f]["attPlayer"] = true
- end
- end
- -- обслуживание всех эффектов на всех объектах
- for f = 1, #cGUData do
- for eff = 1, #cGUData[f]["effects"] do
- if cGUData[f]["living"] and cGUData[f]["effects"][#cGUData[f]["effects"]-eff+1] ~= nil then
- value = gameEffectsData[cGUData[f]["effects"][#cGUData[f]["effects"]-eff+1][1]]["val"][cGUData[f]["effects"][#cGUData[f]["effects"]-eff+1][3]]
- duration = gameEffectsData[cGUData[f]["effects"][#cGUData[f]["effects"]-eff+1][1]]["dur"][cGUData[f]["effects"][#cGUData[f]["effects"]-eff+1][3]]
- efftype = gameEffectsData[cGUData[f]["effects"][#cGUData[f]["effects"]-eff+1][1]]["type"]
- if efftype == "hpi" then
- if cGUData[f]["chp"] + value/duration < cGUData[f]["mhp"] then
- cGUData[f]["chp"] = cGUData[f]["chp"] + value/duration
- else cGUData[f]["chp"] = cGUData[f]["mhp"]
- end
- elseif efftype == "mpi" then
- if cmp + value/duration < mmp then
- cmp = cmp + value/duration
- else cmp = mmp
- end
- elseif efftype == "hpd" then
- makeDamage(f,value/duration)
- elseif efftype == "pdfi%" then
- cGUData[1]["pdef"] = cGUData[1]["pdef"]+math.ceil(value/100*cGUData[1]["pdef"])
- end
- if cGUData[f]["effects"][#cGUData[f]["effects"]-eff+1] ~= nil then
- cGUData[f]["effects"][#cGUData[f]["effects"]-eff+1][2] = cGUData[f]["effects"][#cGUData[f]["effects"]-eff+1][2] - 1
- end
- if cGUData[f]["effects"][#cGUData[f]["effects"]-eff+1][2] == 0 then
- vshowEffDescr = 0
- table.remove(cGUData[f]["effects"],#cGUData[f]["effects"]-eff+1)
- end
- end
- end
- end
- ------------------------------------------------
- if smsg1time > 0 then
- smsg1time = smsg1time - 1
- end
- if smsg2time > 0 then
- smsg2time = smsg2time - 1
- end
- if pickingUp then
- cGUData[1]["mx"] = cGUData[1]["x"]
- pckTime = pckTime - 1
- end
- if pickingUp and pckTime == 0 then
- cGUData[1]["image"] = gameUnitData[1]["image"]
- pickingUp = false
- itemLootarray = getRandSeq(gameUnitData[cGUData[pckTarget]["id"]]["items"])
- for item = 1, #itemLootarray do
- if itemLootarray[item][1] ~= nil and 1000-itemLootarray[item][2]*10 <= math.random(1,1000) then
- if math.random(1,15) == 5 then itemLootarray[item][1] = createNewItem(itemLootarray[item][1]) end
- addItem(itemLootarray[item][1],1)
- console.debug("Получен предмет "..gameItemData[itemLootarray[item][1]]["name"])
- addsmsg1("Получен предмет "..gameItemData[itemLootarray[item][1]]["name"])
- break
- end
- end
- addXP(gameUnitData[cGUData[pckTarget]["id"]]["exp"])
- cCoins = cCoins + gameUnitData[cGUData[pckTarget]["id"]]["coins"]
- playerCanMove = true
- cGUData[pckTarget]["living"] = false
- cGUData[pckTarget]["resptime"] = gameUnitData[cGUData[pckTarget]["id"]]["vresp"]
- if pckTarget == cTarget then cTarget = 0 end
- end
- if uMoveRef <= 0 then uMoveRef = 8 end
- setScreenNewPosition() -- отображает часть мира независимо от координат игрока
- if sScreenTimer1 > 0 then sScreenTimer1 = sScreenTimer1 - 1 end
- end
- os.sleep(1)
- end
- end
- local function funcPrQfsec()
- while ingame do
- if not paused then
- if cGUData[1]["x"] ~= cGUData[1]["mx"] then
- playerAutoMove(cGUData[1]["mx"], 3555, 3)
- end
- end
- os.sleep(0.25)
- end
- end
- local function scrRef()
- while ingame do
- if not stopDrawing then
- gamefps = gamefps + 1
- dmain()
- end
- os.sleep(0.035)
- end
- end
- local someVar1
- local plcmx
- cCoins = 152
- local function fInGame()
- local vseffdescrig
- local pItem
- local mpcktime
- while ingame do
- vseffdescrig = false
- someVar1 = true
- local ev, p2, p3, p4, p5 = event.pull()
- if ev == "key_down" then
- if p4 == 44 then ingame = false end
- if p4 == 205 and not paused and cGUData[1]["x"] <= world[world.current].limitR and playerCanMove then -- right
- if keyboard.isAltDown() then
- cGUData[1]["mx"] = world[world.current].limitR
- else
- cGUData[1]["x"] = cGUData[1]["x"] + 2
- cGlobalx = cGlobalx + 2
- cBackgroundPos = cBackgroundPos + 2
- cGUData[1]["spos"] = "r"
- cGUData[1]["mx"] = cGUData[1]["x"]
- end
- elseif p4 == 203 and not paused and cGUData[1]["x"] >= world[world.current].limitL and playerCanMove then -- left
- if keyboard.isAltDown() then
- cGUData[1]["mx"] = world[world.current].limitL
- else
- cGUData[1]["x"] = cGUData[1]["x"] - 2
- cGlobalx = cGlobalx - 2
- cBackgroundPos = cBackgroundPos - 2
- cGUData[1]["spos"] = "l"
- cGUData[1]["mx"] = cGUData[1]["x"]
- end
- end
- if not paused then
- for f = 1, 6 do
- if cTarget ~= 0 and p4 == 1+f and cUskills[f][1] ~= 0 and gameSkillsData[cUskills[f][1]]["type"] ~= "buff" then
- if cGUData[cTarget]["mx"] > cGUData[1]["x"] then
- plcmx = cGUData[cTarget]["mx"] - (vAttackDistance+gameSkillsData[cUskills[f][1]]["distance"]) - cGUData[1]["width"]
- else
- plcmx = cGUData[cTarget]["mx"] + cGUData[cTarget]["width"] + (vAttackDistance+gameSkillsData[cUskills[f][1]]["distance"])
- end
- if getDistanceToId(1,cTarget) > vAttackDistance+gameSkillsData[cUskills[f][1]]["distance"] then
- cGUData[1]["mx"] = plcmx
- plcmx = cGUData[1]["x"]
- elseif getDistanceToId(1,cTarget) <= vAttackDistance+gameSkillsData[cUskills[f][1]]["distance"] then
- useSkill(f)
- plcmx = cGUData[1]["x"]
- cGUData[1]["mx"] = cGUData[1]["x"]
- end
- elseif p4 == 1+f and cUskills[f][1] ~= 0 and gameSkillsData[cUskills[f][1]]["type"] == "buff" then
- useSkill(f)
- end
- end
- end
- if not paused and cTarget ~= 0 and cGUData[cTarget]["rtype"] == "f" and p4 == 18 and getDistanceToId(1,cTarget) <= 40 then
- cGUData[1]["mx"] = cGUData[1]["x"]
- paused = true
- cWindowTrd = "dialog"
- cDialog = dialogs[cGUData[cTarget]["dialog"]]
- cDialog = insertQuests(cTarget,cDialog)
- end
- if not pickingUp and not paused and cTarget ~= 0 and cGUData[cTarget]["rtype"] == "r" and p4 == 18 and getDistanceToId(1,cTarget) <= 11 then
- pckTarget = cTarget
- pickingUp = true
- mpcktime = math.random(gameUnitData[cGUData[cTarget]["id"]]["mnprs"],gameUnitData[cGUData[cTarget]["id"]]["mxprs"])
- pckTime, maxPckTime = mpcktime, mpcktime
- playerCanMove = false
- cGUData[1]["image"] = "player_pck"
- cGUData[1]["mx"] = cGUData[1]["x"]
- end
- if not paused and p4 == 46 then
- paused = true
- cCnsScroll = math.floor(#consDataR/4)
- cWindowTrd = "console"
- end
- end
- if p4 == 1 and cWindowTrd == nil and ESC == "pause" then
- cWindowTrd = "pause"
- paused = true
- elseif p4 == 1 and cWindowTrd == "pause" and ESC == "pause" then
- cWindowTrd = nil
- paused = false
- end
- if ev == "touch" then
- if cWindowTrd == nil and not paused then
- if clicked(p3,p4,1,4,25,4) then
- svxpbar = true
- else
- svxpbar = false
- end
- end
- if cWindowTrd == nil and cTarget ~= 0 and p5 == 0 and gameUnitData[cGUData[cTarget]["id"]]["rtype"] ~= "r" and clicked(p3,p4,60,5,71,5) then showTargetInfo = true
- elseif cWindowTrd == nil and cTarget ~= 0 and p5 == 0 and not clicked(p3,p4,60,5,71,5) then showTargetInfo = false end
- if p5 == 0 and clicked(p3,p4,1,1,25,5) and cWindowTrd == nil and not paused then cTarget = 1 end
- if p5 == 0 and clicked(p3,p4,156,2,158,3) and cWindowTrd == nil then
- cWindowTrd = "pause"
- paused = true
- elseif p5 == 0 and clicked(p3,p4,156,2,158,3) and cWindowTrd == "pause" then
- cWindowTrd = nil
- paused = false
- end
- if p5 == 0 and not paused then target(p3,p4) end
- if p5 == 0 and not paused then
- for f = 1, math.min(#cGUData[1]["effects"],5) do
- if clicked(p3,p4,f*3-1,6,1+f*3,6) then
- vseffdescrig = true
- vshowEffDescr, sEffdx, sEffdy = f, p3, p4+1
- break
- end
- end
- end
- if not vseffdescrig then vshowEffDescr, sEffdx, sEffdy = 0, 1, 1 end
- if p5 == 0 and cWindowTrd == "pause" then
- for f = 1, #fPauselist do
- if clicked(p3,p4,1,2+f*2,30,2+f*2) then
- fPauseMenuAction[f]()
- p3, p4 = 0, 0
- break
- end
- end
- elseif cWindowTrd == "inventory" then
- if clicked(p3,p4,152,1,159,1) then
- cWindowTrd = "pause"
- end
- if showItemData and invcTargetItem ~= 0 and clicked(p3,p4,2,47,12,47) then
- inventory["bag"][invcTargetItem] = {0,0}
- showItemData, invcTargetItem = false, 0
- end
- local fbParam = true
- local nwitemuwr, xps, yps
- for f = 1, 4 do
- for i = 1, 5 do
- xps, yps = 2+i*21-21, 3+f*11-11
- local formula = (f-1)*5+i
- if inventory["bag"][formula][1] ~= 0 and inventory["bag"][formula][2] ~= 0 then
- if clicked(p3,p4,xps,yps,xps+19,yps+9) then
- pItem = gameItemData[inventory["bag"][formula][1]]
- if p5 == 0 then
- invcTItem = inventory["bag"][formula][1]
- invcTargetItem = formula
- invTItem = inventory["bag"][formula][2]
- showItemData = true
- invIdx, invIdy = p3, p4
- fbParam = false
- break
- else
- if pItem["type"] == "armor" and cGUData[1]["level"] >= pItem["reqlvl"] then
- if inventory["weared"][pItem["subtype"]] == 0 then
- inventory["weared"][pItem["subtype"]] = inventory["bag"][formula][1]
- inventory["bag"][formula][1] = 0
- inventory["bag"][formula][2] = 0
- else
- nwitemuwr = inventory["weared"][pItem["subtype"]]
- inventory["weared"][pItem["subtype"]] = inventory["bag"][formula][1]
- inventory["bag"][formula][1] = 0
- inventory["bag"][formula][2] = 0
- addItem(nwitemuwr,1)
- end
- elseif pItem["type"] == "weapon" and cGUData[1]["level"] >= pItem["reqlvl"] then
- if inventory["weared"]["weapon"] == 0 then
- inventory["weared"]["weapon"] = inventory["bag"][formula][1]
- inventory["bag"][formula][1] = 0
- inventory["bag"][formula][2] = 0
- else
- nwitemuwr = inventory["weared"]["weapon"]
- inventory["weared"]["weapon"] = inventory["bag"][formula][1]
- inventory["bag"][formula][1] = 0
- inventory["bag"][formula][2] = 0
- addItem(nwitemuwr,1)
- end
- elseif pItem["type"] == "chest" then
- for t = 1, #pItem["props"] do
- if 1000-pItem["props"][t][3]*10 <= math.random(1,1000) then
- addItem(pItem["props"][t][1],pItem["props"][t][2])
- break
- end
- end
- addsmsg3(unicode.sub(os.date(), #os.date()-7, #os.date()).." Использован предмет "..pItem["name"])
- inventory["bag"][formula][2] = inventory["bag"][formula][2] - 1
- elseif pItem["type"] == "tlp" then
- cGUData[1]["x"], cGlobalx, cBackgroundPos = 1, 1, 1
- addsmsg3(unicode.sub(os.date(), #os.date()-7, #os.date()).." Использован предмет "..pItem["name"])
- inventory["bag"][formula][2] = inventory["bag"][formula][2] - 1
- elseif pItem["type"] == "potion" and cGUData[1]["level"] >= pItem["reqlvl"] then
- if pItem["subtype"] == "health" then
- addPlayerEffect(1,pItem["level"])
- inventory["bag"][formula][2] = inventory["bag"][formula][2] - 1
- elseif pItem["subtype"] == "mana" then
- addPlayerEffect(2,pItem["level"])
- inventory["bag"][formula][2] = inventory["bag"][formula][2] - 1
- end
- addsmsg3(unicode.sub(os.date(), #os.date()-7, #os.date()).." Использован предмет "..pItem["name"])
- end
- nwitemuwr = nil
- break
- end
- end
- end
- end
- end
- local wItemTypes = {
- "helmet",
- "bodywear",
- "pants",
- "weapon",
- "footwear",
- "pendant",
- }
- for f = 1, 3 do
- for i = 1, 2 do
- xps, yps = 107+i*21-21, 3+f*11-11
- if inventory["weared"][wItemTypes[(f-1)*2+i]] ~= 0 then
- if clicked(p3,p4,xps,yps,xps+19,yps+9) then
- if p5 == 0 then
- invcTItem = inventory["weared"][wItemTypes[(f-1)*2+i]]
- invTItem = 1
- showItemData = true
- invIdx, invIdy = p3, p4
- fbParam = false
- break
- else
- addItem(inventory["weared"][wItemTypes[(f-1)*2+i]],1)
- inventory["weared"][wItemTypes[(f-1)*2+i]] = 0
- end
- end
- end
- end
- end
- if fbParam then
- invcTargetItem = 0
- invTItem = 0
- showItemData = false
- invIdx, invIdy = 1, 1
- end
- playerRefreshVar()
- elseif cWindowTrd == "dialog" then
- for f = 1, #cDialog do
- if cDialog[f]["action"] == "getquest" and gameQuestsData[cDialog[f]["do"]]["comp"] == true then
- table.remove(cDialog[f])
- end
- end
- for f = 1, #cDialog do
- if p5 == 0 and clicked(p3,p4,14,25+f,58,25+f) then
- if cDialog[f]["action"] == "close" then
- cWindowTrd = nil
- cDialog = nil
- paused = false
- elseif cDialog[f]["action"] == "trade" then
- tradew.twindow = cDialog[f]["do"]
- tradew.sect = 1
- cWindowTrd = "tradeWindow"
- elseif cDialog[f]["action"] == "dialog" or cDialog[f]["action"] == "qdialog" then
- cDialog = cDialog[f]["do"]
- elseif cDialog[f]["action"] == "getquest" and gameQuestsData[cDialog[f]["do"]]["comp"] == 0 then
- getQuest(cDialog[f]["do"])
- gameQuestsData[cDialog[f]["do"]]["comp"] = false
- cWindowTrd = nil
- cDialog = nil
- paused = false
- elseif cDialog[f]["action"] == "cmpquest" then
- for t = 1, #cUquests do
- if cUquests[t][1] == cDialog[f]["do"] and cUquests[t][3] then
- -- *награда за задание*
- addXP(gameQuestsData[cDialog[f]["do"]]["qreward"]["xp"])
- cCoins = cCoins + gameQuestsData[cDialog[f]["do"]]["qreward"]["coins"]
- if gameQuestsData[cDialog[f]["do"]]["qreward"]["item"] ~= 0 then
- for u = 1, #gameQuestsData[cDialog[f]["do"]]["qreward"]["item"] do
- addItem(gameQuestsData[cDialog[f]["do"]]["qreward"]["item"][u][1],gameQuestsData[cDialog[f]["do"]]["qreward"]["item"][u][2])
- end
- end
- gameQuestsData[cDialog[f]["do"]]["comp"] = true
- table.remove(cUquests,t)
- cWindowTrd = nil
- cDialog = nil
- paused = false
- break
- end
- end
- elseif cDialog[f]["action"] == "setWorld" and cGUData[1]["level"] >= cDialog[f]["reqlvl"] then
- world.current = cDialog[f]["do"]
- loadWorld(world.current)
- end
- end
- end
- if clicked(p3,p4,61,11,61,11) then
- cWindowTrd = nil
- cDialog = nil
- paused = false
- end
- elseif cWindowTrd == "quests" then
- if p5 == 0 and clicked(p3,p4,122,15,129,15) then
- cWindowTrd = "pause"
- end
- for f = 1, #cUquests do
- if cUquests[f] ~= nil and clicked(p3,p4,32,18+f,60,18+f) then
- someVar1 = false
- targetQuest = f
- break
- end
- if not someVar1 then targetQuest = 0 end
- end
- elseif cWindowTrd == "console" then
- if p5 == 0 and clicked(p3,p4,109,10,109,10) then
- cWindowTrd = nil
- paused = false
- end
- elseif cWindowTrd == "pstats" then
- if p5 == 0 and clicked(p3,p4,122,8,129,8) then cWindowTrd = "pause" end
- for t = 1, 3 do
- if p5 == 0 and charPoints > 0 and clicked(p3,p4,pstatspntrs.x+17,pstatspntrs.y+t,pstatspntrs.x+20,pstatspntrs.y+t) then
- chPointsAss[t] = chPointsAss[t] + 1
- charPoints = charPoints - 1
- chPointsAss[4] = chPointsAss[4] + 1
- elseif p5 == 0 and charPoints > 0 and clicked(p3,p4,pstatspntrs.x+22,pstatspntrs.y+t,pstatspntrs.x+25,pstatspntrs.y+t) and chPointsAss[t] > 0 then
- chPointsAss[t] = chPointsAss[t] - 1
- charPoints = charPoints + 1
- chPointsAss[4] = chPointsAss[4] - 1
- end
- end
- if p5 == 0 and clicked(p3,p4,pstatspntrs.x+28,pstatspntrs.y+1,pstatspntrs.x+34,pstatspntrs.y+1) then
- intelligence = intelligence + chPointsAss[1]
- strength = strength + chPointsAss[2]
- survivability = survivability + chPointsAss[3]
- chPointsAss = {0,0,0,0}
- playerRefreshVar()
- elseif p5 == 0 and chPointsAss[4] > 0 and clicked(p3,p4,pstatspntrs.x+28,pstatspntrs.y+3,pstatspntrs.x+34,pstatspntrs.y+3) then
- charPoints = charPoints + chPointsAss[4]
- chPointsAss = {0,0,0,0}
- playerRefreshVar()
- end
- elseif cWindowTrd == "tradeWindow" then
- if p5 == 0 and clicked(p3,p4,152,1,159,1) then
- tradew = {
- twindow = 1,
- titem = 0,
- titemcount = 1,
- sect = 1,
- tScrl = 1
- }
- cWindowTrd = nil
- cDialog = nil
- paused = false
- end
- if tradew.titem == 0 then
- for f = 1, #gameTradew[tradew.twindow] do
- if p5 == 0 and clicked(p3,p4,2+f*26-26, 2, 2+f*25, 2) then
- tradew.sect = f
- end
- end
- for f = 1, math.min(#gameTradew[tradew.twindow][tradew.sect], 24) do
- if clicked(p3,p4,2,5+f*2-2,160,5+f*2) then
- tradew.titem = f+4*tradew.tScrl-4
- end
- end
- else
- if p5 == 0 and gameItemData[gameTradew[tradew.twindow][tradew.sect][tradew.titem]["item"]]["stackable"] and tradew.titemcount < 100 and clicked(p3,p4,math.floor(80-smw/2)+13, math.floor(25-smh/2)+3,math.floor(80-smw/2)+13, math.floor(25-smh/2)+3) then -- +
- tradew.titemcount = tradew.titemcount + 1
- elseif p5 == 0 and tradew.titemcount > 1 and clicked(p3,p4,math.floor(80-smw/2)+16+#tostring(tradew.titemcount), math.floor(25-smh/2)+3,math.floor(80-smw/2)+16+#tostring(tradew.titemcount), math.floor(25-smh/2)+3) then -- -
- tradew.titemcount = tradew.titemcount - 1
- end
- if clicked(p3,p4,math.floor(80-smw/2),math.floor(25-smh/2)+smh,math.floor(80-smw/2)+smw,math.floor(25-smh/2)+smh+3) and cCoins >= tradew.titemcount*gameTradew[tradew.twindow][tradew.sect][tradew.titem]["cost"] then
- cCoins = cCoins - tradew.titemcount*gameTradew[tradew.twindow][tradew.sect][tradew.titem]["cost"]
- addItem(gameTradew[tradew.twindow][tradew.sect][tradew.titem]["item"],tradew.titemcount)
- tradew.titem = 0
- tradew.titemcount = 1
- end
- if clicked(p3,p4,math.floor(80-smw/2)+smw-2, math.floor(25-smh/2),math.floor(80-smw/2)+smw-2, math.floor(25-smh/2)) then
- tradew.titem = 0
- tradew.titemcount = 1
- end
- end
- end
- end
- if ev == "scroll" then
- if cWindowTrd == "console" then
- if clicked(p3,p4,50,10,109,42) and p5 == 1 and cCnsScroll > 1 then
- cCnsScroll = cCnsScroll - 1
- elseif clicked(p3,p4,50,10,109,42) and p5 == -1 and math.ceil(cCnsScroll*4) < #consDataR then
- cCnsScroll = cCnsScroll + 1
- end
- end
- end
- end
- end
- thread.create(fInGame)
- thread.create(scrRef)
- thread.create(functionPS)
- thread.create(funcPrQfsec)
- thread.waitForAll()
- gpu.setBackground(0x000000)
- gpu.setForeground(0xFFFFFF)
- term.clear()
- term.setCursor(1,1)
- io.write("Wirthe16 game "..TextVersion)
Add Comment
Please, Sign In to add comment