Browse Source

Disarm chest old rules

- Added rule R_Loot, AutoDisarmChest enabled (1) by default.  Setting to 0 will mean you must right click and disarm chest, clicking the chest will not auto disarm and instead always trigger the trap

Fixes #47
Image 4 years ago
parent
commit
151b1fc91a

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

@@ -2008,7 +2008,10 @@ void Commands::Process(int32 index, EQ2_16BitString* command_parms, Client* clie
 
 			if(cmdTarget && cmdTarget->IsEntity()){
 				if (cmdTarget->GetDistance(client->GetPlayer()) <= rule_manager.GetGlobalRule(R_Loot, LootRadius)->GetFloat()){
-					client->Loot((Entity*)cmdTarget);
+					if (!rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool() && command->handler == COMMAND_DISARM )
+						client->OpenChest((Entity*)cmdTarget, true);
+					else
+						client->Loot((Entity*)cmdTarget, rule_manager.GetGlobalRule(R_Loot, AutoDisarmChest)->GetBool());
 					if (!((Entity*)cmdTarget)->HasLoot()){
 						if (((Entity*)cmdTarget)->IsNPC())
 							client->GetCurrentZone()->RemoveDeadSpawn(cmdTarget);

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

@@ -285,6 +285,7 @@ RuleManager::RuleManager() {
 	RULE_INIT(R_Zone, SpawnDeleteTimer, "30000");					// default: 30 seconds, how long a spawn pointer is held onto after being removed from the world before deleting it
 
 	RULE_INIT(R_Loot, LootRadius, "5.0");
+	RULE_INIT(R_Loot, AutoDisarmChest, "1");
 
 	RULE_INIT(R_Spells, NoInterruptBaseChance, "50");
 

+ 1 - 1
EQ2/source/WorldServer/Rules/Rules.h

@@ -143,7 +143,7 @@ enum RuleType {
 
 	/* LOOT */
 	LootRadius,
-
+	AutoDisarmChest, // if enabled disarm only works if you right click and disarm, clicking and opening chest won't attempt auto disarm
 	/* SPELLS */
 	NoInterruptBaseChance,
 

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

@@ -4054,21 +4054,21 @@ void Client::Loot(int32 total_coins, vector<Item*>* items, Entity* entity){
 
 }
 
-void Client::Loot(Entity* entity){
+void Client::Loot(Entity* entity, bool attemptDisarm){
 	if(entity->IsNPC() && ((NPC*)entity)->Brain()->CheckLootAllowed(GetPlayer())){
 		int32 total_coins = entity->GetLootCoins();
 		entity->LockLoot();
 		Loot(total_coins, entity->GetLootItems(), entity);
 		entity->UnlockLoot();
 
-		OpenChest(entity);
+		OpenChest(entity, attemptDisarm);
 	}
 	else
 		SimpleMessage(CHANNEL_COLOR_YELLOW, "You are not allowed to loot at this time.");
 
 }
 
-void Client::OpenChest(Entity* entity)
+void Client::OpenChest(Entity* entity, bool attemptDisarm)
 {
 	if (!entity)
 		return;
@@ -4114,7 +4114,7 @@ void Client::OpenChest(Entity* entity)
 		Skill* disarmSkill = GetPlayer()->GetSkillByName("Disarm Trap", false);
 		firstChestOpen = true;
 		entity->SetTrapTriggered(true);
-		if (disarmSkill)
+		if (disarmSkill && attemptDisarm)
 		{
 			if (disarmSkill->CheckDisarmSkill(entity->GetLevel(), chest_difficulty) < 1)
 			{

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

@@ -243,8 +243,8 @@ public:
 	void	CloseLoot();
 	void	SendPendingLoot(int32 total_coins, Entity* entity);
 	void	Loot(int32 total_coins, vector<Item*>* items, Entity* entity);
-	void	Loot(Entity* entity);
-	void	OpenChest(Entity* entity);
+	void	Loot(Entity* entity, bool attemptDisarm=true);
+	void	OpenChest(Entity* entity, bool attemptDisarm=true);
 	void	CheckPlayerQuestsKillUpdate(Spawn* spawn);
 	void	CheckPlayerQuestsChatUpdate(Spawn* spawn);
 	void	CheckPlayerQuestsItemUpdate(Item* item);