Go Back   EQEmulator Home > EQEmulator Forums > Development > Development: Custom Code

Development: Custom Code This is for code thatdoes not emulate live and wont be added to the official code.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #7  
Old 02-10-2016, 09:35 PM
Freshmaker
Fire Beetle
 
Join Date: May 2010
Posts: 5
Default

Got bored enough to give this another look see tonight. Thanks, image. That helped. I've cobbled together something that gives you the functionality you want, Slaymore.

Tested this by confirming that NEC's "Invoke Death" pet (base 33 delay) gets appropriately set to 19 when given a Lamentation. I didn't thoroughly test all scenarios, but weapons should NOT be able to make a pet hit slower. If the delay is worse, it ignores the delay. If it's faster, it uses it.

Code:
diff --git a/zone/attack.cpp b/zone/attack.cpp
index 2fdf5f1..9b7a1b9 100644
--- a/zone/attack.cpp
+++ b/zone/attack.cpp
@@ -4584,17 +4584,6 @@ void NPC::SetAttackTimer()
 	attack_timer.SetAtTrigger(4000, true);
 
 	Timer *TimerToUse = nullptr;
-	int hhe = itembonuses.HundredHands + spellbonuses.HundredHands;
-
-	// Technically NPCs should do some logic for weapons, but the effect is minimal
-	// What they do is take the lower of their set delay and the weapon's
-	// ex. Mob's delay set to 20, weapon set to 19, delay 19
-	// Mob's delay set to 20, weapon set to 21, delay 20
-	int speed = 0;
-	if (RuleB(Spells, Jun182014HundredHandsRevamp))
-		speed = static_cast<int>(((attack_delay / haste_mod) + ((hhe / 1000.0f) * (attack_delay / haste_mod))) * 100);
-	else
-		speed = static_cast<int>(((attack_delay / haste_mod) + ((hhe / 100.0f) * attack_delay)) * 100);
 
 	for (int i = MainRange; i <= MainSecondary; i++) {
 		//pick a timer
@@ -4607,6 +4596,16 @@ void NPC::SetAttackTimer()
 		else	//invalid slot (hands will always hit this)
 			continue;
 
+		const Item_Struct *ItemToUse = nullptr;
+
+		// Identify the material from the slot to determine the weapon
+		uint8 materialFromSlot = _MaterialInvalid;
+		materialFromSlot = Inventory::CalcMaterialFromSlot(i);
+
+		int itemID = GetEquipment(materialFromSlot);
+		if (itemID > 0)
+			ItemToUse = database.GetItem(itemID);;
+
 		//special offhand stuff
 		if (i == MainSecondary) {
 			// SPECATK_QUAD is uncheesable
@@ -4616,6 +4615,50 @@ void NPC::SetAttackTimer()
 			}
 		}
 
+		//see if we have a valid weapon
+		if (ItemToUse != nullptr) {
+			//check type and damage/delay
+			if (ItemToUse->ItemClass != ItemClassCommon
+					|| ItemToUse->Damage == 0
+					|| ItemToUse->Delay == 0) {
+				//no weapon
+				ItemToUse = nullptr;
+			}
+			// Check to see if skill is valid
+			else if ((ItemToUse->ItemType > ItemTypeLargeThrowing) &&
+					(ItemToUse->ItemType != ItemTypeMartial) &&
+					(ItemToUse->ItemType != ItemType2HPiercing)) {
+				//no weapon
+				ItemToUse = nullptr;
+			}
+		}
+
+		int hhe = itembonuses.HundredHands + spellbonuses.HundredHands;
+
+		// Client pets do some logic for weapons, but the effect is minimal
+		// What they do is take the lower of their set delay and the weapon's
+		// ex. Pet's delay set to 20, weapon set to 19, delay 19
+		// Pet's delay set to 20, weapon set to 21, delay 20
+		int speed = 0;
+		int delay = 100 * attack_delay;
+
+		// Only apply the weapon-based delay modifications to Client pets. Otherwise,
+		// this change would affect all NPCs and their pets
+		bool clientpet = false;
+		if ((IsPet() || IsTempPet()) && IsPetOwnerClient())
+			clientpet = true;
+
+		// Apply weapon delay only if it's faster than the pet's default attack_delay
+		if (clientpet && (ItemToUse != nullptr) && (ItemToUse->Delay < attack_delay))
+			delay = 100 * ItemToUse->Delay;
+
+		speed = delay / haste_mod;
+
+		if (RuleB(Spells, Jun182014HundredHandsRevamp))
+			speed = static_cast<int>(speed + ((hhe / 1000.0f) * speed));
+		else
+			speed = static_cast<int>(speed + ((hhe / 100.0f) * delay));
+
 		TimerToUse->SetAtTrigger(std::max(RuleI(Combat, MinHastedDelay), speed), true, true);
 	}
 }
Reply With Quote
 

Thread Tools
Display Modes

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 11:17 AM.


 

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