Переглянути джерело

- Added pc_bonus_autospell_del, gives support for removing autospell effects. When a negative rate is specified, it will decrease the chance of casting (eg: You have two different cards with autospell Heal +20% each, then do autospell -30. The second card will be cancelled, and the first one will become Heal +10%)
- npc_timers now will not restore the previous timer data when there's no players attached (when it's strictly an npc timer). This should reenable the old behaviour of getnpctimer returning the total ellapsed time since "startnpctimer" even after the last label has been reached. However, this behaviour won't apply to player-attached timers.


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

skotlex 19 роки тому
батько
коміт
44b40f087c
3 змінених файлів з 42 додано та 4 видалено
  1. 10 0
      Changelog-Trunk.txt
  2. 6 4
      src/map/npc.c
  3. 26 0
      src/map/pc.c

+ 10 - 0
Changelog-Trunk.txt

@@ -4,6 +4,16 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/06/23
+	* Added pc_bonus_autospell_del, gives support for removing autospell
+	  effects. When a negative rate is specified, it will decrease the chance of
+	  casting (eg: You have two different cards with autospell Heal +20% each,
+	  then do autospell -30. The second card will be cancelled, and the first one
+	  will become Heal +10%) [Skotlex]
+	* npc_timers now will not restore the previous timer data when there's no
+	  players attached (when it's strictly an npc timer). This should reenable
+	  the old behaviour of getnpctimer returning the total ellapsed time since
+	  "startnpctimer" even after the last label has been reached. However, this
+	  behaviour won't apply to player-attached timers.  [Skotlex]
 	* [Fixed]:
 	  - MAPREGSQL overloading SQL table with temperory map registries.
 	  - Incorrect perfomance calculation for MAPREGSQL loading and saving. [Lance]

+ 6 - 4
src/map/npc.c

@@ -634,10 +634,12 @@ int npc_timerevent(int tid,unsigned int tick,int id,int data)
 		ers_free(timer_event_ers, ted);
 	}
 	run_script(nd->u.scr.script,te->pos,nd->u.scr.rid,nd->bl.id);
-	//Restore previous data.
-	nd->u.scr.rid = old_rid;
-	nd->u.scr.timer = old_timer;
-	nd->u.scr.timertick = old_tick;
+	//Restore previous data, only if this timer is a player-attached one.
+	if (sd) {
+		nd->u.scr.rid = old_rid;
+		nd->u.scr.timer = old_timer;
+		nd->u.scr.timertick = old_tick;
+	}
 	return 0;
 }
 /*==========================================

+ 26 - 0
src/map/pc.c

@@ -1115,8 +1115,34 @@ int pc_disguise(struct map_session_data *sd, int class_) {
 	return 1;
 }
 
+static int pc_bonus_autospell_del(struct s_autospell *spell, int max, short id, short lv, short rate, short card_id) {
+	int i, j;
+	for(i=max-1; i>=0 && !spell[i].id; i--);
+	if (i<0) return 0; //Nothing to substract from.
+
+	j = i;
+	for(; i>=0 && rate > 0; i--)
+	{
+		if (spell[i].id != id || spell[i].lv != lv) continue;
+		if (rate >= spell[i].rate) {
+			rate-= spell[i].rate;
+			spell[i].rate = 0;
+			memmove(&spell[i], &spell[j], sizeof(struct s_autospell));
+			memset(&spell[j], 0, sizeof(struct s_autospell));
+			j--;
+		} else {
+			spell[i].rate -= rate;
+			rate = 0;
+		}
+	}
+	return rate;
+}
+
 static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, short lv, short rate, short card_id) {
 	int i;
+	if (rate < 0) return //Remove the autobonus.
+		pc_bonus_autospell_del(spell, max, id, lv, -rate, card_id);
+
 	for (i = 0; i < max && spell[i].id; i++) {
 		if (spell[i].card_id == card_id &&
 			spell[i].id == id && spell[i].lv == lv)