MrKarpiuk 124 Posted July 2, 2014 Share Posted July 2, 2014 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 Share on other sites More sharing options...
Active Member hachiwari 138 Posted July 2, 2014 Active Member Share Posted July 2, 2014 math.random(100) >= 99 - change % drop So, only 99 and 100. Change to: math.random(100) >= 50 Link to comment Share on other sites More sharing options...
MrKarpiuk 124 Posted July 2, 2014 Author Share Posted July 2, 2014 Soo its a lv who cane drop ? Link to comment Share on other sites More sharing options...
Active Member ATAG 310 Posted July 2, 2014 Active Member Share Posted July 2, 2014 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 Link to comment Share on other sites More sharing options...
Remix 45 Posted July 2, 2014 Share Posted July 2, 2014 If you type just 1 argument in math.random it returns 1. On this way it should work: math.random(1,100) Link to comment Share on other sites More sharing options...
Active Member ATAG 310 Posted July 2, 2014 Active Member Share Posted July 2, 2014 $ 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... Link to comment Share on other sites More sharing options...
Premium Lufbert 20 Posted July 2, 2014 Premium Share Posted July 2, 2014 I think you don't have npc.get_level function in your game Link to comment Share on other sites More sharing options...
lux 5 Posted July 2, 2014 Share Posted July 2, 2014 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 Share on other sites More sharing options...
Viloresi 0 Posted July 3, 2014 Share Posted July 3, 2014 local SUCCESS_ODD = 65 -- Success odds 65 means 65% if math.random(1,100) <= SUCCESS_ODD then end This is way better than the others above Link to comment Share on other sites More sharing options...
Remix 45 Posted July 4, 2014 Share Posted July 4, 2014 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 Share on other sites More sharing options...
Think 117 Posted July 4, 2014 Share Posted July 4, 2014 @iRemix: That is because you are not seeding again. Do math.randomseed(os.time()) -- or math.randomseed(get_global_time()) before the syschat. 1 Link to comment Share on other sites More sharing options...
Remix 45 Posted July 4, 2014 Share Posted July 4, 2014 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). 1 Link to comment Share on other sites More sharing options...
Think 117 Posted July 4, 2014 Share Posted July 4, 2014 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 Share on other sites More sharing options...
Active Member ATAG 310 Posted July 4, 2014 Active Member Share Posted July 4, 2014 Maybe this is not a coincidence that we have a number() quest function. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now