• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Npc Gym

wolverine18

New Member
Joined
Feb 28, 2012
Messages
4
Reaction score
0
When i made the NPC in my OT, everything was going well, but when the NPC summon its pokes, they dont atack!

Anyone can help me??

here is the code of the poke..

<?xml version="1.0" encoding="UTF-8"?>
<monster name="Erika Venusaur" nameDescription="a Erika Venusaur" race="grass" experience="11000" speed="200" manacost="490">
<health now="10200" max="10200"/>
<look type="22" head="0" body="0" legs="0" feet="0" corpse="5962"/>
<targetchange interval="1000" chance="1000"/>
<strategy attack="100" defense="0"/>

<flags>
<flag summonable="1"/>
<flag attackable="1"/>
<flag hostile="1"/>
<flag illusionable="1"/>
<flag convinceable="1"/>
<flag pushable="0"/>
<flag canpushitems="1"/>
<flag canpushcreatures="1"/>
<flag targetdistance="1"/>
<flag staticattack="90"/>
<flag runonhealth="0"/>
</flags>

<attacks>
<attack name="melee" interval="1700" min="-105" max="-145"/>
<attack name="razor leaf" interval="2300" chance="22" min="-75" max="-100">
</attack>
<attack name="vine whip" interval="2700" chance="30" min="-280" max="-360">
</attack>
<attack name="slash" interval="2100" range="1" chance="25" min="-140" max="-160">
</attack>
<attack name="acid" interval="2400" range="6" chance="25" min="-180" max="-210">
</attack>
<attack name="leaf storm" interval="3000" range="4" chance="19" min="-490" max="-500">
</attack>
<attack name="leaf blade" interval="3000" range="1" chance="22" min="-350" max="-480">
</attack>
<attack name="leech seed 2" range="3" interval="4000" chance="15" min="-50" max="-60">
</attack>
<attack name="solar beam" range="3" interval="4500" chance="20" min="-800" max="-1200">
</attack>
</attacks>

<defenses armor="30" defense="35"/>

<voices interval="5000" chance="10">
<voice sentence="Saur"/>
<voice sentence="VENUSAUR"/>
</voices>

</monster>
 
Look at your attack code, it must have a attribute aswell.

Like this attack,

Code:
        <attack name="ice" interval="2000" chance="20" range="7" spread="0" min="-700" max="-1000">
            <attribute key="areaEffect" value="icearea"/>
        </attack>
 
I noticed that few of my POKEMONS have attributes, i tried "atrribute key: areaeffect, value=grass" and still not working, i mean, it didnt atacked me.

Where do i check all the possible attributes that I can use?

anyone can help me with that?!

Btw: when i selected the target, it keeps the selection, but i cant make a move against it.
 
Here it is, my data/lib and data/npc
if there is any mistake, could anyone tell me what is it?!



data/lib/gymlib

funcpokemon = {2220, 2222} -- ID das pokebolas (o pokemon tem que estar vivo nessas IDs)
bpslot = CONST_SLOT_AMMO --em outros servers, pode ser que seja CONST_SLOT_BACKPACK o lugar onde fica a backpack no inventory

ginasios = {
["Erika"] = { storage = 992,
msgdefeat = "You lost! You aren't strong enough yet, don't come back until you get stronger!",
msgafk = "Go away if you don't have any pokemons!",
msgwin = "Congratulations, you were strong enough to win this battle fairly! Take this Rainbow Badge as reward.",
[1] = { msggo = "Lets fight then! I choose you, Venusaur!",
msgba = "That's enough, Venusaur!",
pokem = "Erika Venusaur",
nextp = "Erika Vileplume"},
[2] = { msggo = "It's your turn, Vileplume!",
msgba = "Come back, Vileplume!",
pokem = "Erika Vileplume",
nextp = "Erika Exeggutor"},
[3] = { msggo = "Crush'em, Exeggutor!",
msgba = "You did well, Exeggutor!",
pokem = "Erika Exeggutor",
nextp = "Erika Victreebel"},
[4] = { msggo = "Crush'em, Victreebel!",
msgba = "You did well, Victreebel!",
pokem = "Erika Victreebel",
nextp = "finish"}
}
}

function noPokeAtAll(cid, gympoke, npcname, msgafk)
if not isCreature(cid) then
return false
end
if not isCreature(gympoke) then
return false
end
if #getCreatureSummons(cid) == 0 and getPlayerStorageValue(cid,
992) == 0 and getPlayerStorageValue(cid, ginasios[npcname].storage) ~= 2
then
setPlayerStorageValue(cid, 992, -1)
doCreatureSay(getCreatureByName(npcname), msgafk, 1)
doSendMagicEffect(getThingPos(gympoke), 10)
setPlayerStorageValue(cid, ginasios[npcname].storage, 0)
doRemoveCreature(gympoke)
return true
end
end

function gymChecker(cid, duel, nb, npcname)
if not isCreature(cid) then
return true
end
if not isCreature(duel) then
doSendMagicEffect(getThingPos(cid), 10)
doRemoveCreature(cid)
return true
end
if getDistanceBetween(getThingPos(getCreatureByName(npcname)), getThingPos(duel)) >= 8 then
doSendMagicEffect(getThingPos(cid), 10)
doRemoveCreature(cid)
setPlayerStorageValue(duel, ginasios[npcname].storage, 0)
return true
end
if isCreature(duel) and getPlayerStorageValue(duel, 992) == 0 then
addEvent(noPokeAtAll, 6000, duel, cid, npcname, ginasios[npcname].msgafk)
end
if isCreature(duel) and getPlayerStorageValue(duel, 992) == -1 then
doSendMagicEffect(getThingPos(cid), 10)
doRemoveCreature(cid)
setPlayerStorageValue(duel, ginasios[npcname].storage, 0)
doCreatureSay(getCreatureByName(npcname), ginasios[npcname].msgdefeat, 1)
return true
end
if isCreature(duel) and not hasPokemon(duel) then
setPlayerStorageValue(duel, 992, -1)
end
if not isCreature(getCreatureTarget(cid)) then
if nb == 0 then
addEvent(gymChecker, 200, cid, duel, 1, npcname)
else
doSendMagicEffect(getThingPos(cid), 10)
doRemoveCreature(cid)
if isCreature(duel) then
setPlayerStorageValue(duel, ginasios[npcname].storage, 0)
end
end
return true
end
addEvent(gymChecker, 1000, cid, duel, 0, npcname)
end

function hasPokemon(cid)

if #getCreatureSummons(cid) >= 1 then
return true
end

if isInArray(funcpokemon, getPlayerSlotItem(cid, CONST_SLOT_FEET).itemid) then
return true
end

local bp = getPlayerSlotItem(cid, bpslot)

for cc = 1, #funcpokemon do
if #getItemsInContainerById(bp.uid, funcpokemon[cc]) >= 1 then
return true
end
end

return false
end

function doGymBattle(npcname, gympoke, cid, turn)
doCreatureSay(getCreatureByName(npcname), ginasios[npcname][turn].msggo, 1)
local x = doSummonCreature(gympoke, getThingPos(getCreatureByName(npcname)))
registerCreatureEvent(x, "Gym1")
registerCreatureEvent(x, "Gym2")
registerCreatureEvent(x, "Gym3")
registerCreatureEvent(x, "Gym4")
setPlayerStorageValue(x, 201, ".")
setPlayerStorageValue(x, 201, npcname)
setPlayerStorageValue(x, 202, turn)
doSendMagicEffect(getThingPos(x), 10)
setPlayerStorageValue(x, ginasios[npcname].storage, 1)
addEvent(gymChecker, 1000, x, cid, 0, npcname)
end

data/npc/scripts
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
local talkState = {}

function onThingMove(creature, thing, oldpos, oldstackpos)
end

function onCreatureAppear(creature)
end

function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye sir!')
focus = 0
talk_start = 0
end
end

function onCreatureTurn(creature)
end

function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end

function onCreatureSay(cid, type, msg)
local msg = string.lower(msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

if (msgcontains(msg, 'hi') and (focus == 0) and (focus ~= cid) and (getDistanceToCreature(cid) <= 4)) then
focus = cid
talkState[talkUser] = 1
selfSay("Welcome to the gym of Celadon City. My name is Erika and I am the leader of this gym. Would you like to battle me?")
elseif (msgcontains(msg, "no") or msgcontains(msg, "bye")) and focus == cid and talkState[talkUser] ~= 3 then
selfSay("Bye then, tell strong friends to come here and try to beat me!")
focus = 0
elseif (msgcontains(msg, "yes") or msgcontains(msg, "battle")) and focus == cid and talkState[talkUser] == 1 then
if not hasPokemon(cid) then
selfSay("You don't have any pokemon to battle me!")
focus = 0
return true
end
talkState[talkUser] = 3
doGymBattle("Erika", "Erika Venusaur", cid, 1)
setPlayerStorageValue(cid, ginasios["Erika"].storage, 1)
setPlayerStorageValue(cid, 992, 0)

local function focusCheck(cid)
if not isCreature(cid) then
focus = 0
return true
end
if getPlayerStorageValue(cid, 992) == -1 then
focus = 0
return true
end
addEvent(focusCheck, 500, cid)
end

addEvent(focusCheck, 1000, cid)
end
end

function onThink()
if focus ~= 0 then
a, b, c = selfGetPosition()
if c ~= getThingPos(focus).z then
focus = 0
end
end

if focus ~= 0 then
if getDistanceToCreature(focus) > 6 then
focus = 0
end
end

return true
end
 
Back
Top