• 注册
  • Mod功能提议 Mod功能提议 关注:6005 内容:579

    SPT4.0 模组求助

  • 查看作者
  • 打赏作者
  • 当前位置: ODDBA社区 > 离线版交流区 > Mod功能提议 > 正文
  • 2
  • Mod功能提议
  • 圆转纯熟

    4.0mod要修改保险箱大小要怎么写?有大佬指点一下吗?

      public Task OnLoad()
        {
            _itemsDb = databaseServer.GetTables().Templates.Items;
            var targetItemId = “544a11ac4bdc2d470e8b456a”;
            if(_itemsDb.TryGetValue(targetItemId,out var bbx))
            {
                bbx.Properties.Grids =
               
               
            }

    这是我写的 写到这里就不会了 直接写会报错

    炉火纯青
    2021

    一点都不懂代码。。。我直接偷@等雨停 大佬改背包大小的源代码改的保险箱大小,你看下大佬的源代码有没有思路 [s-2-31]


    #region EditItems 修改物品属性
    /// <summary>
    /// 物品属性修改
    /// </summary>
    private void EditItems()
    {
    if (!modConfig.Items_Enable) return;
    logger.LogWithColor("已启用 物品属性修改", LogTextColor.Yellow);
    var Items = databaseService.GetTables().Templates.Items;
    foreach (var item in Items)
    {
    var id = item.Key;
    var itemData = item.Value;
    var Grids = itemData.Properties?.Grids;

    if (Grids != null)
    {
    #region 给只有一整格的背包扩容
    if (itemData.Parent == "5448e53e4bdc2d60728b4567")
    {
    foreach (var grid in Grids)
    {
    if (Grids.Count() == 1)
    {
    grid.Properties!.CellsH = (int?)Math.Ceiling((grid.Properties.CellsH ?? 0.0) * 1.5 > 6 ? 6 : (grid.Properties.CellsH ?? 0.0) * 1.5); //宽
    grid.Properties.CellsV = (int?)Math.Ceiling((grid.Properties.CellsV ?? 0.0) * 1.5 > 10 ? 10 : (grid.Properties.CellsV ?? 0.0) * 1.5); //高
    }
    grid.Properties!.Filters = [new() { Filter = [new("54009119af1c881c07000029")], ExcludedFilter = [] }]; //去除背包内物品存放限制
    }
    }
    #endregion




    }


    回复
    自成一派
    VIP4
    2021

    var Items = databaseService.GetTables().Templates.Items;

    foreach (var item in Items)

    {

    var idList = new HashSet<MongoId>();

    var itemId = item.Key;

    var itemData = item.Value;

    var itemProperties = itemData.Properties;

    if (itemProperties?.Grids != null)

    {

    var itemGrids = itemProperties?.Grids.ToList();


    #region 所有安全箱

    if (itemData.Parent == "5448bf274bdc2dfc2f8b456a")

    {

    itemProperties!.Weight = -500; //负重

    var cellsH = (int?)(itemGrids[0].Properties.CellsH * 2);

    var cellsV = (int?)(itemGrids[0].Properties.CellsV * 3);

    itemGrids![0].Properties!.CellsH = cellsH > 6 ? 6 : cellsH;

    itemGrids![0].Properties!.CellsV = cellsV > 13 ? 13 : cellsV;

    itemGrids![0].Properties!.Filters = [new() { Filter = [new("54009119af1c881c07000029")], ExcludedFilter = [] }]; //去除安全箱内物品存放限制

    }

    #endregion

    }

    回复

    请登录之后再进行评论

    登录
    离线版交流区
  • 今日 4
  • 内容 10842
  • 关注 6005
  • 聊天
    关注 0

    【招募】GRIFFIN TKF项目开工 期待你的加入 || 你是否想加入格里芬书写自己与人形的故事

    捐助我们

    • 微信
    • 支付宝
  • 签到
  • 任务
  • 发布
  • 模式切换
  • 偏好设置
  • 帖子间隔 侧栏位置: