Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Database/World Building

Development::Database/World Building World Building forum, dedicated to the EQEmu MySQL Database. Post partial/complete databases for spawns, items, etc.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 03-05-2013, 07:40 PM
c0ncrete's Avatar
c0ncrete
Dragon
 
Join Date: Dec 2009
Posts: 719
Default

Code:
 zone/embparser.cpp   | 13 ++++++++++++-
 zone/event_codes.h   |  1 +
 zone/tradeskills.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++---
 zone/zonedb.h        |  1 +
 4 files changed, 59 insertions(+), 4 deletions(-)

diff --git a/zone/embparser.cpp b/zone/embparser.cpp
index dc77b4e..c96c465 100644
--- a/zone/embparser.cpp
+++ b/zone/embparser.cpp
@@ -93,7 +93,8 @@ const char *QuestEventSubroutines[_LargestEventID] = {
 	"EVENT_CLICK_OBJECT",
 	"EVENT_DISCOVER_ITEM",
 	"EVENT_DISCONNECT",
-	"EVENT_CONNECT"
+	"EVENT_CONNECT",
+	"EVENT_COMBINE"
 };
 
 extern Zone* zone;
@@ -768,6 +769,16 @@ void PerlembParser::EventCommon(QuestEventID event, uint32 objid, const char * d
 			break;
 		}
 		//tradeskill events
+		case EVENT_COMBINE:
+		{
+			Seperator *sep = new Seperator(data, '|');
+			ExportVar(packagename.c_str(), "recipe_name", sep->arg[0]);
+			ExportVar(packagename.c_str(), "onsuccess", sep->arg[1]);
+			ExportVar(packagename.c_str(), "onfailure", sep->arg[2]);
+			ExportVar(packagename.c_str(), "recipe_id", extradata);
+			safe_delete(sep);
+			break;
+		}
 		case EVENT_COMBINE_SUCCESS:
 		case EVENT_COMBINE_FAILURE:
 		{
diff --git a/zone/event_codes.h b/zone/event_codes.h
index 3a29756..545390e 100644
--- a/zone/event_codes.h
+++ b/zone/event_codes.h
@@ -58,6 +58,7 @@ typedef enum {
 	EVENT_DISCOVER_ITEM,
 	EVENT_DISCONNECT,
 	EVENT_CONNECT,
+	EVENT_COMBINE,
 	
 	_LargestEventID
 } QuestEventID;
diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp
index 48d097d..99defa9 100644
--- a/zone/tradeskills.cpp
+++ b/zone/tradeskills.cpp
@@ -328,6 +328,47 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob
 		}
 		container->Clear();
 	}
+
+	// trade skills flagged as scripted will be handled entirely by perl
+	// data passed as follows:
+	//     recipe_name|success_item1 success_count1 success_item2 success_count2|fail_item1 fail_count1
+	if(spec.scripted) {
+		
+		_log(TRADESKILLS__TRACE, "Scripted tradeskill '%s' found in Object::HandleCombine.", spec.name.c_str());
+
+		vector<pair<uint32, uint8>>::iterator itr;
+
+		char *data = 0;
+		int32 dsiz = 0, dlen = 0;
+		
+		// build data string to pass to event
+		AppendAnyLenString(&data, &dsiz, &dlen, "%s|", spec.name.c_str());
+		if(spec.onsuccess.size()) {
+			itr = spec.onsuccess.begin();
+			while(itr != spec.onsuccess.end()-1) {
+				AppendAnyLenString(&data, &dsiz, &dlen, "%u %u ", itr->first, itr->second);
+				++itr;
+			}
+			AppendAnyLenString(&data, &dsiz, &dlen, "%u %u", itr->first, itr->second);
+		}
+		AppendAnyLenString(&data, &dsiz, &dlen, "|");
+		if(spec.onfail.size()) {
+			itr = spec.onfail.begin();
+			while(itr != spec.onfail.end()-1) {
+				AppendAnyLenString(&data, &dsiz, &dlen, "%u %u ", itr->first, itr->second);
+				++itr;
+			}
+			AppendAnyLenString(&data, &dsiz, &dlen, "%u %u", itr->first, itr->second);
+		}
+
+		_log(TRADESKILLS__TRACE, "Passing data to EVENT_COMBINE -- %s", data);
+		parse->EventPlayer(EVENT_COMBINE, user, data, spec.recipe_id);
+        
+		safe_delete_array(data);
+
+		return;
+	}
+
 	//do the check and send results...
 	bool success = user->TradeskillExecute(&spec);
 
@@ -1323,7 +1364,7 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id
  	}
  	
  	qlen = MakeAnyLenString(&query, "SELECT tr.id, tr.tradeskill, tr.skillneeded,"
- 	" tr.trivial, tr.nofail, tr.replace_container, tr.name, tr.must_learn, tr.quest, crl.madecount"
+ 	" tr.trivial, tr.nofail, tr.replace_container, tr.name, tr.must_learn, tr.quest, tr.scripted, crl.madecount"
  	" FROM tradeskill_recipe AS tr inner join tradeskill_recipe_entries as tre"
  	" ON tr.id = tre.recipe_id"
  	" LEFT JOIN (SELECT recipe_id, madecount from char_recipe_list WHERE char_id = %u) AS crl "
@@ -1354,12 +1395,13 @@ bool ZoneDatabase::GetTradeRecipe(uint32 recipe_id, uint8 c_type, uint32 some_id
 	spec->name = row[6];
 	spec->must_learn = (uint8)atoi(row[7]);
 	spec->quest = atoi(row[8]) ? true : false;
-	if (row[9] == NULL) {
+	spec->quest = atoi(row[9]) ? true : false;
+	if (row[10] == NULL) {
 		spec->has_learnt = false;
 		spec->madecount = 0;
 	} else {
 		spec->has_learnt = true;
-		spec->madecount = (uint32)atoul(row[9]);
+		spec->madecount = (uint32)atoul(row[10]);
 	}
 	spec->recipe_id = recipe_id;
 	mysql_free_result(result);
diff --git a/zone/zonedb.h b/zone/zonedb.h
index 9863d8f..7933a79 100644
--- a/zone/zonedb.h
+++ b/zone/zonedb.h
@@ -52,6 +52,7 @@ struct DBTradeskillRecipe_Struct {
 	uint32 madecount;
 	uint32 recipe_id;
 	bool quest;
+	bool scripted;
 };
 
 struct PetRecord {
required SQL:
Code:
ALTER TABLE `tradeskill_recipe` ADD `scripted` TINYINT(1) NOT NULL DEFAULT  '0';
if a recipe has the `scripted` flag set to 1 in the database, it parses EVENT_COMBINE in global_player.pl so you can do whatever you want with it. it sends the recipe name, id, and two strings that contain the item ids and counts of the yields on both success and failure. you can break up the strings into a hash like this:
Code:
sub EVENT_COMBINE {

    my %success = split ' ', $onsuccess;
    my %failure = split ' ', $onfailure;

    # full muffin crate
    if ( $recipe_id == 12811 ) {

        # iterate over success items
        while ( my ( $item, $count ) = each %success ) {
            $client->Message( 15, "$item => $count" );
        }

        # iterate over failure items
        while ( my ( $item, $count ) = each %failure ) {
            $client->Message( 15, "$item => $count" );
        }
    }
}
it's completely up to you as to how you calculate successes and skill ups and whatnot at that point.
__________________
I muck about @ The Forge.
say(rand 99>49?'try '.('0x'.join '',map{unpack 'H*',chr rand 256}1..2):'incoherent nonsense')while our $Noport=1;

Last edited by c0ncrete; 03-05-2013 at 07:51 PM.. Reason: corrected exported variable name
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:53 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3