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: New GM Commands, princess commands on map menu, graphics for some explosions #6183

Merged
merged 26 commits into from
Nov 23, 2024

Conversation

Scoppio
Copy link
Collaborator

@Scoppio Scoppio commented Nov 6, 2024

New GM Commands & Much More!

All the commands listed here are GM only, they allow the player who is a Game Master more freedom to change the game to the way they want the story to play out.
They would allow co-op games and RPG or dramatized games to have more events and give the GM more control over how they go.

Examples:

  • Custom scenario, a battle is happening while a space battle goes, every turn there is a chance a stray shot from a warship hits the ground mid battle.

  • A F5 hurrinane is moving towards the base and you need to evacuate the vehicles and people as fast as possible before they all die.

  • In the middle of the battle the day becomes night as the moon engulfs the sun.

  • The star of the system is pulsating, during round 10 it goes super nova, the planet you are playing is far away enough to not be instantaneously destroyed, but the temperature gets extreme and the atmosphere of the planetoid is stripped instantaneously, everyone that was outside a battlemek is dead. Is it worth keeping the fight?

GamemasterServerCommand

New type of ServerCommand, can only be used by gamemaster, it also has an automatic parser for its arguments with automatic error handling. Also has automated "documentation", using the descriptions for each variable as input for itself.

Screenshot 2024-11-14 at 23 49 54 Screenshot 2024-11-14 at 23 50 39

This extra complexity also allows for an automatic "dialog" setup that I implemented (its only in a functional state, not a good state).
Screenshot 2024-11-14 at 23 51 13

  • Added a new type of server command, the gamemaster server command, it has automated parsing, error handling, argument assertion, automated documentation (for /help), it also implements the necessary tools to automate the GM Menu commands.

  • New server commands accept both positional arguments and named arguments. Positional and named arguments can be used in the same command but positional arguments must come first. Named arguments may be used in any order (after positional arguments if those are being used). Example:

The following are equivalent and valid:

    /ob 5 10 200 5
    /ob x=5 y=10 dmg=200 radius=5
    /ob 5 10 dmg=200 radius=5
    /ob 5 dmg=200 radius=5 y=10
    /ob 5 10 radius=5 dmg=200

Command KILL - When you want something DEAD

/kill <id>
Kills (ID) unit at GM's discretion, needs to be enabled in the game options.

Command NOSMOKE - Clear skies

/nosmoke
Clears all smoke clouds in the board.

Command WEATHER - Change planetary conditions

/weather [...args]
Allows the GM to change the weather on demand

Command Disaster - Disasters

/gomorrah <type>
Cast a disaster (like in the old days of SimCity) to spicy things up (WIP)!
The cheat is a homage to SimCity "gomorrah" cheat code which would start a nuclear disaster.

Command OB - Orbital Bombardment

/ob <x> <y> [damage=#] [radius=4]
Calls in orbital bombardment at the end of the next weapons firing phase (WIP)!

Command ChangeOwner - Traitor 2.0

/changeOwner <UnitID> <PlayerID>
Gives a unit to a player.

Command Rescue

/rescue <UnitID>
Rescue from the board a single unit. A "forced flee" if you will.


(Very crude) GM command dialogs

Allows the gamemaster to manually enter the commands

Features:

  • Numerical spinners which obeys the limits set in the command arguments.
  • Enumerator picker/drop down for those more complex commands.
  • Numerical spinners for X and Y position defaults to current hex square (under the mouse when you right clicked on the map).
Screenshot 2024-11-14 at 23 26 11

GM Contextual Menu (Map Menu)

Ps: Some screenshots were taken early in development, so mileage may vary.

Added more functions to the map menu for GMs, most notable being:

  • Removed "Traitor" entry from Map Menu. I can roll back this change, but it was made because the current traitor functionality is very limited and the way it currently works does allow for big mistakes for those not used to how it works.
  • Added a new "Traitor" inside the GM menu, this uses a more contextual approach, it allows you to pick a unit in the hex as you would when targeting a unit.
Screenshot 2024-11-14 at 23 48 00
  • Added new "Kill Unit" inside the GM menu. Allows you to pick a unit in the hex as you would when targeting a unit.
Screenshot 2024-11-14 at 23 47 17
  • Added new "Special Commands" menu to the GM Menu. It lists all commands that are implemented with GamemasterServerCommand class.
Screenshot 2024-11-14 at 23 46 29 Screenshot 2024-11-14 at 23 49 18

Quick Access to Princess controls

  • You can now give orders to your allied royalty (Bots) using the right click menu, making the process of changing Princess' behavior, priority targets, etc, way easier.
Screenshot 2024-11-17 at 02 03 51

Graphics for BIG BOOM

Nukes and orbital bombardment have graphics.

image
image

Support for BIG BOOM

Exploding a nuke on the game is a sure way to grind everything to a halt, your big powerful PC may simply sit down crunching numbers with CPU at 100% for many minutes, and the result is a 5 miles long report with all the units taking tens of thousands of damage points. I added an early exit check that identifies if the unit is already "devastated", if true then it consider the damage processing for that unit done and goes for the next one.
With this small change, now releasing nukes that boil lakes and turn cities into craters is nothing but childsplay!

Copy link

codecov bot commented Nov 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 29.06%. Comparing base (a28fd13) to head (7da1ad0).
Report is 12 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6183      +/-   ##
============================================
- Coverage     29.09%   29.06%   -0.03%     
- Complexity    13981    13982       +1     
============================================
  Files          2647     2647              
  Lines        267373   267642     +269     
  Branches      47650    47674      +24     
============================================
+ Hits          77793    77794       +1     
- Misses       185696   185964     +268     
  Partials       3884     3884              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@Scoppio Scoppio requested review from IllianiCBT and SJuliez November 8, 2024 03:36
}
Report.addNewline(vDesc);
}
}
}

private void explosionDamage(Coords position, Vector<Report> vDesc, Entity e, int damage) {

Check notice

Code scanning / CodeQL

Useless parameter Note

The parameter 'position' is never used.
Copy link
Collaborator

@IllianiCBT IllianiCBT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw you requested I review this.

I don’t have enough working knowledge of the mm side of our codebase, so try not to review mm-specific stuff unless it’s super basic - and even then, I prefer not to get involved. Didn’t want you thinking I was just ignoring your request. :)

@HammerGS HammerGS added the For New Dev Cycle This PR should be merged at the beginning of a dev cycle label Nov 9, 2024
@BLR-IIC
Copy link

BLR-IIC commented Nov 10, 2024

I'm pretty excited to see this in progress. I've been turning over code in my head for making command line orbital bombardment work. I was going to borrow code from the nuke commands. I hope these commands see implementation!

@HammerGS
Copy link
Member

Random thought...how hard would it be to create a "GM Command GUI" a simple GUI that lists the commands and lets you input the values

@Scoppio
Copy link
Collaborator Author

Scoppio commented Nov 10, 2024

Random thought...how hard would it be to create a "GM Command GUI" a simple GUI that lists the commands and lets you input the values

I think its doable, I will do those in small steps. I want to release those first the way they are. I just need to make sure the terrain damage is not too bad.

@Scoppio
Copy link
Collaborator Author

Scoppio commented Nov 10, 2024

I'm pretty excited to see this in progress. I've been turning over code in my head for making command line orbital bombardment work. I was going to borrow code from the nuke commands. I hope these commands see implementation!

Thanks, I picked the nuke as an example and turns out it is pretty standard. Actually the nuke doesnt take things into considerations like VTOL. It also is very expensive because it reachs the entire board and the scale of it is madness (amount of damage, garanteed kill on hit, etc).

So I had to reimplement alot of stuff, but there is still too much code duplication here, and not everything of the Terrain Factor and terrain damage is properly implemented.

I think I will implement the damage terrain in small steps until it is completely implemented, but at least it will be "good enough" for the narrative play.

@Scoppio Scoppio self-assigned this Nov 15, 2024
@Scoppio Scoppio force-pushed the feature/kill-command branch from 1117d85 to 9f36d77 Compare November 15, 2024 04:04
@HammerGS
Copy link
Member

This was a request from the forums

If reworking the GM commands, can we get the Princess Ignore command on a right click menu somehow?

@HammerGS HammerGS requested a review from Sleet01 November 16, 2024 15:52
@Scoppio
Copy link
Collaborator Author

Scoppio commented Nov 16, 2024

This was a request from the forums

If reworking the GM commands, can we get the Princess Ignore command on a right click menu somehow?

I will take a look, depending of complexity I can push for a next release

@Scoppio
Copy link
Collaborator Author

Scoppio commented Nov 17, 2024

Added Nuke graphics, added controls for allied Princesses on the contextual map menu (right mouse button click on the map).

@Scoppio Scoppio changed the title feat: adds a couple of new commands for GMs on games. Feat: New GM Commands, princess commands on map menu, graphics for some explosions Nov 17, 2024
@@ -96,7 +96,7 @@ public static List<Coords> findCFWarningsMovement(Game g, Entity e, Board b) {

List<Coords> hexesToCheck = new ArrayList<Coords>();
if (pos != null) {
hexesToCheck = pos.allAtDistanceOrLess(range + 1);
hexesToCheck = pos.allAtDistanceOrLess(range);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the bug in the function so the fix isnt necessary anymore

return menu;
} else {

if (client.getLocalPlayer().getGameMaster()) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to move those things to another class, will do it on a next PR

int lv = nhex.getLevel();
if (lv < level) {
surrounded = false;
if (nhex != null) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another instance where it may very well be null and there was no null guard

* Returns a list of all coordinates at the given distance (dist - 1)
* and anything less than dist as well.
*/
public ArrayList<Coords> allLessThanDistance(int dist) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

places in the code that were using the previous version of the function allAtDistanceOrLess were changed to use this one instead. This implements the behavior that the previous/bugged version had (same functionality)

Comment on lines +4188 to +4190
if (hex == null) {
return false;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another null check guard that was missing

Comment on lines +3326 to +3328
if (destHex == null) {
return false;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really want to give this program a pass with SonarQube

/**
* @author dirk
*/
public class SpecialHexDisplay implements Serializable {
private static final long serialVersionUID = 27470795993329492L;

public enum Type {
ARTILLERY_AUTOHIT(new MegaMekFile(Configuration.hexesDir(), "artyauto.gif").toString()) {
ARTILLERY_AUTOHIT(new MegaMekFile(Configuration.hexesDir(), "artyauto.gif")) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so far, changing this from string to MegaMegFile seem to be working as expected. This also gave more flexibility on how to access those image files.

Comment on lines +270 to +275
public Image getDefaultImage() {
if (type.useFolderStructure()) {
return type.getImage(imageSignature);
}
return type.getDefaultImage();
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allows to access files in folders, very handy for images that are split in multiple pieces

@Scoppio Scoppio added Performance GM Tools All things related to the GM Tools project. labels Nov 17, 2024
@Scoppio Scoppio force-pushed the feature/kill-command branch from aca9459 to 5b203a4 Compare November 17, 2024 12:11
@HammerGS HammerGS removed the For New Dev Cycle This PR should be merged at the beginning of a dev cycle label Nov 17, 2024
@HammerGS
Copy link
Member

I saw the comment about feature creep, and agree that we should pause new things and only work testing things. Then get this merged. Plus of course polishing anything in here that needs polish.

@repligator
Copy link
Collaborator

"You cannot start a fire in a tornado" gets printed to the round report movement phase.

@Scoppio
Copy link
Collaborator Author

Scoppio commented Nov 17, 2024

"You cannot start a fire in a tornado" gets printed to the round report movement phase.

This is interesting and new... the only way for it to print this message is if it tries to ignite a hex, let me run a test here quickly.

@repligator
Copy link
Collaborator

Not-sure-if-intended, but using the commands can cause atmospheric weather in space.
Screenshot_20241117_165336

@Scoppio
Copy link
Collaborator Author

Scoppio commented Nov 17, 2024

Not-sure-if-intended, but using the commands can cause atmospheric weather in space.

Space tornados!!!!

If the server currently allows you to set planetary conditions in space... I'd say its either a feature or a bug, could go both ways. I'm not against it, mostly because I want the tools to give narrative freedom to people.

Fire wont ignite on a tornado

About the cant start fire in a tornado, it seems to be correct IF the current weather is a tornado. It will print in the phase you are, so if you run the command to start a fire or to start a firestorm while a tornado is happening then the server won't allow the hexes to ignite

@repligator
Copy link
Collaborator

Using an orbital bombardment with a larger than default radius will throw a lot of errors in the log, and won't render correctly.

17:03:57,152 ERROR [megamek.common.util.ImageUtil] {AWT-EventQueue-0} megamek.common.util.ImageUtil$AWTImageLoader.loadImage(ImageUtil.java:289) - Trying to load image for a non-existent file data/images/hexes/orbital_bombardment/hit/col_9_row_8_odd.png

Screenshot_20241117_171008

@Scoppio
Copy link
Collaborator Author

Scoppio commented Nov 17, 2024

Fixed error with radius different than 4, it uses the bomb-hit graphic for other radii values (ortillery with default radius keeps the original image)

Added safeguards for the firestorm, firestart and change weather, now they cant be activated when in space (they still work for ground and atmosphere games).

@Scoppio Scoppio force-pushed the feature/kill-command branch from 9efb970 to a2e0cdb Compare November 18, 2024 00:31
@Scoppio Scoppio force-pushed the feature/kill-command branch from a2e0cdb to 7da1ad0 Compare November 18, 2024 00:31
Copy link
Member

@HammerGS HammerGS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and everything seems to work.

Copy link
Member

@HammerGS HammerGS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and everything seems to work.

@HammerGS HammerGS merged commit b33b7a3 into MegaMek:master Nov 23, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GM Tools All things related to the GM Tools project. Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants