@@ -346,67 +346,78 @@ function NativeHumanAI:Update(Owner)
346
346
end
347
347
348
348
if Leader then
349
- if Leader .EquippedItem and SceneMan :ShortestDistance (Owner .Pos , Leader .Pos , false ).Largest < (Leader .Height + Owner .Height ) * 0.5 then
350
-
351
- if IsHDFirearm (Leader .EquippedItem ) then
352
-
353
- local LeaderWeapon = ToHDFirearm (Leader .EquippedItem )
354
- if LeaderWeapon :IsWeapon () then
355
- local AimDelta = SceneMan :ShortestDistance (Leader .Pos , Leader .ViewPoint , false )
356
- self .Ctrl .AnalogAim = SceneMan :ShortestDistance (Owner .Pos , Leader .ViewPoint + AimDelta , false ).Normalized
357
- self .deviceState = AHuman .POINTING
358
-
359
- -- check if the SL is shooting and if we have a similar weapon
360
- if Owner .FirearmIsReady then
361
- self .deviceState = AHuman .AIMING
362
-
363
- if IsHDFirearm (Owner .EquippedItem ) and Leader :GetController ():IsState (Controller .WEAPON_FIRE ) then
364
- local OwnerWeapon = ToHDFirearm (Owner .EquippedItem )
365
- if OwnerWeapon :IsTool () then
366
- -- try equipping a weapon
367
- if Owner .InventorySize > 0 and not Owner :EquipDeviceInGroup (" Weapons - Primary" , true ) then
368
- Owner :EquipFirearm (true )
369
- end
370
- elseif LeaderWeapon :GetAIBlastRadius () >= OwnerWeapon :GetAIBlastRadius () * 0.5 and
371
- OwnerWeapon :CompareTrajectories (LeaderWeapon ) < math.max (100 , OwnerWeapon :GetAIBlastRadius ())
372
- then
373
- -- slightly displace full-auto shots to diminish stacking sounds and create a more dense fire rate
374
- if OwnerWeapon .FullAuto then
375
- if math.random () < 0.3 then
349
+ local dist = SceneMan :ShortestDistance (Owner .Pos , Leader .Pos , false ).Largest
350
+ local radius = (Leader .Height + Owner .Height ) * 0.5
351
+ if dist < radius then
352
+ -- if Leader:IsPlayerControlled() then
353
+ local copyControls = {Controller .MOVE_LEFT , Controller .MOVE_RIGHT , Controller .BODY_JUMPSTART , Controller .BODY_JUMP , Controller .BODY_CROUCH }
354
+ for _ , control in pairs (copyControls ) do
355
+ local state = Leader :GetController ():IsState (control )
356
+ self .Ctrl :SetState (control , state )
357
+ end
358
+ -- end
359
+ if Leader .EquippedItem then
360
+
361
+ if IsHDFirearm (Leader .EquippedItem ) then
362
+
363
+ local LeaderWeapon = ToHDFirearm (Leader .EquippedItem )
364
+ if LeaderWeapon :IsWeapon () then
365
+ local AimDelta = SceneMan :ShortestDistance (Leader .Pos , Leader .ViewPoint , false )
366
+ self .Ctrl .AnalogAim = SceneMan :ShortestDistance (Owner .Pos , Leader .ViewPoint + AimDelta , false ).Normalized
367
+ self .deviceState = AHuman .POINTING
368
+
369
+ -- check if the SL is shooting and if we have a similar weapon
370
+ if Owner .FirearmIsReady then
371
+ self .deviceState = AHuman .AIMING
372
+
373
+ if IsHDFirearm (Owner .EquippedItem ) and Leader :GetController ():IsState (Controller .WEAPON_FIRE ) then
374
+ local OwnerWeapon = ToHDFirearm (Owner .EquippedItem )
375
+ if OwnerWeapon :IsTool () then
376
+ -- try equipping a weapon
377
+ if Owner .InventorySize > 0 and not Owner :EquipDeviceInGroup (" Weapons - Primary" , true ) then
378
+ Owner :EquipFirearm (true )
379
+ end
380
+ elseif LeaderWeapon :GetAIBlastRadius () >= OwnerWeapon :GetAIBlastRadius () * 0.5 and
381
+ OwnerWeapon :CompareTrajectories (LeaderWeapon ) < math.max (100 , OwnerWeapon :GetAIBlastRadius ())
382
+ then
383
+ -- slightly displace full-auto shots to diminish stacking sounds and create a more dense fire rate
384
+ if OwnerWeapon .FullAuto then
385
+ if math.random () < 0.3 then
386
+ self .Target = nil
387
+ self .squadShoot = true
388
+ end
389
+ else
376
390
self .Target = nil
377
391
self .squadShoot = true
378
392
end
379
- else
380
- self .Target = nil
381
- self .squadShoot = true
382
393
end
394
+ else
395
+ self .squadShoot = false
383
396
end
384
397
else
385
- self .squadShoot = false
386
- end
387
- else
388
- if Owner .FirearmIsEmpty then
389
- Owner :ReloadFirearm ()
390
- elseif Owner .InventorySize > 0 and not Owner :EquipDeviceInGroup (" Weapons - Primary" , true ) then
391
- Owner :EquipFirearm (true )
398
+ if Owner .FirearmIsEmpty then
399
+ Owner :ReloadFirearm ()
400
+ elseif Owner .InventorySize > 0 and not Owner :EquipDeviceInGroup (" Weapons - Primary" , true ) then
401
+ Owner :EquipFirearm (true )
402
+ end
392
403
end
393
404
end
394
- end
395
- elseif IsTDExplosive (Leader .EquippedItem ) and Leader :IsPlayerControlled () then
396
- -- throw grenades in unison with squad
397
- if ToTDExplosive (Leader .EquippedItem ):HasObjectInGroup (" Bombs - Grenades" ) and Owner :HasObjectInGroup (" Bombs - Grenades" ) then
405
+ elseif IsTDExplosive (Leader .EquippedItem ) and Leader :IsPlayerControlled () then
406
+ -- throw grenades in unison with squad
407
+ if ToTDExplosive (Leader .EquippedItem ):HasObjectInGroup (" Bombs - Grenades" ) and Owner :HasObjectInGroup (" Bombs - Grenades" ) then
398
408
399
- self .Ctrl .AnalogAim = SceneMan :ShortestDistance (Leader .Pos , Leader .ViewPoint , false ).Normalized
400
- self .deviceState = AHuman .POINTING
409
+ self .Ctrl .AnalogAim = SceneMan :ShortestDistance (Leader .Pos , Leader .ViewPoint , false ).Normalized
410
+ self .deviceState = AHuman .POINTING
401
411
402
- if Leader :GetController ():IsState (Controller .WEAPON_FIRE ) then
412
+ if Leader :GetController ():IsState (Controller .WEAPON_FIRE ) then
403
413
404
- Owner :EquipDeviceInGroup (" Bombs - Grenades" , true )
414
+ Owner :EquipDeviceInGroup (" Bombs - Grenades" , true )
405
415
406
- self .Target = nil
407
- self .squadShoot = true
408
- else
409
- self .squadShoot = false
416
+ self .Target = nil
417
+ self .squadShoot = true
418
+ else
419
+ self .squadShoot = false
420
+ end
410
421
end
411
422
end
412
423
end
0 commit comments