Advertisement
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 component = require("component")
- local buffer = require("doubleBuffering")
- local gpu = component.gpu
- gpu.setResolution(160,50)
- local LANGUAGE = "russian"
- thread.init()
- local gamefps, cfps = 0, 0
- 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)
- 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("/home/testgame/translate.lang")
- local lang = convLang(rawlang, LANGUAGE)
- local mlSprites = {
- ["player"] = "player",
- ["zombie"] = "zombie1",
- ["ghost"] = "ghost",
- ["greenslug"] = "greenslug",
- ["vil1"] = "vil1",
- ["bush"] = "bush",
- }
- local aItemIconsSpr = {
- [1]="copper_ingot",
- [2]="iron_ingot",
- [3]="rookies_armor",
- [4]="rookies_pants",
- [5]="rookies_helmet",
- [6]="rookies_boots",
- [7]="wooden_sword",
- [8]="bone_necklace",
- [9]="small_hp",
- [10]="small_mp",
- [11]="medium_hp",
- [12]="medium_mp",
- [13]="large_hp",
- [14]="large_mp",
- [15]="condensed_hp",
- [16]="condensed_mp",
- }
- local dialogs = {
- [1]={["text"] = "",
- {["text"] = lang["Задания"],["action"] = "dialog", ["do"] = {
- ["text"] = "Выберите любые доступные задания",
- {["text"] = "Задание1",["action"] = "getquest", ["do"] = 1},
- {["text"] = lang["До встречи"],["action"] = "close", ["do"] = nil},
- }},
- {["text"] = lang["До встречи"],["action"] = "close", ["do"] = nil},
- },
- }
- local mSprites = {}
- local vAttackDistance = 10
- local gameUnitData = {
- {["id"] = 1, ["name"] = lang["Игрок"], ["wtype"] = "Управляемый персонаж", ["level"] = 1, ["atds"] = 10,
- ["loot"] = {["exp"] = 0, ["coins"] = 0, ["items"] = {}}, ["vresp"] = 0, ["rtype"] = "p", ["image"] = "player"},
- {["id"] = 2, ["name"] = lang["Зомби"], ["wtype"] = "Ходячий труп",["level"] = 1, ["atds"] = 10,
- ["loot"] = {["exp"] = 2, ["coins"] = 3, ["items"] = {}}, ["vresp"] = 30, ["rtype"] = "e", ["image"] = "zombie"},
- {["id"] = 3, ["name"] = lang["Привидение"], ["wtype"] = "Призрак",["level"] = 2, ["atds"] = 10,
- ["loot"] = {["exp"] = 4, ["coins"] = 5, ["items"] = {}}, ["vresp"] = 30, ["rtype"] = "e", ["image"] = "ghost"},
- {["id"] = 4, ["name"] = lang["Зеленый слизень"], ["wtype"] = "Слизень", ["level"] = 2, ["atds"] = 10,
- ["loot"] = {["exp"] = 4, ["coins"] = 4, ["items"] = {}}, ["vresp"] = 30, ["rtype"] = "e", ["image"] = "greenslug"},
- {["id"] = 5, ["name"] = lang["Василий"], ["wtype"] = "Житель", ["level"] = 0,
- ["vresp"] = 0, ["image"] = "vil1", ["rtype"] = "f",["dialog"] = 1},
- {["id"] = 6, ["name"] = lang["Зеленый куст"], ["wtype"] = "Дерево", ["level"] = 3, ["atds"] = 10,
- ["loot"] = {["exp"] = 5, ["coins"] = 6, ["items"] = {}}, ["vresp"] = 30, ["rtype"] = "e", ["image"] = "bush"},
- }
- local gameItemData = {
- {["name"] = "Медный слиток", ["type"] = "item", ["subtype"] = "none", ["description"] = "Может быть использован для крафта",
- ["stackable"] = true, ["maxstack"] = 99, ["cost"] = 5, ["icon"] = 1, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Железный слиток", ["type"] = "item", ["subtype"] = "none", ["description"] = "Может быть использован для крафта",
- ["stackable"] = true, ["maxstack"] = 99, ["cost"] = 5, ["icon"] = 2, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Шлем новичка", ["level"] = 1, ["type"] = "armor", ["subtype"] = "helmet", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {["hp+"] = 0, ["phisdef"] = 28, ["magdef"] = 0}, ["stackable"] = false, ["cost"] = 5, ["icon"] = 5, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Доспех новичка", ["level"] = 1, ["type"] = "armor", ["subtype"] = "bodywear", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {["hp+"] = 0, ["phisdef"] = 27, ["magdef"] = 16}, ["stackable"] = false, ["cost"] = 5, ["icon"] = 3, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Брюки новичка", ["level"] = 1, ["type"] = "armor", ["subtype"] = "pants", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {["hp+"] = 0, ["phisdef"] = 25, ["magdef"] = 15}, ["stackable"] = false, ["cost"] = 5, ["icon"] = 4, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Сапоги новичка", ["level"] = 1, ["type"] = "armor", ["subtype"] = "footwear", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {["hp+"] = 0, ["phisdef"] = 22, ["magdef"] = 13}, ["stackable"] = false, ["cost"] = 5, ["icon"] = 6, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Деревянный меч", ["level"] = 1, ["type"] = "weapon", ["subtype"] = "sword", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {["atds"] = 10, ["hp+"] = 0, ["phisat"] = 1, ["magat"] = 0}, ["stackable"] = false, ["cost"] = 1, ["icon"] = 7, ["ncolor"] = 0xFFFF00},
- {["name"] = "Ожерелье из кости", ["level"] = 1, ["type"] = "armor", ["subtype"] = "pendant", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = {["hp+"] = 0, ["phisdef"] = 8, ["magdef"] = 14}, ["stackable"] = false, ["cost"] = 6, ["icon"] = 8, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Малое исцеляющее зелье", ["type"] = "potion", ["subtype"] = "health", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["cost"] = 1, ["icon"] = 9, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Малое бодрящее зелье", ["type"] = "potion", ["subtype"] = "mana", ["reqlvl"] = 1, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["cost"] = 1, ["icon"] = 10, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Среднее исцеляющее зелье", ["type"] = "potion", ["subtype"] = "health", ["reqlvl"] = 5, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["cost"] = 2, ["icon"] = 11, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Среднее бодрящее зелье", ["type"] = "potion", ["subtype"] = "mana", ["reqlvl"] = 5, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["cost"] = 2, ["icon"] = 12, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Большое исцеляющее зелье", ["type"] = "potion", ["subtype"] = "health", ["reqlvl"] = 10, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["cost"] = 3, ["icon"] = 13, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Большое бодрящее зелье", ["type"] = "potion", ["subtype"] = "mana", ["reqlvl"] = 10, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["cost"] = 3, ["icon"] = 14, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Концентрированное исцеляющее зелье", ["type"] = "potion", ["subtype"] = "health", ["reqlvl"] = 15, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["cost"] = 4, ["icon"] = 15, ["ncolor"] = 0xFFFFFF},
- {["name"] = "Концентрированное бодрящее зелье", ["type"] = "potion", ["subtype"] = "mana", ["reqlvl"] = 15, ["description"] = "",
- ["props"] = 1, ["stackable"] = true, ["maxstack"] = 99, ["cost"] = 4, ["icon"] = 16, ["ncolor"] = 0xFFFFFF},
- }
- local gameSkillsData = {
- {["name"] = "Phisical Attack", ["distance"] = vAttackDistance, ["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"] = {0,0,0,0,0,0,0}},
- {["name"] = "Deep Cut", ["distance"] = vAttackDistance+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"] = {0,0,0,0,0,0,0}},
- }
- local gameQuestsData = {
- {["name"] = "Задание1", ["type"] = "k", ["targ"] = 2, ["num"] = 1, ["minlvl"] = 1, ["maxlvl"] = 100,
- ["comp"] = 0, ["qreward"] = {["coins"] = 10, ["xp"] = 12, ["item"] = {9,5}}},
- }
- local cGUData = {} -- массив со всеми персонажами
- local cUskills = {{1,0,1},{2,0,1},{0,0,1},{0,0,1},{0,0,1},{0,0,1}}
- local cUquests = {}
- local inventory = {
- ["weared"] = {
- ["helmet"] = 0,
- ["bodywear"] = 0,
- ["pants"] = 0,
- ["weapon"] = 0,
- ["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 = "/home/testgame/"
- local cGlobalx, cBackgroundPos = 1, 1
- local cTarget = 0
- local paused = false
- local cWindowTrd = nil
- local showTargetInfo = false
- local ingame = true
- local cmp, mmp, cxp, mxp = 0, 0, 0, 0
- local cDialog
- local survivability = 1
- local strength = 1
- local intelligence = 1
- 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 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 cnsCommands[com] then
- cnsCommands[com]()
- end
- end
- end
- 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
- addItem(1,2)
- addItem(2,3)
- addItem(3,1)
- addItem(4,1)
- addItem(5,1)
- addItem(6,1)
- addItem(7,1)
- addItem(8,1)
- local function addUnit(id,x,y)
- 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]["name"] = gameUnitData[id]["name"]
- cGUData[#cGUData]["wtype"] = gameUnitData[id]["wtype"]
- cGUData[#cGUData]["level"] = gameUnitData[id]["level"]
- cGUData[#cGUData]["spos"] = "r"
- cGUData[#cGUData]["image"] = gameUnitData[id]["image"]
- if cGUData[#cGUData]["image"] ~= nil then
- local cUSprite = image.load(cpath.."sprpic/"..mlSprites[gameUnitData[id]["image"]]..".pic")
- cGUData[#cGUData]["width"] = cUSprite.width
- cGUData[#cGUData]["height"] = cUSprite.height
- cUSprite = nil
- end
- cGUData[#cGUData]["mhp"] = math.ceil(12+(gameUnitData[id]["level"]-1)*3*gameUnitData[id]["level"]*0.75)
- cGUData[#cGUData]["chp"] = cGUData[#cGUData]["mhp"]
- mxp = math.ceil(gameUnitData[id]["level"]*5+(gameUnitData[id]["level"]*21.7))
- mmp = math.ceil(gameUnitData[id]["level"]*5+(gameUnitData[id]["level"]*11.46))
- cmp = mmp
- cGUData[#cGUData]["phisatck"] = math.ceil(0.35+cGUData[#cGUData]["level"]*0.8)
- cGUData[#cGUData]["magatck"] = math.ceil(0.75+cGUData[#cGUData]["level"]*0.3)
- cGUData[#cGUData]["phisdef"] = math.ceil(11.5+cGUData[#cGUData]["level"]*5.4)
- cGUData[#cGUData]["magdef"] = math.ceil(9+gameUnitData[id]["level"]*4.1)
- cGUData[#cGUData]["resptime"] = 0
- cGUData[#cGUData]["living"] = true
- cGUData[#cGUData]["rtype"] = gameUnitData[id]["rtype"]
- cGUData[#cGUData]["attackdistance"] = gameUnitData[id]["atds"]
- cGUData[#cGUData]["attplayer"] = false
- cGUData[#cGUData]["agrtime"] = 0
- if gameUnitData[id]["rtype"] == "f" then
- cGUData[#cGUData]["dialog"] = gameUnitData[id]["dialog"]
- end
- cGUData[#cGUData]["effects"] = {}
- for f = 1, 8 do
- cGUData[#cGUData]["effects"][f] = {}
- cGUData[#cGUData]["effects"][f][1] = 0
- cGUData[#cGUData]["effects"][f][2] = 0
- end
- 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
- addUnit(1,1,1)
- addUnit(5,-25,1)
- addUnit(2,35,1)
- addUnit(3,75,2)
- addUnit(4,115,1)
- addUnit(6,135,1)
- local function playerRefreshVar()
- vSur,vStr,vInt,vHpi,vPdm,vMdm,vPdf,vMdf = 0, 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
- vPdf = cGUData[1]["phisdef"] + gameItemData[inventory["weared"][wItemTypes[f]]]["props"]["phisdef"]
- vMdf = cGUData[1]["magdef"] + 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
- vPdm = cGUData[1]["phisatck"] + gameItemData[inventory["weared"]["weapon"]]["props"]["phisat"]
- vMdm = cGUData[1]["magatck"] + gameItemData[inventory["weared"]["weapon"]]["props"]["magat"]
- vAttackDistance = gameItemData[inventory["weared"]["weapon"]]["props"]["atds"] or 10
- end
- 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.0025)+vPdm
- cGUData[1]["magatck"] = math.floor(1+(intelligence+vInt-1)*0.25+(cGUData[1]["level"]-1)*0.00015)+vMdm
- cGUData[1]["phisdef"] = 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
- end
- local function addXP(value)
- if mxp-cxp >= value then
- cxp = cxp + value
- else
- value = value - (mxp - cxp)
- cGUData[1]["level"] = cGUData[1]["level"] + 1
- cxp = value
- playerRefreshVar()
- cGUData[1]["chp"] = cGUData[1]["mhp"]
- cmp = mmp
- end
- end
- local function getQuest(quest)
- table.insert(cUquests,{quest,0,false})
- 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 cGUData[f]["living"] then
- if cGUData[f]["spos"] == "r" and cGUData[f]["x"]+75-cGlobalx >= -10 and cGUData[f]["x"]+75-cGlobalx <= 160 then
- buffer.image(cGUData[f]["x"]+75-cGlobalx,49-cGUData[f]["y"]-cGUData[f]["height"], image.load(cpath.."sprpic/"..mlSprites[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/"..mlSprites[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 cGUData[f]["roletype"] == "f" then
- -- text npc
- elseif cGUData[f]["rtype"] == "r" and cTarget ~= 0 and cTarget == f and vpickwait then
- local vpercentr = math.ceil(vcpcingup*100/vpcingupm)
- pbar(cGUData[f]["x"]+75-cGlobalx, 49-cGUData[f]["y"]-2,8,vpercentr,0x00FF00,0x444444,vpercentr.."% ",0xFFFFFF)
- end
- end
- 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 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),cGUData[cTarget]["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 function playerCInfoBar(x,y)
- buffer.square(x, y, 25, 5, 0x8C8C8C, 0xFFFFFF, " ")
- local percent1 = math.ceil(cGUData[1]["chp"]*100/cGUData[1]["mhp"])
- local percent2 = math.ceil(cmp*100/mmp)
- local percent3 = math.ceil(cxp*100/mxp)
- buffer.text(x+1, y, 0xFFFFFF, "Уровень "..cGUData[1]["level"])
- pbar(x,y+1,25,percent1,0xFF0000,0x5B5B5B," "..math.ceil(cGUData[1]["chp"]).."/"..math.ceil(cGUData[1]["mhp"]).." ", 0xFFFFFF)
- pbar(x,y+2,25,percent2,0x0000FF,0x5B5B5B," "..math.ceil(cmp).."/"..math.ceil(mmp).." ", 0xFFFFFF)
- pbar(x,y+3,25,percent3,0xFFFF00,0x5B5B5B," "..percent3.."% ", 0x333333)
- end
- local function sTargetInfo(x,y)
- local sTInfoArray1 = {
- cGUData[cTarget]["name"],
- "Тип: "..unicode.sub(cGUData[cTarget]["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]["phisdef"]),
- "Маг.защита: "..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)
- 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"]).."] "..cGUData[cTarget]["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)
- elseif cGUData[cTarget]["rtype"] == "f" then
- local pntext, lbtext = cGUData[cTarget]["wtype"], cGUData[cTarget]["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)
- end
- buffer.text(x+1,y+4,0xFFFFFF,"О персонаже")
- if showTargetInfo then
- sTargetInfo(x+1,y+5)
- end
- end
- 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
- end
- local function drawDialog(x,y)
- local sColor
- local massiv = cDialog
- for f = 1, #massiv do
- if massiv[#massiv-f+1]["action"] == "getquest" and gameQuestsData[cDialog[#massiv-f+1]["do"]]["comp"] == true then
- table.remove(massiv[#massiv-f+1])
- 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 = cGUData[cTarget]["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, #massiv do
- sColor = 0xFFFFFF
- if massiv[f]["action"] == getquest and gameQuestsData[massiv[f]["do"]]["comp"] == false then sColor = 0x555555 end
- buffer.text(x+2,y+14+f,sColor,massiv[f]["text"])
- end
- end
- local function itemSubtypeToRus(subtype)
- local massiv = {
- ["helmet"] = "Шлем",
- ["bodywear"] = "Броня",
- ["pants"] = "Штаны",
- ["footwear"] = "Сапоги",
- ["pendant"] = "Кулон",
- ["sword"] = "Меч",
- }
- return massiv[subtype]
- end
- local function getItemInfoWColor(id)
- local info = {}
- local function giiwcAdd(t,c) table.insert(info,{tostring(t),c}) end
- local itemtype = gameItemData[id]["type"]
- giiwcAdd(gameItemData[id]["name"], gameItemData[id]["ncolor"])
- if itemtype == "armor" or itemtype == "weapon" then
- giiwcAdd(itemSubtypeToRus(gameItemData[id]["subtype"]), 0xBCBCBC)
- giiwcAdd("Уровень "..tostring(gameItemData[id]["level"]), 0xFFFFFF)
- end
- if itemtype == "armor" then
- if gameItemData[id]["props"]["phisdef"] ~= 0 then giiwcAdd("Защита +"..tostring(gameItemData[id]["props"]["phisdef"]), 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]["reqlvl"] > cGUData[1]["level"] then
- giiwcAdd("Требуемый уровень: "..gameItemData[id]["reqlvl"], 0xFF0000)
- else
- giiwcAdd("Требуемый уровень: "..gameItemData[id]["reqlvl"], 0xFFFFFF)
- 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
- giiwcAdd("Цена "..tostring(gameItemData[id]["cost"]), 0xFFFFFF)
- return info
- end
- local invcTargetItem, showItemData = 0, false
- local invIdx, invIdy = 1, 1
- 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(106, 2, image.load(cpath.."image/gGrid.pic"))
- 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
- if showItemData and invcTargetItem ~= 0 then
- local itemInfo = getItemInfoWColor(invcTargetItem)
- 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),itemInfo[f][2],itemInfo[f][1])
- end
- 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 = "Консоль v0.14"
- 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 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
- buffer.text(x+3,y+3+f,0xFFFFFF,unicode.sub(gameQuestsData[cUquests[f][1]]["name"],1,28))
- end
- if targetQuest > 0 and cUquests[targetQuest] ~= nil then
- local qInfoList = {
- "Награда:",
- "Монеты "..tostring(gameQuestsData[cUquests[targetQuest][1]]["qreward"]["coins"]),
- "Опыт "..tostring(gameQuestsData[cUquests[targetQuest][1]]["qreward"]["xp"]),
- }
- 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,"Предмет: "..unicode.sub(gameItemData[gameQuestsData[cUquests[targetQuest][1]]["qreward"]["item"][1]]["name"],1,45).." ("..tostring(gameQuestsData[cUquests[targetQuest][1]]["qreward"]["item"][2])..")")
- 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 function killUnitWithoutAnyLoot(id)
- cGUData[id]["living"] = false
- cGUData[id]["resptime"] = gameUnitData[cGUData[id]["id"]]["vresp"]
- end
- local function makeDamage(id, damage)
- if cGUData[id]["chp"] > damage then
- cGUData[id]["chp"] = cGUData[id]["chp"] - damage
- console.debug("Урон нанесен персонажу",cGUData[id]["name"],tostring(damage):sub(1,5))
- elseif cGUData[id]["chp"] <= damage then
- cGUData[id]["chp"] = 0
- cGUData[id]["living"] = false
- cGUData[id]["resptime"] = gameUnitData[cGUData[id]["id"]]["vresp"]
- addXP(gameUnitData[cGUData[id]["id"]]["loot"]["exp"])
- for f = 1, #cUquests do
- if gameUnitData[id]["id"] == gameQuestsData[cUquests[f][1]]["targ"] and cUquests[f][3] == false then
- if cUquests[f][2] < gameQuestsData[cUquests[f][1]]["num"] then
- cUquests[f][2] = cUquests[f][2] + 1
- else
- cUquests[f][3] = true
- end
- end
- end
- cGUData[id]["resptime"] = gameUnitData[cGUData[id]["id"]]["vresp"]
- if id == cTarget then cTarget = 0 end
- showTargetInfo = false
- end
- end
- local function useSkill(skill)
- playerRefreshVar()
- local et = true
- local cskill = cUskills[skill][1]
- local damage = 0
- if gameSkillsData[cskill]["type"] == "attack" and cGUData[cTarget]["rtype"] ~= "p" and et then
- local physDefRedu = cGUData[cTarget]["phisdef"]/(cGUData[cTarget]["phisdef"]+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) <= gameSkillsData[cskill]["distance"] then
- cmp = cmp - gameSkillsData[cskill]["manacost"][cUskills[skill][3]]
- makeDamage(cTarget, damage)
- cUskills[skill][2] = gameSkillsData[cskill]["reloading"]
- end
- end
- end
- local function dmain()
- if cWindowTrd ~= "inventory" then
- buffer.square(1, 1, 160, 50, 0x00AAFF, 0xFFFFFF, " ")
- buffer.square(1, 48, 160, 3, 0x755340, 0xFFFFFF, " ")
- if cGUData[1]["spos"] == "r" then buffer.image(75, 32, image.load(cpath.."sprpic/player.pic"))
- else buffer.image(75, 32, image.flipHorizontal(image.load(cpath.."sprpic/player.pic")))
- end
- drawCDataUnit()
- playerCInfoBar(1,1)
- if cTarget ~= 0 then targetCInfoBar(60,1) end
- fSkillBar(110,1)
- buffer.text(156,2,0xFFFFFF,"█ █")
- buffer.text(156,3,0xFFFFFF,"█ █")
- 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)
- end
- buffer.text(1,50,0xFFFFFF,"fps: "..tostring(cfps))
- buffer.draw()
- end
- local fPauseMenuAction = {
- [1]=function()
- cWindowTrd = nil
- paused = false
- dmain()
- end,
- [2]=function()
- cWindowTrd = "inventory"
- dmain()
- end,
- [3]=function()
- end,
- [4]=function()
- end,
- [5]=function()
- cWindowTrd = "quests"
- dmain()
- end,
- [6]=function()
- ingame = false
- end,
- }
- playerRefreshVar()
- cGUData[1]["chp"] = cGUData[1]["mhp"]
- cmp = mmp
- dmain()
- local healthReg, manaReg
- local function functionPS()
- while ingame do
- cfps = gamefps
- gamefps = 0
- if not paused then
- manaReg = math.min(0.1+(cGUData[1]["level"]-1)*0.022,2)
- healthReg = math.min(0.08+(cGUData[1]["level"]-1)*0.014,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 cmp < mmp - manaReg and cGUData[1]["living"] then
- cmp = cmp + manaReg
- end
- end
- os.sleep(1)
- end
- end
- local function scrRef()
- while ingame do
- gamefps = gamefps + 1
- dmain()
- os.sleep(0.025)
- end
- end
- local someVar1
- local function fInGame()
- while ingame do
- 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 then -- right
- cGUData[1]["x"] = cGUData[1]["x"] + 2
- cGlobalx = cGlobalx + 2
- cBackgroundPos = cBackgroundPos + 2
- cGUData[1]["spos"] = "r"
- elseif p4 == 203 and not paused then -- left
- cGUData[1]["x"] = cGUData[1]["x"] - 2
- cGlobalx = cGlobalx - 2
- cBackgroundPos = cBackgroundPos - 2
- cGUData[1]["spos"] = "l"
- end
- if cTarget ~= 0 and not paused then
- for f = 1, 6 do
- if p4 == 1+f and cUskills[f][1] ~= 0 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
- paused = true
- cWindowTrd = "dialog"
- cDialog = dialogs[cGUData[cTarget]["dialog"]]
- end
- if not paused and p4 == 46 then
- paused = true
- cCnsScroll = math.floor(#consDataR/4)
- cWindowTrd = "console"
- end
- end
- if ev == "touch" then
- if cWindowTrd == nil and cTarget ~= 0 and p5 == 0 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 cWindowTrd == "pause" then
- for f = 1, #fPauselist do
- if clicked(p3,p4,1,2+f*2,30,2+f*2) then
- fPauseMenuAction[f]()
- break
- end
- end
- elseif cWindowTrd == "inventory" then
- if clicked(p3,p4,152,1,159,1) then
- cWindowTrd = "pause"
- 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
- if p5 == 0 then
- invcTargetItem = inventory["bag"][formula][1]
- showItemData = true
- invIdx, invIdy = p3, p4
- fbParam = false
- break
- else
- if gameItemData[inventory["bag"][formula][1]]["type"] == "armor" then
- if inventory["weared"][gameItemData[inventory["bag"][formula][1]]["subtype"]] == 0 then
- inventory["weared"][gameItemData[inventory["bag"][formula][1]]["subtype"]] = inventory["bag"][formula][1]
- inventory["bag"][formula][1] = 0
- inventory["bag"][formula][2] = 0
- else
- nwitemuwr = inventory["weared"][gameItemData[inventory["bag"][formula][1]]["subtype"]]
- inventory["weared"][gameItemData[inventory["bag"][formula][1]]["subtype"]] = inventory["bag"][formula][1]
- inventory["bag"][formula][1] = 0
- inventory["bag"][formula][2] = 0
- addItem(nwitemuwr,1)
- end
- elseif gameItemData[inventory["bag"][formula][1]]["type"] == "weapon" 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
- 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
- invcTargetItem = inventory["weared"][wItemTypes[(f-1)*2+i]]
- 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
- 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"] == "dialog" 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"] == "getquest" and gameQuestsData[cDialog[f]["do"]]["comp"] == false then
- for t = 1, #cUquests do
- if cUquests[t][1] == cDialog[f]["do"] and cUquests[t][3] then
- -- *награда за задание*
- gameQuestsData[cDialog[f]["do"]]["comp"] = true
- table.remove(cUquests,t)
- cWindowTrd = nil
- cDialog = nil
- paused = false
- break
- end
- end
- end
- end
- 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
- 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.waitForAll()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement