-
Notifications
You must be signed in to change notification settings - Fork 27
/
pvm_pvp_attack_simple.py
36 lines (30 loc) · 1.05 KB
/
pvm_pvp_attack_simple.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'''
Author: TheWarDoctor95
Other Contributors:
Last Contribution By: TheWarDoctor95 - March 23, 2019
Description: Finds the nearest enemy to attack. Prioritizes enemies in war mode
'''
from System.Collections.Generic import List
from Scripts.glossary.enemies import GetEnemyNotorieties, GetEnemies
from Scripts.utilities.mobiles import GetEmptyMobileList
def FindEnemy():
'''
Returns the nearest enemy
'''
enemies = GetEnemies( Mobiles, 0, 12, GetEnemyNotorieties() )
if len( enemies ) == 0:
return None
elif len( enemies ) == 1:
return enemies[ 0 ]
else:
enemiesInWarMode = GetEmptyMobileList( Mobiles )
enemiesInWarMode.AddRange( [ enemy for enemy in enemies if enemy.WarMode ] )
if len( enemiesInWarMode ) == 0:
return Mobiles.Select( enemies, 'Nearest' )
elif len( enemiesInWarMode ) == 1:
return enemiesInWarMode[ 0 ]
else:
return Mobiles.Select( enemiesInWarMode, 'Nearest' )
enemy = FindEnemy()
if enemy != None:
Player.Attack( enemy )