- 注册时间
- 2004-12-19
- 最后登录
- 2006-11-15
⑤进阶
- 积分
- 930
|

楼主 |
发表于 2006-11-23 04:16:06
|
显示全部楼层
写了下看看,把物品的价格后3位占用了。
现在物品的价格 = 价格 / 1000 * 1000,如果不足1000就是0了,价格最小单位是1000(*100的话就是100,不过只能到5位字)
具体作用:
个位和十位 - 消耗弹药的物品编号 - 50
百位 - 消耗数量
举例说明下:
20301的某武器,实际价格是20000,它消耗弹药是道具里面的51号,每次消耗3个;
12000的某武器,实际价格12000,不消耗任何弹药。
修改的脚本:
1、Game_Actor类
#--------------------------------------------------------------------------
# ● 获取当前武器的弹药id
#--------------------------------------------------------------------------
def ammo_id
weapon = $data_weapons[@weapon_id]
if weapon != nil
return (weapon.price % 100) + 50
end
return 0
end
#--------------------------------------------------------------------------
# ● 获取当前武器的弹药消耗需求
#--------------------------------------------------------------------------
def ammo_req
weapon = $data_weapons[@weapon_id]
if weapon != nil
return weapon.price % 1000 / 100
end
return 0
end
#--------------------------------------------------------------------------
# ● 消耗弹药
#--------------------------------------------------------------------------
def use_ammo
$game_party.lose_item(ammo_id, ammo_req)
end
#--------------------------------------------------------------------------
# ● 武器是否可用
#--------------------------------------------------------------------------
def weapon_available?
weapon = $data_weapons[@weapon_id]
#没有武器
if weapon == nil
return false
end
#弹药ID是0为该武器不使用弹药的情况
#否则判断弹药道具的数量是否足够消耗
if ammo_id == 0 or $game_party.item_number(ammo_id) >= ammo_req
return true
end
#其他否则,判断为不可用
return false
end
#--------------------------------------------------------------------------
# ● 获取空手攻击力,武器损坏或者无弹药可以使用
#--------------------------------------------------------------------------
def _bare_atk
####return base_str ** 0.5 * 10 #力量加成
return 0
end
#--------------------------------------------------------------------------
# ● 获取基本攻击力
#--------------------------------------------------------------------------
def base_atk
weapon = $data_weapons[@weapon_id]
return weapon_available? ? weapon.atk + _bare_atk : _bare_atk
end
2、Scene_Battle_4,make_basic_action_result,这行后面修正攻击动画,
即没有弹药情况下改用空手攻击效果,否则设置为武器攻击的动画,
并且,攻击之后要执行use_ammo来实现弹药消耗
# 行动方的战斗者是角色的情况下
if @active_battler.is_a?(Game_Actor)
# 设置攻击 ID,是否有武器的情况
if @active_battler.weapon_available?
@animation1_id = @active_battler.animation1_id
@animation2_id = @active_battler.animation2_id
else
@animation1_id = 0
@animation2_id = 0
end
...
# 应用通常攻击效果
for target in @target_battlers
target.attack_effect(@active_battler)
end
#消耗弹药1次
if @active_battler.is_a?(Game_Actor) and @active_battler.weapon_available?
@active_battler.use_ammo
end
3、Scene_Shop和Window_Buy等类,牵扯价格显示和计算的地方相应处理,不再冗述。 |
|