MegaMek / megamek

MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight using giant robots, tanks, and/or infantry on a hex-based map.
http://www.megamek.org
GNU General Public License v2.0
286 stars 276 forks source link

Teach Princess to handle certain units as non-combat regardless of weapons #4308

Open SuperStucco opened 1 year ago

SuperStucco commented 1 year ago

Convoy escort scenarios from MekHQ get a little annoying at times, since Princess likes to do things like rush a MASH truck across the field and straight into enemy fire just because it has a machine gun or two it wants to get into long range (3 or 4 hexes away). That's just following the standard algorithm which assumes everything is reasonably combat oriented. There isn't an easy way to automatically determine which units are genuinely 'combat oriented' and which are not so needs to be done manually by the user.

In the Princess configuration dialog, add a multi-select list of all units that bot player is responsible for. Every entry would be deselected by default for a new bot (e.g. after a /kick and Replace Player... operation), and the user selects the units which Princess should consider non-combat. During the movement phase these units, regardless if they are armed or not, would be considered to have a potential damage of 0 (including physical attacks for Mech-type units). This should put them in the position of only defensive positioning - not getting shot - since they are not considered capable of shooting back. The weapons and physical attack phases are treated as normal, with those units taking shots and using searchlights as warranted.

Thom293 commented 1 year ago

you want this to work on an indiviual unit basis or a bot basis? If a bot basis is fine I can try to test just setting the "run away" number crazy high like I did with berserker and see if that causes them to to avoid combat completely.

kuronekochomusuke commented 1 year ago

there is entity.isMilitary() that may be helpful for this. it uses entity.hasViableWeapons() to check how much damage and range the unit does.

pakfront commented 1 year ago

I agree this feature would be great for AtB. I think setting this per-bot rather than per unit is a good idea. More flexible, more understandable to the user. All non-combat units could be grouped under a non-combat bot. IIRC even fleeing units with the most passive settings will still fire, so it might need to be a feature added to Princess.

Setting per-unit or using an existing flag on units would preclude having the bot use them offensively in last stand scenarios and could have weird affects since the user may not know the value off-hand.

On Tue, Apr 11, 2023 at 08:41 kuronekochomusuke @.***> wrote:

there is entity.isMilitary() that may be helpful for this. it uses entity.hasViableWeapons() to check how much damage and range the unit does.

— Reply to this email directly, view it on GitHub https://github.com/MegaMek/megamek/issues/4308#issuecomment-1503636865, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAK3TODWVW5RV7LJRAOQ66DXAV3SVANCNFSM6AAAAAAWZ7QWI4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

SuperStucco commented 1 year ago

you want this to work on an indiviual unit basis or a bot basis? If a bot basis is fine I can try to test just setting the "run away" number crazy high like I did with berserker and see if that causes them to to avoid combat completely.

Not exactly. The standard algorithm processes both offensive and defensive positioning. I want it to ignore offense entirely even if weapons are present. Since the forces generated can include things like primitive Mechs, armed flatbed trucks, and IndustrialMech MODs which should still be trying to stay out of the way and/or protecting the unarmed units rather than angling for any kind of shot.

Setting per-unit or using an existing flag on units would preclude having the bot use them offensively in last stand scenarios and could have weird affects since the user may not know the value off-hand.

No, if it comes down to that it's a matter of /kick and Replace Player... to institute new settings. If some of the other proposals are implemented, such as scripting/toggling settings when conditions are met that would work the same way except automatically. There's also the consideration of such units surrendering to the attackers rather than fighting to the end or fleeing when things get that bad for them.

IIRC even fleeing units with the most passive settings will still fire, so it might need to be a feature added to Princess.

Just to be clear, firing during the weapons phase isn't a problem. They can still attack targets of opportunity and use searchlights. It's just to remove the positioning for offensive capabilities during the movement phase.

HammerGS commented 1 year ago

There was an old file that helped with this. See attached used in be in the MM repo, but looks like its in the MekHQ repo, but hasn't been updated in years.

Also in the Force Generator files there are various tags that can be set for units, which would also help with this. But it's a HUGE job to maintain these files and I'm the only data person. I just don't have the time to handle all of this, and requests for community help have met with limited success.

These are the roles that can be set and assigned to specific units.

   'role' element: comma-separated list of roles the variant was designed for.
        comma-separated list of roles the variant was designed for. Supported values are:
        fire_support - focus on long range firepower
        sr_fire_support - focus on short range firepower
        infantry_support - commonly found supporting infantry formations
        ew_support - carries additional electronics for ECM, scanning, or command functions
        spotter - carries TAG or equivalent, such as C3 master
        incindiary - can easily set fires
        mag_clamp - battle armor or ProtoMek with magnetic clamps
        artillery - carries tube artillery or artillery cannon
        missile_artillery - carries missile artillery, typically Arrow IV
        minesweeper - can clear mines
        minelayer - can lay mines
        anti_aircraft - special anti-aircraft targeting or flak-coded weapons
        anti_infantry - focus on fighting conventional infantry
        apc - vehicle can carry infantry or battle armor internally
        specops - more focus on stealth than combat
        urban - normally used for urban combat
        recon - speed and detection gear over firepower
        cavalry - speed and firepower
        command - has 'Command Mek' quirk, C3 master, or is otherwise commonly used as a commanders ride
        raider - focus on speed and ammo independence
        engineer - various combat support engineering roles, such as fieldworks and bridge layers
        cargo - primarily a cargo mover, or has large cargo capacity
        support - primary role is noncombat
        civilian - non-military vehicles
        training - historically used for training purposes rather than regular combat
        bomber - focus on bomb delivery
        interceptor - focus on attacking other aerospace units
        ground_support - focus on ground units
        assault - focus on heavy firepower
        escort - small craft and fighters designed to protect others
        mech_carrier - has Mek bays
        asf_carrier - has aerospace bays
        vee_carrier - has vehicle bays
        infantry_carrier - has infantry bays
        troop_carrier - has both infantry and vehicle bays
        ba_carrier - has battle armor bays
        tug - has tug adaptor
        pocket ws - pocket warship DropShip
        corvette - WarShip class
        destroyer - WarShip class
        frigate - WarShip class
        cruiser - WarShip class
        battleship - WarShip class
        marine - conventional infantry that can fight in vacuum
        mountaineer - conventional infantry with mountaineer specialty
        xct - conventional infantry that can survive hostile environments
        paratrooper - conventional non-jump infantry that can be air dropped
        anti_mek - conventional infantry that can perform anti-mek attacks
        field_gun - motorized or mechanized infantry with a towed ballistic or artillery weapon

non_combat_units_list.zip

SuperStucco commented 1 year ago

I try to keep the role entries up to date with my own custom forcegenerator XMLs. Most of the support units don't have an entry in the forcegenerator files, and MekHQ uses the ...\Against the Bot\CivilianUnits.txt RAT files for generating convoy formations.

While I would LOVE to consolidate the separate civilian unit RAT files into the forcegenerator system so everything operates the same way, it would be a huge undertaking in data entry. If someone were to get started on the code for that I would have no problems contributing on the data entry side since I probably spend more time in those files than anyone else.