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

Development::Development Forum for development topics and for those interested in EQEMu development. (Not a support forum)

Reply
 
Thread Tools Display Modes
  #1  
Old 07-08-2006, 12:51 PM
unicorn97211
Sarnak
 
Join Date: May 2006
Posts: 37
Default Lull,Alliance,Mem Blur - Spell/Song Line Fix/Implementation

This fix allows the following spells/songs to take affect on NPCs.

Wake of Tranquility
Lull Animal
Calm Animal
Numb the Dead
Rest the Dead
Pacify
Calm
Benevolence
Lull
Alliance
Soothe
Collaboration
Pacification
Harmony of Nature
Placate
Nature's Serenity
Placate

Beholder Dispel
Strip Enchantment
Pillage Enchantment
Nullify Magic
Annul Magic
Recant Magic
Recant Magic
SpellTheft1
SpellTheft2
SpellTheft3
Nature Veil
Omen-Bst-PH
Devour Enchantment

Mind Wipe
Blanket of Forgetfulness
Reoccurring Amnesia
Memory Blur
Atone
Guide Memory Blur
Guide Memory Blur
Memory Flux

Cinda`s Charismatic Carillon
Kelin`s Lugubrious Lament
Silent Song of Quellious
Luvwen's Aria of Serenity

The current code considers these spells/songs beneficial and won't allow them to be cast on NPCs.

Here is the Diff:
Code:
--- E:\EQEmu815\zone\spdat.cpp	Sat Feb 26 14:39:14 2005
+++ C:\EQEmuSP\Source\0.7.0\zone\spdat.cpp	Sat Jul 08 16:52:11 2006
@@ -208,6 +208,17 @@
 
 bool IsBeneficialSpell(int16 spell_id)
 {
+	// EverHood - These spells are actually detrimental
+	if(spells[spell_id].goodEffect == 1){
+		SpellTargetType tt = spells[spell_id].targettype;
+		if(tt == ST_Target || tt == ST_AETarget || tt == ST_Animal || tt == ST_Undead)
+			if(spells[spell_id].resisttype == 1){
+				int16 sai = spells[spell_id].SpellAffectIndex;
+				// 12 = Lulls & Alliances , 14 = Dispells, 27 = Mem Blurs, 43 = Bard Lull Alliance Blur etc songs
+				if(sai == 12 || sai == 14 || sai == 27 || sai == 43) // Lulls,Dispells,Mem Blurs,Songs
+					return false;
+			}
+	}
 	return spells[spell_id].goodEffect != 0 || IsGroupSpell(spell_id);
 }
After implementing the above fix and doing some testing I found that the Alliance line was not implemented yet so I went ahead and did that as well.

Here is the Diff:
Code:
--- E:\EQEmu815\zone\spell_effects.cpp	Tue Jul 04 09:33:18 2006
+++ C:\EQEmuSP\Source\0.7.0\zone\spell_effects.cpp	Sat Jul 08 16:55:14 2006
@@ -375,9 +375,13 @@
 #ifdef SPELL_EFFECT_SPAM
 				snprintf(effect_desc, _EDLEN, "Faction Mod: %+i", effect_value);
 #endif
-				// solar: TODO implement this
-				const char *msg = "Faction Mod is not implemented.";
-				if(caster) caster->Message(13, msg);
+				// EverHood 
+				if(caster && GetPrimaryFaction()>0) {
+                    NPCFaction* target_faction = new struct NPCFaction;
+					target_faction->factionID = GetPrimaryFaction();
+					target_faction->value_mod = spell.base[0];
+					caster->AddFactionBonus(target_faction);
+				}
 				break;
 			}
 
--- E:\EQEmu815\zone\mob.h	Tue Jul 04 09:33:18 2006
+++ C:\EQEmuSP\Source\0.7.0\zone\mob.h	Sat Jul 08 13:44:10 2006
@@ -696,7 +696,11 @@
 	void				AddFeignMemory(Client* attacker);
 	void				RemoveFromFeignMemory(Client* attacker);
 	void				ClearFeignMemory();
-
+	// EverHood - This is to keep track of mobs we cast faction mod spells on
+	void				AddFactionBonus(NPCFaction* FactionBonus);
+	sint32				GetFactionBonus(sint32 pFaction);
+	void				RemoveFactionBonus(NPCFaction* FactionBonus);
+	void				ClearFactionBonuses();
 	
 	int					GetCurWp(){ return cur_wp; }
 #ifdef ENABLE_FEAR_PATHING
@@ -946,7 +950,15 @@
 	AISpells_Struct	AIspells[MAX_AISPELLS]; // expected to be pre-sorted, best at low index
 	HateList hate_list;
 	std::set<int32> feign_memory_list;
-	
+	// EverHood - Faction Bonuses
+	struct lessNPCFaction
+	{
+	bool operator()(NPCFaction s1, NPCFaction s2) const
+	{
+		return (s1.factionID<s2.factionID);
+	}
+	};
+    std::set<NPCFaction, lessNPCFaction > faction_bonuses;
 	
 #ifdef ENABLE_FEAR_PATHING
 	void CalculateFearPosition();
--- E:\EQEmu815\zone\faction.cpp	Fri May 12 19:35:58 2006
+++ C:\EQEmuSP\Source\0.7.0\zone\faction.cpp	Sat Jul 08 16:42:51 2006
@@ -264,6 +264,39 @@
 	return(CheckNPCFactionAlly(other_faction) == FACTION_ALLY);
 }
 
+// EverHood - Faction Mods for Alliance type spells
+void Mob::AddFactionBonus(NPCFaction* FactionBonus) {
+	std::set<NPCFaction, lessNPCFaction >::value_type faction_bonuses_value_type;
+	faction_bonuses_value_type.factionID = FactionBonus->factionID;
+	faction_bonuses_value_type.value_mod = FactionBonus->value_mod;
+	faction_bonuses.insert(faction_bonuses_value_type);
+}
+
+sint32 Mob::GetFactionBonus(sint32 pFaction) {
+	std::set<NPCFaction, lessNPCFaction >::iterator faction_bonus;
+	faction_bonus = faction_bonuses.begin();
+	while(faction_bonus != faction_bonuses.end()) {
+		if ((*faction_bonus).factionID == pFaction) 
+		{
+			return (*faction_bonus).value_mod;
+		} else {
+			faction_bonus++;
+		}
+	}
+	return 0;
+}
+
+void Mob::RemoveFactionBonus(NPCFaction* FactionBonus) {
+	std::set<NPCFaction, lessNPCFaction >::value_type faction_bonuses_value_type;
+	faction_bonuses_value_type.factionID = FactionBonus->factionID;
+	faction_bonuses_value_type.value_mod = FactionBonus->value_mod;
+	faction_bonuses.erase(faction_bonuses_value_type);
+}
+
+void Mob::ClearFactionBonuses() {
+	faction_bonuses.clear();
+}
+
 FACTION_VALUE Mob::GetSpecialFactionCon(Mob* iOther) {
 #if FACTIONS_DEBUG >= 5
 	LogFile->write(EQEMuLog::Debug, "called $s::GetSpecialFactionCon(%s)", GetName(), iOther->GetName());
@@ -431,6 +464,8 @@
 		{
 			//Get the players current faction with pFaction
 			tmpFactionValue = GetCharacterFactionLevel(pFaction);
+			// Everhood - tack on any bonuses from Alliance type spell effects
+			tmpFactionValue += GetFactionBonus(pFaction);
 			//Return the faction to the client
 			fac = CalculateFaction(&fmods, tmpFactionValue);
 			//Message(0,"Faction: %i %i %i %i",fmods.base,fmods.class_mod,fmods.race_mod,fmods.deity_mod);
--- E:\EQEmu815\zone\zoning.cpp	Sat Jul 08 18:33:22 2006
+++ C:\EQEmuSP\Source\0.7.0\zone\zoning.cpp	Sat Jul 08 14:25:32 2006
@@ -365,6 +365,8 @@
 	
 	//if we are actually going to zone...
 	if (zoneID != zone->GetZoneID()) {
+		// EverHood - Clear faction bonuses
+		ClearFactionBonuses();
 		//set up our accounting vars to be ready to zone
 		zone_mode = zm;
 		zonesummon_ignorerestrictions = ignorerestrictions;
I don't really know enough about playing a bard to test any of the songs so if someone could test that and let me know, that would be great
Reply With Quote
  #2  
Old 07-09-2006, 07:47 AM
fathernitwit
Developer
 
Join Date: Jul 2004
Posts: 773
Default

Few comments:
- I think it would be better to use a map<faction ID, mod amount> instead of your set<NPCFaction> structure. This would avoid your need for the functor and should make the manipulation functions more straight forward (get becomes a find), further it avoids memory management on our part.
- You need to make sure you implement the "buff fade" side of it, otherwise the effects will be permanent. Mob::BuffFadeBySlot
- Please make an enum for the various meanings of of SpellAffectIndex in spdat.h instead of putting constants directly in the code.
- Im not sure I understand why you call ClearFactionBonuses in the zone code... I dont think theres ever any need to call that function
Reply With Quote
  #3  
Old 07-09-2006, 08:04 AM
unicorn97211
Sarnak
 
Join Date: May 2006
Posts: 37
Default

I'll look at using the map class instead of set, that sounds better from what you say, I was hoping you'd suggest something easier than what I did

I'm a bit unclear what you mean by the buff fade side of things. The lull line is the only one that actually puts a buff on a mob and it does fade fine. I get a message in game telling me when Pacify for example wears off. The mem blur line doesn't use a buff slot. The alliance line is active until you zone there is no buff to fade in that case. That is why I stuck the ClearFactionBonuses call in the zone code.

Get back to me and I'll make adjustments as needed. I'll work on rewriting with the MAP class instead of SET and adding the SpellAffectIndex Enum in the mean time.
Reply With Quote
  #4  
Old 07-09-2006, 08:16 AM
fathernitwit
Developer
 
Join Date: Jul 2004
Posts: 773
Default

the buff is fading fine, but the effect would not. Any spell effect applied for a buff which is not just added to spell_bonuses has to be removed in FadeBuff. However, it actually looks like the Pacify spell effect (SE_Lull) is not even implemented. But if it were, it would need to be faded when the buff wears off.

Given that the faction mod stuff is not a buff, does it stack if the spell is cast again?

Either way, dont worry about clearing the faction mods when they zone, their Client object will get destroyed soon after and they will clear anyways.

you should come to #support on IRC, a lot easier to talk.
Reply With Quote
  #5  
Old 07-09-2006, 07:21 PM
unicorn97211
Sarnak
 
Join Date: May 2006
Posts: 37
Default

Made the changes you recommended, I think

Here's the diff

Code:
--- E:\EQEmu815\zone\mob.h	Mon Jul 10 00:55:03 2006
+++ C:\EQEmuSP\Source\0.7.0\zone\mob.h	Mon Jul 10 00:54:58 2006
@@ -945,8 +945,10 @@
 	AISpells_Struct	AIspells[MAX_AISPELLS]; // expected to be pre-sorted, best at low index
 	HateList hate_list;
 	std::set<int32> feign_memory_list;
-	
-	
+	// EverHood - This is to keep track of mobs we cast faction mod spells on
+	std::map<uint32,sint32> faction_bonuses; // Primary FactionID, Bonus
+	void	AddFactionBonus(uint32 pFactionID,sint32 bonus);
+	sint32	GetFactionBonus(uint32 pFactionID);
 #ifdef ENABLE_FEAR_PATHING
 	void CalculateFearPosition();
 	bool FearTryStraight(Mob *caster, int32 duration, bool flee, VERTEX &hit, VERTEX &fv);
--- E:\EQEmu815\zone\spdat.h	Tue Jul 04 09:33:18 2006
+++ C:\EQEmuSP\Source\0.7.0\zone\spdat.h	Sun Jul 09 23:24:17 2006
@@ -41,6 +41,12 @@
 
 #define EFFECT_COUNT 12
 
+enum SpellAffectIndex {
+	SAI_Calm			= 12, // Lull and Alliance Spells
+	SAI_Dispell			= 14,
+	SAI_Memory_Blur		= 27,
+	SAI_Calm_Song		= 43  // Lull and Alliance Songs
+};
 enum RESISTTYPE
 {
 	RESIST_NONE = 0,
--- E:\EQEmu815\zone\spell_effects.cpp	Tue Jul 04 09:33:18 2006
+++ C:\EQEmuSP\Source\0.7.0\zone\spell_effects.cpp	Sun Jul 09 23:57:17 2006
@@ -375,9 +375,10 @@
 #ifdef SPELL_EFFECT_SPAM
 				snprintf(effect_desc, _EDLEN, "Faction Mod: %+i", effect_value);
 #endif
-				// solar: TODO implement this
-				const char *msg = "Faction Mod is not implemented.";
-				if(caster) caster->Message(13, msg);
+				// EverHood 
+				if(caster && GetPrimaryFaction()>0) {
+					caster->AddFactionBonus(GetPrimaryFaction(),spell.base[0]);
+				}
 				break;
 			}
 
--- E:\EQEmu815\zone\faction.cpp	Fri May 12 19:35:58 2006
+++ C:\EQEmuSP\Source\0.7.0\zone\faction.cpp	Mon Jul 10 00:38:49 2006
@@ -264,6 +264,32 @@
 	return(CheckNPCFactionAlly(other_faction) == FACTION_ALLY);
 }
 
+// EverHood - Faction Mods for Alliance type spells
+void Mob::AddFactionBonus(uint32 pFactionID,sint32 bonus) {
+    map <uint32, sint32> :: const_iterator faction_bonus;
+	typedef std::pair <uint32, sint32> NewFactionBonus;
+
+	faction_bonus = faction_bonuses.find(pFactionID);
+	if(faction_bonus == faction_bonuses.end()){
+		faction_bonuses.insert(NewFactionBonus(pFactionID,bonus));
+	}else{
+		if(faction_bonus->second<bonus){
+			faction_bonuses.erase(pFactionID);
+			faction_bonuses.insert(NewFactionBonus(pFactionID,bonus));
+		}
+	}
+}
+
+sint32 Mob::GetFactionBonus(uint32 pFactionID) {
+    map <uint32, sint32> :: const_iterator faction_bonus;
+	faction_bonus = faction_bonuses.find(pFactionID);
+	if(faction_bonus != faction_bonuses.end()){
+			return (*faction_bonus).second;
+	}
+	return 0;
+}
+
+
 FACTION_VALUE Mob::GetSpecialFactionCon(Mob* iOther) {
 #if FACTIONS_DEBUG >= 5
 	LogFile->write(EQEMuLog::Debug, "called $s::GetSpecialFactionCon(%s)", GetName(), iOther->GetName());
@@ -431,6 +457,8 @@
 		{
 			//Get the players current faction with pFaction
 			tmpFactionValue = GetCharacterFactionLevel(pFaction);
+			// Everhood - tack on any bonuses from Alliance type spell effects
+			tmpFactionValue += GetFactionBonus(pFaction);
 			//Return the faction to the client
 			fac = CalculateFaction(&fmods, tmpFactionValue);
 			//Message(0,"Faction: %i %i %i %i",fmods.base,fmods.class_mod,fmods.race_mod,fmods.deity_mod);
--- E:\EQEmu815\zone\spdat.cpp	Sat Feb 26 14:39:14 2005
+++ C:\EQEmuSP\Source\0.7.0\zone\spdat.cpp	Sun Jul 09 23:24:18 2006
@@ -208,6 +208,16 @@
 
 bool IsBeneficialSpell(int16 spell_id)
 {
+	// EverHood - These spells are actually detrimental
+	if(spells[spell_id].goodEffect == 1){
+		SpellTargetType tt = spells[spell_id].targettype;
+		if(tt == ST_Target || tt == ST_AETarget || tt == ST_Animal || tt == ST_Undead)
+			if(spells[spell_id].resisttype == RESIST_MAGIC){
+				int16 sai = spells[spell_id].SpellAffectIndex;
+				if(sai == SAI_Calm || sai == SAI_Dispell || sai == SAI_Memory_Blur || sai == SAI_Calm_Song)
+					return false;
+			}
+	}
 	return spells[spell_id].goodEffect != 0 || IsGroupSpell(spell_id);
 }
Reply With Quote
Reply


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 12:52 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