Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(code): Permanent changes to the player's ship via conversation actions. #190

Open
wants to merge 30 commits into
base: experimental
Choose a base branch
from

Conversation

Zitchas
Copy link
Member

@Zitchas Zitchas commented Jan 3, 2025

Feature

This PR addresses the feature discussed in #184

Summary

The ship has the potential to be the second most important character in the story, second only to the pilot/captain themselves. This is magnified by the fact that while the pilot/captain is the one doing all the talking and interaction in missions, in the rest of the game it is the ship that is doing all the actions. The ship gets shot at, runs away, charges the enemy, kills the enemy, carries the cargo, picks up the debris, etc. We spend virtually all our time dealing with the ship: Buying it, selling it, outfitting it, maneuvering it, praying it doesn't get destroyed, etc. Whereas the Pilot... We get to pick their name, and that's it. For the entirety of the game the pilot is an utter blank void with no discernible attributes or features other than a name, combat ranking, some popularity scores, and a list of what they've done.

Up until now, the ship is a cookie cutter copy. If you have a sparrow, fly it for decades, win the Free Worlds war with it, lead an invasion of Pug occupied territory with it, and travel to the center of the galaxy and back... And it will be, in every single respects, the exact same hull as the sparrow that you buy right out of the shipyard. There is absolutely zero uniqueness, character, or personality in that ship. Many of us love flying the Lampyrid or Emerald Sword precisely because they are unique. They have that personality that pretty much nothing else does.

This aims to change that. This is intend to provide content creators with the ability to, primarily in the course of mission conversations, apply permanent changes to the base ship. These are not outfits to be removed and transferred around, nor are these changes to the overall ship class. If the player buys another ship of the same type, it will not have whatever changes have happened to the other(s). These are changes that will render the ship they are applied to unique.

Scope:

I am initially planning on implementing this strictly for use within the Action node of conversations. That being said, There's really three places where the ship proper could be changed:

  • Stuff happening to the ship (getting disabled, getting overheated, visiting particular systems, etc.)
  • Story (things happening in conversations)
  • Work being done to the ship (improved planetside ship interaction ideas we've bandered about in the past, such as refueling, repairs, modifications, etc)

So while I am currently focused on the Action node in conversations, I would prefer to make it possible for the code to be reutilized in other places in the future. I'm willing and inclined to go the extra mile in order to make it easy for future efforts to use this code to make permanent changes as well.

Likewise, while I am initially planning on keeping it simple and just applying whatever the change is to the current flagship; in the future I would like to give content creators the flexibility to specify specific ships via UID that the changes apply to, regardless of where that ship is or whether it is the flagship or not. Likewise specifying general models of ships. (ex. "This change applies to the first Argosy")

Usage examples

  1. In the course of the story, your ship suffers some unusual problem. Perhaps the player has a saboteur onboard this ship resulting in a weaker hull: attributes add hull -100
  2. As thanks for saving them, the engineering team on the research ship implements a tweak to your fuel system resulting in your ship having greater fuel capacity: attributes add fuel 150
  3. Alien invaders have attached something to your ship, and a mission chain will check for it later: attributes set "parasite" 1

Goal:

conversation [<name>]
	action
		attribute <add or set> <attribute> <quantity>

attribute = Is the keyword that the game looks for to know it is going to be changing an attribute.
add = specifies that the value will be added to the current attribute value (can be negative or positive)
set = specifies that the value will replace the current attribute value.
name of the attribute that is to be added or set to.
how much to be added (can be negative) or what to set the value to. Some things can be negative, some can't.

Testing Done

Some in-game testing of various attributes.

NOTE:

if you have comments, questions, or general suggestions about the idea, please post them on the
Request For Comments - RFC: Ability to make permanent changes to player's flagship or specific ship in fleet #184 .

Please reserve comments here on this PR for things directly pertaining to the code that I have implemented.

…ier to search for

This is just the starting point. Nothing much to see here currently.
@Zitchas Zitchas added enhancement New feature or request code Things that focus on the mechanics and internals of how they have engine works. labels Jan 3, 2025
and some basic error checking for number of elements.
source/GameAction.cpp Outdated Show resolved Hide resolved
I can't see it doing anything yet, but I think this should in theory write the results to the save file, possibly in the details for the saved job.
It succesfully reaches L530 in GameAction, but it does not enter the For. I'm not sure why, but the log entries at L533 and L537 never turn up; but the one at L530 does all the time.
@Zitchas
Copy link
Member Author

Zitchas commented Jan 9, 2025

It succesfully reaches GameAction L530 (as it puts that statement in the log) but it does not enter the for loop in the next line for some reason.
It also successfully reaches GameAction L253 and displays the error message that I have programed in there, displaying the trace as expected.

(note this is copied from the last time I ran it, before I corrected the text to read output L253 instead of the now erronoeous L267)

Trace: Test Data output L267: hull 500.000000
file C:\ZDev\GitHub\ZEndlessSky\endless-sky\data/human\jobs.txt
L5117:   mission "AAA Outfit Give Testing 12"
L5127:     on complete
L5128:       attributes add hull 500

Trace: Test Data output L267: hull 1300.000000
file C:\ZDev\GitHub\ZEndlessSky\endless-sky\data/human\jobs.txt
L5117:   mission "AAA Outfit Give Testing 12"
L5127:     on complete
L5131:       conversation
L5132:         action
L5133:           attributes add hull 1300

So it succesfully read both the attribute name and amount to change it by in that spot.

Zitchas and others added 3 commits January 9, 2025 15:20
Vitalchip had a moment of inspiration that solved why the map kept getting erased, and now the atribute changes are making there way all the way through the code, and at least in the case of hull, temporarily changing the hull value that is stored in the player's save file but outside the "attributes" section of their ship.

So it's not entirely solved yet, but massive progress.

Co-Authored-By: vitalchip <[email protected]>
We can now successfully add attributes to the base ship hull!

Needs sanity checks and perhaps a clean up and stuff, but in any case, awesome!

Many thanks to VitalChip, without whom this would have taken much, much longer. If I even managed it at all.

Co-Authored-By: vitalchip <[email protected]>
@Zitchas
Copy link
Member Author

Zitchas commented Jan 10, 2025

It works! The code now succesfully permanently alters base hull attributes of the player's flagship. The below code (which is currently in the job in the PR, but will be removed before merging) is fully functional and will add the specified hull or cargo space to the player's ship.

This is strictly just the modifying capability. You can add or subtract from attributes, but not set. That part is still to come. Note that there is no inherant safety mechanisms in this (unless those present elsewhere magically kick in), so doing something like setting your hull to negative is possible as of right now.

mission "AAA Outfit Give Testing 13"
	name "AAA Outfit Give Testing v13"
	description "Testing mission v13!"
	job
	repeat
	source
	on accept
		conversation
			`Test text v13`
	on complete
		attributes add hull 500
		attributes add "cargo space" 34
		payment 500
		outfit "Supercapacitor"
		conversation
			action
				attributes add hull 1300
				attributes add "cargo space" 41
			`Concluding v13`

@Zitchas
Copy link
Member Author

Zitchas commented Jan 12, 2025

Part 1 of adding "set". Part 3 to follow in a few hours.

In testing found that there's a slight problem when mass is set to negative. It displays wrong in-game, but then appears correctly at 0.01 after reloading.
@Zitchas
Copy link
Member Author

Zitchas commented Jan 12, 2025

OK, both add and set both work now. And to the extent that I have tested, work correctly 100% of the time that the end value is valid.

The one place that still needs work is on the handling of negative mass. I haven't tested in the "add" section yet, but in the "set" section when I set the mass to something negative, the code should catch that and change it to 0.01. In-game isn't showing that, though, it just looks like it didn't happen. However, after reloading the game shows that it has in fact saved the 0.01 mass correctly.

So it seems like I just need to force it to update something somewhere, as the actual values seem to be working correctly.

@warp-core
Copy link

Mass and cost are stored separately in Outfit. You're using a method that just updates the Dictionary attributes field of Outfit, but, at runtime, mass and cost are not read from that collection, they are stored in their own fields in Outfit.

@Zitchas
Copy link
Member Author

Zitchas commented Jan 15, 2025

Thanks!

@Zitchas Zitchas marked this pull request as ready for review January 17, 2025 03:13
@Zitchas
Copy link
Member Author

Zitchas commented Jan 17, 2025

Everything works! Needs more testing, of course, but as best I can tell everything is working. add or set whatever attribute you want.

Oh, cost will probably still act a little funny, not updating until reload. Might need to handle that special too, but all the more relevant values. Mass, drag, outfit space, etc. should all work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Things that focus on the mechanics and internals of how they have engine works. enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants