Jump to content
  • 0

Quest dont work


MrKarpiuk

Question

quest drop begin
    state start begin
        when kill with not npc.is_pc() and math.random(100) >= 99 begin
            local mob_lvl=npc.get_level()
            local player_level=pc.get_level()
                if player_level - mob_lvl <= 15 and player_level - mob_lvl >= -15 then
                    game.drop_item_with_ovnership(50133,1)
                end
        end
    end
end

Why quest dont work i kill many spot monster and any drop box why ?

 

And wher change % drop ?

 

 

Link to comment

13 answers to this question

Recommended Posts

  • 0

NO!
From 100 kill the script runs only 2 times. I think that you have to check the level BEFORE number/math.random.

quest drop begin
state start begin
  when kill with not npc.is_pc() begin
   local mob_lvl=npc.get_level()
   local player_level=pc.get_level()
   if player_level - mob_lvl <= 15 and player_level - mob_lvl >= -15 then
    local chance = 2 -- percent, change if you want!
    if number(1,100) > (100-chance) then
     game.drop_item_with_ovnership(50133,1)
    end
   end
  end
end
end

$ uptime
1:26AM  up 732 days,  8:29, 1 user, load averages: 0.38, 0.31, 0.22

$ uname -srp
FreeBSD 9.1-RELEASE amd64

Link to comment
  • 0
$ lua51
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> print(math.random(100))
85
>

 

math.random ([m [, n]])

This function is an interface to the simple pseudo-random generator function rand provided by ANSI C. (No guarantees can be given for its statistical properties.)

When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number m, math.random returns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbers m and n, math.random returns a uniform pseudo-random integer in the range [m, n].

 

I don't know how it works in 5.0, but i think it's the same...

 

$ uptime
1:26AM  up 732 days,  8:29, 1 user, load averages: 0.38, 0.31, 0.22

$ uname -srp
FreeBSD 9.1-RELEASE amd64

Link to comment
  • 0
quest drop begin
	state start begin
		when kill with not npc.is_pc() and math.random(1,100) >= 99 begin
			local mob_lvl=npc.get_level(npc.get_race())
			local player_level=pc.get_level()
			if player_level - mob_lvl <= 15 and player_level - mob_lvl >= -15 then
				game.drop_item_with_ownership(50133,1)
			end
		end
	end
end

this work

Link to comment
  • 0

You can test easily what math.random(100) returns with Lua 5.0

Just use this check output: syschat(math.random(100))

 

I tried it again in Lua 5.2 and i just got a 1 all the time.

Link to comment
  • 0

In my 5.2 IDE i get always the same number with math.random(100)

Doesn't matter if i use math.randomseed or not.

 

But well, i tested it ingame with math.random(100) and it worked (without math.randomseed).

  • Love 1
Link to comment
  • 0

Hmm, that's weird. Make sure you are seeding with time, otherwise the number will always be the same.

 

But well, i tested it ingame with math.random(100) and it worked (without math.randomseed).

The game seeds automatically possibly (random guess xD)

Link to comment
  • 0

Maybe this is not a coincidence that we have a number() quest function.

  • Love 1

$ uptime
1:26AM  up 732 days,  8:29, 1 user, load averages: 0.38, 0.31, 0.22

$ uname -srp
FreeBSD 9.1-RELEASE amd64

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.