Ir para conteúdo
  • 0
Famosiin

Scripting [AJUDA] monster.events

Pergunta

Famosiin    0
Famosiin

Antes de fazer a sua pergunta, tenha certeza de ter lido as regras da seção e o guia abaixo:

https://forums.otserv.com.br/index.php?/forums/topic/168583-regras-da-seção/

https://forums.otserv.com.br/index.php?/forums/topic/165121-como-fazer-uma-pergunta-ou-o-grande-guia-do-usuário-com-dúvidas/

Obs: não delete esse formulário pré-definido, preencha-o corretamente para postar o seu tópico!

Descreva em algumas palavras a base utilizada. (Nome do servidor / Nome do cliente / Nome do website / etc.).

Base:

Otserver-BR

Qual é a sua pergunta?

Fala pessoal beleza?

Gostaria de saber se é possivel colocar 2 monsters.events no mesmo monster.xml

monster.events = {
    "LeidenHeal"
}

Como queria colocar

monster.events = {
    "LeidenHeal",
    "LeidenDead"
}

 

eu criei uma função onde quando o boss leiden morrer nascer o boss principal, porem ja tem um evento setado ao leiden que é "LeidenHeal" e são duas funções diferentes.

LeidenHeal = function leidenHeal.onHealthChange

LeidenDead = function leidenDeath.onDeath

vou postar os scripts abaixo com as duas funções e o monster.xml

 

Você tem o código disponível? Se tiver poste-o na caixa de código que está dentro do spoiler abaixo:

Spoiler

CREATURESCRIPT.XML
local leidenHeal = CreatureEvent("LeidenHeal")
function leidenHeal.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
	if creature:getName():lower() == "leiden" then
		if attacker and attacker:isPlayer() then
			primaryType = COMBAT_HEALING
			secondaryType = primaryType
			if primaryDamage < 0 then
				primaryDamage = primaryDamage * -1
			end
			secondaryDamage = primaryDamage
			creature:addHealth(primaryDamage < 0 and -primaryDamage or primaryDamage)
			return primaryDamage, primaryType, secondaryDamage, secondaryType
		end
	end
end

leidenHeal:register()

local leidenDeath = CreatureEvent("LeidenDead")
function leidenDeath.onDeath(creature, corpse, deathList)
	local pool = Tile(creature:getPosition()):getItemById(2016)
	if pool then
		pool:remove()
	end
	Game.createMonster("bug", creature:getPosition(), true, true)
end

leidenDeath:register()

LEIDEN.XML
local mType = Game.createMonsterType("Leiden")
local monster = {}

monster.description = "Leiden"
monster.experience = 0
monster.outfit = {
	lookType = 988,
	lookHead = 0,
	lookBody = 0,
	lookLegs = 0,
	lookFeet = 0,
	lookAddons = 0,
	lookMount = 0
}

monster.health = 30000
monster.maxHealth = 30000
monster.race = "blood"
monster.corpse = 0
monster.speed = 240
monster.manaCost = 390
monster.maxSummons = 2

monster.changeTarget = {
	interval = 4000,
	chance = 20
}

monster.strategiesTarget = {
	nearest = 70,
	health = 10,
	damage = 10,
	random = 10,
}

monster.flags = {
	summonable = true,
	attackable = true,
	hostile = true,
	convinceable = true,
	pushable = false,
	rewardBoss = false,
	illusionable = false,
	canPushItems = true,
	canPushCreatures = true,
	staticAttackChance = 95,
	targetDistance = 1,
	runHealth = 0,
	healthHidden = false,
	isBlockable = false,
	canWalkOnEnergy = false,
	canWalkOnFire = false,
	canWalkOnPoison = false,
	pet = false
}

monster.events = {
	"LeidenHeal"
}

monster.light = {
	level = 0,
	color = 0
}

monster.summons = {
	{name = "Barkless Fanatic", chance = 20, interval = 2000},
	{name = "Barkless Fanatic", chance = 30, interval = 2000}
}

monster.voices = {
	interval = 5000,
	chance = 10,
	{text = "Bring me the pain! Make me suffer!", yell = false}
}

monster.loot = {
}

monster.attacks = {
	{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -400}
}

monster.defenses = {
	defense = 50,
	armor = 35
}

monster.reflects = {
	{type = COMBAT_PHYSICALDAMAGE, percent = 100},
	{type = COMBAT_ENERGYDAMAGE, percent = 100},
	{type = COMBAT_EARTHDAMAGE, percent = 100},
	{type = COMBAT_FIREDAMAGE, percent = 100},
	{type = COMBAT_LIFEDRAIN, percent = 100},
	{type = COMBAT_MANADRAIN, percent = 100},
	{type = COMBAT_DROWNDAMAGE, percent = 100},
	{type = COMBAT_ICEDAMAGE, percent = 100},
	{type = COMBAT_HOLYDAMAGE , percent = 100},
	{type = COMBAT_DEATHDAMAGE , percent = 100}
}

monster.elements = {
	{type = COMBAT_PHYSICALDAMAGE, percent = 100},
	{type = COMBAT_ENERGYDAMAGE, percent = 0},
	{type = COMBAT_EARTHDAMAGE, percent = 0},
	{type = COMBAT_FIREDAMAGE, percent = 0},
	{type = COMBAT_LIFEDRAIN, percent = 0},
	{type = COMBAT_MANADRAIN, percent = 0},
	{type = COMBAT_DROWNDAMAGE, percent = 0},
	{type = COMBAT_ICEDAMAGE, percent = 0},
	{type = COMBAT_HOLYDAMAGE , percent = 0},
	{type = COMBAT_DEATHDAMAGE , percent = 0}
}

monster.immunities = {
	{type = "paralyze", condition = false},
	{type = "outfit", condition = false},
	{type = "invisible", condition = false},
	{type = "bleed", condition = false}
}

mType:register(monster)

 

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, anexe-a dentro do spoiler abaixo:

Spoiler

 

 

Editado por Famosiin

Compartilhar este post


Link para o post
Compartilhar em outros sites

3 respostass a esta questão

Recommended Posts

  • 1
Majesty    1755
Majesty

Tenta assim:

Spoiler

local mType = Game.createMonsterType("Leiden")
local monster = {}

monster.description = "Leiden"
monster.experience = 0
monster.outfit = {
	lookType = 988,
	lookHead = 0,
	lookBody = 0,
	lookLegs = 0,
	lookFeet = 0,
	lookAddons = 0,
	lookMount = 0
}

monster.health = 30000
monster.maxHealth = 30000
monster.race = "blood"
monster.corpse = 0
monster.speed = 240
monster.manaCost = 390
monster.maxSummons = 2

monster.changeTarget = {
	interval = 4000,
	chance = 20
}

monster.strategiesTarget = {
	nearest = 70,
	health = 10,
	damage = 10,
	random = 10,
}

monster.flags = {
	summonable = true,
	attackable = true,
	hostile = true,
	convinceable = true,
	pushable = false,
	rewardBoss = false,
	illusionable = false,
	canPushItems = true,
	canPushCreatures = true,
	staticAttackChance = 95,
	targetDistance = 1,
	runHealth = 0,
	healthHidden = false,
	isBlockable = false,
	canWalkOnEnergy = false,
	canWalkOnFire = false,
	canWalkOnPoison = false,
	pet = false
}

monster.events = {
	"LeidenHeal",
	"LeidenDead"
}

monster.light = {
	level = 0,
	color = 0
}

monster.summons = {
	{name = "Barkless Fanatic", chance = 20, interval = 2000},
	{name = "Barkless Fanatic", chance = 30, interval = 2000}
}

monster.voices = {
	interval = 5000,
	chance = 10,
	{text = "Bring me the pain! Make me suffer!", yell = false}
}

monster.loot = {
}

monster.attacks = {
	{name ="melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -400}
}

monster.defenses = {
	defense = 50,
	armor = 35
}

monster.reflects = {
	{type = COMBAT_PHYSICALDAMAGE, percent = 100},
	{type = COMBAT_ENERGYDAMAGE, percent = 100},
	{type = COMBAT_EARTHDAMAGE, percent = 100},
	{type = COMBAT_FIREDAMAGE, percent = 100},
	{type = COMBAT_LIFEDRAIN, percent = 100},
	{type = COMBAT_MANADRAIN, percent = 100},
	{type = COMBAT_DROWNDAMAGE, percent = 100},
	{type = COMBAT_ICEDAMAGE, percent = 100},
	{type = COMBAT_HOLYDAMAGE , percent = 100},
	{type = COMBAT_DEATHDAMAGE , percent = 100}
}

monster.elements = {
	{type = COMBAT_PHYSICALDAMAGE, percent = 100},
	{type = COMBAT_ENERGYDAMAGE, percent = 0},
	{type = COMBAT_EARTHDAMAGE, percent = 0},
	{type = COMBAT_FIREDAMAGE, percent = 0},
	{type = COMBAT_LIFEDRAIN, percent = 0},
	{type = COMBAT_MANADRAIN, percent = 0},
	{type = COMBAT_DROWNDAMAGE, percent = 0},
	{type = COMBAT_ICEDAMAGE, percent = 0},
	{type = COMBAT_HOLYDAMAGE , percent = 0},
	{type = COMBAT_DEATHDAMAGE , percent = 0}
}

monster.immunities = {
	{type = "paralyze", condition = false},
	{type = "outfit", condition = false},
	{type = "invisible", condition = false},
	{type = "bleed", condition = false}
}

mType:register(monster)

local leidenHeal = CreatureEvent("LeidenHeal")
function leidenHeal.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
	if creature:getName():lower() == "leiden" then
		if attacker and attacker:isPlayer() then
			primaryType = COMBAT_HEALING
			secondaryType = primaryType
			if primaryDamage < 0 then
				primaryDamage = primaryDamage * -1
			end
			secondaryDamage = primaryDamage
			creature:addHealth(primaryDamage < 0 and -primaryDamage or primaryDamage)
			return primaryDamage, primaryType, secondaryDamage, secondaryType
		end
	end
end

leidenHeal:register()

local leidenDeath = CreatureEvent("LeidenDead")
function leidenDeath.onDeath(creature, corpse, deathList)
	local pool = Tile(creature:getPosition()):getItemById(2016)
	if pool then
		pool:remove()
	end
	Game.createMonster("bug", creature:getPosition(), true, true)
end

leidenDeath:register()

 

Os dois creature events estão registrados no monstro.

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Famosiin    0
Famosiin

Funcionou certinho! Obrigado, só uma duvida por um acaso o Boss leiden da OTserverBR não estava funcionando né?

Compartilhar este post


Link para o post
Compartilhar em outros sites
  • 0
Majesty    1755
Majesty

Acho que não.

Você pode criar um issue sobre problemas e/ou bugs que encontrar no servidor em: 
https://github.com/opentibiabr/otservbr-global/issues
Obs: verifica se antes já não existe issue sobre tal assunto para não criar duplicado.

Se o problema e/ou bug for de quest, poste no issue:
https://github.com/opentibiabr/otservbr-global/issues/726

Você pode acompanhar o projeto no discord:
https://discordapp.com/invite/3NxYnyV

 

Compartilhar este post


Link para o post
Compartilhar em outros sites
Visitante
Este tópico está impedido de receber novos posts.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×