Pārlūkot izejas kodu

- Some optimizations to @noks (now using a Status Change timer).
- Added support to Self|Party|Guild options.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12205 54d463be-8e91-2dee-dedb-b68131a5f0ec

zephyrus 17 gadi atpakaļ
vecāks
revīzija
b8cbeb24b8
5 mainītis faili ar 40 papildinājumiem un 22 dzēšanām
  1. 2 0
      Changelog-Trunk.txt
  2. 18 3
      src/map/atcommand.c
  3. 1 5
      src/map/map.h
  4. 17 14
      src/map/mob.c
  5. 2 0
      src/map/status.h

+ 2 - 0
Changelog-Trunk.txt

@@ -6,6 +6,8 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 2008/02/14
 	* Removed/replaced all calls to map_getallusers (followup to r12195)
 	* Trashed @whozeny (from r269) [ultramage]
+	* Added some changes to @noks. Now it uses a SC and not vars in mob_data [Zephyrus]
+	- Added support to Self|Party|Guild to @noks (default is Party)
 2008/02/13
 	* Changes to memory manager: [FlavioJS]
 	- fixed blocks that are fully used not being detected (and not freed) in 

+ 18 - 3
src/map/atcommand.c

@@ -8140,9 +8140,24 @@ int atcommand_ksprotection(const int fd, struct map_session_data *sd, const char
 	if( sd->state.noks ) {
 		sd->state.noks = 0;
 		sprintf(atcmd_output, "[ K.S Protection Inactive ]");
-	} else {
-		sprintf(atcmd_output, "[ K.S Protection Active ]");
-		sd->state.noks = 1;
+	}
+	else
+	{
+		if( !message || !*message || !strcmpi(message, "party") )
+		{ // Default is Party
+			sd->state.noks = 2;
+			sprintf(atcmd_output, "[ K.S Protection Active - Option: Party ]");
+		}
+		else if( !strcmpi(message, "self") )
+		{
+			sd->state.noks = 1;
+			sprintf(atcmd_output, "[ K.S Protection Active - Option: Self ]");
+		}
+		else if( !strcmpi(message, "guild") )
+		{
+			sd->state.noks = 3;
+			sprintf(atcmd_output, "[ K.S Protection Active - Option: Guild ]");
+		}
 	}
 
 	clif_displaymessage(fd, atcmd_output);

+ 1 - 5
src/map/map.h

@@ -552,7 +552,7 @@ struct map_session_data {
 		unsigned ignoreAll : 1;
 		unsigned short autoloot;
 		unsigned short autolootid; // [Zephyrus]
-		unsigned noks : 1; // [Zeph Kill Steal Protection]
+		unsigned noks : 3; // [Zeph Kill Steal Protection]
 		struct guild *gmaster_flag;
 	} state;
 	struct {
@@ -915,10 +915,6 @@ struct mob_data {
 	int level;
 	int target_id,attacked_id;
 
-	// Kill Steal Protection
-	int owner_id;
-	unsigned int ks_tick;
-	
 	unsigned int next_walktime,last_thinktime,last_linktime;
 	short move_fail_count;
 	short lootitem_count;

+ 17 - 14
src/map/mob.c

@@ -283,6 +283,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target)
 {
 	struct block_list *s_bl;
 	struct map_session_data *sd, *pl_sd;
+	struct status_change_entry *sce;
 	struct mob_data *md;
 	unsigned int tick = gettick();
 	char output[128];
@@ -304,25 +305,28 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target)
 			return false; // Ignores GVG, PVP and AllowKS map flags
 
 		if( md->db->mexp || md->master_id )
-			return false; // MVP and Slaves ignores KS
+			return false; // MVP, Slaves mobs ignores KS
 
-		if( sd->bl.id == md->owner_id )
-			break; // Same player
+		if( (sce = md->sc.data[SC_KSPROTECTED]) == NULL )
+			break; // No KS Protected
 
-		if( !md->owner_id || !(pl_sd = map_id2sd(md->owner_id)) )
-			break; // Not owner or owner offline
+		if( sd->bl.id == sce->val1 )
+			break; // Same Player
 
-		if( pl_sd->bl.m != md->bl.m )
-			break; // Owner on different map
+		if( !(pl_sd = map_id2sd(sce->val1)) )
+			break; // Owner offline
 
-		if( DIFF_TICK(md->ks_tick, tick) <= 0 )
-			break; // Protection Time's Out
+		if( pl_sd->bl.m != md->bl.m )
+			break; // Protection expires on different map
 
 		if( !pl_sd->state.noks )
-			return false; // No KS Protected, but this is necessary to protect normal players
+			return false; // No KS Protected, but normal players should be protected too
+
+		if( pl_sd->state.noks == 2 && pl_sd->status.party_id && pl_sd->status.party_id == sd->status.party_id )
+			break; // Party KS allowed
 
-		if( pl_sd->status.party_id && pl_sd->status.party_id == sd->status.party_id )
-			break; // Same Party Allow KS
+		if( pl_sd->state.noks == 3 && pl_sd->status.guild_id && pl_sd->status.guild_id == sd->status.guild_id )
+			break; // Guild KS allowed
 
 		// Message to KS
 		if( DIFF_TICK(sd->ks_floodprotect_tick, tick) <= 0 )
@@ -345,8 +349,7 @@ bool mob_ksprotected (struct block_list *src, struct block_list *target)
 		return true;
 	} while(0);
 
-	md->owner_id = sd->bl.id;
-	md->ks_tick = tick + battle_config.ksprotection;
+	status_change_start(target, SC_KSPROTECTED, 10000, sd->bl.id, 0, 0, 0, battle_config.ksprotection, 0);
 
 	return false;
 }

+ 2 - 0
src/map/status.h

@@ -284,6 +284,8 @@ enum sc_type {
 	SC_HPREGEN,
 	SC_INCHEALRATE,
 	SC_PNEUMA,
+	SC_AUTOTRADE,
+	SC_KSPROTECTED,
 	SC_MAX, //Automatically updated max, used in for's to check we are within bounds.
 };
 int SkillStatusChangeTable(int skill);