Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function AITurretData::ChooseTarget(%this,%turret)
- {
- %turret.clearAim();
- if (!%this.vehicleTurret)
- {
- // pick a target
- %tgt = %this.CheckTarget(%turret);
- %turret.setTarget(%tgt);
- if (%turret.getTarget().team != %turret.team)
- {
- // setup to fire the first shot after picking a target
- %this.setupNextFire(%turret,%this.firstFireDelay,%this.firstFireDelayVariance);
- }
- else
- {
- echo("!!!---<<<|||>>>---!!! that was an ally --------------------------------------------------->|>|>|>|>|>");
- %turret.clearAim();
- }
- }
- else
- {
- echo("failed to pick a target");
- }
- }
- // <- phdana turrets
- function AITurretData::CheckTarget(%this,%turret)
- {
- %turretpos = %turret.getPosition();
- //find a target that is in range, in LOS and is not on same team
- for (%j = 1; %j <= $TotalTeams; %j++) //cycle through teams
- {
- //do not cycle through same team as turret
- if(%turret.team != %j)
- {
- //Get the name of the SimSet the bot is checking
- %teamSet = "TeamSet" @ %j;
- //The number of things to check
- %count = %teamSet.getCount();
- %tgtDist = %this.triggerRadius; //turret range
- for (%i = 0; %i < %count; %i++) //loop through possible targets
- {
- %tgt = %teamSet.getobject(%i);
- %namedClass = %tgt.getClassName();
- //If the target is invalid then the function bails out returning a -1 value
- if (%tgt != %turret && isObject(%tgt) && ((%tgt.behavior.isKillable && %namedClass $= "AIPlayer")
- || %namedClass $= "Player") && %tgt.getstate() !$= "Dead"|| (%namedClass $= "AITurret"
- || %namedClass $= "Turret"))
- {
- //distance
- //check LOS
- %tempdist = vectorDist(%tgt.getposition(), %turretpos);//distance to target
- if (%tempdist < %tgtDist && (isInLOS(%tgt)) && (isReachableAngle(%tgt)))
- {
- %tgtDist=%tempdist;
- %chosentgt=%tgt;
- }
- }
- }
- }
- }
- return(%chosentgt);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement