コード例 #1
0
        //--------------------------------------------------------------------------
        // ● 刷新画面 (物品窗口被激活的情况下)
        //--------------------------------------------------------------------------
        public void update_item()
        {
            // 按下 B 键的情况下
            if (Input.is_trigger(Input.B))
            {
                // 演奏取消 SE
                Global.game_system.se_play(Global.data_system.cancel_se);
                // 切换到菜单画面
                Global.scene = new Scene_Menu(0);
                return;
            }
            // 按下 C 键的情况下
            if (Input.is_trigger(Input.C))
            {
                // 获取物品窗口当前选中的物品数据
                this.item = (RPG.Item) this.item_window.item;
                // 不使用物品的情况下
                if (!(this.item is RPG.Item))
                {
                    // 演奏冻结 SE
                    Global.game_system.se_play(Global.data_system.buzzer_se);
                    return;
                }
                // 不能使用的情况下
                if (!Global.game_party.is_item_can_use(this.item.id))
                {
                    // 演奏冻结 SE
                    Global.game_system.se_play(Global.data_system.buzzer_se);
                    return;
                }
                // 演奏确定 SE
                Global.game_system.se_play(Global.data_system.decision_se);
                // 效果范围是我方的情况下
                if (this.item.scope >= 3)
                {
                    // 激活目标窗口
                    this.item_window.active    = false;
                    this.target_window.x       = (this.item_window.index + 1) % 2 * 304;
                    this.target_window.visible = true;
                    this.target_window.active  = true;
                    // 设置效果范围 (单体/全体) 的对应光标位置
                    if (this.item.scope == 4 || this.item.scope == 6)
                    {
                        this.target_window.index = -1;
                    }
                    else
                    {
                        this.target_window.index = 0;
                    }
                }
                // 效果在我方以外的情况下
                else
                {
                    // 公共事件 ID 有效的情况下
                    if (this.item.common_event_id > 0)
                    {
                        // 预约调用公共事件
                        Global.game_temp.common_event_id = this.item.common_event_id;
                        // 演奏物品使用时的 SE
                        Global.game_system.se_play(this.item.menu_se);
                        // 消耗品的情况下
                        if (this.item.consumable)
                        {
                            // 使用的物品数减 1
                            Global.game_party.lose_item(this.item.id, 1);
                            // 再描绘物品窗口的项目
                            this.item_window.draw_item(this.item_window.index);


                            // 切换到地图画面
                            Global.scene = new Scene_Map();
                            return;
                        }
                    }
                    return;
                }
            }
        }
コード例 #2
0
        //--------------------------------------------------------------------------
        // ● 应用物品效果
        //     item : 物品
        //--------------------------------------------------------------------------
        public bool item_effect(RPG.Item item)
        {
            // 清除会心一击标志
            this.critical = false;
            // 物品的效果范围是 HP 1 以上的己方、自己的 HP 为 0、
            // 或者物品的效果范围是 HP 0 的己方、自己的 HP 为 1 以上的情况下
            if (((item.scope == 3 || item.scope == 4) && this.hp == 0) ||
                ((item.scope == 5 || item.scope == 6) && this.hp >= 1))
            {
                // 过程结束
                return(false);
            }
            // 清除有效标志
            var effective = false;

            // 公共事件 ID 是有效的情况下,设置为有效标志
            effective |= item.common_event_id > 0;
            // 命中判定
            var hit_result = (Global.rand(100) < item.hit);

            // 不确定的特技的情况下设置为有效标志
            effective |= item.hit < 100;
            // 命中的情况
            if (hit_result == true)
            {
                // 计算回复量
                var recover_hp = maxhp * item.recover_hp_rate / 100 + item.recover_hp;
                var recover_sp = maxsp * item.recover_sp_rate / 100 + item.recover_sp;
                if (recover_hp < 0)
                {
                    recover_hp += this.pdef * item.pdef_f / 20;
                    recover_hp += this.mdef * item.mdef_f / 20;
                    recover_hp  = Math.Min(recover_hp, 0);
                }
                // 属性修正
                recover_hp *= elements_correct(item.element_set);
                recover_hp /= 100;
                recover_sp *= elements_correct(item.element_set);
                recover_sp /= 100;
                // 分散
                if (item.variance > 0 && Math.Abs(recover_hp) > 0)
                {
                    var amp = (int)Math.Max(Math.Abs(recover_hp) * item.variance / 100, 1);
                    recover_hp += Global.rand(amp + 1) + Global.rand(amp + 1) - amp;
                }
                if (item.variance > 0 && Math.Abs(recover_sp) > 0)
                {
                    int amp = (int)Math.Max(Math.Abs(recover_sp) * item.variance / 100, 1);
                    recover_sp += Global.rand(amp + 1) + Global.rand(amp + 1) - amp;
                }
                // 回复量符号为负的情况下
                if (recover_hp < 0)
                {
                    // 防御修正
                    if (this.is_guarding)
                    {
                        recover_hp /= 2;
                    }
                }
                // HP 回复量符号的反转、设置伤害值
                this.damage = -recover_hp;
                // HP 以及 SP 的回复
                var last_hp = this.hp;
                var last_sp = this.sp;
                this.hp   += recover_hp;
                this.sp   += recover_sp;
                effective |= this.hp != last_hp;
                effective |= this.sp != last_sp;
                // 状态变化
                this.state_changed = false;
                effective         |= states_plus(item.plus_state_set);
                effective         |= states_minus(item.minus_state_set);
                // 能力上升值有效的情况下
                if (item.parameter_type > 0 && item.parameter_points != 0)
                {
                    // 能力值的分支
                    switch (item.parameter_type)
                    {
                    case 1:      // MaxHP
                        this.maxhp_plus += item.parameter_points; break;

                    case 2:      // MaxSP
                        this.maxsp_plus += item.parameter_points; break;

                    case 3:      // 力量
                        this.str_plus += item.parameter_points; break;

                    case 4:      // 灵巧
                        this.dex_plus += item.parameter_points; break;

                    case 5:      // 速度
                        this.agi_plus += item.parameter_points; break;

                    case 6:      // 魔力
                        this.int_plus += item.parameter_points; break;
                    }
                    // 设置有效标志
                    effective = true;
                }
                // HP 回复率与回复量为 0 的情况下
                if (item.recover_hp_rate == 0 && item.recover_hp == 0)
                {
                    // 设置伤害为空的字符串
                    this.damage = "";
                    // SP 回复率与回复量为 0、能力上升值无效的情况下
                    if (
                        item.recover_sp_rate == 0 && item.recover_sp == 0 &&
                        (item.parameter_type == 0 || item.parameter_points == 0))
                    {
                        // 状态没有变化的情况下
                        if (!this.state_changed)
                        {
                            // 伤害设置为 "Miss"
                            this.damage = "Miss";
                        }
                    }
                }
                // Miss 的情况下
                else
                {
                    // 伤害设置为 "Miss"
                    this.damage = "Miss";
                }
                // 不在战斗中的情况下
                if (!Global.game_temp.in_battle)
                {
                    // 伤害设置为 null
                    this.damage = null;
                }
                // 过程结束
                return(effective);
            }
            return(false);
        }