Sign in to follow this  
Friya

[Released] Server mod; Loot Tables

Recommended Posts

This is one I wrote ... earlier. It gives you the ability to assign loot to individual (or very specific sets of) creatures. Nothing truly special, really. It's been running on a live server for a good while, although with rather simple loot rules. But is stable.

 

I apologize for the indentation in the file quoted below.

 

-- ****************************************************************************
-- ***                                                                      ***
-- ***                         What is this?                                ***
-- ***                                                                      ***
-- ****************************************************************************
--
-- This file is an example on how to create loot rules and loot tables that 
-- define what NPC's should drop, using just the database. This is handy if 
-- you are not into programming (or modding Wurm).
--
-- You can actually paste this entire file into your favorite SQLite database 
-- administration tool. You can of course just edit your database manually 
-- too, but at the very least, you probably want to examine the examples 
-- below to get a bit of a grasp.
--
-- The database you want to work with is in your World's sqlite folder: 
-- modsupport.db, after having installed this mod and started the server 
-- once, the tables will have been created in there.
--
-- Now, if you want to get your hands dirty or ...
-- If you want to go near code, you can just use the API from your own
-- mods. If you go this route you will probably be interested in the
-- LootResult object as that will enable you to create rule-based quest 
-- triggers.
-- 
--                                 -- Friya, 2016-2017, Discord: Friya#7934
--
-- ****************************************************************************
-- ***                                                                      ***
-- ***                        Explain yourself...                           ***
-- ***                                                                      ***
-- ****************************************************************************
-- You want NPC's to drop loot. But you want to be able to specify who drops
-- what and when.
--
-- So we have:
-- []  A loot-rule, this says what criteria an NPC has to fulfill to qualify,
--     it also enforces a maximum number of items this creature can drop.
--
-- []  A loot-table, this is simply put just a collection of items that a
--     rule will yield. Say, a 25% chance that a knife or a fork will drop
--     when this venerable wolf on the mountain top dies.
-- 
-- []  A loot-item, this is a "template" to create Wurm items, it specifies
--     what quality, if it has a chance to be rare, how damaged the item is,
--     etc, etc. In addition to this, it is also the place that decides how
--     big chance the item has to drop (i.e. it has a chance to drop 25%
--     of the times this rule was triggered; that is, creature died.
--
-- []  A loot-set is more an abstract 'thing', but it is a collection of 
--     loot-rules/tables. That is, any creature that die may qualify for 
--     many loot-rules and this could yield many different loot-tables. For 
--     instance, you may have a loot-rule for creatures that die in the 
--     night and another one for creatures that die in the winter -- these 
--     two will overlap and at the right time, both loot-tables are valid 
--     and at other times none. This is a loot-set; a collection of rules
--     and tables.
--
-- Loot rules can be modified and added while server is running. Adding new 
-- loot-tables and loot-items require a server restart.
--
-- Multiple loot-rules can match a kill, all items in all loot-tables will 
-- then be rolled between.
-- 
-- You can specify a maximum number of items a loot-rule should be able to 
-- give, if many loot-rules match this kill, the LOWEST max number of 
-- items will be picked (so we will err on the cheap side, so to speak).
--
-- If an item has 100% drop-chance, it will always drop from the NPC even
-- if it would exceed the maximum number of items it can drop. So you 
-- probably want to keep too broad 100% drops at a minimum or you may 
-- rarely see random items drop. There is really little reason to create
-- 100% drop-chance of something for all creatures in the game, though.
--

-- ****************************************************************************
-- ***                                                                      ***
-- *** 1. Create a loot-table                                               ***
-- ***                                                                      ***
-- ***      Let's create a loot-table (ID 1) that has two items in it       ***
-- ***                                                                      ***
-- ****************************************************************************
INSERT INTO FriyaLootTables(tableid, lootid) VALUES(1, 258);		-- this is a 'knife'
INSERT INTO FriyaLootTables(tableid, lootid) VALUES(1, 259);		-- this is a 'fork'

-- NOTE: The 'lootid' above will not always correspond to a 'wurm template id' 
-- since you are able create your own items and configurations of them.
--
-- However, for convenience, all available items in Wurm were imported
-- with somewhat sane configurations when you first started up the LootSystem.
-- All these template IDs correspond to the actual Wurm template ID. Nice eh?


-- ****************************************************************************
-- ***                                                                      ***
-- *** 2. The rule for dropping the knife and fork                          ***
-- ***                                                                      ***
-- ***   Let's specify which NPCs should drop the loot in our loot-table    ***
-- ***                                                                      ***
-- ****************************************************************************
INSERT INTO FriyaLootRules
	(loottable, creature) VALUES
	(
		1,				-- For this rule, use the loot-table we created above
		'goblin'		-- Goblins, they should drop knife and fork
	);
INSERT INTO FriyaLootRules
	(loottable, rulename, age) VALUES
	(
		1,				-- For this rule, use the loot-table we created above
		'Example 2',	-- Just a name we can identify with, not mandatory
		'venerable'		-- All venerable creatures should drop knife and fork
	);


-- ****************************************************************************
-- ***                                                                      ***
-- ***                      ...well, that was dull!                         ***
-- ***                                                                      ***
-- *** 3. More exciting rules                                               ***
-- ***                                                                      ***
-- ***             Now some more, eh, exciting (?) loot rules...            ***
-- ***                                                                      ***
-- ****************************************************************************
--
-- Ever wanted to make really specific creatures always drop something? Well, me 
-- neither ... but I could for instance say:
--
-- Elderly female champion wolves killed on the snowy mountain tops on them cold 
-- winter nights when the wind is coming in hard from the north.
--
-- ...they should drop a knife and a fork.
--
-- So:
--
INSERT INTO FriyaLootRules
	(
	 loottable, rulename, creature, age, type, gender, starthour, endhour, 
	 minaltitude, season, windstrength, winddirection, tiletype
	)
	VALUES(
		1,									-- The loot-table we want to use (we created loot-table 1 above)
		"Wolf killing on chilly nights",	-- A name of the rule that we can identify with
		"wolf",								-- creature type
		"venerable",						-- age
		"champion",							-- type
		1,									-- gender: 1 = female
		22,									-- start-hour: 10 PM
		05,									-- end-hour: 5 AM
		5000,								-- minimum altitude
		"winter",							-- season
		"gale",								-- wind strength
		"north",							-- wind direction
		30									-- tiletype; snow
	);


-- ****************************************************************************
-- ***                                                                      ***
-- *** 4. Custom items                                                      ***
-- ***                                                                      ***
-- ***  NOTE: A "loot ID" is NOT the same as a "Wurm template ID",          ***
-- ***        as a convenience, I have just chosen to import all Wurm       ***
-- ***        templates when you first installed the LootSystem.            ***
-- ***                                                                      ***
-- ***  We can add our own specific items to loot-tables, custom items      *** 
-- ***  or items with special configurations. This is done below.           ***
-- ***                                                                      ***
-- ****************************************************************************
-- This is a custom item called ancient amulet in my case, 1% drop-chance.
INSERT INTO FriyaLootItems
	(id, itemids, dropchance) VALUES(
		100001,					-- the LOOT id of this item
		'22763',				-- the actual Wurm ID of the item
		1						-- 1% drop chance
	);

-- Let's create a new loot-table for this amulet
INSERT INTO FriyaLootTables
	(tableid, lootid) VALUES
	(
		2,						-- loot-table 2
		100001					-- the id of the amulet we added to loot-items
	);

-- ... we could add more items to LootTable 2 here...


-- Let's create a rule that makes this item drop from EVERY NPC in the game
-- but of course, at a 1% chance.
INSERT INTO FriyaLootRules
	(loottable, rulename) VALUES
	(
		2,				-- For this rule, use the loot-table we created above
		'Ancient Amulet Global drop'
						-- Note the complete lack of ANY rules. This means
						-- every NPC in the game will be able to drop the
						-- items specified by this loot-table.
	);

/*
-- ****************************************************************************
-- ***                                                                      ***
-- *** 5. The options of rules                                              ***
-- ***                                                                      ***
-- *** A lot is possible, below are all the options to customize loot rules ***
-- ***                                                                      ***
-- ****************************************************************************

	rulename			Just a rule name so you can easily identify it
	loottable			point to a loot-table which then should link to items
	
	maxloot				-1 = no limit, otherwise number of items a creature can drop max	
	
	creature			* for any NPC, or e.g. 'goblin'
	age					* for any, or e.g. 'venerable'
	type				* for any, or e.g. 'champion'
	
	gender				-1 = any, 0 = male, 1 = female
	wild				-1 = any, 0 = must be bred in captivity, 1 = must be wild
	
	surface				-1 = any, 1 = surface, 2 = cave
	kingdom				is in land of: -1 = any, 1 = JK, 2 = MR, 3 = HOTS, 4 = Freedom
	tiletype			-1 = any, for specific see com.wurmonline.mesh.Tiles.TILE_*
	zonename			* = any, enter zone name for specific
	
	starthour			-1 = any, e.g. 00 = midnight
	endhour				-1 = any, 23 = 11pm
	
	minaltitude			-1 = any, 0+ = above water
	maxaltitude			-1 = any, e.g. 1000 = 1k dirt above sea
	
	fat					* for any, or starving or fat
	diseased			-1 = any, or 0 = not diseased, 1 = diseased
	
	isunique			-1 any, 0 = no, 1 = yes (this is a shortcut so you don't have to specify each unique in the game)
	isfromkingdom		is member of: -1 any, , 1 = JK, 2 = MR, 3 = HOTS, 4 = Freedom
	ishumanoid			-1 any, 0 = no, 1 = yes
	iszombie			-1 any, 0 = no, 1 = yes
	isfromrift			-1 any, 0 = no, 1 = yes
	
	minslope			-1 = any, or any number that describes min. slope (e.g. 40)
	maxslope			-1 = any, or any number that describes max. slope (e.g. 100)
	
	minxpos				-1 any, or a start coordinate. Say, you only want creatures living at the center of the map.
	minypos				see above
	maxxpos				-1 any, or an end coordinate
	maxypos				see above
	
	weather				* for any or 'precipitation' (snow/rain), 'clear' (sun), 'fog' or 'overcast' (cloudy)
	windstrength		* for any or gale, strong wind, strong breeze, breeze, light breeze
	winddirection		* for any or north, northwest, west, southwest, south, southeast, east, northeast
	season				* for any, spring, summer, autumn or winter
	
	deityinfluence		* for any, vynora, fo, ...
	neardeed			-1 any, 0 = must not be near deed, 1 = must be near deed
	neartower			-1 any, 0 = must not be near tower, 1 = must be near tower
*/

/*
-- ****************************************************************************
-- ***                                                                      ***
-- *** 6. The options for items (subject to further additions)              ***
-- ***                                                                      ***
-- ****************************************************************************

	int lootId;
	int[] wurmItemIds;			-- each loot-item can actually be many wurm-items (to save repetition)
	String name;
	byte material;
	float startQl;
	float endQl;
	boolean canBeRare;
	float dropChance;
	String creator;
	int auxData;
	long decayTime;
	float damage;

	String customMethod;		-- for callback when the item gets triggered
	String customArgument;

	int cloneCount;				-- number of clones/copies that should be created
	int cloneCountRandom;		-- randomness to the above

	String enchants;			-- enchants to be applied to the item
	int enchantStrength;		-- the strength of the enchants
	int enchantStrengthRandom;	-- how much randomness should be applied to the enchant strength

*/

/*
-- ****************************************************************************
-- ***                                                                      ***
-- *** 7. Enchants                                                          ***
-- ***                                                                      ***
-- ****************************************************************************
--
-- set 'enchants' to e.g: "coc woa nimb ms fosdemise" and Circle of Cunning,
-- Wind of Ages, Nimbleness, Mind Stealer and Fo's Demise will be applied to 
-- the item.
--
-- Set 'enchantstrength' to 10 and all enchants will have that strength.
-- Set 'enchantstrengthrandom' to 90 and all enchants will have a random 
-- strength between 10 and 100.
--
-- Abbreviations of enchants:
--
-- Enchants with strength
-- **********************
-- aosp          Aura of shared pain
-- botd          Blessing of the Dark
-- bt            Bloodthirst
-- coc           Circle of Cunning
-- courier       Courier
-- dm            Dark messenger
-- fa            Flaming aura
-- fb            Frostbrand
-- lt            Life Transfer
-- litdark       Lurker in the Dark
-- litdeep       Lurker in the Deep
-- litwoods      Lurker in the Woods
-- ms            Mind stealer
-- nimb          Nimbleness
-- nolo          Nolocate
-- opulence      Opulence
-- rt            Rotting Touch
-- venom         Venom
-- wa            Web Armour
-- woa           Wind of Ages
--
-- Boolean enchants
-- ****************
-- animalsdemise
-- dragonsdemise 
-- humansdemise 
-- selfhealersdemise
--
-- fosdemise
-- libilasdemise
-- vynorasdemise
-- magranonssdemise
--
-- foscounter
-- libilascounter
-- vynorascounter
-- magranonscounter
--


/*
-- ****************************************************************************
-- ***                                                                      ***
-- *** 8. Some queries (or a query for now) that might be handy...          ***
-- ***                                                                      ***
-- ****************************************************************************

-- Query to see which rule will yield which loot-table and which items 
SELECT lr.id AS LootRuleID, lr.rulename AS LootRuleName, lt.tableid AS LootTableID, lt.lootid AS LootItemID, li.itemids AS LootItemItems
	FROM FriyaLootRules AS lr
	INNER JOIN FriyaLootTables AS lt ON (lr.loottable = lt.tableid)
	INNER JOIN FriyaLootItems AS li ON (lt.lootid = li.id);
*/

 

That was for adding rules using the database. If you are fine with touching code, creating loot rules and loot tables from your own mods is easy:

 

// 
// Mostly everything should make sense once you have added the JAR to your project.
// 
// This is an example on how I have one of my other projects use Loot Tables.
//
// (log statements and comments were added to make it easier for you to test and debug)
// 
//               -- Friya
// 

// You want to implement BeforeDropListener, after that your IDE should give you some hints.
public class CreatureLoot implements BeforeDropListener
{
	private static Logger logger = Logger.getLogger(CreatureLoot.class.getName());
	private static CreatureLoot instance;
	static String ancientAmuletRuleName = "[all NPCs] mod:vamps, Ancient Amulet";

	CreatureLoot()
	{
	}
	
	public static CreatureLoot getInstance()
	{
		if(instance == null) {
			instance = new CreatureLoot();
		}

		return instance; 
	}

	
	@Override
	public boolean onBeforeDrop(LootResult lootResult)
	{
		logger.log(Level.INFO, "We were notified about something dying!");
		
		logger.log(Level.INFO, "ancientAmuletRuleName triggered: " + lootResult.hasLootRule(ancientAmuletRuleName));
		logger.log(Level.INFO, "Killers: " + Arrays.toString(lootResult.getKillers()));
		logger.log(Level.INFO, "Rules: " + lootResult.getLootRules());
		logger.log(Level.INFO, "Items: " + Arrays.toString(lootResult.getItems()));

		// The lootResult contains everything you would need, including:
		// - who killed the NPC
		// - which rules were triggered (handy to create quests)
		// - which items are about to drop
		// - etc, etc.
		
		// Returning false will discard any items that would otherwise drop.
		return true;
	}


	public static void onServerStarted() 
	{
		createLootRules();

		// Set up a onBeforeDropListener so that we get notifications when something might drop.
		LootSystem.getInstance().listen((BeforeDropListener)getInstance());
	}

	static void createLootRules() 
	{
		LootSystem ls = LootSystem.getInstance();
		
		if(ls.hasLootRule(ancientAmuletRuleName) == false) {
			// This rule says: Every NPC has the chance to drop the contents from this loot-table.

			logger.log(Level.INFO, "Adding loot rule: " + ancientAmuletRuleName);

			LootRule lr = new LootRule(ancientAmuletRuleName);

			// The item(s) in question is/are:
			// We treat Wurm's item IDs as strings so that we can support multiple IDs per SQL statement (for those who don't go near code)
			LootItem[] li = new LootItem[]{
			
				// NOTE: You probably do not have any ancient amulet on your server, so the "Amulet.getId()"
				// 		 will fail. Replace it with a template ID of your own, or one from Wurm proper.

				// We specify some attributes of the item, the rest are defaults.
				new LootItem("" + Amulet.getId(), Item.MATERIAL_SERYLL, 2.0f, "Vampire Hunter D")
			};

			ls.addLootRule(lr, li);
		}

		// Just assign it a name so that you can easily identify it, can be anything.
		String ruleName = "[all NPCs] Rare stuff";
		
		if(ls.hasLootRule(ruleName) == false) {
			// Every NPC should have a small chance to drop these special items (these are 'safe', such as shoulders, etc)
			logger.log(Level.INFO, "Adding loot rule: " + ruleName);

			LootRule lr = new LootRule(ruleName);

			// We treat Wurm's item IDs as strings so that we can support multiple IDs per SQL statement.
			// This makes for less than optimal database design, but it is to make lives easier for those 
			// who don't want to go near code and just perform changes using SQL (perhaps even SQL given
			// to them by others). Sharing is caring!
			LootItem[] li = new LootItem[] {
				new LootItem(
					"370,443,465,489,509,515,600,666,667,"
				  + "668,700,738,781,834,844,867,967,972," 
				  + "973,974,975,976,977,978,979,980,1014,"
				  + "1015,1032,1049,1050,1051,1052,1053,1054,
				  + "1055,1056,1057,1058,1059,"
				  + "1060,1061,1062,1063,1064,1065,1066,1076,"
				  + "1077,1078,1079,1080,1081,1082,1083,1084," 
				  + "1085,1086,1087,1088,1089,"
				  + "1090,1092,1093,1094,1095,1099",
					(1.0/102.0)		// This (1.0%) is per item, so divide with number of items in the collection (I kept the division of 102 despite removing items from list -- which means the drop chance for any of these is less than 1% as it stands)
				)
			};

			ls.addLootRule(lr, li);
		}
	}
}


A small note: By setting createDefaultRules to true in the configuration, you will get a default loot rule that will enable a global[1] drop of some rare but by default unobtainable items (such as shoulders etc). By default this rule is a bit less than 1% chance for that entire table (the chance per item is a lot less). You can change that rule in your database, of course. If you don't want the rule, you can simply set createDefaultRules to false and delete it in the database.

 

 

Download here:

http://www.filterbubbles.com/wurm-unlimited/loottables.zip

 

[1] Global here means all "livings" within constraints set by configuration and that at least one *player* was involved in the kill.

 

Edited by Friya
  • Like 4

Share this post


Link to post
Share on other sites

omg this sounds soooo awesome

 

this means, i could make a lot of different rules and can switch between or enable more than one rule for some events?

 

Eject

 

add:

-- Loot rules can be modified and added while server is running.

how can you do this?

Edited by Eject

Share this post


Link to post
Share on other sites

Looks pretty awesome. Kind of like something I have being doing on a GM manually haha. I will definitely be checking this out soon!

Share this post


Link to post
Share on other sites
-- Loot rules can be modified and added while server is running.

how can you do this?

 

You mean by using Java or by using database? I'll assume database:

 

Provided you have a loot table with items already.

 

Then as an example:

- open modsupport.db in your favorite SQLite editor
- run: insert into friyalootrules(rulename, loottable, creature, maxaltitude) values("Lowland Nogump Slaying", <<loot-table-id>>, "son of nogump", 200);
- write changes / save

 

If a Nogump is killed and they're below 200 dirt altitude, they will now use the loot rule/ you just created.
Replace <<loot-table-id>> with the ID of the loot table containing the items you want the Nogump to drop.

 

That's it.

 

Edited by Friya

Share this post


Link to post
Share on other sites

Some hints, tips and technicalities:

 

[] The LootTables mod will only *read* from the database after server was started.

 

[] Changing rules 'runtime' is only practical if mods don't use modsupport.db to write data while server is running. As far as I know, no public ones do. If it turns out that modsupport is very much read/write at some point down the line, I'll probably just move the data to a separate SQLite database.

 

[] I do *not* load loot-rules into memory when server starts, this to allow for rule modification when server is running. Provided you don't have thousands of loot rules this will have no negative effect on your server.

 

[] I load loot table and item contents into memory when you start your server (for performance reasons). This is why loot tables and items must exist when server starts. You can still add tables/items when server is running, but they will not go into effect until after restart. I have considered adding a 'reload loot tables' action in the past, but never had the need so never got around to it.

 

[] If in doubt what the performance hit is on your server, enable logging of costs in the configuration.

 

[] There are no foreign key constraints; if your rule points to a loot table that does not exist you will not get any warnings, so make sure you have your IDs correct when you do your inserts :)

 

[] I consider the mod largely done until I run into something I need, but will fix bugs.

 

[] If you are testing loot rules as GM, remember to set yourself vulnerable or your kills will not trigger any loot drop.

 

[] A tip to insert new loot tables, use "select max", e.g.: insert into friyaloottables values((select max(tableid)+1 from friyaloottables), 694);

 

[] Clarification of the above insert: This will create a loot table using the next available LootTable ID. I know for instance that 694 is an adamantine lump (both in LootItems table and in Wurm). If you did not change it after installing the mod it should have been imported with a 25% drop chance.

 

[] Set sqlLogging to true in the configuration will make it easier to test your loot rules as the queries will be output in your server log. Note, though, that this can have a mild negative impact on performance of your server.

 

Edited by Friya
  • Like 2

Share this post


Link to post
Share on other sites

The distributed jar above was updated just now.

 

Changes:
- added sqlLogging flag to configuration
- fixed a bug where altitude (cough) was not properly checked

 

  • Like 2

Share this post


Link to post
Share on other sites

i havent known that the server reading the database again i thought its reading one time at start and store in any temp file =)

but if is so as you said (adding rules directly in the db while running server) than this is realy awesome 

i will test it this weekend and i am very courius about this mod ^^

 

thank you very much

Share this post


Link to post
Share on other sites
Quote

this means, i could make a lot of different rules and can switch between or enable more than one rule for some events?

 

Forgot to reply to this one.

 

Yes, that is correct.

 

Our primary use is static loot rules like a specific loot table for 'all NPCs', and another for say, 'trolls' or uniques. We also have several mods that depend on this one to add our own custom items to NPCs (as opposed to have every mod do their own handout of loot, which can cause all kinds of nastiness and imbalances).

 

But yes, switching in and out rules is the idea :)

Edited by Friya

Share this post


Link to post
Share on other sites

"But yes, switching in and out rules is the idea"

 

with deleting database entrys while server is running? or overwrite entrys?

sorry for my noob questions :)

 

Another one is, my server is hosted, i have to download the db add the rule and overwrite the file at the server, would this bring problems if the server is running?

 

Eject

Edited by Eject

Share this post


Link to post
Share on other sites

now i run the testserver with your mod, but there are no tables created in the db

can i find anywhere a sql to create the tables?

 

Eject

Share this post


Link to post
Share on other sites
8 hours ago, Eject said:

with deleting database entrys while server is running? or overwrite entrys?

 

The rules table you can change any which way. Delete, create or update.

 

Quote

Another one is, my server is hosted, i have to download the db add the rule and overwrite the file at the server, would this bring problems if the server is running?

 

I have never tried. Let me know if it works, though!

 

Quote

now i run the testserver with your mod, but there are no tables created in the db

can i find anywhere a sql to create the tables?

 

The tables should be created automatically, but taking a quick glance at the code (it's been a while since I wrote this), I suppose there could be a case where they don't get created if you don't create the default rule (at least once).

 

Try setting deleteAllRules or createDefaultRules to true if neither of them are.

 

Other than that, if the mod is properly installed (and the configuration flag 'enabled' is set to true, of course), it should just do its thing.

 

Edited by Friya

Share this post


Link to post
Share on other sites

i have some messages in the log log like: sqliite does not support setting the schema, schema not changed

 

i tried to start with the default rules but again no tables created in the db file :/

 

Eject

Share this post


Link to post
Share on other sites

now i remember, as i installed the local server new yesterday, for ever reason there was no moddsupport.db, i copyied this db from my hosted server to the local server.

maybe anywhere here is the problem.

 

 

Eject

Share this post


Link to post
Share on other sites

Early on in your log you should have:
 

INFO com.friya.wurmonline.server.loot.Mod: Loaded LootTable configuration


Three tables are created when you first install LootTables, so if you have logging set to INFO or finer, on your first run you should see:

INFO com.friya.wurmonline.server.loot.LootSystem: Created FriyaLootRules
INFO com.friya.wurmonline.server.loot.LootSystem: Created FriyaLootTables
INFO com.friya.wurmonline.server.loot.LootSystem: Created FriyaLootItems

...the followed by a lot of statements like this:
INFO com.friya.wurmonline.server.loot.LootSystem: Importing: 1296, // 'lunchbox'
INFO com.friya.wurmonline.server.loot.LootSystem: Executing: INSERT INTO FriyaLootItems(id, itemids, name, material, startql, endql, canberare, dropchance, creator, decaytime, damage) VALUES(1296,'1296','lunchbox',-1,10.0,60.0,1,25.0,'Secret Santa',172800,90.0)

 

These three tables are created in sqlite/modsupport.db. If tables (and data) was already created you will only see that it loaded configuration (the first line).

 

I just verified that it works (I dropped all tables and they were correctly recreated), this was with Ago's loader v0.24. Make sure the mod is correctly installed by checking the log for anything like the log statements above.

 

If you copy files over with FTP or so, it might be a permission problem. Make sure that Wurm can write to the file. But I'd imagine you'd have a lot of crying in your server log if that was the case.

 

Share this post


Link to post
Share on other sites

Hello Friya

 

I believe i had an error at my local testserver, i reinstalled all new and now the database is configured and i can play with your nice mod =)

thats cool because today is starting my holiday ^^

 

Eject

Edited by Eject

Share this post


Link to post
Share on other sites

It works =)))

 

yeahhhh this is sooooo coooooool

 

now making some tables for different events

Share this post


Link to post
Share on other sites

i added 20 copper coins to the db, (100% chance for drop for testing) but the mobs dont drop that

do you know what i was doing wrong?

 

"100002"    "58"    "58"    "coinCopperTwenty"    "-1"    "10.0"    "40.0"    "1"    "100.0"    "Secret Santa"        "172800"    "0.0"    

 

edit: Works now after serverrestart    

Edited by Eject

Share this post


Link to post
Share on other sites

it works that hens drop a egg, but they should drop 1-3, i get always just one ^^

 

"5"    "5"    "Egging"    "3"    "3"    "*"    "*"    "*"    "-1"    "1"    "-1"    "-1"    "-1"    "*"    "-1"    "-1"    "-1"    "-1"    "*"    "-1"    "-1"    "-1"    "-1"    "-1"    "-1"    "-1"    "-1"    "-1"    "-1"    "-1"    "-1"    "*"    "*"    "*"    "*"    "*"    "-1"    "-1"

 

loottable is 3 which is the egg (chance 100% from the itemlist)

maxloot is 3, i tested now with round 50 hens and always get one egg

 

have you an idea where i am wrong with the settings?

 

Eject

Edited by Eject

Share this post


Link to post
Share on other sites

Glad you got it working!

 

Ah, maxLoot is there to cap the number of items an NPC *may* drop when it dies.

 

This is so that various mods and rules can work together and if one feels "oh dear, this is such a powerful item, nothing else should drop here".

 

Edited by Friya

Share this post


Link to post
Share on other sites

so i have to copie the table/rules? or how i can set that the npc drop 1-3 eggs?

 

Eject

Share this post


Link to post
Share on other sites

I actually have not had a reason to drop multiple clones of the same item. But I think I will add that functionality, actually.

 

Until then, you'd need multiple rules items, yep!

 

Edit: Sorry, I re-read what nonsense I spat out now, you don't need multiple rules, you need multiple items. But I will add a patch for this and add a new column for it in the LootItems table.

Edited by Friya
  • Like 1

Share this post


Link to post
Share on other sites

a lttle question...

can you expand the mod like.....if mission id 1023 is finished the rule id 5 will start?

 

Eject

Edited by Eject

Share this post


Link to post
Share on other sites
30 minutes ago, Eject said:

a lttle question...

can you expand the mod like.....if mission id 1023 is finished the rule id 5 will start?

 

Eject

 

This would be very easy to do with a few lines of code using the API from another mod (see first post). I feel that doing that kind of logic in the database is beyond the scope of this mod since it will place a requirement at the "slayer" instead of the "slain".

 

Sorry :)

  • Like 1

Share this post


Link to post
Share on other sites

I had a bit of spare time to look at this on this lovely Sunday.

 

NOTE: This patch will perform changes to the database, it will automatically migrate the first time you start your server. But you will have to start your server at least once before you can use the added features.


 

Changes to item customization in database

[ ] added ability to set how many clones/copies (can be random) should drop
[ ] ability to enchant loot items before they drop

That is, in addition to what was already in place: ql, rarity, creator, auxdata, decay, damage, etc. Of course, if you hook in with your own mod, you can do whatever you want with the items in onBeforeDrop().

 

You can test both of these new features with the following inserts into your database

--
-- Start with inserting an item, this is a huge axe which we say should 
-- be ID 100000 (to stay clear of any already imported items). We say that
-- it will be a QL between 10 and 90 and should drop at least once, with
-- an additional 4 randomness (so drop between 1 and 5 huge axes). Then
-- we say they should all be enchanted with coc/woa/nimb/ms/shd of a strength
-- of 10, and add 94 randomness on top of that (which means enchant strength of
-- between 10 and 104).
--
INSERT INTO FriyaLootItems(id, itemids, name, material, startql, endql, 
                           canberare, dropchance, creator, decaytime, 
                           damage, clonecount, clonecountrandom, enchants,
                           enchantstrength, enchantstrengthrandom)
	VALUES(
		100000,
		'87', 'enchanted huge axe', -1, 10.0, 90.0, 1, 100.0, 'Zenath', 172800, 0.0, 
		1, 4,
		'coc woa nimb ms selfhealersdemise', 10, 94
	);

--
-- Now we create a new loottable for the item above (ID 100000)
--
INSERT INTO friyaloottables values((select max(tableid)+1 from friyaloottables), 100000); 

--
-- And now we say that ALL Nogumps should have a chance to drop these huge axes.
--
INSERT INTO friyalootrules(rulename, loottable, creature)
	values("Huge Axe of Nogump", (select max(tableid) from friyaloottables), "son of nogump");

 

Elaboration on enchants:

[ ] Set 'enchants' column to e.g: "coc woa nimb ms fosdemise" and Circle of Cunning, Wind of Ages, Nimbleness, Mind Stealer and Fo's Demise will be applied to the item.

[ ] Set 'enchantstrength' to 10 and all enchants will have that strength.
[ ] Given strength is set to 10, set 'enchantstrengthrandom' to 90 and all enchants will have a random strength between 10 and 100.

 

Abbreviations of enchants


Enchants with strength

    - aosp          Aura of shared pain
    - botd          Blessing of the Dark
    - bt            Bloodthirst
    - coc           Circle of Cunning
    - courier       Courier
    - dm            Dark messenger
    - fa            Flaming aura
    - fb            Frostbrand
    - lt            Life Transfer
    - litdark       Lurker in the Dark
    - litdeep       Lurker in the Deep
    - litwoods      Lurker in the Woods
    - ms            Mind stealer
    - nimb          Nimbleness
    - nolo          Nolocate
    - opulence      Opulence
    - rt            Rotting Touch
    - venom         Venom
    - wa            Web Armour
    - woa           Wind of Ages

Boolean enchants (strength is ignored)

    - animalsdemise
    - dragonsdemise
    - humansdemise
    - selfhealersdemise

    - fosdemise
    - libilasdemise
    - vynorasdemise
    - magranonssdemise

    - foscounter
    - libilascounter
    - vynorascounter
    - magranonscounter

 

The original post's download link was updated with latest version.

 

Note:
If you have non-standard spells on your server or want to add runes or imbues, you can also put in the ID of the spell in 'enchants'.

Edited by Friya
  • Like 1

Share this post


Link to post
Share on other sites

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
Sign in to follow this