local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function doBuyPokemonWithCasinoCoins(cid, poke) npcHandler:onSellpokemon(cid) end
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
------------------------------------------------------------
local function buyPoke(cid, pokemon, price, lvl)
if pokemon == "" then return true end
local gender = getRandomGenderByName(pokemon)
local mypoke = getPokemonStatus(pokemon)
if not mypoke then return true end
local level = lvl
local extrastr = 1.5
local btype = "normal"
local offense = mypoke.off * level * extrastr
local defense = mypoke.def * level * extrastr
local speed = mypoke.agi * level * extrastr
local vit = mypoke.vit * level * extrastr
local spatk = mypoke.spatk * level * extrastr
local happy = 180
local leveltable = getPokemonExperienceTable(pokemon)
if getPlayerFreeCap(cid) >= 6 or getContainerSize(getPlayerSlotItem(cid, 3).uid) >= 18 then
item = doCreateItemEx(11826)
else
item = doAddContainerItem(getPlayerSlotItem(cid, 3).uid, 11826, 1)
end
doItemSetAttribute(item, "poke", pokemon)
doItemSetAttribute(item, "hp", 1)
doItemSetAttribute(item, "level", level)
doItemSetAttribute(item, "exp", leveltable[level])
doItemSetAttribute(item, "nextlevelexp", leveltable[level+1] - leveltable[level])
doItemSetAttribute(item, "offense", offense)
doItemSetAttribute(item, "defense", defense)
doItemSetAttribute(item, "speed", speed)
doItemSetAttribute(item, "vitality", vit)
doItemSetAttribute(item, "specialattack", spatk)
doItemSetAttribute(item, "happy", happy)
doItemSetAttribute(item, "gender", gender)
doItemSetAttribute(item, "description", "Contains a "..pokemon..".")
doItemSetAttribute(item, "fakedesc", "Contains a "..pokemon..".")
if getPlayerFreeCap(cid) >= 6 or getContainerSize(getPlayerSlotItem(cid, 3).uid) >= 18 then
doPlayerSendMailByName(getCreatureName(cid), item, 1)
end
setPlayerStorageValue(cid, 23254, getPlayerStorageValue(cid, 23254) - price)
end
------------------------------------------------------------------------------
if msgcontains(msg, 'pokemon') then
selfSay("Hello ".. getCreatureName(cid) .. ", I have two Pokemons to choose one among them, {Eevee} and {Porygon}, which would you choose? ", cid)
talkState[cid] = 1
elseif (msgcontains(msg, 'Eevee') or msgcontains(msg, 'eevee')) and talkState[cid] == 1 then
selfSay("Are you sure you want buy an Eevee for 22000 cassino coins?", cid)
talkState[cid] = 2
elseif (msgcontains(msg, 'Porygon') or msgcontains(msg, 'porygon')) and talkState[cid] == 1 then
selfSay("Are you sure you want buy an Porygon for 45000 cassino coins?", cid)
talkState[cid] = 3
elseif (msgcontains(msg, 'nao') or msgcontains(msg, 'no')) and talkState[cid] == 2 then
selfSay("Did not like this choice? You can choose one {Porygon} too.", cid)
talkState[cid] = 1
elseif (msgcontains(msg, 'nao') or msgcontains(msg, 'no')) and talkState[cid] == 3 then
selfSay("Did not like this choice? You can choose one {Eevee} too.", cid)
talkState[cid] = 1
elseif (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) and talkState[cid] == 2 then
if getPlayerStorageValue(cid, 23254) >= 22000 then
local pokemon = "Eevee"
local price = 22000
local lvl = 20
buyPoke(cid, pokemon, price, lvl)
selfSay("Here you are! You have just bought an "..pokemon.." for "..price.." casino coins!", cid)
talkState[cid] = 0
else
selfSay("You don't have enought cassino coins!", cid)
talkState[cid] = 0
end
elseif (msgcontains(msg, 'sim') or msgcontains(msg, 'yes')) and talkState[cid] == 3 then
if getPlayerStorageValue(cid, 23254) >= 45000 then
local pokemon = "Porygon"
local price = 45000
local lvl = 40
buyPoke(cid, pokemon, price, lvl)
selfSay("Here you are! You have just bought an "..pokemon.." for "..price.." casino coins!", cid)
talkState[cid] = 0
else
selfSay("You don't have enought cassino coins!", cid)
talkState[cid] = 0
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())