Anime-Game-Servers / Grasscutter-Quests

A server software implementation, ineroperable with a certain anime game client. The code in this repository is fully custom made for edyoucational purposes and future preservation, no copyrighted code is allowed in this repository.
https://grasscutters.xyz/grasscutter
GNU Affero General Public License v3.0
133 stars 31 forks source link

[Bug] interacting with the items on the table in Custodian of Clouds does nothing #105

Closed scooterboo closed 2 months ago

scooterboo commented 8 months ago

Describe the bug When trying to interact with the items on the able in Custodian of Clouds, nothing happens. image

Notes First of all, the InteractId (Jewelry Soup is 8) of the gadget needs to be sent to the client. This is done on line 280ish of EntityGadget:

        if (this.metaGadget != null) {
            gadgetInfo.setDraftId(this.metaGadget.getDraftId());
            gadgetInfo.setInteractId(this.metaGadget.getInteractId());
        }

After doing that, the client will make a popup when interacting with the gadget: image

When you have the Jewelry Soup, pressing confirm sends a GadgetInteractReq packet from the client:

GadgetInteractReq(gadgetEntityId=67109721, gadgetId=70710120, opType=INTER_OP_START, isUseCondenseResin=false, resinCostType=RESIN_COST_TYPE_NORMAL, uiInteractId=0)

Grasscutter needs to get the gadget's InteractId again. This can be done from the EntityId with something like:

        var entity = session.getPlayer().getScene().getEntityById(req.getGadgetEntityId());
        if(entity instanceof EntityGadget entityGadget){
            var InteractId = entityGadget.getMetaGadget().getInteractId();
        }

If we use that InteractId (of 8) with GadgetInteractExcelConfigData:

    {
        "interactId": 8,
        "actionType": "INTERACT_ACTION_STATE",
        "param1": 201,
        "actionList": [
            {
                "actionType": "INTERACT_ACTION_STATE",
                "param": [
                    201,
                    0
                ]
            }
        ],
        "costItems": [
            {
                "id": 108088,
                "count": 1
            }
        ],
        "uiTitleTextMapHash": 2651015517,
        "uiDescTextMapHash": 3219395005,
        "isMpModeInteract": true
    }

Grasscutter can do the right thing and set the gadget to state 201 and remove one 108088 (Jewelry Soup) from the inventory.

If you set the entity's state to 201 manually with /entity 914001 state201: image

It will appear on the table.

Which branch did you use? multi_proto Grasscutter version: 1.4.4-dev-4e8f709e Lua: JNLua

scooterboo commented 8 months ago

Jewelry soup: /give 108088 1 matsutake meat rolls: /give 108091 1 mora meat: /give 108094 1

scooterboo commented 8 months ago

Similar thing in Chapter 1 Act 3: Equilibrium image

scooterboo commented 4 months ago

Similar thing in Chapter 1 Act 3: Equilibrium image

The gadget type here is a GadgetWorktop. Not a normal GadgetObject. There is an unknown number of types of gadget that check for interact ID. The code needs to be moved to a common place and checked on multiple gadget types.

scooterboo commented 2 months ago

I'll make a new ticket for the bug in Chapter 1 Act 3: Equilibrium I don't want to think about this table any more.