How can tell whether a shot was fired by the player or by a different ship?
Here's the current version of the code if having some context helps:
(avoidCriteria is "sTF N:20 S:D" in the case below)
Code: Select all
; notTargets: (spaceObject list) List of targets to avoid shooting at all costs
; Nil means do not hold fire even if there is a chance of hitting a friendly target
; Set notTargets based on the list of criteria given by the function's avoidCriteria argument
(setq notTargets (sysFindObject gSource avoidCriteria))
; If allow friendly fire is true, then we REMOVE all angry (but friendly "green" on the LRS) targets from
; the list of ships to avoid shooting
; ELSE: Do nothing
(if (eq (objGetData gSource "pds_allowFriendlyFire") true)
(block Nil
; We need to a new list to store the new list of targets as enum iterates through the original list
(setq newNotTargets Nil)
; Iterate through all the targets we supposedly shouldn't shoot at
(enum notTargets theTarget
; If the object isn't angry at gSource, add it to the new list
(if (not (objIsAngryAt theTarget gSource))
(lnkAppend newNotTargets theTarget)
)
)
; Now we have a new list of targets to avoid shooting, and none of the ships in the list is angry at gSource
; Make the original list equal to the new one, since we're finished with enum
(setq notTargets newNotTargets)
)
)