Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. function AITurretData::ChooseTarget(%this,%turret)
  2. {
  3. %turret.clearAim();
  4. if (!%this.vehicleTurret)
  5. {
  6. // pick a target
  7.  
  8. %tgt = %this.CheckTarget(%turret);
  9. %turret.setTarget(%tgt);
  10.  
  11. if (%turret.getTarget().team != %turret.team)
  12. {
  13. // setup to fire the first shot after picking a target
  14. %this.setupNextFire(%turret,%this.firstFireDelay,%this.firstFireDelayVariance);
  15. }
  16. else
  17. {
  18.  
  19.  
  20. echo("!!!---<<<|||>>>---!!! that was an ally --------------------------------------------------->|>|>|>|>|>");
  21. %turret.clearAim();
  22. }
  23. }
  24. else
  25. {
  26. echo("failed to pick a target");
  27. }
  28. }
  29. // <- phdana turrets
  30. function AITurretData::CheckTarget(%this,%turret)
  31. {
  32. %turretpos = %turret.getPosition();
  33. //find a target that is in range, in LOS and is not on same team
  34. for (%j = 1; %j <= $TotalTeams; %j++) //cycle through teams
  35. {
  36. //do not cycle through same team as turret
  37. if(%turret.team != %j)
  38. {
  39. //Get the name of the SimSet the bot is checking
  40. %teamSet = "TeamSet" @ %j;
  41.  
  42. //The number of things to check
  43. %count = %teamSet.getCount();
  44. %tgtDist = %this.triggerRadius; //turret range
  45. for (%i = 0; %i < %count; %i++) //loop through possible targets
  46. {
  47. %tgt = %teamSet.getobject(%i);
  48. %namedClass = %tgt.getClassName();
  49. //If the target is invalid then the function bails out returning a -1 value
  50. if (%tgt != %turret && isObject(%tgt) && ((%tgt.behavior.isKillable && %namedClass $= "AIPlayer")
  51. || %namedClass $= "Player") && %tgt.getstate() !$= "Dead"|| (%namedClass $= "AITurret"
  52. || %namedClass $= "Turret"))
  53. {
  54. //distance
  55.  
  56. //check LOS
  57.  
  58. %tempdist = vectorDist(%tgt.getposition(), %turretpos);//distance to target
  59.  
  60. if (%tempdist < %tgtDist && (isInLOS(%tgt)) && (isReachableAngle(%tgt)))
  61.  
  62. {
  63. %tgtDist=%tempdist;
  64. %chosentgt=%tgt;
  65. }
  66.  
  67. }
  68.  
  69.  
  70. }
  71.  
  72.  
  73. }
  74. }
  75. return(%chosentgt);
  76.  
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement