Old Murgh wrote: ↑Sat Jul 09, 2022 11:27 pm
I was wondering if there was a way to make the above script apply equally to both primary roles xpat and xpatesc, or if I should ditch the plan and risk the loop, or a find a smarter solution.
This slight change to the if condition should help:
Code: Select all
if (ship.primaryRole == "xpat" || ship.primaryRole == "xpatesc")
Old Murgh wrote: ↑Sat Jul 09, 2022 11:27 pm
I then looked to how I would continue the conversation or offer different paths, but I didn't do it quite right.
Simply increasing the IDcounter evidently isn't enough.
...
This ended up with comm#2 eclipsing #1, so still just one option in addition to the greet, taunt and 5Tdemand..
Here you didn't add new shipSpawned and $transmitCallback, but replaced them. There should be only one shipSpawned and each transmitCallback must be stored in a separate variable. You are not limited the "transmitCallback" name and can use more descriptive names if you like. If many dialogues are planned, I would recommend to do this, it can help in the long run.
Returning to the topic of adding new comms:
This code will add two custom available communication options at the start of a conversation:
Code: Select all
this._IDcounter = 1; // several ships can be spawned in one second, so clock.adjustedSeconds is not enough for ID uniqueness
this.shipSpawned = function(ship) {
if (ship.primaryRole == "xpat" || ship.primaryRole == "xpatesc") {
this._bcc.$createMessage({
messageName: "myXpatMessage_status" + this._IDcounter++, // a unique ID for this message
displayText: "Inquire Xpat status", // what to show in the BCC MFD
messageText: "Rickety Xpat, are you in need of assistance?", // the actual text of the transmission,
ship: ship, // pass the reference to the ship that has just spawned
transmissionType: "target", // this message is for a particular ship, not a general broadcast
callbackFunction: this.$inquireStatusTransmitCallback.bind(this, ship), // the function that is called once the player sends the message, and includes the ship reference as a parameter
deleteOnTransmit: true, // true here means the message option will disappear from the BCC MFD after transmission
delayCallback: 2, // number of seconds to wait after transmission before sending the reply
hideOnConditionRed: false // false here means that the message option will always be available, regardless of any combat
});
this._bcc.$createMessage({
messageName: "myXpatMessage_slavedemand" + this._IDcounter++, // one counter stiil should be enough
displayText: "Demand slave offering",
messageText: "Vulnerable Xpat, select your healthiest specimens and eject to my custody, and I will let the rest of you live",
ship: ship,
transmissionType: "target",
callbackFunction: this.$demandSlavesTransmitCallback.bind(this, ship),
deleteOnTransmit: true, // true here means the message option will disappear from the BCC MFD after transmission
delayCallback: 5, // number of seconds to wait after transmission before sending the reply
hideOnConditionRed: false // false here means that the message option will always be available, regardless of any combat
});
// You can add more here! (But they will also be available immediately)
}
}
// Variable naming is my passion, so feel free to change those names for better ones
this.$inquireStatusTransmitCallback = function $InquireStatusTransmitCallback(ship) {
// we get here after the player has send the message, and after whatever delay was requested
ship.commsMessage("Kind Commander, we ware indeed in a sorry state and in need of help.", player.ship);
// Add one or more $createMessage here and they will appear after status inquring
}
this.$demandSlavesTransmitCallback = function $demandSlavesTransmitCallback(ship) {
// we get here after the player has send the message, and after whatever delay was requested
ship.commsMessage("You lowlife! We sacrifice nobody and would sooner die together!", player.ship);
}
This code will add one custom available communication option after using which another one will appear:
Code: Select all
this._IDcounter = 1; // several ships can be spawned in one second, so clock.adjustedSeconds is not enough for ID uniqueness
this.shipSpawned = function(ship) {
if (ship.primaryRole == "xpat" || ship.primaryRole == "xpatesc") {
this._bcc.$createMessage({
messageName: "myXpatMessage_status" + this._IDcounter++, // a unique ID for this message
displayText: "Inquire Xpat status", // what to show in the BCC MFD
messageText: "Rickety Xpat, are you in need of assistance?", // the actual text of the transmission,
ship: ship, // pass the reference to the ship that has just spawned
transmissionType: "target", // this message is for a particular ship, not a general broadcast
callbackFunction: this.$inquireStatusTransmitCallback.bind(this, ship), // the function that is called once the player sends the message, and includes the ship reference as a parameter
deleteOnTransmit: true, // true here means the message option will disappear from the BCC MFD after transmission
delayCallback: 2, // number of seconds to wait after transmission before sending the reply
hideOnConditionRed: false // false here means that the message option will always be available, regardless of any combat
});
// You can add more here! (But they will also be available immediately)
}
}
// Variable naming is my passion, so feel free to change those names for better ones
this.$inquireStatusTransmitCallback = function $InquireStatusTransmitCallback(ship) {
// we get here after the player has send the message, and after whatever delay was requested
ship.commsMessage("Kind Commander, we ware indeed in a sorry state and in need of help.", player.ship);
this._bcc.$createMessage({
messageName: "myXpatMessage_slavedemand" + this._IDcounter++, // one counter stiil should be enough
displayText: "Demand slave offering",
messageText: "Vulnerable Xpat, select your healthiest specimens and eject to my custody, and I will let the rest of you live",
ship: ship,
transmissionType: "target",
callbackFunction: this.$demandSlavesTransmitCallback.bind(this, ship),
deleteOnTransmit: true,
delayCallback: 5,
hideOnConditionRed: false
});
// Add more here and they will appear after status inquring
}
this.$demandSlavesTransmitCallback = function $demandSlavesTransmitCallback(ship) {
// we get here after the player has send the message, and after whatever delay was requested
ship.commsMessage("You lowlife! We sacrifice nobody and would sooner die together!", player.ship);
}