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.

Reply
 
Thread Tools Display Modes
  #1  
Old 01-22-2016, 01:19 PM
Slaymore
Fire Beetle
 
Join Date: Nov 2007
Posts: 21
Default Small code change help

HI

Sorry if this is not the right forum. Please feel free to move as needed.

I would like to make a change where the necro pet reverts back 15 years lol

By this I mean, once upon a time, a necro could give his pet 2 noobie daggers and the pet would use the attack speed from the daggers but still retain the pet innate damage.

Just looking to be pointed in the right direction on where I might find the necro pet code etc.

I have a linux install up and running and everything seems to be working fine.

I am not a programmer but I can normally figure things out with a little google fu.

Why do I want this you ask? Well, way back, i can remember watching a necro kill freeport guards. He then entertained me for a few minutes while his pet talked to me and he did all kinds of wonderful things ( I had no idea what was going on at that time in the game). Anyway, I instantly logged out and made a necro of course.. and within a few days they patched that weapon speed feature out of the game lol .. It is still one of my best memories from eq when everything was new and magical..

The butcherblock dwarves were a common target as well.. and they dropped a 25pp axe .. I was so envious and couldn't wait to do those things lol

I know how to change the guards hp back in the db .. I even think i have logs from back then lol.

Just looking for a pointer in the right direction or if this is even possible.

Thanks in advance
Reply With Quote
  #2  
Old 01-22-2016, 02:12 PM
Uleat's Avatar
Uleat
Developer
 
Join Date: Apr 2012
Location: North Carolina
Posts: 2,815
Default

I doubt that it was a 'feature' .. but, rather an honest to goodness bug.


There's nothing keeping you from changing combat behavior - or any behavior for that matter - to anything that you wish

That's the whole point of customization!


There is no specific code for necro pet melee combat. All pets (mobs?) share the same basic code.

You would need to add special checks to account for the pet class and (probably) just add an empty-handed damage check to whatever weapon damage is reported.

This is the attack processing code: https://github.com/EQEmu/Server/blob...one/attack.cpp

That would be a good place to start and just follow the calls backwards as needed.


Just remember..unless you explicitly specify to only check for client-owned pets, all pets - including mob-owned - will receive this modifier.
__________________
Uleat of Bertoxxulous

Compilin' Dirty
Reply With Quote
  #3  
Old 01-22-2016, 04:15 PM
Slaymore
Fire Beetle
 
Join Date: Nov 2007
Posts: 21
Default

Thank you so much, Uleat, for pointing me in the right direction. HEHE you caught my use of the word "feature" right away lol

Having said that I think what I was asking about might already be the default .. reading through the attack.cpp i found this:

// 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

This is assuming that pets are using NPC melee code.. I'm sill looking lol

But, taking a look in the database, i see this pet for example:

566 SumAirR16 attack_speed -19 / attack_delay 29

Im not sure what attack_speed -19 does but a quick google and I found a post that said it was no longer used and replaced by attack_delay (not sure if true or not). But according to the comment in the attack.cpp file if i give any weapon to this air pet (or any pet with a attack_delay higher than the weapon delay) with a delay lower than 29 it should use the lower delay of the weapon.

I can honestly say that I never tried it (parsed) lol, and if this is true than it is defiantly not live like for 15 years or so ..

I am totally new to this so if I am way off base here please cut me some slack lol.. Im fragile
Reply With Quote
  #4  
Old 01-26-2016, 12:50 PM
Freshmaker
Fire Beetle
 
Join Date: May 2010
Posts: 5
Default

I've honestly never touched the eqemu codebase before, so everything is still entirely foreign to me.

I'm confident in most of the logic here other than how I attempt to grab the weapon(s) equipped by the pet. Random shot in the dark, untested, likely won't work. But, I can't test this right now.

Code:
diff --git a/zone/attack.cpp b/zone/attack.cpp
index 85ee29e..003acb3 100644
--- a/zone/attack.cpp
+++ b/zone/attack.cpp
@@ -4586,17 +4586,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
@@ -4609,6 +4598,13 @@ void NPC::SetAttackTimer()
 		else	//invalid slot (hands will always hit this)
 			continue;
 
+		const Item_Struct *ItemToUse = nullptr;
+
+		//find our item
+		ServerLootItem_Struct* item_data = GetItem(i);
+		if (item_data)
+			ItemToUse = database.GetItem(item_data->item_id);
+
 		//special offhand stuff
 		if (i == MainSecondary) {
 			// SPECATK_QUAD is uncheesable
@@ -4618,6 +4614,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);
 	}
 }
It at least compiles, but that means little. If you care to give 'er a whirl, let me know. I may be able to test this tonight.
Reply With Quote
  #5  
Old 01-27-2016, 09:54 AM
Freshmaker
Fire Beetle
 
Join Date: May 2010
Posts: 5
Default

As I anticipated, I tested this last night and it doesn't work. Going to need to brush up more on the codebase and, having come from the land of Perl, I'm at a disadvantage. In theory all that needs to be fixed is the correct way of nabbing the pet's equipped weapons to read in their delay. The rest of the logic to only apply it if it's faster and only if it's a Client/PC pet should work. Maybe this weekend I'll try and expand my mind on the eqemu codebase and revisit.

But, should you be more versed in eqemu's codebase, the above should at least give you a great starting point to accomplish what you want.
Reply With Quote
  #6  
Old 01-27-2016, 10:55 AM
image
Demi-God
 
Join Date: Jan 2002
Posts: 1,289
Default

Doing this off the top of my head, but the NPC use-case could be something like this to get the weapon delay:

const Item_Struct* ItemToUse = NULL;
int itemID = CastToNPC()->GetEquipment(MATERIAL_PRIMARY);
if (itemID > 0)
ItemToUse = database.GetItem(itemID);

then you can check if ItemToUse isn't null and use ItemToUse->Delay
__________________
www.eq2emu.com
EQ2Emu Developer
Former EQEMu Developer / GuildWars / Zek Seasons Servers
Member of the "I hate devn00b" club.
Reply With Quote
  #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
  #8  
Old 02-12-2016, 10:38 AM
Slaymore
Fire Beetle
 
Join Date: Nov 2007
Posts: 21
Default

Wow That is awesome thank you so much, Freshmaker!!

lol having said that let me see if I can figure out how to apply this.

So, my directory structure is like so:

:~/eqemu$ ls
bin CMakeLists.txt loginserver ucs
changelog.txt common luabind utils
client_files dependencies Makefile world
cmake eqlaunch queryserv zone
CMakeCache.txt freshmaker_petattackspeed_patch.diff README.md
CMakeFiles GPL.txt shared_memory
cmake_install.cmake LICENSE.md tests


I created the file freshmaker_petattackspeed_patch.diff , pasted in your code.

Now i believe i will need to edit this part of the file:

diff --git a/zone/attack.cpp b/zone/attack.cpp
index 2fdf5f1..9b7a1b9 100644
--- a/zone/attack.cpp
+++ b/zone/attack.cpp

to this:

diff --git freshmaker_petattackspeed_patch.diff /zone/attack.cpp
index 2fdf5f1..9b7a1b9 100644
--- freshmaker_petattackspeed_patch.diff
+++ /zone/attack.cpp

then run:

git apply freshmaker_petattackspeed_patch.diff

then:

make clean
make

How does that look? Am I in the ball park?
Reply With Quote
  #9  
Old 02-12-2016, 12:44 PM
Freshmaker
Fire Beetle
 
Join Date: May 2010
Posts: 5
Default

Without any modification to the snippet, you should just be able to save it and then use "git apply" against it. The diff is against the current master branch of EQEmu as of 2016-02-10, so if you get any chunk failures make sure you're up-to-date against master first.

But yeah, you'e got the right idea.
Reply With Quote
  #10  
Old 02-12-2016, 01:44 PM
demonstar55
Demi-God
 
Join Date: Apr 2008
Location: MA
Posts: 1,165
Default

Early on pets would use the delay of weapons if it was faster. This was patched. (it still works for normal NPCs AFAIK)

Pets damage can actually change if the weapon's base damage is higher than the pets base damage. (this is something we don't support)
Reply With Quote
  #11  
Old 02-12-2016, 02:13 PM
Slaymore
Fire Beetle
 
Join Date: Nov 2007
Posts: 21
Default

Success!! lol thank you so much!

This would have been so OP when it was on live lol.

I logged into my cleric and gave her a red dragon tooth (single use Invoke Death pet)

Gave him a Mosscovered Twig off hand (3/10) and a Revultant Whip (5/14) main hand. No other haste or buffs.

Had him attack the level 65 dummy in the arena.. he missed most of the time but check out this attack spam lol. Zenarer could open up a tattoo parlor

On a side note.. is there a way to see attack delay or haste as a number in GamParse?

Again thank you so much.. now that I see how to do these customizations I will have to give writing some code a try..

[Fri Feb 12 12:46:23 2016] Zenarer tells you, 'Attacking an undead training dummy Master.'
[Fri Feb 12 12:46:23 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:23 2016] Zenarer tries to crush an undead training dummy, but an undead training dummy parries!
[Fri Feb 12 12:46:23 2016] Zenarer tries to kick an undead training dummy, but misses!
[Fri Feb 12 12:46:24 2016] Zenarer tries to crush an undead training dummy, but an undead training dummy dodges!
[Fri Feb 12 12:46:24 2016] Zenarer tries to crush an undead training dummy, but an undead training dummy dodges!
[Fri Feb 12 12:46:24 2016] Zenarer tries to slash an undead training dummy, but an undead training dummy dodges!
[Fri Feb 12 12:46:25 2016] An undead training dummy hits Zenarer for 3 points of damage.
[Fri Feb 12 12:46:25 2016] Zenarer tries to crush an undead training dummy, but an undead training dummy ripostes!
[Fri Feb 12 12:46:26 2016] Zenarer slashes an undead training dummy for 59 points of damage.
[Fri Feb 12 12:46:26 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:27 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:27 2016] Zenarer tries to slash an undead training dummy, but an undead training dummy parries!
[Fri Feb 12 12:46:28 2016] Zenarer tries to crush an undead training dummy, but misses!
[Fri Feb 12 12:46:29 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:29 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:29 2016] Zenarer tries to crush an undead training dummy, but misses!
[Fri Feb 12 12:46:30 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:31 2016] Zenarer tries to crush an undead training dummy, but misses!
[Fri Feb 12 12:46:31 2016] Zenarer tries to kick an undead training dummy, but misses!
[Fri Feb 12 12:46:31 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:31 2016] Zenarer tries to slash an undead training dummy, but an undead training dummy dodges!
[Fri Feb 12 12:46:33 2016] Zenarer tries to crush an undead training dummy, but misses!
[Fri Feb 12 12:46:33 2016] Zenarer tries to crush an undead training dummy, but misses!
[Fri Feb 12 12:46:33 2016] Zenarer slashes an undead training dummy for 55 points of damage.
[Fri Feb 12 12:46:34 2016] Zenarer tries to crush an undead training dummy, but an undead training dummy dodges!
[Fri Feb 12 12:46:34 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:34 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:35 2016] Zenarer tries to crush an undead training dummy, but an undead training dummy dodges!
[Fri Feb 12 12:46:35 2016] Zenarer tries to crush an undead training dummy, but misses!
[Fri Feb 12 12:46:36 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:36 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:37 2016] Zenarer slashes an undead training dummy for 59 points of damage.
[Fri Feb 12 12:46:37 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:38 2016] Zenarer tries to slash an undead training dummy, but an undead training dummy parries!
[Fri Feb 12 12:46:39 2016] Zenarer tries to bash an undead training dummy, but misses!
[Fri Feb 12 12:46:40 2016] Zenarer tries to slash an undead training dummy, but misses!
[Fri Feb 12 12:46:40 2016] Zenarer tries to slash an undead training dummy, but misses!
Reply With Quote
Reply

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 06:35 PM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3