Difference between revisions of "Script - Proximity Trigger"
From FreeSpace Wiki
(initial commit) |
m (unnecessary header) |
||
Line 1: | Line 1: | ||
− | + | After certain activation time the script detonates set weapons if there are non-friendly ships (neutral, hostile, traitor etc.) within certain radius. Can be used as proximity trigger for weapons or for example as proximity trigger for mines. | |
− | After certain activation time the script detonates set weapons if there are non friendly ships (neutral, hostile, traitor etc.) within certain radius. Can be used as proximity trigger for weapons or for example as proximity trigger for mines. | ||
Example below uses Helios as the weapon having proximity trigger that activates 5 seconds after the weapon launch (This particular Helios has lifetime of 30 s). The script detonates the weapon if target approaches to closer than 1000 m ('''''IMPORTANT NOTE:''''' '''unlike ingame''' distances this one is measured '''from the centerpoint''' of the weapon '''to the centerpoint''' of the target) | Example below uses Helios as the weapon having proximity trigger that activates 5 seconds after the weapon launch (This particular Helios has lifetime of 30 s). The script detonates the weapon if target approaches to closer than 1000 m ('''''IMPORTANT NOTE:''''' '''unlike ingame''' distances this one is measured '''from the centerpoint''' of the weapon '''to the centerpoint''' of the target) |
Latest revision as of 19:40, 16 April 2010
After certain activation time the script detonates set weapons if there are non-friendly ships (neutral, hostile, traitor etc.) within certain radius. Can be used as proximity trigger for weapons or for example as proximity trigger for mines.
Example below uses Helios as the weapon having proximity trigger that activates 5 seconds after the weapon launch (This particular Helios has lifetime of 30 s). The script detonates the weapon if target approaches to closer than 1000 m (IMPORTANT NOTE: unlike ingame distances this one is measured from the centerpoint of the weapon to the centerpoint of the target)
Table Entry
#Global Hooks $Simulation: [ --Get all weapons for i=1,mn.getNumWeapons() do weapon = mn.getWeaponByIndex(i) weapontype = weapon.Class.Name --Select only mines if weapontype == "Helios" then weaponlife = weapon.LifeLeft --Select only those mines that have been activated (time activation) if weaponlife < 25 then weaponteam = weapon.Team --Start building distance array for m=1,mn.getNumShips() do ship = mn.getShipByIndex(m) shipteam = ship.Team weaponposition = weapon.Position shipposition = ship.Position shipdistance = weaponposition:getDistance(shipposition) if shipteam ~= weaponteam and shipdistance < 1000 then weapon.LifeLeft = 0 end end end end end ] #End