This is what I have come up with so far.
Let me know what you think... not tried it yet..
- Code: Select all
item = {} -- make a table to hold the meshfiles
dropchance = 15; -- drop chance is 15
dropnumber = 0; -- Initialize rest of the variables
itemtospawn = 0;
x = 0;
y = 0;
z = 0;
-- ** drop on enemy death, this is to go inside the KO function of your AI script **
item[0] = "ammo.mesh";
item[1] = "firstaid02.mesh";
x,y,z = entity.getPosition( obj );
dropnumber = math.random(1,100)
if dropnumber < dropchance then
itemtospawn = math.random(0,1)
entity.spawn(item[itemtospawn],x,y,z,0.01,0.01,0.01);
end
entity.delete( obj );
The last one entity.delete is to delete the dead enemy from the scene so you can see the drop better.