randovania / randomprime

Prime1 patcher for Randovania and a few other things.
MIT License
2 stars 3 forks source link

Custom item support #93

Closed UltiNaruto closed 2 weeks ago

UltiNaruto commented 3 months ago

Required mains supported for Missiles/PB Unlimited Missiles/PBs are supported now Spring Ball has its own item now

UltiNaruto commented 3 months ago

Non required mains seeds need to set unknown1 (which is Unknown Item 2) in starting items to 12 (4 | 8 => Missile Launcher | Power Bomb Launcher).

If you only require mains for missile then it is 8. If you only require mains for PB then it is 4.

UltiNaruto commented 3 months ago

Migrated Ice Trap from Special Function to Pickup and it doesn't require enable_ice_trap in config anymore

toasterparty commented 2 months ago

@UltiNaruto PLEASE do not force-push when updating your changes. It makes it hard for me to incrementally review your work (otherwise I have to double over all lines of your code each feedback iteration)

toasterparty commented 2 months ago

Actually, I forgot you may have told me a way to see the old code for force push. It might be fine

toasterparty commented 2 months ago
UltiNaruto commented 2 months ago

So things are less confusing moving forwards, can you rename unknown0 and unknown1 in spawn_point.rs to unknown1 and unknown2? We should be consistent with where we start count from and I think it's pretty well established we start at 1 when talking about inventory items,

Make sure the JSON input also reflects this change.

unknown1 or unknownItem1?

toasterparty commented 2 months ago

unknownItem1

toasterparty commented 2 months ago

Actually, @UltiNaruto we should deprecated game_config.spring_ball and default game_config.spring_ball_item to the custom pickup.

Sorry for the flip flop, caffine still kicking in

duncathan commented 2 months ago

Actually, @UltiNaruto we should deprecated game_config.spring_ball and default game_config.spring_ball_item to the custom pickup.

Sorry for the flip flop, caffine still kicking in

Would it perhaps be preferable to default it to bombs, for backwards compatibility?

toasterparty commented 2 months ago

To preserve backwards compatibility, make it so that springBall: true sets springBallItem: Bombs.

UltiNaruto commented 2 months ago

I thought about another idea. What about making springBall default to false and if it's set to true with a pickup having SpringBall as its type then it complains about both being used?

springBall would remain useable and not deprecated but using both makes the patcher panic with the following message Use either springBall or add a pickup as SpringBall type

As for using SpringBall type for pickups, it would detect it then change springBall to true and springBallItem to SpringBall.

toasterparty commented 2 months ago

@UltiNaruto I really think this is the best option, please implement it:

  1. Deprecate springBall in the JSON schema and remove all if config.spring_ball conditions
  2. Add springBallItem to the JSON schema with "default": "Spring Ball"
  3. Add the following
let spring_ball_item = match spring_ball_item {
    Some(spring_ball_item) => spring_ball_item,
    None => {
        match spring_ball {
            false => "Spring Ball",
            true => "Morph Ball Bombs",
        }
    },
}
UltiNaruto commented 2 months ago

Up to you. I'll do that then.

UltiNaruto commented 2 months ago

I'm pretty happy with the code but in my testing startingItems isn't working. Please check using this JSON file which should start with all the custom items.

{
    "$schema": "./schema/randomprime.schema.json",
    "gameConfig": {
        "startingRoom": "Tallon Overworld:Arbor Chamber",
        "startingItems": {
            "combatVisor": true,
            "powerBeam": true,
            "scanVisor": true,
            "missiles": 10,
            "energyTanks": 0,
            "powerBombs": 8,
            "wave": false,
            "ice": false,
            "plasma": false,
            "charge": false,
            "morphBall": true,
            "bombs": false,
            "spiderBall": false,
            "boostBall": false,
            "powerSuit": 0,
            "variaSuit": false,
            "gravitySuit": false,
            "phazonSuit": false,
            "thermalVisor": false,
            "xray": false,
            "spaceJump": true,
            "grapple": false,
            "superMissile": false,
            "wavebuster": false,
            "iceSpreader": false,
            "flamethrower": false,
            "unknownItem1": 0,
            "unlimitedMissiles": true,
            "unlimitedPowerBombs": true,
            "missileLauncher": true,
            "powerBombLauncher": true,
            "springBall": true
        }
    },
    "levelData": {
        "Tallon Overworld": {
            "rooms": {
                "Arbor Chamber": {
                    "pickups": [
                        {
                            "type": "Spring Ball"
                        },
                        {
                            "type": "Main Power Bomb",
                            "position": [-723.6977, 334.1136, 40.2428]
                        },
                        {
                            "type": "Missile Launcher",
                            "position": [-723.6977, 329.1136, 40.2428]
                        },
                        {
                            "type": "Unlimited Missiles",
                            "position": [-723.6977, 344.1136, 40.2428]
                        },
                        {
                            "type": "Unlimited Power Bombs",
                            "position": [-723.6977, 349.1136, 40.2428]
                        }
                    ]
                }
            }
        }
    }
}

Also, please update use the struct to define starting items rather than u64 so that the player spawns with missile/pb launcher if left unspecified

let starting_items = {
    let items = self.game_config.starting_items.as_ref();

    match items {
        Some(items) => items.clone(),
        None => {
            if force_vanilla_layout {
                StartingItems::from_u64(2188378143)
            } else {
                StartingItems::from_u64(1)
            }
        }
    }
};

don't forget to add item max capacity 2^31 else unknown item 2 cannot be set since it defaults to 0 max


{
    "$schema": "./schema/randomprime.schema.json",
    "gameConfig": {
        "startingRoom": "Tallon Overworld:Arbor Chamber",
        "startingItems": {
            "combatVisor": true,
            "powerBeam": true,
            "scanVisor": true,
            "missiles": 10,
            "energyTanks": 0,
            "powerBombs": 8,
            "wave": false,
            "ice": false,
            "plasma": false,
            "charge": false,
            "morphBall": true,
            "bombs": false,
            "spiderBall": false,
            "boostBall": false,
            "powerSuit": 0,
            "variaSuit": false,
            "gravitySuit": false,
            "phazonSuit": false,
            "thermalVisor": false,
            "xray": false,
            "spaceJump": true,
            "grapple": false,
            "superMissile": false,
            "wavebuster": false,
            "iceSpreader": false,
            "flamethrower": false,
            "unknownItem1": 0,
            "unlimitedMissiles": true,
            "unlimitedPowerBombs": true,
            "missileLauncher": true,
            "powerBombLauncher": true,
            "springBall": true
        },
        "itemMaxCapacity": {
            "Unknown Item 2": 2147483647
        }
    },
    "levelData": {
        "Tallon Overworld": {
            "rooms": {
                "Arbor Chamber": {
                    "pickups": [
                        {
                            "type": "Spring Ball"
                        },
                        {
                            "type": "Main Power Bomb",
                            "position": [-723.6977, 334.1136, 40.2428]
                        },
                        {
                            "type": "Missile Launcher",
                            "position": [-723.6977, 329.1136, 40.2428]
                        },
                        {
                            "type": "Unlimited Missiles",
                            "position": [-723.6977, 344.1136, 40.2428]
                        },
                        {
                            "type": "Unlimited Power Bombs",
                            "position": [-723.6977, 349.1136, 40.2428]
                        }
                    ]
                }
            }
        }
    }
}```
toasterparty commented 2 months ago

@UltiNaruto the default max capacity for unknown2 should change then because that was really unintuitive

UltiNaruto commented 2 months ago

fixed the starting custom item issue

UltiNaruto commented 2 months ago

@UltiNaruto the default max capacity for unknown2 should change then because that was really unintuitive

Defaults to 1 in the schema

UltiNaruto commented 2 months ago

Do we want just to change the schema or add unknown item 2 if it's not specified in patch_config.rs?

toasterparty commented 2 months ago

We'll need to always patch unknown_item_2 regardless if it's in the JSON or not.

I'm defining "backwards compatible" here as "not fundamentally changing the behavior of explicitly named JSON properties". That means changing the default value used for an unspecified property is a non-breaking change.

UltiNaruto commented 2 months ago

now the patch config will auto add Unknown Item 2 with the correct value if it's not specified. also I fixed the negative capacity patch for custom items which will properly remove the custom item.

UltiNaruto commented 2 months ago

Fixed it. It was just missing a value & 1 to prevent the value to be higher than 1.

UltiNaruto commented 3 weeks ago

It works as intended for underwater remove floaty but it does +2 for fluid count when picking up non removal one. I'll fix that one.

UltiNaruto commented 3 weeks ago

Well nvm it wasn't recompiled to latest version. I'll add a out of water ticks check to fluid count decrement.