Jump to content

Drop de piedras +4 al azar


ReuS

Mensajes recomendados

Bueno, este es un pequeño aporte para quienes no saben como poner en los metines, que dropee 1 sola piedra al azar, ya que en mob_drop_item.txt no se puede hacer.

--Quest realizada por ReuS para metin2zone
-- Discord : ReuS#4312

quest drop_piedras begin
	state start begin
		when 101.kill begin
		local probabilidad = math.random(1,1) ----editable, 1,1 significa que siempre dropeara
			if probabilidad == 1 then
				local drop = math.random(1,14) --- drop al azar
					if drop == 1 then
						game.drop_item_with_ownership("28430", 1)
					elseif drop == 2 then
						game.drop_item_with_ownership("28431", 1)
					elseif drop == 3 then
						game.drop_item_with_ownership("28432", 1)
					elseif drop == 4 then
						game.drop_item_with_ownership("28433", 1)
					elseif drop == 5 then
						game.drop_item_with_ownership("28434", 1)
					elseif drop == 6 then
						game.drop_item_with_ownership("28435", 1)
					elseif drop == 7 then
						game.drop_item_with_ownership("28436", 1)
					elseif drop == 8 then
						game.drop_item_with_ownership("28437", 1)
					elseif drop == 9 then
						game.drop_item_with_ownership("28438", 1)
					elseif drop == 10 then
						game.drop_item_with_ownership("28439", 1)
					elseif drop == 11 then
						game.drop_item_with_ownership("28440", 1)
					elseif drop == 12 then
						game.drop_item_with_ownership("28441", 1)
					elseif drop == 13 then
						game.drop_item_with_ownership("28442", 1)
					elseif drop == 14 then
						game.drop_item_with_ownership("28443", 1)
					end
				end
			end
		end
	end

 

Enlace para comentar
Compartir en otros sitios

quest drop_piedras_4 begin
	state start begin
		function esMetin()
			return {
				[8001] = 0, --este estructura la puse así para que cada vez que mate no tenga que hacer un ciclo
				[8002] = 0
			}
		end
		when kill with drop_piedras_4.esMetin()[npc.get_race()] != nil begin --en la tabla que puse arriba asigné números 0 (o podía poner cualquier cosa que no sea nil) para que logre detectar el vnum. Ya que toda tabla tiene sus index por defecto en nil. Al irme directamente a la posición con npc.get_race() no tendría que recorrer la tabla.
			if prob(0.75) then --acá está mi función "prob", esto significa 0.75%
				local rango_piedras = {28430, 28443}
				local piedra_azar = number(0, rango_piedras[2] - rango_piedras[1])+rango_piedras[1] --acá elijo un número al azar entre 0 y la diferencia en el rango, o sea, 13. Luego le sumo el vnum base y ya obtengo la piedra. 
				game.drop_item_with_ownership(piedra_azar)
			end
		end
	end
end

--Mi función del questlib.lua
function prob(probabilidad) -- formato de probabilidad: 100, 80, 55, 32.5, 1, 0.3, 0.07
	local base = 1
	if probabilidad >= 1 then
		return math.random(1, base*100) <= probabilidad
	else
		for i = 1, string.len(probabilidad)-1 do
			base = base*10
		end
		return math.random(1, base) <= probabilidad*(base/10)
	end
end

 

Lo hice de esta manera, comentado obviamente para transmitir el conocimiento. 

Ojo, no la probé xD

 

Vamos crackkksss!

 

Esta función será útil algún día xD

Enlace para comentar
Compartir en otros sitios

  • 1 year later...

--Quest realizada por ReuS para metin2zone
-- Discord : ReuS#4312

quest drop_piedras begin
    state start begin
        when 101.kill begin
            if math.random(1,1) == 1 then game.drop_item_with_ownership(number(28430,28443), 1) end 
        end
    end
    
--editable, 1,1 significa que siempre dropeara \\ math.random(1,2) == 50% \\  math.random(1,100) == 1% sucess drop

Enlace para comentar
Compartir en otros sitios

Unirse a la conversación

Puedes publicar ahora y registrarte más tarde. Si tienes una cuenta, regístrate para publicar con su cuenta.

Guest
Responder a este tema...

×   Has pegado contenido con formato .   Eliminar formato

  Only 75 emoji are allowed.

×   Tu enlace se ha incorporado automáticamente.   Mostrar un enlace en su lugar

×   Se ha restaurado el contenido anterior. .   Borrar editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recientemente navegando por este tema   0 miembros

    • No hay usuarios registrados visitando esta página.
×
×
  • Crear nuevo...