-
Notifications
You must be signed in to change notification settings - Fork 991
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(ships): Add "auto explosion" tag to create explosions fitting to the ship #10071
base: master
Are you sure you want to change the base?
Conversation
Note: could be expanded to add a multiplier to support higher |
Bear in mind that MZ eventually ditched this formula for T2+ ships because the explosions ended up getting way too big. I think it'd make sense to allow this token to have a decimal value next to it that can be used to scale the default explosion. So
Data keys shouldn't require a specific ordering to function. If one value needs information from another to work, that should be done in FinishLoading() functions. |
It might also make sense to calculate the explosion damage on the fly when a ship explodes, should we want to concern ourselves with outfits that can increase/decrease the shields/hull of a ship. |
We did not until now, so I would leave that to another PR, if that's ok. |
Blast radius is lower relative to damage for higher-tier ships, so it wouldn't be a simple case of applying the same scaling factor to all four values. |
did that
and that still need to test it |
could we square the multiplier for blast radius or something like that? |
If we would want to do so, the LoadExplosion in Weapon would also be helpful so it lays at least some groundwork. |
I think the simplicity comes in the fact that this node would be doing calculations for you rather than you needing to calculate what these values would be given a ship's hull and shields. That is, should we tweak the hull and shields of a ship, we don't then also need to tweak the explosion. So even if the node looked something like this, it would still be simpler to use:
|
this almost looks like something that should be moved into a struct? |
also could this be moved out of the attributes section? |
Given how this is set up, I think it does make more sense as a direct child of |
implemented, will update description, still needs testing XD |
Co-authored-by: TomGoodIdea <108272452+TomGoodIdea@users.noreply.github.com>
source/Weapon.h
Outdated
@@ -59,6 +59,8 @@ class Weapon { | |||
public: | |||
// Load from a "weapon" node, either in an outfit, a ship (explosion), or a hazard. | |||
void LoadWeapon(const DataNode &node); | |||
// Load attributes that represent a ship explosion. | |||
void LoadExplosion(double blastRadius, double shieldDamage, double hullDamage, double hitForce); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LoadExplosion
feels like an inappropriate name given that the method doesn't load the data from anything. It is given some values and it assigns some of its members those values.
I like SetExplosion
more.
source/Ship.cpp
Outdated
@@ -601,6 +619,20 @@ void Ship::Load(const DataNode &node) | |||
// loaded yet. So, wait until everything has been loaded, then call this. | |||
void Ship::FinishLoading(bool isNewInstance) | |||
{ | |||
// Automatically create an explosion for this ship if requested but | |||
// only if the ship does not already have a defined explosion. | |||
if(autoExplosion.baseMult > 0. && !baseAttributes.IsWeapon()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put autoExplosion
in an std::optional
.
Co-authored-by: warp-core <warp-core@users.noreply.github.com>
Co-authored-by: warp-core <warp-core@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to code via phone
@warp-core i think I adressed your comments |
// Automatically create an explosion for this ship if requested but | ||
// only if the ship does not already have a defined explosion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure that we to have logic for explosion hierarchy? I'm not sure if there's a use-case for overriding the automatic explosion, so just directly setting the explosion in Load
would be nicer and make it so that not every ship needs to carry around a vestigial autoExplosion
variable that's never used again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Amazinite requested so.
Co-authored-by: Daniel <101683475+Koranir@users.noreply.github.com>
Co-authored-by: Daniel <101683475+Koranir@users.noreply.github.com>
tested, seems to work |
Feature
This PR addresses the bug/feature described in
my dreamsa stream by saugSummary
This takes the default explosion formula from the wiki:
and implements it in game with the name "auto explosion"
it can be useful for not having the worry about changing explosion values every time you change the ships hull/shields as it updates them automatically, note that this only works in data files and not in saves, as the automatically created weapon will be normally saved
full syntax:
final calculation:
Usage examples
Instead of:
now do:
Testing Done
not yet