Sfoglia il codice sorgente

SetInfoStructUInt(NPC, friendly_target_npc, 1) will allow casting friendly spells on NPC

Emagi 1 anno fa
parent
commit
b478cdb300

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

@@ -335,6 +335,8 @@ void Entity::MapInfoStruct()
 	get_int8_funcs["override_primary_weapon"] = l::bind(&InfoStruct::get_override_primary_weapon, &info_struct);
 	get_int8_funcs["override_secondary_weapon"] = l::bind(&InfoStruct::get_override_secondary_weapon, &info_struct);
 	get_int8_funcs["override_ranged_weapon"] = l::bind(&InfoStruct::get_override_ranged_weapon, &info_struct);
+	
+	get_int8_funcs["friendly_target_npc"] = l::bind(&InfoStruct::get_friendly_target_npc, &info_struct);
 
 /** SETS **/
 	set_string_funcs["name"] = l::bind(&InfoStruct::set_name, &info_struct, l::_1);
@@ -515,6 +517,8 @@ void Entity::MapInfoStruct()
 	set_int8_funcs["override_primary_weapon"] = l::bind(&InfoStruct::set_override_primary_weapon, &info_struct, l::_1);
 	set_int8_funcs["override_secondary_weapon"] = l::bind(&InfoStruct::set_override_secondary_weapon, &info_struct, l::_1);
 	set_int8_funcs["override_ranged_weapon"] = l::bind(&InfoStruct::set_override_ranged_weapon, &info_struct, l::_1);
+	
+	set_int8_funcs["friendly_target_npc"] = l::bind(&InfoStruct::set_friendly_target_npc, &info_struct, l::_1);
 }
 
 bool Entity::HasMoved(bool include_heading){

+ 10 - 2
EQ2/source/WorldServer/Entity.h

@@ -270,6 +270,8 @@ struct InfoStruct{
 		override_primary_weapon_ = 0;
 		override_secondary_weapon_ = 0;
 		override_ranged_weapon_ = 0;
+		
+		friendly_target_npc_ = 0;
 	}
 
 
@@ -452,6 +454,7 @@ struct InfoStruct{
 		override_primary_weapon_ = oldStruct->get_override_primary_weapon();
 		override_secondary_weapon_ = oldStruct->get_override_secondary_weapon();
 		override_ranged_weapon_ = oldStruct->get_override_ranged_weapon();
+		friendly_target_npc_ = oldStruct->get_friendly_target_npc();
 
 	}
 	//mutable std::shared_mutex mutex_;
@@ -650,7 +653,10 @@ struct InfoStruct{
 	int8	get_override_primary_weapon() { std::lock_guard<std::mutex> lk(classMutex); return override_primary_weapon_; }
 	int8	get_override_secondary_weapon() { std::lock_guard<std::mutex> lk(classMutex); return override_secondary_weapon_; }
 	int8	get_override_ranged_weapon() { std::lock_guard<std::mutex> lk(classMutex); return override_ranged_weapon_; }
-
+	
+	int8	get_friendly_target_npc() { std::lock_guard<std::mutex> lk(classMutex); return friendly_target_npc_; }
+	
+	
 	void	set_name(std::string value) { std::lock_guard<std::mutex> lk(classMutex); name_ = value; }
 	
 	void	set_deity(std::string value) { std::lock_guard<std::mutex> lk(classMutex); deity_ = value; }
@@ -932,7 +938,7 @@ struct InfoStruct{
 	void	set_override_primary_weapon(int8 value) { std::lock_guard<std::mutex> lk(classMutex); override_secondary_weapon_ = value; }
 	void	set_override_secondary_weapon(int8 value) { std::lock_guard<std::mutex> lk(classMutex); override_secondary_weapon_ = value; }
 	void	set_override_ranged_weapon(int8 value) { std::lock_guard<std::mutex> lk(classMutex); override_ranged_weapon_ = value; }
-	
+	void	set_friendly_target_npc(int8 value) { std::lock_guard<std::mutex> lk(classMutex); friendly_target_npc_ = value; }
 	void	ResetEffects(Spawn* spawn)
 	{
 		for(int i=0;i<45;i++){
@@ -1132,6 +1138,8 @@ private:
 	int8			override_secondary_weapon_;
 	int8			override_ranged_weapon_;
 	
+	int8			friendly_target_npc_;
+	
 	// when PacketStruct is fixed for C++17 this should become a shared_mutex and handle read/write lock
 	std::mutex		classMutex;
 };

+ 6 - 3
EQ2/source/WorldServer/SpellProcess.cpp

@@ -1298,6 +1298,9 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
 						return;
 					}
 				}
+				else if(((Entity*)target)->GetInfoStruct()->get_friendly_target_npc()) {
+					// it's a bypass!
+				}
 				else if (target->IsBot() && (caster->IsPlayer() || caster->IsBot())) {
 					// Needed so bots or player can cast friendly spells on bots
 				}
@@ -2029,7 +2032,7 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
 					// check if spell is friendly
 					if (data->friendly_spell) {
 						//if target is NPC (and not a bot) on friendly spell, check to see if target is friendly
-						if (target->IsNPC() && !target->IsBot()) {
+						if (target->IsNPC() && !((Entity*)target)->GetInfoStruct()->get_friendly_target_npc() && !target->IsBot()) {
 							if (!target->IsPet() || (target->IsPet() && ((NPC*)target)->GetOwner()->IsNPC())) {
 								if (secondary_target && secondary_target->IsPlayer()) {
 									target = secondary_target;
@@ -2079,7 +2082,7 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
 			else if (caster->IsPlayer()) {
 				if (data->friendly_spell) {
 					if (target->IsNPC() && !target->IsBot()) {
-						if (!target->IsPet() || (target->IsPet() && ((NPC*)target)->GetOwner()->IsNPC())) {
+						if (!((Entity*)target)->GetInfoStruct()->get_friendly_target_npc() && (!target->IsPet() || (target->IsPet() && ((NPC*)target)->GetOwner()->IsNPC()))) {
 							target = caster;
 							luaspell->initial_target = caster->GetID();
 							luaspell->initial_target_char_id = (caster && caster->IsPlayer()) ? ((Player*)caster)->GetCharacterID() : 0;
@@ -2308,7 +2311,7 @@ void SpellProcess::GetSpellTargets(LuaSpell* luaspell)
 						else
 							AddLuaSpellTarget(luaspell, caster->GetID(), false); // else return the caster
 					}
-					else if (target->IsPlayer() || target->IsBot()) // else it is not raid, group only or group spell
+					else if (target->IsPlayer() || target->IsBot() || (target->IsNPC() && ((Entity*)target)->GetInfoStruct()->get_friendly_target_npc())) // else it is not raid, group only or group spell
 						AddLuaSpellTarget(luaspell, target->GetID(), false); // return target for single spell
 					else if ((luaspell->targets.size() < 1) || (!target->IsPet() || (((Entity*)target)->GetOwner() && !((Entity*)target)->GetOwner()->IsPlayer()))) 
 						AddLuaSpellTarget(luaspell, caster->GetID(), false); // and if no target, cast on self