Ok I've got quite a few questions about scripting.
1. Can scripts be attached to individual ships (or at least individual classes)? and can those scripts be fired at specific times, like on ship death or hitpoints left?
Yes, that's exactly what conditional hooks aim to do. Given a series of conditions (Mission, ship class, ship, etc) you can define a series of hooks that are triggered by actions (Collisions, warpout, and death so far)
2. Can you create the explosions effects using scripts (same as the sexp version)?
Not directly.
3. Can you get the offset of origin of subsystems with it?
Yes. For example:
offset = ship['engine01'].Position - ship.Position
4. Are variables in a script attached to specified ships (i.e. their members of the ships class)
Yes and no. The scripting system currently defines a set of variables for ships; however, you can only modify or use those variables, you cannot add news ones. (Although there is nothing stopping you from making an array to store the variables instead)
5. Are arrays supported?
YesThis is what I'm trying to do in pseudocode:
OnShipCreated:
// ExplodeSubSystem is a small untargettable subsystem that determines where explosion will occur
ExplosionPointX[0] = GetSubSystemXPos (ExplodeSubSystem0)
ExplosionPointY[0] = GetSubSystemYPos (ExplodeSubSystem0)
ExplosionPointZ[0] = GetSubSystemZPos (ExplodeSubSystem0)
// Repeat for any additional ExplodeSubSystem subsystems
end
OnShipDestroyed:
while (not (end of mission))
WhichOne = random (0, Number of ExplodeSubSystems -1)
DoExplosion (ExplosionPointX[WhichOne], ExplosionPointY[WhichOne], ExplosionPointZ[WhichOne])
Sleep For Random Time
end
end
I'm trying to implement this http://www.hard-light.net/forums/index.php/topic,43796.0.html without having to have to make SEXP's and variables for each mission.
Besides the lack of the explosion function, the other things stopping you from doing this would be that the On Ship Destroyed hook would trigger only once, as scripting is on the same thread as the rest of FS2_Open. So rather than having the explosions actually occur in that hook, you'd need to store the data in a variable that would be used to create the explosions in another hook, that would trigger regardless of the ship's status (eg dead or alive) and would depend solely on the variable.
The other thing is that the On Ship Destroyed hook doesn't provide a variable to the ship actually getting destroyed. You could of course get the variable yourself by simply indexing mn.Ships[] with the ship's name (eg mn.Ships['Alpha 1']).
All the new scripting stuff is parked in
this build.
EDIT: Made a change to the On Death Hook so that it will provide a "Self" and "Killer" variables to the On Death hook. Asteroid and debris death will provide a "Self" variable to the On Death hook. This is not in the aforementioned build, but will be included in future builds.