Ir para conteúdo
  • 0

Aumenta a quantidade de bicho com dust


MalBack

Pergunta

salve rapaziada queria saber se tem como aumenta a quantidade de mostro q aparece no map com dust "as poerinha para foge "

n ta aparecendo nada , parece um la de vem em quando . 

 

 

se poder me ajuda fico muito grato . " VERSAO 12.91 "

 

Vou deixa 2 arquivo pra verr se ajuda , ver se tem alguma coisa a ver com o que to pedindo .

 

 

local createMonster = TalkAction("/m")

function createMonster.onSay(player, words, param)
	if not player:getGroup():getAccess() or player:getAccountType() < ACCOUNT_TYPE_GOD then
		return true
	end

	-- Usage: "/m monstername, fiendish" for create a fiendish monster (/m rat, fiendish)
	-- Usage: "/m monstername, [1-5]" for create a influenced monster with specific level (/m rat, 2)
	if param == "" then
		player:sendCancelMessage("Monster name param required.")
		Spdlog.error("[createMonster.onSay] - Monster name param not found.")
		return false
	end

	local split = param:split(",")
	local monsterName = split[1]
	local monsterForge = nil
	if split[2] then
		split[2] = split[2]:gsub("^%s*(.-)$", "%1") --Trim left
		monsterForge = split[2]
	end
	-- Check dust level
	local setFiendish = false
	local setInfluenced
	if type(monsterForge) == "string" and monsterForge == "fiendish" then
		setFiendish = true
	end
	local influencedLevel
	if not setFiendish then
		influencedLevel = tonumber(monsterForge)
	end
	if influencedLevel and influencedLevel > 0 then
		if influencedLevel > 5 then
			player:sendCancelMessage("Invalid influenced level.")
			return false
		end
		setInfluenced = true
	end

	local position = player:getPosition()
	local monster = Game.createMonster(monsterName, position)
	if monster then
		monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
		position:sendMagicEffect(CONST_ME_MAGIC_RED)
		if setFiendish then
			local monsterType = monster:getType()
			if monsterType and not monsterType:isForgeCreature() then
				player:sendCancelMessage("Only allowed monsters can be fiendish.")
				return false
			end
			monster:setFiendish(position, player)
		end
		if setInfluenced then
			local influencedMonster = Monster(ForgeMonster:pickInfluenced())
			-- If it's reached the limit, we'll remove one to add the new one.
			if ForgeMonster:exceededMaxInfluencedMonsters() then
				if influencedMonster then
					Game.removeInfluencedMonster(influencedMonster:getId())
				end
			end
			Game.addInfluencedMonster(monster)
			monster:setForgeStack(influencedLevel)
		end
	else
		player:sendCancelMessage("There is not enough room.")
		position:sendMagicEffect(CONST_ME_POFF)
	end
	return false
end

createMonster:separator(" ")
createMonster:register()

 

 

if not ForgeMonster then
	ForgeMonster = {
		timeLeftToChangeMonsters = {},
		names = {
			[FORGE_NORMAL_MONSTER] = 'influenced',
			[FORGE_INFLUENCED_MONSTER] = 'influenced',
			[FORGE_FIENDISH_MONSTER] = 'fiendish'
		},
		chanceToAppear = {
			fiendish = 80,
			influenced = 20
		},
		maxFiendish = 3,
		eventName = 'ForgeMonster'
	}
end

function getFiendishMinutesLeft(leftTime)
	local secLeft = leftTime - os.time()
	local desc = "This monster will stay fiendish for less than"

	if math.floor(secLeft / 60) >= 1 then
		desc = desc .. " " .. math.floor(secLeft / 60) .. " minutes and"
		secLeft = secLeft - math.floor(secLeft / 60) * 60
	end

	if secLeft < 60 then
		desc = desc .. " " .. secLeft .. " seconds."
	end
	return desc
end

function ForgeMonster:getTimeLeftToChangeMonster(creature)
	local monster = Monster(creature)
	if monster then
		local leftTime = monster:getTimeToChangeFiendish()
		leftTime = leftTime or 0
		return getFiendishMinutesLeft(leftTime)
	end
	return 0
end

function ForgeMonster:onDeath(creature, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
	if not creature then
		return true
	end

	local stack = creature:getForgeStack()
	if stack > 0 then
		local party = nil
		if killer then
			if killer:isPlayer() then
				party = killer:getParty()
			elseif killer:getMaster() and killer:getMaster():isPlayer() then
				party = killer:getMaster():getParty()
			end
		end

		if party and party:isSharedExperienceEnabled() then
			local killers = {}
			local partyMembers = party:getMembers()

			for pid, _ in pairs(creature:getDamageMap()) do
				local creatureKiller = Creature(pid)
				if creatureKiller and creatureKiller:isPlayer() then
					if not isInArray(killers, creatureKiller) and isInArray(partyMembers, creatureKiller) then
						table.insert(killers, creatureKiller)
					end
				end
			end

			for i = 1, #killers do
				local playerKiller = killers[i]
				if playerKiller then
					-- Each stack can multiplied from 1x to 3x
					-- Example monster with 5 stack and system randomize multiplier 3x, players will receive 15x dusts

					local amount = math.random(stack, 3 * stack)

					local totalDusts = playerKiller:getForgeDusts()
					local limitDusts = playerKiller:getForgeDustLevel()

					if totalDusts < limitDusts then
						if totalDusts + amount > limitDusts then
							playerKiller:addForgeDusts(limitDusts - totalDusts)
						else
							playerKiller:addForgeDusts(amount)
						end

						local actualTotalDusts = playerKiller:getForgeDusts()
						playerKiller:sendTextMessage(MESSAGE_EVENT_ADVANCE,
						"You received " .. amount .. " dust" ..
						" for the Exaltation Forge. You now have " .. actualTotalDusts .. " out of a maximum of " ..
						limitDusts .. " dusts.")
					else
						playerKiller:sendTextMessage(MESSAGE_EVENT_ADVANCE,
						"You did not receive " .. amount .. " dust" ..
						" for the Exaltation Forge because you have already reached the maximum of " .. limitDusts .. " dust.")
					end
				end
			end
		else
			local playerKiller = nil

			if killer then
				if killer:isPlayer() then
					playerKiller = killer
				elseif killer:getMaster() and killer:getMaster():isPlayer() then
					playerKiller = killer:getMaster()
				end
			end

			if playerKiller then
				-- Each stack can multiplied from 1x to 3x
				-- Example monster with 5 stack and system randomize multiplier 3x, players will receive 15x dusts

				local amount = math.random(stack, 3 * stack)

				local totalDusts = playerKiller:getForgeDusts()
				local limitDusts = playerKiller:getForgeDustLevel()

				if totalDusts < limitDusts then
					if totalDusts + amount > limitDusts then
						playerKiller:addForgeDusts(limitDusts - totalDusts)
					else
						playerKiller:addForgeDusts(amount)
					end

					local actualTotalDusts = playerKiller:getForgeDusts()
					playerKiller:sendTextMessage(MESSAGE_EVENT_ADVANCE,
					"You received " .. amount .. " dust" ..
					" for the Exaltation Forge. You now have " .. actualTotalDusts .. " out of a maximum of " ..
					limitDusts .. " dusts.")
				else
					playerKiller:sendTextMessage(MESSAGE_EVENT_ADVANCE,
					"You did not receive " .. amount .. " dust" ..
					" for the Exaltation Forge because you have already reached the maximum of " .. limitDusts .. " dust.")
				end
			end
		end
	end
	return true
end

function ForgeMonster:onSpawn(creature)
	local monster = Monster(creature)
	if not monster then
		return false
	end

	local monsterType = monster:getType()
	if not monsterType then
		return false
	end

	local pos = monster:getPosition()
	local tile = Tile(pos)
	if tile and tile:hasFlag(TILESTATE_NOLOGOUT) then
		return false
	end

	Game.addInfluencedMonster(monster)
end

function ForgeMonster:pickFiendish()
	for _, cid in pairs(Game.getFiendishMonsters()) do
		if Monster(cid) then
			return cid
		end
	end
	return 0
end

function ForgeMonster:pickInfluenced()
	for _, cid in pairs(Game.getInfluencedMonsters()) do
		if Monster(cid) then
			return cid
		end
	end
	return 0
end

function ForgeMonster:pickClosestFiendish(creature)
	local player = Player(creature)
	if not player then
		return 0
	end

	local creatures = {}

	local playerPosition = player:getPosition()
	for _, cid in pairs(Game.getFiendishMonsters()) do
		if (Monster(cid)) then
			creatures[#creatures + 1] = {cid = cid, distance = Monster(cid):getPosition():getDistance(playerPosition)}
		end
	end

	if (#creatures == 0) then
		return false
	end

	table.sort(creatures, function(a, b)
		return a.distance < b.distance
	end)
	return creatures[1].cid
end

function ForgeMonster:exceededMaxInfluencedMonsters()
	local totalMonsters = 0
	for _, cid in pairs(Game.getInfluencedMonsters()) do
		if Monster(cid) then
			totalMonsters = totalMonsters + 1
		end
	end
	local configMaxMonsters = configManager.getNumber(configKeys.FORGE_INFLUENCED_CREATURES_LIMIT)
	if totalMonsters >= configMaxMonsters then
		return true
	end
	return false
end

 

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...