Michcol94
Member
- Joined
- Sep 2, 2021
- Messages
- 105
- Reaction score
- 19
proszę o pomoc w optymalizacji mojego skryptu, bo wydaje mi się że przy większej liczbie osób będzie mulił silnik a nie mam jak tego przetestować, oczekuję opinii i ewentualnej edycji kodu w celu optymalizacji systemu transform:
Talkactions: Transform
Talkactions: Revert
globalevents: transformsystemautomat
globalevents: constantmagiceffect
Talkactions: Transform
Lua:
local SystemTransformData= {
[1] = { lvl = 1, manaPerSec =0,
newlookType = 397, revertlookType =436,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 0, revertmaxmana = 0,
newvoc = 2, revertvoc = 1,
constforma = true, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 0, allbonusmaxmana = 0,
effect=126,
},
--goku kaioken look type 397
[2] = { lvl = 1, manaPerSec =10,
newlookType = 438, revertlookType =436,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 3, revertvoc = 1,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 1000, allbonusmaxmana = 1000,
effect=127,
},
--goku ssj looktype 438
[3] = { lvl = 1, manaPerSec =20,
newlookType = 404, revertlookType =397,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 4, revertvoc = 2,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 2000, allbonusmaxmana = 2000,
effect=128,
},
--goku ssj2 looktype 404
[4] = { lvl = 1, manaPerSec =30,
newlookType = 437, revertlookType =438,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 5, revertvoc = 3,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 3000, allbonusmaxmana = 3000,
effect=129,
},
--goku ssj3 looktype 437
[5] = { lvl = 1, manaPerSec =40,
newlookType = 433, revertlookType =404,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 6, revertvoc = 4,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 4000, allbonusmaxmana = 4000,
effect=130,
},
--goku ssj4 looktype 433
[6] = { lvl = 1, manaPerSec =50,
newlookType = 433, revertlookType =437,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 6, revertvoc = 5,
constforma = false, lasttransform = true,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 5000, allbonusmaxmana = 5000,
effect=131,
},
}
function onSay(player, words)
local cid = player:getId()
local polecenie = Player(cid)
if not polecenie then
print("Nie mozna znalezc gracza o podanym id.")
return false
end
local vocationobecny = polecenie:getVocation():getId()
local infoData = SystemTransformData[vocationobecny]
if infoData.lasttransform == true then
polecenie:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Nie mozesz sie juz transformowac, osiagnales szczyt mozliwosci i jestes aktualnie na ostatniej transformacji!")
elseif polecenie:getLevel() < infoData.lvl then
polecenie:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Posiadasz zbyt niski lvl!")
else
--zwiększenie maksymalnego zdrowia i many
polecenie:setMaxHealth(polecenie:getMaxHealth() + infoData.maxhp)
polecenie:setMaxMana(polecenie:getMaxMana() + infoData.maxmana)
polecenie:setHealth(polecenie:getMaxHealth())
polecenie:addMana(polecenie:getMaxMana())
polecenie:setOutfit({lookType=infoData.newlookType})
polecenie:getPosition():sendMagicEffect(infoData.effect)
--MIEJSCE NA AKTUALIZACJE KODU I DODAWANIE NOWYCH FUNKCJI PONIŻEJ--
--------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------
polecenie:setVocation(infoData.newvoc)
polecenie:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Transformacja udana!")
end
end
Lua:
local SystemTransformData= {
[1] = { lvl = 1, manaPerSec =0,
newlookType = 397, revertlookType =436,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 0, revertmaxmana = 0,
newvoc = 2, revertvoc = 1,
constforma = true, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 0, allbonusmaxmana = 0,
effect=126,
},
--goku kaioken look type 397
[2] = { lvl = 1, manaPerSec =10,
newlookType = 438, revertlookType =436,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 3, revertvoc = 1,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 1000, allbonusmaxmana = 1000,
effect=127,
},
--goku ssj looktype 438
[3] = { lvl = 1, manaPerSec =20,
newlookType = 404, revertlookType =397,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 4, revertvoc = 2,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 2000, allbonusmaxmana = 2000,
effect=128,
},
--goku ssj2 looktype 404
[4] = { lvl = 1, manaPerSec =30,
newlookType = 437, revertlookType =438,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 5, revertvoc = 3,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 3000, allbonusmaxmana = 3000,
effect=129,
},
--goku ssj3 looktype 437
[5] = { lvl = 1, manaPerSec =40,
newlookType = 433, revertlookType =404,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 6, revertvoc = 4,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 4000, allbonusmaxmana = 4000,
effect=130,
},
--goku ssj4 looktype 433
[6] = { lvl = 1, manaPerSec =50,
newlookType = 433, revertlookType =437,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 6, revertvoc = 5,
constforma = false, lasttransform = true,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 5000, allbonusmaxmana = 5000,
effect=131,
},
}
function onSay(player, words)
local cid = player:getId()
local polecenie = Player(cid)
if not polecenie then
print("Nie mozna znalezc gracza o podanym id.")
return false
end
local vocationobecny = polecenie:getVocation():getId()
local revertdata = SystemTransformData[vocationobecny]
if revertdata.constforma == true then
polecenie:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Masz stała forme nie mozesz jej cofnac!!!!")
else
polecenie:setOutfit({lookType=revertdata.revertlookType})
polecenie:setMaxHealth(polecenie:getMaxHealth() - revertdata.revertmaxhp)
polecenie:setMaxMana(polecenie:getMaxMana() - revertdata.revertmaxmana)
polecenie:setVocation(revertdata.revertvoc)
polecenie:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Revert udany!")
end
end
Code:
local SystemTransformData= {
[1] = { lvl = 1, manaPerSec =0,
newlookType = 397, revertlookType =436,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 0, revertmaxmana = 0,
newvoc = 2, revertvoc = 1,
constforma = true, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 0, allbonusmaxmana = 0,
effect=126,
},
--goku kaioken look type 397
[2] = { lvl = 1, manaPerSec =10,
newlookType = 438, revertlookType =436,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 3, revertvoc = 1,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 1000, allbonusmaxmana = 1000,
effect=127,
},
--goku ssj looktype 438
[3] = { lvl = 1, manaPerSec =20,
newlookType = 404, revertlookType =397,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 4, revertvoc = 2,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 2000, allbonusmaxmana = 2000,
effect=128,
},
--goku ssj2 looktype 404
[4] = { lvl = 1, manaPerSec =30,
newlookType = 437, revertlookType =438,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 5, revertvoc = 3,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 3000, allbonusmaxmana = 3000,
effect=129,
},
--goku ssj3 looktype 437
[5] = { lvl = 1, manaPerSec =40,
newlookType = 433, revertlookType =404,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 6, revertvoc = 4,
constforma = false, lasttransform = false,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 4000, allbonusmaxmana = 4000,
effect=130,
},
--goku ssj4 looktype 433
[6] = { lvl = 1, manaPerSec =50,
newlookType = 433, revertlookType =437,
maxhp = 1000, maxmana = 1000,
revertmaxhp = 1000, revertmaxmana = 1000,
newvoc = 6, revertvoc = 5,
constforma = false, lasttransform = true,
constlookType = 436, constvoc = 1,
allbonusmaxhp = 5000, allbonusmaxmana = 5000,
effect=131,
},
}
function onThink(interval)
for index, player in pairs(Game.getPlayers()) do
if player then
local vocation = player:getVocation():getId()
local removedata = SystemTransformData[vocation]
if removedata ~= nil then
if removedata.constforma == true then
else
if removedata.constforma == false then
local cid = player:getId()
local player = Player(cid)
if player == nil then
return false
end
if player:getMana() > 100 then
player:addMana(-removedata.manaPerSec)
else
player:setOutfit({lookType = removedata.constlookType})
player:setVocation(removedata.constvoc)
player:setMaxHealth(player:getMaxHealth() - removedata.allbonusmaxhp)
player:setMaxMana(player:getMaxMana() - removedata.allbonusmaxmana)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Miales zbyt malo many, aby utrzymac transformacje.")
end
end
end
end
end
end
return true
end
Lua:
local efektytabela ={
[1]={constanteffect=100},[2]={constanteffect=100},[3]={constanteffect=100},[4]={constanteffect=305},[5]={constanteffect=305},[6]={constanteffect=336},
}
function onThink(interval)
for index, player in pairs(Game.getPlayers()) do
if player then
local vocation = player:getVocation():getId()
local tabela = efektytabela[vocation]
if tabela ~= nil then
local cid = player:getId()
local player = Player(cid)
if player == nil then
return false
end
if tabela.constanteffect > 101 then
player:getPosition():sendMagicEffect(tabela.constanteffect)
end
end
end
end
return true
endfunction onThink(interval)
for index, player in pairs(Game.getPlayers()) do
if player then
local vocation = player:getVocation():getId()
local tabela = efektytabela[vocation]
if tabela ~= nil then
local cid = player:getId()
local player = Player(cid)
if player == nil then
return false
end
if tabela.constanteffect > 101 then
player:getPosition():sendMagicEffect(tabela.constanteffect)
end
end
end
end
return true
end