Hello all! : )
I made this Lua+SQL code because it is much easier in the editing of C++ when someone don't know c++ (like me). Easy system - easy addons. : ) Everybody who know base of Lua can make addons to this system (like loot effect's, items special options). Furthermore you can loot now runes, potions etc.
And items drop rate is set in percent like (50% chance for drop item)
Script made by creaturescripts (Lua) and ots database (new table, SQL).
for the proper operation of the script should be clear Loot from monsters (in the XML scripts)
in data/creaturescripts/scripts/login.lua add:
under:
add:
now in data/creaturescripts/creaturescripts.xml
under:
add:
and last code which you must add is in:
data/creaturescripts/scripts make lootsystem.lua
and paste this code:
now only import it in phpmyadmin to ots database:
RapidShare: Easy Filehosting <-- its database of items loot.
and replace your old monster with this without loot set in xml (base 0.3b2 monsters without loot)
RapidShare: Easy Filehosting
and it's all! ; )
azi.
I made this Lua+SQL code because it is much easier in the editing of C++ when someone don't know c++ (like me). Easy system - easy addons. : ) Everybody who know base of Lua can make addons to this system (like loot effect's, items special options). Furthermore you can loot now runes, potions etc.
And items drop rate is set in percent like (50% chance for drop item)
Script made by creaturescripts (Lua) and ots database (new table, SQL).
for the proper operation of the script should be clear Loot from monsters (in the XML scripts)
in data/creaturescripts/scripts/login.lua add:
under:
PHP:
function onLogin(cid)
PHP:
registerCreatureEvent(cid, "MonsterLoot")
under:
PHP:
<creaturescripts>
PHP:
<event type="kill" name="MonsterLoot" script="lootsystem.lua"/>
data/creaturescripts/scripts make lootsystem.lua
and paste this code:
PHP:
function getLoot(monstername)
local loocik = {}
local loot = db.getResult("SELECT * FROM `monsters_loot` WHERE `monster_name`='" .. monstername .. "';")
if loot:getID() ~= -1 then
while(true) do
table.insert(loocik, {loot:getDataInt("item_id"), loot:getDataInt("item_count"), loot:getDataInt("drop_percent"), loot:getDataInt("in_container")})
if not(loot:next())then
break
end
end
loot:free()
else
print("No loot in database for: "..monstername.."!")
end
return loocik
end
function addLoot(x)
pos = x["pos"]
for i=0,255 do
pos.stackpos = 255-i
gpos = getThingfromPos(pos)
if isCorpse(gpos.uid) == 1 then
corp = 255-i
end
end
pos.stackpos = corp
corpse = getThingfromPos(pos)
local container = 0
for i=1,#x.loot do
if x.loot[i][3] >= math.random(1,100) then
if x.loot[i][4] == 0 or container == nil then
local la = doAddContainerItem(corpse.uid, x.loot[i][1], math.random(1, x.loot[i][2]))
if isContainer(la) then
container = la
end
elseif x.loot[i][4] == 1 and container ~= nil then
doAddContainerItem(container, x.loot[i][1], math.random(1, x.loot[i][2]))
end
end
end
end
function onKill(cid, target)
if isMonster(target) then
local pos = getCreaturePosition(target)
local monsterloot = getLoot(getCreatureName(target))
x = {
["pos"] = pos,
["loot"] = monsterloot
}
addEvent(addLoot, 1, x)
end
return TRUE
end
now only import it in phpmyadmin to ots database:
RapidShare: Easy Filehosting <-- its database of items loot.
and replace your old monster with this without loot set in xml (base 0.3b2 monsters without loot)
RapidShare: Easy Filehosting
and it's all! ; )
azi.