Jump to content

Tutorial Básico Movements


DuuhCarvalho

Recommended Posts

Movements, são scripts que são executados após um Player * Passar por cima, Sair de cima, Equipar item, Desequipar item, Adicionar item, Remover item*

 

 

Para isso existe algumas funções : 

function onEquip(cid, item, slot)     -- Ao equiparfunction onDeEquip(cid, item, slot)   -- Ao desequiparfunction onStepOut(cid, item, pos)    -- Ao sair de cimafunction onStepIn(cid, item, pos)     -- Ao pisar em cimafunction onAddItem(moveitem, tileitem, pos)   -- Ao adicionar itemfunction onRemoveItem(moveitem, tileitem, pos)  -- Ao remover item

Exemplo de script com função : onEquip e onDeEquip ...

Spoiler

 

function onEquip(cid, item, slot)if isPremium(cid) then setPlayerStorageValue(cid, 445566, 1)endreturn TRUEendfunction onDeEquip(cid, item, slot)setPlayerStorageValue(cid, 445566, 0)return TRUEend

O que acontece nesse script ?..

 

function onEquip(cid, item, slot)
Ao equipar o item o script vai verificar se o player é premium, se for então ele vai adicionar storage 445566, 1 no Player.

function onDeEquip(cid, item, slot)

Ao desequipar o item o script vai mudar a storage para 445566, 0

 

tag em movements.xml :

<movevent type="Equip" itemid="2643" slot="feet" event="script" value="NomedoArquivo.lua"/><movevent type="DeEquip" itemid="2643" slot="feet" event="script" value="NomedoArquivo.lua"/>

e necessário usar 2 tags , para o script rodar quando equipar e quando desequipar . 

type = Equip , para quando equipar

type = DeEquip, para quando desequipar .

 

 


 

 


Exemplo de script com função: onStepIn e onStepOut ...

Spoiler


 

function onStepIn(cid, item, pos) if isPlayer(cid) then doPlayerAddItem(cid, 2160, 100)endreturn TRUEendfunction onStepOut(cid, item, pos) if isPlayer(cid) thendoPlayerRemoveItem(cid, 2160, 100)endreturn TRUEend

Entendendo ..
 

function onStepIn(cid, item, pos) 

Ao pisar no tile com o UniqueId que você coloca em movements.xml,
o script vai verificar se quem ta pisando no tile é um player, se sim então o Player receber 100 itens 2160(doPlayerAddItem(cid, 2160, 100)), no caso 100 crystal coins.

function onStepOut(cid, item, pos) 

Ao sair do tile será removido o mesmo (doPlayerRemoveItem(cid, 2160, 100)) 100 crystal coins.

tags em movements.xml

        <movevent type="StepIn" uniqueid="AquiAuniqueID" event="script" value="NomedoArquivo.lua"/>        <movevent type="StepOut" uniqueid="AquiAuniqueID" event="script" value="NomedoArquivo.lua"/>

type = StepIn , ao pisar

type = StepOut, ao sair .

 

 

Para cria um novo script em movements, vá em data / movements / scripts , e crie um novo arquivo.lua

depois é so colocar a tag em data / movements.xml .

 

 

algumas funções get , set , do ..


get :

Spoiler

getCreatureHealth(cid)
getCreatureMaxHealth(cid)
getCreatureMana(cid)
getCreatureMaxMana(cid)
getCreatureMaster(cid)
getCreatureSummons(cid)
getCreatureOutfit(cid)
getCreaturePosition(cid)
getCreatureName(cid)
getCreatureSpeed(cid)
getCreatureBaseSpeed(cid)
getCreatureTarget(cid)
getCreatureByName(name)
getCreatureSkullType(cid)
getCreatureCondition(cid, condition[, subId])
getCreatureNoMove(cid)
getMonsterInfo(name)
getMonsterHealingSpells(name)
getMonsterAttackSpells(name)
getMonsterLootList(name)
getMonsterTargetList(cid)
getMonsterFriendList(cid)
getPlayerByNameWildcard(name~)
getPlayerLossSkill(cid)
getPlayerLossPercent(cid, lossType)
getPlayerGUIDByName(name[, multiworld])
getPlayerNameByGUID(guid[, multiworld])
getPlayerFood(cid)
getPlayerLevel(cid)
getPlayerExperience(cid)
getPlayerMagLevel(cid[, ignoreBuffs])
getPlayerSpentMana(cid)
getPlayerAccess(cid)
getPlayerSkillLevel(cid, skillid)
getPlayerSkillTries(cid, skillid)
getPlayerTown(cid)
getPlayerVocation(cid)
getPlayerRequiredMana(cid, magicLevel)
getPlayerRequiredSkillTries(cid, skillId, skillLevel)
getPlayerItemCount(cid, itemid)
getPlayerSoul(cid)
getPlayerAccountId(cid)
getPlayerAccount(cid)
getPlayerIp(cid)
getPlayerFreeCap(cid)
getPlayerLight(cid)
getPlayerSlotItem(cid, slot)
getPlayerWeapon(cid[, ignoreAmmo])
getPlayerItemById(cid, deepSearch, itemId[, subType])
getPlayerDepotItems(cid, depotid)
getPlayerGuildId(cid)
getPlayerGuildName(cid)
getPlayerGuildRank(cid)
getPlayerGuildNick(cid)
getPlayerGuildLevel(cid)
getPlayerSex(cid)
getPlayerLookDir(cid)
getPlayerStorageValue(uid, valueid)
getPlayerGUID(cid)
getPlayerFlagValue(cid, flag)
getPlayerCustomFlagValue(cid, flag)
getPlayerPromotionLevel(cid)
getPlayerGroupId(cid)
getPlayerLearnedInstantSpell(cid, name)
getPlayerInstantSpellCount(cid)
getPlayerInstantSpellInfo(cid, index)
getPlayerSex(cid)
getPlayerBlessing(cid, blessing)
getPlayerStamina(cid)
getPlayerExtraExpRate(cid)
getPlayerPartner(cid)
getPlayerParty(cid)
getPlayerPremiumDays(cid)
getPlayerBalance(cid)
getPlayerRedSkullTicks(cid)
getPlayerRates(cid)
getInstantSpellInfo(cid, name)
getPlayersByAccountId(accountNumber)
getPlayersByIp(ip[, mask = 0xFFFFFFFF])
getPlayersOnline()
getPartyMembers(lid)
getAccountIdByName(name)
getAccountByName(name)
getAccountIdByAccount(accName)
getAccountByAccountId(accId)
getIpByName(name)
getItemRWInfo(uid)
getItemDescriptionsById(itemid)
getItemWeightById(itemid, count[, precise])
getItemDescriptions(uid)
getItemWeight(uid[, precise])
getItemAttack(uid)
getItemExtraAttack(uid)
getItemDefense(uid)
getItemExtraDefense(uid)
getItemArmor(uid)
getItemAttackSpeed(uid)
getItemHitChance(uid)
getItemShootRange(uid)
getItemIdByName(name[, reportError])
getItemLevelDoor(itemid)
getItemWeaponType(uid)
getFluidSourceType(type)
getContainerSize(uid)
getContainerCap(uid)
getContainerCapById(itemid)
getContainerItem(uid, slot)
getDepotId(uid)
getTileItemById(pos, itemId[, subType])
getTileItemByType(pos, type)
getTileThingByPos(pos)
getTileInfo(pos)
getTopCreature(pos)
getClosestFreeTile(cid, targetpos[, extended[, ignoreHouse]])
getThingFromPos(pos)
getThing(uid)
getThingPos(uid)
getHouseOwner(houseid)
getHouseName(houseid)
getHouseEntry(houseid)
getHouseRent(houseid)
getHousePrice(houseid)
getHouseTown(houseid)
getHouseAccessList(houseid, listid)
getHouseByPlayerGUID(playerGUID)
getHouseFromPos(pos)
getHouseTilesSize(houseid)
getTownId(townName)
getTownName(townId)
getTownTemplePosition(townId)
getTownHouses(townId)
getWorldType()
getWorldTime()
getWorldLight()
getWorldCreatures(type) //0 players, 1 monsters, 2 npcs, 3 all
getWorldUpTime()
getHighscoreString(skillId)
getVocationInfo(id)
getGuildId(guildName)
getGuildMotd(guildId)
getSpectators(centerPos, rangex, rangey, multifloor)
getSearchString(fromPosition, toPosition[, fromIsCreature[, toIsCreature]])
getWaypointPosition(name)
getGameState()
getNotationsCount(accId)
getBanData(value)
getBanList(type[, value])
getBanReason(id)
getBanAction(id[, ipBanishment])
getGlobalStorageValue(valueid)
getExperienceStage(level)
getConfigFile()
getConfigValue(key)
getLogsDir()
getDataDir()

 


set :

Spoiler

setCreatureMaxHealth(cid, health)
setCreatureMaxMana(cid, mana)
setPlayerStorageValue(uid, valueid, newvalue)
setPlayerGroupId(cid, newGroupId)
setPlayerPromotionLevel(cid, level)
setPlayerStamina(cid, minutes)
setPlayerExtraExpRate(cid, value)
setPlayerPartner(cid, guid)
setHouseOwner(houseid, ownerGUID)
setHouseAccessList(houseid, listid, listtext)
setItemName(uid)
setItemPluralName(uid)
setItemArticle(uid)
setItemAttack(uid, attack)
setItemExtraAttack(uid, extraattack)
setItemDefense(uid, defense)
setItemArmor(uid, armor)
setItemExtraDefense(uid, extradefense)
setItemAttackSpeed(uid, attackspeed)
setItemHitChance(uid, hitChance)
setItemShootRange(uid, shootRange)
setCombatArea(combat, area)
setCombatCondition(combat, condition)
setCombatParam(combat, key, value)
setConditionParam(condition, key, value)
setCombatCallBack(combat, key, function_name)
setCombatFormula(combat, type, mina, minb, maxa, maxb)
setConditionFormula(combat, mina, minb, maxa, maxb)
setGlobalStorageValue(valueid, newvalue)
setWorldType(type)

 


do :

Spoiler

doCreatureAddHealth(cid, health[, force])
doCreatureAddMana(cid, mana)
doCreatureSetDropLoot(cid, doDrop)
doCreatureSetSkullType(cid, skull)
doCreatureSetLookDir(cid, dir)
doCreatureChangeOutfit(cid, outfit)
doCreatureSay(cid, text, type[, pos])
doCreatureSetNoMove(cid, cannotMove)
doSetCreatureLight(cid, lightLevel, lightColor, time)
doSetCreatureOutfit(cid, outfit, time)
doRemoveCreature(cid)
doMoveCreature(cid, direction)
doConvinceCreature(cid, target)
doChallengeCreature(cid, target)
doChangeSpeed(cid, delta)
doSummonMonster(name, pos)
doCreateMonster(name, pos)
doMonsterChangeTarget(cid)
doMonsterSetTarget(cid, target)
doCreateNpc(name, pos)
doSetMonsterOutfit(cid, name, time)
doPlayerBroadcastMessage(cid, message[, type])
doPlayerSetSex(cid, newSex)
doPlayerSetTown(cid, townid)
doPlayerSetVocation(cid,voc)
doPlayerRemoveItem(cid, itemid, count[, subtype])
doPlayerAddExp(cid, exp)
doPlayerSetGuildId(cid, id)
doPlayerSetGuildRank(cid, rank)
doPlayerSetGuildNick(cid, nick)
doPlayerAddOutfit(cid,looktype, addons)
doPlayerRemoveOutfit(cid,looktype, addons)
doPlayerSetRedSkullTicks(cid, amount)
doPlayerSetLossPercent(cid, lossType, newPercent)
doPlayerSetLossSkill(cid, doLose)
doPlayerAddSkillTry(cid, skillid, n)
doPlayerAddSpentMana(cid, amount)
doPlayerAddSoul(cid, soul)
doPlayerAddItem(uid, itemid[, count/subtype[, canDropOnMap]])
doPlayerAddItemEx(cid, uid[, canDropOnMap])
doPlayerSendTextMessage(cid, MessageClasses, message)
doPlayerSendChannelMessage(cid, author, message, SpeakClasses, channel)
doPlayerSendToChannel(cid, targetId, SpeakClasses, message, channel[, time])
doPlayerAddMoney(cid, money)
doPlayerRemoveMoney(cid, money)
doPlayerWithdrawMoney(cid, money)
doPlayerDepositMoney(cid, money)
doPlayerTransferMoneyTo(cid, target, money)
doPlayerPopupFYI(cid, message)
doPlayerSendTutorial(cid, id)
doPlayerAddMapMark(cid, pos, type[, description])
doPlayerAddPremiumDays(cid, days)
doPlayerAddBlessing(cid, blessing)
doPlayerAddStamina(cid, minutes)
doPlayerResetIdleTime(cid)
doPlayerLearnInstantSpell(cid, name)
doPlayerUnlearnInstantSpell(cid, name)
doPlayerFeed(cid, food)
doPlayerSendCancel(cid, text)
doPlayerSendDefaultCancel(cid, ReturnValue)
doPlayerSetExperienceRate(cid, value)
doPlayerSetMagicRate(cid, value)
doPlayerSetSkillRate(cid, skill, value)
doPlayerJoinParty(cid, lid)
doPlayerSendOutfitWindow(cid)
doCreateItem(itemid, type/count, pos)
doCreateItemEx(itemid[, count/subtype])
doAddContainerItemEx(uid, virtuid)
doAddContainerItem(uid, itemid[, count/subtype])
doChangeTypeItem(uid, newtype)
doDecayItem(uid)
doRemoveItem(uid[, n])
doTransformItem(uid, toitemid[, count/subtype])
doSetItemActionId(uid, actionid)
doSetItemText(uid, text[, writer[, date]])
doSetItemSpecialDescription(uid, desc)
doSetItemOutfit(cid, item, time)
doTileAddItemEx(pos, uid)
doTileQueryAdd(uid, pos[, flags])
doAddCondition(cid, condition)
doRemoveCondition(cid, type[, subId])
doRemoveConditions(cid[, onlyPersistent])
doAreaCombatHealth(cid, type, pos, area, min, max, effect)
doTargetCombatHealth(cid, target, type, min, max, effect)
doAreaCombatMana(cid, pos, area, min, max, effect)
doTargetCombatMana(cid, target, min, max, effect)
doAreaCombatCondition(cid, pos, area, condition, effect)
doTargetCombatCondition(cid, target, condition, effect)
doAreaCombatDispel(cid, pos, area, type, effect)
doTargetCombatDispel(cid, target, type, effect)
doCombat(cid, combat, param)
doTeleportThing(cid, newpos[, pushmove])
doCreateTeleport(itemid, topos, createpos)
doSendMagicEffect(pos, type[, creature])
doSendDistanceShoot(frompos, topos, type[, creature])
doSendAnimatedText(pos, text, color[, creature])
doShowTextDialog(cid, itemid, text)
doRelocate(pos, posTo)
doBroadcastMessage(message, type)
doWaypointAddTemporial(name, pos)
doSetGameState(id)
doAddIpBanishment(ip[, length[, comment[, admin]]])
doAddNamelock(name[, reason[, action[, comment[, admin]]]])
doAddBanishment(accId[, length[, reason[, action[, comment[, admin]]]]])
doAddDeletion(accId[, reason[, action[, comment[, admin]]]]])
doAddNotation(accId[, reason[, action[, comment[, admin]]]]])
doRemoveIpBanishment(ip[, mask])
doRemoveNamelock(name)
doRemoveBanisment(accId)
doRemoveDeletion(accId)
doRemoveNotations(accId)
doSaveServer()
doReloadInfo()
doCleanHouse(houseId)
doCleanMap()
doRefreshMap()

 

 

Edited by Ed'Specter
Link to comment
Share on other sites

Olá gosto muito da area de scripts,acho muito #$@$ quem sabe criar scripts..mais tive uma duvida ali na parte do stepin e stepout,

pelo que entendi o item apenas aparece e desaparece da bp,tipo voce vai no sqm pisa e ele aparece vc sai do sqm e ele some?

se for assim,nao seria mais facil o player ir com um amigo e deslogar em cima do tile e o amigo jogar mw pra ele ser teleportado?

ele ia ter "dinheiro infinito" fazendo isso..

nao ia acabar..desculpe se nao tem nada a ver..estou lendo isso pois quero aprender e tive essa duvida.

 

EDIT>

Aki meu PRIMEIRO script

sei que deve ta tudo errado hEUHEU mais foi oq entendi

 


function onStepIn(cid, item, pos)
getCreatureHealth(cid)
doCreatureAddHealth(cid, 500[, force])
end
Edited by DragonTheory
Link to comment
Share on other sites

Amigo , usei esse script ae apenas como uma base , para explicar em apenas 1 script o uso de 2 funções(onStepIn e onStepOut)...

Claro que se fosse um tile que ganhasse dinheiro , usaria apenas a função 'onStepIn', e para que o player ganhasse apenas uma vez , usaria storage..

 

Ex :

function onStepIn(cid, item, pos)

if isPlayer(cid) then
   if getPlayerStorageValue(cid, 54321) <= 0 then
      doPlayerAddItem(cid, 2160, 100)
   else
      doPlayerSendCancel(cid, "Você já fez essa quest!")
   end
end

return true
end

O seu script tá totalmente errado, no caso ficaria assim :

function onStepIn(cid, item, pos)

if isPlayer(cid) then
   doCreatureAddHealth(cid, 500)
end

return true
end

..

Pelo que eu entendi sua ideia era que ao pisar no tile, o player ganhasse 500 de hp, então...

Não tem necessidade de usar getCreatureHealth(cid).

Apenas use um ' if (se) ' ,isPlayer(cid) .. ( Se é Player) .. Assim o script só será executado se for player.. (Apenas Player ganharam 500 de hp)

E usa um doCreatureAddHealth(cid, 500).. Vai adicionar 500 de hp no cid(creatura que ta pisando no tile)

e finaliza o if com um ' end ' .

Link to comment
Share on other sites

Ah valeu cara..

Uma ajudinha pra quem está começando é sempre bem vinda! haha

 

Edit>

a proposito,eu ouvi falar que existe um programa proprio de scripting de tibia..

isso realmente existe?

que ele tem todas as funçoes e tal..

Edited by DragonTheory
Link to comment
Share on other sites

×
×
  • Create New...