|
You last visited: Today at 09:39
Advertisement
[Release] Neue Dropmethode
Discussion on [Release] Neue Dropmethode within the Metin2 PServer Guides & Strategies forum part of the Metin2 Private Server category.
12/07/2013, 17:04
|
#31
|
elite*gold: 35
Join Date: May 2010
Posts: 311
Received Thanks: 36
|
Es wird immer zu 100% gedropt. Da kann man eingeben was man will.
MfG
|
|
|
12/07/2013, 20:39
|
#32
|
elite*gold: 0
Join Date: Jul 2013
Posts: 809
Received Thanks: 1,613
|
Quote:
Originally Posted by ~Crain~
bei mir droppen die mobs die schen trd 100 % ^^
hier der code was mach ich falsch
Code:
[102] = {
typ = "limit", -- type
min_level = 1, -- mindestlevel
max_level = 10, -- maxlevel
dropps = {
{23, 1, 1}, -- dropeintrag (vnum, count, chance)
{4003, 1, 0.001},
{2013, 1, 0.001},
{5003, 1, 0.001},
{7013, 1, 0.001},
{3013, 1, 0.001},
}
},
|
ICh wurde ignoeriert als ich das erklären wollte. man kann glaube ich nicht
0.001% einstellen
|
|
|
12/07/2013, 20:45
|
#33
|
elite*gold: 5
Join Date: Mar 2013
Posts: 1,986
Received Thanks: 2,254
|
Quote:
Originally Posted by CryPrime
ICh wurde ignoeriert als ich das erklären wollte. man kann glaube ich nicht
0.001% einstellen
|
Chance auslesen:
PHP Code:
if dropList[self].dropps[i][3] == nil then -- checkt ob Eintrag existiert chance = dropList[self].dropps[i][3] --Wenn ja chance auf den Wert der Tabelle setzen else chance = 100--Wenn nicht auf 100% end
Ich schätze das hier irg. ein Fehler vorhanden ist:
PHP Code:
if dropList[self].dropps[i][3] == nil then
habe mit Tabellen noch nicht so viel gemacht darum keine Ahnung...
€: Achso stimmt alles unter 2% geht nicht da:
PHP Code:
if math.random(1, 100) < chance then
|
|
|
12/07/2013, 21:36
|
#34
|
elite*gold: 35
Join Date: May 2010
Posts: 311
Received Thanks: 36
|
Also wenn ich z.B. 50% Chance in die droplist.lua eintrage dann kommt trotzdem immer 100% ein Item. Wenn ich aber in der questlib.lua chance anstatt 100 zu 50 mache dann kommt das item auch nur zu 50%. Also liest er die Droplist.lua nicht richtig aus.
Einer eine Idee wie es richtig geht?
MfG
|
|
|
12/07/2013, 21:46
|
#35
|
elite*gold: 5
Join Date: Mar 2013
Posts: 1,986
Received Thanks: 2,254
|
Quote:
Originally Posted by krieger3
Also wenn ich z.B. 50% Chance in die droplist.lua eintrage dann kommt trotzdem immer 100% ein Item. Wenn ich aber in der questlib.lua chance anstatt 100 zu 50 mache dann kommt das item auch nur zu 50%. Also liest er die Droplist.lua nicht richtig aus.
Einer eine Idee wie es richtig geht?
MfG
|
Versuch mal die hier da sollten einfach Texte im Chat erscheinen.. hab gerade keinen Server zum testen hier...:
PHP Code:
function drop(self) if dropList[self].typ == "limit" then if dropList[self].min_level == nil or dropList[self].max_level == nil then return end if dropList[self].min_level > pc.level or dropList[self].max_level < pc.level then return end local chance,count table.foreach(dropList[self].dropps, function(i) chat("Chance: "..dropList[self].dropps[i][3].."") if dropList[self].dropps[i][3] == nil then chance = dropList[self].dropps[i][3] else chat("Chance auf 100% gesetzt") chance = 100 end if dropList[self].dropps[i][2] == nil then count = dropList[self].dropps[i][2] else count = 1 end if math.random(1, 100) < chance then game.drop_item_with_ownership(dropList[self].dropps[i][1], count) end end) elseif dropList[self].typ == "drop" then local chance,count table.foreach(dropList[self].dropps, function(i) chat("Chance: "..dropList[self].dropps[i][3].."") if dropList[self].dropps[i][3] == nil then chance = dropList[self].dropps[i][3] else chat("Chance auf 100% gesetzt") chance = 100 end if dropList[self].dropps[i][2] == nil then count = dropList[self].dropps[i][2] else count = 1 end if math.random(1, 100) < chance then game.drop_item_with_ownership(dropList[self].dropps[i][1], count) end end) else return end end
|
|
|
12/08/2013, 02:55
|
#36
|
elite*gold: 35
Join Date: May 2010
Posts: 311
Received Thanks: 36
|
Hier eine funktionieren Version.
Geändert:
-Chance von 0.001 bis 100 möglich
-Chancen funktionieren nun (nicht immer 100%)
-Es werden auch mehrere Items gedropt (vorher immer nur 1)
-Man muss die Werte vnum, count, chance angeben weil die Abfrage "else" raus ist. (find ich unnötig)
MfG
PHP Code:
dofile("/usr/home/game/share/locale/germany/droplist.lua")
function drop(self) if dropList[self].typ == "limit" then if dropList[self].min_level == nil or dropList[self].max_level == nil then return end if dropList[self].min_level > pc.level or dropList[self].max_level < pc.level then return end local chance,count table.foreach(dropList[self].dropps, function(i) if dropList[self].dropps[i][3] then chance = dropList[self].dropps[i][3] end if dropList[self].dropps[i][2] then count = dropList[self].dropps[i][2] end if math.random(0.001, 100) < chance then game.drop_item_with_ownership(dropList[self].dropps[i][1], count) end end) elseif dropList[self].typ == "drop" then local chance,count table.foreach(dropList[self].dropps, function(i) if dropList[self].dropps[i][3] then chance = dropList[self].dropps[i][3] end if dropList[self].dropps[i][2] then count = dropList[self].dropps[i][2] end if math.random(0.001, 100) < chance then game.drop_item_with_ownership(dropList[self].dropps[i][1], count) end end) else return end end
|
|
|
12/08/2013, 04:17
|
#37
|
elite*gold: 212
Join Date: Jul 2012
Posts: 14,508
Received Thanks: 5,528
|
Mathe nicht eure Stärke?
Je höher die Zahl nach dem Komma, desto geringer die Chance auf das Item.
Die 100 ist im Normalfall variabel.
|
|
|
12/08/2013, 11:43
|
#38
|
elite*gold: 191
Join Date: May 2009
Posts: 1,214
Received Thanks: 2,594
|
Kleiner Lösungsvorschlag:
aus
if math.random(1, 100) < chance then
mach
if math.random(1e6, 100e6) < chance*1e6 then
oder
if math.random(1, 100)*1e6 < chance*1e6 then
Vll hilfts euch
|
|
|
12/13/2013, 08:54
|
#39
|
elite*gold: 50
Join Date: May 2011
Posts: 269
Received Thanks: 990
|
MyMod
Here is my modifications(untested!)
I added to it the "kill" and the "thiefgloves" types and a new "event" type.
0x01; Expanded LuaDrop
All in one.
Code:
--[[ *UNTESTED*
Created and published by iRemix
Expanded by P3NG3R
]]
--* droplist.lua *--
dropList = {
--[mVnum] = table,
[101] = {
typ = "drop", -- type
drops = { -- droptable
-- {vnum, count, chance},
{19, 1, 75.1},
{29, 1, 55.9},
}
},
[102] = {
typ = "limit", -- type
level_limit = {min=18,max=25}, -- level limit
drops = { -- droptable
-- {vnum, count, chance},
{19, 1, 25.02},
{29, 1, 39.4},
}
},
[103] = {
typ = "kill", -- type
kill_drop = 50, -- kill count
cycle = 60*60*12, -- reset cycle time
drops = { -- droptable
-- {vnum, count, chance},
{19, 1, 4.2},
{29, 1, 7.5},
}
},
[104] = {
typ = "thiefgloves",
gloves = {70043,71016,72004,72005,72006,79009}, --thief's gloves items' vnum
drops = { -- droptable
-- {vnum, count, chance},
{19, 1, 3.5},
{29, 1, 10.2},
}
},
[105] = {
typ = "event",
drops = {
--eFlag = droptable,
moonlight = {
{19, 1, 2.2},
{29, 1, 0.2},
},
hexagonal = {
{19, 1, 2.2},
{29, 1, 0.2},
},
xmas = {
{19, 1, 2.2},
{29, 1, 0.2},
},
},
},
}
--* questlib.lua *--
--dofile("/usr/home/metin2/share/locale/hungary/droplist.lua")
dofile(get_locale_base_path().."/droplist.lua")
MOB_LEVEL = nil
MOB_EXP = nil
npc.get_level = npc.get_level or function(vnum)--or diffed game function or Lib_so
local q=(mysql_query(string.format("SELECT level FROM player.mob_proto WHERE vnum=%d", tonumber(vnum or npc.get_race()))) or {{0}})[1]
return tonumber(q[1])
end
function in_tab(tab,val)
if type(tab)~="table" then return end
for i,v in pairs(tab) do if val==v then return true end end
return false
end
function has_key(tab,key)
if type(tab)~="table" then return end
for i,v in pairs(tab) do if key==i then return true end end
return false
end
function drop(self)
if has_key(dropList, self) == false then return end
if dropList[self].typ == "limit" then
if dropList[self].level_limit.min == nil or dropList[self].level_limit.max == nil then return end
if dropList[self].level_limit.min > pc.level or dropList[self].level_limit.max < pc.level then return end
local count,chance
table.foreach(dropList[self].drops, function(i)
count = dropList[self].drops[i][2] or 1
chance = dropList[self].drops[i][3] or 100
if math.random(1, 100)*1e6 < chance*1e6 then
game.drop_item_with_ownership(dropList[self].drops[i][1], count)
end
end)
elseif dropList[self].typ == "drop" then
local mob_lev, pc_lev = (MOB_LEVEL[self] or get_mob_level[self] or npc.get_level() or 1), pc.get_level()
if (pc_lev-10<=mob_lev and pc_lev+10>=mob_lev)==false return end
local count,chance
table.foreach(dropList[self].drops, function(i)
count = dropList[self].drops[i][2] or 1
chance = dropList[self].drops[i][3] or 100
if math.random(1, 100)*1e6 < chance*1e6 then
game.drop_item_with_ownership(dropList[self].drops[i][1], count)
end
end)
elseif dropList[self].typ == "kill" then
if dropList[self].kill_drop == nil then return end
if pc.getf("lua_drop", tostring(self).."_killduration") == nil and pc.getf("lua_drop", tostring(self).."_killcount") == nil or pc.getf("lua_drop", tostring(self).."_killduration") < get_time() then
pc.setf("lua_drop", tostring(self).."_killduration", get_time()+(dropList[self].cycle or 86400))
pc.setf("lua_drop", tostring(self).."_killcount", 0)
end
if pc.getf("lua_drop", tostring(self).."_killcount") < dropList[self].kill_drop then
pc.setf("lua_drop", tostring(self).."_killcount", pc.getf("lua_drop", tostring(self).."_killcount")+1)
end
local count,chance
table.foreach(dropList[self].drops, function(i)
count = dropList[self].drops[i][2] or 1
chance = dropList[self].drops[i][3] or 100
if math.random(1, 100)*1e6 < chance*1e6 and pc.getf("lua_drop", tostring(self).."_killcount") >= dropList[self].kill_drop then
game.drop_item_with_ownership(dropList[self].drops[i][1], count)
end
end)
elseif dropList[self].typ == "thiefgloves" then
if dropList[self].gloves == nil or #dropList[self].gloves == 0 then return end
if in_tab(dropList[self].gloves, pc.get_wear(97)) == false and in_tab(dropList[self].gloves, pc.get_wear(98)) == false then return end
local count,chance
table.foreach(dropList[self].drops, function(i)
count = dropList[self].drops[i][2] or 1
chance = dropList[self].drops[i][3] or 100
if math.random(1, 100)*1e6 < chance*1e6 then
game.drop_item_with_ownership(dropList[self].drops[i][1], count)
end
end)
elseif dropList[self].typ == "event" then
table.foreach(dropList[self].drops, function(flag)
local count,chance
if game.get_event_flag(flag)==1 then
table.foreach(dropList[self].drops.flag, function(i)
count = dropList[self].drops.flag[i][2] or 1
chance = dropList[self].drops.flag[i][3] or 100
if math.random(1, 100)*1e6 < chance*1e6 then
game.drop_item_with_ownership(dropList[self].flag.drops[i][1], count)
end
end)
end
end)
else
sys_log(0, "[LUA] Unknown drop type '"..tostring(dropList[self].typ).."'")
return
end
end
--* lua_drop.quest *--
quest lua_drop begin
state start begin
when login begin
set_state("dropping")
end
end
state dropping begin
when login begin
if MOB_LEVEL == nil then --fill up global variable after "reload q" or "reboot".
local _q=mysql_query('SELECT vnum, level, exp FROM player.mob_proto WHERE vnum > 0 AND vnum < 9000 ORDER BY vnum;')
MOB_LEVEL = {}; MOB_EXP = {};
table.foreach(_q,function(i,v)
table.insert(MOB_LEVEL, v[1],v[2]);table.insert(MOB_EXP, v[1], v[3])
end)
test_chat(string.format("Mob table was load in succesfully with %d pcs. mobs!",table.getn(MOB_LEVEL)))
end
end
when kill with not npc.is_pc() begin
drop(npc.get_race())
end
end
end
0x02; MultiLuaDrop
Code:
--[[ *UNTESTED*
LuaMultiDrop
By P3NG3R
]]
--* droplist.lua *--
dropList = {
[101] = {
{
typ = "drop",
drops = {
{19, 1, 75.1},
{29, 1, 55.9},
}
},
{
typ = "limit",
level_limit = {min=18,max=25},
drops = {
{39, 1, 25.02},
{49, 1, 39.4},
}
},
{
typ = "kill",
kill_drop = 75,
cycle = 60*60*24,
drops = {
{59, 1, 4.2},
{69, 1, 7.5},
}
},
{
typ = "thiefgloves",
gloves = {70043,71016,72004,72005,72006,79009},
drops = {
{79, 1, 3.5},
{89, 1, 10.2},
}
},
},
events = {
moonlight = {
{99, 1, 2.5},
{109, 1, 11.6},
},
hexagonal = {
{119, 1, 1.5},
{129, 1, 5.2},
},
xmas = {
{139, 1, 0.7112},
{149, 1, 0.2119},
},
},
}
--* questlib.lua *--
--dofile("/usr/home/metin2/share/locale/hungary/droplist.lua")
dofile(get_locale_base_path().."/droplist.lua")
MOB_LEVEL = nil
MOB_EXP = nil
npc.get_level = npc.get_level or function(vnum)--or diffed game function or Lib_so
local q=(mysql_query(string.format("SELECT level FROM player.mob_proto WHERE vnum=%d", tonumber(vnum or npc.get_race()))) or {{0}})[1]
return tonumber(q[1])
end
function in_tab(tab,val)
if type(tab)~="table" then return end
for i,v in pairs(tab) do if val==v then return true end end
return false
end
function has_key(tab,key)
if type(tab)~="table" then return end
for i,v in pairs(tab) do if key==i then return true end end
return false
end
function drop(self)
if has_key(dropList, self) == false then return end
--* Event drop *--
table.foreach(dropList.events, function(flag)
local count,chance
if game.get_event_flag(flag) == 1 then
table.foreach(dropList.events.flag, function(j)
count = dropList.events.flag[j][2] or 1
chance = dropList.events.flag[j][3] or 100
if math.random(1, 100)*1e6 < chance*1e6 then
game.drop_item_with_ownership(dropList.events.flag[j][1], count)
end
end)
end
end)
--* Monster drop *--
table.foreach(dropList, function(i)
if dropList[self][i].typ == "drop" then
local mob_lev, pc_lev = (npc.get_level() or MOB_LEVEL[self] or get_mob_level[self] or 1), pc.get_level()
if (pc_lev-10<=mob_lev and pc_lev+10>=mob_lev)==false return end
local count,chance
table.foreach(dropList[self][i].drops, function(j)
count = dropList[self][i].drops[j][2] or 1
chance = dropList[self][i].drops[j][3] or 100
if math.random(1, 100)*1e6 < chance*1e6 then
game.drop_item_with_ownership(dropList[self][i].drops[j][1], count)
end
end)
elseif dropList[self][i].typ == "limit" then
if dropList[self][i].level_limit.min == nil or dropList[self][i].level_limit.max == nil then return end
if dropList[self][i].level_limit.min > pc.level or dropList[self][i].level_limit.max < pc.level then return end
local count,chance
table.foreach(dropList[self][i].drops, function(j)
count = dropList[self][i].drops[j][2] or 1
chance = dropList[self][i].drops[j][3] or 100
if math.random(1, 100)*1e6 < chance*1e6 then
game.drop_item_with_ownership(dropList[self][i].drops[j][1], count)
end
end)
elseif dropList[self][i].typ == "kill" then
if dropList[self][i].kill_drop == nil then return end
if pc.getf("lua_drop", tostring(self).."_killduration") == nil and pc.getf("lua_drop", tostring(self).."_killcount") == nil or pc.getf("lua_drop", tostring(self).."_killduration") < get_time() then
pc.setf("lua_drop", tostring(self).."_killduration", get_time()+(dropList[self][i].cycle or 86400))
pc.setf("lua_drop", tostring(self).."_killcount", 0)
end
if pc.getf("lua_drop", tostring(self).."_killcount") < dropList[self][i].kill_drop then
pc.setf("lua_drop", tostring(self).."_killcount", pc.getf("lua_drop", tostring(self).."_killcount")+1)
end
local count,chance
table.foreach(dropList[self][i].drops, function(i)
count = dropList[self][i].drops[i][2] or 1
chance = dropList[self][i].drops[i][3] or 100
if math.random(1, 100)*1e6 < chance*1e6 and pc.getf("lua_drop", tostring(self).."_killcount") >= dropList[self][i].kill_drop then
game.drop_item_with_ownership(dropList[self][i].drops[i][1], count)
end
end)
elseif dropList[self][i].typ == "thiefgloves" then
if dropList[self][i].gloves == nil or #dropList[self][i].gloves == 0 then return end
if in_tab(dropList[self][i].gloves, pc.get_wear(97)) == false and in_tab(dropList[self][i].gloves, pc.get_wear(98)) == false then return end
local count,chance
table.foreach(dropList[self][i].drops, function(j)
count = dropList[self][i].drops[j][2] or 1
chance = dropList[self][i].drops[j][3] or 100
if math.random(1, 100)*1e6 < chance*1e6 then
game.drop_item_with_ownership(dropList[self][i].drops[j][1], count)
end
end)
else
sys_log(0, "[LUA] Unknown drop type '"..tostring(dropList[self][i].typ).."'")
return
end
end)
end
--* lua_drop.quest *--
quest lua_drop begin
state start begin
when login begin
set_state("dropping")
end
end
state dropping begin
when login begin
if MOB_LEVEL == nil then --fill up global variable after "reload q" or "reboot".
local _q=mysql_query('SELECT vnum, level, exp FROM player.mob_proto WHERE vnum > 0 AND vnum < 9000 ORDER BY vnum;')
MOB_LEVEL = {}; MOB_EXP = {};
table.foreach(_q,function(i,v)
table.insert(MOB_LEVEL, v[1],v[2]);table.insert(MOB_EXP, v[1], v[3])
end)
test_chat(string.format("Mob table was load in succesfully with %d pcs. mobs!",table.getn(MOB_LEVEL)))
end
end
when kill with not npc.is_pc() begin
drop(npc.get_race())
end
end
end
Special thanks to:
- iRemix[author]
- Mijago[chance]
With regards,
P3NG3R
|
|
|
12/14/2013, 15:03
|
#40
|
elite*gold: 0
Join Date: Dec 2013
Posts: 1
Received Thanks: 0
|
geht besser
|
|
|
12/15/2013, 16:07
|
#41
|
elite*gold: 0
Join Date: May 2012
Posts: 50
Received Thanks: 83
|
it is good for hamachi servers, on dedicated it will generate too much load. But this idea is great )
|
|
|
12/15/2013, 16:12
|
#42
|
elite*gold: 0
Join Date: Dec 2013
Posts: 60
Received Thanks: 12
|
Sehr nice kann jeder gebrauchen !
|
|
|
02/16/2014, 18:11
|
#43
|
elite*gold: 0
Join Date: Nov 2013
Posts: 401
Received Thanks: 132
|
SYSERR: Feb 16 17:59:53 :: RunState: LUA_ERROR: locale/germany/quest/questlib.lua:1804: attempt to index field `?' (a nil value)
SYSERR: Feb 16 17:59:53 :: WriteRunningStateToSyserr: LUA_ERROR: quest lua_drop.start click
|
|
|
02/18/2014, 10:48
|
#44
|
elite*gold: 0
Join Date: Jan 2009
Posts: 104
Received Thanks: 126
|
You need a minimal "error handling" in drop function.
Code:
function drop(self)
if not dropList[self] then return end
if dropList[self].typ == "limit" then
...
|
|
|
02/18/2014, 15:35
|
#45
|
elite*gold: 1
Join Date: Jun 2013
Posts: 79
Received Thanks: 19
|
Hey,
also wenn ich mich recht erinnere wurde das
schon des öfteren " Publiziert" bzw. erwähnt ...
BΣQЦIΣƬ
|
|
|
Similar Threads
|
[Release]Metin2 Neue Ladebild/Login/Charaauswahl[Release]
12/21/2012 - Metin2 PServer Guides & Strategies - 57 Replies
Moin Alle zusammen
erstmal muss ich euch erst sagen das ich ein anfänger bin bei sachen
Designen usw. deswegen bitte ich darum das keine von euch gleich mit
müll oder so kommt, jeder hat mal neu angefangen :).
Ich habe bis jetzt nur einen Ladebild aber werde mehrere machen
kommt aber drauf an wie es euch gefählt :), kann auch für die
jenigen denn namen von Server reinschreiben, denn das was ich habe
ist nur Test. es werden welche es gebrauchen :)
|
All times are GMT +2. The time now is 09:39.
|
|