summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-24 14:52:11 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-24 14:52:11 +0000
commitdc9ae7b5a2a047d3cf3e889b0d1df0d7af67e2a4 (patch)
tree05b3fa0c830cdbdb14ffc85ae56ff153ff4c929d /src/map
parent52c05755226744e3fc6f42779d60f6ed392a5e4b (diff)
downloadhercules-dc9ae7b5a2a047d3cf3e889b0d1df0d7af67e2a4.tar.gz
hercules-dc9ae7b5a2a047d3cf3e889b0d1df0d7af67e2a4.tar.bz2
hercules-dc9ae7b5a2a047d3cf3e889b0d1df0d7af67e2a4.tar.xz
hercules-dc9ae7b5a2a047d3cf3e889b0d1df0d7af67e2a4.zip
- Fixed skill_delayfix not altering delay at all after you reached 150.
- Applied ers to pet loot drops. - Cleaned up the pet loot drop function. - Mob skill state MSS_ANY won't include MSS_DEAD now. - Added mob skill state MSS_ANYTARGET ("anytarget") which means any state (except dead) on which the mob has a target set. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6250 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map')
-rw-r--r--src/map/mob.c30
-rw-r--r--src/map/mob.h19
-rw-r--r--src/map/pet.c119
-rw-r--r--src/map/pet.h1
-rw-r--r--src/map/skill.c2
5 files changed, 96 insertions, 75 deletions
diff --git a/src/map/mob.c b/src/map/mob.c
index 2ff43cdc9..c9b969b44 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1383,23 +1383,6 @@ static int mob_ai_hard(int tid,unsigned int tick,int id,int data)
}
/*==========================================
- * The structure object for item drop with delay
- * Since it is only two being able to pass [ int ] a timer function
- * Data is put in and passed to this structure object.
- *------------------------------------------
- */
-struct item_drop {
- struct item item_data;
- struct item_drop *next;
-};
-
-struct item_drop_list {
- int m,x,y;
- struct map_session_data *first_sd,*second_sd,*third_sd;
- struct item_drop *item;
-};
-
-/*==========================================
* Initializes the delay drop structure for mob-dropped items.
*------------------------------------------
*/
@@ -2617,10 +2600,12 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
if (DIFF_TICK(tick, md->skilldelay[i]) < ms[i].delay)
continue;
- // 状態判定
- if (ms[i].state != MSS_ANY && ms[i].state != md->state.skillstate)
- continue;
-
+ if (ms[i].state != md->state.skillstate && md->state.skillstate != MSS_DEAD) {
+ if (ms[i].state == MSS_ANY || (ms[i].state == MSS_ANYTARGET && md->target_id))
+ ; //ANYTARGET works with any state as long as there's a target. [Skotlex]
+ else
+ continue;
+ }
if (rand() % 10000 > ms[i].permillage) //Lupus (max value = 10000)
continue;
@@ -3478,7 +3463,7 @@ static int mob_readskilldb(void)
{ "hiding", SC_HIDING },
{ "sight", SC_SIGHT },
}, state[] = {
- { "any", MSS_ANY },
+ { "any", MSS_ANY }, //All states except Dead
{ "idle", MSS_IDLE },
{ "walk", MSS_WALK },
{ "loot", MSS_LOOT },
@@ -3487,6 +3472,7 @@ static int mob_readskilldb(void)
{ "angry", MSS_ANGRY }, //Preemptive attack (aggressive mobs)
{ "chase", MSS_RUSH }, //Chase escaping target
{ "follow", MSS_FOLLOW }, //Preemptive chase (aggressive mobs)
+ { "anytarget",MSS_ANYTARGET }, //Berserk+Angry+Rush+Follow
}, target[] = {
{ "target", MST_TARGET },
{ "self", MST_SELF },
diff --git a/src/map/mob.h b/src/map/mob.h
index 3fb9a64b9..2cb995ac0 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -106,6 +106,25 @@ enum {
MSS_ANGRY, //Mob retaliating from being attacked.
MSS_RUSH, //Mob following a player after being attacked.
MSS_FOLLOW, //Mob following a player without being attacked.
+ MSS_ANYTARGET,
+};
+
+
+/*==========================================
+ * The structure object for item drop with delay
+ * Since it is only two being able to pass [ int ] a timer function
+ * Data is put in and passed to this structure object.
+ *------------------------------------------
+ */
+struct item_drop {
+ struct item item_data;
+ struct item_drop *next;
+};
+
+struct item_drop_list {
+ int m,x,y;
+ struct map_session_data *first_sd,*second_sd,*third_sd;
+ struct item_drop *item;
};
struct mob_db* mob_db(int class_);
diff --git a/src/map/pet.c b/src/map/pet.c
index 1c176750f..d4db10d09 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -10,6 +10,7 @@
#include "../common/nullpo.h"
#include "../common/malloc.h"
#include "../common/showmsg.h"
+#include "../common/ers.h"
#include "pc.h"
#include "status.h"
@@ -29,6 +30,9 @@
struct pet_db pet_db[MAX_PET_DB];
+static struct eri *item_drop_ers; //For loot drops delay structures.
+static struct eri *item_drop_list_ers;
+
static int dirx[8]={0,-1,-1,-1,0,1,1,1};
static int diry[8]={1,1,0,-1,-1,-1,0,1};
@@ -321,18 +325,6 @@ int pet_hungry_timer_delete(struct map_session_data *sd)
return 0;
}
-struct delay_item_drop {
- int m,x,y;
- int nameid,amount;
- struct map_session_data *first_sd,*second_sd,*third_sd;
-};
-
-struct delay_item_drop2 {
- int m,x,y;
- struct item item_data;
- struct map_session_data *first_sd,*second_sd,*third_sd;
-};
-
int pet_performance(struct map_session_data *sd)
{
struct pet_data *pd;
@@ -1082,54 +1074,72 @@ int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap)
return 0;
}
+static int pet_delay_item_drop(int tid,unsigned int tick,int id,int data)
+{
+ struct item_drop_list *list;
+ struct item_drop *ditem, *ditem_prev;
+ list=(struct item_drop_list *)id;
+ ditem = list->item;
+ while (ditem) {
+ map_addflooritem(&ditem->item_data,ditem->item_data.amount,
+ list->m,list->x,list->y,
+ list->first_sd,list->second_sd,list->third_sd,0);
+ ditem_prev = ditem;
+ ditem = ditem->next;
+ ers_free(item_drop_ers, ditem_prev);
+ }
+ ers_free(item_drop_list_ers, list);
+ return 0;
+}
+
int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd)
{
int i,flag=0;
- struct delay_item_drop2 *ditem_floor, ditem;
- if(pd && pd->loot && pd->loot->count) {
- memset(&ditem, 0, sizeof(struct delay_item_drop2));
- ditem.m = pd->bl.m;
- ditem.x = pd->bl.x;
- ditem.y = pd->bl.y;
- ditem.first_sd = 0;
- ditem.second_sd = 0;
- ditem.third_sd = 0;
- for(i=0;i<pd->loot->count;i++) {
- memcpy(&ditem.item_data,&pd->loot->item[i],sizeof(pd->loot->item[0]));
- // 落とさないで直接PCのItem欄へ
- if(sd){
- if((flag = pc_additem(sd,&ditem.item_data,ditem.item_data.amount))){
- clif_additem(sd,0,0,flag);
- map_addflooritem(&ditem.item_data,ditem.item_data.amount,ditem.m,ditem.x,ditem.y,ditem.first_sd,ditem.second_sd,ditem.third_sd,0);
- }
- }
- else {
- ditem_floor=(struct delay_item_drop2 *)aCalloc(1,sizeof(struct delay_item_drop2));
- memcpy(ditem_floor, &ditem, sizeof(struct delay_item_drop2));
- add_timer(gettick()+540+i,pet_delay_item_drop2,(int)ditem_floor,0);
+ struct item_drop_list *dlist;
+ struct item_drop *ditem;
+ struct item *it;
+ if(!pd || !pd->loot || !pd->loot->count)
+ return 0;
+ dlist = ers_alloc(item_drop_list_ers, struct item_drop_list);
+ dlist->m = pd->bl.m;
+ dlist->x = pd->bl.x;
+ dlist->y = pd->bl.y;
+ dlist->first_sd = NULL;
+ dlist->second_sd = NULL;
+ dlist->third_sd = NULL;
+ dlist->item = NULL;
+
+ for(i=0;i<pd->loot->count;i++) {
+ it = &pd->loot->item[i];
+ if(sd){
+ if((flag = pc_additem(sd,it,it->amount))){
+ clif_additem(sd,0,0,flag);
+ ditem = ers_alloc(item_drop_ers, struct item_drop);
+ memcpy(&ditem->item_data, it, sizeof(struct item));
+ ditem->next = dlist->item;
+ dlist->item = ditem->next;
}
}
- //The smart thing to do is use pd->loot->max (thanks for pointing it out, Shinomori)
- memset(pd->loot->item,0,pd->loot->max * sizeof(struct item));
- pd->loot->count = 0;
- pd->loot->weight = 0;
- pd->ud.canact_tick = gettick()+10000; // 10*1000msの間拾わない
+ else {
+ ditem = ers_alloc(item_drop_ers, struct item_drop);
+ memcpy(&ditem->item_data, it, sizeof(struct item));
+ ditem->next = dlist->item;
+ dlist->item = ditem->next;
+ }
}
+ //The smart thing to do is use pd->loot->max (thanks for pointing it out, Shinomori)
+ memset(pd->loot->item,0,pd->loot->max * sizeof(struct item));
+ pd->loot->count = 0;
+ pd->loot->weight = 0;
+ pd->ud.canact_tick = gettick()+10000; // 10*1000msの間拾わない
+
+ if (dlist->item)
+ add_timer(gettick()+540,pet_delay_item_drop,(int)dlist,0);
+ else
+ ers_free(item_drop_list_ers, dlist);
return 1;
}
-int pet_delay_item_drop2(int tid,unsigned int tick,int id,int data)
-{
- struct delay_item_drop2 *ditem;
-
- ditem=(struct delay_item_drop2 *)id;
-
- map_addflooritem(&ditem->item_data,ditem->item_data.amount,ditem->m,ditem->x,ditem->y,ditem->first_sd,ditem->second_sd,ditem->third_sd,0);
-
- aFree(ditem);
- return 0;
-}
-
/*==========================================
* pet bonus giving skills [Valaris] / Rewritten by [Skotlex]
*------------------------------------------
@@ -1384,10 +1394,13 @@ int do_init_pet(void)
memset(pet_db,0,sizeof(pet_db));
read_petdb();
+ item_drop_ers = ers_new((uint32)sizeof(struct item_drop));
+ item_drop_list_ers = ers_new((uint32)sizeof(struct item_drop_list));
+
add_timer_func_list(pet_hungry,"pet_hungry");
add_timer_func_list(pet_ai_hard,"pet_ai_hard");
add_timer_func_list(pet_skill_bonus_timer,"pet_skill_bonus_timer"); // [Valaris]
- add_timer_func_list(pet_delay_item_drop2,"pet_delay_item_drop2");
+ add_timer_func_list(pet_delay_item_drop,"pet_delay_item_drop");
add_timer_func_list(pet_skill_support_timer, "pet_skill_support_timer"); // [Skotlex]
add_timer_func_list(pet_recovery_timer,"pet_recovery_timer"); // [Valaris]
add_timer_func_list(pet_heal_timer,"pet_heal_timer"); // [Valaris]
@@ -1404,5 +1417,7 @@ int do_final_pet(void) {
pet_db[i].script = NULL;
}
}
+ ers_destroy(item_drop_ers);
+ ers_destroy(item_drop_list_ers);
return 0;
}
diff --git a/src/map/pet.h b/src/map/pet.h
index 5e4541de0..9517fb37b 100644
--- a/src/map/pet.h
+++ b/src/map/pet.h
@@ -52,7 +52,6 @@ int pet_equipitem(struct map_session_data *sd,int index);
int pet_unequipitem(struct map_session_data *sd);
int pet_food(struct map_session_data *sd);
int pet_lootitem_drop(struct pet_data *pd,struct map_session_data *sd);
-int pet_delay_item_drop2(int tid,unsigned int tick,int id,int data);
int pet_ai_sub_hard_lootsearch(struct block_list *bl,va_list ap);
int pet_attackskill(struct pet_data *pd, int target_id);
int pet_skill_support_timer(int tid, unsigned int tick, int id, int data); // [Skotlex]
diff --git a/src/map/skill.c b/src/map/skill.c
index 77705973a..80bbacd4f 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -8330,6 +8330,8 @@ int skill_delayfix(struct block_list *bl, int skill_id, int skill_lv)
int scale = battle_config.castrate_dex_scale - status_get_dex(bl);
if (scale > 0)
time = time * scale / battle_config.castrate_dex_scale;
+ else //To be capped later to minimum.
+ time = 0;
}
if (bl->type == BL_PC && ((TBL_PC*)bl)->delayrate != 100)