Server Mod: Loot While Crafting Mini Game!

tatwi

Member
Joined
May 31, 2012
Messages
66
Updated Download Link 2016.06.08

This server side mod is a mini game that aims to reward those who enjoy the crafting process with a chance to win some loot. I created this mod with my Legends of Hondo single player server in mind, where the only source of Skill Enhancing Attachments is what you happen personally loot - slow going to say the least!

The mod consists of c++ changes to one file and has two optional files that you can use if you'd like.

Purpose:
- To add a fun way for non-combat type players to earn useful loot.
- To act as another "resource sink" that encourages folks to use up their stock piles.

What it Does:
- Adds a chance to get a piece of loot when using the Practice Mode option while crafting.
- There are 6 teirs of success,

1. You rolled successfully, but the item you crafted didn't have any quality stats (could not be experimented upon) so you don't win a prize.
2. You rolled successfully, but the quality of the item and/or your skill was not high enough to win a prize.
3. You won a piece of Junk Loot (on a LoH server this includes the chance to win an SEA of level 10 out of 300).
4. You won a piece of Junk Loot (on a LoH server this includes the chance to win an SEA of level 50 out of 300).
5. You won an Armor Attachment! (level 100 out of 300)
6. You won a Clothing Attachment! (level 150 out of 300)

- In my testing creating MANY SEAs, the highest number I got using level 150 was 16. Pretty great, but super uber either.

- Keep in mind that the loot groups used are entirely optional and you can set them to whatever you'd like. In fact, you could even go ahead and create brand new loot groups just for this mini game if you'd like!

How it Works:
- The basic idea here is that when you hit the [Practice] button, the game determines:
1. If you've won a piece of loot, based up on the complexity of the final item, your crafting tool quality, and your related assembly skill mod.
2. The prize you've won, based upon the complexity of the final item, the highest experimentation percentage, and your related assembly skill mod.
- Keep in mind that no matter how great you are, you'll only ever have about a 50/50 chance to win, at best. This can easily be adjusted "to taste" though.

The process rewards players who choose the most complex schematics, who use the best resources for the schematic, who use all their experimentation points to the best of their ability, and who have the highest related assembly skill (which is capped at 150 for this mini game).

Here is the logic portion of the code for anyone who wants to understand the process in detail and remove ALL the mystery from the game.  :D
Code:
// ===================
		// Legend of Hondo Customization
		// Roll for loot drop when in practice mode
		if (grantLootChance == 1){	
			ManagedReference<DraftSchematic*> draftSchematic = manufactureSchematic->getDraftSchematic();
			int itemComplexity = manufactureSchematic->getComplexity();
			int toolQuality = craftingTool->getEffectiveness();
			int assemblySkill = crafter->getSkillMod(draftSchematic->getAssemblySkill());
			if (assemblySkill > 150)
				assemblySkill = 150; // Cap Assembly Skill
			
			int playerRoll = (itemComplexity + toolQuality) + (assemblySkill / 2);
			int luckRoll = System::random(30);
			// Set the random goal to beat. Min is 61. Increase 300 to reduce likelihood of winning. 
			int successTarget = System::random(300) + 60; 
			
			// See if they won loot and take action if they did.
			if ((playerRoll + luckRoll) >= successTarget){				
				// Get the average quality of the crafted item, based up resources used and experimentation results, and times it by 1000.
				Reference<CraftingValues*> craftingValues = manufactureSchematic->getCraftingValues();
				int titleCount = craftingValues->getVisibleExperimentalPropertyTitleSize();
				if (titleCount <= 0)
					titleCount = 1; // Prevent divide by zero.
				float goodness = 0;
				float cvTemp = 0;
				for (int i = 0; i < titleCount; i++) {
					String title = craftingValues->getVisibleExperimentalPropertyTitle(i);
					cvTemp = craftingValues->getCurrentVisiblePercentage(title);
					if (cvTemp > goodness)
						goodness = cvTemp; // Use the highest  % experimentation line avchieved
				}

				// Determine the winnings. Higher numbers are harder to achieve.
				int lootGroupAchieved = (itemComplexity + luckRoll) * goodness * assemblySkill * 10;
				String lootGroup;
				int level = 0;
				
				if (lootGroupAchieved <= 0){
					// The item being crafted didn't have any quality stats
					crafter->sendSystemMessage("Sorry, but in order to win loot, you must craft items that can be experimented upon.");
				}
				else if (lootGroupAchieved <= 7499){
					// Resource quality or Assembly skill too low to win an prize
					crafter->sendSystemMessage("You pause for a moment and wonder what you could do with higher quality resources and more refined skill...");
				}
				else if (lootGroupAchieved >= 120000){
					// Clothing SEA
					lootGroup = "clothing_attachments";
					level = luckRoll + 100;
				}
				else if (lootGroupAchieved >= 90000){
					// Armor SEA (which includes crafting ones in Legend of Hondo)
					lootGroup = "armor_attachments";
					level = luckRoll + 50;
				}
				else if (lootGroupAchieved >= 30000){
					// Junk Loot with a chance for a mid level SEA
					lootGroup = "junk";
					level = luckRoll + 10;
				}
				else if (lootGroupAchieved >= 7500){
					// Junk Loot with a chance for a low level SEA
					lootGroup = "junk";
					level = 10;
				}
				
				// Send the winnings to the player
				ManagedReference<SceneObject*> inventory = crafter->getSlottedObject("inventory");
				if (level > 0 && inventory != NULL) {
					if (inventory->isContainerFull()) {
						crafter->sendSystemMessage("Inventory Full! You won a loot item, but it could not be created.");
					}
					else{
						Reference<LootManager*> lootManager = crafter->getZoneServer()->getLootManager();
						lootManager->createLoot(inventory, lootGroup, level);
						crafter->sendSystemMessage( "You have received a loot item!");
					}
				}
			}
		}
		// ===================

Files Included:

[Required]
required/src/server/zone/objects/player/sessions/crafting/CraftingSessionImplementation.cpp
- This is the source code required to make this mod work.

[Optional]
optional/src/server/zone/objects/player/sessions/crafting/WITH_VERBOSE_DEBUG_OUTPUT_CraftingSessionImplementation.cpp
- This is the same file as above, only I put in some handy output to the command line and one item to the chat box in game. You can use it instead if you'd like. It's nice for tuning the numbers to your liking or just seeing how close you were to winning!

optional/bin/scripts/loot/groups/junk.lua
- This file adds both types of Skill Enhancing Attachment types into the Junk Loot group.
- Level of the Mob looted is passed on to the SEA, so their quality is appropriate for the
 difficulty of the encounter.

optional/bin/scripts/managers/loot_manager.lua
- This file lists the groups of skills that can occur on looted gear and SEAs.
- Normally Clothing Attachments more possibilties than Armor Attachment.
- This mod makes both SEA types have the same full array of stat possibilities.


How to Install:
Use github to create a patch based on the following commit to my Legend of Hondo project,
https://github.com/Tatwi/legend-of-hondo/commit/d007fff8df1c3c966fc0e69407217eba5b8c1a2f

or

Download the whole files and use something like Meld to patch in the changes.
https://mega.nz/#!6Q1m1Z6I!lW-xNIoXGcuEh6k8Df9I_0V05S0I5kgzXCIuW4gk0Wc


I hope someone out there gives this a whirl and enjoys it as much as I do!  :D
 

Tonberry

Inactive Staff
Joined
Aug 30, 2010
Messages
372
A very interesting concept. I really like the idea, not sure how big of an effect it'd have on the economy though and it could make the combat guys a bit mad knowing some of their sweet lootz is now accessible by crafters passively. :p

Either way looking like some great work. I'm really glad you posted it, I'm in the planning stages of giving the site a bit of an overhaul and one of the changes will include a restructure of the forum. I was planning on adding a content development area which would cover things with a server-side component so I hope to see more work like this in the future. :)
 

tatwi

Member
Joined
May 31, 2012
Messages
66
"Passively" he says... teehee... You tell me how passive it is to use all 14 points, one point at time to maximize complexity, practicing away at power converters for a couple hours. hahahaha... insanity! *facial twitch* :)

But yeah, I could see some folks getting their undies in a bunch over this mod. That is until they try it. I did not make it a cake walk. A whole lot of testing went into making it just the right amount of utterly punishing for those who want an easy ride lol... But I am sure someone will one day find a way to cheese it and win a lot, even with the high "impossible to win" random factor (which is why I capped the assembly mod - no stacking to brute force win all the time!).
 

Tonberry

Inactive Staff
Joined
Aug 30, 2010
Messages
372
Ah it factors in experimentation, sorry must've missed that in the overview. ;) Then yeah that is very cool and sounds like it could be pretty balanced. Loving the sound of it and I'm not generally a hardcore crafter. It definitely adds a bit of spice to crafting, lets be honest if you're doing a lot of crafting it can be pretty tedious. It's not like it involves any mini-games to keep you occupied so this is a really nice bonus for the crafters that go through all that tedium.
 

Timbab

Administrator
Staff member
Administrator
Moderator
Joined
Oct 6, 2010
Messages
1,057
Location
Magna Germania
Happy to see this kind of stuff on here. :)

We're starting to need a Content/Server related release forum. :p
 

drdax

Member
Joined
Jun 11, 2015
Messages
133
Great idea, akin to the RE of space parts for a chance to get a KSE disk... nice work!
 

tiars

New Member
Joined
Aug 19, 2012
Messages
18
Unfortunately there is nothing there when you follow the link. I have the version on Git but was interested in verbose debug version to fine tune things.

Great work and after a few iterations I merged your code with publish 7 and have it working as I wanted it to.
 

tatwi

Member
Joined
May 31, 2012
Messages
66
tiars said:
Unfortunately there is nothing there when you follow the link. I have the version on Git but was interested in verbose debug version to fine tune things.

Great work and after a few iterations I merged your code with publish 7 and have it working as I wanted it to.
Sorry... I got rid of OneDrive and have too many links all over the place lol... I think the verbose version is in a zip in my Mega storage.

https://mega.nz/#F!SQ9mHYQC!ap7EF8qLidpiXAEzQJ4p9Q

For reals, I will be keeping everything on Mega unless it shuts down.
 
Top Bottom