Browse Source

Fixed AA commands handler ids being wrong, new lua functions

- char sheet code updated to show unassigned AA, prestige, tradeskill prestige pts

LUA Functions:

- SetInvulnerable(Spawn, true/false)
- GetAAInfo(Spawn, type)
- SetAAInfo(Spawn, type, value)
type can be, assigned_aa, unassigned_aa, assigned_tradeskill_aa, unassigned_tradeskill_aa, assigned_prestige_aa, unassigned_prestige_aa, assigned_tradeskill_prestige_aa, unassigned_tradeskill_prestige_aa
Image 4 years ago
parent
commit
ba80ab2078

+ 1 - 0
EQ2/source/WorldServer/Commands/Commands.cpp

@@ -10273,6 +10273,7 @@ void Commands::Add_AA(Client* client, Seperator* sep) {
 		AltAdvanceData* data = master_aa_list.GetAltAdvancement(spell_id);
 		// addspellbookentry here
 		if (spell_tier >= data->maxRank) {
+		LogWrite(COMMAND__ERROR, 0, "Command", "Error in Add_AA spell_tier %u >= maxRank %u", spell_tier, data->maxRank);
 			return;
 		}
 		if (!spell_tier) {

+ 9 - 9
EQ2/source/WorldServer/Commands/Commands.h

@@ -866,15 +866,15 @@ private:
 
 #define COMMAND_RELOADREGIONSCRIPTS		524
 
-#define GET_AA_XML						751
-#define ADD_AA							752
-#define COMMIT_AA_PROFILE				753				
-#define BEGIN_AA_PROFILE				754
-#define BACK_AA							755
-#define REMOVE_AA						756
-#define SWITCH_AA_PROFILE				757
-#define CANCEL_AA_PROFILE				758
-#define SAVE_AA_PROFILE					759
+#define GET_AA_XML						750
+#define ADD_AA							751
+#define COMMIT_AA_PROFILE				752				
+#define BEGIN_AA_PROFILE				753
+#define BACK_AA							754
+#define REMOVE_AA						755
+#define SWITCH_AA_PROFILE				756
+#define CANCEL_AA_PROFILE				757
+#define SAVE_AA_PROFILE					758
 
 
 

+ 79 - 0
EQ2/source/WorldServer/LuaFunctions.cpp

@@ -11109,6 +11109,17 @@ int EQ2Emu_lua_IsInvulnerable(lua_State* state) {
 	return 0;
 }
 
+int EQ2Emu_lua_SetInvulnerable(lua_State* state) {
+	if (!lua_interface)
+		return 0;
+	Spawn* spawn = lua_interface->GetSpawn(state);
+	bool invul = lua_interface->GetBooleanValue(state, 2);
+	if (spawn) {
+		spawn->SetInvulnerable(invul);
+	}
+	return 0;
+}
+
 int EQ2Emu_lua_GetRuleFlagInt32(lua_State* state) {
 	if (!lua_interface)
 		return 0;
@@ -11123,4 +11134,72 @@ int EQ2Emu_lua_GetRuleFlagInt32(lua_State* state) {
 	
 	lua_interface->LogError("%s: LUA GetRuleFlag Unknown rule with category '%s' and type '%s'", lua_interface->GetScriptName(state), category.c_str(), name.c_str());
 	return 0;
+}
+
+
+int EQ2Emu_lua_GetAAInfo(lua_State* state) {
+	if (!lua_interface)
+		return 0;
+	Spawn* spawn = lua_interface->GetSpawn(state);
+	string type = lua_interface->GetStringValue(state, 2);
+	if (spawn) {
+		int res = 1;
+
+		boost::to_lower(type);
+		if(type == "assigned_aa")
+			lua_interface->SetSInt32Value(state, spawn->GetAssignedAA());
+		else if ( type == "unassigned_aa")
+			lua_interface->SetSInt32Value(state, spawn->GetUnassignedAA());
+		else if ( type == "assigned_tradeskill_aa")
+			lua_interface->SetSInt32Value(state, spawn->GetTradeskillAA());
+		else if ( type == "unassigned_tradeskill_aa")
+			lua_interface->SetSInt32Value(state, spawn->GetUnassignedTradeskillAA());
+		else if ( type == "assigned_prestige_aa")
+			lua_interface->SetSInt32Value(state, spawn->GetPrestigeAA());
+		else if ( type == "unassigned_prestige_aa")
+			lua_interface->SetSInt32Value(state, spawn->GetUnassignedPretigeAA());
+		else if ( type == "assigned_tradeskill_prestige_aa")
+			lua_interface->SetSInt32Value(state, spawn->GetTradeskillPrestigeAA());
+		else if ( type == "unassigned_tradeskill_prestige_aa")
+			lua_interface->SetSInt32Value(state, spawn->GetUnassignedTradeskillPrestigeAA());
+		else
+			res = 0;
+
+		return res;
+	}
+	
+	lua_interface->LogError("%s: LUA GetAAInfo spawn does not exist", lua_interface->GetScriptName(state));
+	return 0;
+}
+
+int EQ2Emu_lua_SetAAInfo(lua_State* state) {
+	if (!lua_interface)
+		return 0;
+
+	Spawn* spawn = lua_interface->GetSpawn(state);
+	string type = lua_interface->GetStringValue(state, 2);
+	sint32 value = lua_interface->GetSInt32Value(state, 3);
+	if (spawn) {
+		boost::to_lower(type);
+		if(type == "assigned_aa")
+			spawn->SetAssignedAA((sint16)value);
+		else if ( type == "unassigned_aa")
+			spawn->SetUnassignedAA((sint16)value);
+		else if ( type == "assigned_tradeskill_aa")
+			spawn->SetTradeskillAA((sint16)value);
+		else if ( type == "unassigned_tradeskill_aa")
+			spawn->SetUnassignedTradeskillAA((sint16)value);
+		else if ( type == "assigned_prestige_aa")
+			spawn->SetPrestigeAA((sint16)value);
+		else if ( type == "unassigned_prestige_aa")
+			spawn->SetUnassignedPrestigeAA((sint16)value);
+		else if ( type == "assigned_tradeskill_prestige_aa")
+			spawn->SetTradeskillPrestigeAA((sint16)value);
+		else if ( type == "unassigned_tradeskill_prestige_aa")
+			spawn->SetUnassignedTradeskillPrestigeAA((sint16)value);
+
+		if(spawn->IsPlayer())
+			((Player*)spawn)->SetCharSheetChanged(true);
+	}
+	return 0;
 }

+ 4 - 0
EQ2/source/WorldServer/LuaFunctions.h

@@ -519,6 +519,10 @@ int EQ2Emu_lua_InLava(lua_State* state);
 int EQ2Emu_lua_DamageSpawn(lua_State* state);
 
 int EQ2Emu_lua_IsInvulnerable(lua_State* state);
+int EQ2Emu_lua_SetInvulnerable(lua_State* state);
 
 int EQ2Emu_lua_GetRuleFlagInt32(lua_State* state);
+
+int EQ2Emu_lua_GetAAInfo(lua_State* state);
+int EQ2Emu_lua_SetAAInfo(lua_State* state);
 #endif

+ 4 - 0
EQ2/source/WorldServer/LuaInterface.cpp

@@ -1233,8 +1233,12 @@ void LuaInterface::RegisterFunctions(lua_State* state) {
 	
 	lua_register(state, "DamageSpawn", EQ2Emu_lua_DamageSpawn);
 	lua_register(state, "IsInvulnerable", EQ2Emu_lua_IsInvulnerable);
+	lua_register(state, "SetInvulnerable", EQ2Emu_lua_SetInvulnerable);
 	
 	lua_register(state, "GetRuleFlagInt32", EQ2Emu_lua_GetRuleFlagInt32);
+	
+	lua_register(state, "GetAAInfo", EQ2Emu_lua_GetAAInfo);
+	lua_register(state, "SetAAInfo", EQ2Emu_lua_SetAAInfo);
 }
 
 void LuaInterface::LogError(const char* error, ...)  {

+ 5 - 5
EQ2/source/WorldServer/Player.cpp

@@ -767,7 +767,7 @@ EQ2Packet* PlayerInfo::serialize(int16 version, int16 modifyPos, int32 modifyVal
 
 		packet->setDataByName("assigned_aa", player->GetAssignedAA());
 		packet->setDataByName("max_aa", rule_manager.GetGlobalRule(R_Player, MaxAA)->GetInt16());
-		packet->setDataByName("unassigned_aa", 200);// player->GetUnassignedAA()); // dov confirmed
+		packet->setDataByName("unassigned_aa", player->GetUnassignedAA()); // dov confirmed
 		packet->setDataByName("aa_green_bar", 0);// dov confirmed
 		packet->setDataByName("adv_xp_to_aa_xp_slider", 0);  // aa slider max // dov confirmed
 		packet->setDataByName("adv_xp_to_aa_xp_max", 100);  // aa slider position // dov confirmed
@@ -1026,11 +1026,11 @@ EQ2Packet* PlayerInfo::serialize(int16 version, int16 modifyPos, int32 modifyVal
 		packet->setDataByName("uncontested_riposte_pve", 0); //????
 		packet->setDataByName("uncontested_parry_pve", 0); //????
 		packet->setDataByName("total_prestige_points", player->GetPrestigeAA());
-		packet->setDataByName("unassigned_prestige_points", 25); // player->GetUnassignedPretigeAA());
-		packet->setDataByName("total_tradeskill_points", 40); // player->GetTradeskillAA());
-		packet->setDataByName("unassigned_tradeskill_points", 25);// player->GetUnassignedTradeskillAA());
+		packet->setDataByName("unassigned_prestige_points", player->GetUnassignedPretigeAA());
+		packet->setDataByName("total_tradeskill_points", player->GetTradeskillAA());
+		packet->setDataByName("unassigned_tradeskill_points", player->GetUnassignedTradeskillAA());
 		packet->setDataByName("total_tradeskill_prestige_points", player->GetTradeskillPrestigeAA());
-		packet->setDataByName("unassigned_tradeskill_prestige_points", 25);// player->GetUnassignedTradeskillPrestigeAA());
+		packet->setDataByName("unassigned_tradeskill_prestige_points", player->GetUnassignedTradeskillPrestigeAA());
 		/*packet->setDataByName("unknown13", 201, 0);
 		packet->setDataByName("unknown13", 201, 1);
 		packet->setDataByName("unknown13", 234, 2);

+ 4 - 2
EQ2/source/WorldServer/WorldDatabase.cpp

@@ -3787,11 +3787,13 @@ void WorldDatabase::Save(Client* client){
 	if(client->GetCurrentZone())
 		zone_id = client->GetCurrentZone()->GetZoneID();
 	query.AddQueryAsync(client->GetCharacterID(), this, Q_UPDATE, "update characters set current_zone_id=%u, x=%f, y=%f, z=%f, heading=%f, level=%i,instance_id=%i,last_saved=%i, `class`=%i, `tradeskill_level`=%i, `tradeskill_class`=%i, `group_id`=%u where id = %u", zone_id, player->GetX(), player->GetY(), player->GetZ(), player->GetHeading(), player->GetLevel(), instance_id, client->GetLastSavedTimeStamp(), client->GetPlayer()->GetAdventureClass(), client->GetPlayer()->GetTSLevel(), client->GetPlayer()->GetTradeskillClass(), client->GetPlayer()->GetGroupMemberInfo() ? client->GetPlayer()->GetGroupMemberInfo()->group_id : 0, client->GetCharacterID());
-	query.AddQueryAsync(client->GetCharacterID(), this, Q_UPDATE, "update character_details set hp=%u, power=%u, str=%i, sta=%i, agi=%i, wis=%i, intel=%i, heat=%i, cold=%i, magic=%i, mental=%i, divine=%i, disease=%i, poison=%i, coin_copper=%u, coin_silver=%u, coin_gold=%u, coin_plat=%u, max_hp = %u, max_power=%u, xp = %u, xp_needed = %u, xp_debt = %u, xp_vitality = %f, tradeskill_xp = %u, tradeskill_xp_needed = %u, tradeskill_xp_vitality = %f, bank_copper = %u, bank_silver = %u, bank_gold = %u, bank_plat = %u, bind_zone_id=%u, bind_x = %f, bind_y = %f, bind_z = %f, bind_heading = %f, house_zone_id=%u, combat_voice = %i, emote_voice = %i, biography='%s', flags=%u, flags2=%u, last_name='%s' where char_id = %u",
+	query.AddQueryAsync(client->GetCharacterID(), this, Q_UPDATE, "update character_details set hp=%u, power=%u, str=%i, sta=%i, agi=%i, wis=%i, intel=%i, heat=%i, cold=%i, magic=%i, mental=%i, divine=%i, disease=%i, poison=%i, coin_copper=%u, coin_silver=%u, coin_gold=%u, coin_plat=%u, max_hp = %u, max_power=%u, xp = %u, xp_needed = %u, xp_debt = %u, xp_vitality = %f, tradeskill_xp = %u, tradeskill_xp_needed = %u, tradeskill_xp_vitality = %f, bank_copper = %u, bank_silver = %u, bank_gold = %u, bank_plat = %u, bind_zone_id=%u, bind_x = %f, bind_y = %f, bind_z = %f, bind_heading = %f, house_zone_id=%u, combat_voice = %i, emote_voice = %i, biography='%s', flags=%u, flags2=%u, last_name='%s', assigned_aa = %i, unassigned_aa = %i, tradeskill_aa = %i, unassigned_tradeskill_aa = %i, prestige_aa = %i, unassigned_prestige_aa = %i, tradeskill_prestige_aa = %i, unassigned_tradeskill_prestige_aa = %i where char_id = %u",
 		player->GetHP(), player->GetPower(), player->GetStrBase(), player->GetStaBase(), player->GetAgiBase(), player->GetWisBase(), player->GetIntBase(), player->GetHeatResistanceBase(), player->GetColdResistanceBase(), player->GetMagicResistanceBase(),
 		player->GetMentalResistanceBase(), player->GetDivineResistanceBase(), player->GetDiseaseResistanceBase(), player->GetPoisonResistanceBase(), player->GetCoinsCopper(), player->GetCoinsSilver(), player->GetCoinsGold(), player->GetCoinsPlat(), player->GetTotalHPBase(), player->GetTotalPowerBase(), player->GetXP(), player->GetNeededXP(), player->GetXPDebt(), player->GetXPVitality(), player->GetTSXP(), player->GetNeededTSXP(), player->GetTSXPVitality(), player->GetBankCoinsCopper(),
 		player->GetBankCoinsSilver(), player->GetBankCoinsGold(), player->GetBankCoinsPlat(), client->GetPlayer()->GetPlayerInfo()->GetBindZoneID(), client->GetPlayer()->GetPlayerInfo()->GetBindZoneX(), client->GetPlayer()->GetPlayerInfo()->GetBindZoneY(), client->GetPlayer()->GetPlayerInfo()->GetBindZoneZ(), client->GetPlayer()->GetPlayerInfo()->GetBindZoneHeading(), client->GetPlayer()->GetPlayerInfo()->GetHouseZoneID(), 
-		client->GetPlayer()->GetCombatVoice(), client->GetPlayer()->GetEmoteVoice(), getSafeEscapeString(client->GetPlayer()->GetBiography().c_str()).c_str(), player->GetFlags(), player->GetFlags2(), client->GetPlayer()->GetLastName(), client->GetCharacterID());
+		client->GetPlayer()->GetCombatVoice(), client->GetPlayer()->GetEmoteVoice(), getSafeEscapeString(client->GetPlayer()->GetBiography().c_str()).c_str(), player->GetFlags(), player->GetFlags2(), client->GetPlayer()->GetLastName(), 
+		client->GetPlayer()->GetAssignedAA(), client->GetPlayer()->GetUnassignedAA(), client->GetPlayer()->GetTradeskillAA(), client->GetPlayer()->GetUnassignedTradeskillAA(), client->GetPlayer()->GetPrestigeAA(), 
+		client->GetPlayer()->GetUnassignedPretigeAA(), client->GetPlayer()->GetTradeskillPrestigeAA(), client->GetPlayer()->GetUnassignedTradeskillPrestigeAA(), client->GetCharacterID());
 	map<string, int8>::iterator itr;
 	map<string, int8>* friends = player->GetFriends();
 	if(friends && friends->size() > 0){