8.X - Potiony które mają użycia!
PRzeSteR
8.X - Potiony które mają użycia!1 załącznik(ów) Witam. :) Od tej pory na twoim OTS nie będzie latania i kupowania po 200 bp potionów, bo można to zrobić dodając użycia do nich.
Z góry oświadczam że użyte skrypty nie są moje, jednak przerobienie ich + wykonanie w 100% by me. Więc jedziemy:
W
Cytat:
data\actions\scripts\liquids\ tworzymy plik
Cytat:
potions.lua A w nim wklejamy to:
Cytat:
local ultimateHealthPot = 8473
local greatHealthPot = 7591
local greatManaPot = 7590
local greatSpiritPot = 8472
local strongHealthPot = 7588
local strongManaPot = 7589
local healthPot = 7618
local manaPot = 7620
local smallHealthPot = 8704
local antidotePot = 8474
local greatEmptyPot = 7635
local strongEmptyPot = 7634
local emptyPot = 7636
local antidote = createCombatObject()
setCombatParam(antidote, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(antidote, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(antidote, COMBAT_PARAM_TARGETCASTERORTOPMOST, TRUE)
setCombatParam(antidote, COMBAT_PARAM_AGGRESSIVE, FALSE)
setCombatParam(antidote, COMBAT_PARAM_DISPEL, CONDITION_POISON)
local exhaust = createConditionObject(CONDITION_EXHAUST_HEAL)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, getConfigInfo('timeBetweenExActions'))
function onUse(cid, item, fromPosition, itemEx, toPosition)
if(itemEx.uid ~= cid or itemEx.itemid ~= 1) then
return TRUE
end
if(getCreatureCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return TRUE
end
if(item.itemid == antidotePot) then
if(doCombat(cid, antidote, numberToVariant(cid)) == LUA_ERROR) then
return FALSE
end
doRemoveCondition(cid, CONDITION_PARALYZE)
doAddCondition(cid, exhaust)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_RED)
doRemoveItem(item.uid, emptyPot)
elseif(item.itemid == smallHealthPot) then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 50, 100, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doRemoveCondition(cid, CONDITION_PARALYZE)
doAddCondition(cid, exhaust)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_ORANGE)
doChangeTypeItem(item.uid, item.type - 1)
elseif(item.itemid == healthPot) then
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 300, 400, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_RED)
doChangeTypeItem(item.uid, item.type - 1)
elseif(item.itemid == manaPot) then
if(doTargetCombatMana(0, cid, 280, 400, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doRemoveCondition(cid, CONDITION_PARALYZE)
doAddCondition(cid, exhaust)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_RED)
doChangeTypeItem(item.uid, item.type - 1)
elseif(item.itemid == strongHealthPot) then
if(not(isKnight(cid) or isPaladin(cid)) or (getPlayerLevel(cid) < 50)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by paladins and knights of level 50 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 795, 800, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_RED)
doChangeTypeItem(item.uid, item.type - 1)
elseif(item.itemid == strongManaPot) then
if(not(isSorcerer(cid) or isDruid(cid) or isPaladin(cid)) or (getPlayerLevel(cid) < 50)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by sorcerers, druids and paladins of level 50 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end
if(doTargetCombatMana(0, cid, 695, 700, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doRemoveCondition(cid, CONDITION_PARALYZE)
doAddCondition(cid, exhaust)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_RED)
doChangeTypeItem(item.uid, item.type - 1)
elseif(item.itemid == greatSpiritPot) then
if(not(isPaladin(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by paladins of level 80 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 800, 820, CONST_ME_MAGIC_BLUE) == LUA_ERROR or doTargetCombatMana(0, cid, 900, 920, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doRemoveCondition(cid, CONDITION_PARALYZE)
doAddCondition(cid, exhaust)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_RED)
doChangeTypeItem(item.uid, item.type - 1)
elseif(item.itemid == greatHealthPot) then
if(not(isKnight(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by knights of level 80 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 900, 1000, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_RED)
doChangeTypeItem(item.uid, item.type - 1)
elseif(item.itemid == greatManaPot) then
if(not(isSorcerer(cid) or isDruid(cid)) or (getPlayerLevel(cid) < 80)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by sorcerers and druids of level 80 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end
if(doTargetCombatMana(0, cid, 995, 1000, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doRemoveCondition(cid, CONDITION_PARALYZE)
doAddCondition(cid, exhaust)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_RED)
doChangeTypeItem(item.uid, item.type - 1)
elseif(item.itemid == ultimateHealthPot) then
if(not(isKnight(cid)) or (getPlayerLevel(cid) < 130)) and not(getPlayerGroupId(cid) >= 2) then
doCreatureSay(cid, "This potion can only be consumed by knights of level 130 or higher.", TALKTYPE_ORANGE_1)
return TRUE
end
if(doTargetCombatHealth(0, cid, COMBAT_HEALING, 1600, 1800, CONST_ME_MAGIC_BLUE) == LUA_ERROR) then
return FALSE
end
doAddCondition(cid, exhaust)
doSendAnimatedText(getPlayerPosition(cid), "Aaaah...", TEXTCOLOR_RED)
doChangeTypeItem(item.uid, item.type - 1)
end
return TRUE
end Ile ma leczyć/dawać many dany potion
V2Sprawdzone na silniku TFS 0.3.6 - nie wywala błędów w consoli!
Cytat:
local config = {
removeOnUse = "no",
usableOnTarget = "yes", -- can be used on target? (fe. healing friend)
splashable = "yes",
realAnimation = "yes", -- make text effect visible only for players in range 1x1
healthMultiplier = 1.0,
manaMultiplier = 1.0
}
config.removeOnUse = getBooleanFromString(config.removeOnUse)
config.usableOnTarget = getBooleanFromString(config.usableOnTarget)
config.splashable = getBooleanFromString(config.splashable)
config.realAnimation = getBooleanFromString(config.realAnimation)
local POTIONS = {
[8704] = {empty = 7636, splash = 2, health = {50, 100}}, -- small health potion
[7618] = {empty = 7636, splash = 2, health = {100, 200}}, -- health potion
[7588] = {empty = 7634, splash = 2, health = {200, 400}, level = 50, vocations = {3, 4, 7, 8}, vocStr = "knights and paladins"}, -- strong health potion
[7591] = {empty = 7635, splash = 2, health = {500, 700}, level = 80, vocations = {4, 8}, vocStr = "knights"}, -- great health potion
[8473] = {empty = 7635, splash = 2, health = {800, 1000}, level = 130, vocations = {4, 8}, vocStr = "knights"}, -- ultimate health potion
[7620] = {empty = 7636, splash = 7, mana = {70, 130}}, -- mana potion
[7589] = {empty = 7634, splash = 7, mana = {110, 190}, level = 50, vocations = {1, 2, 3, 5, 6, 7}, vocStr = "sorcerers, druids and paladins"}, -- strong mana potion
[7590] = {empty = 7635, splash = 7, mana = {200, 300}, level = 80, vocations = {1, 2, 5, 6}, vocStr = "sorcerers and druids"}, -- great mana potion
[8472] = {empty = 7635, splash = 3, health = {200, 400}, mana = {110, 190}, level = 80, vocations = {3, 7}, vocStr = "paladins"} -- great spirit potion
}
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, fromPosition, itemEx, toPosition)
local potion = POTIONS[item.itemid]
if(not potion) then
return false
end
if(not isPlayer(itemEx.uid) or (not config.usableOnTarget and cid ~= itemEx.uid)) then
if(not config.splashable) then
return false
end
if(toPosition.x == CONTAINER_POSITION) then
toPosition = getThingPos(item.uid)
end
doDecayItem(doCreateItem(2016, potion.splash, toPosition))
doChangeTypeItem(item.uid, item.type - 1)
return true
end
if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return true
end
if(((potion.level and getPlayerLevel(cid) < potion.level) or (potion.vocations and not isInArray(potion.vocations, getPlayerVocation(cid)))) and
not getPlayerCustomFlagValue(cid, PLAYERCUSTOMFLAG_GAMEMASTERPRIVILEGES))
then
doCreatureSay(itemEx.uid, "Only " .. potion.vocStr .. (potion.level and (" of level " .. potion.level) or "") .. " or above may drink this fluid.", TALKTYPE_ORANGE_1)
return true
end
local health = potion.health
if(health and not doCreatureAddHealth(itemEx.uid, math.ceil(math.random(health[1], health[2]) * config.healthMultiplier))) then
return false
end
local mana = potion.mana
if(mana and not doPlayerAddMana(itemEx.uid, math.ceil(math.random(mana[1], mana[2]) * config.manaMultiplier))) then
return false
end
doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_MAGIC_BLUE)
if(not realAnimation) then
doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1)
else
for i, tid in ipairs(getSpectators(getCreaturePosition(cid), 1, 1)) do
if(isPlayer(tid)) then
doCreatureSay(itemEx.uid, "Aaaah...", TALKTYPE_ORANGE_1, false, tid)
end
end
end
doAddCondition(cid, exhaust)
if(not potion.empty or config.removeOnUse) then
doRemoveItem(item.uid)
return true
end
doChangeTypeItem(item.uid, item.type - 1)
return true
end Teraz actions.xml w silnikach 8.4+ :
Cytat:
<action itemid="7588-7591;8472-8473;7618;7620;8704" event="script" value="liquids/potions.lua"/> a w starszych:
Cytat:
<action itemid="7588" script="liquids/potions.lua"/>
<action itemid="7589" script="liquids/potions.lua"/>
<action itemid="7590" script="liquids/potions.lua"/>
<action itemid="7591" script="liquids/potions.lua"/>
<action itemid="8472" script="liquids/potions.lua"/>
<action itemid="8473" script="liquids/potions.lua"/>
<action itemid="8704" script="liquids/potions.lua"/>
<action itemid="7620" script="liquids/potions.lua"/>
<action itemid="7618" script="liquids/potions.lua"/> Na końcu items.xml:
Przy każdym potionie dodać komende aby miały charges + aby charges były widoczne.
Np:
Cytat:
<item id="7588" article="a" name="strong health potion">
<attribute key="weight" value="200"/>
<attribute key="charges" value="3"/>
<attribute key="showcharges" value="1"/>
<attribute key="description" value="This potion can only be consumed by paladins and knights of level 50 or higher."/>
</item> To trzeba dodać do każdego Potiona.
Jeszcze na koniec ID potionów:
Cytat:
7588
7589
7590
7591
8472
8473
8704
7620
7618 Teraz w npc/scripts/runes.lua
Zamiast:
Cytat:
shopModule:addBuyableItem({'health potion'}, 7618, 45, 'health potion') Dać:
Cytat:
shopModule:addBuyableItem({'health potion'}, 7618, 45, 10, 'health potion') 10 to liczba użyć w potionie.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SS w załączniku.
Mam nadzieje że komuś się przyda. Mogą występować ewentualne błędy w consoli - to zależy od silnika, ale działa na 100%. Testowane na 8.40 8.42 8.50 8.54 na silnikach TFS.
Tylko skrypt na potiony nie jest mój. Jest to standardowy skrypt na TFS'ach.!
Cytat:
Zastrzegam prawo do kopiowania mojego postu/udostępniania skryptu bez podania linku do oryginalnego (czyt. tego) tematu!
Bradzo przydane wielkie dzienki
;o Czego to nie wymyślą to jest coś w stylu RonOts + za skrypt naprawdę m się przyda!
oo wlasnie czegos takiego szukalem , wielkie dzieki
Przepraszam, że odświeżam temat. Ale mam pytanie, ponieważ potrzebuje bardzo ten skrypt, a wyskakują mi w nim błędy:
Kod: [23/04/2010 23:48:36] [Error - Action Interface]
[23/04/2010 23:48:36] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:36] Description:
[23/04/2010 23:48:36] (luaCreateConditionObject) Condition not found
[23/04/2010 23:48:36] [Error - Action Interface]
[23/04/2010 23:48:36] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:36] Description:
[23/04/2010 23:48:36] (luaSetConditionParam) Condition not found
[23/04/2010 23:48:36] [Error - Action Interface]
[23/04/2010 23:48:36] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:36] Description:
[23/04/2010 23:48:36] (luaCreateConditionObject) Condition not found
[23/04/2010 23:48:36] [Error - Action Interface]
[23/04/2010 23:48:36] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:36] Description:
[23/04/2010 23:48:36] (luaSetConditionParam) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaCreateConditionObject) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaSetConditionParam) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaCreateConditionObject) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaSetConditionParam) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaCreateConditionObject) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaSetConditionParam) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaCreateConditionObject) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaSetConditionParam) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaCreateConditionObject) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaSetConditionParam) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaCreateConditionObject) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaSetConditionParam) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaCreateConditionObject) Condition not found
[23/04/2010 23:48:37] [Error - Action Interface]
[23/04/2010 23:48:37] data/actions/scripts/liquids/potions.lua
[23/04/2010 23:48:37] Description:
[23/04/2010 23:48:37] (luaSetConditionParam) Condition not found
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item with id: 9743, in fromid: 9743 and toid: 9744
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item with id: 9744, in fromid: 9743 and toid: 9744
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7588
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7589
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7590
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7591
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7618
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7620
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 8472
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 8473
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 8704
[23/04/2010 23:48:37]
Pomógłbyś?
Cytat:
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item with id: 9743, in fromid: 9743 and toid: 9744
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item with id: 9744, in fromid: 9743 and toid: 9744
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7588
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7589
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7590
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7591
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7618
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 7620
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 8472
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 8473
[23/04/2010 23:48:37] [Warning - Actions::registerEvent] Duplicate registered item id: 8704 To oznacza że ID potionów jest już używane w actions.xml :)
Cytat:
(luaCreateConditionObject) To oznacza że "exhausted" masz "wbudowany" w OTS pod inną nazwą. Zignoruj to, a jeśli ci przeszkadzają "błędy" w silniku to popróbuj sam. Ja już nie robie skryptów - nie mam chęci. Zajrzałem poprostu w mój stary temacik. (Chyba najlepszy skrypt jaki napisałem). ;]
Fajne kto na to wpadł ;D
Pozdrawiam Stalin
Mam dwa pytania:
1. Czy za możliwość posiadania potionow w danej ilości odpowiada dopisek w items.xml
2. Da się zrobić tak aby można je było rozdzielać i laczyc jak na 8.6?
odrazu mowie : silnik XML Aries (8.1)
@up
1. Nie, nie odpowiada za to dopisek w items.xml. Dopisek w items.xml jest po to aby "uświadomic" nasz silnik o tym że Potion posiada charges - uzycia.
2. To już wyższa szkoła jazdy C++ oraz DatEditor. Ja niestety nie potrafie tego zrobic.
@2x up
Wpadlo na to pewnie dużo osób. Jednak ten skrypt jest wykonany w 100% przeze mnie. Czyt. kombinacje ze standardowym skryptem TFS'a.
To wkoncu jest na 7.6 czy 8.X ?
@UP
Są dwie wersje masz w pierwszym poście. Pierwszy skrypt do actions jest pod starsze wersje, a drugi do actions pod nowsze (raczej 8.x).
@TOPIC
Za skrypt 10/10. Z pewnością wykorzystam go w swoim OTS'ie.
@2x up
V1 jest na silniki TFS pod 8.40 +, V2 jest pod 8.54 +. Jednak można spróbowac wersji V2 na starszych silnikach. Nie jestem pewien czy zadziała ale z pewnością nie wywala błędów w consoli.
A można zrobić żeby były numerki przy potionie ile zostało?
Wielkie dzięki :)