R
Rahim
Guest
Przegl?daj?c dzi? forum zauwa?y?em temat z skryptem o transformacji. Oczywi?cie nie trzeba si? domy?la?, ?e skrypt by? do?? kiepskiej jako?ci Pomy?la?em jednak, ?e taki skrypt mo?e by? bardzo przydatny dlatego napisa?em swoj? wersj?.
Czym si? ona cechuje?
Jakie? zdj?tko? Why not:
No ok, to teraz przejd?my do ca?ego skryptu
Do talkactions/scripts/transform.lua
talkactions.xml
Wersja dla nowszych tfs?w:
Wersja dla starszych silnik?w.
Teraz do creaturescripts.xml
lub, je?li masz starszy silnik:
creaturescripts/scripts/transform.lua
UWAGA! Jest to wersja poprawiona dnia 4 sierpnia 2010. Zalecana aktualizacja.
Teraz musimy doda? do pliku login.lua (w creaturescripts =]) trzy linijki. Je?li nie masz tego pliku (w co w?tpi? xd) to sobie zr?b.
No i teraz najwa?niejsze - konfiguracja. Wklep to na sam d??:
I wsio. Jeszcze po kr?tce obja?ni? konfiguracj? i dodawanie w?asnych trans?w
Cyfra na niebiesko symbolizuje id profesji, dla kt?rej ta transformacja jest (tak - jedna profesja mo?e mie? tylko jednego transa. Jak kto? chce to sobie zmieni?, niech to ju? robi w swoim zakresie
Dalsz? cz??? tabeli my?l?, ?e nie trzeba t?umaczy?. Outfit to outfit, kt?ry gracz "za?o?y", level to wymagany poziom... Mo?na si? domy?li? Je?li chcesz doda? nowego transa - wzoruj si? na przyk?adach. To nie trudne
Teraz og?lny config. CheckingLevel i CheckingMana ustala, czy skrypt ma sprawdza? czy gracz posiada wymagany level i man? do transformacji. W sumie nie wiem po co to da?em ale jak ju? jest niech sobie b?dzie Aby to wy??czy?, nale?y wpisa? warto?? false.
Wszystkie te te na fioletowo to numer storage, na kt?rym b?d? zapisywane r??ne, potrzebne skryptowi warto?ci, jak stary outfit (tak, gdy transformacja si? sko?czy, gracz otrzymuje stary outfit), star? profesj? gracza oraz czas do ko?ca trwania transformacji.
Od healTransformedPlayer zale?y, czy gracz po transformacji ma zosta? uleczony (czyli je?li gracz am np. 400/1300 hp to jego zdrowie po transformacji wzro?nie do 1300. Z man? to samo)
messages to tabela z tekstami, kt?re s? wysy?ane do gracza je?li nei spe?nia jakich? warunk?w. Pierwszy to wiadomo??, gdy profesja gracza nie ma ?adnych transformacji. Druga to gdy gracz ma za ma?y poziom a trzecia, gdy typkowi brakuje many "%i" zostaje zast?pione przez skrypt wymaganym levelem b?d? man? do transformacji.
Konfiguracj? si?y, regeneracji zdrowia i innych pierd?? musicie zrobi? ju? sami, wedle swojego uznania, w vocations.xml
I to chyba ju? wsio. C??, je?li pojawi? si? jakie? b??dy, oczywi?cie piszcie! Og?lnie te? piszcie, w sumie zale?y mi na ocenach
Pozdro wienia! Bless.
Czym si? ona cechuje?
- Skrypt jest niezawodny - nie musisz si? ba?, ?e gdy gracz padnie albo si? wyloguje to zostanie mu profesja i bonusy jak dodatkowe ?ycie. Skrypt nie bazuje jak pozosta?e na addEvent, ale na funkcji onThink w creaturescripts Dlatego nawet po wylogowaniu skrypcik dalej kontroluje transformacj? i gdy minie czas - znika.
- Postara?em si? o jak najwi?ksz? konfiguracj?. Nie musisz wnika? do budowy skryptu - w pliku constant.lua (b?d? global.lua) znajdziesz pe?en config a w nim wszystko co potrzebne, np. nowy outfit oraz id nowej profesji po transformacji, czas trwania (w sekundach), bonus do hp i many, wymagany level oraz man?, ile ma zabiera? many, efekty, jaki? tekst, kt?ry gracz wypowie podczas transformacji i co? tam jeszcze. Chyba nie jest ?le, co?
- W bardzo prosty spos?b mo?na dodawa? w?asne, nowe transformacje - jak to robi?, opisa?em na dole tematu
Jakie? zdj?tko? Why not:
No ok, to teraz przejd?my do ca?ego skryptu
Do talkactions/scripts/transform.lua
PHP:
--[[
Script: Transform System v1.0
Author: Rahim
Date: 11.07.2010
Forum: tibia.net.pl
Thread: http://tibia.net.pl/inne-skrypty/385286-8-x-transform-system.html
Tibia Version: 8.5 - 8.6 (should work in older versions =] If not - take a look at the forum)
Tested on: TheForgottenServer 0.3.6
]]
function onSay(cid, words, param, channel)
local voc = getPlayerVocation(cid)
local transform = transforms[voc]
if(not transform) then
doPlayerSendCancel(cid, Transform_config.messages["wrong_vocation"])
return true
end
if(Transform_config.checkingLevel and getPlayerLevel(cid) < transform.level) then
doPlayerSendCancel(cid, string.format(Transform_config.messages["low_level"], transform.level))
return true
end
if(Transform_config.checkingMana and getPlayerMana(cid) < transform.firstManaCost) then
doPlayerSendCancel(cid, string.format(Transform_config.messages["not_have_mana"], transform.firstManaCost))
return true
end
doCreatureAddMana(cid, -transform.firstManaCost)
setPlayerStorageValue(cid, Transform_config.timeSaveStorage, os.time() + transform.time)
setPlayerStorageValue(cid, Transform_config.storageSaveOldVocation, voc)
registerCreatureEvent(cid, "transform")
doPlayerSetVocation(cid, transform.newVocation)
if(transform.firstSoulCost) then doPlayerAddSoul(cid, -transform.firstSoulCost) end
if(transform.firstEffect) then doSendMagicEffect(getThingPos(cid), transform.firstEffect) end
if(transform.gainHealth) then setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + transform.gainHealth) end
if(transform.gainMana) then setCreatureMaxMana(cid, getCreatureMaxMana(cid) + transform.gainMana) end
if(transform.text) then doCreatureSay(cid, transform.text, transform.textSayType) end
if(Transform_config.healTransformedPlayer) then
doCreatureAddHealth(cid, math.abs(getCreatureMaxHealth(cid) - getCreatureHealth(cid)))
doCreatureAddMana(cid, math.abs(getCreatureMaxMana(cid) - getCreatureMana(cid)))
else
doCreatureAddHealth(cid, 1) -- we need to send stats to client :D otherwise player will not see any changes in health. setCreatureMaxHealtht aren't send stats :\
end
if(transform.outfit) then
-- saving old outfit to storages.
local i = 0
for k, v in pairs(getCreatureOutfit(cid)) do
i = i + 1
setPlayerStorageValue(cid, Transform_config.storageSaveOutfit + i - 1, v)
end
doCreatureChangeOutfit(cid, transform.outfit)
end
return true
end
Wersja dla nowszych tfs?w:
PHP:
<talkaction words="/transform" event="script" value="transform.lua"/>
PHP:
<talkaction words="/transform" script="transform.lua"/>
PHP:
<event type="think" name="transform" event="script" value="transform.lua"/>
PHP:
<event type="think" name="transform" script="transform.lua"/>
UWAGA! Jest to wersja poprawiona dnia 4 sierpnia 2010. Zalecana aktualizacja.
PHP:
--[[
Script: Transform System v1.0
Author: Rahim
Date: 11.07.2010
Forum: tibia.net.pl
Thread: http://tibia.net.pl/inne-skrypty/385286-8-x-transform-system.html
Tibia Version: 8.5 - 8.6 (should work in older versions =] If not - take a look at the forum)
Tested on: TheForgottenServer 0.3.6
]]
local function loadOutfit(cid)
local outfit = {lookAddons = 0, lookType = 0, lookHead = 0, lookTypeEx = 0, lookLegs = 0, lookBody = 0, lookFeet = 0}
outfit.lookType = getPlayerStorageValue(cid, Transform_config.storageSaveOutfit + 1) -- I know it's ugly but really there is no other way to load outfit xd
outfit.lookTypeEx = getPlayerStorageValue(cid, Transform_config.storageSaveOutfit + 3)
outfit.lookHead = getPlayerStorageValue(cid, Transform_config.storageSaveOutfit + 2)
outfit.lookBody = getPlayerStorageValue(cid, Transform_config.storageSaveOutfit + 5)
outfit.lookLegs = getPlayerStorageValue(cid, Transform_config.storageSaveOutfit + 4)
outfit.lookFeet = getPlayerStorageValue(cid, Transform_config.storageSaveOutfit + 6)
outfit.lookAddons = getPlayerStorageValue(cid, Transform_config.storageSaveOutfit)
return outfit
end
function onThink(cid, interval)
local oldvoc = getPlayerStorageValue(cid, Transform_config.storageSaveOldVocation)
local transform = transforms[oldvoc]
if(not transform) then
return true
end
if(getPlayerStorageValue(cid, Transform_config.timeSaveStorage) < os.time()) then
-- revert
doPlayerSetVocation(cid, oldvoc)
if(transform.gainHealth) then setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) - transform.gainHealth) end
if(transform.gainMana) then setCreatureMaxMana(cid, getCreatureMaxMana(cid) - transform.gainMana) end
if(transform.outfit) then doCreatureChangeOutfit(cid, loadOutfit(cid)) end
if(type(unregisterCreatureEvent) == "function") then -- I have no idea whether it is this function in earlier versions =]
unregisterCreatureEvent(cid, "transform")
else
registerCreatureEvent(cid, "transform") -- in older versions this function works the same way like unregisterCreatureEvent
end
doCreatureAddHealth(cid, 1)
return true
end
if(transform.effect) then doSendMagicEffect(getThingPos(cid), transform.effect) end
if(transform.manaCost) then doCreatureAddMana(cid, -transform.manaCost) end
if(transform.soulCost) then doPlayerAddSoul(cid, -transform.soulCost) end
if(getCreatureOutfit(cid).lookType ~= transform.outfit.lookType) then doCreatureChangeOutfit(cid, transform.outfit) end
return true
end
PHP:
registerCreatureEvent(cid, "transform")
Code:
transforms =
{
[[COLOR=RoyalBlue][B]5[/B][/COLOR]] = {outfit = {lookType = 59, lookTypeEx = 0, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0}, firstManaCost = 1000, text = "Yo yeah men, I'm evoluting#@#!", textSayType = TALKTYPE_SAY, manaCost = 20, level = 40, gainMana = 1000, gainHealth = 1000, firstSoulCost = 1, soulCost = 0, time = 20, newVocation = 9, effect = CONST_ME_MAGIC_RED, firstEffect = nil},
[[COLOR=RoyalBlue][B]6[/B][/COLOR]] = {outfit = {lookType = 12, lookTypeEx = 0, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookAddons = 0}, firstManaCost = 1000, text = "Ha yoh ! I'm have superpowers!", textSayType = TALKTYPE_MONSTER, manaCost = 30, level = 40, gainMana = 1000, gainHealth = 1000, firstSoulCost = 1, soulCost = 0, time = 25, newVocation = 10, effect = CONST_ME_MAGIC_GREEN, firstEffect = CONST_ME_HOLYDAMAGE}
}
Transform_config =
{
[COLOR=Red][B]checkingLevel [/B][/COLOR]= true,
[COLOR=Red][B]checkingMana [/B][/COLOR]= true,
[COLOR=DarkOrchid][B]timeSaveStorage [/B][/COLOR]= 9750,
[COLOR=DarkOrchid][B]storageSaveOutfit [/B][/COLOR]= 9751, -- this storage value and six more must been unused.
[COLOR=DarkOrchid][B]storageSaveOldVocation [/B][/COLOR]= 9758,
[COLOR=SeaGreen][B]healTransformedPlayer [/B][/COLOR]= true,
[COLOR=Magenta][B]messages [/B][/COLOR]=
{
["wrong_vocation"] = "Your vocation hasn't any transformations.",
["low_level"] = "You need level %i at least to transformation.",
["not_have_mana"] = "You need %i manapoints to transformation."
}
}
Cyfra na niebiesko symbolizuje id profesji, dla kt?rej ta transformacja jest (tak - jedna profesja mo?e mie? tylko jednego transa. Jak kto? chce to sobie zmieni?, niech to ju? robi w swoim zakresie
Dalsz? cz??? tabeli my?l?, ?e nie trzeba t?umaczy?. Outfit to outfit, kt?ry gracz "za?o?y", level to wymagany poziom... Mo?na si? domy?li? Je?li chcesz doda? nowego transa - wzoruj si? na przyk?adach. To nie trudne
Teraz og?lny config. CheckingLevel i CheckingMana ustala, czy skrypt ma sprawdza? czy gracz posiada wymagany level i man? do transformacji. W sumie nie wiem po co to da?em ale jak ju? jest niech sobie b?dzie Aby to wy??czy?, nale?y wpisa? warto?? false.
Wszystkie te te na fioletowo to numer storage, na kt?rym b?d? zapisywane r??ne, potrzebne skryptowi warto?ci, jak stary outfit (tak, gdy transformacja si? sko?czy, gracz otrzymuje stary outfit), star? profesj? gracza oraz czas do ko?ca trwania transformacji.
Od healTransformedPlayer zale?y, czy gracz po transformacji ma zosta? uleczony (czyli je?li gracz am np. 400/1300 hp to jego zdrowie po transformacji wzro?nie do 1300. Z man? to samo)
messages to tabela z tekstami, kt?re s? wysy?ane do gracza je?li nei spe?nia jakich? warunk?w. Pierwszy to wiadomo??, gdy profesja gracza nie ma ?adnych transformacji. Druga to gdy gracz ma za ma?y poziom a trzecia, gdy typkowi brakuje many "%i" zostaje zast?pione przez skrypt wymaganym levelem b?d? man? do transformacji.
Konfiguracj? si?y, regeneracji zdrowia i innych pierd?? musicie zrobi? ju? sami, wedle swojego uznania, w vocations.xml
I to chyba ju? wsio. C??, je?li pojawi? si? jakie? b??dy, oczywi?cie piszcie! Og?lnie te? piszcie, w sumie zale?y mi na ocenach
Pozdro wienia! Bless.