Jelajahi Sumber

tradeskill fixes that never made git

should fix issue of not being able to examine recipes from recipe book
Robert Allen 1 tahun lalu
induk
melakukan
c58a0ef358

+ 23 - 7
EQ2/source/WorldServer/Tradeskills/Tradeskills.cpp

@@ -233,7 +233,7 @@ void TradeskillMgr::Process() {
 	m_tradeskills.releasewritelock(__FUNCTION__, __LINE__);
 }
 
-void TradeskillMgr::BeginCrafting(Client* client, vector<pair<int32,int8>> components) {
+void TradeskillMgr::BeginCrafting(Client* client, vector<pair<int32,int16>> components) {
 	Recipe* recipe = master_recipe_list.GetRecipe(client->GetPlayer()->GetCurrentRecipe());
 
 	if (!recipe) {
@@ -243,7 +243,7 @@ void TradeskillMgr::BeginCrafting(Client* client, vector<pair<int32,int8>> compo
 	}
 
 	// TODO: use the vecotr to lock inventory slots
-	vector<pair<int32, int8>>::iterator itr;
+	vector<pair<int32, int16>>::iterator itr;
 	bool missingItem = false;
 	int32 itemid = 0;
 	vector<Item*> tmpItems;
@@ -317,7 +317,7 @@ void TradeskillMgr::StopCrafting(Client* client, bool lock) {
 	int32 dur = tradeskill->currentDurability;
 	int32 progress = tradeskill->currentProgress;
 	Recipe* recipe = tradeskill->recipe;
-	vector<pair<int32, int8>>::iterator itr;
+	vector<pair<int32, int16>>::iterator itr;
 	Item* item = 0;
 	int32 item_id = 0;
 	int8 i = 0;
@@ -370,8 +370,17 @@ void TradeskillMgr::StopCrafting(Client* client, bool lock) {
 	item = 0;
 	qty = recipe->GetFuelComponentQuantity();	
 	item_id = recipe->components[5][0];
+	float tsx = 0;
 	int8 HS = playerRecipe->GetHighestStage();
-	if (progress >= 400 && progress < 600) {
+	client->Message(CHANNEL_COLOR_RED, "%s: StopCrafting Error finding item %u to remove quantity for recipe id %u!", client->GetPlayer()->GetName(), dur);
+	if (progress < 400) { //stage 0
+		if (recipe->products.count(0) > 0) {
+			item_id = recipe->products[0]->product_id;
+			qty = recipe->products[0]->product_qty;
+		}
+		tsx = 1;
+	}
+	else if (progress >= 400 && progress < 600) { //stage 1
 		if (HS & (1 << (1 - 1))) {
 		}
 		else {
@@ -382,8 +391,10 @@ void TradeskillMgr::StopCrafting(Client* client, bool lock) {
 			item_id = recipe->products[1]->product_id;
 			qty = recipe->products[1]->product_qty;
 		}
+		tsx = .45;
 	}
-	else if ((dur < 200 && progress >= 600) || (dur >= 200 && progress >= 600 && progress < 800)) {
+	else if (progress >= 600 && progress < 800) { //stage 2
+	//else if ((dur < 200 && progress >= 600) || (dur >= 200 && progress >= 600 && progress < 800)) { //stage 2
 		if (HS & (1 << (2 - 1))) {
 		}
 		else {
@@ -394,8 +405,10 @@ void TradeskillMgr::StopCrafting(Client* client, bool lock) {
 			item_id = recipe->products[2]->product_id;
 			qty = recipe->products[2]->product_qty;
 		}
+		tsx = .30;
 	}
-	else if ((dur >= 200 && dur < 800 && progress >= 800) || (dur >= 800 && progress >= 800 && progress < 1000)) {
+	//else if ((dur >= 200 && dur < 800 && progress >= 800) || (dur >= 800 && progress >= 800 && progress < 1000)) { // stage 3
+	else if (progress >= 800 && progress < 1000) { // stage 3
 		if (HS & (1 << (3 - 1))) {
 		}
 		else {
@@ -406,8 +419,10 @@ void TradeskillMgr::StopCrafting(Client* client, bool lock) {
 			item_id = recipe->products[3]->product_id;
 			qty = recipe->products[3]->product_qty;
 		}
+		tsx = .15;
 	}
-	else if (dur >= 800 && progress >= 1000) {
+	//else if (dur >= 800 && progress >= 1000) {  // stage 4
+	else if (progress >= 1000) {  // stage 4
 		if (HS & (1 << (4 - 1))) {
 		}
 		else {
@@ -438,6 +453,7 @@ void TradeskillMgr::StopCrafting(Client* client, bool lock) {
 	}
 
 	float xp = client->GetPlayer()->CalculateTSXP(recipe->GetLevel());
+	xp = xp - (xp * tsx);
 	if (xp > 0) {
 		int16 level = client->GetPlayer()->GetTSLevel();
 		if (client->GetPlayer()->AddTSXP((int32)xp)) {

+ 2 - 2
EQ2/source/WorldServer/Tradeskills/Tradeskills.h

@@ -54,7 +54,7 @@ struct Tradeskill
 	int32			currentProgress;
 	int32			currentDurability;
 	int32			nextUpdateTime;
-	vector<pair<int32, int8>>	usedComponents;
+	vector<pair<int32, int16>>	usedComponents;
 	TradeskillEvent* CurrentEvent;
 	bool			eventChecked;
 	bool			eventCountered;
@@ -72,7 +72,7 @@ public:
 	/// <summary>Starts the actual crafting process</summary>
 	/// <param name='client'>Client that is crafting</param>
 	/// <param name='components'>List of items the player is using to craft</param>
-	void BeginCrafting(Client* client, vector<pair<int32, int8>> components);
+	void BeginCrafting(Client* client, vector<pair<int32, int16>> components);
 
 	/// <summary>Stops the crafting process</summary>
 	/// <param name='client'>Client that stopped crafting</param>

+ 26 - 9
EQ2/source/WorldServer/client.cpp

@@ -1684,7 +1684,7 @@ bool Client::HandlePacket(EQApplicationPacket* app) {
 			packet->LoadPacketData(app->pBuffer, app->size);
 			int32 item = 0;
 			int8 qty = 0;
-			vector<pair<int32, int8>> items;
+			vector<pair<int32, int16>> items;
 			char tmp_item_id[30];
 			int8 num_primary_selected_items = packet->getType_int8_ByName("num_primary_selected_items");
 			for (int8 i = 0; i < num_primary_selected_items; i++) {
@@ -1692,7 +1692,7 @@ bool Client::HandlePacket(EQApplicationPacket* app) {
 				sprintf(tmp_item_id, "primary_selected_item_id_%i", i);
 				item = packet->getType_int32_ByName(tmp_item_id);
 				sprintf(tmp_item_id, "primary_selected_item_qty_%i", i);
-				qty = packet->getType_int8_ByName(tmp_item_id);
+				qty = packet->getType_int16_ByName(tmp_item_id);
 				if (item > 0)
 					items.push_back(make_pair(item,qty));
 				item = 0;
@@ -1707,7 +1707,7 @@ bool Client::HandlePacket(EQApplicationPacket* app) {
 					sprintf(tmp_item_id, "selected_id%i_%i", i,j);
 					item = packet->getType_int32_ByName(tmp_item_id);
 					sprintf(tmp_item_id, "selected_qty%i_%i", i, j);
-					qty = packet->getType_int8_ByName(tmp_item_id);
+					qty = packet->getType_int16_ByName(tmp_item_id);
 					if (item > 0)
 						items.push_back(make_pair(item, qty));
 
@@ -1717,10 +1717,10 @@ bool Client::HandlePacket(EQApplicationPacket* app) {
 			int8 num_fuel_items = packet->getType_int8_ByName("num_fuel_items");
 			for (int8 i = 0; i < num_fuel_items; i++) {
 				memset(tmp_item_id, 0, 30);
-				sprintf(tmp_item_id, "selected_id_%i", i);
+				sprintf(tmp_item_id, "fuel_id_%i", i);
 				item = packet->getType_int32_ByName(tmp_item_id);
-				sprintf(tmp_item_id, "selected_qty_%i", i);
-				qty = packet->getType_int8_ByName(tmp_item_id);
+				sprintf(tmp_item_id, "fuel_qty_%i", i);
+				qty = packet->getType_int16_ByName(tmp_item_id);
 				if (item > 0)
 					items.push_back(make_pair(item, qty));
 				item = 0;
@@ -10066,6 +10066,7 @@ void Client::SendRecipeList() {
 	map<int32, Recipe*>::iterator itr;
 	Recipe* recipe;
 	int16 i = 0;
+	int8 level = player->GetTSLevel();
 	int index = 0;
 	for (itr = recipes->begin(); itr != recipes->end(); itr++) {
 		recipe = itr->second;
@@ -10080,12 +10081,28 @@ void Client::SendRecipeList() {
 	packet->setArrayLengthByName("num_recipes", recipes->size());
 	for (itr = recipes->begin(); itr != recipes->end(); itr++) {
 		recipe = itr->second;
-		packet->setArrayDataByName("id", recipe->GetID(), i);
-		packet->setArrayDataByName("tier", recipe->GetTier(), i);
+		int32 myid = recipe->GetID();
+		int8 rlevel = recipe->GetLevel();
+		int8 even = level - level * .05 + .5;
+		int8 easymin = level - level * .25 + .5;
+		int8 veasymin = level - level * .35 + .5;
+		if (rlevel > level )
+			packet->setArrayDataByName("tier", 4, i);
+		else if ((rlevel <= level) & (rlevel >= even))
+			packet->setArrayDataByName("tier", 3, i);
+		else if ((rlevel <= even) & (rlevel >= easymin))
+			packet->setArrayDataByName("tier", 2, i);
+		else if ((rlevel <= easymin) & (rlevel >= veasymin))
+			packet->setArrayDataByName("tier", 1, i);
+		else if ((rlevel <= veasymin) & (rlevel >= 0))
+			packet->setArrayDataByName("tier", 0, i);
+		if (rlevel == 2)
+			int xxx = 1;
+		packet->setArrayDataByName("recipe_id", myid, i);
 		packet->setArrayDataByName("level", recipe->GetLevel(), i);
+		packet->setArrayDataByName("unknown1", recipe->GetLevel(), i);
 		packet->setArrayDataByName("icon", recipe->GetIcon(), i);
 		packet->setArrayDataByName("classes", recipe->GetClasses(), i);
-		//packet->setArrayDataByName("skill", recipe->GetSkill(), i);
 		packet->setArrayDataByName("technique", recipe->GetTechnique(), i);
 		packet->setArrayDataByName("knowledge", recipe->GetKnowledge(), i);