smcameron / space-nerds-in-space

Multi-player spaceship bridge simulator game. Captain your starship through adventures with your friends. See https://smcameron.github.io/space-nerds-in-space
GNU General Public License v2.0
728 stars 73 forks source link

We don't have enough mission scripts #127

Open smcameron opened 6 years ago

smcameron commented 6 years ago

I could use some help coming up with mission scripts. Mission scripts are written in Lua.

Got ideas for some mission scenarios? Open an issue describing the mission you'd like to see. Do you know Lua? We need more mission scenario scripts. Take a look at lua-api.txt and at some of the mission scripts in share/snis/luascripts. Reasonably good examples are Saving Planet Erph, Space Pox. See also these tutorial videos about how to create mission scripts:

MCMic commented 5 years ago

0001-Added-too_close_to_planet_or_sun-lua-function.patch.txt 0002-Add-ROYAL-WEDDING-mission-script.patch.txt

First patch is an improvement of too_close_to_other_planet_or_sun function and it makes it available from lua scripts under the name too_close_to_planet_or_sun. The second patch adds the mission script I’ve been working on. I advise that you play it at least once before reading through it (it’s fine if you do not push it in the mean time).

I expected to be able to test it in real conditions last week-end but the session was canceled due to crew members canceling. I tested it alone through and was able to finish it without bugs. (well I did encounter bugs but I fixed them).

You will most likely find inaccuracies in the english language used, do not hesitate to report them afterwards (and any other problem/question you may run into, really)

Enjoy.

MCMic commented 5 years ago

(The mission script uses the lua function added by the first patch, of course, which is why I posted both of them together. Just realized I did not state that in my last message.)

smcameron commented 5 years ago

Holy crap! Awesome! Haven't looked at the mission script yet.

Congratulations on being the first person to create a mission script other than me!

smcameron commented 5 years ago

So I see one problem (maybe two) with making this too_close_to_other_planet_or_sun function lua-callable.

The first is just an implementation detail, it needs to call pthread_mutex_lock(&universe_mutex) before calling too_close_to_other_planet_or_sun and pthread_mutex_unlock(&universe_mutex) after to protect access to the go[] array.

The 2nd concern is more aesthetic. This function is kind of specialized and is otherwise only called when adding planets during initial universe creation (or indirectly via REGENERATE.LUA, when it's creating a new universe again). It's kind of a strange API to expose.

I might have a clearer idea of what might be better to do instead once I see what you're using it for, but register_proximity_callback() and object_distance() strike me as possible alternates.

MCMic commented 5 years ago

Hum I thought mutex were only needed for adding/editing stuff, sorry.

I just use it to code kind of the same thing as add_planets: add some random planets so that the planets useful to the story are not the only ones out there.

Exposing an api to directly add random planets would work too but that would be more generic, since we may want to find a "quiet" place for something else that a planet at some point.

smcameron commented 5 years ago

Ah, I see you are using too_close_to_other_planet_or_sun for a similar purpose -- for spreading planets around somewhat randomly.

smcameron commented 5 years ago

Ok, I played through the mission. Pretty cool! Took me awhile to find the "restrain prince" button, ha.

I think there were supposed to be some ships trying to attack me when the warp drive first broke down, but I repaired it quickly so they never even got a shot off and I didn't notice they were even there right away. Maybe need to move them closer?

The prince says something about it, "how can they dare? kill this vermin." I didn't know what that was about until I happened to look on the demon screen and saw some ships far behind me with a red dotted line to me (means they're attacking me).

smcameron commented 5 years ago

Hum I thought mutex were only needed for adding/editing stuff, sorry.

It's to avoid have another thread changing go[] while your thread is scanning it.

smcameron commented 5 years ago

I committed both of these (with the small change to use the mutex locking).

MCMic commented 5 years ago

[SPOILER ALERT]

Ok, I played through the mission. Pretty cool! Took me awhile to find the "restrain prince" button, ha.

Yeah, I intended that to be hard to find. And it happens at a moment you’re concentrating to dock and the queen is pressing you. In the code you’ll see I have a TODO for adding some noise to make it clearer that someone is crashing stuff. Not sure if there is an API yet for that. The warp engine failure would be better too with an explosion sound. That being said, if you had to restrain the prince you went for the "bad ending", kind of. There is an other ending where you save him.

I think there were supposed to be some ships trying to attack me when the warp drive first broke down, but I repaired it quickly so they never even got a shot off and I didn't notice they were even there right away. Maybe need to move them closer?

Yeah, I don’t know about that. They announce themselves on the radio, and I thought people would take the time to figure out what’s happening, with the explosion and the bodyguard death. I wanted people to have the time to see them coming and prepare, as I usually warp with shields and phasers down. But they are kind of slow. I think I should try to add them on the other side, between the players and the destination so that at least the impulse drive is not enough to lose them. Did you have a look at the manifest at that point? ;-)

A cool thing I would like to add is to have the Royal Mothership docked next to you at the beginning and at the wedding station. But it seems NPC ships cannot dock.

smcameron commented 5 years ago

I have a TODO for adding some noise to make it clearer that someone is crashing stuff. Not sure if there is an API yet for that. The warp engine failure would be better too with an explosion sound.

It's possible to play sound files from Lua now, since: d3d427473e7c5e1895c71ef2a86703dc7ff94236

MCMic commented 5 years ago

0001-Added-sounds-to-ROYAL-WEDDING-mission.patch.txt I did not test this but it should play sounds when the engine explodes and when the prince panic.

smcameron commented 5 years ago

Applied as df3e467de85c25c7b73b6b09ac08c2c9153d7d0e

smcameron commented 5 years ago

@MCMic Some minor feedback on the Royal Wedding mission: We played it a couple times at HackRVA last night. Neither attempt was successful, both times we got destroyed by the attackers after the warp drive failure, and it was decided not to try a third time. One of the crew members was very prone to fits of whining and complaining though ( https://www.youtube.com/watch?v=dsx2vdn7gpY ), so I don't know that I'd take this feedback too seriously (after I all, I was able to succeed just by myself after a few attempts.)

smcameron commented 5 years ago

I did not test this but it should play sounds when the engine explodes and when the prince panic.

This worked, at least the engine exploding part, I don't think we got to the prince panicking part.

MCMic commented 5 years ago

Thanks for the feedback. You succeeded but iirc you fleed, fighting must be a viable option. I did not have the chance to try the mission with a crew yet. When I do I'll try to see if it needs changes. It's ok if it's hard, but it should be winable. I also kind of hoped a ships balancing would happen before I looked into that. I need to get back on the ship model and stats patch at some point, and forget about changing the wombat scale so it can get merged at some point.

smcameron commented 5 years ago

@MCMic Was looking at the royal wedding script, and I found this, which may be a bit too aggressive:

https://github.com/smcameron/space-nerds-in-space/blob/master/share/snis/luascripts/MISSIONS/ROYAL-WEDDING.LUA#L254

number_of_rebels    = 4;
set_variable("MISSILE_FIRE_CHANCE", "5");

This variable, MISSILE_FIRE_CHANCE, controls how likely the NPC ships are to fire homing missiles, and has no effect on lasers or torpedoes.

The missiles being fired by NPC ships at the player is somewhat problematic, as they are homing missiles and travel quite quickly and do a lot of damage. I should probably make the missiles do less damage. There is chaff, which will generally work well against missiles, however, the crew needs to be really on the ball to be able to deploy it quickly enough. Might be better to let your gang of 4 rebels rely on lasers and torpedoes.

MCMic commented 5 years ago

Yeah it felt too much like cheating to prevent them from using missiles. Maybe those should be slower to give time for using chaff.

I still hope to try PvP some day but I feel like with current state battles would be instantly finished and only rely on who launch all its missiles first.

MCMic commented 5 years ago

I think there were supposed to be some ships trying to attack me when the warp drive first broke down, but I repaired it quickly so they never even got a shot off and I didn't notice they were even there right away. Maybe need to move them closer?

Regarding this, playing the mission several time we noticed the damage to the warp drive is somewhat random and sometimes minimal. It would be better if the mission script was able to really damage the warp drive as wanted. Here is should completely damage the 3 components of the drive so that the robot needs to go 3 times to the repair place and it takes a bit of time to get back up. (well you can warp with only 2 of them repaired I guess)

MCMic commented 5 years ago

This patch lessen the missile chance from 5 to 2, and makes sure the prince gets off the player ship at the end of the mission.

0001-Fixes-in-ROYAL-WEDDING-mission-script.patch.txt

@smcameron Could you go through the transmissions in the mission script and fix any english mistakes if you find any?

smcameron commented 5 years ago

Thanks, applied. Sure, I can review it, probably not today though, maybe Monday.

smcameron commented 5 years ago

Regarding this, playing the mission several time we noticed the damage to the warp drive is somewhat random and sometimes minimal. It would be better if the mission script was able to really damage the warp drive as wanted. Here is should completely damage the 3 components of the drive so that the robot needs to go 3 times to the repair place and it takes a bit of time to get back up. (well you can warp with only 2 of them repaired I guess)

This is a consequence of the history of the project... The damage was originally represented as a single byte value for each system before the damage control system existed -- and it really still is, because this single byte value ties into the power/coolant model. The damage to this single byte value is then distributed among each of the 3 associated damage control systems, and while I don't remember the details, some relationship is enforced such that the sum of the damage control subsystems == 3 * this single byte value -- or something like that, I don't quite remember the details at the moment. I can work on exposing the innards of the damage control system to Lua, but not today. I think it shouldn't be too hard, the hardest part is probably maintaining the weird relationship between this single byte value and the 3 subsystems.

smcameron commented 5 years ago

@smcameron Could you go through the transmissions in the mission script and fix any english mistakes if you find any?

Gave it a shot: 407aa2f0ca71661997c7adcc5befa0e3afcf734b

smcameron commented 5 years ago

Regarding this, playing the mission several time we noticed the damage to the warp drive is somewhat random and sometimes minimal. It would be better if the mission script was able to really damage the warp drive as wanted. Here is should completely damage the 3 components of the drive so that the robot needs to go 3 times to the repair place and it takes a bit of time to get back up. (well you can warp with only 2 of them repaired I guess)

Ok, this should allow Lua scripts to better control how damage is distributed: 9d87946592d3c4c210431b4ed0a39b45cca55d96

MCMic commented 5 years ago

Regarding the comment in the file, iirc the prince reaction is after the rebels starts threatening on the radio, so that's fine.