Browse Source

Pets and bots now properly update their damage upon levelling with their owner

Emagi 1 year ago
parent
commit
957fa27b5c

+ 1 - 4
EQ2/source/WorldServer/Bots/Bot.cpp

@@ -665,11 +665,8 @@ void Bot::ChangeLevel(int16 old_level, int16 new_level) {
 	//SendNewSpells(classes.GetBaseClass(player->GetAdventureClass()));
 	//SendNewSpells(classes.GetSecondaryBaseClass(player->GetAdventureClass()));
 
-
-	ChangePrimaryWeapon();
-	ChangeSecondaryWeapon();
-	ChangeRangedWeapon();
 	GetInfoStruct()->set_level(new_level);
+	UpdateWeapons();
 	// GetPlayer()->SetLevel(new_level);
 
 	LogWrite(MISC__TODO, 1, "TODO", "Get new HP/POWER/stat based on default values from DB\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);

+ 1 - 1
EQ2/source/WorldServer/Bots/BotCommands.cpp

@@ -549,7 +549,7 @@ void Commands::Command_Bot_Spawn(Client* client, Seperator* sep) {
 				bot->SetPower(25 * bot->GetLevel() + 1);
 			}
 			bot->SetOwner(client->GetPlayer());
-			bot->ChangePrimaryWeapon();
+			bot->UpdateWeapons();
 			bot->CalculateBonuses();
 			bot->GetNewSpells();
 			client->GetCurrentZone()->AddSpawn(bot);

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

@@ -6818,9 +6818,7 @@ void Commands::Command_Inventory(Client* client, Seperator* sep, EQ2_RemoteComma
 						client->QueuePacket(outapp);
 				}
 
-				client->GetPlayer()->ChangePrimaryWeapon();
-				client->GetPlayer()->ChangeSecondaryWeapon();
-				client->GetPlayer()->ChangeRangedWeapon();
+				client->GetPlayer()->UpdateWeapons();
 				EQ2Packet* characterSheetPackets = client->GetPlayer()->GetPlayerInfo()->serialize(client->GetVersion());
 				client->QueuePacket(characterSheetPackets);
 			}

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

@@ -790,6 +790,12 @@ void Entity::ChangeRangedWeapon(){
 	}
 }
 
+void Entity::UpdateWeapons() {
+	ChangePrimaryWeapon();
+	ChangeSecondaryWeapon();
+	ChangeRangedWeapon();
+}
+
 int32 Entity::GetStrengthDamage() {
 	int32 str_offset = 1;
 	if(IsNPC()) {

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

@@ -1376,6 +1376,7 @@ public:
 	void	ChangePrimaryWeapon();
 	void	ChangeSecondaryWeapon();
 	void	ChangeRangedWeapon();
+	void	UpdateWeapons();
 	int32	GetStrengthDamage();
 	virtual Skill*	GetSkillByName(const char* name, bool check_update = false);
 	virtual Skill*	GetSkillByID(int32 id, bool check_update = false);

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

@@ -5364,6 +5364,9 @@ int EQ2Emu_lua_SummonPet(lua_State* state) {
 		pet->SetLevel(spawn->GetLevel());
 	// Set the max level this pet can reach
 	((NPC*)pet)->SetMaxPetLevel(max_level);
+	
+	((NPC*)pet)->UpdateWeapons();
+	
 	// Set the faction of the pet to the same faction as the owner
 	pet->SetFactionID(spawn->GetFactionID());
 	// Set the spawn as a pet

+ 1 - 2
EQ2/source/WorldServer/NPC.cpp

@@ -95,8 +95,7 @@ NPC::NPC(NPC* old_npc){
 		CalculateBonuses();	
 		SetHP(GetTotalHP());
 		SetPower(GetTotalPower());
-		ChangePrimaryWeapon();
-		ChangeSecondaryWeapon();
+		UpdateWeapons();
 		SetSoundsDisabled(old_npc->IsSoundsDisabled());
 		SetFlyingCreature();
 		SetWaterCreature();

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

@@ -825,9 +825,7 @@ void Client::SendCharInfo() {
 		SendTitleUpdate();
 	}
 
-	GetPlayer()->ChangePrimaryWeapon();
-	GetPlayer()->ChangeSecondaryWeapon();
-	GetPlayer()->ChangeRangedWeapon();
+	GetPlayer()->UpdateWeapons();
 	if(!GetPlayer()->IsReturningFromLD()) {
 		database.LoadBuyBacks(this);
 	}
@@ -4643,6 +4641,7 @@ void Client::ChangeLevel(int16 old_level, int16 new_level) {
 		NPC* pet = (NPC*)player->GetPet();
 		if (pet->GetMaxPetLevel() == 0 || new_level <= pet->GetMaxPetLevel()) {
 			pet->SetLevel(new_level);
+			pet->UpdateWeapons();
 			PacketStruct* command_packet = configReader.getStruct("WS_CannedEmote", GetVersion());
 			if (command_packet) {
 				command_packet->setDataByName("spawn_id", player->GetIDWithPlayerSpawn(pet));
@@ -4677,10 +4676,8 @@ void Client::ChangeLevel(int16 old_level, int16 new_level) {
 
 	SendNewAdventureSpells();
 
-	GetPlayer()->ChangePrimaryWeapon();
-	GetPlayer()->ChangeSecondaryWeapon();
-	GetPlayer()->ChangeRangedWeapon();
 	GetPlayer()->GetInfoStruct()->set_level(new_level);
+	GetPlayer()->UpdateWeapons();
 	// GetPlayer()->SetLevel(new_level);
 
 	LogWrite(MISC__TODO, 1, "TODO", "Get new HP/POWER/stat based on default values from DB\n\t(%s, function: %s, line #: %i)", __FILE__, __FUNCTION__, __LINE__);
@@ -7021,9 +7018,7 @@ void Client::UnequipItem(int16 index, sint32 bag_id, int8 to_slot, int8 appearan
 			QueuePacket(outapp);
 	}
 
-	GetPlayer()->ChangePrimaryWeapon();
-	GetPlayer()->ChangeSecondaryWeapon();
-	GetPlayer()->ChangeRangedWeapon();
+	GetPlayer()->UpdateWeapons();
 	EQ2Packet* characterSheetPackets = GetPlayer()->GetPlayerInfo()->serialize(GetVersion());
 	QueuePacket(characterSheetPackets);
 }