@@ -949,7 +949,7 @@ function HumanBehaviors.WeaponSearch(AI, Owner, Abort)
949
949
if _abrt then return true end
950
950
end
951
951
952
- if IsHeldDevice (movableObject ) and MovableMan : ValidMO (movableObject ) then
952
+ if MovableMan : ValidMO (movableObject ) and IsHeldDevice (movableObject ) then
953
953
local device = ToHeldDevice (movableObject );
954
954
if device :IsPickupableBy (Owner ) and not device :IsActivated () and device .Vel .Largest < 3 and not SceneMan :IsUnseen (device .Pos .X , device .Pos .Y , Owner .Team ) then
955
955
local distanceToDevice = SceneMan :ShortestDistance (Owner .Pos , device .Pos , SceneMan .SceneWrapsX or SceneMan .SceneWrapsY );
@@ -974,33 +974,34 @@ function HumanBehaviors.WeaponSearch(AI, Owner, Abort)
974
974
local devicesToPickUp = {};
975
975
for _ , deviceEntry in pairs (devices ) do
976
976
local device = deviceEntry .device ;
977
-
978
- local pathMultipler = 1 ;
979
- if device :HasObjectInGroup (" Weapons - Primary" ) or device :HasObjectInGroup (" Weapons - Heavy" ) then
980
- pathMultipler = 0.4 ; -- prioritize primary or heavy weapons
981
- elseif device .ClassName == " TDExplosive" then
982
- pathMultipler = 1.4 ; -- avoid grenades if there are other weapons
983
- elseif device :IsTool () then
984
- if pickupDiggers and device :HasObjectInGroup (" Tools - Diggers" ) then
985
- pathMultipler = 1.8 ; -- avoid diggers if there are other weapons
986
- else
987
- pathMultipler = - 1 ; -- disregard non-digger tools
977
+ if MovableMan :ValidMO (device ) then
978
+ local pathMultipler = 1 ;
979
+ if device :HasObjectInGroup (" Weapons - Primary" ) or device :HasObjectInGroup (" Weapons - Heavy" ) then
980
+ pathMultipler = 0.4 ; -- prioritize primary or heavy weapons
981
+ elseif device .ClassName == " TDExplosive" then
982
+ pathMultipler = 1.4 ; -- avoid grenades if there are other weapons
983
+ elseif device :IsTool () then
984
+ if pickupDiggers and device :HasObjectInGroup (" Tools - Diggers" ) then
985
+ pathMultipler = 1.8 ; -- avoid diggers if there are other weapons
986
+ else
987
+ pathMultipler = - 1 ; -- disregard non-digger tools
988
+ end
988
989
end
989
- end
990
990
991
- if MovableMan :ValidMO (device ) and pathMultipler ~= - 1 then
992
- local deviceID = device .UniqueID ;
993
- SceneMan .Scene :CalculatePathAsync (
994
- function (pathRequest )
995
- local pathLength = pathRequest .PathLength ;
996
- if pathRequest .Status ~= PathRequest .NoSolution and pathLength < maxPathLength then
997
- local score = pathLength * pathMultipler ;
998
- table.insert (devicesToPickUp , {deviceId = deviceID , score = score });
999
- end
1000
- searchesRemaining = searchesRemaining - 1 ;
1001
- end ,
1002
- Owner .Pos , device .Pos , false , Owner .DigStrength , Owner .Team
1003
- );
991
+ if pathMultipler ~= - 1 then
992
+ local deviceID = device .UniqueID ;
993
+ SceneMan .Scene :CalculatePathAsync (
994
+ function (pathRequest )
995
+ local pathLength = pathRequest .PathLength ;
996
+ if pathRequest .Status ~= PathRequest .NoSolution and pathLength < maxPathLength then
997
+ local score = pathLength * pathMultipler ;
998
+ table.insert (devicesToPickUp , {deviceId = deviceID , score = score });
999
+ end
1000
+ searchesRemaining = searchesRemaining - 1 ;
1001
+ end ,
1002
+ Owner .Pos , device .Pos , false , Owner .DigStrength , Owner .Team
1003
+ );
1004
+ end
1004
1005
end
1005
1006
end
1006
1007
@@ -1077,7 +1078,7 @@ function HumanBehaviors.ToolSearch(AI, Owner, Abort)
1077
1078
for movableObject in MovableMan :GetMOsInRadius (Owner .Pos , maxSearchDistance , - 1 , true ) do
1078
1079
mosSearched = mosSearched + 1 ;
1079
1080
1080
- if IsHeldDevice (movableObject ) and MovableMan : ValidMO (movableObject ) then
1081
+ if MovableMan : ValidMO (movableObject ) and IsHeldDevice (movableObject ) then
1081
1082
local device = ToHeldDevice (movableObject );
1082
1083
if device :IsPickupableBy (Owner ) and not device :IsActivated () and device .Vel .Largest < 3 and not SceneMan :IsUnseen (device .Pos .X , device .Pos .Y , Owner .Team ) and device :HasObjectInGroup (" Tools - Diggers" ) then
1083
1084
local distanceToDevice = SceneMan :ShortestDistance (Owner .Pos , device .Pos , SceneMan .SceneWrapsX or SceneMan .SceneWrapsY );
0 commit comments