~harrison-rt/+junk/jaguar_company

« back to all changes in this revision

Viewing changes to trunk/jaguar_company.oxp/Scripts/jaguar_company_tracker.js

  • Committer: Richard Harrison
  • Date: 2013-01-19 22:54:57 UTC
  • Revision ID: harrison.rt@gmail.com-20130119225457-ymm3tf03jao7b3lp
Tags: 2.1
* Thargoids and tharglets always returns true in $isHostile check.
* There is a safe zone of 30km around the base.
** NB: The safe zone does not extend to known attackers.
* Took out some ship script event handlers and AI sendScriptMessage functions from the base, buoy, miner and tug ship scripts that is inserted by $addFriendly.
* Fixed colour bug with the tracker. Didn't start off red if the target was behind the player.
* Fixed name error for $performJaguarCompanyAttackTarget in $addFriendly.
* Fixed sun check error if no sun exists.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*jslint indent: 4, maxlen: 120, maxerr: 50, white: true, es5: true, undef: true, bitwise: true, regexp: true,
2
 
newcap: true */
3
 
/*jshint es5: true, undef: true, bitwise: true, eqnull: true, noempty: true, eqeqeq: true, boss: true, loopfunc: true,
4
 
laxbreak: true, strict: true, curly: true */
5
 
/*global oolite, Timer, addFrameCallback, removeFrameCallback, isValidFrameCallback */
 
1
/*jslint indent: 4, maxlen: 120, maxerr: 50, white: true, es5: true, undef: true, regexp: true, newcap: true */
 
2
/*jshint es5: true, undef: true, eqnull: true, noempty: true, eqeqeq: true, boss: true, loopfunc: true, laxbreak: true,
 
3
strict: true, curly: true */
 
4
/*global Timer, addFrameCallback, removeFrameCallback, isValidFrameCallback */
6
5
 
7
6
/* Jaguar Company Tracker
8
7
 *
28
27
    this.copyright = "© 2012 Richard Thomas Harrison (Tricky)";
29
28
    this.license = "CC BY-NC-SA 3.0";
30
29
    this.description = "Ship script for the Jaguar Company Tracker.";
31
 
    this.version = "1.0";
 
30
    this.version = "1.1";
32
31
 
33
32
    /* Private variable. */
34
33
    var p_tracker = {};
226
225
        /* Vector pointing towards the target. */
227
226
        vector = cps.position.subtract(PS.position).direction();
228
227
 
229
 
        if (vector.dot(PS.heading) >= 0 && !p_tracker.material) {
 
228
        if (vector.dot(PS.heading) >= 0) {
 
229
            p_tracker.material = 0;
 
230
        } else {
 
231
            p_tracker.material = 1;
 
232
        }
 
233
 
 
234
        if (!p_tracker.material) {
230
235
            /* Change the tracker colour to be green. */
231
236
            tracker.setMaterials({
232
237
                jaguar_company_tracker : {
237
242
                    specular_color : ["0", "0.2", "0", "1"]
238
243
                }
239
244
            });
240
 
            p_tracker.material = 1;
241
 
        } else if (vector.dot(PS.heading) < 0 && p_tracker.material) {
 
245
        } else if (p_tracker.material) {
242
246
            /* Change the tracker colour to be red. */
243
247
            tracker.setMaterials({
244
248
                jaguar_company_tracker : {
249
253
                    specular_color : ["0.2", "0", "0", "1"]
250
254
                }
251
255
            });
252
 
            p_tracker.material = 0;
253
256
        }
254
257
 
255
258
        /* Distance in front of the player. */