-
Notifications
You must be signed in to change notification settings - Fork 0
/
weapon.coffee
40 lines (35 loc) · 942 Bytes
/
weapon.coffee
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
37
38
39
40
weaponSelect = (weaponId) ->
if getWeapon() != weaponId
setWeapon(weaponId)
weaponBestRange = ->
max = -1
i = 0
while i < count(pWeapons)
range = getWeaponMaxRange(pWeapons[i])
if(range > max)
max = range
maxWeapon = pWeapons[i]
i++
maxWeapon
weaponLeekBestRange = (leekId) ->
lWeapons = getWeapons(leekId)
max = -1
i = 0
while i < count(lWeapons)
range = getWeaponMaxRange(lWeapons[i])
if(range > max)
max = range
maxWeapon = lWeapons[i]
i++
maxWeapon
weaponBestDamageOnTarget = (targetId) ->
weaponCanAttack = (weaponId, fromCell, toCell) ->
distance = getCellDistance(fromCell, toCell)
if(weaponNeedLos(weaponId) && !lineOfSight(fromCell, toCell))
false
else if(isInlineWeapon(weaponId) && !isOnSameLine(fromCell, toCell))
false
else if (getWeaponMinRange(weaponId) > distance || getWeaponMaxRange(weaponId) < distance)
false
else
true