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

Carry objects #5706

Merged
merged 40 commits into from
Jul 30, 2024
Merged

Carry objects #5706

merged 40 commits into from
Jul 30, 2024

Conversation

NickAragua
Copy link
Member

@NickAragua NickAragua commented Jul 8, 2024

Implements cargo carrier rules from TW:261 (mechs and protomechs only) and (partly) TOAR:90 (just the part where you can pick up a lighter object with one hand only).

Includes:

  • picking up cargo (mechs and protomechs only)
  • dropping/unloading cargo (drop if you keep moving, unload if it's the last step)
  • can't fire if loaded/unloaded cargo this turn
  • can't fire torso/arm weapons if carrying cargo (can use other arm when carrying really light cargo)
  • cargo will get damaged if the carrying unit is shot at
  • cargo may get destroyed if carrying unit drops it on the move (even more likely when flying/jumping)
  • graphical indicators and reporting of cargo-related activity
  • cargo can be 0-weight and invulnerable
  • if you fall, you drop the cargo

Does not include

  • TSM bonus
  • Loading cargo for non-mech/protomech units

A story told in a few screenshots:

image

image

image

image

image

image

@NickAragua NickAragua added the In Development (Draft) An additional way to mark something as a draft. Make it stand out more. label Jul 8, 2024
@HammerGS
Copy link
Member

Would there be any opportunity in this to handle the Lift Hoists being able to load and carry a unit and drop on the map?

@NickAragua
Copy link
Member Author

Definitely not units. I'll look into Lift Hoists/infantry being able to load cargo in a subsequent pull request.

@NickAragua NickAragua removed the In Development (Draft) An additional way to mark something as a draft. Make it stand out more. label Jul 18, 2024
@NickAragua
Copy link
Member Author

Not quite complete, but can be put through some initial testing/feedback.

return "attacker is evading.";
}

if (!game.getOptions().booleanOption(OptionsConstants.BASE_FRIENDLY_FIRE)) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed this because it's being done in the base class already.

@@ -46,35 +46,27 @@ public ToHitData toHit(Game game) {
*/
protected static String toHitIsImpossible(Game game, Entity ae, Targetable target) {
String physicalImpossible = PhysicalAttackAction.toHitIsImpossible(game, ae, target);
String extendedBladeImpossible = null;
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed this because it's being done in the base class already.

@repligator
Copy link
Collaborator

NPE when creating a 1,000 ton object.
megamek.log

@repligator
Copy link
Collaborator

A "So-and-so" has fled the map, taking (Object) with it message would be nice.

@NickAragua
Copy link
Member Author

Refactored the ICarryable interface so it's part of the BTObject hierarchy.

I'm kind of ambivalent re: camo, as the cargo may not necessarily belong to the player (i.e. scenario rules call for "attacker nominates X squares that contain cargo"). The one thing that I do want to ideally do is have the cargo sprite appear "under" the units rather than over (it looks odd). Any advice on that?

@SJuliez
Copy link
Member

SJuliez commented Jul 26, 2024

Ah ok, I didn't know if they should be player-colored. My intention was more to not keep them this black/white. Giving them a fixed brownish camo (we sure have one) is a simple option. But we can leave that for any point later.

Sprite ordering ... is not in an ideal place. There is Sprite.getSpritePriority() but it is only used with the xyzSpriteHandlers while the older code just draws the sprites according to type. Since the handler sprites are mostly the ones that go over everything (move envelope) they currently draw after the units and it wouldnt be helpful to swap that. I'll take a look if the unit sprites can be added to the allSprites treemap without a big hassle so they would respect draw order, then the sprite priority should help. Will be back on this.

@repligator
Copy link
Collaborator

As of the latest push, the object names are displaying like this
Screenshot_20240726_085242

@NickAragua
Copy link
Member Author

Should be better now. Got a little too overzealous in my refactoring.

@SJuliez
Copy link
Member

SJuliez commented Jul 26, 2024

I have created #5801
That one injects the entity sprites into the AbstractBoardView sprite drawing process and so allows the Carryable sprites to draw under units. You can pull it into this one, if you want. I merged them locally and it seemed to work fine.
(It's draft only so that it doesnt get merged accidentally)

@NickAragua
Copy link
Member Author

Ok, merged #5801 into this one. I think this one's ready to go now.

@SJuliez
Copy link
Member

SJuliez commented Jul 28, 2024

The briefcase sprite doesnt scale with the board zoom.

Suggestion: replace the empty prepare() in GroundObjectSprite with this:

    @Override
    public void prepare() {
        updateBounds();
        image = createNewHexImage();
        Graphics2D graph = (Graphics2D) image.getGraphics();
        UIUtil.setHighQualityRendering(graph);
        graph.scale(bv.scale, bv.scale);
        graph.drawImage(CARGO_IMAGE, 0, 0, null);
    }

:)

@repligator
Copy link
Collaborator

The report for a dropped object seems to get nested under the last physical attack. ID:95 was the one carrying the object.
Screenshot_20240728_064022

@SJuliez
Copy link
Member

SJuliez commented Jul 28, 2024

I'm getting problems when trying to pick up stacked objects, i.e. more than 1 in a hex, specifically a light 2t and a heavy 30t. The game lets me pick up one, no questions asked (as the 30t is too heavy) but it does not really pick it up.

@SJuliez
Copy link
Member

SJuliez commented Jul 28, 2024

Would it make sense to show carried objects in the unit tooltip? (or does it already?)

@SJuliez
Copy link
Member

SJuliez commented Jul 28, 2024

Hoping I'm not missing something that's there already, I feel that it's likely we will at some point want to be able to identify specific carryables and maybe have them have an owner (thinking of capture the flag). May I suggest having ICarryable extend InGameObject instead of BTObject and adding the following to Briefcase.
As currently owner and id arent used anywhere, no other changes are necessary but this adds the infrastructure.

	private int id;
	private int ownerId;
	
	@Override
	public int getId() {
		return id;
	}

	@Override
	public void setId(int newId) {
		this.id = newId;
	}

	@Override
	public int getOwnerId() {
		return ownerId;
	}

	@Override
	public void setOwnerId(int newOwnerId) {
		this.ownerId = newOwnerId;
	}

	@Override
	public int getStrength() {
		return 0;
	}

@NickAragua
Copy link
Member Author

Added sprite scaling and unit tooltip; adjusted the ordering of "cargo dropped" messages during PSR resolution; adjusted object hierarchy; make sure to pick up the correct object when the "default" object being picked up isn't the first in the list.

@NickAragua NickAragua merged commit adae3a1 into master Jul 30, 2024
3 checks passed
@NickAragua NickAragua deleted the carry_objects branch July 30, 2024 20:05
SJuliez added a commit that referenced this pull request Aug 3, 2024
[After #5706] Carryable objects scenario v2 language
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants