summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-02-01 20:06:06 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-02-01 20:06:06 +0000
commit75b71c93f2449765688df5a247d808b7b86b0fda (patch)
treecdba42c8b756b0db204a4db27ae19887e12b49e4 /src
parente38f00cc342543973a5a1faaa2db067f63dcb9e4 (diff)
downloadhercules-75b71c93f2449765688df5a247d808b7b86b0fda.tar.gz
hercules-75b71c93f2449765688df5a247d808b7b86b0fda.tar.bz2
hercules-75b71c93f2449765688df5a247d808b7b86b0fda.tar.xz
hercules-75b71c93f2449765688df5a247d808b7b86b0fda.zip
- Added support for mob skill target 'randomtarget', when specified, it will pick a random enemy from within the skill's cast range.
- Updated the mob_db so that all skills from non-moving mobs that specified 'target' as enemy will use 'randomtarget' instead. - Amon Ra's meteors now use randomtarget instead of self. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9762 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src')
-rw-r--r--src/map/battle.c38
-rw-r--r--src/map/battle.h1
-rw-r--r--src/map/mob.c9
-rw-r--r--src/map/mob.h1
4 files changed, 46 insertions, 3 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index 8b67ce885..bf79ff9b5 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -53,9 +53,6 @@ static int battle_gettargeted_sub(struct block_list *bl, va_list ap)
int target_id;
int *c;
- nullpo_retr(0, bl);
- nullpo_retr(0, ap);
-
bl_list = va_arg(ap, struct block_list **);
c = va_arg(ap, int *);
target_id = va_arg(ap, int);
@@ -105,6 +102,41 @@ int battle_gettarget(struct block_list *bl)
}
return 0;
}
+
+static int battle_getenemy_sub(struct block_list *bl, va_list ap)
+{
+ struct block_list **bl_list;
+ struct block_list *target;
+ int *c;
+
+ bl_list = va_arg(ap, struct block_list **);
+ c = va_arg(ap, int *);
+ target = va_arg(ap, struct block_list *);
+
+ if (bl->id == target->id)
+ return 0;
+ if (*c >= 24)
+ return 0;
+
+ if (battle_check_target(target, bl, BCT_ENEMY) > 0) {
+ bl_list[(*c)++] = bl;
+ return 1;
+ }
+ return 0;
+}
+
+// Picks a random enemy of the given type (BL_PC, BL_CHAR, etc) within the range given. [Skotlex]
+struct block_list* battle_getenemy(struct block_list *target, int type, int range)
+{
+ struct block_list *bl_list[24];
+ int c = 0;
+ memset(bl_list, 0, sizeof(bl_list));
+ map_foreachinrange(battle_getenemy_sub, target, range, type, bl_list, &c, target);
+ if (c == 0 || c > 24)
+ return NULL;
+ return bl_list[rand()%c];
+}
+
// _??[W̒x
struct delay_damage {
struct block_list *src;
diff --git a/src/map/battle.h b/src/map/battle.h
index 00be1fe42..6d2d8a7db 100644
--- a/src/map/battle.h
+++ b/src/map/battle.h
@@ -57,6 +57,7 @@ int battle_weapon_attack( struct block_list *bl,struct block_list *target,
// ep[^𓾂
struct block_list* battle_get_master(struct block_list *src);
struct block_list* battle_gettargeted(struct block_list *target);
+struct block_list* battle_getenemy(struct block_list *target, int type, int range);
int battle_gettarget(struct block_list *bl);
int battle_getcurrentskill(struct block_list *bl);
diff --git a/src/map/mob.c b/src/map/mob.c
index b47dfcbb8..f32acc85f 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -2757,6 +2757,10 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
short x = 0, y = 0;
if (ms[i].target <= MST_AROUND) {
switch (ms[i].target) {
+ case MST_RANDOM: //Pick a random enemy within skill range.
+ bl = battle_getenemy(&md->bl, md->special_state.ai?BL_CHAR:BL_PC|BL_HOM,
+ skill_get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv));
+ break;
case MST_TARGET:
case MST_AROUND5:
case MST_AROUND6:
@@ -2805,6 +2809,10 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
if (ms[i].target <= MST_MASTER) {
struct block_list *bl;
switch (ms[i].target) {
+ case MST_RANDOM: //Pick a random enemy within skill range.
+ bl = battle_getenemy(&md->bl, md->special_state.ai?BL_CHAR:BL_PC|BL_HOM,
+ skill_get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv));
+ break;
case MST_TARGET:
bl = map_id2bl(md->target_id);
break;
@@ -3657,6 +3665,7 @@ static int mob_readskilldb(void)
{ "anytarget",MSS_ANYTARGET }, //Berserk+Angry+Rush+Follow
}, target[] = {
{ "target", MST_TARGET },
+ { "randomtarget", MST_RANDOM },
{ "self", MST_SELF },
{ "friend", MST_FRIEND },
{ "master", MST_MASTER },
diff --git a/src/map/mob.h b/src/map/mob.h
index f4895c7e0..0828629bd 100644
--- a/src/map/mob.h
+++ b/src/map/mob.h
@@ -73,6 +73,7 @@ struct mob_db {
enum {
MST_TARGET = 0,
+ MST_RANDOM, //Random Target!
MST_SELF,
MST_FRIEND,
MST_MASTER,