summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpanikon <panikon@zoho.com>2014-05-29 14:53:39 -0300
committerpanikon <panikon@zoho.com>2014-05-29 14:53:39 -0300
commit10e6f1a189f20ca346ada2f6199378869b370442 (patch)
tree966652fc6b52b02fd75f367769a54989bb86ba9d
parenta1df5eec5dc3c36838dbcf78128a83cf98a9b1ac (diff)
downloadhercules-10e6f1a189f20ca346ada2f6199378869b370442.tar.gz
hercules-10e6f1a189f20ca346ada2f6199378869b370442.tar.bz2
hercules-10e6f1a189f20ca346ada2f6199378869b370442.tar.xz
hercules-10e6f1a189f20ca346ada2f6199378869b370442.zip
Implemented MD_RANDOMTARGET, see doc/mob_db_mode_list.txt for more information
-rw-r--r--doc/mob_db_mode_list.txt4
-rw-r--r--src/map/mob.c26
-rw-r--r--src/map/status.h1
3 files changed, 22 insertions, 9 deletions
diff --git a/doc/mob_db_mode_list.txt b/doc/mob_db_mode_list.txt
index 08abf800d..17f25d9bc 100644
--- a/doc/mob_db_mode_list.txt
+++ b/doc/mob_db_mode_list.txt
@@ -26,7 +26,7 @@ MD_ANGRY | 0x0800 | 2048
MD_CHANGETARGET_MELEE | 0x1000 | 4096
MD_CHANGETARGET_CHASE | 0x2000 | 8192
MD_TARGETWEAK | 0x4000 | 16384
-MD_RANDOMTARGET | 0x8000 | 32768 (not implemented)
+MD_RANDOMTARGET | 0x8000 | 32768
Explanation for modes:
-------------------------------------------------------------------------------
@@ -75,7 +75,7 @@ Target Weak: Allows aggressive monsters to only be aggressive against
For example, a monster of level 104 will not pick fights with a level 99.
Random Target: Picks a new random target in range on each attack / skill.
- (not implemented)
+
Aegis Mob Types:
-------------------------------------------------------------------------------
diff --git a/src/map/mob.c b/src/map/mob.c
index 784bb5a07..ef47d6b70 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1620,7 +1620,16 @@ bool mob_ai_sub_hard(struct mob_data *md, int64 tick) {
if(tbl->type == BL_PC)
mob->log_damage(md, tbl, 0); //Log interaction (counts as 'attacker' for the exp bonus)
- unit->attack(&md->bl,tbl->id,1);
+
+ if(!(mode&MD_RANDOMTARGET))
+ unit->attack(&md->bl,tbl->id,1);
+ else { // Attack once and find new random target
+ int search_size = (view_range < md->status.rhw.range) ? view_range : md->status.rhw.range;
+ unit->attack(&md->bl,tbl->id,0);
+ tbl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md), search_size);
+ md->target_id = tbl->id;
+ md->min_chase = md->db->range3;
+ }
return true;
}
@@ -3073,6 +3082,7 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) {
struct block_list *bl;
struct mob_data *fmd = NULL;
int i,j,n;
+ short skill_target;
nullpo_ret(md);
nullpo_ret(ms = md->db->skill);
@@ -3171,10 +3181,12 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) {
if (!flag)
continue; //Skill requisite failed to be fulfilled.
+
//Execute skill
+ skill_target = (md->db->status.mode&MD_RANDOMTARGET)? MST_RANDOM : ms[i].target;
if (skill->get_casttype(ms[i].skill_id) == CAST_GROUND) {//Ground skill.
short x, y;
- switch (ms[i].target) {
+ switch (skill_target) {
case MST_RANDOM: //Pick a random enemy within skill range.
bl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md),
skill->get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv));
@@ -3204,10 +3216,10 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) {
x = bl->x;
y = bl->y;
// Look for an area to cast the spell around...
- if (ms[i].target >= MST_AROUND1 || ms[i].target >= MST_AROUND5) {
- j = ms[i].target >= MST_AROUND1?
- (ms[i].target-MST_AROUND1) +1:
- (ms[i].target-MST_AROUND5) +1;
+ if (skill_target >= MST_AROUND1 || skill_target >= MST_AROUND5) {
+ j = skill_target >= MST_AROUND1?
+ (skill_target-MST_AROUND1) +1:
+ (skill_target-MST_AROUND5) +1;
map->search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3);
}
md->skill_idx = i;
@@ -3220,7 +3232,7 @@ int mobskill_use(struct mob_data *md, int64 tick, int event) {
}
} else {
//Targetted skill
- switch (ms[i].target) {
+ switch (skill_target) {
case MST_RANDOM: //Pick a random enemy within skill range.
bl = battle->get_enemy(&md->bl, DEFAULT_ENEMY_TYPE(md),
skill->get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv));
diff --git a/src/map/status.h b/src/map/status.h
index 3bdd59041..32bef4df8 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -1525,6 +1525,7 @@ enum e_mode
MD_CHANGETARGET_MELEE = 0x1000,
MD_CHANGETARGET_CHASE = 0x2000,
MD_TARGETWEAK = 0x4000,
+ MD_RANDOMTARGET = 0x8000,
MD_MASK = 0xFFFF,
};