
...
Team Singh Speed
Krait



Mamba



Sidewinder



Moderators: winston, another_commander
Ahh, a more interesting ship script example than my mothership-making-escorts-attack-station one.LittleBear wrote:Think I'll have to make it a condition that you are Clean to enter the race (otherwise the wheaze for detecting that the player has cheated by lasering up the opposition won't work).
Code: Select all
this.beingAttacked = function(attacker)
{
// Find first umpire in system, assuming there will only be one.
var umpire = system.shipsWithRole("littlebear-race-umpire")[0];
if (umpire)
{
umpire.script.racingShipAttacked(this, attacker);
}
}
Code: Select all
this.racingShipAttacked = function(victim, attacker)
{
// Is there a race on?
if (this.raceInProgress)
{
var victimIndex = this.participants.indexOf(victim);
var attackerIndex = this.participants.indexOf(attacker);
// Is the victim in the race?
if (victimIndex != -1)
{
// Is the attacker in the race?
if (attackerIndex != -1)
{
// Penalty for attacker, bonus for victim.
this.timePenalty[victimIndex] -= 5;
this.timePenalty[attackerIndex] += 15;
}
else
{
// Participant was attacked by non-participant.
// Send in 30% of the muscle.
this.sendProtectionAfter(attacker, 0.3);
}
}
}
}
this.sendProtectionAfter = function(whom, proportion)
{
function makeShipAttack(ship)
{
// Attack whom with probability proportion.
if (Math.random() <= proportion)
{
ship.target = whom;
ship.setAI("interceptAI.plist");
}
}
// Call makeShipAttack() on all littlebear-race-protectors.
var protectors = system.shipsWithRole("littlebear-race-protectors");
protectors.forEach(makeShipAttack);
}
// Additional umpire functions left as an exercise
It is my contention that designing ship liveries is an inherently OXP-related activity, and I don’t see how a thread in Expansion Pack can’t be used for wiki-enhancement.Captain Hesperus wrote:I'd prefer it if the OXP development was moved and the actual create-a-race-team-livery/biography remained in Discussion, since I was originally intending to enhance the Wiki.
Both of these things will be much easier to do with ship scripts in 1.70. It may well be worth waiting.LittleBear wrote:Cheers. 59 of the blighters to make a course and had to give each one its own shipdata entry as they each need a facing_position to make them face each other. … The racer AI is gonna be a bit of a pain as it'll need 59 states all with go:pwm co-ordinates for each ring.
No. I have no intention of doing anything to the ship behaviour methods (the core routines that implement, well, the behaviours of ships) before the next full release. I’m making a conscious effort not to add any more major feature changes, so that it will actually be ready at some point. :-)LittleBear wrote:Will 1.70 mean ships have the "sense" to avoid things in the way?
Probably whatever they’re doing now. However, the JavaScript scripting model allows you to perform calculations on positions, so it will be possible to make each ship target a slightly different part of the ring. If you want to be fancy about it, it may be possible for each ring to keep track of which NPC racers are heading for it and assign them different target points. This won’t necessarily stop their courses from intersecting, though.LittleBear wrote:As the ships are flying to the same pwm point, will ship B pass ship A (giving the overtaking effect I'm after - even if after overtaking he hit the next ring after passing Ship A and have a "racing incident" but still pass ship A) or will he just go smack into the back of him as both are taking the same angle (albiet at different speeds) to the pwm point?