- Dołączył
- Luty 12, 2010
- Posty
- 171
- Liczba reakcji
- 1
Witam.
Ostatnio szuka?em i szuka?em a? znalaz?em podstaw? pod skrypt do systemu catch, go/back pod 8.7.
Chodzi tutaj o taki system dla servera RPG (nie pokemony), ?apiesz sb Djina w lamp? i mo?esz z nim expi?.
Skrypt jest przejrzysty i dzia?a ale jest kilka funkcji, kt?re chcia?bym z wasz? pomoc? doda?.
A mianowicie:
-Max 1 summona, tak jak to wygl?da w pokemonach.
-System zapami?tywania stanu ?ycia oraz npc, kt?ry ulecza?by naszego dedni?tego Djina.
-Item, kt?ry w czasie expienia pom?g?by nam uleczy? dedni?tego Djina.
-System tak zwanej evolucji, podobnie jak to wygl?da w pokach.
My?l? ?e mi pomo?ecie, bo jako ?e ja jestem s?aby w te klocki to my?l? ?e nam si? uda. Oczywi?cie po sko?czeniu prac skrypt zostanie ca?kowicie udost?pniony pod licencj? GPL.
Podstawa sk?ada si? z kilku plik?w:
[LUA]
config = {lamp_id = 2141, used_lamp = 4873, summoned = 6453}
t = {["Djin"] = {["100"] = 10},} -- MODEL: ["MONSTER_NAME"] = {["CHANCE_PERCENT"] = LIFE_PERCENT},
t2 = {[1001] = "Djin",} -- MODEL: [MONSTER_STORAGE] = "MONSTER_NAME",
-- KA?DY MONSTER MUSI MIE? INNE STORAGE
function string.trim(str)
return (string.gsub(str, "^%s*(.-)%s*$", "%1"))
end
function string.explode(str, sep)
local pos, t = 1, {}
if #sep == 0 or #str == 0 then return end
for s, e in function() return string.find(str, sep, pos) end do
table.insert(t, string.trim(string.sub(str, pos, s-1)))
pos = e+1
end
table.insert(t, string.trim(string.sub(str, pos)))
return t
end [/LUA]
Kolejnym plikiem jaki posiadam jest plik Catch.lua, kt?ry to odpowiada za ?apanie.
[LUA]
dofile("./lamp.lua")
function onUse(cid, item, fromPosition, itemEx, toPosition)
for k,v in pairs(t) do
for kk,vv in pairs(v) do
if getCreatureName(itemEx.uid) == k then
if getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(itemEx.uid)) <= 1 then
if getCreatureHealth(itemEx.uid) <= getCreatureMaxHealth(itemEx.uid)/vv then
if math.random(1,100) <= tonumber(kk) then
doRemoveCreature(itemEx.uid)
doSendMagicEffect(toPosition, CONST_ME_FIREWORK_BLUE)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You cought a wild ".. k .."!")
doRemoveItem(item.uid, 1)
mb = doPlayerAddItem(cid, config.lamp_id, 1)
doItemSetAttribute(mb, "description", "It contains ".. k)
else
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT,"Your lamp broke!")
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
else
doPlayerSendCancel(cid, "You have to do some attacks before catch.")
end
else
doPlayerSendCancel(cid, "You need to be closer.")
end
end
end
end
return true
end [/LUA]
Nast?pny plik to goback.lua
[LUA]dofile("./lamp.lua")
function onUse(cid, item, fromPosition, itemEx, toPosition)
for k,v in pairs(t2) do
if item.itemid == config.lamp_id then
if string.explode(getItemAttribute(item.uid, "description"), " ")[3] == v then
doTransformItem(item.uid, config.used_lamp)
x = doCreateMonster(v, getThingPos(cid))
doConvinceCreature(cid, x)
doSendMagicEffect(getThingPos(x), CONST_ME_TELEPORT)
doCreatureSay(cid, v ..", go!", MESSAGE_FIRST)
setPlayerStorageValue(cid, config.summoned, 1)
if getPlayerStorageValue(cid, k) == -1 then
doCreatureAddHealth(x, getCreatureMaxHealth(x)-getCreatureHealth(x))
else
doCreatureAddHealth(x, - getCreatureHealth(x) + getPlayerStorageValue(cid, k))
end
else
doPlayerSendTextMessage(cid, 22, "ERROR[1]:: Please send this message to admin.")
end
else
if #getCreatureSummons(cid) <= 0 then
doTransformItem(item.uid, config.lamp_id)
else
doCreatureSetStorage(cid, k, getCreatureHealth(getCreatureSummons(cid)[1]))
doSendMagicEffect(getThingPos(getCreatureSummons(cid)[1]), CONST_ME_TELEPORT)
if doRemoveCreature(getCreatureSummons(cid)[1]) then end
doTransformItem(item.uid, config.lamp_id)
setPlayerStorageValue(cid, config.summoned, -1)
doCreatureSay(cid, v ..", back!", MESSAGE_FIRST)
end
end
end
return true
end [/LUA]
Dodatkowo do creaturescript doda?em co? takiego "goback.lua"
[LUA]
dofile("./lamp.lua")
function onLogout(cid, interval)
if isPlayer(cid) then
if getPlayerStorageValue(cid, config.summoned) ~= -1 then
setPlayerStorageValue(cid, config.summoned, -1)
end
end
return true
end [/LUA]
Do actions.xml :
[XML] <!-- Lamp -->
<action itemid="4863" event="script" value="catch.lua" allowfaruse="1"/>
<action itemid="2141;4873" event="script" value="goback.lua" allowfaruse="1"/> [/XML]
Do creaturescripts.xml:
[XML]<!-- Go/Back -->
<event type="logout" name="goback" event="script" value="goback.lua"/> [/XML]
A do login.lua :
[LUA]registerCreatureEvent(cid, "goback") [/LUA]
Mam nadziej? ?e s? to wszystkie potrzebne informacje i ?e uda nam si? stworzy? co? godnego ka?dego ots'a RPG.
Czekam na rady i ka?d? pomoc.
Pozdrawiam Tracer.
Ostatnio szuka?em i szuka?em a? znalaz?em podstaw? pod skrypt do systemu catch, go/back pod 8.7.
Chodzi tutaj o taki system dla servera RPG (nie pokemony), ?apiesz sb Djina w lamp? i mo?esz z nim expi?.
Skrypt jest przejrzysty i dzia?a ale jest kilka funkcji, kt?re chcia?bym z wasz? pomoc? doda?.
A mianowicie:
-Max 1 summona, tak jak to wygl?da w pokemonach.
-System zapami?tywania stanu ?ycia oraz npc, kt?ry ulecza?by naszego dedni?tego Djina.
-Item, kt?ry w czasie expienia pom?g?by nam uleczy? dedni?tego Djina.
-System tak zwanej evolucji, podobnie jak to wygl?da w pokach.
My?l? ?e mi pomo?ecie, bo jako ?e ja jestem s?aby w te klocki to my?l? ?e nam si? uda. Oczywi?cie po sko?czeniu prac skrypt zostanie ca?kowicie udost?pniony pod licencj? GPL.
Podstawa sk?ada si? z kilku plik?w:
Zawarto??:lamp.lua - Plik ten jest umieszczony dok?adnie tam gdzie nasz serverowy config lua.
[LUA]
config = {lamp_id = 2141, used_lamp = 4873, summoned = 6453}
t = {["Djin"] = {["100"] = 10},} -- MODEL: ["MONSTER_NAME"] = {["CHANCE_PERCENT"] = LIFE_PERCENT},
t2 = {[1001] = "Djin",} -- MODEL: [MONSTER_STORAGE] = "MONSTER_NAME",
-- KA?DY MONSTER MUSI MIE? INNE STORAGE
function string.trim(str)
return (string.gsub(str, "^%s*(.-)%s*$", "%1"))
end
function string.explode(str, sep)
local pos, t = 1, {}
if #sep == 0 or #str == 0 then return end
for s, e in function() return string.find(str, sep, pos) end do
table.insert(t, string.trim(string.sub(str, pos, s-1)))
pos = e+1
end
table.insert(t, string.trim(string.sub(str, pos)))
return t
end [/LUA]
Kolejnym plikiem jaki posiadam jest plik Catch.lua, kt?ry to odpowiada za ?apanie.
[LUA]
dofile("./lamp.lua")
function onUse(cid, item, fromPosition, itemEx, toPosition)
for k,v in pairs(t) do
for kk,vv in pairs(v) do
if getCreatureName(itemEx.uid) == k then
if getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(itemEx.uid)) <= 1 then
if getCreatureHealth(itemEx.uid) <= getCreatureMaxHealth(itemEx.uid)/vv then
if math.random(1,100) <= tonumber(kk) then
doRemoveCreature(itemEx.uid)
doSendMagicEffect(toPosition, CONST_ME_FIREWORK_BLUE)
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You cought a wild ".. k .."!")
doRemoveItem(item.uid, 1)
mb = doPlayerAddItem(cid, config.lamp_id, 1)
doItemSetAttribute(mb, "description", "It contains ".. k)
else
doRemoveItem(item.uid, 1)
doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT,"Your lamp broke!")
doSendMagicEffect(toPosition, CONST_ME_POFF)
end
else
doPlayerSendCancel(cid, "You have to do some attacks before catch.")
end
else
doPlayerSendCancel(cid, "You need to be closer.")
end
end
end
end
return true
end [/LUA]
Nast?pny plik to goback.lua
[LUA]dofile("./lamp.lua")
function onUse(cid, item, fromPosition, itemEx, toPosition)
for k,v in pairs(t2) do
if item.itemid == config.lamp_id then
if string.explode(getItemAttribute(item.uid, "description"), " ")[3] == v then
doTransformItem(item.uid, config.used_lamp)
x = doCreateMonster(v, getThingPos(cid))
doConvinceCreature(cid, x)
doSendMagicEffect(getThingPos(x), CONST_ME_TELEPORT)
doCreatureSay(cid, v ..", go!", MESSAGE_FIRST)
setPlayerStorageValue(cid, config.summoned, 1)
if getPlayerStorageValue(cid, k) == -1 then
doCreatureAddHealth(x, getCreatureMaxHealth(x)-getCreatureHealth(x))
else
doCreatureAddHealth(x, - getCreatureHealth(x) + getPlayerStorageValue(cid, k))
end
else
doPlayerSendTextMessage(cid, 22, "ERROR[1]:: Please send this message to admin.")
end
else
if #getCreatureSummons(cid) <= 0 then
doTransformItem(item.uid, config.lamp_id)
else
doCreatureSetStorage(cid, k, getCreatureHealth(getCreatureSummons(cid)[1]))
doSendMagicEffect(getThingPos(getCreatureSummons(cid)[1]), CONST_ME_TELEPORT)
if doRemoveCreature(getCreatureSummons(cid)[1]) then end
doTransformItem(item.uid, config.lamp_id)
setPlayerStorageValue(cid, config.summoned, -1)
doCreatureSay(cid, v ..", back!", MESSAGE_FIRST)
end
end
end
return true
end [/LUA]
Dodatkowo do creaturescript doda?em co? takiego "goback.lua"
[LUA]
dofile("./lamp.lua")
function onLogout(cid, interval)
if isPlayer(cid) then
if getPlayerStorageValue(cid, config.summoned) ~= -1 then
setPlayerStorageValue(cid, config.summoned, -1)
end
end
return true
end [/LUA]
Do actions.xml :
[XML] <!-- Lamp -->
<action itemid="4863" event="script" value="catch.lua" allowfaruse="1"/>
<action itemid="2141;4873" event="script" value="goback.lua" allowfaruse="1"/> [/XML]
Do creaturescripts.xml:
[XML]<!-- Go/Back -->
<event type="logout" name="goback" event="script" value="goback.lua"/> [/XML]
A do login.lua :
[LUA]registerCreatureEvent(cid, "goback") [/LUA]
Mam nadziej? ?e s? to wszystkie potrzebne informacje i ?e uda nam si? stworzy? co? godnego ka?dego ots'a RPG.
Czekam na rady i ka?d? pomoc.
Pozdrawiam Tracer.

