Code: Select all
this.startUpComplete = this.equipmentAdded = this.playerBoughtNewShip = function()
I think it would be better to do something like this:
Code: Select all
this.startUpComplete = function()
{
this.$adjustSpeed();
}
this.equipmentAdded = function(equipmentKey)
{
log(this.name, "adding equipment " + equipmentKey);
if (equipmentKey == "EQ_TRANSIT_DEFAULT" || equipmentKey == "EQ_TRANSIT_GRADE" || equipmentKey == "EQ_PERFORMANCE_DEFAULT" || equipmentKey == "EQ_PERFORMANCE_GRADE")
this.$adjustSpeed();
}
this.playerBoughtNewShip = function(ship, price)
{
log(this.name, "new ship " + ship);
this.$adjustSpeed();
}
this.$adjustSpeed = function()
{
var p = player.ship;
var td = p.equipmentStatus("EQ_TRANSIT_DEFAULT");
var tg = p.equipmentStatus("EQ_TRANSIT_GRADE");
var pd = p.equipmentStatus("EQ_PERFORMANCE_DEFAULT");
var pg = p.equipmentStatus("EQ_PERFORMANCE_GRADE");
log(this.name, "transit def " + td + ", gde " + tg);
log(this.name, "perform def " + pd + ", gde " + pg);
log(this.name, "maxspeed pre = " + p.maxSpeed);
if(tg == "EQUIPMENT_OK" && td != "EQUIPMENT_OK" && pd != "EQUIPMENT_OK") {p.maxSpeed -= 50;}
if(pg == "EQUIPMENT_OK" && pd != "EQUIPMENT_OK" && td != "EQUIPMENT_OK") {p.maxSpeed += 50;}
if(tg == "EQUIPMENT_OK" && pd == "EQUIPMENT_OK") {p.maxSpeed -= 100;}
if(pg == "EQUIPMENT_OK" && td == "EQUIPMENT_OK") {p.maxSpeed += 100;}
log(this.name, "maxspeed post = " + p.maxSpeed);
}
equipmentAdded
function won't keep adjusting your speed when non-related equipment items are added.