Just to inform: any ship that has a script defined will no longer use the launch-actions, death_actions and so on. The three places were this happens with your oxp the launch_actions can be completely removed. (setting Ai at this point is not necessary)
But maybe also replace the other occasions with a script.js. Not spawning a ship in a death_action but with a script like:
Code: Select all
this.shipDied = function()
{
let drone = this.ship.spawnOne("role")
if(this.ship.target)
{
drone.target = this.ship.target
drone.setPosition(this.ship.position)
}
}
Advantage of a js script is that when you spawn the thing you can store the entity in a variable and do some additional settings. e.g. transfer the target to the spawned ship and put the drone exactly on the position of the launcher. That way the drone needs not looking for a target itself but still goes for the target the player aimed at. That way you can use the missiles you started with.
That way you you must of cause create a different script for each launcher. But a bunch of almost identical scripts ask for a more intelligent approach. In shipdata.plist you can define a "script_info" that is a directory of variables that are accessible by the script:
Code: Select all
script = "droneLauncher.js";
"script_info" = {"launch_name" = "antithargoid_drone"; };
The script now becomes:
Code: Select all
this.shipDied = function()
{
let drone = this.ship.spawnOne(this.ship.scriptInfo.launch_name)
if(this.ship.target)
{
drone.target = this.ship.target
}
}
Now you have an universal script that works with all your launchers. You only define in the different launch_names in shipdata.plist
On testing I just noticed that the "shipDied" event never happens when a ship is exploded by AI script. So in the AI you must help a little by explicit call this event after exploding:
Code: Select all
ENTER = (becomeExplosion, "sendScriptMessage: shipDied");
You can do the same thing with your 3 current, almost identical, scripts. Put the two differences in a script_info and use this from within the script.
Sounds difficult? By what I see from your scripts I think you get it quick and you'll publish the first oxp that uses the script_info.