Browse Source

Adds new mob skill condition MSC_MOBNEARBYGT (#7130)

* Adds new mob skill condition MSC_MOBNEARBYGT as on official some monsters trigger skills when specific amount of other monsters are nearby.
munkrej 2 years ago
parent
commit
84d295e784
5 changed files with 8 additions and 2 deletions
  1. 1 0
      db/import-tmpl/mob_skill_db.txt
  2. 1 0
      db/pre-re/mob_skill_db.txt
  3. 1 0
      db/re/mob_skill_db.txt
  4. 4 2
      src/map/mob.cpp
  5. 1 0
      src/map/mob.hpp

+ 1 - 0
db/import-tmpl/mob_skill_db.txt

@@ -43,6 +43,7 @@
 //	afterskill		After mob casts the specified skill.
 //	casttargeted		When a target is in cast range (no condition value).
 //	rudeattacked		When mob is rude attacked (no condition value).
+//	mobnearbygt		When monsters in range become greater than specified number.
 //
 //	Status abnormalities specified through the statuson/statusoff system:
 //	    anybad (any type of state change) / stone / freeze / stun / sleep /

+ 1 - 0
db/pre-re/mob_skill_db.txt

@@ -44,6 +44,7 @@
 //	afterskill		After mob casts the specified skill.
 //	casttargeted		When a target is in cast range (no condition value).
 //	rudeattacked		When mob is rude attacked (no condition value).
+//	mobnearbygt		When monsters in range become greater than specified number.
 //
 //	Status abnormalities specified through the statuson/statusoff system:
 //	    anybad (any type of state change) / stone / freeze / stun / sleep /

+ 1 - 0
db/re/mob_skill_db.txt

@@ -44,6 +44,7 @@
 //	afterskill		After mob casts the specified skill.
 //	casttargeted		When a target is in cast range (no condition value).
 //	rudeattacked		When mob is rude attacked (no condition value).
+//	mobnearbygt		When monsters in range become greater than specified number.
 //
 //	Status abnormalities specified through the statuson/statusoff system:
 //	    anybad (any type of state change) / stone / freeze / stun / sleep /

+ 4 - 2
src/map/mob.cpp

@@ -3765,8 +3765,9 @@ int mobskill_use(struct mob_data *md, t_tick tick, int event)
 				case MSC_MASTERATTACKED:
 					flag = (md->master_id > 0 && (fbl=map_id2bl(md->master_id)) && unit_counttargeted(fbl) > 0); break;
 				case MSC_ALCHEMIST:
-					flag = (md->state.alchemist);
-					break;
+					flag = (md->state.alchemist); break;
+				case MSC_MOBNEARBYGT:
+					flag = (map_foreachinallrange(mob_count_sub, &md->bl, AREA_SIZE, BL_MOB) > c2 ); break;
 			}
 		}
 
@@ -5794,6 +5795,7 @@ static bool mob_parse_row_mobskilldb(char** str, int columns, int current)
 		{ "masterattacked",    MSC_MASTERATTACKED    },
 		{ "alchemist",         MSC_ALCHEMIST         },
 		{ "onspawn",           MSC_SPAWN             },
+		{ "mobnearbygt",       MSC_MOBNEARBYGT       },
 	}, cond2[] ={
 		{	"anybad",		-1				},
 		{	"stone",		SC_STONE		},

+ 1 - 0
src/map/mob.hpp

@@ -430,6 +430,7 @@ enum e_mob_skill_condition {
 	MSC_MASTERATTACKED,
 	MSC_ALCHEMIST,
 	MSC_SPAWN,
+	MSC_MOBNEARBYGT,
 };
 
 // The data structures for storing delayed item drops