--# 4 No changes
local focuses = {}
local function isFocused(cid)
for i, v in pairs(focuses) do
if(v == cid) then
return true
end
end
return false
end
local function addFocus(cid)
if(not isFocused(cid)) then
table.insert(focuses, cid)
end
end
local function removeFocus(cid)
for i, v in pairs(focuses) do
if(v == cid) then
table.remove(focuses, i)
break
end
end
end
local function lookAtFocus()
for i, v in pairs(focuses) do
if(isPlayer(v) == TRUE) then
doNpcSetCreatureFocus(v)
return
end
end
doNpcSetCreatureFocus(0)
end
--#5
local function doPlayerAddAttributePoint(cid, amount)
local current = getPlayerAttrStorage(cid)
local new = (current+amount)
setPlayerAttrStorage(cid, new)
return LUA_NO_ERROR
end
--#6
local function doPlayerCheckAttributePoint(cid)
local amt = getPlayerAttrStorage(cid)
return amt
end
--#7 No changes
function onCreatureAppear(cid)
end
function onCreatureDisappear(cid)
if(isFocused(cid)) then
selfSay("Hmph!")
removeFocus(cid)
if(isPlayer(cid) == TRUE) then
closeShopWindow(cid)
end
end
end
function onCreatureSay(cid, type, msg)
local Vitality =
{ [1] = {name = 'Sorcerer', cost = 100000, amount = 100000},
[2] = {name = 'Druid', cost = 100000, amount = 100000},
[3] = {name = 'Paladin', cost = 100000, amount = 200000},
[4] = {name = 'Knight', cost = 100000, amount = 200000},
[5] = {name = 'Master Sorcerer', cost = 100000, amount = 100000},
[6] = {name = 'Elder Druid', cost = 100000, amount = 100000},
[7] = {name = 'Royal Paladin', cost = 100000, amount = 200000},
[8] = {name = 'Elite Knight', cost = 100000, amount = 200000},
[9] = {name = 'Illusionist Mage', cost = 100000, amount = 200000},
[10] = {name = 'Elemental Master', cost = 100000, amount = 200000},
[11] = {name = 'Sniper', cost = 100000, amount = 300000},
[12] = {name = 'Blade Master', cost = 100000, amount = 300000},
}
local Energy =
{ [1] = {name = 'Sorcerer', cost = 100000, amount = 200000}, ---[1] = Vocation, Name = Vocation Name, Cost = Amount of Attribute Points Needed, Amount = MaxMana Added
[2] = {name = 'Druid', cost = 100000, amount = 200000},
[3] = {name = 'Paladin', cost = 100000, amount = 200000},
[4] = {name = 'Knight', cost = 100000, amount = 100000},
[5] = {name = 'Master Sorcerer', cost = 100000, amount = 200000},
[6] = {name = 'Elder Druid', cost = 100000, amount = 200000},
[7] = {name = 'Royal Paladin', cost = 100000, amount = 200000},
[8] = {name = 'Elite Knight', cost = 100000, amount = 100000},
[9] = {name = 'Illusionist Mage', cost = 100000, amount = 300000},
[10] = {name = 'Elemental Master', cost = 100000, amount = 300000},
[11] = {name = 'Sniper', cost = 100000, amount = 200000},
[12] = {name = 'Blade Master', cost = 100000, amount = 200000},
}
if((msg == "hi") and not (isFocused(cid))) then
selfSay("Ola "..getCreatureName(cid)..", Quer aprender sobre {Attribute Points}? Voce possui "..doPlayerCheckAttributePoint(cid).." attribute points.", cid)
addFocus(cid)
talk_state = 1
elseif((isFocused(cid)) and (msg == "attribute" or msg == "points" or msg == "help" or msg == "job" or msg == "attribute point" or msg == "attribute points")) and talk_state == 1 then
selfSay("Quando voce ganha levels, voce ganha attribute points. Voce pode gastar seus pontos em {vitality} ou {energy} para melhorar seu char.", cid)
elseif((isFocused(cid)) and (msg == "energy")) and talk_state == 1 then
selfSay("Como um "..(Energy[getPlayerVocation(cid)].name).." voce pode aumentar sua {energy} em "..(Energy[getPlayerVocation(cid)].amount)..". Vai custar "..(Energy[getPlayerVocation(cid)].cost).." attribute points.", cid)
selfSay("Voce quer gastar seus attribute points em energy?", cid)
talk_state = 2
elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 2 then
if doPlayerCheckAttributePoint(cid) >= Energy[getPlayerVocation(cid)].amount then
local maxmana = getCreatureMaxMana(cid)
setCreatureMaxMana(cid, (maxmana+Energy[getPlayerVocation(cid)].amount))
local mana = (getCreatureMaxMana(cid)-getCreatureMana(cid))
doCreatureAddMana(cid, mana)
doPlayerAddAttributePoint(cid, -(Energy[getPlayerVocation(cid)].cost))
selfSay("Sua energy foi aumentada em "..(Energy[getPlayerVocation(cid)].amount).."!", cid)
selfSay("Ate mais, volte sempre!", cid)
talk_state = 0
removeFocus(cid)
else
selfSay("Voce nao tem attribute points suficientes!", cid)
selfSay("Vai upar e volte depois.", cid)
talk_state = 0
removeFocus(cid)
end
elseif((isFocused(cid)) and (msg == "vitality")) and talk_state == 1 then
selfSay("Como um "..(Vitality[getPlayerVocation(cid)].name).." voce pode aumentar sua {vitality} em "..(Vitality[getPlayerVocation(cid)].amount)..". Vai custar "..(Vitality[getPlayerVocation(cid)].cost).." attribute points.", cid)
selfSay("Voce quer gastar seus pontos em vitality?", cid)
talk_state = 3
elseif((isFocused(cid)) and (msg == "yes" or msg == "ye")) and talk_state == 3 then
if doPlayerCheckAttributePoint(cid) >= Vitality[getPlayerVocation(cid)].cost then -- attempt to compare number with string, error that show in console
local maxhp = getCreatureMaxHealth(cid)
setCreatureMaxHealth(cid, (maxhp+Vitality[getPlayerVocation(cid)].amount))
local health = (getCreatureMaxHealth(cid)-getCreatureHealth(cid))
doCreatureAddHealth(cid, health)
doPlayerAddAttributePoint(cid, -(Vitality[getPlayerVocation(cid)].cost))
selfSay("Sua vitality foi aumentada em "..(Vitality[getPlayerVocation(cid)].amount).."!", cid)
selfSay("Ate mais, volte sempre!", cid)
talk_state = 0
removeFocus(cid)
else
selfSay("Voce nao tem attribute points suficientes!", cid)
selfSay("Vai upar e volte depois.", cid)
talk_state = 0
removeFocus(cid)
end
elseif((isFocused(cid)) and (msg == "bye" or msg == "goodbye" or msg == "cya")) then
selfSay("Ate mais!", cid, TRUE)
closeShopWindow(cid)
removeFocus(cid)
end
end
function onPlayerCloseChannel(cid)
if(isFocused(cid)) then
selfSay("Afff!")
closeShopWindow(cid)
removeFocus(cid)
end
end
function onPlayerEndTrade(cid)
selfSay("Foi um prazer fazer negocios com voce.", cid)
end
function onThink()
for i, focus in pairs(focuses) do
if(isCreature(focus) == FALSE) then
removeFocus(focus)
else
local distance = getDistanceTo(focus) or -1
if((distance > 4) or (distance == -1)) then
selfSay("Afff!")
closeShopWindow(focus)
removeFocus(focus)
end
end
end
lookAtFocus()
end