Preamble: I know perfectly well that I can do what I'm about to describe in FRED. As kind of a personal challenge, to develop a better grasp on FSO's more arcane features, I want to do this via lua.
Ok, I've been bugging people on IRC about this for a while, and I finally got pointed towards the -script_output command line option (holla Zacam). The output, while very in-depth and intriguing, hasn't helped me towards my current goal: assembling a script that can register multikills (aka a number of kills in rapid succession). I think this would be fun for some single-player missions, and could potentially be entertaining in multi, but the biggest stumbling block I've ran across: I can't seem to find how FSO actually tracks "who killed what".
I mean, internally, there's some tracking system. That's obvious. What I'm wondering is if I can co-opt some of those functions. Digression: I'm a lua novice, but I've seen enough of the syntax and had enough general programming experience to figure things out as I go. I've got most of a script ready to go (I think), but I'm still missing a few key hooks.
Here's what I've got now, please let me know if I'm totally off-base or not:
[
multikill=0
timemark=(initialzed)
missiontime=mn.getMissionTime()
for i=1, mn.getNumShips() do
shipteam=ship.Team
if shipteam~=playerteam and (ship was killed by player)
multikill++
timemark=missiontime
if multikill==2
("double kill" praise/bonus of some sort)
(continue as far as desired)
if missiontime>(timemark+3)
multikill=0
]
I'm currently co-opting some ideas from the
death flash script, which is why I'm using that weird
for loop. I'd much rather have this script checked on a kill-by-kill basis, rather than continuously (yeah yeah, I know the timing bits will need to run continuously).
Feedback?