소스 검색

Update to /mood

Devn00b 2 년 전
부모
커밋
5383358146
4개의 변경된 파일59개의 추가작업 그리고 10개의 파일을 삭제
  1. 1 0
      DB/updates/mood_command_may_2022.sql
  2. 51 10
      EQ2/source/WorldServer/Commands/Commands.cpp
  3. 2 0
      EQ2/source/WorldServer/Entity.cpp
  4. 5 0
      EQ2/source/WorldServer/Entity.h

+ 1 - 0
DB/updates/mood_command_may_2022.sql

@@ -0,0 +1 @@
+UPDATE commands SET handler='800' WHERE  id=32;

+ 51 - 10
EQ2/source/WorldServer/Commands/Commands.cpp

@@ -11513,37 +11513,78 @@ Player* player = client->GetPlayer();
 	if( sep && sep->arg[0] )
 	{
 		const char* value = sep->arg[0];
-		// process single-param commands first
+		InfoStruct* info = player->GetInfoStruct();
+		int32 cid = client->GetCharacterID();
+		char* characterName = database.GetCharacterName(cid);
+		char tmp[1024]; // our emote string "xyz appears zyx"
+		//char properties vals
+		char* pname = "mood";
+		char* pval; // mood value
+		bool pt; //used to verify return from DB.
+
+		//This should never be seen.
+		sprintf(tmp, " ");
 		if( strncasecmp(value, "angry", strlen(value)) == 0 ) 
 		{
+			sprintf(tmp, "%s appears angry", characterName);
+			pval = "11852";
 			player->SetMoodState(11852, 1);
-			return;
+			info->set_mood(11852);
+			pt = database.insertCharacterProperty(client, pname, pval);
 		}
 		else if( strncasecmp(value, "afraid", strlen(value)) == 0 ) 
 		{
+			sprintf(tmp, "%s appears afraid", characterName);
+			pval = "11851";
 			player->SetMoodState(11851, 1);
-			return;
+			info->set_mood(11851);
+			pt = database.insertCharacterProperty(client, pname, pval);
 		} 
 		else if( strncasecmp(value, "happy", strlen(value)) == 0 ) 
 		{
+			sprintf(tmp, "%s appears happy", characterName);
+			pval = "11854";
 			player->SetMoodState(11854, 1);
-			return;
+			info->set_mood(11854);
+			pt = database.insertCharacterProperty(client, pname, pval);
 		} 
 		else if( strncasecmp(value, "sad", strlen(value)) == 0 ) {
+			sprintf(tmp, "%s appears sad", characterName);
+			pval = "11856";
 			player->SetMoodState(11856, 1);
-			return;
+			info->set_mood(11856);
+			pt = database.insertCharacterProperty(client, pname, pval);
 		}
 		else if( strncasecmp(value, "tired", strlen(value)) == 0 ) 
 		{
-			player->SetMoodState(11857,1);
-			return;
+			sprintf(tmp, "%s appears tired", characterName);
+			pval = "11857";
+			player->SetMoodState(11857, 1);
+			info->set_mood(11857);
+			pt = database.insertCharacterProperty(client, pname, pval);
 		}
 		else if( strncasecmp(value, "none", strlen(value)) == 0 ) 
 		{
+			//using 11855 mood_idle for none, I assume thats what its for?
+			pval = "11855";
 			player->SetMoodState(11855, 1);
+			info->set_mood(11855);
+			pt = database.insertCharacterProperty(client, pname, pval);
+			//return since we have nothing left to do. No emote for none.
 			return;
-		}
-
+		}else{
+			client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
+			client->SimpleMessage(CHANNEL_NARRATIVE, "none");
+			client->SimpleMessage(CHANNEL_NARRATIVE, "afraid");
+			client->SimpleMessage(CHANNEL_NARRATIVE, "angry");
+			client->SimpleMessage(CHANNEL_NARRATIVE, "happy");
+			client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
+			client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
+			return;
+			}
+			
+		client->GetPlayer()->GetZone()->HandleChatMessage(0, 0, CHANNEL_EMOTE, tmp);
+		return;
 	}
 	
 	client->SimpleMessage(CHANNEL_NARRATIVE, "Listing Available Moods:");
@@ -11554,4 +11595,4 @@ Player* player = client->GetPlayer();
 	client->SimpleMessage(CHANNEL_NARRATIVE, "sad");
 	client->SimpleMessage(CHANNEL_NARRATIVE, "tired");
 	return;
-}
+}

+ 2 - 0
EQ2/source/WorldServer/Entity.cpp

@@ -303,6 +303,7 @@ void Entity::MapInfoStruct()
 
 	get_int8_funcs["interaction_flag"] = l::bind(&InfoStruct::get_interaction_flag, &info_struct);
 	get_int8_funcs["tag1"] = l::bind(&InfoStruct::get_tag1, &info_struct);
+	get_int16_funcs["mood"] = l::bind(&InfoStruct::get_mood, &info_struct);
 
 /** SETS **/
 	set_string_funcs["name"] = l::bind(&InfoStruct::set_name, &info_struct, l::_1);
@@ -450,6 +451,7 @@ void Entity::MapInfoStruct()
 
 	set_int8_funcs["interaction_flag"] = l::bind(&InfoStruct::set_interaction_flag, &info_struct, l::_1);
 	set_int8_funcs["tag1"] = l::bind(&InfoStruct::set_tag1, &info_struct, l::_1);
+	set_int16_funcs["mood"] = l::bind(&InfoStruct::set_mood, &info_struct, l::_1);
 
 }
 

+ 5 - 0
EQ2/source/WorldServer/Entity.h

@@ -259,6 +259,7 @@ struct InfoStruct{
 
 		interaction_flag_ = 0;
 		tag1_ = 0;
+		mood_ = 0;
 	}
 
 
@@ -413,6 +414,7 @@ struct InfoStruct{
 
 		interaction_flag_ = oldStruct->get_interaction_flag();
 		tag1_ = oldStruct->get_tag1();
+		mood_ = oldStruct->get_mood();
 	}
 
 	//mutable std::shared_mutex mutex_;
@@ -577,6 +579,7 @@ struct InfoStruct{
 
 	int8	get_interaction_flag() { std::lock_guard<std::mutex> lk(classMutex); return interaction_flag_; }
 	int8	get_tag1() { std::lock_guard<std::mutex> lk(classMutex); return tag1_; }
+	int16	get_mood() { std::lock_guard<std::mutex> lk(classMutex); return mood_; }
 
 	void	set_name(std::string value) { std::lock_guard<std::mutex> lk(classMutex); name_ = value; }
 	
@@ -825,6 +828,7 @@ struct InfoStruct{
 
 	void	set_interaction_flag(int8 value) { std::lock_guard<std::mutex> lk(classMutex); interaction_flag_ = value; }
 	void	set_tag1(int8 value) { std::lock_guard<std::mutex> lk(classMutex); tag1_ = value; }
+	void	set_mood(int16 value) { std::lock_guard<std::mutex> lk(classMutex); mood_ = value; }
 
 	void	ResetEffects(Spawn* spawn)
 	{
@@ -996,6 +1000,7 @@ private:
 
 	int8			interaction_flag_;
 	int8			tag1_;
+	int16			mood_;
 	// when PacketStruct is fixed for C++17 this should become a shared_mutex and handle read/write lock
 	std::mutex		classMutex;
 };