Ir para conteúdo
  • 0

[ERROR] Addon System em RIDE,FLY E SURF!


boxxer321

Pergunta

Galera, cá estou eu mais uma vez por conta desse addon system kkk

o problema é o seguinte: 

assim que voce entra em RIDE, FLY ou SURF, voce continua tendo acesso a janela do "set outfit" como a imagem abaixo, e quando voce troca o seu addon do pokémon durante o ride. fly etc, o do player troca junto...

Queria saber se tem alguma forma de por um exhausted caso o player esteja em FLY, RIDE E SURF, na hora de tentar trocar o addon.

 

Imagens do erro:

erro2.png.5a95946736c59cf83a5a389d16796fbf.png

 

Após a contra:

erro1.png.d889c503e478a695f890cae701a1f247.png

 

vou deixar meu creaturescrips/addon.lua e meu lib/order.lua, caso precisem.

 

addon.lua

Spoiler

function onOutfit(cid, old, current)
local pk = getCreatureSummons(cid)
if #pk >= 1 and getPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default) >= 1 then
    
    local oldStorages = string.explode(getPlayerStorageValue(cid, storages.addonSystem), ",")
    for i = 1, #oldStorages do
      for t1, t2 in pairs(stringStorages) do
       if oldStorages[i] == t1 then
          setPlayerStorageValue(cid, t2, 1)
       end
      end 
    end
    
    local oldStoragess = string.explode(getPlayerStorageValue(cid, storages.addonSystem3), ",")
    for i = 1, #oldStoragess do
      for t1, t2 in pairs(pokeStrings) do
       if i >= 1 and oldStoragess[i] == t1 then
          setPlayerStorageValue(cid, t2, 0)
          setPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default, 0)
       end
      end 
    end
      for id1, id2 in pairs(itensAddons) do
       local a = {"addon", "addon2", "addon3", "addon4", "addon5", "addon6", "addon7"}
          for i = 1, #a do 
           if getItemAttribute(getPlayerSlotItem(cid, 8).uid, a[i]) == id2.addon then 
             setPlayerStorageValue(cid, id2.stor, 0)
             setPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default, 0)
           else
             setPlayerStorageValue(cid, pokeAddons[getPokemonName(pk[1])].default, 0)  
          end
          end
      end
    setPlayerStorageValue(cid, storages.checkOutfitColor, "")
    setPlayerStorageValue(cid, storages.checkOutfitColor, getPlayerStorageValue(cid, storages.checkOutfitColor)..","..getCreatureOutfit(cid).lookBody..","..getCreatureOutfit(cid).lookHead..","..getCreatureOutfit(cid).lookLegs..","..getCreatureOutfit(cid).lookFeet) 
    setPlayerStorageValue(cid, storages.addonSystem2, getCreatureOutfit(cid).lookType) 
    addEvent(doSet, 2, cid, pk)
           

end
return true
end

function doSet(cid, summon)
if not isCreature(cid) then return true end
if not isCreature(summon[1]) then return true end
local out = getCreatureOutfit(cid)
local colors = string.explode(","..getPlayerStorageValue(cid, storages.checkOutfitColor), ",")
    doSetCreatureOutfit(summon[1], {lookType = getCreatureOutfit(cid).lookType, lookBody = out.lookBody, lookHead = out.lookHead, lookLegs = out.lookLegs, lookFeet = out.lookFeet}, -1)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color1", out.lookBody)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color2", out.lookHead)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color3", out.lookLegs)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "color4", out.lookFeet)
    doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "addonNow", getCreatureOutfit(cid).lookType)
    doCreatureChangeOutfit(cid, {lookType = getPlayerStorageValue(cid, storages.addonSystem2), lookBody = colors[1], lookHead = colors[2], lookLegs = colors[3], lookFeet = colors[4]})
end

 

 

order.lua

Spoiler

local dirpref = {
[1] =  {[NORTH] = {[1] = {NORTH}, [2] = {EAST, WEST}, [3] = {NORTHEAST, NORTHWEST}},
	[EAST] = {[1] = {EAST}, [2] = {NORTH, SOUTH}, [3] = {NORTHEAST, SOUTHEAST}},
	[SOUTH] = {[1] = {SOUTH}, [2] = {EAST, WEST}, [3] = {SOUTHEAST, SOUTHWEST}},
	[WEST] = {[1] = {WEST}, [2] = {SOUTH, NORTH}, [3] = {NORTHWEST, SOUTHWEST}},
	[NORTHEAST] = {[1] = {NORTH, EAST}, [2] = {NORTHEAST}, [3] = {SOUTH, WEST}},
	[SOUTHEAST] = {[1] = {SOUTH, EAST}, [2] = {SOUTHEAST}, [3] = {NORTH, WEST}},
	[SOUTHWEST] = {[1] = {SOUTH, WEST}, [2] = {SOUTHWEST}, [3] = {NORTH, EAST}},
	[NORTHWEST] = {[1] = {NORTH, WEST}, [2] = {NORTHWEST}, [3] = {EAST, SOUTH}}},
[2] =  {[NORTH] = {[1] = {NORTH}, [2] = {WEST, EAST}, [3] = {NORTHWEST, NORTHEAST}},
	[EAST] = {[1] = {EAST}, [2] = {SOUTH, NORTH}, [3] = {SOUTHEAST, NORTHEAST}},
	[SOUTH] = {[1] = {SOUTH}, [2] = {WEST, EAST}, [3] = {SOUTHWEST, SOUTHEAST}},
	[WEST] = {[1] = {WEST}, [2] = {NORTH, SOUTH}, [3] = {SOUTHWEST, NORTHWEST}},
	[NORTHEAST] = {[1] = {EAST, NORTH}, [2] = {NORTHEAST}, [3] = {WEST, SOUTH}},
	[SOUTHEAST] = {[1] = {EAST, SOUTH}, [2] = {SOUTHEAST}, [3] = {WEST, NORTH}},
	[SOUTHWEST] = {[1] = {WEST, SOUTH}, [2] = {SOUTHWEST}, [3] = {EAST, NORTH}},
	[NORTHWEST] = {[1] = {WEST, NORTH}, [2] = {NORTHWEST}, [3] = {SOUTH, EAST}}},
}

function doPushCreature(uid,direction,distance,time)
   if isCreature(uid) == TRUE then
   local rand = (2*math.random(0,1))-1
   local rand2 = math.random(-1,0)
	  if direction == 0 then
	  signal = {0,rand,-rand,rand,-rand,0,-1,-1,-1,0,0,0}
	  elseif direction == 1 then
	  signal = {1,1,1,0,0,0,0,rand,-rand,rand,-rand,0}
	  elseif direction == 2 then
	  signal = {0,rand,-rand,rand,-rand,0,1,1,1,0,0,0}

	  elseif direction == 3 then

	  signal = {-1,-1,-1,0,0,0,0,rand,-rand,rand,-rand,0}

	  elseif direction == 4 then

	  signal = {-1,rand2,(-rand2)-1,0,1,rand2+1,rand2,0}

	  elseif direction == 5 then

	  signal = {1,-rand2,-((-rand2)-1),0,1,rand2+1,rand2,0}

	  elseif direction == 6 then

	  signal = {-1,rand2,(-rand2)-1,0,-1,(-rand2)-1,rand2,0}

	  else

	  signal = {1,-rand2,-((-rand2)-1),0,-1,(-rand2)-1,rand2,0}

	  end

   local pos = getThingPos(uid)

   nsig = #signal

   nvar = 0

   

   repeat

   nvar = nvar+1

   newpos = {x=pos.x+(signal[nvar]),y=pos.y+(signal[(nsig/2)+nvar]),z=pos.z}

   newtile = {x=newpos.x,y=newpos.y,z=newpos.z,stackpos=0}

   until getTileThingByPos(newtile).uid ~= 0 and hasProperty(getTileThingByPos(newtile).uid,3) == FALSE and canWalkOnPos(newtile, true, false, true, true, false) and queryTileAddThing(uid,newpos) == 1 or nvar == (nsig/2)
                                                                                                                        --alterado v2.5
   

	  if distance == nil or distance == 1 then

	  doTeleportThing(uid,newpos,TRUE)   

	  else

	  distance = distance-1

	  doTeleportThing(uid,newpos,TRUE)

		 if time ~= nil then

		 addEvent(doPushCreature,time,uid,direction,distance,time)

		 else

		 addEvent(doPushCreature,500,uid,direction,distance,500)

		 end	   

	  end

   end  

end

function doComparePosition(pos1, pos2)
	if pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z then
	return true
	end
return false
end

function getNextStepDelay(cid, dir)
	return 868
end

function walkTo(cid, direction, finalp, useExtraMoveOrder)
	if not isCreature(cid) then return true end

	doChangeSpeed(cid, 5)
	local x = getThingPos(cid)
	local ratedelaywalk = 1
	local finalpos = {x = finalp.x, y = finalp.y, z = finalp.z}

		if not canWalkOnPos(finalpos, false, false, true, true, true) then
			finalpos = getClosestFreeTile(cid, finalpos)
		end

		if not finalpos then
		return false
		end

	local dir = getDirectionTo(getThingPos(cid), finalpos)
	if dir and tonumber(dir) ~= nil and tonumber(dir) >= 0 and tonumber(dir) <= 7 then
		if dir >= 4 then
			ratedelaywalk = 0.4
		end
		doPushCreature(cid, dir, 1, getNextStepDelay(cid, dir) * ratedelaywalk)
		return getNextStepDelay(cid, dir) * ratedelaywalk
	elseif useExtraMoveOrder then

local random = math.random(1, 2)

	for ta = 1, 3 do
		for tb = 1, #dirpref[random][direction][ta] do
			local y = getPosByDir(getThingPos(cid), dirpref[random][direction][ta][tb])
			local w = getCreatureLP(cid)
			local z = getDirectionTo(y, getThingPos(cid)) -- direção q vai marcar
			local j = getDirectionTo(getThingPos(cid), y) -- direção q ele vai
			if canWalkOnPos(y, true, false, true, true, true) and w ~= j then
				if dirpref[random][direction][ta][tb] >= 4 then
					ratedelaywalk = 0.5
				end
				doPushCreature(cid, dirpref[random][direction][ta][tb], 1, getNextStepDelay(cid, dirpref[random][direction][ta][tb]) * ratedelaywalk)
				markLP(cid, z)
			return getNextStepDelay(cid, dirpref[random][direction][ta][tb]) * ratedelaywalk
			end
		end
	end
	end
return false
end

function getCreatureLP(cid)
return getPlayerStorageValue(cid, 197)
end

function markLP(cid, dir)
setPlayerStorageValue(cid, 197, dir)
end

function markPos(sid, pos)
if not isCreature(sid) then return end
setPlayerStorageValue(sid, 145, pos.x)
setPlayerStorageValue(sid, 146, pos.y)
setPlayerStorageValue(sid, 147, pos.z)
end

function markFlyingPos(sid, pos)
if not isCreature(sid) then return end
setPlayerStorageValue(sid, 33145, pos.x)
setPlayerStorageValue(sid, 33146, pos.y)
setPlayerStorageValue(sid, 33147, pos.z)
end

function getFlyingMarkedPos(sid)
if not isCreature(sid) then return end
local xx = getPlayerStorageValue(sid, 33145)
local yy = getPlayerStorageValue(sid, 33146)
local zz = getPlayerStorageValue(sid, 33147)
return {x = xx, y = yy, z = zz, stackpos = 0}
end

function getMarkedPos(sid)
if not isCreature(sid) then return end
local xx = getPlayerStorageValue(sid, 145)
local yy = getPlayerStorageValue(sid, 146)
local zz = getPlayerStorageValue(sid, 147)
return {x = xx, y = yy, z = zz}
end

function getOwnerPos(sid)
if not isCreature(sid) then return end
local xx = getPlayerStorageValue(sid, 148)
local yy = getPlayerStorageValue(sid, 149)
local zz = getPlayerStorageValue(sid, 150)
return {x = xx, y = yy, z = zz}
end

function markOwnerPos(sid, pos)
if not isCreature(sid) then return end
setPlayerStorageValue(sid, 148, pos.x)
setPlayerStorageValue(sid, 149, pos.y)
setPlayerStorageValue(sid, 150, pos.z)
end

function recheck(sid, skill, pos)
    if not isCreature(sid) then return end
    local cid = getCreatureMaster(sid)

    if skill == "cut" then

        local item = getTileItemById(pos, 2767)
        doCreatureSay(sid, "CUT!", TALKTYPE_ORANGE_1)
        markPos(sid, {x=1,y=1,z=7})
        doFaceCreature(sid, pos)
        doSendMagicEffect(getThingPos(item.uid), 141)
        doTransformItem(item.uid, 6216)
            local function growBush()
            doTransformItem(getTileItemById(pos, 6216).uid, 2767)
            end
        addEvent(growBush, intervalToRegrowBushAndStones * 1000)

    elseif skill == "rock smash" then

        local item = getTileItemById(pos, 1285)
        doCreatureSay(sid, "ROCK SMASH!", TALKTYPE_ORANGE_1)
        markPos(sid, {x=1,y=1,z=7})
        doFaceCreature(sid, pos)
        doSendMagicEffect(getThingPos(item.uid), 118)
        doTransformItem(item.uid, 3610)
            local function growRock()
            doTransformItem(getTileItemById(pos, 3610).uid, 1285)
            end
        addEvent(growRock, intervalToRegrowBushAndStones * 1000)
        
elseif skill == "headbutt" then  --alterado v1.6
local master = getCreatureMaster(sid)
local array = {}  

for lvls, pokes in pairs(headbutt) do
    if getPlayerLevel(master) >= lvls[1] and getPlayerLevel(master) <= lvls[2] then
       array = pokes
       break
    end
end

if not next(array) then  --proteçao para caso algum player tenha lvl maior q o limite da tabela, q ali ta 100k
   print("Some player have level bigger then 100k ")
   doPlayerSendTextMessage(cid, 20, "You can't have level bigger then 100k ")
   return true
end

local rand = array[math.random(#array)]
for j = 1, rand[2] do
    local poke = doCreateMonster(rand[1], getClosestFreeTile(sid, pos), false)
    doSetMonsterPassive(poke)             
end
local item = getTileItemById(pos, 12591)    --id do item   arvore normal
doCreatureSay(sid, "HEADBUTT!", TALKTYPE_MONSTER)
markPos(sid, {x=1,y=1,z=7})
doFaceCreature(sid, pos)
doSendMagicEffect(getThingPos(item.uid), 118)
doTransformItem(item.uid, 12592)  --id do item   arvore quebrada
local function growHead()
      doTransformItem(getTileItemById(pos, 12592).uid, 12591) --id do item  arvore quebrada, arvore normal
end
addEvent(growHead, choose(5, 10, 20, 30) * 60 * 1000)   --o tempo pra arvore voltar ao normal varia de 5~30min

    elseif skill == "dig" then

        local item = getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0})
        doCreatureSay(sid, "DIG!", TALKTYPE_ORANGE_1)
        markPos(sid, {x=1,y=1,z=7})
        doFaceCreature(sid, pos)
        doSendMagicEffect(getThingPos(item.uid), 3)
        doTransformItem(item.uid, item.itemid+1)
            local function closeHole()
            doTransformItem(getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).uid, item.itemid)
            end
        addEvent(closeHole, intervalToRegrowBushAndStones * 1000)
    
    elseif skill == "fly" then
   
        --if not isPremium(cid) then
        --doPlayerSendCancel(cid, "Only premium members are allowed to fly.")
        --return true
        --end
        local pokemon = flys[getPokemonName(getCreatureSummons(cid)[1])]
        doPlayerSendTextMessage(cid, 27, "Type \"up\" or \"h1\" to fly higher and \"down\" or \"h2\" to fly lower.")
        doChangeSpeed(cid, -getCreatureSpeed(cid))
        local speed = 500 + PlayerSpeed/5 + getSpeed(sid) * 6 * speedRate
        doChangeSpeed(cid, speed)
        setPlayerStorageValue(cid, 54844, speed)
    local go = false
    local pks = getCreatureSummons(cid)[1]
         if getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon2") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec2")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon3") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec3")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon4") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec4")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon5") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec5")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon6") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec6")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon7") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec7")
         end
   if out then
     local item = getPlayerSlotItem(cid, 8)
     local color1, color2, color3, color4 = getItemAttribute(item.uid, "color1"), getItemAttribute(item.uid, "color2"), getItemAttribute(item.uid, "color3"), getItemAttribute(item.uid, "color4")
        doSetCreatureOutfit(cid, {lookType = out, lookBody = color1, lookHead = color2, lookLegs = color3, lookFeet = color4}, -1)
    else
        --doSetCreatureOutfit(cid, {lookType = pokemon[1], lookHead = color1, lookBody = color2, lookLegs = color3, lookFeet = color4}, -1)
        doSetCreatureOutfit(cid, {lookType = pokemon[1] + 351}, -1)
   end




        --doSetCreatureOutfit(cid, {lookType = pokemon[1] + 351}, -1)
        doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "hp", getCreatureHealth(getCreatureSummons(cid)[1]) / getCreatureMaxHealth(getCreatureSummons(cid)[1]))
        doRemoveCreature(getCreatureSummons(cid)[1])
        setPlayerStorageValue(cid, 17000, 1)
    if getPlayerGroupId(cid) == 8 then
    setPlayerGroupId(cid, 1)
    end
        if getCreatureOutfit(cid).lookType == 667 or getCreatureOutfit(cid).lookType == 999 then
           markPosEff(cid, getThingPos(cid))
           sendMovementEffect(cid, 136, getThingPos(cid))     --edited efeito quando anda com o porygon
        end
    return true

    elseif skill == "ride" then
        out = false
        local pokemon = rides[getPokemonName(getCreatureSummons(cid)[1])]
        doChangeSpeed(cid, -getCreatureSpeed(cid))
        local speed = 150 + PlayerSpeed + getSpeed(sid) * 5 * speedRate
        doChangeSpeed(cid, speed)
        setPlayerStorageValue(cid, 54844, speed)
        doSetCreatureOutfit(cid, {lookType = pokemon[1] + 351}, -1)
        doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "hp", getCreatureHealth(getCreatureSummons(cid)[1]) / getCreatureMaxHealth(getCreatureSummons(cid)[1]))
		    local go = false
    local pks = getCreatureSummons(cid)[1]
                 if getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon2") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec2")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon3") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec3")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon4") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec4")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon5") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec5")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon6") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec6")
         elseif getCreatureOutfit(pks).lookType == getItemAttribute(getPlayerSlotItem(cid, 8).uid, "addon7") then
            go = true
            out = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "spec7")
         end
   if out then
     local item = getPlayerSlotItem(cid, 8)
     local color1, color2, color3, color4 = getItemAttribute(item.uid, "color1"), getItemAttribute(item.uid, "color2"), getItemAttribute(item.uid, "color3"), getItemAttribute(item.uid, "color4")
        doSetCreatureOutfit(cid, {lookType = out, lookBody = color1, lookHead = color2, lookLegs = color3, lookFeet = color4}, -1)
    else
        --doSetCreatureOutfit(cid, {lookType = pokemon[1], lookHead = color1, lookBody = color2, lookLegs = color3, lookFeet = color4}, -1)
        doSetCreatureOutfit(cid, {lookType = pokemon[1] + 351}, -1)
   end
        doRemoveCreature(getCreatureSummons(cid)[1])
        setPlayerStorageValue(cid, 17001, 1)
    if getPlayerGroupId(cid) == 8 then
    setPlayerGroupId(cid, 1)
    end

    return true
    end

    if getOwnerPos(sid).x ~= getThingPos(getCreatureMaster(sid)).x or getOwnerPos(sid).y ~= getThingPos(getCreatureMaster(sid)).y or isCreature(getCreatureTarget(getCreatureMaster(sid))) then
        doRegainSpeed(sid)
        markPos(sid, {x=1,y=1,z=7})
    return true
    end

    addEvent(recheck, 120, sid)
end

function goThere(sid, thepos, skill, target, rept)
	if not isCreature(sid) then return true end
	if getCreatureNoMove(sid) or isSleeping(sid) or isParalyze(sid) then return true end            --alterado v2.6
	if thepos.x ~= getMarkedPos(sid).x or thepos.y ~= getMarkedPos(sid).y then return true end
	if isCreature(getCreatureTarget(getCreatureMaster(sid))) and target == false or (rept and rept <= 0) then
		doRegainSpeed(sid)
		markPos(sid, {x=1,y=1,z=7})
	return true
	end	

if (skill == "ride" or skill == "fly") and getDistanceBetween(getThingPos(sid), getMarkedPos(sid)) <= 1 then

	local currentPos = getThingPos(getCreatureMaster(sid))
	local summonPos = getThingPos(sid)
	local masterPos = getCreatureLastPosition(sid)

	if (getThingPos(sid).x == getThingPos(getCreatureMaster(sid)).x and getThingPos(sid).y == getThingPos(getCreatureMaster(sid)).y) or (currentPos.x == masterPos.x and currentPos.y == masterPos.y) then
	recheck(sid, skill, thepos)
	return true
	end

	if currentPos.x == thepos.x and currentPos.y == thepos.y then
		if getDirectionTo(getThingPos(sid), getThingPos(getCreatureMaster(sid))) <= 3 then
			doRegainSpeed(sid)
			local ndelay = getNextStepDelay(sid, 0)
			doTeleportThing(sid, thepos, true)
			doChangeSpeed(sid, -getCreatureSpeed(sid))
			markPos(sid, getThingPos(getCreatureMaster(sid)))
			addEvent(goThere, ndelay, sid, getMarkedPos(sid), skill, target)
		else
			doChangeSpeed(sid, - getCreatureSpeed(sid))
			doRegainSpeed(sid)
			markPos(sid, getThingPos(getCreatureMaster(sid)))
			local x = walkTo(sid, getDirectionTo(getThingPos(sid), getMarkedPos(sid)), getMarkedPos(sid), skill == "ride" or skill == "fly")
			doChangeSpeed(sid, - getCreatureSpeed(sid))
			addEvent(goThere, x, sid, getMarkedPos(sid), skill, target)
			end
	return true
	else
		markPos(sid, getThingPos(getCreatureMaster(sid)))
		doChangeSpeed(sid, - getCreatureSpeed(sid))
		doRegainSpeed(sid)
		local ndelay = getNextStepDelay(sid, 0)
			if getDirectionTo(getThingPos(sid), getMarkedPos(sid)) >= 4 then
				local x = walkTo(sid, getDirectionTo(getThingPos(sid), getMarkedPos(sid)), getMarkedPos(sid), skill == "ride" or skill == "fly")
			else
				doTeleportThing(sid, getPosByDir(getThingPos(sid), getDirectionTo(getThingPos(sid), getMarkedPos(sid))))
			end
		doChangeSpeed(sid, - getCreatureSpeed(sid))
		addEvent(goThere, x and x or ndelay, sid, getMarkedPos(sid), skill, target)
	return true
	end

addEvent(recheck, 350, sid, skill, thepos)
return true
end

if getThingPos(sid).x == getMarkedPos(sid).x and getThingPos(sid).y == getMarkedPos(sid).y then
	if isCreature(getCreatureTarget(sid)) then
	doFaceCreature(sid, getThingPos(getCreatureTarget(sid)))
	end
	if skill == "blink" then
	   doChangeSpeed(sid, - getCreatureSpeed(sid))   --edited blink
	end
addEvent(recheck, 350, sid, skill, thepos)
return true
end

if (getOwnerPos(sid).x ~= getThingPos(getCreatureMaster(sid)).x or getOwnerPos(sid).y ~= getThingPos(getCreatureMaster(sid)).y) and isCreature(getCreatureTarget(getCreatureMaster(sid))) == false and skill == "move" then
doRegainSpeed(sid)
markPos(sid, {x=1,y=1,z=7})
return true
end

doRegainSpeed(sid)

local holeid = thepos
holeid.stackpos = 0
holeid = getTileThingByPos(holeid).itemid

if getDistanceBetween(getThingPos(sid), getMarkedPos(sid)) <= 1 and (not isWalkable(getPosByDir(getThingPos(sid), getDirectionTo(getThingPos(sid), getMarkedPos(sid))), true, false, false, true) or isInArray(specialabilities["digholes"], holeid)) then
	if isGhostPokemon(sid) and getPlayerStorageValue(getCreatureMaster(sid), 990) <= 0 then
		local todir = getDirectionTo(getThingPos(sid), getMarkedPos(sid))
		if todir <= 3 then
			doTeleportThing(sid, getMarkedPos(sid), true)
		else
			local gotopos = getPosByDir(getThingPos(sid), dirpref[math.random(1, 2)][todir][1][math.random(1, 2)])
			doTeleportThing(sid, gotopos, true)
			addEvent(goThere, getNextStepDelay(sid, 0), sid, getMarkedPos(sid), skill, target)
			return true
		end
	end
doFaceCreature(sid, getMarkedPos(sid))
addEvent(recheck, 180, sid, skill, thepos)
doChangeSpeed(sid, - getCreatureSpeed(sid))
return true
end	

local ret = 0
	if getDistanceBetween(getThingPos(sid), getMarkedPos(sid)) <= 1 then
		ret = walkTo(sid, getDirectionTo(getThingPos(sid), getMarkedPos(sid)), getMarkedPos(sid), skill == "ride" or skill == "fly" or isGhostPokemon(sid))
		if not tonumber(ret) then
			doFaceCreature(sid, getMarkedPos(sid))
			addEvent(recheck, 180, sid, skill, thepos)
			doChangeSpeed(sid, - getCreatureSpeed(sid))
		return true
		end
	else
		ret = walkTo(sid, getDirectionTo(getThingPos(sid), getMarkedPos(sid)), getMarkedPos(sid), skill == "ride" or skill == "fly" or not isGhostPokemon(sid))-- and isSightClear(getThingPos(sid), getMarkedPos(sid), false)))
	end

if not tonumber(ret) then
doPlayerSendCancel(getCreatureMaster(sid), "Destination is not reachable.")
markPos(sid, {x=1,y=1,z=7})
return true
end

doChangeSpeed(sid, - getCreatureSpeed(sid))
addEvent(goThere, tonumber(ret), sid, getMarkedPos(sid), skill, target, rept and rept - 1 or 22)
end

 

 

Editado por boxxer321
Link para o comentário
Compartilhar em outros sites

8 respostass a esta questão

Posts Recomendados

  • 0
Em 23/02/2019 em 18:30, Refe disse:

Preciso da função que faz abrir

achei a "set outfit" em modules/game_interface.lua

aqui está, @Refe

Spoiler

WALK_STEPS_RETRY = 10

gameRootPanel = nil
gameMapPanel = nil
gameRightPanel = nil
gameLeftPanel = nil
gameBottomPanel = nil
logoutButton = nil
mouseGrabberWidget = nil
countWindow = nil
logoutWindow = nil
exitWindow = nil
bottomSplitter = nil
limitedZoom = false
currentViewMode = 0
smartWalkDirs = {}
smartWalkDir = nil
walkFunction = nil
hookedMenuOptions = {}

function init()
  g_ui.importStyle('styles/countwindow')

  connect(g_game, {
    onGameStart = onGameStart,
    onGameEnd = onGameEnd,
    onLoginAdvice = onLoginAdvice,
  }, true)

  gameRootPanel = g_ui.displayUI('gameinterface')
  gameRootPanel:hide()
  gameRootPanel:lower()
  gameRootPanel.onGeometryChange = updateStretchShrink
  gameRootPanel.onFocusChange = stopSmartWalk

  mouseGrabberWidget = gameRootPanel:getChildById('mouseGrabber')
  mouseGrabberWidget.onMouseRelease = onMouseGrabberRelease

  bottomSplitter = gameRootPanel:getChildById('bottomSplitter')
  gameMapPanel = gameRootPanel:getChildById('gameMapPanel')
  backGameRightPanel = gameRootPanel:getChildById('backgroundGameRightPanel')
  skinRight = gameRootPanel:getChildById('skinRight')
  gameRightPanel = gameRootPanel:getChildById('gameRightPanel')
  backGameLeftPanel = gameRootPanel:getChildById('backgroundGameLeftPanel')
  skinLeft = gameRootPanel:getChildById('skinLeft')
  gameLeftPanel = gameRootPanel:getChildById('gameLeftPanel')
  gameBottomPanel = gameRootPanel:getChildById('gameBottomPanel')
  connect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })

  logoutButton = modules.client_topmenu.addLeftButton('logoutButton', tr('Exit'),
    '/images/topbuttons/logout', tryLogout, true)

  setupViewMode(0)
backGameLeftPanel:setVisible(false)
  bindKeys()
  load()

  if g_game.isOnline() then
    show()
  end
	aWindow = g_ui.displayUI('a')
	hideDropWindow()
end

function hideDropWindow()
	aWindow:hide()
	return true
end

function showDropWindow(item, pos)
	aWindow:setVisible(true)
	aWindow:show()
	aWindow:raise()
	aWindow:focus()
	aWindow.onEnter = function() g_game.move(item, pos, 1) hideDropWindow() end
	aWindow:getChildById('yesButton').onClick = function() g_game.move(item, pos, 1) hideDropWindow() end
	return true
end

function bindKeys()
  gameRootPanel:setAutoRepeatDelay(100)
  bindWalkKey('Up', North)
  g_keyboard.bindKeyDown('Up', function() g_game.turn(North) end, gameRootPanel)
  bindWalkKey('Right', East)
  g_keyboard.bindKeyDown('Right', function() g_game.turn(East)end, gameRootPanel)
  bindWalkKey('Down', South)
  g_keyboard.bindKeyDown('Down', function() g_game.turn(South) end, gameRootPanel)
  bindWalkKey('Left', West)
  g_keyboard.bindKeyDown('Left', function() g_game.turn(West) end, gameRootPanel)
  bindWalkKey('Numpad8', North)
  bindWalkKey('Numpad9', NorthEast)
  bindWalkKey('Numpad6', East)
  bindWalkKey('Numpad3', SouthEast)
  bindWalkKey('Numpad2', South)
  bindWalkKey('Numpad1', SouthWest)
  bindWalkKey('Numpad4', West)
  bindWalkKey('Numpad7', NorthWest)

  g_keyboard.bindKeyPress('Ctrl+Up', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+Right', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+Down', function() g_game.turn(South) changeWalkDir(South) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+Left', function() g_game.turn(West) changeWalkDir(West) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+Numpad8', function() g_game.turn(North) changeWalkDir(North) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+Numpad6', function() g_game.turn(East) changeWalkDir(East) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+Numpad2', function() g_game.turn(South) changeWalkDir(South) end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+Numpad4', function() g_game.turn(West) changeWalkDir(West) end, gameRootPanel)
  g_keyboard.bindKeyPress('Escape', function() g_game.cancelAttackAndFollow() end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+=', function() gameMapPanel:zoomIn() end, gameRootPanel)
  g_keyboard.bindKeyPress('Ctrl+-', function() gameMapPanel:zoomOut() end, gameRootPanel)
  g_keyboard.bindKeyDown('Ctrl+Q', function() tryLogout(false) end, gameRootPanel)
  g_keyboard.bindKeyDown('Ctrl+L', function() tryLogout(false) end, gameRootPanel)
  g_keyboard.bindKeyDown('Ctrl+W', function() g_map.cleanTexts() modules.game_textmessage.clearMessages() end, gameRootPanel)
  g_keyboard.bindKeyDown('Ctrl+.', nextViewMode, gameRootPanel)
end

function bindWalkKey(key, dir)
  g_keyboard.bindKeyDown(key, function() changeWalkDir(dir) end, gameRootPanel, true)
  g_keyboard.bindKeyUp(key, function() changeWalkDir(dir, true) end, gameRootPanel, true)
  g_keyboard.bindKeyPress(key, function() smartWalk(dir) end, gameRootPanel)
end

function unbindWalkKey(key)
  g_keyboard.unbindKeyDown(key, gameRootPanel)
  g_keyboard.unbindKeyUp(key, gameRootPanel)
  g_keyboard.unbindKeyPress(key, gameRootPanel)
end

function terminate()
  save()
  hide()

  hookedMenuOptions = {}

  stopSmartWalk()

  disconnect(g_game, {
    onGameStart = onGameStart,
    onGameEnd = onGameEnd,
    onLoginAdvice = onLoginAdvice
  })

  disconnect(gameLeftPanel, { onVisibilityChange = onLeftPanelVisibilityChange })

  logoutButton:destroy()
  gameRootPanel:destroy()
end

function onGameStart()
  show()

  -- open tibia has delay in auto walking
  if not g_game.isOfficialTibia() then
    g_game.enableFeature(GameForceFirstAutoWalkStep)
  else
    g_game.disableFeature(GameForceFirstAutoWalkStep)
  end
end

function onGameEnd()
  setupViewMode(0)
  hide()
end

function show()
  connect(g_app, { onClose = tryExit })
  modules.client_background.hide()
  gameRootPanel:show()
  gameRootPanel:focus()
  gameMapPanel:followCreature(g_game.getLocalPlayer())
  setupViewMode(0)
  updateStretchShrink()
  logoutButton:setTooltip(tr('Logout'))

  addEvent(function()
    if not limitedZoom or g_game.isGM() then
      gameMapPanel:setMaxZoomOut(513)
      gameMapPanel:setLimitVisibleRange(false)
    else
      gameMapPanel:setMaxZoomOut(11)
      gameMapPanel:setLimitVisibleRange(true)
    end
  end)
end

function hide()
  disconnect(g_app, { onClose = tryExit })
  logoutButton:setTooltip(tr('Exit'))

  if logoutWindow then
    logoutWindow:destroy()
    logoutWindow = nil
  end
  if exitWindow then
    exitWindow:destroy()
    exitWindow = nil
  end
  if countWindow then
    countWindow:destroy()
    countWindow = nil
  end
  gameRootPanel:hide()
  modules.client_background.show()
end

function save()
  local settings = {}
  settings.splitterMarginBottom = bottomSplitter:getMarginBottom()
  settings.imageSkin = modules.client_options.getImageSkin()
  g_settings.setNode('game_interface', settings)
end

function load()
  local settings = g_settings.getNode('game_interface')
  if settings then
    if settings.splitterMarginBottom then
      bottomSplitter:setMarginBottom(settings.splitterMarginBottom)
    end
    if settings.imageSkin then
      skinRight:setImageSource(settings.imageSkin)
      skinLeft:setImageSource(settings.imageSkin)
    end
  end
end

function onLoginAdvice(message)
  displayInfoBox(tr("Information"), message)
end

function forceExit()
  g_game.cancelLogin()
  scheduleEvent(exit, 10)
  return true
end

function tryExit()
  if exitWindow then
    return true
  end

  local exitFunc = function() g_game.safeLogout() forceExit() end
  local logoutFunc = function() g_game.safeLogout() exitWindow:destroy() exitWindow = nil end
  local cancelFunc = function() exitWindow:destroy() exitWindow = nil end

  exitWindow = displayGeneralBox(tr('Exit'), tr("If you shut down the program, your character might stay in the game.\nClick on 'Logout' to ensure that you character leaves the game properly.\nClick on 'Exit' if you want to exit the program without logging out your character."),
  { { text=tr('Force Exit'), callback=exitFunc },
    { text=tr('Logout'), callback=logoutFunc },
    { text=tr('Cancel'), callback=cancelFunc },
    anchor=AnchorHorizontalCenter }, logoutFunc, cancelFunc)

  return true
end

function tryLogout(prompt)
  if type(prompt) ~= "boolean" then
    prompt = true
  end
  if not g_game.isOnline() then
    exit()
    return
  end

  if logoutWindow then
    return
  end

  local msg, yesCallback
  if not g_game.isConnectionOk() then
    msg = 'Your connection is failing, if you logout now your character will be still online, do you want to force logout?'

    yesCallback = function()
      g_game.forceLogout()
      if logoutWindow then
        logoutWindow:destroy()
        logoutWindow=nil
      end
    end
  else
    msg = 'Are you sure you want to logout?'

    yesCallback = function()
      g_game.safeLogout()
      if logoutWindow then
        logoutWindow:destroy()
        logoutWindow=nil
      end
    end
  end

  local noCallback = function()
    logoutWindow:destroy()
    logoutWindow=nil
  end

  if prompt then
    logoutWindow = displayGeneralBox(tr('Logout'), tr(msg), {
      { text=tr('Yes'), callback=yesCallback },
      { text=tr('No'), callback=noCallback },
      anchor=AnchorHorizontalCenter}, yesCallback, noCallback)
  else
     yesCallback()
  end
end

function stopSmartWalk()
  smartWalkDirs = {}
  smartWalkDir = nil
end

function changeWalkDir(dir, pop)
  while table.removevalue(smartWalkDirs, dir) do end
  if pop then
    if #smartWalkDirs == 0 then
      stopSmartWalk()
      return
    end
  else
    table.insert(smartWalkDirs, 1, dir)
  end

  smartWalkDir = smartWalkDirs[1]
  if modules.client_options.getOption('smartWalk') and #smartWalkDirs > 1 then
    for _,d in pairs(smartWalkDirs) do
      if (smartWalkDir == North and d == West) or (smartWalkDir == West and d == North) then
        smartWalkDir = NorthWest
        break
      elseif (smartWalkDir == North and d == East) or (smartWalkDir == East and d == North) then
        smartWalkDir = NorthEast
        break
      elseif (smartWalkDir == South and d == West) or (smartWalkDir == West and d == South) then
        smartWalkDir = SouthWest
        break
      elseif (smartWalkDir == South and d == East) or (smartWalkDir == East and d == South) then
        smartWalkDir = SouthEast
        break
      end
    end
  end
end

function smartWalk(dir)
  if g_keyboard.getModifiers() == KeyboardNoModifier then
    local func = walkFunction
    if not func then
      if modules.client_options.getOption('dashWalk') then
        func = g_game.dashWalk
      else
        func = g_game.walk
      end
    end
    local dire = smartWalkDir or dir
    func(dire)
    return true
  end
  return false
end

function updateStretchShrink()
  if modules.client_options.getOption('dontStretchShrink') and not alternativeView then
    gameMapPanel:setVisibleDimension({ width = 15, height = 11 })

    -- Set gameMapPanel size to height = 11 * 32 + 2
    bottomSplitter:setMarginBottom(bottomSplitter:getMarginBottom() + (gameMapPanel:getHeight() - 32 * 11) - 10)
  end
end

function onMouseGrabberRelease(self, mousePosition, mouseButton)
  if selectedThing == nil then return false end
  if mouseButton == MouseLeftButton then
    local clickedWidget = gameRootPanel:recursiveGetChildByPos(mousePosition, false)
    if clickedWidget then
      if selectedType == 'use' then
        onUseWith(clickedWidget, mousePosition)
      elseif selectedType == 'trade' then
        onTradeWith(clickedWidget, mousePosition)
      end
    end
  end

  selectedThing = nil
  g_mouse.popCursor('target')
  self:ungrabMouse()
  return true
end

function onUseWith(clickedWidget, mousePosition)
  if clickedWidget:getClassName() == 'UIGameMap' then
    local tile = clickedWidget:getTile(mousePosition)
    if tile then
      if selectedThing:isFluidContainer() or selectedThing:isMultiUse() then
        g_game.useWith(selectedThing, tile:getTopMultiUseThing())
      else
        g_game.useWith(selectedThing, tile:getTopUseThing())
      end
    end
  elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
    g_game.useWith(selectedThing, clickedWidget:getItem())
  elseif clickedWidget:getClassName() == 'UICreatureButton' then
    local creature = clickedWidget:getCreature()
    if creature then
      g_game.useWith(selectedThing, creature)
    end
  end
end

function onTradeWith(clickedWidget, mousePosition)
  if clickedWidget:getClassName() == 'UIGameMap' then
    local tile = clickedWidget:getTile(mousePosition)
    if tile then
      g_game.requestTrade(selectedThing, tile:getTopCreature())
    end
  end
end

function startUseWith(thing)
  if not thing then return end
  if g_ui.isMouseGrabbed() then
    if selectedThing then
      selectedThing = thing
      selectedType = 'use'
    end
    return
  end
  selectedType = 'use'
  selectedThing = thing
  mouseGrabberWidget:grabMouse()
  g_mouse.pushCursor('target')
end

function startTradeWith(thing)
  if not thing then return end
  if g_ui.isMouseGrabbed() then
    if selectedThing then
      selectedThing = thing
      selectedType = 'trade'
    end
    return
  end
  selectedType = 'trade'
  selectedThing = thing
  mouseGrabberWidget:grabMouse()
  g_mouse.pushCursor('target')
end

function isMenuHookCategoryEmpty(category)
  if category then
    for _,opt in pairs(category) do
      if opt then return false end
    end
  end
  return true
end

function addMenuHook(category, name, callback, condition, shortcut)
  if not hookedMenuOptions[category] then
    hookedMenuOptions[category] = {}
  end
  hookedMenuOptions[category][name] = {
    callback = callback,
    condition = condition,
    shortcut = shortcut
  }
end

function removeMenuHook(category, name)
  if not name then
    hookedMenuOptions[category] = {}
  else
    hookedMenuOptions[category][name] = nil
  end
end

function createThingMenu(menuPosition, lookThing, useThing, creatureThing)
  if not g_game.isOnline() then return end
  local menu = g_ui.createWidget('PopupMenu')
  local classic = modules.client_options.getOption('classicControl')
  local shortcut = nil

  if not classic then shortcut = '(Shift)' else shortcut = nil end
  if lookThing then
    menu:addOption(tr('Look'), function() g_game.look(lookThing) end, shortcut)
  end

  if not classic then shortcut = '(Ctrl)' else shortcut = nil end
  if useThing then
    if useThing:isContainer() then
      if useThing:getParentContainer() then
        menu:addOption(tr('Open'), function() g_game.open(useThing, useThing:getParentContainer()) end, shortcut)
        menu:addOption(tr('Open in new window'), function() g_game.open(useThing) end)
      else
        menu:addOption(tr('Open'), function() g_game.open(useThing) end, shortcut)
      end
    else
      if useThing:isMultiUse() then
        menu:addOption(tr('Use with ...'), function() startUseWith(useThing) end, shortcut)
      else
        menu:addOption(tr('Use'), function() g_game.use(useThing) end, shortcut)
      end
    end

    if useThing:isRotateable() then
      menu:addOption(tr('Rotate'), function() g_game.rotate(useThing) end)
    end

    if g_game.getFeature(GameBrowseField) and useThing:getPosition().x ~= 0xffff then
      menu:addOption(tr('Browse Field'), function() g_game.browseField(useThing:getPosition()) end)
    end
  end

function isD(id)
	if id >= 3497 and id <= 3500 then return true
	elseif id >= 11419 and id <= 11422 then return true
	elseif id >= 14424 and id <= 14439 then return true
	elseif id == 15979 then return true
	end
	return false
end

  if lookThing and not lookThing:isCreature() and not lookThing:isNotMoveable() and lookThing:isPickupable() then
    menu:addSeparator()
    menu:addOption(tr('Trade with ...'), function() startTradeWith(lookThing) end)
  end

 --[[  if isD(lookThing:getId()) then
	  menu:addSeparator()
	  menu:addOption(tr('Change Password'), function() g_game.talk("/changeZdepotpasswordI") end)
	  menu:addOption(tr('Remove Password'), function() g_game.talk("/removeZdepotpasswordI") end)
   end]]

		if lookThing and not lookThing:isCreature() and not lookThing:isNotMoveable() and lookThing:isPickupable() then
			if lookThing:getId() == 14827 or lookThing:getId() == 14828 then
				menu:addSeparator()
				menu:addOption(tr('Ditto memory ...'), function() modules.game_memory.sendRequestShow() end)
			end
			menu:addSeparator()
			menu:addOption(tr('Trade with ...'), function() startTradeWith(lookThing) end)
		end   
   
  if lookThing then
    local parentContainer = lookThing:getParentContainer()
    if parentContainer and parentContainer:hasParent() then
      menu:addOption(tr('Move up'), function() g_game.moveToParentContainer(lookThing, lookThing:getCount()) end)
    end
  end

  if creatureThing then
    local localPlayer = g_game.getLocalPlayer()
    menu:addSeparator()

    if creatureThing:isLocalPlayer() then
      menu:addOption(tr('Set Outfit'), function() g_game.requestOutfit() end)

      if g_game.getFeature(GamePlayerMounts) then
        if not localPlayer:isMounted() then
          menu:addOption(tr('Mount'), function() localPlayer:mount() end)
        else
          menu:addOption(tr('Dismount'), function() localPlayer:dismount() end)
        end
      end

      if creatureThing:isPartyMember() then
        if creatureThing:isPartyLeader() then
          if creatureThing:isPartySharedExperienceActive() then
            menu:addOption(tr('Disable Shared Experience'), function() g_game.getProtocolGame():sendExtendedOpcode(175, 'disable') end)
          else
            menu:addOption(tr('Enable Shared Experience'), function() g_game.getProtocolGame():sendExtendedOpcode(175, 'enable') end)
          end
        end
        menu:addOption(tr('Leave Duel'), function() g_game.partyLeave() end)
      end

    else
      local localPosition = localPlayer:getPosition()
      if not classic then shortcut = '(Alt)' else shortcut = nil end
      if creatureThing:getPosition().z == localPosition.z then
        if g_game.getAttackingCreature() ~= creatureThing then
          menu:addOption(tr('Attack'), function() g_game.attack(creatureThing) end, shortcut)
        else
          menu:addOption(tr('Stop Attack'), function() g_game.cancelAttack() end, shortcut)
        end

        if g_game.getFollowingCreature() ~= creatureThing then
          menu:addOption(tr('Follow'), function() g_game.follow(creatureThing) end)
        else
          menu:addOption(tr('Stop Follow'), function() g_game.cancelFollow() end)
        end
      end

      if creatureThing:isPlayer() then
        menu:addSeparator()
        local creatureName = creatureThing:getName()
        menu:addOption(tr('Message to %s', creatureName), function() g_game.openPrivateChannel(creatureName) end)
        if modules.game_console.getOwnPrivateTab() then
          menu:addOption(tr('Invite to private chat'), function() g_game.inviteToOwnChannel(creatureName) end)
          menu:addOption(tr('Exclude from private chat'), function() g_game.excludeFromOwnChannel(creatureName) end) -- [TODO] must be removed after message's popup labels been implemented
        end
        if not localPlayer:hasVip(creatureName) then
          menu:addOption(tr('Add to VIP list'), function() g_game.addVip(creatureName) end)
        end

        if modules.game_console.isIgnored(creatureName) then
          menu:addOption(tr('Unignore') .. ' ' .. creatureName, function() modules.game_console.removeIgnoredPlayer(creatureName) end)
        else
          menu:addOption(tr('Ignore') .. ' ' .. creatureName, function() modules.game_console.addIgnoredPlayer(creatureName) end)
        end

    ---//// Duel

    ---//// Duel		
		
        local localPlayerShield = localPlayer:getShield()
        local creatureShield = creatureThing:getShield()

        if localPlayerShield == ShieldNone or localPlayerShield == ShieldWhiteBlue then
          if creatureShield == ShieldWhiteYellow then
            menu:addOption(tr('Join %s\'s Duel', creatureThing:getName()), function() g_game.partyJoin(creatureThing:getId()) end)
          else
            menu:addOption(tr('Invite to a Duel'), function() g_game.partyInvite(creatureThing:getId()) end)
          end
        elseif localPlayerShield == ShieldWhiteYellow then
          if creatureShield == ShieldWhiteBlue then
            menu:addOption(tr('Revoke %s\'s Invitation', creatureThing:getName()), function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
          end
        elseif localPlayerShield == ShieldYellow or localPlayerShield == ShieldYellowSharedExp or localPlayerShield == ShieldYellowNoSharedExpBlink or localPlayerShield == ShieldYellowNoSharedExp then
          if creatureShield == ShieldWhiteBlue then
            menu:addOption(tr('Revoke %s\'s Invitation', creatureThing:getName()), function() g_game.partyRevokeInvitation(creatureThing:getId()) end)
          elseif creatureShield == ShieldBlue or creatureShield == ShieldBlueSharedExp or creatureShield == ShieldBlueNoSharedExpBlink or creatureShield == ShieldBlueNoSharedExp then
            menu:addOption(tr('Pass Leadership to %s', creatureThing:getName()), function() g_game.partyPassLeadership(creatureThing:getId()) end)
          else
            menu:addOption(tr('Invite to a Duel'), function() g_game.partyInvite(creatureThing:getId()) end)
          end
        end
      end
    end

    if modules.game_ruleviolation.hasWindowAccess() and creatureThing:isPlayer() then
      menu:addSeparator()
      menu:addOption(tr('Rule Violation'), function() modules.game_ruleviolation.show(creatureThing:getName()) end)
    end

    menu:addSeparator()
    menu:addOption(tr('Copy Name'), function() g_window.setClipboardText(creatureThing:getName()) end)
  end

  -- hooked menu options
  for _,category in pairs(hookedMenuOptions) do
    if not isMenuHookCategoryEmpty(category) then
      menu:addSeparator()
      for name,opt in pairs(category) do
        if opt and opt.condition(menuPosition, lookThing, useThing, creatureThing) then
          menu:addOption(name, function() opt.callback(menuPosition, 
            lookThing, useThing, creatureThing) end, opt.shortcut)
        end
      end
    end
  end

  menu:display(menuPosition)
end

function processMouseAction(menuPosition, mouseButton, autoWalkPos, lookThing, useThing, creatureThing, attackCreature)
  local keyboardModifiers = g_keyboard.getModifiers()

  if not modules.client_options.getOption('classicControl') then
    if keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton then
      createThingMenu(menuPosition, lookThing, useThing, creatureThing)
      return true
    elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
      g_game.look(lookThing)
      return true
    elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
      if useThing:isContainer() then
        if useThing:getParentContainer() then
          g_game.open(useThing, useThing:getParentContainer())
        else
          g_game.open(useThing)
        end
        return true
      elseif useThing:isMultiUse() then
        startUseWith(useThing)
        return true
      else
        g_game.use(useThing)
        return true
      end
      return true
    elseif attackCreature and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
      g_game.attack(attackCreature)
      return true
    elseif creatureThing and creatureThing:getPosition().z == autoWalkPos.z and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
      g_game.attack(creatureThing)
      return true
    end

  -- classic control
  else
    if useThing and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseRightButton and not g_mouse.isPressed(MouseLeftButton) then
      local player = g_game.getLocalPlayer()
      if attackCreature and attackCreature ~= player then
        g_game.attack(attackCreature)
        return true
      elseif creatureThing and creatureThing ~= player and creatureThing:getPosition().z == autoWalkPos.z then
        g_game.attack(creatureThing)
        return true
      elseif useThing:isContainer() then
        if useThing:getParentContainer() then
          g_game.open(useThing, useThing:getParentContainer())
          return true
        else
          g_game.open(useThing)
          return true
        end
      elseif useThing:isMultiUse() then
        startUseWith(useThing)
        return true
      else
        g_game.use(useThing)
        return true
      end
      return true
    elseif lookThing and keyboardModifiers == KeyboardShiftModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
      g_game.look(lookThing)
      return true
    elseif lookThing and ((g_mouse.isPressed(MouseLeftButton) and mouseButton == MouseRightButton) or (g_mouse.isPressed(MouseRightButton) and mouseButton == MouseLeftButton)) then
      g_game.look(lookThing)
      return true
    elseif useThing and keyboardModifiers == KeyboardCtrlModifier and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
      createThingMenu(menuPosition, lookThing, useThing, creatureThing)
      return true
    elseif attackCreature and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
      g_game.attack(attackCreature)
      return true
    elseif creatureThing and creatureThing:getPosition().z == autoWalkPos.z and g_keyboard.isAltPressed() and (mouseButton == MouseLeftButton or mouseButton == MouseRightButton) then
      g_game.attack(creatureThing)
      return true
    end
  end


  local player = g_game.getLocalPlayer()
  player:stopAutoWalk()

  if autoWalkPos and keyboardModifiers == KeyboardNoModifier and mouseButton == MouseLeftButton then
    player:autoWalk(autoWalkPos)
    return true
  end

  return false
end

function moveStackableItem(item, toPos)
  if countWindow then
    return
  end
  if g_keyboard.isCtrlPressed() then
    g_game.move(item, toPos, item:getCount())
    return
  elseif g_keyboard.isShiftPressed() then
    g_game.move(item, toPos, 1)
    return
  end
  local count = item:getCount()

  countWindow = g_ui.createWidget('CountWindow', rootWidget)
  local itembox = countWindow:getChildById('item')
  local scrollbar = countWindow:getChildById('countScrollBar')
  itembox:setItemId(item:getId())
  itembox:setItemCount(count)
  scrollbar:setMaximum(count)
  scrollbar:setMinimum(1)
  scrollbar:setValue(count)

  local spinbox = countWindow:getChildById('spinBox')
  spinbox:setMaximum(count)
  spinbox:setMinimum(0)
  spinbox:setValue(0)
  spinbox:hideButtons()
  spinbox:focus()
  spinbox.firstEdit = true

  local spinBoxValueChange = function(self, value)
    spinbox.firstEdit = false
    scrollbar:setValue(value)
  end
  spinbox.onValueChange = spinBoxValueChange

  local check = function()
    if spinbox.firstEdit then
      spinbox:setValue(spinbox:getMaximum())
      spinbox.firstEdit = false
    end
  end
  g_keyboard.bindKeyPress("Up", function() check() spinbox:up() end, spinbox)
  g_keyboard.bindKeyPress("Down", function() check() spinbox:down() end, spinbox)
  g_keyboard.bindKeyPress("Right", function() check() spinbox:up() end, spinbox)
  g_keyboard.bindKeyPress("Left", function() check() spinbox:down() end, spinbox)
  g_keyboard.bindKeyPress("PageUp", function() check() spinbox:setValue(spinbox:getValue()+10) end, spinbox)
  g_keyboard.bindKeyPress("PageDown", function() check() spinbox:setValue(spinbox:getValue()-10) end, spinbox)

  scrollbar.onValueChange = function(self, value)
    itembox:setItemCount(value)
    spinbox.onValueChange = nil
    spinbox:setValue(value)
    spinbox.onValueChange = spinBoxValueChange
  end

  local okButton = countWindow:getChildById('buttonOk')
  local moveFunc = function()
    g_game.move(item, toPos, itembox:getItemCount())
    okButton:getParent():destroy()
    countWindow = nil
  end
  local cancelButton = countWindow:getChildById('buttonCancel')
  local cancelFunc = function()
    cancelButton:getParent():destroy()
    countWindow = nil
  end

  countWindow.onEnter = moveFunc
  countWindow.onEscape = cancelFunc

  okButton.onClick = moveFunc
  cancelButton.onClick = cancelFunc
end

function getRootPanel()
  return gameRootPanel
end

function getMapPanel()
  return gameMapPanel
end

function getSkinRight()
  return skinRight
end
function getRightPanel()
  return gameRightPanel
end

function getSkinLeft()
  return skinLeft
end

function getLeftPanel()
  return gameLeftPanel
end

function getBottomPanel()
  return gameBottomPanel
end

function onLeftPanelVisibilityChange(leftPanel, visible)
skinLeft:setVisible(visible)
backGameLeftPanel:setVisible(visible)
  if not visible and g_game.isOnline() then
    local children = leftPanel:getChildren()
    for i=1,#children do
      children[i]:setParent(gameRightPanel)
    end
  end
end

function nextViewMode()
  setupViewMode((currentViewMode + 1) % 3)
end

function setupViewMode(mode)
  if mode == currentViewMode then return end

  if currentViewMode == 2 then
    gameMapPanel:addAnchor(AnchorLeft, 'gameLeftPanel', AnchorRight)
    gameMapPanel:addAnchor(AnchorRight, 'gameRightPanel', AnchorLeft)
    gameMapPanel:addAnchor(AnchorBottom, 'gameBottomPanel', AnchorTop)
    gameRootPanel:addAnchor(AnchorTop, 'topMenu', AnchorBottom)
   -- gameLeftPanel:setOn(modules.client_options.getOption('showLeftPanel'))
    backGameLeftPanel:setImageColor('white')
    backGameRightPanel:setImageColor('white')
  --  gameLeftPanel:setMarginTop(0)
    gameRightPanel:setMarginTop(0)
    gameBottomPanel:setImageColor('white')
    modules.client_topmenu.getTopMenu():setImageColor('white')
    g_game.changeMapAwareRange(18, 14)
  end

  if mode == 0 then
    gameMapPanel:setKeepAspectRatio(true)
    gameMapPanel:setLimitVisibleRange(false)
    gameMapPanel:setZoom(11)
    gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
  elseif mode == 1 then
    gameMapPanel:setKeepAspectRatio(false)
    gameMapPanel:setLimitVisibleRange(true)
    gameMapPanel:setZoom(11)
    gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
  elseif mode == 2 then
    local limit = limitedZoom and not g_game.isGM()
    gameMapPanel:setLimitVisibleRange(limit)
    gameMapPanel:setZoom(11)
    gameMapPanel:setVisibleDimension({ width = 15, height = 11 })
    gameMapPanel:fill('parent')
    gameRootPanel:fill('parent')
    backGameLeftPanel:setImageColor('alpha')
    backGameRightPanel:setImageColor('alpha')
    gameLeftPanel:setMarginTop(modules.client_topmenu.getTopMenu()
      :getHeight() - gameLeftPanel:getPaddingTop())
    gameRightPanel:setMarginTop(modules.client_topmenu.getTopMenu()
      :getHeight() - gameRightPanel:getPaddingTop())
    --gameLeftPanel:setOn(true)
  --  gameLeftPanel:setVisible(true)
    gameRightPanel:setOn(true)
    gameMapPanel:setOn(true)
    gameBottomPanel:setImageColor('#ffffff88')
    modules.client_topmenu.getTopMenu():setImageColor('#ffffff66')
    if not limit then
      g_game.changeMapAwareRange(24, 20)
    end
  end

  currentViewMode = mode
end

function limitZoom()
  limitedZoom = true
end

 

 

Link para o comentário
Compartilhar em outros sites

  • 0

@Refe @bXnny

 

    if creatureThing:isLocalPlayer() then
      menu:addOption(tr('Set Outfit'), function() g_game.requestOutfit() end)

unica linha que eu achei com "set outfit" dentro de game_interface.lua

Editado por boxxer321
Link para o comentário
Compartilhar em outros sites

  • 0

Então cara, eu precisaria entender esse sistema a fundo.

Você comprou ele de alguém?

Caso sim, veja se ela consegue te dar esse suporte, pois nesses arquivos ai não tem nada que possa causar esse "erro"

Aliás, esse é um grande problema de fazer as coisas na gambiarra :/

Link para o comentário
Compartilhar em outros sites

  • 0
Agora, Refe disse:

Então cara, eu precisaria entender esse sistema a fundo.

Você comprou ele de alguém?

Caso sim, veja se ela consegue te dar esse suporte, pois nesses arquivos ai não tem nada que possa causar esse "erro"

Aliás, esse é um grande problema de fazer as coisas na gambiarra :/

não, ele está em um servidor aqui do xtibia no qual estou trabalhando disponibilizado pelo deglorio... eu estava até pretendendo postar ele aqui depois...

não tem nenhuma forma de criar um exhausted para trocar a outfit se ele estiver em fly, ride ou surf?

 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...