Ir para conteúdo
  • Cadastre-se

Regeneração de Mana nos Trainers


Posts Recomendados

Fala galera. 

Estou usando o TFS 1.3, mapa otservbr-global, última versão. Alguém tem script ou sabe como eu faço para adicionar regeneração de mana nos trainers? Preciso que fique regenerando sempre, para que os mages possam treinar também. 

Obrigado.

Link para o post
Compartilhar em outros sites
  • Moderador

Este tópico foi movido para a seção de Suporte Otserv.

 

20230912_034613.png.cf49b650c34dd7d7b1f79bd49c70f53c.png

Eu sou um entusiasta da programação apaixonado por ajudar a comunidade open source a crescer. Sempre em busca de novos desafios e oportunidades para contribuir com meu código.  #OpenSource #Programação #Contribuição

 

Link para o post
Compartilhar em outros sites
10 horas atrás, pergher disse:

Fala galera. 

Estou usando o TFS 1.3, mapa otservbr-global, última versão. Alguém tem script ou sabe como eu faço para adicionar regeneração de mana nos trainers? Preciso que fique regenerando sempre, para que os mages possam treinar também. 

Obrigado.

Tu pode fazer um globalevents (mesmo sistema que foi feito na magia das estatuas da library) porem tu pode tirar o dano e add a linha de add mana

 

 

Testa esse ai, só configura o fromPosition e o toPosition para a mesma coordenada para assim soltar em 1 lugar só, ai é só repetir para todos os trainers!

local effects = {
	{fromPosition = Position(32526, 32536, 12), toPosition = Position(32526, 32539, 12), effect = CONST_ME_HOLYDAMAGE},
}

function onThink(interval, cid)
	local jolf
	for i = 1, #effects do
        local settings = effects[i]
		fromPosition = settings.fromPosition
		toPosition = settings.toPosition
		local spectators = Game.getSpectators(settings.fromPosition, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
			if settings.effect then
				for y = fromPosition.y, toPosition.y do
					local newPosition = Position(fromPosition.x, y, fromPosition.z)
					newPosition:sendMagicEffect(settings.effect)

					jolf = Tile(newPosition):getTopCreature()
					if jolf and jolf:isPlayer() then
						doPlayerAddMana(cid, getPlayerMaxMana(cid))
					end
				end
				for x = fromPosition.x, toPosition.x do
					local newPosition2 = Position(x, fromPosition.y, fromPosition.z)
					newPosition2:sendMagicEffect(settings.effect)
					jolf = Tile(newPosition2):getTopCreature()
					if jolf and jolf:isPlayer() then
						doPlayerAddMana(cid, getPlayerMaxMana(cid))
					end
				end
			end
		end
	end
	return true
end

 

Editado por Faysal (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
6 horas atrás, Zazeros disse:

@pergher Cara, se tu quiser mais simples, põe pros Trainers healar a mana do alvo, só pegar um bicho que bate na mana e trocar o valor pra positivo, ai vai curar a mana do player

Que baita ideia haha

monster.attacks = {
    {name = "melee", attack = 130, effect = CONST_ME_DRAWBLOOD, interval = 2*1000, minDamage = -1, maxDamage = -2};
    {name= "manadrain", interval = 2*1000, chance="90", range="7", min="10", max="30"}
}

Adicionei o manadrain aqui, mas por alguma razao está dando 'unknow spell name'. Tem ideia de como pode ser o nome? Jah tentei varios haha

7 horas atrás, Faysal disse:

Tu pode fazer um globalevents (mesmo sistema que foi feito na magia das estatuas da library) porem tu pode tirar o dano e add a linha de add mana

 

 

Testa esse ai, só configura o fromPosition e o toPosition para a mesma coordenada para assim soltar em 1 lugar só, ai é só repetir para todos os trainers!


local effects = {
	{fromPosition = Position(32526, 32536, 12), toPosition = Position(32526, 32539, 12), effect = CONST_ME_HOLYDAMAGE},
}

function onThink(interval, cid)
	local jolf
	for i = 1, #effects do
        local settings = effects[i]
		fromPosition = settings.fromPosition
		toPosition = settings.toPosition
		local spectators = Game.getSpectators(settings.fromPosition, false, true, 7, 7, 5, 5)
        if #spectators > 0 then
			if settings.effect then
				for y = fromPosition.y, toPosition.y do
					local newPosition = Position(fromPosition.x, y, fromPosition.z)
					newPosition:sendMagicEffect(settings.effect)

					jolf = Tile(newPosition):getTopCreature()
					if jolf and jolf:isPlayer() then
						doPlayerAddMana(cid, getPlayerMaxMana(cid))
					end
				end
				for x = fromPosition.x, toPosition.x do
					local newPosition2 = Position(x, fromPosition.y, fromPosition.z)
					newPosition2:sendMagicEffect(settings.effect)
					jolf = Tile(newPosition2):getTopCreature()
					if jolf and jolf:isPlayer() then
						doPlayerAddMana(cid, getPlayerMaxMana(cid))
					end
				end
			end
		end
	end
	return true
end

 


Meu unico problema é que o char é teleportado até uma room disponível... 

 

local config = {
    -- Position of the first position (line 1 column 1)
    firstRoomPosition = {x = 1018, y = 1112, z = 7},
    -- X distance between each room (on the same line)
    distancePositionX= 12,
    -- Y distance between each room (on the same line)
    distancePositionY= 12,
    -- Number of columns
    columns= 7,
    -- Number of lines
    lines= 11
}

local function isBusyable(position)
    local player = Tile(position):getTopCreature()
    if player then
        if player:isPlayer() then
            return false
        end
    end

    local tile = Tile(position)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
        return false
    end

    local items = tile:getItems()
    for i = 1, tile:getItemCount() do
        local item = items
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end
    return true
end

local function calculatingRoom(uid, position, column, line)
    local player = Player(uid)
    if column >= config.columns then
        column = 0
        line = line < (config.lines -1) and line + 1 or false
    end

    if line then
        local room_pos = {x = position.x + (column * config.distancePositionX), y = position.y + (line * config.distancePositionY), z = position.z}
        if isBusyable(room_pos) then
            player:teleportTo(room_pos)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        else
            calculatingRoom(uid, position, column + 1, line)
        end
    else
        player:sendCancelMessage("Couldn't find any position for you right now.")
    end
end

local trainerEntrance = MoveEvent()
function trainerEntrance.onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return true
    end

    calculatingRoom(creature.uid, config.firstRoomPosition, 0, 0)
    Game.createMonster("training machine", creature:getPosition(), true, false)
    Game.createMonster("training machine", creature:getPosition(), true, false)
    return true
end

trainerEntrance:position({x = 1116, y = 1092, z = 7})
trainerEntrance:register()
 

Link para o post
Compartilhar em outros sites
7 minutos atrás, pergher disse:

Que baita ideia haha

monster.attacks = {
    {name = "melee", attack = 130, effect = CONST_ME_DRAWBLOOD, interval = 2*1000, minDamage = -1, maxDamage = -2};
    {name= "manadrain", interval = 2*1000, chance="90", range="7", min="10", max="30"}
}

Adicionei o manadrain aqui, mas por alguma razao está dando 'unknow spell name'. Tem ideia de como pode ser o nome? Jah tentei varios haha


Meu unico problema é que o char é teleportado até uma room disponível... 

 

local config = {
    -- Position of the first position (line 1 column 1)
    firstRoomPosition = {x = 1018, y = 1112, z = 7},
    -- X distance between each room (on the same line)
    distancePositionX= 12,
    -- Y distance between each room (on the same line)
    distancePositionY= 12,
    -- Number of columns
    columns= 7,
    -- Number of lines
    lines= 11
}

local function isBusyable(position)
    local player = Tile(position):getTopCreature()
    if player then
        if player:isPlayer() then
            return false
        end
    end

    local tile = Tile(position)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground or ground:hasProperty(CONST_PROP_BLOCKSOLID) then
        return false
    end

    local items = tile:getItems()
    for i = 1, tile:getItemCount() do
        local item = items
        local itemType = item:getType()
        if itemType:getType() ~= ITEM_TYPE_MAGICFIELD and not itemType:isMovable() and item:hasProperty(CONST_PROP_BLOCKSOLID) then
            return false
        end
    end
    return true
end

local function calculatingRoom(uid, position, column, line)
    local player = Player(uid)
    if column >= config.columns then
        column = 0
        line = line < (config.lines -1) and line + 1 or false
    end

    if line then
        local room_pos = {x = position.x + (column * config.distancePositionX), y = position.y + (line * config.distancePositionY), z = position.z}
        if isBusyable(room_pos) then
            player:teleportTo(room_pos)
            player:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
        else
            calculatingRoom(uid, position, column + 1, line)
        end
    else
        player:sendCancelMessage("Couldn't find any position for you right now.")
    end
end

local trainerEntrance = MoveEvent()
function trainerEntrance.onStepIn(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        return true
    end

    calculatingRoom(creature.uid, config.firstRoomPosition, 0, 0)
    Game.createMonster("training machine", creature:getPosition(), true, false)
    Game.createMonster("training machine", creature:getPosition(), true, false)
    return true
end

trainerEntrance:position({x = 1116, y = 1092, z = 7})
trainerEntrance:register()
 

Abre o rme e vê a posição de cada piso que os players vai ficar, assim tu configura como desejar

Link para o post
Compartilhar em outros sites
11 minutos atrás, Faysal disse:

Caso não der certo posso tentar ajudar com o método do @Zazeros

Tntei o dele mas por alguma razao ele nao esta reconhecendo o "manadrain"

monster.attacks = {
    {name = "melee", attack = 130, effect = CONST_ME_DRAWBLOOD, interval = 2*1000, minDamage = -1, maxDamage = -2};
    {name= "manadrain", interval = 2*1000, chance="90", range="7", min="10", max="30"}
}

Adicionei o manadrain aqui, mas por alguma razao está dando 'unknow spell name'. Tem ideia de como pode ser o nome? Jah tentei varios haha

Link para o post
Compartilhar em outros sites
24 minutos atrás, pergher disse:

Tntei o dele mas por alguma razao ele nao esta reconhecendo o "manadrain"

monster.attacks = {
    {name = "melee", attack = 130, effect = CONST_ME_DRAWBLOOD, interval = 2*1000, minDamage = -1, maxDamage = -2};
    {name= "manadrain", interval = 2*1000, chance="90", range="7", min="10", max="30"}
}

Adicionei o manadrain aqui, mas por alguma razao está dando 'unknow spell name'. Tem ideia de como pode ser o nome? Jah tentei varios haha

tenta assim
 

<attack name="manadrain" interval="1000" chance="7" range="7" min="900" max="10000">

    <attribute key="shootEffect" value="energy" />

    <attribute key="areaEffect" value="poff" />

</attack>

   
   
 

 

 

Link para o post
Compartilhar em outros sites
1 hora atrás, Faysal disse:

tenta assim
 

<attack name="manadrain" interval="1000" chance="7" range="7" min="900" max="10000">

    <attribute key="shootEffect" value="energy" />

    <attribute key="areaEffect" value="poff" />

</attack>

   
   
 

 

 

Obrigado pela ajuda. 

Me ajudaram em outro forum, vou botar aqui como fica caso mais alguém queira:

monster.attacks = {
    {name = "melee", attack = 130, effect = CONST_ME_DRAWBLOOD, interval = 2*1000, minDamage = -1, maxDamage = -2};
    {name ="combat", interval = 3000, chance = 80, minDamage = 30, maxDamage = 50, type = COMBAT_MANADRAIN, range = 7, effect = CONST_ME_SMALLPLANTS, target = false},

}


Faysal, valeu a ajuda. Esse é customizado, aí é escrito em lua, não xml. 
Abraço.

Link para o post
Compartilhar em outros sites
2 horas atrás, Faysal disse:

<attack name="manadrain" interval="1000" chance="7" range="7" min="900" max="10000">

    <attribute key="shootEffect" value="energy" />

    <attribute key="areaEffect" value="poff" />

</attack>

Boa noite!
Amigo, estou tentando a mesma coisa que o amigo ai em cima. Tentei desta maneira como vc sugeriu, porém nada acontece (assim como não há log de erros).
Alguma outra sugestão ?
Desde já mto obg.

 

Meu codigo no caso ficou assim:

 

<?xml version="1.0" encoding="UTF-8"?>
<monster name="Training Monk" nameDescription="a training monk" race="blood" experience="0" speed="0" manacost="0">
	<health now="200000" max="200000"/>
	<look type="57" corpse="22567"/>
	<targetchange interval="60000" chance="0"/>
	<flags>
		<flag summonable="0"/>
		<flag attackable="1"/>
		<flag hostile="1"/>
		<flag illusionable="0"/>
		<flag convinceable="0"/>
		<flag pushable="0"/>
		<flag canpushitems="0"/>
		<flag canpushcreatures="0"/>
		<flag targetdistance="1"/>
		<flag staticattack="50"/>
		<flag runonhealth="0"/>
	</flags> 
	<attacks>
	<attack name="melee" interval="2000" skill="0" attack="-1"/>
	</attacks>
	<attack name="manadrain" interval="1000" chance="7" range="7" min="900" max="10000">
    <attribute key="shootEffect" value="energy" />
    <attribute key="areaEffect" value="poff" />
	</attack>
	<defenses armor="0" defense="0">
		<defense name="healing" interval="2000" chance="80" min="10000" max="20000">
			<attribute key="areaEffect" value="blueshimmer"/>
		</defense>
	</defenses>
	<immunities>
		<immunity invisible="1"/>
	</immunities>
</monster>

 

Link para o post
Compartilhar em outros sites
26 minutos atrás, Xablaw disse:

Boa noite!
Amigo, estou tentando a mesma coisa que o amigo ai em cima. Tentei desta maneira como vc sugeriu, porém nada acontece (assim como não há log de erros).
Alguma outra sugestão ?
Desde já mto obg.

 

Meu codigo no caso ficou assim:

 


<?xml version="1.0" encoding="UTF-8"?>
<monster name="Training Monk" nameDescription="a training monk" race="blood" experience="0" speed="0" manacost="0">
	<health now="200000" max="200000"/>
	<look type="57" corpse="22567"/>
	<targetchange interval="60000" chance="0"/>
	<flags>
		<flag summonable="0"/>
		<flag attackable="1"/>
		<flag hostile="1"/>
		<flag illusionable="0"/>
		<flag convinceable="0"/>
		<flag pushable="0"/>
		<flag canpushitems="0"/>
		<flag canpushcreatures="0"/>
		<flag targetdistance="1"/>
		<flag staticattack="50"/>
		<flag runonhealth="0"/>
	</flags> 
	<attacks>
	<attack name="melee" interval="2000" skill="0" attack="-1"/>
	</attacks>
	<attack name="manadrain" interval="1000" chance="7" range="7" min="900" max="10000">
    <attribute key="shootEffect" value="energy" />
    <attribute key="areaEffect" value="poff" />
	</attack>
	<defenses armor="0" defense="0">
		<defense name="healing" interval="2000" chance="80" min="10000" max="20000">
			<attribute key="areaEffect" value="blueshimmer"/>
		</defense>
	</defenses>
	<immunities>
		<immunity invisible="1"/>
	</immunities>
</monster>

 

Testa esse aqui

 

<attack name="manadrain" interval="15000" chance="100" range="7" min="100" max="200">
      <attribute key="areaEffect" value="redshimmer"/>
 </attack>
Link para o post
Compartilhar em outros sites

Ficou assim, e está funcionando 100%.
Obrigado!

 

<?xml version="1.0" encoding="UTF-8"?>
<monster name="Training Monk" nameDescription="a training monk" race="blood" experience="0" speed="0" manacost="0">
	<health now="200000" max="200000"/>
	<look type="57" corpse="22567"/>
	<targetchange interval="60000" chance="0"/>
	<flags>
		<flag summonable="0"/>
		<flag attackable="1"/>
		<flag hostile="1"/>
		<flag illusionable="0"/>
		<flag convinceable="0"/>
		<flag pushable="0"/>
		<flag canpushitems="0"/>
		<flag canpushcreatures="0"/>
		<flag targetdistance="1"/>
		<flag staticattack="50"/>
		<flag runonhealth="0"/>
	</flags> 
	<attacks>
	<attack name="melee" interval="2000" skill="0" attack="-1"/>
	<attack name="manadrain" interval="1000" chance="7" range="7" min="900" max="10000">
	<attribute key="shootEffect" value="energy" />
    <attribute key="areaEffect" value="poff" />
	</attack>
	</attacks>
	<defenses armor="0" defense="0">
		<defense name="healing" interval="2000" chance="80" min="10000" max="20000">
			<attribute key="areaEffect" value="blueshimmer"/>
		</defense>
	</defenses>
	<immunities>
		<immunity invisible="1"/>
	</immunities>
</monster>

 

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo