Page 2 of 2

Re: PVP

Posted: Fri May 14, 2010 12:04 pm
by bolly
I'd rather keep up with your svn tbh. The plan is to be exactly the same as Tess but add in PVP code changes so you content guys can get some additional bug feedback.

Here's the diff:

Code: Select all

diff -rupN world/Combat.cpp world_new/Combat.cpp
--- world/Combat.cpp	Fri May 14 19:59:50 2010
+++ world_new/Combat.cpp	Fri May 14 19:51:13 2010
@@ -32,6 +32,7 @@ extern Classes classes;
 extern ConfigReader configReader;
 extern EQEMuLog* LogFile;
 extern MasterSkillList master_skill_list;
+extern Variables variables;
 
 Combat::Combat(ZoneServer* in_zone){
 	shutdown = false;
@@ -464,11 +465,44 @@ bool Combat::SecondaryWeaponReady(Entity
 }
 
 bool Combat::AttackAllowed(Entity* attacker, Spawn* victim, bool calculate_distance, bool range_attack){
+	Variable* var = variables.FindVariable("server_type");
+	if (var)
+	{
+		sint16 ServerType = atoi(var->GetValue());
+		switch(ServerType)
+		{
+			case 2:
+				// can only attack different starting city players
+				if (attacker->IsPlayer() && victim->IsPlayer())
+				{
+					if (((Player*)attacker)->GetPlayerInfo()->GetStartingCity() == ((Player*)victim)->GetPlayerInfo()->GetStartingCity())
+					{
+						// same starting city so can't attack
+						return false;
+					}
+				}
+				break;
+			case 1:
+				// can only attack diff race
+				if (attacker->IsPlayer() && victim->IsPlayer() && (attacker->GetRace() == victim->GetRace()))
+				{
+					return false;
+				}
+				break;
+				// normal operation
+			default:
+				if((attacker->IsPlayer() && victim->appearance.attackable == 0) || (attacker->IsPlayer() && victim->IsPlayer()))
+				return false;
+		}
+	} else {
+		// normal operation (variable table entry missing)
+		if((attacker->IsPlayer() && victim->appearance.attackable == 0) || (attacker->IsPlayer() && victim->IsPlayer()))
+			return false;
+	}
+	
 	if(!attacker || !victim || attacker->IsMezzedOrStunned() || attacker->IsDazed())
 		return false;
-	if((attacker->IsPlayer() && victim->appearance.attackable == 0) || (attacker->IsPlayer() && victim->IsPlayer()))
-		return false;
-	else if(victim->GetHP() == 0)
+	if(victim->GetHP() == 0)
 		return false;
 	else if(calculate_distance){
 		float distance = attacker->GetDistance(victim);
diff -rupN world/Player.cpp world_new/Player.cpp
--- world/Player.cpp	Fri May 14 19:59:50 2010
+++ world_new/Player.cpp	Fri May 14 19:47:39 2010
@@ -178,6 +178,11 @@ void PlayerInfo::SetBindZone(int32 id){
 	bind_zone_id = id;
 }
 
+void PlayerInfo::SetStartingCity(int32 id)
+{
+	starting_city = id;
+}
+
 void PlayerInfo::SetBindX(float x){
 	bind_x = x;
 }
@@ -202,6 +207,10 @@ int32 PlayerInfo::GetBindZoneID(){
 	return bind_zone_id;
 }
 
+int32 PlayerInfo::GetStartingCity(){
+	return starting_city;
+}
+
 float PlayerInfo::GetBindZoneX(){
 	return bind_x;
 }
@@ -1415,6 +1424,7 @@ PlayerInfo::PlayerInfo(Player* in_player
 	}
 	house_zone_id = 0;
 	bind_zone_id = 0;
+	starting_city = 0;
 	bind_x = 0;
 	bind_y = 0;
 	bind_z = 0;
diff -rupN world/Player.h world_new/Player.h
--- world/Player.h	Fri May 14 19:59:50 2010
+++ world_new/Player.h	Fri May 14 19:55:19 2010
@@ -250,6 +250,7 @@ public:
 	EQ2Packet* serialize3(PacketStruct* packet, int16 version);
 	void CalculateXPPercentages();
 	void SetHouseZone(int32 id);
+	void SetStartingCity(int32 id);
 	void SetBindZone(int32 id);
 	void SetBindX(float x);
 	void SetBindY(float y);
@@ -258,6 +259,7 @@ public:
 	void SetAccountAge(int8 days);
 	int32 GetHouseZoneID();
 	int32 GetBindZoneID();
+	int32 GetStartingCity();
 	float GetBindZoneX();
 	float GetBindZoneY();
 	float GetBindZoneZ();
@@ -270,6 +272,7 @@ private:
 	float			bind_y;
 	float			bind_z;
 	float			bind_heading;
+	int32			starting_city;
 	uchar*			changes;
 	uchar*			orig_packet;
 	InfoStruct*		info_struct;
diff -rupN world/SpellProcess.cpp world_new/SpellProcess.cpp
--- world/SpellProcess.cpp	Fri May 14 19:59:50 2010
+++ world_new/SpellProcess.cpp	Fri May 14 19:51:14 2010
@@ -22,6 +22,7 @@ extern MasterSpellList master_spell_list
 extern ConfigReader configReader;
 extern LuaInterface* lua_interface;
 extern Commands commands;
+extern Variables variables;
 
 SpellProcess::SpellProcess(){
 	last_checked_time = 0;
@@ -594,9 +595,45 @@ void SpellProcess::ProcessSpell(ZoneServ
 					zone->SendSpellFailedPacket(client, SPELL_ERROR_TARGET_INVULNERABLE);
 					return;
 				}
-				if (target->IsPlayer() && caster->IsPlayer()) {
-					zone->SendSpellFailedPacket(client, SPELL_ERROR_NOT_AN_ENEMY);
-					return;
+
+				Variable* var = variables.FindVariable("server_type");
+				if (var)
+				{
+					sint16 ServerType = atoi(var->GetValue());
+					switch(ServerType)
+					{
+						case 2:
+							// can only attack different starting city players
+							if (caster->IsPlayer() && target->IsPlayer())
+							{
+								if (((Player*)caster)->GetPlayerInfo()->GetStartingCity() == ((Player*)target)->GetPlayerInfo()->GetStartingCity())
+								{
+									// same starting city so can't attack
+									return;
+								}
+							}
+							break;
+						case 1:
+							// can only attack diff race
+							if (caster->IsPlayer() && target->IsPlayer() && (caster->GetRace() == target->GetRace()))
+							{
+								return;
+							}
+							break;
+							// normal operation
+						default:
+							// normal operation (variable table entry missing)
+							if (target->IsPlayer() && caster->IsPlayer()) {
+								zone->SendSpellFailedPacket(client, SPELL_ERROR_NOT_AN_ENEMY);
+								return;
+							}
+					}
+				} else {
+					// normal operation (variable table entry missing)
+					if (target->IsPlayer() && caster->IsPlayer()) {
+						zone->SendSpellFailedPacket(client, SPELL_ERROR_NOT_AN_ENEMY);
+						return;
+					}
 				}
 			}
 		}
diff -rupN world/WorldDatabase.cpp world_new/WorldDatabase.cpp
--- world/WorldDatabase.cpp	Fri May 14 19:59:50 2010
+++ world_new/WorldDatabase.cpp	Fri May 14 19:50:36 2010
@@ -1697,7 +1697,7 @@ bool WorldDatabase::loadCharacter(const 
 	MYSQL_ROW row, row4;
 	int32 id = 0;
 	query.escaped_name = getEscapeString(ch_name);
-	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT id, current_zone_id, x, y, z, heading, admin_status, race, model_type, class, deity, level, gender, tradeskill_level, wing_type, hair_type, chest_type, legs_type, soga_wing_type, soga_hair_type, soga_chest_type, soga_legs_type, 0xFFFFFFFF - crc32(name), facial_hair_type, soga_facial_hair_type,instance_id,last_saved, DATEDIFF(curdate(), created_date) as accage from characters where name='%s' and account_id=%i", query.escaped_name, account_id);
+	MYSQL_RES* result = query.RunQuery2(Q_SELECT, "SELECT id, current_zone_id, x, y, z, heading, admin_status, race, model_type, class, deity, level, gender, tradeskill_level, wing_type, hair_type, chest_type, legs_type, soga_wing_type, soga_hair_type, soga_chest_type, soga_legs_type, 0xFFFFFFFF - crc32(name), facial_hair_type, soga_facial_hair_type,instance_id,last_saved, DATEDIFF(curdate(), created_date) as accage, starting_city from characters where name='%s' and account_id=%i", query.escaped_name, account_id);
 	// no character found
 	if(result == NULL)
 		return false;
@@ -1744,7 +1744,8 @@ bool WorldDatabase::loadCharacter(const 
 		else
 			client->SetCurrentZone(zoneid);
 
-
+		// Save the starting city to so we can query it for pvp and call of qeynos etc
+		client->GetPlayer()->GetPlayerInfo()->SetStartingCity(atoi(row[28]));
 
 		int32 lastsavedtime = atoi(row[26]);
 		client->SetLastSavedTimeStamp(lastsavedtime);

Re: PVP

Posted: Fri May 14, 2010 12:25 pm
by bolly
i just checked out your latest svn and manually made changes and created the diff above so it should go in easily

hopefully i didn't forget to add anything!

Re: PVP

Posted: Fri May 14, 2010 12:30 pm
by John Adams
Right on, I'll see about checking it out this weekend. Scat is our main Dev dude tho, and he's afk for the week. When he gives the ok, I'll add the config to the variables table for all.

Thanks for the code bump!


For the record, if my server type is PVE, it functions exactly the same as it does now - before this change, right?

Re: PVP

Posted: Fri May 14, 2010 12:41 pm
by bolly
yeah or if the variable isn't defined it will fall back on pve

Re: PVP

Posted: Sun May 23, 2010 4:30 pm
by Scatman
This looks fine. If you want to put the variable into the database we can check this in.